Data Structures | Functions | Variables

ai_gui.cpp File Reference

Window for configuring the AIs. More...

#include "../stdafx.h"
#include "../table/sprites.h"
#include "../error.h"
#include "../gui.h"
#include "../querystring_gui.h"
#include "../company_func.h"
#include "../company_base.h"
#include "../company_gui.h"
#include "../strings_func.h"
#include "../window_func.h"
#include "../gfx_func.h"
#include "../command_func.h"
#include "../network/network.h"
#include "../settings_func.h"
#include "../network/network_content.h"
#include "../core/backup_type.hpp"
#include "ai.hpp"
#include "../script/api/script_log.hpp"
#include "ai_config.hpp"
#include "ai_info.hpp"
#include "ai_instance.hpp"
#include "../game/game.hpp"
#include "../game/game_config.hpp"
#include "../game/game_info.hpp"
#include "../game/game_instance.hpp"
#include "../widgets/ai_widget.h"
#include "table/strings.h"
#include <vector>

Go to the source code of this file.

Data Structures

struct  AIListWindow
 Window that let you choose an available AI. More...
struct  AISettingsWindow
 Window for settings the parameters of an AI. More...
struct  AIConfigWindow
 Window to configure which AIs will start. More...
struct  AIDebugWindow
 Window with everything an AI prints via ScriptLog. More...

Functions

static ScriptConfigGetConfig (CompanyID slot)
static void ShowAIListWindow (CompanyID slot)
 Open the AI list window to chose an AI for the given company slot.
static void ShowAISettingsWindow (CompanyID slot)
 Open the AI settings window to change the AI settings for an AI.
void ShowAIConfigWindow ()
 Open the AI config window.
NWidgetBaseMakeCompanyButtonRowsAIDebug (int *biggest_index)
 Make a number of rows with buttons for each company for the AI debug window.
void ShowAIDebugWindow (CompanyID show_company)
 Open the AI debug window and select the given company.
void InitializeAIGui ()
 Reset the AI windows to their initial state.
void ShowAIDebugWindowIfAIError ()
 Open the AI debug window if one of the AI scripts has crashed.

Variables

static const NWidgetPart _nested_ai_list_widgets []
 Widgets for the AI list window.
static const WindowDesc _ai_list_desc (WDP_CENTER, 200, 234, WC_AI_LIST, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_ai_list_widgets, lengthof(_nested_ai_list_widgets))
 Window definition for the ai list window.
static const NWidgetPart _nested_ai_settings_widgets []
 Widgets for the AI settings window.
static const WindowDesc _ai_settings_desc (WDP_CENTER, 500, 208, WC_AI_SETTINGS, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_ai_settings_widgets, lengthof(_nested_ai_settings_widgets))
 Window definition for the AI settings window.
static const NWidgetPart _nested_ai_config_widgets []
 Widgets for the configure AI window.
static const WindowDesc _ai_config_desc (WDP_CENTER, 0, 0, WC_GAME_OPTIONS, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_ai_config_widgets, lengthof(_nested_ai_config_widgets))
 Window definition for the configure AI window.
static const NWidgetPart _nested_ai_debug_widgets []
 Widgets for the AI debug window.
static const WindowDesc _ai_debug_desc (WDP_AUTO, 600, 450, WC_AI_DEBUG, WC_NONE, 0, _nested_ai_debug_widgets, lengthof(_nested_ai_debug_widgets))
 Window definition for the AI debug window.

Detailed Description

Window for configuring the AIs.

Definition in file ai_gui.cpp.


Function Documentation

NWidgetBase* MakeCompanyButtonRowsAIDebug ( int *  biggest_index  ) 

Make a number of rows with buttons for each company for the AI debug window.

Definition at line 1229 of file ai_gui.cpp.

References MakeCompanyButtonRows(), WID_AID_COMPANY_BUTTON_END, and WID_AID_COMPANY_BUTTON_START.

void ShowAIConfigWindow (  ) 

Open the AI config window.

Definition at line 830 of file ai_gui.cpp.

References DeleteWindowByClass(), and WC_GAME_OPTIONS.

Referenced by MenuClickSettings(), and SelectGameWindow::OnClick().

void ShowAIDebugWindow ( CompanyID  show_company  ) 

Open the AI debug window and select the given company.

Parameters:
show_company Display debug information about this AI company.

Definition at line 1290 of file ai_gui.cpp.

References _ai_debug_desc, _network_server, _networking, BringWindowToFrontById(), AIDebugWindow::ChangeToAI(), INVALID_COMPANY, INVALID_STRING_ID, ShowErrorMessage(), WC_AI_DEBUG, and WL_INFO.

