OpenTTD Source 20250818-master-g1850ad1aa2
genworld_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 <http://www.gnu.org/licenses/>.
6 */
7
10#include "stdafx.h"
11#include "heightmap.h"
12#include "debug.h"
13#include "genworld.h"
14#include "network/network.h"
15#include "strings_func.h"
16#include "window_func.h"
18#include "sound_func.h"
19#include "fios.h"
20#include "string_func.h"
21#include "dropdown_type.h"
22#include "dropdown_func.h"
23#include "querystring_gui.h"
24#include "town.h"
26#include "core/random_func.hpp"
27#include "saveload/saveload.h"
28#include "progress.h"
29#include "error.h"
30#include "newgrf_townname.h"
31#include "townname_type.h"
33#include "ai/ai_gui.hpp"
34#include "game/game_gui.hpp"
35#include "industry.h"
37
39
40#include "table/strings.h"
41
43
44#include "safeguards.h"
45
46
47extern void MakeNewgameSettingsLive();
48
55
64
75
79 NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
80 NWidget(WWT_CAPTION, COLOUR_BROWN), SetStringTip(STR_MAPGEN_WORLD_GENERATION_CAPTION),
82 NWidget(WWT_PANEL, COLOUR_BROWN),
84 /* Landscape selection. */
86 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TEMPERATE), SetSpriteTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
87 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_ARCTIC), SetSpriteTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
88 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TROPICAL), SetSpriteTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
89 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TOYLAND), SetSpriteTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
91
92 /* Generation options. */
94 /* Left half (land generation options) */
96 /* Labels on the left side (global column 1). */
98 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_MAPSIZE, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
99 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_TERRAIN_TYPE, STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT), SetFill(1, 1),
100 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_VARIETY, STR_CONFIG_SETTING_VARIETY_HELPTEXT), SetFill(1, 1),
101 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_SMOOTHNESS, STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT), SetFill(1, 1),
102 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT), SetFill(1, 1),
103 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_BORDER_TYPE, STR_MAPGEN_BORDER_TYPE_TOOLTIP), SetFill(1, 1),
104 EndContainer(),
105
106 /* Widgets on the right side (global column 2). */
108 /* Mapsize X * Y. */
110 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_X_PULLDOWN), SetToolTip(STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
111 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_BY), SetFill(0, 1), SetAlignment(SA_CENTER),
112 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_Y_PULLDOWN), SetToolTip(STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
113 EndContainer(),
114 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TERRAIN_PULLDOWN), SetToolTip(STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT), SetFill(1, 1),
115 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_VARIETY_PULLDOWN), SetToolTip(STR_CONFIG_SETTING_VARIETY_HELPTEXT), SetFill(1, 1),
116 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_SMOOTHNESS_PULLDOWN), SetToolTip(STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT), SetFill(1, 1),
117 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_RIVER_PULLDOWN), SetToolTip(STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT), SetFill(1, 1),
118 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_BORDERS_RANDOM), SetToolTip(STR_MAPGEN_BORDER_TYPE_TOOLTIP), SetFill(1, 1),
119 EndContainer(),
120 EndContainer(),
121
122 /* Right half (all other options) */
124 /* Labels on the left side (global column 3). */
127 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_SNOW_COVERAGE, STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT), SetFill(1, 1),
128 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_DESERT_COVERAGE, STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT), SetFill(1, 1),
130 EndContainer(),
131 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_DATE, STR_MAPGEN_DATE_TOOLTIP), SetFill(1, 1),
132 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_TOWN_NAME_LABEL, STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP), SetFill(1, 1),
133 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_NUMBER_OF_TOWNS, STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP), SetFill(1, 1),
134 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES, STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP), SetFill(1, 1),
135 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_SEA_LEVEL, STR_MAPGEN_SEA_LEVEL_TOOLTIP), SetFill(1, 1),
136 EndContainer(),
137
138 /* Widgets on the right side (global column 4). */
140 /* Climate selector. */
142 /* Snow coverage. */
144 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_DOWN), SetSpriteTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_COVERAGE_DOWN_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
145 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_TEXT), SetToolTip(STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT), SetFill(1, 1),
146 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_UP), SetSpriteTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_COVERAGE_UP_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
147 EndContainer(),
148 /* Desert coverage. */
150 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_DOWN), SetSpriteTip(SPR_ARROW_DOWN, STR_MAPGEN_DESERT_COVERAGE_DOWN_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
151 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_TEXT), SetToolTip(STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT), SetFill(1, 1),
152 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_UP), SetSpriteTip(SPR_ARROW_UP, STR_MAPGEN_DESERT_COVERAGE_UP_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
153 EndContainer(),
154 /* Temperate/Toyland spacer. */
156 EndContainer(),
157 /* Starting date. */
159 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_DOWN), SetSpriteTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_MOVE_THE_STARTING_DATE_BACKWARD_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
160 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetToolTip(STR_MAPGEN_DATE_TOOLTIP), SetFill(1, 1),
161 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_UP), SetSpriteTip(SPR_ARROW_UP, STR_SCENEDIT_TOOLBAR_MOVE_THE_STARTING_DATE_FORWARD_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
162 EndContainer(),
163 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWNNAME_DROPDOWN), SetToolTip(STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP), SetFill(1, 1),
164 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWN_PULLDOWN), SetToolTip(STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP), SetFill(1, 1),
165 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_INDUSTRY_PULLDOWN), SetToolTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP), SetFill(1, 1),
166 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_WATER_PULLDOWN), SetToolTip(STR_MAPGEN_SEA_LEVEL_TOOLTIP), SetFill(1, 1),
167 EndContainer(),
168 EndContainer(),
169 EndContainer(),
170
171 /* Map borders buttons for each edge. */
174 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_NORTHWEST), SetPadding(0, WidgetDimensions::unscaled.hsep_normal, 0, 0), SetFill(1, 1), SetAlignment(SA_RIGHT | SA_VERT_CENTER),
175 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_NW), SetToolTip(STR_MAPGEN_NORTHWEST), SetFill(1, 1),
176 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_NE), SetToolTip(STR_MAPGEN_NORTHEAST), SetFill(1, 1),
177 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_NORTHEAST), SetPadding(0, 0, 0, WidgetDimensions::unscaled.hsep_normal), SetFill(1, 1),
178 EndContainer(),
180 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_SOUTHWEST), SetPadding(0, WidgetDimensions::unscaled.hsep_normal, 0, 0), SetFill(1, 1), SetAlignment(SA_RIGHT | SA_VERT_CENTER),
181 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_SW), SetToolTip(STR_MAPGEN_SOUTHWEST), SetFill(1, 1),
182 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_SE), SetToolTip(STR_MAPGEN_SOUTHEAST), SetFill(1, 1),
183 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_SOUTHEAST), SetPadding(0, 0, 0, WidgetDimensions::unscaled.hsep_normal), SetFill(1, 1),
184 EndContainer(),
185 EndContainer(),
186
187 /* AI, GS, and NewGRF settings */
189 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_AI_BUTTON), SetMinimalTextLines(2, 0), SetStringTip(STR_MAPGEN_AI_SETTINGS, STR_MAPGEN_AI_SETTINGS_TOOLTIP), SetFill(1, 0),
190 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_GS_BUTTON), SetMinimalTextLines(2, 0), SetStringTip(STR_MAPGEN_GS_SETTINGS, STR_MAPGEN_GS_SETTINGS_TOOLTIP), SetFill(1, 0),
191 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_NEWGRF_BUTTON), SetMinimalTextLines(2, 0), SetStringTip(STR_MAPGEN_NEWGRF_SETTINGS, STR_MAPGEN_NEWGRF_SETTINGS_TOOLTIP), SetFill(1, 0),
192 EndContainer(),
193
194 /* Generate */
195 NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_GL_GENERATE_BUTTON), SetMinimalTextLines(3, 0), SetStringTip(STR_MAPGEN_GENERATE, STR_MAPGEN_GENERATE_TOOLTIP), SetFill(1, 1),
196 EndContainer(),
197 EndContainer(),
198};
199
202 /* Window header. */
204 NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
205 NWidget(WWT_CAPTION, COLOUR_BROWN), SetStringTip(STR_MAPGEN_WORLD_GENERATION_CAPTION),
206 EndContainer(),
207 NWidget(WWT_PANEL, COLOUR_BROWN),
209 /* Landscape selection. */
211 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TEMPERATE), SetSpriteTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
212 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_ARCTIC), SetSpriteTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
213 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TROPICAL), SetSpriteTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
214 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TOYLAND), SetSpriteTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
215 EndContainer(),
216
218 /* Heightmap name label. */
219 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_HEIGHTMAP_NAME, STR_MAPGEN_HEIGHTMAP_NAME_TOOLTIP),
220 NWidget(WWT_TEXT, INVALID_COLOUR, WID_GL_HEIGHTMAP_NAME_TEXT), SetTextStyle(TC_ORANGE), SetToolTip(STR_MAPGEN_HEIGHTMAP_NAME_TOOLTIP), SetFill(1, 0),
221 EndContainer(),
222
223 /* Generation options. */
225 /* Left half (land generation options) */
227 /* Labels on the left side (global column 1). */
229 /* Land generation option labels. */
230 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_HEIGHTMAP_SIZE_LABEL, STR_MAPGEN_HEIGHTMAP_SIZE_LABEL_TOOLTIP), SetFill(1, 1),
231 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_MAPSIZE, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
232 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_HEIGHTMAP_ROTATION, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_TOOLTIP), SetFill(1, 1),
233 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_HEIGHTMAP_HEIGHT, STR_MAPGEN_HEIGHTMAP_HEIGHT_TOOLTIP), SetFill(1, 1),
234 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT), SetFill(1, 1),
235 EndContainer(),
236
237 /* Left half widgets (global column 2) */
239 NWidget(WWT_TEXT, INVALID_COLOUR, WID_GL_HEIGHTMAP_SIZE_TEXT), SetStringTip(STR_MAPGEN_HEIGHTMAP_SIZE, STR_MAPGEN_HEIGHTMAP_SIZE_LABEL_TOOLTIP), SetFill(1, 1),
240 /* Mapsize X * Y. */
242 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_X_PULLDOWN), SetToolTip(STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
243 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_BY), SetFill(0, 1), SetAlignment(SA_CENTER),
244 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_Y_PULLDOWN), SetToolTip(STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
245 EndContainer(),
246 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_ROTATION_PULLDOWN), SetToolTip(STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_TOOLTIP), SetFill(1, 1),
247 /* Heightmap highest peak. */
249 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_DOWN), SetSpriteTip(SPR_ARROW_DOWN, STR_MAPGEN_HEIGHTMAP_HEIGHT_DOWN_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
250 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_TEXT), SetToolTip(STR_MAPGEN_HEIGHTMAP_HEIGHT_TOOLTIP), SetFill(1, 1),
251 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_UP), SetSpriteTip(SPR_ARROW_UP, STR_MAPGEN_HEIGHTMAP_HEIGHT_UP_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
252 EndContainer(),
253 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_RIVER_PULLDOWN), SetToolTip(STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT), SetFill(1, 1),
254 EndContainer(),
255 EndContainer(),
256
257 /* Right half (all other options) */
259 /* Right half labels (global column 3) */
262 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_SNOW_COVERAGE, STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT), SetFill(1, 1),
263 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_DESERT_COVERAGE, STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT), SetFill(1, 1),
265 EndContainer(),
266 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_DATE, STR_MAPGEN_DATE_TOOLTIP), SetFill(1, 1),
267 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_TOWN_NAME_LABEL, STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP), SetFill(1, 1),
268 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_NUMBER_OF_TOWNS, STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP), SetFill(1, 1),
269 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES, STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP), SetFill(1, 1),
270 EndContainer(),
271
272 /* Right half widgets (global column 4) */
274 /* Climate selector. */
276 /* Snow coverage. */
278 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_DOWN), SetSpriteTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_COVERAGE_DOWN_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
279 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_TEXT), SetToolTip(STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT), SetFill(1, 1),
280 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_UP), SetSpriteTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_COVERAGE_UP_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
281 EndContainer(),
282 /* Desert coverage. */
284 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_DOWN), SetSpriteTip(SPR_ARROW_DOWN, STR_MAPGEN_DESERT_COVERAGE_DOWN_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
285 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_TEXT), SetToolTip(STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT), SetFill(1, 1),
286 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_UP), SetSpriteTip(SPR_ARROW_UP, STR_MAPGEN_DESERT_COVERAGE_UP_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
287 EndContainer(),
288 /* Temperate/Toyland spacer. */
290 EndContainer(),
291 /* Starting date. */
293 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_DOWN), SetSpriteTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_MOVE_THE_STARTING_DATE_BACKWARD_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
294 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetToolTip(STR_MAPGEN_DATE_TOOLTIP), SetFill(1, 1),
295 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_UP), SetSpriteTip(SPR_ARROW_UP, STR_SCENEDIT_TOOLBAR_MOVE_THE_STARTING_DATE_FORWARD_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
296 EndContainer(),
297 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWNNAME_DROPDOWN), SetToolTip(STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP), SetFill(1, 1),
298 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWN_PULLDOWN), SetToolTip(STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP), SetFill(1, 1),
299 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_INDUSTRY_PULLDOWN), SetToolTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP), SetFill(1, 1),
300 EndContainer(),
301 EndContainer(),
302 EndContainer(),
303
304 /* AI, GS, and NewGRF settings */
306 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_AI_BUTTON), SetMinimalTextLines(2, 0), SetStringTip(STR_MAPGEN_AI_SETTINGS, STR_MAPGEN_AI_SETTINGS_TOOLTIP), SetFill(1, 0),
307 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_GS_BUTTON), SetMinimalTextLines(2, 0), SetStringTip(STR_MAPGEN_GS_SETTINGS, STR_MAPGEN_GS_SETTINGS_TOOLTIP), SetFill(1, 0),
308 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_NEWGRF_BUTTON), SetMinimalTextLines(2, 0), SetStringTip(STR_MAPGEN_NEWGRF_SETTINGS, STR_MAPGEN_NEWGRF_SETTINGS_TOOLTIP), SetFill(1, 0),
309 EndContainer(),
310
311 /* Generate */
312 NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_GL_GENERATE_BUTTON), SetMinimalTextLines(3, 0), SetStringTip(STR_MAPGEN_GENERATE, STR_MAPGEN_GENERATE_TOOLTIP), SetFill(1, 1),
313 EndContainer(),
314 EndContainer(),
315};
316
317static void StartGeneratingLandscape(GenerateLandscapeWindowMode mode)
318{
321
322 /* Copy all XXX_newgame to XXX when coming from outside the editor */
323 MakeNewgameSettingsLive();
324 ResetGRFConfig(true);
325
327 switch (mode) {
328 case GLWM_GENERATE: _switch_mode = (_game_mode == GM_EDITOR) ? SM_GENRANDLAND : SM_NEWGAME; break;
329 case GLWM_HEIGHTMAP: _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_HEIGHTMAP : SM_START_HEIGHTMAP; break;
330 case GLWM_SCENARIO: _switch_mode = SM_EDITOR; break;
331 default: NOT_REACHED();
332 }
333}
334
335static void LandscapeGenerationCallback(Window *w, bool confirmed)
336{
337 if (confirmed) StartGeneratingLandscape(w->window_number);
338}
339
340static DropDownList BuildMapsizeDropDown()
341{
342 DropDownList list;
343
344 for (uint i = MIN_MAP_SIZE_BITS; i <= MAX_MAP_SIZE_BITS; i++) {
345 list.push_back(MakeDropDownListStringItem(GetString(STR_JUST_INT, 1ULL << i), i));
346 }
347
348 return list;
349}
350
351static DropDownList BuildTownNameDropDown()
352{
353 DropDownList list;
354
355 /* Add and sort newgrf townnames generators */
356 const auto &grf_names = GetGRFTownNameList();
357 for (uint i = 0; i < grf_names.size(); i++) {
358 list.push_back(MakeDropDownListStringItem(grf_names[i], BUILTIN_TOWNNAME_GENERATOR_COUNT + i));
359 }
360 std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
361
362 size_t newgrf_size = list.size();
363 /* Insert newgrf_names at the top of the list */
364 if (newgrf_size > 0) {
365 list.push_back(MakeDropDownListDividerItem()); // separator line
366 newgrf_size++;
367 }
368
369 /* Add and sort original townnames generators */
370 for (uint i = 0; i < BUILTIN_TOWNNAME_GENERATOR_COUNT; i++) {
371 list.push_back(MakeDropDownListStringItem(STR_MAPGEN_TOWN_NAME_ORIGINAL_ENGLISH + i, i));
372 }
373 std::sort(list.begin() + newgrf_size, list.end(), DropDownListStringItem::NatSortFunc);
374
375 return list;
376}
377
378
379static const StringID _elevations[] = {STR_TERRAIN_TYPE_VERY_FLAT, STR_TERRAIN_TYPE_FLAT, STR_TERRAIN_TYPE_HILLY, STR_TERRAIN_TYPE_MOUNTAINOUS, STR_TERRAIN_TYPE_ALPINIST, STR_TERRAIN_TYPE_CUSTOM};
380static const StringID _sea_lakes[] = {STR_SEA_LEVEL_VERY_LOW, STR_SEA_LEVEL_LOW, STR_SEA_LEVEL_MEDIUM, STR_SEA_LEVEL_HIGH, STR_SEA_LEVEL_CUSTOM};
381static const StringID _rivers[] = {STR_RIVERS_NONE, STR_RIVERS_FEW, STR_RIVERS_MODERATE, STR_RIVERS_LOT};
382static const StringID _smoothness[] = {STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_SMOOTH, STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_SMOOTH, STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_ROUGH, STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_ROUGH};
383static const StringID _rotation[] = {STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE};
384static const StringID _num_towns[] = {STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM};
385static const StringID _num_inds[] = {STR_FUNDING_ONLY, STR_MINIMAL, STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM};
386static const StringID _variety[] = {STR_VARIETY_NONE, STR_VARIETY_VERY_LOW, STR_VARIETY_LOW, STR_VARIETY_MEDIUM, STR_VARIETY_HIGH, STR_VARIETY_VERY_HIGH};
387
388static_assert(std::size(_num_inds) == ID_END);
389
391 WidgetID widget_id{};
392 uint x = 0;
393 uint y = 0;
394 std::string name{};
396
397 GenerateLandscapeWindow(WindowDesc &desc, WindowNumber number = 0) : Window(desc)
398 {
399 this->InitNested(number);
400
402
403 this->mode = this->window_number;
404
405 /* Disable town and industry in SE */
406 this->SetWidgetDisabledState(WID_GL_TOWN_PULLDOWN, _game_mode == GM_EDITOR);
407 this->SetWidgetDisabledState(WID_GL_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR);
408
409 /* In case the map_height_limit is changed, clamp heightmap_height and custom_terrain_type. */
412
413 /* If original landgenerator is selected and alpinist terrain_type was selected, revert to mountainous. */
416 }
417
418 this->OnInvalidateData();
419 }
420
421
422 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
423 {
424 switch (widget) {
429 case WID_GL_SNOW_COVERAGE_TEXT: return GetString(STR_MAPGEN_SNOW_COVERAGE_TEXT, _settings_newgame.game_creation.snow_coverage);
430 case WID_GL_DESERT_COVERAGE_TEXT: return GetString(STR_MAPGEN_DESERT_COVERAGE_TEXT, _settings_newgame.game_creation.desert_coverage);
431
433 if (_game_mode == GM_EDITOR) {
434 return GetString(STR_CONFIG_SETTING_OFF);
435 }
437 return GetString(STR_NUM_CUSTOM_NUMBER, _settings_newgame.game_creation.custom_town_number);
438 }
440
444 STR_MAPGEN_TOWN_NAME_ORIGINAL_ENGLISH + gen :
445 GetGRFTownNameName(gen - BUILTIN_TOWNNAME_GENERATOR_COUNT);
446 return GetString(name);
447 }
448
450 if (_game_mode == GM_EDITOR) {
451 return GetString(STR_CONFIG_SETTING_OFF);
452 }
455 }
457
460 return GetString(STR_TERRAIN_TYPE_CUSTOM_VALUE, _settings_newgame.game_creation.custom_terrain_type);
461 }
463
466 return GetString(STR_SEA_LEVEL_CUSTOM_PERCENTAGE, _settings_newgame.game_creation.custom_sea_level);
467 }
469
470 case WID_GL_HEIGHTMAP_NAME_TEXT: return this->name;
474 case WID_GL_BORDERS_RANDOM: return GetString((_settings_newgame.game_creation.water_borders == BorderFlag::Random) ? STR_MAPGEN_BORDER_RANDOMIZE : STR_MAPGEN_BORDER_MANUAL);
475 case WID_GL_WATER_NE: return GetString((_settings_newgame.game_creation.water_borders == BorderFlag::Random) ? STR_MAPGEN_BORDER_RANDOM : _settings_newgame.game_creation.water_borders.Test(BorderFlag::NorthEast) ? STR_MAPGEN_BORDER_WATER : STR_MAPGEN_BORDER_FREEFORM);
476 case WID_GL_WATER_NW: return GetString((_settings_newgame.game_creation.water_borders == BorderFlag::Random) ? STR_MAPGEN_BORDER_RANDOM : _settings_newgame.game_creation.water_borders.Test(BorderFlag::NorthWest) ? STR_MAPGEN_BORDER_WATER : STR_MAPGEN_BORDER_FREEFORM);
477 case WID_GL_WATER_SE: return GetString((_settings_newgame.game_creation.water_borders == BorderFlag::Random) ? STR_MAPGEN_BORDER_RANDOM : _settings_newgame.game_creation.water_borders.Test(BorderFlag::SouthEast) ? STR_MAPGEN_BORDER_WATER : STR_MAPGEN_BORDER_FREEFORM);
478 case WID_GL_WATER_SW: return GetString((_settings_newgame.game_creation.water_borders == BorderFlag::Random) ? STR_MAPGEN_BORDER_RANDOM : _settings_newgame.game_creation.water_borders.Test(BorderFlag::SouthWest) ? STR_MAPGEN_BORDER_WATER : STR_MAPGEN_BORDER_FREEFORM);
480
483 return GetString(STR_MAPGEN_HEIGHTMAP_SIZE, this->y, this->x);
484 }
485 return GetString(STR_MAPGEN_HEIGHTMAP_SIZE, this->x, this->y);
486
487 default:
488 return this->Window::GetWidgetString(widget, stringid);
489 }
490 }
491
497 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
498 {
499 if (!gui_scope) return;
500 /* Update the climate buttons */
505
506 /* You can't select smoothness / non-water borders if not terragenesis */
507 if (mode == GLWM_GENERATE) {
513
515
520
523 }
524
525 /* Disable snowline if not arctic */
527 /* Disable desert if not tropic */
529
530 /* Set snow/rainforest selections */
531 int climate_plane = 0;
533 case LandscapeType::Temperate: climate_plane = 2; break;
534 case LandscapeType::Arctic: climate_plane = 0; break;
535 case LandscapeType::Tropic: climate_plane = 1; break;
536 case LandscapeType::Toyland: climate_plane = 2; break;
537 }
538 this->GetWidget<NWidgetStacked>(WID_GL_CLIMATE_SEL_LABEL)->SetDisplayedPlane(climate_plane);
539 this->GetWidget<NWidgetStacked>(WID_GL_CLIMATE_SEL_SELECTOR)->SetDisplayedPlane(climate_plane);
540
541 /* Update availability of decreasing / increasing start date and snow level */
542 if (mode == GLWM_HEIGHTMAP) {
545 }
552
553 /* Do not allow a custom sea level or terrain type with the original land generator. */
557 }
560 }
561 }
562
563 }
564
565 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
566 {
568 std::span<const StringID> strs;
569 switch (widget) {
574 break;
575
578 break;
579
582 break;
583
587 break;
588
590 d = GetStringBoundingBox(GetString(STR_MAPGEN_SNOW_COVERAGE_TEXT, GetParamMaxValue(MAX_TILE_HEIGHT)));
591 break;
592
594 d = GetStringBoundingBox(GetString(STR_MAPGEN_DESERT_COVERAGE_TEXT, GetParamMaxValue(MAX_TILE_HEIGHT)));
595 break;
596
598 d = GetStringBoundingBox(GetString(STR_MAPGEN_HEIGHTMAP_SIZE, this->x, this->y));
599 break;
600
602 strs = _num_towns;
604 break;
605
607 strs = _num_inds;
609 break;
610
612 strs = _elevations;
613 d = GetStringBoundingBox(GetString(STR_TERRAIN_TYPE_CUSTOM_VALUE, GetParamMaxValue(MAX_MAP_HEIGHT_LIMIT)));
614 break;
615
617 strs = _sea_lakes;
619 break;
620
621 case WID_GL_RIVER_PULLDOWN: strs = _rivers; break;
622 case WID_GL_SMOOTHNESS_PULLDOWN: strs = _smoothness; break;
623 case WID_GL_VARIETY_PULLDOWN: strs = _variety; break;
624 case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: strs = _rotation; break;
626 d = maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_RANDOMIZE), GetStringBoundingBox(STR_MAPGEN_BORDER_MANUAL));
627 break;
628
629 case WID_GL_WATER_NE:
630 case WID_GL_WATER_NW:
631 case WID_GL_WATER_SE:
632 case WID_GL_WATER_SW:
633 d = maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_RANDOM), maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_WATER), GetStringBoundingBox(STR_MAPGEN_BORDER_FREEFORM)));
634 break;
635
637 size.width = 0;
638 break;
639
640 default:
641 return;
642 }
643 d = maxdim(d, GetStringListBoundingBox(strs));
644 d.width += padding.width;
645 d.height += padding.height;
646 size = maxdim(size, d);
647 }
648
649 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
650 {
651 switch (widget) {
652 case WID_GL_TEMPERATE:
653 case WID_GL_ARCTIC:
654 case WID_GL_TROPICAL:
655 case WID_GL_TOYLAND:
657 SndClickBeep();
658 break;
659
660 case WID_GL_MAPSIZE_X_PULLDOWN: // Mapsize X
662 break;
663
664 case WID_GL_MAPSIZE_Y_PULLDOWN: // Mapsize Y
666 break;
667
668 case WID_GL_TOWN_PULLDOWN: // Number of towns
670 break;
671
672 case WID_GL_TOWNNAME_DROPDOWN: // Townname generator
674 break;
675
676 case WID_GL_INDUSTRY_PULLDOWN: // Number of industries
678 break;
679
680 case WID_GL_GENERATE_BUTTON: { // Generate
681 /* Get rotated map size. */
682 uint map_x;
683 uint map_y;
685 map_x = this->y;
686 map_y = this->x;
687 } else {
688 map_x = this->x;
689 map_y = this->y;
690 }
691 if (mode == GLWM_HEIGHTMAP &&
692 (map_x * 2 < (1U << _settings_newgame.game_creation.map_x) ||
693 map_x / 2 > (1U << _settings_newgame.game_creation.map_x) ||
694 map_y * 2 < (1U << _settings_newgame.game_creation.map_y) ||
695 map_y / 2 > (1U << _settings_newgame.game_creation.map_y))) {
696 ShowQuery(
697 GetEncodedString(STR_WARNING_HEIGHTMAP_SCALE_CAPTION),
698 GetEncodedString(STR_WARNING_HEIGHTMAP_SCALE_MESSAGE),
699 this,
700 LandscapeGenerationCallback);
701 } else {
702 StartGeneratingLandscape(mode);
703 }
704 break;
705 }
706
708 case WID_GL_HEIGHTMAP_HEIGHT_UP: // Height level buttons
709 /* Don't allow too fast scrolling */
710 if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
711 this->HandleButtonClick(widget);
712
714 this->InvalidateData();
715 }
716 _left_button_clicked = false;
717 break;
718
719 case WID_GL_HEIGHTMAP_HEIGHT_TEXT: // Height level text
720 this->widget_id = WID_GL_HEIGHTMAP_HEIGHT_TEXT;
721 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.heightmap_height), STR_MAPGEN_HEIGHTMAP_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QueryStringFlag::EnableDefault);
722 SndClickBeep();
723 break;
724
725
727 case WID_GL_START_DATE_UP: // Year buttons
728 /* Don't allow too fast scrolling */
729 if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
730 this->HandleButtonClick(widget);
731
733 this->InvalidateData();
734 }
735 _left_button_clicked = false;
736 break;
737
738 case WID_GL_START_DATE_TEXT: // Year text
739 this->widget_id = WID_GL_START_DATE_TEXT;
740 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.starting_year), STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QueryStringFlag::EnableDefault);
741 break;
742
744 case WID_GL_SNOW_COVERAGE_UP: // Snow coverage buttons
745 /* Don't allow too fast scrolling */
746 if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
747 this->HandleButtonClick(widget);
748
750 this->InvalidateData();
751 }
752 _left_button_clicked = false;
753 break;
754
755 case WID_GL_SNOW_COVERAGE_TEXT: // Snow coverage text
756 this->widget_id = WID_GL_SNOW_COVERAGE_TEXT;
757 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.snow_coverage), STR_MAPGEN_SNOW_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QueryStringFlag::EnableDefault);
758 SndClickBeep();
759 break;
760
762 case WID_GL_DESERT_COVERAGE_UP: // Desert coverage buttons
763 /* Don't allow too fast scrolling */
764 if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
765 this->HandleButtonClick(widget);
766
768 this->InvalidateData();
769 }
770 _left_button_clicked = false;
771 break;
772
773 case WID_GL_DESERT_COVERAGE_TEXT: // Desert line text
774 this->widget_id = WID_GL_DESERT_COVERAGE_TEXT;
775 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.desert_coverage), STR_MAPGEN_DESERT_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QueryStringFlag::EnableDefault);
776 SndClickBeep();
777 break;
778
779 case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: // Heightmap rotation
781 break;
782
783 case WID_GL_TERRAIN_PULLDOWN: // Terrain type
784 /* For the original map generation only the first four are valid. */
786 break;
787
788 case WID_GL_WATER_PULLDOWN: { // Water quantity
789 uint32_t hidden_mask = 0;
790 /* Disable custom water level when the original map generator is active. */
793 }
795 break;
796 }
797
798 case WID_GL_RIVER_PULLDOWN: // Amount of rivers
800 break;
801
802 case WID_GL_SMOOTHNESS_PULLDOWN: // Map smoothness
804 break;
805
806 case WID_GL_VARIETY_PULLDOWN: // Map variety
808 break;
809
810 /* Freetype map borders */
811 case WID_GL_WATER_NW:
813 SndClickBeep();
814 this->InvalidateData();
815 break;
816
817 case WID_GL_WATER_NE:
819 SndClickBeep();
820 this->InvalidateData();
821 break;
822
823 case WID_GL_WATER_SE:
825 SndClickBeep();
826 this->InvalidateData();
827 break;
828
829 case WID_GL_WATER_SW:
831 SndClickBeep();
832 this->InvalidateData();
833 break;
834
838 } else {
840 }
841 SndClickBeep();
842 this->InvalidateData();
843 break;
844
845 case WID_GL_AI_BUTTON:
847 break;
848
849 case WID_GL_GS_BUTTON:
851 break;
852
854 ShowNewGRFSettings(true, true, false, _grfconfig_newgame);
855 break;
856 }
857 }
858
867
868 void OnDropdownSelect(WidgetID widget, int index, int) override
869 {
870 switch (widget) {
876
878
880 if ((uint)index == CUSTOM_TOWN_NUMBER_DIFFICULTY) {
881 this->widget_id = widget;
882 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.custom_town_number), STR_MAPGEN_NUMBER_OF_TOWNS, 5, this, CS_NUMERAL, {});
883 }
885 break;
886
887 case WID_GL_TOWNNAME_DROPDOWN: // Town names
888 if (_game_mode == GM_MENU || Town::GetNumItems() == 0) {
891 }
892 break;
893
895 if ((uint)index == ID_CUSTOM) {
896 this->widget_id = widget;
897 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.custom_industry_number), STR_MAPGEN_NUMBER_OF_INDUSTRIES, 5, this, CS_NUMERAL, {});
898 }
900 break;
901
903 if ((uint)index == CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY) {
904 this->widget_id = widget;
905 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.custom_terrain_type), STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT, 4, this, CS_NUMERAL, {});
906 }
908 break;
909 }
910
912 if ((uint)index == CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY) {
913 this->widget_id = widget;
914 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.custom_sea_level), STR_MAPGEN_SEA_LEVEL, 3, this, CS_NUMERAL, {});
915 }
917 break;
918 }
919 }
920 this->InvalidateData();
921 }
922
923 void OnQueryTextFinished(std::optional<std::string> str) override
924 {
925 /* Was 'cancel' pressed? */
926 if (!str.has_value()) return;
927
928 int32_t value;
929 if (!str->empty()) {
930 auto val = ParseInteger<int32_t>(*str, 10, true);
931 if (!val.has_value()) return;
932 value = *val;
933 } else {
934 /* An empty string means revert to the default */
935 switch (this->widget_id) {
937 case WID_GL_START_DATE_TEXT: value = CalendarTime::DEF_START_YEAR.base(); break;
938 case WID_GL_SNOW_COVERAGE_TEXT: value = DEF_SNOW_COVERAGE; break;
940 case WID_GL_TOWN_PULLDOWN: value = 1; break;
941 case WID_GL_INDUSTRY_PULLDOWN: value = 1; break;
944 default: NOT_REACHED();
945 }
946 }
947
948 switch (this->widget_id) {
952 break;
953
957 break;
958
962 break;
963
967 break;
968
971 break;
972
975 break;
976
979 break;
980
983 break;
984 }
985
986 this->InvalidateData();
987 }
988};
989
990static WindowDesc _generate_landscape_desc(
991 WDP_CENTER, {}, 0, 0,
993 {},
995);
996
997static WindowDesc _heightmap_load_desc(
998 WDP_CENTER, {}, 0, 0,
1000 {},
1002);
1003
1004static void _ShowGenerateLandscape(GenerateLandscapeWindowMode mode)
1005{
1006 uint x = 0;
1007 uint y = 0;
1008
1010
1011 /* Generate a new seed when opening the window */
1012 _settings_newgame.game_creation.generation_seed = InteractiveRandom();
1013
1014 if (mode == GLWM_HEIGHTMAP) {
1015 /* If the function returns negative, it means there was a problem loading the heightmap */
1017 }
1018
1019 WindowDesc &desc = (mode == GLWM_HEIGHTMAP) ? _heightmap_load_desc : _generate_landscape_desc;
1020 GenerateLandscapeWindow *w = AllocateWindowDescFront<GenerateLandscapeWindow, true>(desc, mode);
1021
1022 if (mode == GLWM_HEIGHTMAP) {
1023 w->x = x;
1024 w->y = y;
1025 w->name = _file_to_saveload.title;
1026 }
1027
1029}
1030
1033{
1034 _ShowGenerateLandscape(GLWM_GENERATE);
1035}
1036
1039{
1040 _ShowGenerateLandscape(GLWM_HEIGHTMAP);
1041}
1042
1045{
1046 StartGeneratingLandscape(GLWM_SCENARIO);
1047}
1048
1053void StartNewGameWithoutGUI(uint32_t seed)
1054{
1055 /* GenerateWorld takes care of the possible GENERATE_NEW_SEED value in 'seed' */
1057
1058 StartGeneratingLandscape(GLWM_GENERATE);
1059}
1060
1062{
1063 WidgetID widget_id{};
1064
1066 {
1067 this->InitNested(window_number);
1069 }
1070
1071 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
1072 {
1073 switch (widget) {
1076
1078 return GetString(STR_JUST_INT, 1LL << _settings_newgame.game_creation.map_x);
1079
1081 return GetString(STR_JUST_INT, 1LL << _settings_newgame.game_creation.map_y);
1082
1085
1086 default:
1087 return this->Window::GetWidgetString(widget, stringid);
1088 }
1089 }
1090
1105
1106 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
1107 {
1108 std::string str;
1109 switch (widget) {
1114 return;
1115
1118 break;
1119
1122 str = GetString(STR_JUST_INT, GetParamMaxValue(MAX_MAP_SIZE));
1123 break;
1124
1126 str = GetString(STR_JUST_INT, GetParamMaxValue(MAX_TILE_HEIGHT));
1127 break;
1128
1129 default:
1130 return;
1131 }
1133 d.width += padding.width;
1134 d.height += padding.height;
1135 size = maxdim(size, d);
1136 }
1137
1138 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1139 {
1140 switch (widget) {
1141 case WID_CS_TEMPERATE:
1142 case WID_CS_ARCTIC:
1143 case WID_CS_TROPICAL:
1144 case WID_CS_TOYLAND:
1147 break;
1148
1149 case WID_CS_MAPSIZE_X_PULLDOWN: // Mapsize X
1151 break;
1152
1153 case WID_CS_MAPSIZE_Y_PULLDOWN: // Mapsize Y
1155 break;
1156
1157 case WID_CS_EMPTY_WORLD: // Empty world / flat world
1158 StartGeneratingLandscape(GLWM_SCENARIO);
1159 break;
1160
1161 case WID_CS_RANDOM_WORLD: // Generate
1163 break;
1164
1166 case WID_CS_START_DATE_UP: // Year buttons
1167 /* Don't allow too fast scrolling */
1168 if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
1169 this->HandleButtonClick(widget);
1170 this->SetDirty();
1171
1173 }
1174 _left_button_clicked = false;
1175 break;
1176
1177 case WID_CS_START_DATE_TEXT: // Year text
1178 this->widget_id = WID_CS_START_DATE_TEXT;
1179 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.starting_year), STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, {});
1180 break;
1181
1183 case WID_CS_FLAT_LAND_HEIGHT_UP: // Height level buttons
1184 /* Don't allow too fast scrolling */
1185 if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
1186 this->HandleButtonClick(widget);
1187 this->SetDirty();
1188
1190 }
1191 _left_button_clicked = false;
1192 break;
1193
1194 case WID_CS_FLAT_LAND_HEIGHT_TEXT: // Height level text
1195 this->widget_id = WID_CS_FLAT_LAND_HEIGHT_TEXT;
1196 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.se_flat_world_height), STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, {});
1197 break;
1198 }
1199 }
1200
1205
1206 void OnDropdownSelect(WidgetID widget, int index, int) override
1207 {
1208 switch (widget) {
1211 }
1212 this->SetDirty();
1213 }
1214
1215 void OnQueryTextFinished(std::optional<std::string> str) override
1216 {
1217 if (!str.has_value()) return;
1218
1219 auto value = ParseInteger<int32_t>(*str, 10, true);
1220 if (!value.has_value()) return;
1221
1222 switch (this->widget_id) {
1226 break;
1227
1231 break;
1232 }
1233
1234 this->SetDirty();
1235 }
1236};
1237
1238static constexpr NWidgetPart _nested_create_scenario_widgets[] = {
1240 NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
1241 NWidget(WWT_CAPTION, COLOUR_BROWN), SetStringTip(STR_SE_MAPGEN_CAPTION),
1242 EndContainer(),
1243 NWidget(WWT_PANEL, COLOUR_BROWN),
1245 /* Landscape style selection. */
1247 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TEMPERATE), SetSpriteTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
1248 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_ARCTIC), SetSpriteTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
1249 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TROPICAL), SetSpriteTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
1250 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TOYLAND), SetSpriteTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
1251 EndContainer(),
1252
1254 /* Green generation type buttons: 'Flat land' and 'Random land'. */
1256 NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_CS_EMPTY_WORLD), SetStringTip(STR_SE_MAPGEN_FLAT_WORLD, STR_SE_MAPGEN_FLAT_WORLD_TOOLTIP), SetFill(1, 1),
1257 NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_CS_RANDOM_WORLD), SetStringTip(STR_SE_MAPGEN_RANDOM_LAND, STR_TERRAFORM_TOOLTIP_GENERATE_RANDOM_LAND), SetFill(1, 1),
1258 EndContainer(),
1259
1260 /* Labels + setting drop-downs */
1262 /* Labels. */
1264 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_MAPSIZE, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(0, 1),
1265 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_DATE, STR_MAPGEN_DATE_TOOLTIP), SetFill(0, 1),
1266 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_SE_MAPGEN_FLAT_WORLD_HEIGHT, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_TOOLTIP), SetFill(0, 1),
1267 EndContainer(),
1268
1270 /* Map size. */
1272 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_CS_MAPSIZE_X_PULLDOWN), SetToolTip(STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
1273 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_BY), SetFill(0, 1), SetAlignment(SA_CENTER),
1274 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_CS_MAPSIZE_Y_PULLDOWN), SetToolTip(STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
1275 EndContainer(),
1276
1277 /* Date. */
1279 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_CS_START_DATE_DOWN), SetFill(0, 1), SetSpriteTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_MOVE_THE_STARTING_DATE_BACKWARD_TOOLTIP), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
1280 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CS_START_DATE_TEXT), SetFill(1, 1), SetToolTip(STR_MAPGEN_DATE_TOOLTIP),
1281 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_CS_START_DATE_UP), SetFill(0, 1), SetSpriteTip(SPR_ARROW_UP, STR_SCENEDIT_TOOLBAR_MOVE_THE_STARTING_DATE_FORWARD_TOOLTIP), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
1282 EndContainer(),
1283
1284 /* Flat map height. */
1286 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_CS_FLAT_LAND_HEIGHT_DOWN), SetFill(0, 1), SetSpriteTip(SPR_ARROW_DOWN, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_DOWN_TOOLTIP), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
1287 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CS_FLAT_LAND_HEIGHT_TEXT), SetFill(1, 1), SetToolTip(STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_TOOLTIP),
1288 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_CS_FLAT_LAND_HEIGHT_UP), SetFill(0, 1), SetSpriteTip(SPR_ARROW_UP, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_UP_TOOLTIP), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
1289 EndContainer(),
1290 EndContainer(),
1291 EndContainer(),
1292 EndContainer(),
1293 EndContainer(),
1294 EndContainer(),
1295};
1296
1297static WindowDesc _create_scenario_desc(
1298 WDP_CENTER, {}, 0, 0,
1300 {},
1301 _nested_create_scenario_widgets
1302);
1303
1306{
1308 new CreateScenarioWindow(_create_scenario_desc, GLWM_SCENARIO);
1309}
1310
1311static constexpr NWidgetPart _nested_generate_progress_widgets[] = {
1312 NWidget(WWT_CAPTION, COLOUR_GREY), SetStringTip(STR_GENERATION_WORLD, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1313 NWidget(WWT_PANEL, COLOUR_GREY),
1315 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GP_PROGRESS_BAR), SetFill(1, 0),
1316 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GP_PROGRESS_TEXT), SetFill(1, 0),
1317 NWidget(WWT_TEXTBTN, COLOUR_WHITE, WID_GP_ABORT), SetStringTip(STR_GENERATION_ABORT), SetFill(1, 0),
1318 EndContainer(),
1319 EndContainer(),
1320};
1321
1322
1323static WindowDesc _generate_progress_desc(
1324 WDP_CENTER, {}, 0, 0,
1327 _nested_generate_progress_widgets
1328);
1329
1331 static inline uint percent;
1332 static inline StringID cls;
1333 static inline uint current;
1334 static inline uint total;
1335};
1336
1337static const StringID _generation_class_table[] = {
1338 STR_GENERATION_WORLD_GENERATION,
1339 STR_GENERATION_LANDSCAPE_GENERATION,
1340 STR_GENERATION_RIVER_GENERATION,
1341 STR_GENERATION_CLEARING_TILES,
1342 STR_GENERATION_TOWN_GENERATION,
1343 STR_GENERATION_INDUSTRY_GENERATION,
1344 STR_GENERATION_OBJECT_GENERATION,
1345 STR_GENERATION_TREE_GENERATION,
1346 STR_GENERATION_SETTINGUP_GAME,
1347 STR_GENERATION_PREPARING_TILELOOP,
1348 STR_GENERATION_PREPARING_SCRIPT,
1349 STR_GENERATION_PREPARING_GAME
1350};
1351static_assert(lengthof(_generation_class_table) == GWP_CLASS_COUNT);
1352
1353
1354static void AbortGeneratingWorldCallback(Window *, bool confirmed)
1355{
1356 if (confirmed) {
1358 } else if (HasModalProgress() && !IsGeneratingWorldAborted()) {
1359 SetMouseCursor(SPR_CURSOR_ZZZ, PAL_NONE);
1360 }
1361}
1362
1364
1365 GenerateProgressWindow() : Window(_generate_progress_desc)
1366 {
1367 this->InitNested();
1368 }
1369
1370 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1371 {
1372 switch (widget) {
1373 case WID_GP_ABORT:
1374 SetMouseCursorBusy(false);
1375 ShowQuery(
1376 GetEncodedString(STR_GENERATION_ABORT_CAPTION),
1377 GetEncodedString(STR_GENERATION_ABORT_MESSAGE),
1378 this,
1379 AbortGeneratingWorldCallback
1380 );
1381 break;
1382 }
1383 }
1384
1385 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
1386 {
1387 switch (widget) {
1388 case WID_GP_PROGRESS_BAR: {
1389 size = GetStringBoundingBox(GetString(STR_GENERATION_PROGRESS, GetParamMaxValue(100)));
1390 /* We need some spacing for the 'border' */
1393 break;
1394 }
1395
1397 for (uint i = 0; i < GWP_CLASS_COUNT; i++) {
1398 size.width = std::max(size.width, GetStringBoundingBox(_generation_class_table[i]).width + padding.width);
1399 }
1401 break;
1402 }
1403 }
1404
1405 void DrawWidget(const Rect &r, WidgetID widget) const override
1406 {
1407 switch (widget) {
1408 case WID_GP_PROGRESS_BAR: {
1409 /* Draw the % complete with a bar and a text */
1411 Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
1412 DrawFrameRect(br.WithWidth(br.Width() * GenWorldStatus::percent / 100, _current_text_dir == TD_RTL), COLOUR_MAUVE, {});
1413 DrawString(br.left, br.right, CentreBounds(br.top, br.bottom, GetCharacterHeight(FS_NORMAL)),
1414 GetString(STR_GENERATION_PROGRESS, GenWorldStatus::percent), TC_FROMSTRING, SA_HOR_CENTER);
1415 break;
1416 }
1417
1419 /* Tell which class we are generating */
1420 DrawString(r.left, r.right, r.top, GenWorldStatus::cls, TC_FROMSTRING, SA_HOR_CENTER);
1421
1422 /* And say where we are in that class */
1423 DrawString(r.left, r.right, r.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal,
1424 GetString(STR_GENERATION_PROGRESS_NUM, GenWorldStatus::current, GenWorldStatus::total), TC_FROMSTRING, SA_HOR_CENTER);
1425 }
1426 }
1427};
1428
1433{
1434 GenWorldStatus::cls = STR_GENERATION_WORLD_GENERATION;
1435 GenWorldStatus::current = 0;
1436 GenWorldStatus::total = 0;
1437 GenWorldStatus::percent = 0;
1438}
1439
1448
1449static void _SetGeneratingWorldProgress(GenWorldProgress cls, uint progress, uint total)
1450{
1451 static const int percent_table[] = {0, 5, 14, 17, 20, 40, 60, 65, 80, 85, 95, 99, 100 };
1452 static_assert(lengthof(percent_table) == GWP_CLASS_COUNT + 1);
1453 assert(cls < GWP_CLASS_COUNT);
1454
1455 /* Check if we really are generating the world.
1456 * For example, placing trees via the SE also calls this function, but
1457 * shouldn't try to update the progress.
1458 */
1459 if (!HasModalProgress()) return;
1460
1463 return;
1464 }
1465
1466 if (total == 0) {
1467 assert(GenWorldStatus::cls == _generation_class_table[cls]);
1468 GenWorldStatus::current += progress;
1469 assert(GenWorldStatus::current <= GenWorldStatus::total);
1470 } else {
1471 GenWorldStatus::cls = _generation_class_table[cls];
1472 GenWorldStatus::current = progress;
1473 GenWorldStatus::total = total;
1474 GenWorldStatus::percent = percent_table[cls];
1475 }
1476
1477 /* Percentage is about the number of completed tasks, so 'current - 1' */
1478 GenWorldStatus::percent = percent_table[cls] + (percent_table[cls + 1] - percent_table[cls]) * (GenWorldStatus::current == 0 ? 0 : GenWorldStatus::current - 1) / GenWorldStatus::total;
1479
1480 if (_network_dedicated) {
1481 static uint last_percent = 0;
1482
1483 /* Never display 0% */
1484 if (GenWorldStatus::percent == 0) return;
1485 /* Reset if percent is lower than the last recorded */
1486 if (GenWorldStatus::percent < last_percent) last_percent = 0;
1487 /* Display every 5%, but 6% is also very valid.. just not smaller steps than 5% */
1488 if (GenWorldStatus::percent % 5 != 0 && GenWorldStatus::percent <= last_percent + 5) return;
1489 /* Never show steps smaller than 2%, even if it is a mod 5% */
1490 if (GenWorldStatus::percent <= last_percent + 2) return;
1491
1492 Debug(net, 3, "Map generation percentage complete: {}", GenWorldStatus::percent);
1493 last_percent = GenWorldStatus::percent;
1494
1495 return;
1496 }
1497
1499
1501}
1502
1512{
1513 if (total == 0) return;
1514
1515 _SetGeneratingWorldProgress(cls, 0, total);
1516}
1517
1526{
1527 /* In fact the param 'class' isn't needed.. but for some security reasons, we want it around */
1528 _SetGeneratingWorldProgress(cls, 1, 0);
1529}
void ShowAIConfigWindow()
Open the AI config window.
Definition ai_gui.cpp:334
Window for configuring the AIs
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
constexpr Timpl & Reset()
Reset all bits.
constexpr Timpl & Flip(Tvalue_type value)
Flip the value-th bit.
static bool NatSortFunc(std::unique_ptr< const DropDownListItem > const &first, std::unique_ptr< const DropDownListItem > const &second)
Natural sorting comparator function for DropDownList::sort().
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
static constexpr TimerGame< struct Calendar >::Year DEF_START_YEAR
The default starting year.
static constexpr TimerGame< struct Calendar >::Year MIN_YEAR
The absolute minimum year in OTTD.
static constexpr TimerGame< struct Calendar >::Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date,...
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
void GameLoopPause()
Pause the game-loop for a bit, releasing the game-state lock.
RectPadding frametext
Padding inside frame with text.
Definition window_gui.h:41
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition window_gui.h:30
int vsep_normal
Normal vertical spacing.
Definition window_gui.h:58
RectPadding fullbevel
Always-scaled bevel thickness.
Definition window_gui.h:39
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:93
Functions related to debugging.
#define Debug(category, level, format_string,...)
Output a line of debugging information.
Definition debug.h:37
void ShowDropDownMenu(Window *w, std::span< const StringID > strings, int selected, WidgetID button, uint32_t disabled_mask, uint32_t hidden_mask, uint width)
Show a dropdown menu window near a widget of the parent window.
Definition dropdown.cpp:455
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close, bool persist)
Show a drop down list.
Definition dropdown.cpp:415
Common drop down list components.
Functions related to the drop down widget.
Types related to the drop down widget.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23)
Definition enum_type.hpp:17
Functions related to errors.
void ClearErrorMessages()
Clear all errors from the queue.
Declarations for savegames operations.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition fontcache.cpp:87
void ShowGSConfigWindow()
Open the GS config window.
Definition game_gui.cpp:425
Window for configuring the Games
void HandleGeneratingWorldAbortion()
Really handle the abortion, i.e.
Definition genworld.cpp:276
void AbortGeneratingWorld()
Initializes the abortion process.
Definition genworld.cpp:259
bool IsGeneratingWorldAborted()
Is the generation being aborted?
Definition genworld.cpp:268
Functions related to world/map generation.
static const uint MAP_HEIGHT_LIMIT_AUTO_MINIMUM
When map height limit is auto, make this the lowest possible map height limit.
Definition genworld.h:54
@ LG_ORIGINAL
The original landscape generator.
Definition genworld.h:21
static const uint CUSTOM_SEA_LEVEL_MAX_PERCENTAGE
Maximum percentage a user can specify for custom sea level.
Definition genworld.h:50
static const uint CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY
Value for custom sea level in difficulty settings.
Definition genworld.h:48
GenWorldProgress
Current stage of world generation process.
Definition genworld.h:61
static const uint CUSTOM_SEA_LEVEL_MIN_PERCENTAGE
Minimum percentage a user can specify for custom sea level.
Definition genworld.h:49
static const uint CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY
Value for custom terrain type in difficulty settings.
Definition genworld.h:46
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
void ShowGenerateWorldProgress()
Show the window where a user can follow the process of the map generation.
void ShowGenerateLandscape()
Start with a normal game.
static constexpr NWidgetPart _nested_heightmap_load_widgets[]
Widgets of GenerateLandscapeWindow when loading heightmap.
void ShowCreateScenario()
Show the window to create a scenario.
static constexpr NWidgetPart _nested_generate_landscape_widgets[]
Widgets of GenerateLandscapeWindow when generating world.
static uint GetMapHeightLimit()
Get the map height limit, or if set to "auto", the absolute limit.
void SetNewLandscapeType(LandscapeType landscape)
Changes landscape type and sets genworld window dirty.
void StartScenarioEditor()
Start with a scenario editor.
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
void PrepareGenerateWorldProgress()
Initializes the progress counters to the starting point.
GenerateLandscapeWindowMode
Enum for the modes we can generate in.
@ GLWM_GENERATE
Generate new game.
@ GLWM_HEIGHTMAP
Load from heightmap.
@ GLWM_SCENARIO
Generate flat land.
void ShowHeightmapLoad()
Start with loading a heightmap.
void StartNewGameWithoutGUI(uint32_t seed)
Start a normal game without the GUI.
Types related to the genworld widgets.
@ WID_CS_TROPICAL
Select tropical landscape style.
@ WID_CS_TEMPERATE
Select temperate landscape style.
@ WID_CS_MAPSIZE_X_PULLDOWN
Pull-down arrow for x map size.
@ WID_CS_TOYLAND
Select toy-land landscape style.
@ WID_CS_FLAT_LAND_HEIGHT_TEXT
Clickable flat land height value.
@ WID_CS_START_DATE_TEXT
Clickable start date value.
@ WID_CS_START_DATE_DOWN
Decrease start year (start earlier).
@ WID_CS_EMPTY_WORLD
Generate an empty flat world.
@ WID_CS_ARCTIC
Select arctic landscape style.
@ WID_CS_MAPSIZE_Y_PULLDOWN
Pull-down arrow for y map size.
@ WID_CS_FLAT_LAND_HEIGHT_DOWN
Decrease flat land height.
@ WID_CS_FLAT_LAND_HEIGHT_UP
Increase flat land height.
@ WID_CS_RANDOM_WORLD
Generate random land button.
@ WID_CS_START_DATE_UP
Increase start year (start later).
@ WID_GL_TOWNNAME_DROPDOWN
Dropdown 'Townnames'.
@ WID_GL_WATER_SE
SE 'Water'/'Freeform'.
@ WID_GL_WATER_PULLDOWN
Dropdown 'Sea level'.
@ WID_GL_MAPSIZE_X_PULLDOWN
Dropdown 'map X size'.
@ WID_GL_SNOW_COVERAGE_TEXT
Snow coverage.
@ WID_GL_WATER_NE
NE 'Water'/'Freeform'.
@ WID_GL_VARIETY_PULLDOWN
Dropdown 'Variety distribution'.
@ WID_GL_TOYLAND
Button with icon "Toyland".
@ WID_GL_GENERATE_BUTTON
'Generate' button.
@ WID_GL_ARCTIC
Button with icon "Arctic".
@ WID_GL_HEIGHTMAP_HEIGHT_TEXT
Max. heightmap highest mountain.
@ WID_GL_HEIGHTMAP_ROTATION_PULLDOWN
Dropdown 'Heightmap rotation'.
@ WID_GL_MAPSIZE_Y_PULLDOWN
Dropdown 'map Y size'.
@ WID_GL_TROPICAL
Button with icon "Tropical".
@ WID_GL_HEIGHTMAP_NAME_TEXT
Heightmap name.
@ WID_GL_RIVER_PULLDOWN
Dropdown 'Rivers'.
@ WID_GL_DESERT_COVERAGE_TEXT
Desert coverage.
@ WID_GL_AI_BUTTON
'AI Settings' button.
@ WID_GL_SNOW_COVERAGE_DOWN
Decrease snow coverage.
@ WID_GL_HEIGHTMAP_HEIGHT_UP
Increase max. heightmap highest mountain.
@ WID_GL_NEWGRF_BUTTON
'NewGRF Settings' button.
@ WID_GL_CLIMATE_SEL_LABEL
NWID_SELECTION for snow or desert coverage label.
@ WID_GL_BORDERS_RANDOM
'Random'/'Manual' borders.
@ WID_GL_HEIGHTMAP_SIZE_TEXT
Size of heightmap.
@ WID_GL_WATER_NW
NW 'Water'/'Freeform'.
@ WID_GL_TEMPERATE
Button with icon "Temperate".
@ WID_GL_SMOOTHNESS_PULLDOWN
Dropdown 'Smoothness'.
@ WID_GL_GS_BUTTON
'Game Script Settings' button.
@ WID_GL_START_DATE_DOWN
Decrease start year.
@ WID_GL_START_DATE_TEXT
Start year.
@ WID_GL_CLIMATE_SEL_SELECTOR
NWID_SELECTION for snow or desert coverage selector.
@ WID_GL_DESERT_COVERAGE_UP
Increase desert coverage.
@ WID_GL_TOWN_PULLDOWN
Dropdown 'No. of towns'.
@ WID_GL_HEIGHTMAP_HEIGHT_DOWN
Decrease heightmap highest mountain.
@ WID_GL_WATER_SW
SW 'Water'/'Freeform'.
@ WID_GL_SNOW_COVERAGE_UP
Increase snow coverage.
@ WID_GL_INDUSTRY_PULLDOWN
Dropdown 'No. of industries'.
@ WID_GL_DESERT_COVERAGE_DOWN
Decrease desert coverage.
@ WID_GL_TERRAIN_PULLDOWN
Dropdown 'Terrain type'.
@ WID_GL_START_DATE_UP
Increase start year.
@ WID_GP_PROGRESS_TEXT
Text with the progress bar.
@ WID_GP_PROGRESS_BAR
Progress bar.
@ WID_GP_ABORT
Abort button.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Geometry functions.
int CentreBounds(int min, int max, int size)
Determine where to position a centred object.
void SetMouseCursor(CursorID sprite, PaletteID pal)
Assign a single non-animated sprite to the cursor.
Definition gfx.cpp:1700
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition gfx.cpp:895
Dimension GetStringListBoundingBox(std::span< const StringID > list, FontSize fontsize)
Get maximum dimension of a list of strings.
Definition gfx.cpp:933
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.
Definition gfx.cpp:666
bool _left_button_clicked
Is left mouse button clicked?
Definition gfx.cpp:43
void SetMouseCursorBusy(bool busy)
Set or unset the ZZZ cursor.
Definition gfx.cpp:1684
SwitchMode _switch_mode
The next mainloop command.
Definition gfx.cpp:50
@ FS_NORMAL
Index of the normal font in the font tables.
Definition gfx_type.h:250
@ SA_RIGHT
Right align the text (must be a single bit).
Definition gfx_type.h:391
@ SA_HOR_CENTER
Horizontally center the text.
Definition gfx_type.h:390
@ SA_CENTER
Center both horizontally and vertically.
Definition gfx_type.h:399
@ SA_VERT_CENTER
Vertically center the text.
Definition gfx_type.h:395
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
constexpr NWidgetPart SetSpriteTip(SpriteID sprite, StringID tip={})
Widget part function for setting the sprite and tooltip.
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
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 SetAspect(float ratio, AspectFlags flags=AspectFlag::ResizeX)
Widget part function for setting the aspect ratio.
constexpr NWidgetPart SetTextStyle(TextColour colour, FontSize size=FS_NORMAL)
Widget part function for setting the text style.
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
constexpr NWidgetPart SetToolTip(StringID tip)
Widget part function for setting tooltip and clearing the widget data.
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
constexpr NWidgetPart SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
constexpr NWidgetPart SetAlignment(StringAlignment align)
Widget part function for setting the alignment of text/images.
constexpr NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post)
Widget part function for setting a pre/inter/post ratio.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition window.cpp:957
bool GetHeightmapDimensions(DetailedFileType dft, std::string_view filename, uint *x, uint *y)
Get the dimensions of a heightmap.
Functions related to creating heightmaps from files.
@ HM_CLOCKWISE
Rotate the map clockwise 45 degrees.
Definition heightmap.h:21
Base of all industries.
LandscapeType
Landscape types.
@ NorthWest
Border on North West.
@ Random
Randomise borders.
@ NorthEast
Border on North East.
@ SouthEast
Border on South East.
@ SouthWest
Border on South West.
static const uint MIN_MAP_SIZE_BITS
Minimal and maximal map width and height.
Definition map_type.h:37
static const uint MAX_MAP_SIZE
Maximal map size = 4096.
Definition map_type.h:40
static const uint MAX_MAP_SIZE_BITS
Maximal size of map is equal to 2 ^ MAX_MAP_SIZE_BITS.
Definition map_type.h:38
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition math_func.hpp:79
void ShowQuery(EncodedString &&caption, EncodedString &&message, Window *parent, QueryCallbackProc *callback, bool focus)
Show a confirmation window with standard 'yes' and 'no' buttons The window is aligned to the centre o...
void ShowQueryString(std::string_view str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
bool _network_dedicated
are we a dedicated server?
Definition network.cpp:70
Basic functions/variables used all over the place.
void ResetGRFConfig(bool defaults)
Reset the current GRF Config to either blank or newgame settings.
GRFConfigList _grfconfig_newgame
First item in list of default GRF set up.
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfigList &config)
Setup the NewGRF gui.
Header of Action 0F "universal holder" structure and functions.
@ SM_START_HEIGHTMAP
Load a heightmap and start a new game from it.
Definition openttd.h:38
@ SM_GENRANDLAND
Generate random land within scenario editor.
Definition openttd.h:36
@ SM_LOAD_HEIGHTMAP
Load heightmap from scenario editor.
Definition openttd.h:39
@ SM_EDITOR
Switch to scenario editor.
Definition openttd.h:31
@ SM_NEWGAME
New Game --> 'Random game'.
Definition openttd.h:28
Functions related to modal progress.
bool HasModalProgress()
Check if we are currently in a modal progress state.
Definition progress.h:17
Base for the GUIs that have an edit box in them.
Pseudo random number generator.
A number of safeguards to prevent using unsafe methods.
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
Definition saveload.cpp:66
Functions/types related to saving and loading games.
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Definition settings.cpp:62
@ ID_CUSTOM
Custom number of industries.
@ ID_END
Number of industry density settings.
void SndConfirmBeep()
Play a beep sound for a confirm event if enabled in settings.
Definition sound.cpp:261
void SndClickBeep()
Play a beep sound for a click event if enabled in settings.
Definition sound.cpp:253
Functions related to sound.
Definition of base types and functions in a cross-platform compatible way.
#define lengthof(array)
Return the length of an fixed size array.
Definition stdafx.h:271
Parse strings.
Functions related to low-level strings.
@ CS_NUMERAL
Only numeric ones.
Definition string_type.h:26
uint64_t GetParamMaxValue(uint64_t max_value, uint min_count, FontSize size)
Get some number that is suitable for string size computations.
Definition strings.cpp:236
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
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition strings.cpp:56
Functions related to OTTD's strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
static constexpr uint32_t BUILTIN_TOWNNAME_GENERATOR_COUNT
The number of builtin generators for town names.
@ TD_RTL
Text is written right-to-left by default.
bool freeform_edges
allow terraforming the tiles at the map edges
uint8_t map_height_limit
the maximum allowed heightlevel
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
void OnDropdownSelect(WidgetID widget, int index, int) override
A dropdown option associated to this window has been selected.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void OnQueryTextFinished(std::optional< std::string > str) override
The query window opened from this window has closed.
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.
void OnPaint() override
The window must be repainted.
void OnTimeout() override
Called when this window's timeout has been reached.
uint8_t number_towns
the amount of towns
uint8_t terrain_type
the mountainousness of the landscape
uint8_t industry_density
The industry density.
uint8_t quantity_sea_lakes
the amount of seas/lakes
Dimensions (a width and height) of a rectangle in 2D.
std::string title
Internal name of the game.
Definition saveload.h:426
FiosType ftype
File type.
Definition saveload.h:424
std::string name
Name of the file.
Definition saveload.h:425
DetailedFileType detailed
Detailed file type.
Definition fileio_type.h:65
uint8_t custom_sea_level
manually entered percentage of water in the map
uint8_t amount_of_rivers
the amount of rivers
uint16_t custom_town_number
manually entered number of towns
uint16_t custom_industry_number
manually entered number of industries
uint8_t variety
variety level applied to TGP
uint8_t snow_coverage
the amount of snow coverage on the map
uint8_t desert_coverage
the amount of desert coverage on the map
uint8_t custom_terrain_type
manually entered height for TGP to aim for
LandscapeType landscape
the landscape we're currently in
uint8_t map_x
X size of map.
uint8_t land_generator
the landscape generator
uint8_t tgen_smoothness
how rough is the terrain from 0-3
uint8_t se_flat_world_height
land height a flat world gets in SE
uint8_t town_name
the town name generator used for town names
uint8_t map_y
Y size of map.
TimerGameCalendar::Year starting_year
starting date
uint8_t heightmap_rotation
rotation director for the heightmap
BorderFlags water_borders
bitset of the borders that are water
uint32_t generation_seed
noise seed for world generation
uint8_t heightmap_height
highest mountain for heightmap (towards what it scales)
ConstructionSettings construction
construction of things in-game
DifficultySettings difficulty
settings related to the difficulty
GameCreationSettings game_creation
settings used during the creation of a game (map)
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.
void OnDropdownSelect(WidgetID widget, int index, int) override
A dropdown option associated to this window has been selected.
void OnTimeout() override
Called when this window's timeout has been reached.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
void OnQueryTextFinished(std::optional< std::string > str) override
The query window opened from this window has closed.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
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.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
Partial widget specification to allow NWidgets to be written nested.
static size_t GetNumItems()
Returns number of valid items in the pool.
static constexpr size_t MAX_SIZE
Make template parameter accessible from outside.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Specification of a rectangle with absolute coordinates of all edges.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Templated helper to make a type-safe 'typedef' representing a single POD value.
High level window description.
Definition window_gui.h:167
Number to differentiate different windows of the same class.
Data structure for an opened window.
Definition window_gui.h:273
void DrawWidgets() const
Paint all widgets of a window.
Definition widget.cpp:777
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Definition window.cpp:3207
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
Definition window_gui.h:469
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition window.cpp:556
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
Definition window.cpp:504
ResizeInfo resize
Resize information.
Definition window_gui.h:314
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
Definition window_gui.h:515
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition window_gui.h:441
void RaiseWidgetsWhenLowered(Args... widgets)
Raises the widgets and sets widgets dirty that are lowered.
Definition window_gui.h:536
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition window_gui.h:460
void HandleButtonClick(WidgetID widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
Definition window.cpp:595
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition window.cpp:1793
WindowFlags flags
Window flags.
Definition window_gui.h:300
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition window_gui.h:381
int width
width of the window (number of pixels to the right in x direction)
Definition window_gui.h:311
WindowNumber window_number
Window number within the window class.
Definition window_gui.h:302
@ EnableDefault
enable the 'Default' button ("\0" is returned)
static constexpr uint MAX_TILE_HEIGHT
Maximum allowed tile height.
Definition tile_type.h:24
static constexpr uint MIN_CUSTOM_TERRAIN_TYPE
Lowest possible peak value for world generation.
Definition tile_type.h:27
static constexpr uint DEF_DESERT_COVERAGE
Default desert coverage.
Definition tile_type.h:37
static constexpr uint MIN_MAP_HEIGHT_LIMIT
Lower bound of maximum allowed heightlevel (in the construction settings)
Definition tile_type.h:29
static constexpr uint MAX_MAP_HEIGHT_LIMIT
Upper bound of maximum allowed heightlevel (in the construction settings)
Definition tile_type.h:30
static constexpr uint MIN_HEIGHTMAP_HEIGHT
Lowest possible peak value for heightmap creation.
Definition tile_type.h:26
static constexpr uint DEF_SNOW_COVERAGE
Default snow coverage.
Definition tile_type.h:36
Definition of the game-calendar-timer.
Base of the town class.
static const uint CUSTOM_TOWN_MAX_NUMBER
this is the maximum number of towns a user can specify in customisation
Definition town.h:30
static const uint CUSTOM_TOWN_NUMBER_DIFFICULTY
value for custom town number in difficulty settings
Definition town.h:29
Definition of structures used for generating town names.
Base of all video drivers.
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition widget.cpp:298
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
@ WWT_IMGBTN
(Toggle) Button with image
Definition widget_type.h:42
@ WWT_IMGBTN_2
(Toggle) Button with diff image when clicked
Definition widget_type.h:43
@ NWID_SPACER
Invisible widget that takes some space.
Definition widget_type.h:71
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:67
@ WWT_TEXTBTN
(Toggle) Button with text
Definition widget_type.h:45
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:40
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition widget_type.h:53
@ NWID_VERTICAL
Vertical container.
Definition widget_type.h:69
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition widget_type.h:61
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition widget_type.h:38
@ WWT_DROPDOWN
Drop down list.
Definition widget_type.h:62
@ WWT_TEXT
Pure simple text.
Definition widget_type.h:50
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition widget_type.h:72
@ EqualSize
Containers should keep all their (resizing) children equally large.
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Definition window.cpp:1196
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
Definition window.cpp:1267
void CloseAllNonVitalWindows()
It is possible that a stickied window gets to a position where the 'close' button is outside the gami...
Definition window.cpp:3328
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition window.cpp:3149
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
Definition window.cpp:3284
Window functions not directly related to making/drawing windows.
@ NoClose
This window can't be interactively closed.
@ BorderOnly
Draw border only, no background.
@ Lowered
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
@ Timeout
Window timeout counter.
@ WDP_CENTER
Center the window.
Definition window_gui.h:145
int WidgetID
Widget ID.
Definition window_type.h:20
@ WN_GAME_OPTIONS_GAME_OPTIONS
Game options.
Definition window_type.h:28
@ WC_SELECT_GAME
Select game window; Window numbers:
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition window_type.h:47
@ WC_GENERATE_LANDSCAPE
Generate landscape (newgame); Window numbers:
@ WC_GAME_OPTIONS
Game options window; Window numbers:
@ WC_MODAL_PROGRESS
Progress report of landscape generation; Window numbers: