Public Member Functions | Data Fields | Static Public Attributes

AIDebugWindow Struct Reference

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

Inheritance diagram for AIDebugWindow:
Window ZeroedMemoryAllocator

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.
Scrollbarvscroll
 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< AIDebugWindowaidebug_hotkeys []

Detailed Description

Window with everything an AI prints via ScriptLog.

Definition at line 965 of file ai_gui.cpp.


Constructor & Destructor Documentation


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

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

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

Parameters:
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.

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

References bottom_offset, FONT_HEIGHT_NORMAL, top_offset, and WID_AID_LOG_PANEL.


Field Documentation

Hotkey< AIDebugWindow > AIDebugWindow::aidebug_hotkeys [static]
Initial value:
 {
  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.


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