Window with everything an AI prints via AILog. More...
Public Member Functions | |
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 void | OnTimeout () |
Called when this window's timeout has been reached. | |
virtual void | OnMouseLoop () |
Called for every mouse loop run, which is at least once per (game) tick. | |
virtual EventState | OnKeyPress (uint16 key, uint16 keycode) |
A key has been pressed. | |
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. | |
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 AID_WIDGET_LOG_PANEL. | |
static const int | bottom_offset = WD_FRAMERECT_BOTTOM |
Offset of the text at the bottom of the AID_WIDGET_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 bool | case_sensitive_break_check = false |
Is the matching done case-sensitive. |
Window with everything an AI prints via AILog.
Definition at line 775 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 797 of file ai_gui.cpp.
References _settings_client, ai_debug_company, GUISettings::ai_developer_tools, autoscroll, break_check_enabled, break_string, case_sensitive_break_check, COMPANY_FIRST, Window::CreateNestedTree(), Window::DisableWidget(), QueryStringBaseWindow::edit_str_buf, QueryStringBaseWindow::edit_str_size, Window::FinishInitNested(), Window::GetScrollbar(), ClientSettings::gui, highlight_row, InitializeTextBuffer(), INVALID_COMPANY, Company::IsValidAiID(), last_vscroll_pos, Window::LowerWidget(), MAX_BREAK_STR_STRING_LENGTH, MAX_COMPANIES, Window::SetWidgetDisabledState(), Window::SetWidgetLoweredState(), show_break_box, strecpy(), SZSP_HORIZONTAL, UpdateTextBufferSize(), and vscroll.
void AIDebugWindow::ChangeToAI | ( | CompanyID | show_ai | ) | [inline] |
Change all settings to select another AI.
show_ai | The new AI to show. |
Definition at line 1000 of file ai_gui.cpp.
References _current_company, ai_debug_company, autoscroll, DeleteWindowByClass(), AIObject::GetLogPointer(), Scrollbar::GetPosition(), last_vscroll_pos, Window::LowerWidget(), Window::RaiseWidget(), Backup< T >::Restore(), Scrollbar::SetCount(), Window::SetDirty(), AILog::LogData::used, and vscroll.
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 956 of file ai_gui.cpp.
References _current_company, ai_debug_company, AILog::LogData::count, DrawString(), AIObject::GetLogPointer(), Scrollbar::GetPosition(), GfxFillRect(), highlight_row, INVALID_COMPANY, Scrollbar::IsVisible(), AILog::LogData::lines, AILog::LOG_ERROR, AILog::LOG_INFO, AILog::LOG_SQ_ERROR, AILog::LOG_SQ_INFO, AILog::LOG_WARNING, PC_BLACK, AILog::LogData::pos, Window::resize, Backup< T >::Restore(), SA_FORCE, SA_LEFT, ResizeInfo::step_height, top_offset, AILog::LogData::type, AILog::LogData::used, vscroll, and WD_PAR_VSEP_NORMAL.
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 1018 of file ai_gui.cpp.
References ai_debug_company, break_check_enabled, case_sensitive_break_check, ChangeToAI(), CMD_COMPANY_CTRL, CMD_PAUSE, Window::DisableWidget(), DoCommandP(), IsInsideMM(), Window::IsWidgetDisabled(), PM_PAUSED_NORMAL, Window::RaiseWidget(), Window::SetWidgetDirty(), Window::SetWidgetLoweredState(), and ShowAISettingsWindow().
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 1086 of file ai_gui.cpp.
References _current_company, _pause_mode, ai_debug_company, break_check_enabled, case_sensitive_break_check, CMD_PAUSE, Window::DisableWidget(), DoCommandP(), QueryStringBaseWindow::edit_str_buf, Window::EnableWidget(), AIObject::GetLogPointer(), highlight_row, AILog::LogData::lines, PM_PAUSED_NORMAL, PM_UNPAUSED, AILog::LogData::pos, Backup< T >::Restore(), Window::SetDirty(), Window::SetWidgetDirty(), StrEmpty(), and AI::Suspend().
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 1071 of file ai_gui.cpp.
References break_string, QueryStringBaseWindow::edit_str_buf, ES_NOT_HANDLED, lastof, and strecpy().
virtual void AIDebugWindow::OnPaint | ( | ) | [inline, virtual] |
The window must be repainted.
Reimplemented from Window.
Definition at line 838 of file ai_gui.cpp.
References _current_company, ai_debug_company, autoscroll, NWidgetCore::colour, 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(), AIObject::GetLogPointer(), Scrollbar::GetPosition(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_COMPANY, CompanyProperties::is_ai, NWidgetCore::IsDisabled(), Window::IsShaded(), Company::IsValidAiID(), last_vscroll_pos, Window::LowerWidget(), max(), MAX_COMPANIES, NWidgetBase::pos_x, Window::RaiseWidget(), Backup< T >::Restore(), Scrollbar::SetCount(), Window::SetDirty(), NWidgetCore::SetDisabled(), Scrollbar::SetPosition(), Window::SetWidgetDirty(), Window::SetWidgetsDisabledState(), show_break_box, AILog::LogData::used, valid, vscroll, and WIDGET_LIST_END.
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 1130 of file ai_gui.cpp.
References Scrollbar::SetCapacityFromWidget(), and vscroll.
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 939 of file ai_gui.cpp.
References ai_debug_company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), ScriptFileInfo::GetName(), ScriptFileInfo::GetVersion(), INVALID_COMPANY, Company::IsValidAiID(), SetDParam(), and SetDParamStr().
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 830 of file ai_gui.cpp.
References bottom_offset, FONT_HEIGHT_NORMAL, top_offset, and WD_PAR_VSEP_NORMAL.