OpenTTD Source 20260731-master-g77ba2b244a
ai_gui.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#include "../stdafx.h"
11#include "../error.h"
12#include "../company_base.h"
13#include "../window_func.h"
14#include "../network/network.h"
15#include "../settings_func.h"
18
19#include "ai.hpp"
20#include "ai_gui.hpp"
21#include "ai_config.hpp"
22#include "ai_info.hpp"
24
26
27#include "table/strings.h"
28
29#include "../safeguards.h"
30
31
33static constexpr std::initializer_list<NWidgetPart> _nested_ai_config_widgets = {
36 NWidget(WWT_CAPTION, Colours::Mauve), SetStringTip(STR_AI_CONFIG_CAPTION_AI, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
56 NWidget(WWT_PUSHTXTBTN, Colours::Yellow, WID_AIC_MOVE_UP), SetResize(1, 0), SetFill(1, 0), SetStringTip(STR_AI_CONFIG_MOVE_UP, STR_AI_CONFIG_MOVE_UP_TOOLTIP),
57 NWidget(WWT_PUSHTXTBTN, Colours::Yellow, WID_AIC_MOVE_DOWN), SetResize(1, 0), SetFill(1, 0), SetStringTip(STR_AI_CONFIG_MOVE_DOWN, STR_AI_CONFIG_MOVE_DOWN_TOOLTIP),
60 NWidget(WWT_FRAME, Colours::Mauve), SetStringTip(STR_AI_CONFIG_AI), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
62 NWidget(WWT_MATRIX, Colours::Mauve, WID_AIC_LIST), SetMinimalSize(288, 112), SetFill(1, 0), SetMatrixDataTip(1, 8, STR_AI_CONFIG_AILIST_TOOLTIP), SetScrollbar(WID_AIC_SCROLLBAR),
65 NWidget(WWT_PUSHTXTBTN, Colours::Yellow, WID_AIC_CONFIGURE), SetFill(1, 0), SetStringTip(STR_AI_CONFIG_CONFIGURE, STR_AI_CONFIG_CONFIGURE_TOOLTIP),
69 NWidget(WWT_PUSHTXTBTN, Colours::Yellow, WID_AIC_CHANGE), SetFill(1, 1), SetStringTip(STR_AI_CONFIG_CHANGE_AI, STR_AI_CONFIG_CHANGE_TOOLTIP),
70 NWidget(WWT_PUSHTXTBTN, Colours::Yellow, WID_AIC_CONTENT_DOWNLOAD), SetFill(1, 1), SetStringTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
74 NWidget(WWT_PUSHTXTBTN, Colours::Yellow, WID_AIC_OPEN_URL), SetResize(1, 0), SetFill(1, 0), SetStringTip(STR_CONTENT_OPEN_URL, STR_CONTENT_OPEN_URL_TOOLTIP),
75 NWidget(WWT_PUSHTXTBTN, Colours::Yellow, WID_AIC_TEXTFILE + TextfileType::Readme), SetFill(1, 1), SetResize(1, 0), SetStringTip(STR_TEXTFILE_VIEW_README, STR_TEXTFILE_VIEW_README_TOOLTIP),
78 NWidget(WWT_PUSHTXTBTN, Colours::Yellow, WID_AIC_TEXTFILE + TextfileType::Changelog), SetFill(1, 1), SetResize(1, 0), SetStringTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_TEXTFILE_VIEW_CHANGELOG_TOOLTIP),
79 NWidget(WWT_PUSHTXTBTN, Colours::Yellow, WID_AIC_TEXTFILE + TextfileType::License), SetFill(1, 1), SetResize(1, 0), SetStringTip(STR_TEXTFILE_VIEW_LICENCE, STR_TEXTFILE_VIEW_LICENCE_TOOLTIP),
85};
86
89 WindowPosition::Center, {}, 0, 0,
90 WindowClass::GameOptions, WindowClass::None,
91 {},
93);
94
98struct AIConfigWindow : public Window {
99 CompanyID selected_slot = CompanyID::Invalid();
100 int line_height = 0;
101 Scrollbar *vscroll = nullptr;
102
103 AIConfigWindow() : Window(_ai_config_desc)
104 {
105 this->InitNested(GameOptionsWindowNumber::AI); // Initializes 'this->line_height' as a side effect.
106 this->vscroll = this->GetScrollbar(WID_AIC_SCROLLBAR);
107 this->selected_slot = CompanyID::Invalid();
109 this->vscroll->SetCapacity(nwi->current_y / this->line_height);
110 this->vscroll->SetCount(MAX_COMPANIES);
111 this->OnInvalidateData(0);
112 }
113
114 void Close([[maybe_unused]] int data = 0) override
115 {
116 CloseWindowByClass(WindowClass::ScriptList);
117 CloseWindowByClass(WindowClass::ScriptSettings);
118 this->Window::Close();
119 }
120
121 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
122 {
123 switch (widget) {
124 case WID_AIC_NUMBER:
125 return GetString(STR_AI_CONFIG_MAX_COMPETITORS, GetGameSettings().difficulty.max_no_competitors);
126
127 case WID_AIC_INTERVAL:
128 return GetString(STR_AI_CONFIG_COMPETITORS_INTERVAL, GetGameSettings().difficulty.competitors_interval);
129
130 default:
131 return this->Window::GetWidgetString(widget, stringid);
132 }
133 }
134
135 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
136 {
137 switch (widget) {
142 size = maxdim(size, NWidgetScrollbar::GetHorizontalDimension());
143 break;
144
145 case WID_AIC_LIST:
146 this->line_height = GetCharacterHeight(FontSize::Normal) + padding.height;
147 fill.height = resize.height = this->line_height;
148 size.height = 8 * this->line_height;
149 break;
150 }
151 }
152
158 static bool IsEditable(CompanyID slot)
159 {
160 if (_game_mode != GameMode::Normal) {
161 return slot > 0 && slot < MAX_COMPANIES;
162 }
163 return slot < MAX_COMPANIES && !Company::IsValidID(slot);
164 }
165
171 std::string GetSlotText(CompanyID cid) const
172 {
173 if ((_game_mode != GameMode::Normal && cid == 0) || (_game_mode == GameMode::Normal && Company::IsValidHumanID(cid))) return GetString(STR_AI_CONFIG_HUMAN_PLAYER);
174 if (const AIInfo *info = AIConfig::GetConfig(cid)->GetInfo(); info != nullptr) return info->GetName();
175 return GetString(STR_AI_CONFIG_RANDOM_AI);
176 }
177
184 TextColour GetSlotColour(CompanyID cid, CompanyID max_slot) const
185 {
186 if (this->selected_slot == cid) return TextColour::White;
187 if (IsEditable(cid)) return cid < max_slot ? TextColour::Orange : TextColour::Silver;
189 return TextColour::Silver;
190 }
191
192 void DrawWidget(const Rect &r, WidgetID widget) const override
193 {
194 switch (widget) {
195 case WID_AIC_LIST: {
196 Rect tr = r.Shrink(WidgetDimensions::scaled.matrix);
198 if (_game_mode == GameMode::Normal) {
199 for (const Company *c : Company::Iterate()) {
200 if (c->is_ai) max_slot--;
201 }
202 for (CompanyID cid = CompanyID::Begin(); cid < max_slot && cid < MAX_COMPANIES; ++cid) {
203 if (Company::IsValidID(cid)) max_slot++;
204 }
205 } else {
206 max_slot++; // Slot 0 is human
207 }
208 for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < MAX_COMPANIES; i++) {
209 CompanyID cid = static_cast<CompanyID>(i);
210 DrawString(tr, this->GetSlotText(cid), this->GetSlotColour(cid, static_cast<CompanyID>(max_slot)));
211 tr.top += this->line_height;
212 }
213 break;
214 }
215 }
216 }
217
218 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
219 {
220 if (widget >= WID_AIC_TEXTFILE && widget < WID_AIC_TEXTFILE + TextfileType::ContentEnd) {
221 if (this->selected_slot == CompanyID::Invalid() || AIConfig::GetConfig(this->selected_slot) == nullptr) return;
222
223 ShowScriptTextfileWindow(this, static_cast<TextfileType>(widget - WID_AIC_TEXTFILE), this->selected_slot);
224 return;
225 }
226
227 switch (widget) {
230 int new_value;
231 if (widget == WID_AIC_DECREASE_NUMBER) {
232 new_value = std::max(0, GetGameSettings().difficulty.max_no_competitors - 1);
233 } else {
234 new_value = std::min<int>(MAX_COMPANIES - 1, GetGameSettings().difficulty.max_no_competitors + 1);
235 }
236 IConsoleSetSetting("difficulty.max_no_competitors", new_value);
237 this->InvalidateData();
238 break;
239 }
240
243 int new_value;
244 if (widget == WID_AIC_DECREASE_INTERVAL) {
245 new_value = std::max(static_cast<int>(MIN_COMPETITORS_INTERVAL), GetGameSettings().difficulty.competitors_interval - 1);
246 } else {
247 new_value = std::min(static_cast<int>(MAX_COMPETITORS_INTERVAL), GetGameSettings().difficulty.competitors_interval + 1);
248 }
249 IConsoleSetSetting("difficulty.competitors_interval", new_value);
250 this->InvalidateData();
251 break;
252 }
253
254 case WID_AIC_LIST: { // Select a slot
255 this->selected_slot = static_cast<CompanyID>(this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget));
256 this->InvalidateData();
257 if (click_count > 1 && IsEditable(this->selected_slot)) ShowScriptListWindow(this->selected_slot, _ctrl_pressed);
258 break;
259 }
260
261 case WID_AIC_MOVE_UP:
262 if (IsEditable(this->selected_slot) && IsEditable(static_cast<CompanyID>(this->selected_slot - 1))) {
263 auto it = std::next(std::begin(GetGameSettings().script_config.ai), this->selected_slot.base());
264 std::swap(*it, *std::prev(it));
265 this->selected_slot = static_cast<CompanyID>(this->selected_slot - 1);
266 this->vscroll->ScrollTowards(this->selected_slot.base());
267 this->InvalidateData();
268 }
269 break;
270
272 if (IsEditable(this->selected_slot) && IsEditable(static_cast<CompanyID>(this->selected_slot + 1))) {
273 auto it = std::next(std::begin(GetGameSettings().script_config.ai), this->selected_slot.base());
274 std::swap(*it, *std::next(it));
275 ++this->selected_slot;
276 this->vscroll->ScrollTowards(this->selected_slot.base());
277 this->InvalidateData();
278 }
279 break;
280
281 case WID_AIC_OPEN_URL: {
282 const AIConfig *config = AIConfig::GetConfig(this->selected_slot);
283 if (this->selected_slot == CompanyID::Invalid() || config == nullptr || config->GetInfo() == nullptr) return;
284 OpenBrowser(config->GetInfo()->GetURL());
285 break;
286 }
287
288 case WID_AIC_CHANGE: // choose other AI
289 if (IsEditable(this->selected_slot)) ShowScriptListWindow(this->selected_slot, _ctrl_pressed);
290 break;
291
292 case WID_AIC_CONFIGURE: // change the settings for an AI
293 ShowScriptSettingsWindow(this->selected_slot);
294 break;
295
297 if (!_network_available) {
298 ShowErrorMessage(GetEncodedString(STR_NETWORK_ERROR_NOTAVAILABLE), {}, WarningLevel::Error);
299 } else {
301 }
302 break;
303 }
304 }
305
311 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
312 {
313 if (!IsEditable(this->selected_slot) && !Company::IsValidAiID(this->selected_slot)) {
314 this->selected_slot = CompanyID::Invalid();
315 }
316
317 if (!gui_scope) return;
318
319 AIConfig *config = this->selected_slot == CompanyID::Invalid() ? nullptr : AIConfig::GetConfig(this->selected_slot);
320
321 this->SetWidgetDisabledState(WID_AIC_DECREASE_NUMBER, GetGameSettings().difficulty.max_no_competitors == 0);
322 this->SetWidgetDisabledState(WID_AIC_INCREASE_NUMBER, GetGameSettings().difficulty.max_no_competitors == MAX_COMPANIES - 1);
325 this->SetWidgetDisabledState(WID_AIC_CHANGE, !IsEditable(this->selected_slot));
326 this->SetWidgetDisabledState(WID_AIC_CONFIGURE, this->selected_slot == CompanyID::Invalid() || config->GetConfigList()->empty());
327 this->SetWidgetDisabledState(WID_AIC_MOVE_UP, !IsEditable(this->selected_slot) || !IsEditable(static_cast<CompanyID>(this->selected_slot - 1)));
328 this->SetWidgetDisabledState(WID_AIC_MOVE_DOWN, !IsEditable(this->selected_slot) || !IsEditable(static_cast<CompanyID>(this->selected_slot + 1)));
329
330 this->SetWidgetDisabledState(WID_AIC_OPEN_URL, this->selected_slot == CompanyID::Invalid() || config->GetInfo() == nullptr || config->GetInfo()->GetURL().empty());
332 this->SetWidgetDisabledState(WID_AIC_TEXTFILE + tft, this->selected_slot == CompanyID::Invalid() || !config->GetTextfile(tft, this->selected_slot).has_value());
333 }
334 }
335};
336
339{
340 CloseWindowByClass(WindowClass::GameOptions);
341 new AIConfigWindow();
342}
343
Base functions for all AIs.
AIConfig stores the configuration settings of every AI.
static WindowDesc _ai_config_desc(WindowPosition::Center, {}, 0, 0, WindowClass::GameOptions, WindowClass::None, {}, _nested_ai_config_widgets)
Window definition for the configure AI window.
void ShowAIConfigWindow()
Open the AI config window.
Definition ai_gui.cpp:338
static constexpr std::initializer_list< NWidgetPart > _nested_ai_config_widgets
Widgets for the configure AI window.
Definition ai_gui.cpp:33
Window for configuring the AIs.
AIInfo keeps track of all information of an AI, like Author, Description, ...
Types related to the ai widgets.
@ WID_AIC_CONFIGURE
Change AI settings button.
Definition ai_widget.h:29
@ WID_AIC_NUMBER
Number of AIs.
Definition ai_widget.h:20
@ WID_AIC_INTERVAL
Interval between time AIs start.
Definition ai_widget.h:23
@ WID_AIC_TEXTFILE
Open AI readme, changelog (+1) or license (+2).
Definition ai_widget.h:31
@ WID_AIC_MOVE_DOWN
Move down button.
Definition ai_widget.h:27
@ WID_AIC_BACKGROUND
Window background.
Definition ai_widget.h:17
@ WID_AIC_LIST
List with currently selected AIs.
Definition ai_widget.h:24
@ WID_AIC_CONTENT_DOWNLOAD
Download content button.
Definition ai_widget.h:32
@ WID_AIC_INCREASE_INTERVAL
Increase the interval.
Definition ai_widget.h:22
@ WID_AIC_OPEN_URL
Open AI URL.
Definition ai_widget.h:30
@ WID_AIC_DECREASE_INTERVAL
Decrease the interval.
Definition ai_widget.h:21
@ WID_AIC_SCROLLBAR
Scrollbar to scroll through the selected AIs.
Definition ai_widget.h:25
@ WID_AIC_DECREASE_NUMBER
Decrease the number of AIs.
Definition ai_widget.h:18
@ WID_AIC_CHANGE
Select another AI button.
Definition ai_widget.h:28
@ WID_AIC_INCREASE_NUMBER
Increase the number of AIs.
Definition ai_widget.h:19
@ WID_AIC_MOVE_UP
Move up button.
Definition ai_widget.h:26
AI instantion of script configuration.
Definition ai_config.hpp:17
class AIInfo * GetInfo() const
Get the ScriptInfo linked to this ScriptConfig.
Definition ai_config.cpp:37
static AIConfig * GetConfig(CompanyID company, ScriptSettingSource source=ScriptSettingSource::Default)
Get the AI configuration of specific company.
Definition ai_config.cpp:20
All static information from an AI like name, version, etc.
Definition ai_info.hpp:16
Iterate a range of enum values.
uint current_y
Current vertical size (after resizing).
Base class for a 'real' widget.
std::optional< std::string > GetTextfile(TextfileType type, CompanyID slot) const
Search a textfile file next to this script.
const ScriptConfigItemList * GetConfigList()
Get the config list for this ScriptConfig.
const std::string & GetURL() const
Get the website for this script.
Scrollbar data structure.
void SetCount(size_t num)
Sets the number of elements in the list.
void SetCapacity(size_t capacity)
Set the capacity of visible elements.
size_type GetScrolledRowFromWidget(int clickpos, const Window *const w, WidgetID widget, int padding=0, int line_height=-1) const
Compute the row of a scrolled widget that a user clicked in.
Definition widget.cpp:2474
void ScrollTowards(size_type position)
Scroll towards the given position; if the item is visible nothing happens, otherwise it will be shown...
size_type GetPosition() const
Gets the position of the first visible element in the list.
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition window_gui.h:30
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:95
Definition of stuff that is very close to a company, like the company struct itself.
static const uint MIN_COMPETITORS_INTERVAL
The minimum interval (in minutes) between competitors.
static const uint MAX_COMPETITORS_INTERVAL
The maximum interval (in minutes) between competitors.
Functions related to errors.
@ Error
Errors (eg. saving/loading failed).
Definition error.h:26
void ShowErrorMessage(EncodedString &&summary_msg, int x, int y, CommandCost &cc)
Display an error message in a window.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition fontcache.cpp:88
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Geometry functions.
bool _ctrl_pressed
Is Ctrl pressed?
Definition gfx.cpp:39
int DrawString(int left, int right, int top, std::string_view str, ExtendedTextColour colour, Alignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition gfx.cpp:668
@ Normal
Index of the normal font in the font tables.
Definition gfx_type.h:249
@ Mauve
Mauve.
Definition gfx_type.h:295
@ Invalid
Invalid marker.
Definition gfx_type.h:302
@ Yellow
Yellow.
Definition gfx_type.h:288
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition gfx_type.h:315
@ White
White colour.
Definition gfx_type.h:330
@ Orange
Orange colour.
Definition gfx_type.h:324
@ Green
Green colour.
Definition gfx_type.h:325
@ Silver
Silver colour.
Definition gfx_type.h:319
constexpr NWidgetPart SetMatrixDataTip(uint32_t cols, uint32_t rows, StringID tip={})
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
constexpr NWidgetPart SetScrollbar(WidgetID index)
Attach a scrollbar to a widget.
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
constexpr NWidgetPart SetStringTip(StringID string, StringID tip={})
Widget part function for setting the string and tooltip.
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=INVALID_WIDGET)
Widget part function for starting a new 'real' widget.
constexpr NWidgetPart SetArrowWidgetTypeTip(ArrowWidgetType widget_type, StringID tip={})
Widget part function for setting the arrow widget type and tooltip.
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
#define Point
Macro that prevents name conflicts between included headers.
bool _network_available
is network mode available?
Definition network.cpp:69
Basic functions/variables used all over the place.
Part of the network protocol handling content distribution.
void ShowNetworkContentListWindow(ContentVector *cv=nullptr, ContentType type1=ContentType::End, ContentType type2=ContentType::End)
Show the content list window with a given set of content.
@ Normal
Playing a game.
Definition openttd.h:20
A number of safeguards to prevent using unsafe methods.
void ShowScriptSettingsWindow(CompanyID slot)
Open the Script settings window to change the Script settings for a Script.
void ShowScriptTextfileWindow(Window *parent, TextfileType file_type, CompanyID slot)
Open the Script version of the textfile window.
void ShowScriptListWindow(CompanyID slot, bool show_all)
Open the Script list window to chose a script for the given company slot.
Window for configuring the scripts.
Functions related to setting/changing the settings.
GameSettings & GetGameSettings()
Get the settings-object applicable for the current situation: the newgame settings when we're in the ...
Definition of base types and functions in a cross-platform compatible way.
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
Definition strings.cpp:90
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:424
StrongType::Typedef< uint32_t, struct StringIDTag, StrongType::Compare, StrongType::Integer > StringID
Numeric value that represents a string, independent of the selected language.
Window to configure which AIs will start.
Definition ai_gui.cpp:98
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
Definition ai_gui.cpp:121
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition ai_gui.cpp:114
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.
Definition ai_gui.cpp:135
std::string GetSlotText(CompanyID cid) const
Get text to display for a given company slot.
Definition ai_gui.cpp:171
TextColour GetSlotColour(CompanyID cid, CompanyID max_slot) const
Get colour to display text in for a given company slot.
Definition ai_gui.cpp:184
CompanyID selected_slot
The currently selected AI slot or CompanyID::Invalid().
Definition ai_gui.cpp:99
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
Definition ai_gui.cpp:192
static bool IsEditable(CompanyID slot)
Can the AI config in the given company slot be edited?
Definition ai_gui.cpp:158
Scrollbar * vscroll
Cache of the vertical scrollbar.
Definition ai_gui.cpp:101
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition ai_gui.cpp:218
int line_height
Height of a single AI-name line.
Definition ai_gui.cpp:100
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition ai_gui.cpp:311
static bool IsValidAiID(auto index)
Is this company a valid company, controlled by the computer (a NoAI program)?
static bool IsValidHumanID(auto 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.
AISettings ai
what may the AI do?
DifficultySettings difficulty
settings related to the difficulty
static Pool::IterateWrapper< Company > Iterate(size_t from=0)
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.
Definition window_gui.h:172
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
Definition window.cpp:1112
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing).
Definition window.cpp:3258
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
Definition window.cpp:513
ResizeInfo resize
Resize information.
Definition window_gui.h:314
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition window.cpp:1841
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
Definition window_gui.h:989
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition window.cpp:1831
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
Definition window.cpp:322
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition window_gui.h:381
@ Ai
The content consists of an AI.
TextfileType
Additional text files accompanying Tar archives.
@ Readme
Content readme.
@ ContentBegin
This marker is used to generate the below three buttons in sequence by various of places in the code.
@ ContentEnd
This marker is used to generate the above three buttons in sequence by various of places in the code.
@ License
Content license.
@ Changelog
Content changelog.
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
@ WWT_PUSHARROWBTN
Normal push-button (no toggle button) with arrow caption.
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:66
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:39
@ WWT_MATRIX
Grid of rows and columns.
Definition widget_type.h:50
@ WWT_CAPTION
Window caption (window title between closebox and stickybox).
Definition widget_type.h:52
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition widget_type.h:76
@ NWID_VERTICAL
Vertical container.
Definition widget_type.h:68
@ WWT_CLOSEBOX
Close box (at top-left of a window).
Definition widget_type.h:60
@ WWT_FRAME
Frame.
Definition widget_type.h:51
@ WWT_TEXT
Pure simple text.
Definition widget_type.h:49
@ EqualSize
Containers should keep all their (resizing) children equally large.
@ Decrease
Arrow to the left or in case of RTL to the right.
Definition widget_type.h:20
@ Increase
Arrow to the right or in case of RTL to the left.
Definition widget_type.h:21
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Definition window.cpp:1217
Window functions not directly related to making/drawing windows.
@ Center
Center the window.
Definition window_gui.h:147
int WidgetID
Widget ID.
Definition window_type.h:21