# ai_gui.cpp File Reference

Window for configuring the AIs. More...

`#include "../stdafx.h"`
`#include "../openttd.h"`
`#include "../gui.h"`
`#include "../window_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 "../textbuf_gui.h"`
`#include "../settings_func.h"`
`#include "../network/network_content.h"`
`#include "ai.hpp"`
`#include "api/ai_log.hpp"`
`#include "ai_config.hpp"`
`#include "ai_instance.hpp"`
`#include "table/strings.h"`

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 AILog. More...
## Enumerations
enum | AIListWindowWidgets { AIL_WIDGET_LIST, AIL_WIDGET_SCROLLBAR, AIL_WIDGET_INFO_BG, AIL_WIDGET_ACCEPT, AIL_WIDGET_CANCEL }
| Enum referring to the widgets of the AI list window. More...
enum | AISettingsWindowWidgest { AIS_WIDGET_BACKGROUND, AIS_WIDGET_SCROLLBAR, AIS_WIDGET_ACCEPT, AIS_WIDGET_RESET }
| Enum referring to the widgets of the AI settings window. More...
enum | AIConfigWindowWidgets { AIC_WIDGET_BACKGROUND, AIC_WIDGET_DECREASE, AIC_WIDGET_INCREASE, AIC_WIDGET_NUMBER, AIC_WIDGET_LIST, AIC_WIDGET_SCROLLBAR, AIC_WIDGET_MOVE_UP, AIC_WIDGET_MOVE_DOWN, AIC_WIDGET_CHANGE, AIC_WIDGET_CONFIGURE, AIC_WIDGET_CLOSE, AIC_WIDGET_CONTENT_DOWNLOAD }
| Enum referring to the widgets of the AI config window. More...
enum | AIDebugWindowWidgets { AID_WIDGET_VIEW, AID_WIDGET_NAME_TEXT, AID_WIDGET_SETTINGS, AID_WIDGET_RELOAD_TOGGLE, AID_WIDGET_LOG_PANEL, AID_WIDGET_SCROLLBAR, AID_WIDGET_COMPANY_BUTTON_START, AID_WIDGET_COMPANY_BUTTON_END = AID_WIDGET_COMPANY_BUTTON_START + 14 }
| Enum referring to the widgets of the AI debug window.
## Functions
static void | ShowAIListWindow (CompanyID slot)
static void | ShowAISettingsWindow (CompanyID slot)
void | ShowAIConfigWindow ()
void | ShowAIDebugWindow (CompanyID show_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 []
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))
static const NWidgetPart | _nested_ai_settings_widgets []
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))
static const NWidgetPart | _nested_ai_config_widgets []
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))
static const NWidgetPart | _nested_ai_debug_widgets []
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))

## Detailed Description

Window for configuring the AIs.

Definition in file ai_gui.cpp.

## Enumeration Type Documentation

enum AIConfigWindowWidgets

Enum referring to the widgets of the AI config window.

Enumerator:

  AIC_WIDGET_BACKGROUND | Window background.
  AIC_WIDGET_DECREASE | Decrease the number of AIs.
  AIC_WIDGET_INCREASE | Increase the number of AIs.
  AIC_WIDGET_NUMBER | Number of AIs.
  AIC_WIDGET_LIST | List with currently selected AIs.
  AIC_WIDGET_SCROLLBAR | Scrollbar to scroll through the selected AIs.
  AIC_WIDGET_MOVE_UP | Move up button.
  AIC_WIDGET_MOVE_DOWN | Move down button.
  AIC_WIDGET_CHANGE | Select another AI button.
  AIC_WIDGET_CONFIGURE | Change AI settings button.
  AIC_WIDGET_CLOSE | Close window button.
  AIC_WIDGET_CONTENT_DOWNLOAD | Download content button.

Definition at line 447 of file ai_gui.cpp.

enum AIListWindowWidgets

Enum referring to the widgets of the AI list window.

Enumerator:

  AIL_WIDGET_LIST | The matrix with all available AIs.
  AIL_WIDGET_SCROLLBAR | Scrollbar next to the AI list.
  AIL_WIDGET_INFO_BG | Panel to draw some AI information on.
  AIL_WIDGET_ACCEPT | Accept button.
  AIL_WIDGET_CANCEL | Cancel button.

Definition at line 36 of file ai_gui.cpp.

enum AISettingsWindowWidgest

Enum referring to the widgets of the AI settings window.

Enumerator:

  AIS_WIDGET_BACKGROUND | Panel to draw the settings on.
  AIS_WIDGET_SCROLLBAR | Scrollbar to scroll through all settings.
  AIS_WIDGET_ACCEPT | Accept button.
  AIS_WIDGET_RESET | Reset button.

Definition at line 223 of file ai_gui.cpp.

## Function Documentation

void ShowAIDebugWindowIfAIError | ( |  | ) |

Open the AI debug window if one of the AI scripts has crashed.

Definition at line 1029 of file ai_gui.cpp.

References _network_server, _networking, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, and AIInstance::IsDead().

Referenced by InitializeWindowsAndCaches().

## Variable Documentation

const NWidgetPart _nested_ai_list_widgets[]`[static]`

Initial value:

     {
      NWidget(NWID_HORIZONTAL),
        NWidget(WWT_CLOSEBOX, COLOUR_MAUVE),
        NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_AI_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
      EndContainer(),
      NWidget(NWID_HORIZONTAL),
        NWidget(WWT_MATRIX, COLOUR_MAUVE, AIL_WIDGET_LIST), SetMinimalSize(188, 112), SetFill(1, 1), SetResize(1, 1), SetDataTip(0x501, STR_AI_LIST_TOOLTIP),
        NWidget(WWT_SCROLLBAR, COLOUR_MAUVE, AIL_WIDGET_SCROLLBAR),
      EndContainer(),
      NWidget(WWT_PANEL, COLOUR_MAUVE, AIL_WIDGET_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, AIL_WIDGET_ACCEPT), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_AI_LIST_ACCEPT, STR_AI_LIST_ACCEPT_TOOLTIP),
          NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, AIL_WIDGET_CANCEL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_AI_LIST_CANCEL, STR_AI_LIST_CANCEL_TOOLTIP),
        EndContainer(),
        NWidget(WWT_RESIZEBOX, COLOUR_MAUVE),
      EndContainer(),
    }

Definition at line 188 of file ai_gui.cpp.

const NWidgetPart _nested_ai_settings_widgets[]`[static]`

Initial value:

     {
      NWidget(NWID_HORIZONTAL),
        NWidget(WWT_CLOSEBOX, COLOUR_MAUVE),
        NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_AI_SETTINGS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
      EndContainer(),
      NWidget(NWID_HORIZONTAL),
        NWidget(WWT_MATRIX, COLOUR_MAUVE, AIS_WIDGET_BACKGROUND), SetMinimalSize(188, 182), SetResize(1, 1), SetFill(1, 0), SetDataTip(0x501, STR_NULL),
        NWidget(WWT_SCROLLBAR, COLOUR_MAUVE, AIS_WIDGET_SCROLLBAR),
      EndContainer(),
      NWidget(NWID_HORIZONTAL),
        NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
          NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, AIS_WIDGET_ACCEPT), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_AI_SETTINGS_CLOSE, STR_NULL),
          NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, AIS_WIDGET_RESET), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_AI_SETTINGS_RESET, STR_NULL),
        EndContainer(),
        NWidget(WWT_RESIZEBOX, COLOUR_MAUVE),
      EndContainer(),
    }

Definition at line 413 of file ai_gui.cpp.