Referenced by AIInstance::Died(), MenuClickHelp(), MainToolbarWindow::OnKeyPress(), and ShowAIDebugWindowIfAIError().

void ShowAIDebugWindowIfAIError (  ) 
static void ShowAIListWindow ( CompanyID  slot  )  [static]

Open the AI list window to chose an AI for the given company slot.

Parameters:
slot The slot to change the AI of.

Definition at line 267 of file ai_gui.cpp.

References _ai_list_desc, DeleteWindowByClass(), and WC_AI_LIST.

Referenced by AIConfigWindow::OnClick().

static void ShowAISettingsWindow ( CompanyID  slot  )  [static]

Open the AI settings window to change the AI settings for an AI.

Parameters:
slot The CompanyID of the AI to change the settings.

Definition at line 560 of file ai_gui.cpp.

References _ai_settings_desc, DeleteWindowByClass(), WC_AI_LIST, and WC_AI_SETTINGS.

Referenced by AIConfigWindow::OnClick().


Variable Documentation

const WindowDesc _ai_config_desc(WDP_CENTER, 0, 0, WC_GAME_OPTIONS, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_ai_config_widgets, lengthof(_nested_ai_config_widgets)) [static]

Window definition for the configure AI window.

const WindowDesc _ai_debug_desc(WDP_AUTO, 600, 450, WC_AI_DEBUG, WC_NONE, 0, _nested_ai_debug_widgets, lengthof(_nested_ai_debug_widgets)) [static]

Window definition for the AI debug window.

Referenced by ShowAIDebugWindow().

const WindowDesc _ai_list_desc(WDP_CENTER, 200, 234, WC_AI_LIST, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_ai_list_widgets, lengthof(_nested_ai_list_widgets)) [static]

Window definition for the ai list window.

Referenced by ShowAIListWindow().

const WindowDesc _ai_settings_desc(WDP_CENTER, 500, 208, WC_AI_SETTINGS, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_ai_settings_widgets, lengthof(_nested_ai_settings_widgets)) [static]

Window definition for the AI settings window.

Referenced by ShowAISettingsWindow().

Widgets for the configure AI window.

Definition at line 568 of file ai_gui.cpp.

Widgets for the AI debug window.

Definition at line 1235 of file ai_gui.cpp.

Initial value:
 {
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_CLOSEBOX, COLOUR_MAUVE),
    NWidget(WWT_CAPTION, COLOUR_MAUVE, WID_AIL_CAPTION), SetDataTip(STR_AI_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
  EndContainer(),
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_MATRIX, COLOUR_MAUVE, WID_AIL_LIST), SetMinimalSize(188, 112), SetFill(1, 1), SetResize(1, 1), SetDataTip(0x501, STR_AI_LIST_TOOLTIP), SetScrollbar(WID_AIL_SCROLLBAR),
    NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, WID_AIL_SCROLLBAR),
  EndContainer(),
  NWidget(WWT_PANEL, COLOUR_MAUVE, WID_AIL_INFO_BG), SetMinimalTextLines(8, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM), SetResize(1, 0),
  EndContainer(),
  NWidget(NWID_HORIZONTAL),
    NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
      NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_AIL_ACCEPT), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_AI_LIST_ACCEPT, STR_AI_LIST_ACCEPT_TOOLTIP),
      NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_AIL_CANCEL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_AI_LIST_CANCEL, STR_AI_LIST_CANCEL_TOOLTIP),
    EndContainer(),
    NWidget(WWT_RESIZEBOX, COLOUR_MAUVE),
  EndContainer(),
}

Widgets for the AI list window.

Definition at line 235 of file ai_gui.cpp.

Initial value:
 {
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_CLOSEBOX, COLOUR_MAUVE),
    NWidget(WWT_CAPTION, COLOUR_MAUVE, WID_AIS_CAPTION), SetDataTip(STR_AI_SETTINGS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
  EndContainer(),
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_MATRIX, COLOUR_MAUVE, WID_AIS_BACKGROUND), SetMinimalSize(188, 182), SetResize(1, 1), SetFill(1, 0), SetDataTip(0x501, STR_NULL), SetScrollbar(WID_AIS_SCROLLBAR),
    NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, WID_AIS_SCROLLBAR),
  EndContainer(),
  NWidget(NWID_HORIZONTAL),
    NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
      NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_AIS_ACCEPT), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_AI_SETTINGS_CLOSE, STR_NULL),
      NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_AIS_RESET), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_AI_SETTINGS_RESET, STR_NULL),
    EndContainer(),
    NWidget(WWT_RESIZEBOX, COLOUR_MAUVE),
  EndContainer(),
}

Widgets for the AI settings window.

Definition at line 530 of file ai_gui.cpp.