# AIDebugWindow Struct Reference

Window with everything an AI prints via AILog. More...

Inheritance diagram for AIDebugWindow:

## Public Member Functions
| AIDebugWindow (const WindowDesc *desc, WindowNumber number)
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)
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
int | last_vscroll_pos
bool | autoscroll
bool | show_break_box
int | highlight_row
| The output row that matches the given string, or -1.
Scrollbar * | vscroll
## 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
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.

## Detailed Description

Window with everything an AI prints via AILog.

Definition at line 756 of file ai_gui.cpp.

## Member Function Documentation

virtual void AIDebugWindow::DrawWidget | ( | const Rect & | r,
|  | int | widget |
| ) |  |  | const`[inline, virtual]`

Draw the contents of a nested widget.

Parameters:

  | r | Rectangle occupied by the widget.
  | widget | Number of the widget to draw.

Note:
  This method may not change any state, it may only use drawing functions.

Reimplemented from Window.

Definition at line 933 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, AILog::LogData::pos, Window::resize, Backup< T >::Restore(), SA_FORCE, SA_LEFT, ResizeInfo::step_height, top_offset, AILog::LogData::type, AILog::LogData::used, 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.

Parameters:

  | 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 991 of file ai_gui.cpp.

References ai_debug_company, break_check_enabled, case_sensitive_break_check, 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.

Parameters:

  | 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 1059 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.

Parameters:

  | key | the Unicode value of the key.
  | keycode | the untranslated key code including shift state.

Returns:
  ES_HANDLED if the key press has been handled and no other window should receive the event.

Reimplemented from Window.

Definition at line 1044 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.

Note:
  This method should not change any state, it should only use drawing functions.

Reimplemented from Window.

Definition at line 814 of file ai_gui.cpp.

References _current_company, ai_debug_company, NWidgetCore::colour, COMPANY_FIRST, NWidgetBase::current_x, Window::DisableWidget(), DrawCompanyIcon(), Window::DrawWidgets(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Scrollbar::GetCapacity(), Scrollbar::GetCount(), AIObject::GetLogPointer(), Scrollbar::GetPosition(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_COMPANY, CompanyProperties::is_ai, NWidgetCore::IsDisabled(), Window::IsShaded(), Company::IsValidAiID(), 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(), AILog::LogData::used, valid, 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 1103 of file ai_gui.cpp.

References Scrollbar::SetCapacityFromWidget().

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.

Parameters:

  | widget | Widget number.

Reimplemented from Window.

Definition at line 916 of file ai_gui.cpp.

References ai_debug_company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, 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.

Parameters:

  | 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 806 of file ai_gui.cpp.

References bottom_offset, FONT_HEIGHT_NORMAL, top_offset, and WD_PAR_VSEP_NORMAL.

The documentation for this struct was generated from the following file:

- src/ai/ai_gui.cpp