12#include "../company_base.h"
13#include "../window_func.h"
14#include "../network/network.h"
15#include "../settings_func.h"
16#include "../network/network_content.h"
17#include "../core/geometry_func.hpp"
23#include "../script/script_gui.h"
24#include "table/strings.h"
26#include "../safeguards.h"
59 NWidget(
WWT_MATRIX, COLOUR_MAUVE,
WID_AIC_LIST),
SetMinimalSize(288, 112),
SetFill(1, 0),
SetMatrixDataTip(1, 8, STR_AI_CONFIG_AILIST_TOOLTIP),
SetScrollbar(
WID_AIC_SCROLLBAR),
138 size =
maxdim(size, NWidgetScrollbar::GetHorizontalDimension());
156 if (_game_mode != GM_NORMAL) {
168 if (_game_mode == GM_NORMAL) {
191 if (this->selected_slot == i) {
224 IConsoleSetSetting(
"difficulty.max_no_competitors",
new_value);
237 IConsoleSetSetting(
"difficulty.competitors_interval",
new_value);
252 this->selected_slot--;
261 this->selected_slot++;
270 OpenBrowser(
config->GetInfo()->GetURL());
Base functions for all AIs.
AIConfig stores the configuration settings of every AI.
static WindowDesc _ai_config_desc(WDP_CENTER, nullptr, 0, 0, WC_GAME_OPTIONS, WC_NONE, 0, _nested_ai_config_widgets)
Window definition for the configure AI window.
void ShowAIConfigWindow()
Open the AI config window.
static constexpr NWidgetPart _nested_ai_config_widgets[]
Widgets for the configure AI window.
Window for configuring the AIs
AIInfo keeps track of all information of an AI, like Author, Description, ...
static AIConfig * GetConfig(CompanyID company, ScriptSettingSource source=SSS_DEFAULT)
Get the config of a company.
static const uint MIN_COMPETITORS_INTERVAL
The minimum interval (in minutes) between competitors.
Owner
Enum for all companies/owners.
@ INVALID_COMPANY
An invalid company.
@ COMPANY_FIRST
First company, same as owner.
@ MAX_COMPANIES
Maximum number of companies.
static const uint MAX_COMPETITORS_INTERVAL
The maximum interval (in minutes) between competitors.
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
@ WL_ERROR
Errors (eg. saving/loading failed)
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
bool _ctrl_pressed
Is Ctrl pressed?
@ FS_NORMAL
Index of the normal font in the font tables.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
constexpr void Swap(T &a, T &b)
Type safe swap operation.
bool _network_available
is network mode available?
void ShowNetworkContentListWindow(ContentVector *cv=nullptr, ContentType type1=CONTENT_TYPE_END, ContentType type2=CONTENT_TYPE_END)
Show the content list window with a given set of content.
void ShowScriptTextfileWindow(TextfileType file_type, CompanyID slot)
Open the Script version of the textfile window.
void ShowScriptSettingsWindow(CompanyID slot)
Open the Script settings window to change the Script settings for a Script.
void ShowScriptListWindow(CompanyID slot, bool show_all)
Open the Script list window to chose a script for the given company slot.
GameSettings & GetGameSettings()
Get the settings-object applicable for the current situation: the newgame settings when we're in the ...
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Window to configure which AIs will start.
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
CompanyID selected_slot
The currently selected AI slot or INVALID_COMPANY.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
static bool IsEditable(CompanyID slot)
Can the AI config in the given company slot be edited?
Scrollbar * vscroll
Cache of the vertical scrollbar.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void SetStringParameters(WidgetID widget) const override
Initialize string parameters for a widget.
int line_height
Height of a single AI-name line.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
static bool IsValidAiID(size_t index)
Is this company a valid company, controlled by the computer (a NoAI program)?
static bool IsValidHumanID(size_t index)
Is this company a valid company, not controlled by a NoAI program?
uint8_t max_no_competitors
the number of competitors (AIs)
Dimensions (a width and height) of a rectangle in 2D.
DifficultySettings difficulty
settings related to the difficulty
Coordinates of a point in 2D.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Specification of a rectangle with absolute coordinates of all edges.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
High level window description.
Data structure for an opened window.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
ResizeInfo resize
Resize information.
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
@ CONTENT_TYPE_AI
The content consists of an AI.
TextfileType
Additional text files accompanying Tar archives.
@ TFT_LICENSE
Content license.
@ TFT_README
Content readme.
@ TFT_CHANGELOG
Content changelog.
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
@ WDP_CENTER
Center the window.
@ WN_GAME_OPTIONS_AI
AI settings.
@ WC_SCRIPT_SETTINGS
Script settings; Window numbers:
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ WC_SCRIPT_LIST
Scripts list; Window numbers:
@ WC_GAME_OPTIONS
Game options window; Window numbers: