Public Member Functions | Data Fields | Static Public Attributes

# AIDebugWindow Struct Reference

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

Inheritance diagram for AIDebugWindow:

## 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 (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 | 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 HotkeyList | hotkeys

## Detailed Description

Window with everything an AI prints via ScriptLog.

Definition at line 967 of file ai_gui.cpp.

## Constructor & Destructor Documentation

AIDebugWindow::AIDebugWindow | ( | WindowDesc * | desc,
|  | WindowNumber | number |
| ) |  |  | `[inline]`

Constructor for the window.

Parameters:

  | desc | The description of the window.
  | number | The window number (actually unused).

Definition at line 1047 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(), Window::SetWidgetsDisabledState(), show_break_box, SZSP_HORIZONTAL, vscroll, WID_AID_BREAK_STR_EDIT_BOX, WID_AID_BREAK_STR_ON_OFF_BTN, WID_AID_MATCH_CASE_BTN, WID_AID_SCROLLBAR, and WIDGET_LIST_END.

## Member Function Documentation

void AIDebugWindow::ChangeToAI | ( | CompanyID | show_ai | ) | `[inline]`

Change all settings to select another AI.

Parameters:

  | show_ai | The new AI to show.

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

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

Returns:
  true if dead.

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

Parameters:

  | company | Company to check for validity.

Returns:
  true if company is valid for debugging.

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

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

virtual void AIDebugWindow::OnEditboxChanged | ( | int | widget | ) | `[inline, virtual]`

The text in an editbox has been edited.

Parameters:

  | widget | The widget of the editbox.

Reimplemented from Window.

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

Parameters:

  | 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 1325 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 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 1080 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 1382 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 1023 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.

Parameters:

  | widget | Widget number.

Reimplemented from Window.

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

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

References bottom_offset, FONT_HEIGHT_NORMAL, top_offset, and WID_AID_LOG_PANEL.

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

- src/ai/ai_gui.cpp