Window with everything an AI prints via ScriptLog. More...
Public Member Functions | |
ScriptLog::LogData * | GetLogPointer () const |
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 995 of file ai_gui.cpp.
References _settings_client, ai_debug_company, GUISettings::ai_developer_tools, Textbuf::Assign(), autoscroll, break_check_enabled, break_editbox, break_string, case_sensitive_break_check, COMPANY_FIRST, Window::CreateNestedTree(), Window::DisableWidget(), Window::EnableWidget(), Window::FinishInitNested(), Window::GetScrollbar(), ClientSettings::gui, highlight_row, INVALID_COMPANY, AI::IsPaused(), Game::IsPaused(), Company::IsValidAiID(), last_vscroll_pos, Window::LowerWidget(), OWNER_DEITY, Window::querystrings, Window::SetWidgetDisabledState(), Window::SetWidgetLoweredState(), show_break_box, SZSP_HORIZONTAL, 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, WID_AID_SCROLLBAR, and WID_AID_SETTINGS.
void AIDebugWindow::ChangeToAI | ( | CompanyID | show_ai | ) | [inline] |
Change all settings to select another AI.
show_ai | The new AI to show. |
Definition at line 1221 of file ai_gui.cpp.
References ai_debug_company, autoscroll, DeleteWindowByClass(), Scrollbar::GetPosition(), highlight_row, AI::IsPaused(), Game::IsPaused(), last_vscroll_pos, Window::LowerWidget(), OWNER_DEITY, Window::RaiseWidget(), Scrollbar::SetCount(), Window::SetDirty(), Window::SetWidgetDisabledState(), vscroll, WC_AI_SETTINGS, WID_AID_COMPANY_BUTTON_START, WID_AID_CONTINUE_BTN, and WID_AID_SCRIPT_GAME.
Referenced by OnClick(), 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 1179 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.
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 1249 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, Window::DisableWidget(), DoCommandP(), highlight_row, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, CompanyProperties::is_ai, IsInsideMM(), AI::IsPaused(), Game::IsPaused(), Window::IsWidgetDisabled(), OWNER_DEITY, PM_PAUSED_NORMAL, Window::SetWidgetDirty(), Window::SetWidgetLoweredState(), 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_LOG_PANEL, 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 1339 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. | |
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 1353 of file ai_gui.cpp.
References _pause_mode, StringFilter::AddLine(), ai_debug_company, break_check_enabled, break_string_filter, CMD_PAUSE, DoCommandP(), Window::EnableWidget(), StringFilter::GetState(), highlight_row, StringFilter::IsEmpty(), OWNER_DEITY, AI::Pause(), Game::Pause(), PM_PAUSED_NORMAL, PM_UNPAUSED, StringFilter::ResetState(), Window::SetDirty(), Window::SetWidgetDirty(), and WID_AID_CONTINUE_BTN.
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 1322 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 1043 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::GetGameInstance(), Game::GetInstance(), Scrollbar::GetPosition(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_COMPANY, CompanyProperties::is_ai, ScriptInstance::IsDead(), NWidgetCore::IsDisabled(), ScriptInstance::IsPaused(), Window::IsShaded(), Company::IsValidAiID(), last_vscroll_pos, Window::LowerWidget(), max(), OWNER_DEITY, NWidgetBase::pos_x, Window::RaiseWidget(), Scrollbar::SetCount(), Window::SetDirty(), NWidgetCore::SetDisabled(), Scrollbar::SetPosition(), SetScriptButtonColour(), Window::SetWidgetDirty(), Window::SetWidgetDisabledState(), valid, vscroll, WID_AID_COMPANY_BUTTON_START, WID_AID_LOG_PANEL, WID_AID_RELOAD_TOGGLE, WID_AID_SCRIPT_GAME, WID_AID_SCROLLBAR, and WID_AID_SETTINGS.
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 1390 of file ai_gui.cpp.
References Scrollbar::SetCapacityFromWidget(), vscroll, and WID_AID_LOG_PANEL.
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 1156 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 1035 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 1395 of file ai_gui.cpp.