Window with everything an AI prints via ScriptLog. More...
Public Member Functions | |
ScriptLog::LogData * | GetLogPointer () const |
bool | IsDead () const |
Check whether the currently selected AI/GS is dead. | |
bool | IsValidDebugCompany (CompanyID company) const |
Check whether a company is a valid AI company or GS. | |
void | SelectValidDebugCompany () |
Ensure that ai_debug_company refers to a valid AI company or GS, or is set to INVALID_COMPANY. | |
AIDebugWindow (const WindowDesc *desc, WindowNumber number) | |
Constructor for the window. | |
virtual void | UpdateWidgetSize (int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) |
Update size and resize step of a widget in the window. | |
virtual void | OnPaint () |
The window must be repainted. | |
virtual void | SetStringParameters (int widget) const |
Initialize string parameters for a widget. | |
virtual void | DrawWidget (const Rect &r, int widget) const |
Draw the contents of a nested widget. | |
void | ChangeToAI (CompanyID show_ai) |
Change all settings to select another AI. | |
virtual void | OnClick (Point pt, int widget, int click_count) |
A click with the left mouse button has been made on the window. | |
virtual EventState | OnKeyPress (uint16 key, uint16 keycode) |
A key has been pressed. | |
virtual void | OnEditboxChanged (int wid) |
The text in an editbox has been edited. | |
virtual void | OnInvalidateData (int data=0, bool gui_scope=true) |
Some data on this window has become invalid. | |
virtual void | OnResize () |
Called after the window got resized. | |
Data Fields | |
int | redraw_timer |
Timer for redrawing the window, otherwise it'll happen every tick. | |
int | last_vscroll_pos |
Last position of the scrolling. | |
bool | autoscroll |
Whether automatically scrolling should be enabled or not. | |
bool | show_break_box |
Whether the break/debug box is visible. | |
QueryString | break_editbox |
Break editbox. | |
int | highlight_row |
The output row that matches the given string, or -1. | |
Scrollbar * | vscroll |
Cache of the vertical scrollbar. | |
Static Public Attributes | |
static const int | top_offset = WD_FRAMERECT_TOP + 2 |
Offset of the text at the top of the WID_AID_LOG_PANEL. | |
static const int | bottom_offset = WD_FRAMERECT_BOTTOM |
Offset of the text at the bottom of the WID_AID_LOG_PANEL. | |
static const unsigned int | MAX_BREAK_STR_STRING_LENGTH = 256 |
Maximum length of the break string. | |
static CompanyID | ai_debug_company = INVALID_COMPANY |
The AI that is (was last) being debugged. | |
static bool | break_check_enabled = true |
Stop an AI when it prints a matching string. | |
static char | break_string [MAX_BREAK_STR_STRING_LENGTH] = "" |
The string to match to the AI output. | |
static StringFilter | break_string_filter |
Log filter for break. | |
static bool | case_sensitive_break_check = false |
Is the matching done case-sensitive. | |
static Hotkey< AIDebugWindow > | aidebug_hotkeys [] |
Window with everything an AI prints via ScriptLog.
Definition at line 965 of file ai_gui.cpp.
AIDebugWindow::AIDebugWindow | ( | const WindowDesc * | desc, | |
WindowNumber | number | |||
) | [inline] |
Constructor for the window.
desc | The description of the window. | |
number | The window number (actually unused). |
Definition at line 1045 of file ai_gui.cpp.
References _settings_client, GUISettings::ai_developer_tools, Textbuf::Assign(), autoscroll, break_check_enabled, break_editbox, break_string, Window::CreateNestedTree(), Window::FinishInitNested(), Window::GetScrollbar(), ClientSettings::gui, highlight_row, Window::InvalidateData(), last_vscroll_pos, Window::querystrings, SelectValidDebugCompany(), show_break_box, SZSP_HORIZONTAL, vscroll, and WID_AID_SCROLLBAR.
void AIDebugWindow::ChangeToAI | ( | CompanyID | show_ai | ) | [inline] |
Change all settings to select another AI.
show_ai | The new AI to show. |
Definition at line 1219 of file ai_gui.cpp.
References ai_debug_company, autoscroll, DeleteWindowByClass(), Scrollbar::GetPosition(), highlight_row, Window::InvalidateData(), IsValidDebugCompany(), last_vscroll_pos, vscroll, and WC_AI_SETTINGS.
Referenced by OnClick(), SelectValidDebugCompany(), and ShowAIDebugWindow().
virtual void AIDebugWindow::DrawWidget | ( | const Rect & | r, | |
int | widget | |||
) | const [inline, virtual] |
Draw the contents of a nested widget.
r | Rectangle occupied by the widget. | |
widget | Number of the widget to draw. |
Reimplemented from Window.
Definition at line 1177 of file ai_gui.cpp.
References ai_debug_company, DrawString(), Scrollbar::GetPosition(), GfxFillRect(), highlight_row, INVALID_COMPANY, Scrollbar::IsVisible(), PC_BLACK, Window::resize, SA_FORCE, SA_LEFT, ResizeInfo::step_height, top_offset, vscroll, WD_PAR_VSEP_NORMAL, and WID_AID_LOG_PANEL.
bool AIDebugWindow::IsDead | ( | ) | const [inline] |
Check whether the currently selected AI/GS is dead.
Definition at line 994 of file ai_gui.cpp.
References ai_debug_company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Game::GetInstance(), ScriptInstance::IsDead(), Company::IsValidAiID(), and OWNER_DEITY.
Referenced by OnClick(), and OnInvalidateData().
bool AIDebugWindow::IsValidDebugCompany | ( | CompanyID | company | ) | const [inline] |
Check whether a company is a valid AI company or GS.
company | Company to check for validity. |
Definition at line 1008 of file ai_gui.cpp.
References Game::GetInstance(), INVALID_COMPANY, Company::IsValidAiID(), and OWNER_DEITY.
Referenced by ChangeToAI(), OnInvalidateData(), and SelectValidDebugCompany().
virtual void AIDebugWindow::OnClick | ( | Point | pt, | |
int | widget, | |||
int | click_count | |||
) | [inline, virtual] |
A click with the left mouse button has been made on the window.
pt | the point inside the window that has been clicked. | |
widget | the clicked widget. | |
click_count | Number of fast consecutive clicks at same position |
Reimplemented from Window.
Definition at line 1236 of file ai_gui.cpp.
References _pause_mode, ai_debug_company, break_check_enabled, case_sensitive_break_check, ChangeToAI(), CMD_COMPANY_CTRL, CMD_PAUSE, CRR_MANUAL, DoCommandP(), highlight_row, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Window::InvalidateData(), CompanyProperties::is_ai, IsDead(), IsInsideMM(), AI::IsPaused(), Game::IsPaused(), Window::IsWidgetDisabled(), OWNER_DEITY, PM_PAUSED_NORMAL, ShowAISettingsWindow(), AI::Unpause(), Game::Unpause(), WID_AID_BREAK_STR_ON_OFF_BTN, WID_AID_COMPANY_BUTTON_END, WID_AID_COMPANY_BUTTON_START, WID_AID_CONTINUE_BTN, WID_AID_MATCH_CASE_BTN, WID_AID_RELOAD_TOGGLE, WID_AID_SCRIPT_GAME, and WID_AID_SETTINGS.
Referenced by OnKeyPress().
virtual void AIDebugWindow::OnEditboxChanged | ( | int | widget | ) | [inline, virtual] |
The text in an editbox has been edited.
widget | The widget of the editbox. |
Reimplemented from Window.
Definition at line 1323 of file ai_gui.cpp.
References break_editbox, break_string, break_string_filter, Textbuf::buf, lastof, StringFilter::SetFilterTerm(), strecpy(), and WID_AID_BREAK_STR_EDIT_BOX.
virtual void AIDebugWindow::OnInvalidateData | ( | int | data = 0 , |
|
bool | gui_scope = true | |||
) | [inline, virtual] |
Some data on this window has become invalid.
data | Information about the changed data. This is the company ID of the AI/GS which wrote a new log message, or -1 in other cases. | |
gui_scope | Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See InvalidateWindowData() for details. |
Reimplemented from Window.
Definition at line 1338 of file ai_gui.cpp.
References _pause_mode, StringFilter::AddLine(), ai_debug_company, break_check_enabled, break_string_filter, case_sensitive_break_check, CMD_PAUSE, COMPANY_FIRST, DoCommandP(), Game::GetGameInstance(), StringFilter::GetState(), highlight_row, INVALID_COMPANY, IsDead(), StringFilter::IsEmpty(), AI::IsPaused(), Game::IsPaused(), Company::IsValidAiID(), IsValidDebugCompany(), OWNER_DEITY, AI::Pause(), Game::Pause(), PM_PAUSED_NORMAL, PM_UNPAUSED, StringFilter::ResetState(), SelectValidDebugCompany(), Scrollbar::SetCount(), Window::SetWidgetDisabledState(), Window::SetWidgetLoweredState(), vscroll, WID_AID_BREAK_STR_ON_OFF_BTN, WID_AID_COMPANY_BUTTON_START, WID_AID_CONTINUE_BTN, WID_AID_MATCH_CASE_BTN, WID_AID_RELOAD_TOGGLE, WID_AID_SCRIPT_GAME, and WID_AID_SETTINGS.
virtual EventState AIDebugWindow::OnKeyPress | ( | uint16 | key, | |
uint16 | keycode | |||
) | [inline, virtual] |
A key has been pressed.
key | the Unicode value of the key. | |
keycode | the untranslated key code including shift state. |
Reimplemented from Window.
Definition at line 1306 of file ai_gui.cpp.
References CheckHotkeyMatch(), OnClick(), Window::SetFocusedWidget(), SetFocusedWindow(), show_break_box, WID_AID_BREAK_STR_EDIT_BOX, and WID_AID_BREAK_STRING_WIDGETS.
virtual void AIDebugWindow::OnPaint | ( | ) | [inline, virtual] |
The window must be repainted.
Reimplemented from Window.
Definition at line 1076 of file ai_gui.cpp.
References ai_debug_company, autoscroll, COMPANY_FIRST, NWidgetBase::current_x, DrawCompanyIcon(), Window::DrawWidgets(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Scrollbar::GetCapacity(), Scrollbar::GetCount(), Game::GetInstance(), Scrollbar::GetPosition(), INVALID_COMPANY, Window::InvalidateData(), ScriptInstance::IsDead(), NWidgetCore::IsDisabled(), ScriptInstance::IsPaused(), Window::IsShaded(), Company::IsValidAiID(), last_vscroll_pos, max(), NWidgetBase::pos_x, SelectValidDebugCompany(), Scrollbar::SetCount(), Scrollbar::SetPosition(), SetScriptButtonColour(), Window::SetWidgetDirty(), valid, vscroll, WID_AID_COMPANY_BUTTON_START, WID_AID_LOG_PANEL, and WID_AID_SCROLLBAR.
virtual void AIDebugWindow::OnResize | ( | ) | [inline, virtual] |
Called after the window got resized.
For nested windows with a viewport, call NWidgetViewport::UpdateViewportCoordinates.
Reimplemented from Window.
Definition at line 1395 of file ai_gui.cpp.
References Scrollbar::SetCapacityFromWidget(), vscroll, and WID_AID_LOG_PANEL.
void AIDebugWindow::SelectValidDebugCompany | ( | ) | [inline] |
Ensure that ai_debug_company
refers to a valid AI company or GS, or is set to INVALID_COMPANY.
If no valid company is selected, it selects the first valid AI or GS if any.
Definition at line 1021 of file ai_gui.cpp.
References ai_debug_company, ChangeToAI(), Game::GetInstance(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, CompanyProperties::is_ai, IsValidDebugCompany(), and OWNER_DEITY.
Referenced by AIDebugWindow(), OnInvalidateData(), and OnPaint().
virtual void AIDebugWindow::SetStringParameters | ( | int | widget | ) | const [inline, virtual] |
Initialize string parameters for a widget.
Calls to this function are made during initialization to measure the size (that is as part of InitNested()), during drawing, and while re-initializing the window. Only for widgets that render text initializing is requested.
widget | Widget number. |
Reimplemented from Window.
Definition at line 1154 of file ai_gui.cpp.
References ai_debug_company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Game::GetInfo(), ScriptInfo::GetName(), ScriptInfo::GetVersion(), INVALID_COMPANY, Company::IsValidAiID(), OWNER_DEITY, SetDParam(), SetDParamStr(), and WID_AID_NAME_TEXT.
virtual void AIDebugWindow::UpdateWidgetSize | ( | int | widget, | |
Dimension * | size, | |||
const Dimension & | padding, | |||
Dimension * | fill, | |||
Dimension * | resize | |||
) | [inline, virtual] |
Update size and resize step of a widget in the window.
After retrieval of the minimal size and the resize-steps of a widget, this function is called to allow further refinement, typically by computing the real maximal size of the content. Afterwards, size is taken to be the minimal size of the widget and resize is taken to contain the resize steps. For the convenience of the callee, padding contains the amount of padding between the content and the edge of the widget. This should be added to the returned size.
widget | Widget number. | |
size | Size of the widget. | |
padding | Recommended amount of space between the widget content and the widget edge. | |
fill | Fill step of the widget. | |
resize | Resize step of the widget. |
Reimplemented from Window.
Definition at line 1068 of file ai_gui.cpp.
References bottom_offset, FONT_HEIGHT_NORMAL, top_offset, and WID_AID_LOG_PANEL.
Hotkey< AIDebugWindow > AIDebugWindow::aidebug_hotkeys [static] |
{ Hotkey<AIDebugWindow>('1', "company_1", WID_AID_COMPANY_BUTTON_START), Hotkey<AIDebugWindow>('2', "company_2", WID_AID_COMPANY_BUTTON_START + 1), Hotkey<AIDebugWindow>('3', "company_3", WID_AID_COMPANY_BUTTON_START + 2), Hotkey<AIDebugWindow>('4', "company_4", WID_AID_COMPANY_BUTTON_START + 3), Hotkey<AIDebugWindow>('5', "company_5", WID_AID_COMPANY_BUTTON_START + 4), Hotkey<AIDebugWindow>('6', "company_6", WID_AID_COMPANY_BUTTON_START + 5), Hotkey<AIDebugWindow>('7', "company_7", WID_AID_COMPANY_BUTTON_START + 6), Hotkey<AIDebugWindow>('8', "company_8", WID_AID_COMPANY_BUTTON_START + 7), Hotkey<AIDebugWindow>('9', "company_9", WID_AID_COMPANY_BUTTON_START + 8), Hotkey<AIDebugWindow>((uint16)0, "company_10", WID_AID_COMPANY_BUTTON_START + 9), Hotkey<AIDebugWindow>((uint16)0, "company_11", WID_AID_COMPANY_BUTTON_START + 10), Hotkey<AIDebugWindow>((uint16)0, "company_12", WID_AID_COMPANY_BUTTON_START + 11), Hotkey<AIDebugWindow>((uint16)0, "company_13", WID_AID_COMPANY_BUTTON_START + 12), Hotkey<AIDebugWindow>((uint16)0, "company_14", WID_AID_COMPANY_BUTTON_START + 13), Hotkey<AIDebugWindow>((uint16)0, "company_15", WID_AID_COMPANY_BUTTON_START + 14), Hotkey<AIDebugWindow>('S', "settings", WID_AID_SETTINGS), Hotkey<AIDebugWindow>('0', "game_script", WID_AID_SCRIPT_GAME), Hotkey<AIDebugWindow>((uint16)0, "reload", WID_AID_RELOAD_TOGGLE), Hotkey<AIDebugWindow>('B', "break_toggle", WID_AID_BREAK_STR_ON_OFF_BTN), Hotkey<AIDebugWindow>('F', "break_string", WID_AID_BREAK_STR_EDIT_BOX), Hotkey<AIDebugWindow>('C', "match_case", WID_AID_MATCH_CASE_BTN), Hotkey<AIDebugWindow>(WKC_RETURN, "continue", WID_AID_CONTINUE_BTN), }
Definition at line 1400 of file ai_gui.cpp.