OpenTTD Source  20241108-master-g80f628063a
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_common_type.h"
23 #include "dropdown_func.h"
24 #include "querystring_gui.h"
25 #include "town.h"
26 #include "core/geometry_func.hpp"
27 #include "core/random_func.hpp"
28 #include "saveload/saveload.h"
29 #include "progress.h"
30 #include "error.h"
31 #include "newgrf_townname.h"
32 #include "townname_type.h"
33 #include "video/video_driver.hpp"
34 #include "ai/ai_gui.hpp"
35 #include "game/game_gui.hpp"
36 #include "industry.h"
37 
39 
40 #include "safeguards.h"
41 
42 
43 extern void MakeNewgameSettingsLive();
44 
50 };
51 
55 static uint GetMapHeightLimit()
56 {
59 }
60 
65 void SetNewLandscapeType(uint8_t landscape)
66 {
70 }
71 
75  NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
76  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_MAPGEN_WORLD_GENERATION_CAPTION, STR_NULL),
77  EndContainer(),
78  NWidget(WWT_PANEL, COLOUR_BROWN),
80  /* Landscape selection. */
82  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TEMPERATE), SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
83  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_ARCTIC), SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
84  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TROPICAL), SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
85  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TOYLAND), SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
86  EndContainer(),
87 
88  /* Generation options. */
90  /* Left half (land generation options) */
92  /* Labels on the left side (global column 1). */
94  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAPSIZE, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
95  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_TERRAIN_TYPE, STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT), SetFill(1, 1),
96  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_VARIETY, STR_CONFIG_SETTING_VARIETY_HELPTEXT), SetFill(1, 1),
97  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SMOOTHNESS, STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT), SetFill(1, 1),
98  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT), SetFill(1, 1),
99  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BORDER_TYPE, STR_MAPGEN_BORDER_TYPE_TOOLTIP), SetFill(1, 1),
100  EndContainer(),
101 
102  /* Widgets on the right side (global column 2). */
104  /* Mapsize X * Y. */
106  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_X_PULLDOWN), SetDataTip(STR_JUST_INT, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
107  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BY, STR_NULL), SetFill(0, 1), SetAlignment(SA_CENTER),
108  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_Y_PULLDOWN), SetDataTip(STR_JUST_INT, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
109  EndContainer(),
110  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TERRAIN_PULLDOWN), SetDataTip(STR_JUST_STRING1, STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT), SetFill(1, 1),
111  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_VARIETY_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_CONFIG_SETTING_VARIETY_HELPTEXT), SetFill(1, 1),
112  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_SMOOTHNESS_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT), SetFill(1, 1),
113  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_RIVER_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT), SetFill(1, 1),
114  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_BORDERS_RANDOM), SetDataTip(STR_JUST_STRING, STR_MAPGEN_BORDER_TYPE_TOOLTIP), SetFill(1, 1),
115  EndContainer(),
116  EndContainer(),
117 
118  /* Right half (all other options) */
120  /* Labels on the left side (global column 3). */
123  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SNOW_COVERAGE, STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT), SetFill(1, 1),
124  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DESERT_COVERAGE, STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT), SetFill(1, 1),
125  NWidget(NWID_SPACER), SetFill(1, 1),
126  EndContainer(),
127  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_MAPGEN_DATE_TOOLTIP), SetFill(1, 1),
128  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_TOWN_NAME_LABEL, STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP), SetFill(1, 1),
129  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_TOWNS, STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP), SetFill(1, 1),
130  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES, STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP), SetFill(1, 1),
131  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SEA_LEVEL, STR_MAPGEN_SEA_LEVEL_TOOLTIP), SetFill(1, 1),
132  EndContainer(),
133 
134  /* Widgets on the right side (global column 4). */
136  /* Climate selector. */
138  /* Snow coverage. */
140  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_COVERAGE_DOWN), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
141  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_TEXT), SetDataTip(STR_MAPGEN_SNOW_COVERAGE_TEXT, STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT), SetFill(1, 1),
142  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_COVERAGE_UP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
143  EndContainer(),
144  /* Desert coverage. */
146  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_DESERT_COVERAGE_DOWN), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
147  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_TEXT), SetDataTip(STR_MAPGEN_DESERT_COVERAGE_TEXT, STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT), SetFill(1, 1),
148  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_DESERT_COVERAGE_UP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
149  EndContainer(),
150  /* Temperate/Toyland spacer. */
151  NWidget(NWID_SPACER), SetFill(1, 1),
152  EndContainer(),
153  /* Starting date. */
155  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_BACKWARD), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
156  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetDataTip(STR_JUST_DATE_LONG, STR_MAPGEN_DATE_TOOLTIP), SetFill(1, 1),
157  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_UP), SetDataTip(SPR_ARROW_UP, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_FORWARD), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
158  EndContainer(),
159  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWNNAME_DROPDOWN), SetDataTip(STR_JUST_STRING, STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP), SetFill(1, 1),
160  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWN_PULLDOWN), SetDataTip(STR_JUST_STRING1, STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP), SetFill(1, 1),
161  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_INDUSTRY_PULLDOWN), SetDataTip(STR_JUST_STRING1, STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP), SetFill(1, 1),
162  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_WATER_PULLDOWN), SetDataTip(STR_JUST_STRING1, STR_MAPGEN_SEA_LEVEL_TOOLTIP), SetFill(1, 1),
163  EndContainer(),
164  EndContainer(),
165  EndContainer(),
166 
167  /* Map borders buttons for each edge. */
170  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NORTHWEST, STR_NULL), SetPadding(0, WidgetDimensions::unscaled.hsep_normal, 0, 0), SetFill(1, 1), SetAlignment(SA_RIGHT | SA_VERT_CENTER),
171  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_NW), SetDataTip(STR_JUST_STRING, STR_MAPGEN_NORTHWEST), SetFill(1, 1),
172  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_NE), SetDataTip(STR_JUST_STRING, STR_MAPGEN_NORTHEAST), SetFill(1, 1),
173  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NORTHEAST, STR_NULL), SetPadding(0, 0, 0, WidgetDimensions::unscaled.hsep_normal), SetFill(1, 1),
174  EndContainer(),
176  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SOUTHWEST, STR_NULL), SetPadding(0, WidgetDimensions::unscaled.hsep_normal, 0, 0), SetFill(1, 1), SetAlignment(SA_RIGHT | SA_VERT_CENTER),
177  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_SW), SetDataTip(STR_JUST_STRING, STR_MAPGEN_SOUTHWEST), SetFill(1, 1),
178  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_SE), SetDataTip(STR_JUST_STRING, STR_MAPGEN_SOUTHEAST), SetFill(1, 1),
179  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SOUTHEAST, STR_NULL), SetPadding(0, 0, 0, WidgetDimensions::unscaled.hsep_normal), SetFill(1, 1),
180  EndContainer(),
181  EndContainer(),
182 
183  /* AI, GS, and NewGRF settings */
185  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_AI_BUTTON), SetMinimalTextLines(2, 0), SetDataTip(STR_MAPGEN_AI_SETTINGS, STR_MAPGEN_AI_SETTINGS_TOOLTIP), SetFill(1, 0),
186  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_GS_BUTTON), SetMinimalTextLines(2, 0), SetDataTip(STR_MAPGEN_GS_SETTINGS, STR_MAPGEN_GS_SETTINGS_TOOLTIP), SetFill(1, 0),
187  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_NEWGRF_BUTTON), SetMinimalTextLines(2, 0), SetDataTip(STR_MAPGEN_NEWGRF_SETTINGS, STR_MAPGEN_NEWGRF_SETTINGS_TOOLTIP), SetFill(1, 0),
188  EndContainer(),
189 
190  /* Generate */
191  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_GL_GENERATE_BUTTON), SetMinimalTextLines(3, 0), SetDataTip(STR_MAPGEN_GENERATE, STR_MAPGEN_GENERATE_TOOLTIP), SetFill(1, 1),
192  EndContainer(),
193  EndContainer(),
194 };
195 
198  /* Window header. */
200  NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
201  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_MAPGEN_WORLD_GENERATION_CAPTION, STR_NULL),
202  EndContainer(),
203  NWidget(WWT_PANEL, COLOUR_BROWN),
205  /* Landscape selection. */
207  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TEMPERATE), SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
208  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_ARCTIC), SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
209  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TROPICAL), SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
210  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TOYLAND), SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
211  EndContainer(),
212 
214  /* Heightmap name label. */
215  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_NAME, STR_MAPGEN_HEIGHTMAP_NAME_TOOLTIP),
216  NWidget(WWT_TEXT, COLOUR_ORANGE, WID_GL_HEIGHTMAP_NAME_TEXT), SetTextStyle(TC_ORANGE), SetDataTip(STR_JUST_RAW_STRING, STR_MAPGEN_HEIGHTMAP_NAME_TOOLTIP), SetFill(1, 0),
217  EndContainer(),
218 
219  /* Generation options. */
221  /* Left half (land generation options) */
223  /* Labels on the left side (global column 1). */
225  /* Land generation option labels. */
226  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_SIZE_LABEL, STR_MAPGEN_HEIGHTMAP_SIZE_LABEL_TOOLTIP), SetFill(1, 1),
227  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAPSIZE, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
228  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_ROTATION, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_TOOLTIP), SetFill(1, 1),
229  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_HEIGHT, STR_MAPGEN_HEIGHTMAP_HEIGHT_TOOLTIP), SetFill(1, 1),
230  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT), SetFill(1, 1),
231  EndContainer(),
232 
233  /* Left half widgets (global column 2) */
235  NWidget(WWT_TEXT, COLOUR_ORANGE, WID_GL_HEIGHTMAP_SIZE_TEXT), SetDataTip(STR_MAPGEN_HEIGHTMAP_SIZE, STR_MAPGEN_HEIGHTMAP_SIZE_LABEL_TOOLTIP), SetFill(1, 1),
236  /* Mapsize X * Y. */
238  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_X_PULLDOWN), SetDataTip(STR_JUST_INT, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
239  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BY, STR_NULL), SetFill(0, 1), SetAlignment(SA_CENTER),
240  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_Y_PULLDOWN), SetDataTip(STR_JUST_INT, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
241  EndContainer(),
242  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_ROTATION_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_TOOLTIP), SetFill(1, 1),
243  /* Heightmap highest peak. */
245  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_HEIGHTMAP_HEIGHT_DOWN), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
246  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_TEXT), SetDataTip(STR_JUST_INT, STR_MAPGEN_HEIGHTMAP_HEIGHT_TOOLTIP), SetFill(1, 1),
247  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_HEIGHTMAP_HEIGHT_UP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
248  EndContainer(),
249  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_RIVER_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT), SetFill(1, 1),
250  EndContainer(),
251  EndContainer(),
252 
253  /* Right half (all other options) */
255  /* Right half labels (global column 3) */
258  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SNOW_COVERAGE, STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT), SetFill(1, 1),
259  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DESERT_COVERAGE, STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT), SetFill(1, 1),
260  NWidget(NWID_SPACER), SetFill(1, 1),
261  EndContainer(),
262  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_MAPGEN_DATE_TOOLTIP), SetFill(1, 1),
263  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_TOWN_NAME_LABEL, STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP), SetFill(1, 1),
264  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_TOWNS, STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP), SetFill(1, 1),
265  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES, STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP), SetFill(1, 1),
266  EndContainer(),
267 
268  /* Right half widgets (global column 4) */
270  /* Climate selector. */
272  /* Snow coverage. */
274  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_COVERAGE_DOWN), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
275  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_TEXT), SetDataTip(STR_MAPGEN_SNOW_COVERAGE_TEXT, STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT), SetFill(1, 1),
276  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_COVERAGE_UP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
277  EndContainer(),
278  /* Desert coverage. */
280  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_DESERT_COVERAGE_DOWN), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
281  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_TEXT), SetDataTip(STR_MAPGEN_DESERT_COVERAGE_TEXT, STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT), SetFill(1, 1),
282  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_DESERT_COVERAGE_UP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
283  EndContainer(),
284  /* Temperate/Toyland spacer. */
285  NWidget(NWID_SPACER), SetFill(1, 1),
286  EndContainer(),
287  /* Starting date. */
289  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_BACKWARD), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
290  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetDataTip(STR_JUST_DATE_LONG, STR_MAPGEN_DATE_TOOLTIP), SetFill(1, 1),
291  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_UP), SetDataTip(SPR_ARROW_UP, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_FORWARD), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
292  EndContainer(),
293  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWNNAME_DROPDOWN), SetDataTip(STR_JUST_STRING, STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP), SetFill(1, 1),
294  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWN_PULLDOWN), SetDataTip(STR_JUST_STRING1, STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP), SetFill(1, 1),
295  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_INDUSTRY_PULLDOWN), SetDataTip(STR_JUST_STRING1, STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP), SetFill(1, 1),
296  EndContainer(),
297  EndContainer(),
298  EndContainer(),
299 
300  /* AI, GS, and NewGRF settings */
302  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_AI_BUTTON), SetMinimalTextLines(2, 0), SetDataTip(STR_MAPGEN_AI_SETTINGS, STR_MAPGEN_AI_SETTINGS_TOOLTIP), SetFill(1, 0),
303  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_GS_BUTTON), SetMinimalTextLines(2, 0), SetDataTip(STR_MAPGEN_GS_SETTINGS, STR_MAPGEN_GS_SETTINGS_TOOLTIP), SetFill(1, 0),
304  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_NEWGRF_BUTTON), SetMinimalTextLines(2, 0), SetDataTip(STR_MAPGEN_NEWGRF_SETTINGS, STR_MAPGEN_NEWGRF_SETTINGS_TOOLTIP), SetFill(1, 0),
305  EndContainer(),
306 
307  /* Generate */
308  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_GL_GENERATE_BUTTON), SetMinimalTextLines(3, 0), SetDataTip(STR_MAPGEN_GENERATE, STR_MAPGEN_GENERATE_TOOLTIP), SetFill(1, 1),
309  EndContainer(),
310  EndContainer(),
311 };
312 
313 static void StartGeneratingLandscape(GenerateLandscapeWindowMode mode)
314 {
317 
318  /* Copy all XXX_newgame to XXX when coming from outside the editor */
319  MakeNewgameSettingsLive();
320  ResetGRFConfig(true);
321 
322  if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP);
323  switch (mode) {
324  case GLWM_GENERATE: _switch_mode = (_game_mode == GM_EDITOR) ? SM_GENRANDLAND : SM_NEWGAME; break;
325  case GLWM_HEIGHTMAP: _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_HEIGHTMAP : SM_START_HEIGHTMAP; break;
326  case GLWM_SCENARIO: _switch_mode = SM_EDITOR; break;
327  default: NOT_REACHED();
328  }
329 }
330 
331 static void LandscapeGenerationCallback(Window *w, bool confirmed)
332 {
333  if (confirmed) StartGeneratingLandscape((GenerateLandscapeWindowMode)w->window_number);
334 }
335 
336 static DropDownList BuildMapsizeDropDown()
337 {
338  DropDownList list;
339 
340  for (uint i = MIN_MAP_SIZE_BITS; i <= MAX_MAP_SIZE_BITS; i++) {
341  SetDParam(0, 1LL << i);
342  list.push_back(MakeDropDownListStringItem(STR_JUST_INT, i));
343  }
344 
345  return list;
346 }
347 
348 static DropDownList BuildTownNameDropDown()
349 {
350  DropDownList list;
351 
352  /* Add and sort newgrf townnames generators */
353  const auto &grf_names = GetGRFTownNameList();
354  for (uint i = 0; i < grf_names.size(); i++) {
355  list.push_back(MakeDropDownListStringItem(grf_names[i], BUILTIN_TOWNNAME_GENERATOR_COUNT + i));
356  }
357  std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
358 
359  size_t newgrf_size = list.size();
360  /* Insert newgrf_names at the top of the list */
361  if (newgrf_size > 0) {
362  list.push_back(MakeDropDownListDividerItem()); // separator line
363  newgrf_size++;
364  }
365 
366  /* Add and sort original townnames generators */
367  for (uint i = 0; i < BUILTIN_TOWNNAME_GENERATOR_COUNT; i++) {
368  list.push_back(MakeDropDownListStringItem(STR_MAPGEN_TOWN_NAME_ORIGINAL_ENGLISH + i, i));
369  }
370  std::sort(list.begin() + newgrf_size, list.end(), DropDownListStringItem::NatSortFunc);
371 
372  return list;
373 }
374 
375 
376 static 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};
377 static 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};
378 static const StringID _rivers[] = {STR_RIVERS_NONE, STR_RIVERS_FEW, STR_RIVERS_MODERATE, STR_RIVERS_LOT};
379 static 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};
380 static const StringID _rotation[] = {STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE};
381 static const StringID _num_towns[] = {STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM};
382 static 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};
383 static const StringID _variety[] = {STR_VARIETY_NONE, STR_VARIETY_VERY_LOW, STR_VARIETY_LOW, STR_VARIETY_MEDIUM, STR_VARIETY_HIGH, STR_VARIETY_VERY_HIGH};
384 
385 static_assert(std::size(_num_inds) == ID_END);
386 
388  WidgetID widget_id;
389  uint x;
390  uint y;
391  std::string name;
393 
394  GenerateLandscapeWindow(WindowDesc &desc, WindowNumber number = 0) : Window(desc)
395  {
396  this->InitNested(number);
397 
399 
400  this->mode = (GenerateLandscapeWindowMode)this->window_number;
401 
402  /* Disable town and industry in SE */
403  this->SetWidgetDisabledState(WID_GL_TOWN_PULLDOWN, _game_mode == GM_EDITOR);
404  this->SetWidgetDisabledState(WID_GL_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR);
405 
406  /* In case the map_height_limit is changed, clamp heightmap_height and custom_terrain_type. */
409 
410  /* If original landgenerator is selected and alpinist terrain_type was selected, revert to mountainous. */
413  }
414 
415  this->OnInvalidateData();
416  }
417 
418 
419  void SetStringParameters(WidgetID widget) const override
420  {
421  switch (widget) {
428 
430  if (_game_mode == GM_EDITOR) {
431  SetDParam(0, STR_CONFIG_SETTING_OFF);
433  SetDParam(0, STR_NUM_CUSTOM_NUMBER);
435  } else {
437  }
438  break;
439 
443  STR_MAPGEN_TOWN_NAME_ORIGINAL_ENGLISH + gen :
444  GetGRFTownNameName(gen - BUILTIN_TOWNNAME_GENERATOR_COUNT);
445  SetDParam(0, name);
446  break;
447  }
448 
450  if (_game_mode == GM_EDITOR) {
451  SetDParam(0, STR_CONFIG_SETTING_OFF);
453  SetDParam(0, STR_NUM_CUSTOM_NUMBER);
455  } else {
457  }
458  break;
459 
462  SetDParam(0, STR_TERRAIN_TYPE_CUSTOM_VALUE);
464  } else {
465  SetDParam(0, _elevations[_settings_newgame.difficulty.terrain_type]); break;
466  }
467  break;
468 
471  SetDParam(0, STR_SEA_LEVEL_CUSTOM_PERCENTAGE);
473  } else {
475  }
476  break;
477 
478  case WID_GL_HEIGHTMAP_NAME_TEXT: SetDParamStr(0, this->name); break;
482  case WID_GL_BORDERS_RANDOM: SetDParam(0, (_settings_newgame.game_creation.water_borders == BORDERS_RANDOM) ? STR_MAPGEN_BORDER_RANDOMIZE : STR_MAPGEN_BORDER_MANUAL); break;
483  case WID_GL_WATER_NE: SetDParam(0, (_settings_newgame.game_creation.water_borders == BORDERS_RANDOM) ? STR_MAPGEN_BORDER_RANDOM : HasBit(_settings_newgame.game_creation.water_borders, BORDER_NE) ? STR_MAPGEN_BORDER_WATER : STR_MAPGEN_BORDER_FREEFORM); break;
484  case WID_GL_WATER_NW: SetDParam(0, (_settings_newgame.game_creation.water_borders == BORDERS_RANDOM) ? STR_MAPGEN_BORDER_RANDOM : HasBit(_settings_newgame.game_creation.water_borders, BORDER_NW) ? STR_MAPGEN_BORDER_WATER : STR_MAPGEN_BORDER_FREEFORM); break;
485  case WID_GL_WATER_SE: SetDParam(0, (_settings_newgame.game_creation.water_borders == BORDERS_RANDOM) ? STR_MAPGEN_BORDER_RANDOM : HasBit(_settings_newgame.game_creation.water_borders, BORDER_SE) ? STR_MAPGEN_BORDER_WATER : STR_MAPGEN_BORDER_FREEFORM); break;
486  case WID_GL_WATER_SW: SetDParam(0, (_settings_newgame.game_creation.water_borders == BORDERS_RANDOM) ? STR_MAPGEN_BORDER_RANDOM : HasBit(_settings_newgame.game_creation.water_borders, BORDER_SW) ? STR_MAPGEN_BORDER_WATER : STR_MAPGEN_BORDER_FREEFORM); break;
488 
491  SetDParam(0, this->y);
492  SetDParam(1, this->x);
493  } else {
494  SetDParam(0, this->x);
495  SetDParam(1, this->y);
496  }
497  break;
498  }
499  }
500 
506  void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
507  {
508  if (!gui_scope) return;
509  /* Update the climate buttons */
514 
515  /* You can't select smoothness / non-water borders if not terragenesis */
516  if (mode == GLWM_GENERATE) {
522 
524 
529 
532  }
533 
534  /* Disable snowline if not arctic */
536  /* Disable desert if not tropic */
538 
539  /* Set snow/rainforest selections */
540  int climate_plane = 0;
542  case LT_TEMPERATE: climate_plane = 2; break;
543  case LT_ARCTIC: climate_plane = 0; break;
544  case LT_TROPIC: climate_plane = 1; break;
545  case LT_TOYLAND: climate_plane = 2; break;
546  }
547  this->GetWidget<NWidgetStacked>(WID_GL_CLIMATE_SEL_LABEL)->SetDisplayedPlane(climate_plane);
548  this->GetWidget<NWidgetStacked>(WID_GL_CLIMATE_SEL_SELECTOR)->SetDisplayedPlane(climate_plane);
549 
550  /* Update availability of decreasing / increasing start date and snow level */
551  if (mode == GLWM_HEIGHTMAP) {
554  }
561 
562  /* Do not allow a custom sea level or terrain type with the original land generator. */
566  }
569  }
570  }
571 
572  }
573 
574  void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
575  {
577  std::span<const StringID> strs;
578  switch (widget) {
579  case WID_GL_TEMPERATE: case WID_GL_ARCTIC:
580  case WID_GL_TROPICAL: case WID_GL_TOYLAND:
583  break;
584 
587  d = GetStringBoundingBox(STR_JUST_INT);
588  break;
589 
592  d = GetStringBoundingBox(STR_JUST_DATE_LONG);
593  break;
594 
598  d = GetStringBoundingBox(STR_JUST_INT);
599  break;
600 
603  d = GetStringBoundingBox(STR_MAPGEN_SNOW_COVERAGE_TEXT);
604  break;
605 
608  d = GetStringBoundingBox(STR_MAPGEN_DESERT_COVERAGE_TEXT);
609  break;
610 
612  SetDParam(0, this->x);
613  SetDParam(1, this->y);
614  d = GetStringBoundingBox(STR_MAPGEN_HEIGHTMAP_SIZE);
615  break;
616 
618  strs = _num_towns;
620  d = GetStringBoundingBox(STR_NUM_CUSTOM_NUMBER);
621  break;
622 
624  strs = _num_inds;
626  d = GetStringBoundingBox(STR_NUM_CUSTOM_NUMBER);
627  break;
628 
630  strs = _elevations;
632  d = GetStringBoundingBox(STR_TERRAIN_TYPE_CUSTOM_VALUE);
633  break;
634 
636  strs = _sea_lakes;
638  d = GetStringBoundingBox(STR_SEA_LEVEL_CUSTOM_PERCENTAGE);
639  break;
640 
641  case WID_GL_RIVER_PULLDOWN: strs = _rivers; break;
642  case WID_GL_SMOOTHNESS_PULLDOWN: strs = _smoothness; break;
643  case WID_GL_VARIETY_PULLDOWN: strs = _variety; break;
644  case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: strs = _rotation; break;
646  d = maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_RANDOMIZE), GetStringBoundingBox(STR_MAPGEN_BORDER_MANUAL));
647  break;
648 
649  case WID_GL_WATER_NE:
650  case WID_GL_WATER_NW:
651  case WID_GL_WATER_SE:
652  case WID_GL_WATER_SW:
653  d = maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_RANDOM), maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_WATER), GetStringBoundingBox(STR_MAPGEN_BORDER_FREEFORM)));
654  break;
655 
657  size.width = 0;
658  break;
659 
660  default:
661  return;
662  }
663  d = maxdim(d, GetStringListBoundingBox(strs));
664  d.width += padding.width;
665  d.height += padding.height;
666  size = maxdim(size, d);
667  }
668 
669  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
670  {
671  switch (widget) {
672  case WID_GL_TEMPERATE:
673  case WID_GL_ARCTIC:
674  case WID_GL_TROPICAL:
675  case WID_GL_TOYLAND:
677  break;
678 
679  case WID_GL_MAPSIZE_X_PULLDOWN: // Mapsize X
681  break;
682 
683  case WID_GL_MAPSIZE_Y_PULLDOWN: // Mapsize Y
685  break;
686 
687  case WID_GL_TOWN_PULLDOWN: // Number of towns
689  break;
690 
691  case WID_GL_TOWNNAME_DROPDOWN: // Townname generator
693  break;
694 
695  case WID_GL_INDUSTRY_PULLDOWN: // Number of industries
697  break;
698 
699  case WID_GL_GENERATE_BUTTON: { // Generate
700  /* Get rotated map size. */
701  uint map_x;
702  uint map_y;
704  map_x = this->y;
705  map_y = this->x;
706  } else {
707  map_x = this->x;
708  map_y = this->y;
709  }
710  if (mode == GLWM_HEIGHTMAP &&
711  (map_x * 2 < (1U << _settings_newgame.game_creation.map_x) ||
712  map_x / 2 > (1U << _settings_newgame.game_creation.map_x) ||
713  map_y * 2 < (1U << _settings_newgame.game_creation.map_y) ||
714  map_y / 2 > (1U << _settings_newgame.game_creation.map_y))) {
715  ShowQuery(
716  STR_WARNING_HEIGHTMAP_SCALE_CAPTION,
717  STR_WARNING_HEIGHTMAP_SCALE_MESSAGE,
718  this,
719  LandscapeGenerationCallback);
720  } else {
721  StartGeneratingLandscape(mode);
722  }
723  break;
724  }
725 
727  case WID_GL_HEIGHTMAP_HEIGHT_UP: // Height level buttons
728  /* Don't allow too fast scrolling */
729  if (!(this->flags & WF_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_HEIGHTMAP_HEIGHT_TEXT: // Height level text
739  this->widget_id = WID_GL_HEIGHTMAP_HEIGHT_TEXT;
741  ShowQueryString(STR_JUST_INT, STR_MAPGEN_HEIGHTMAP_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
742  break;
743 
744 
746  case WID_GL_START_DATE_UP: // Year buttons
747  /* Don't allow too fast scrolling */
748  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
749  this->HandleButtonClick(widget);
750 
752  this->InvalidateData();
753  }
754  _left_button_clicked = false;
755  break;
756 
757  case WID_GL_START_DATE_TEXT: // Year text
758  this->widget_id = WID_GL_START_DATE_TEXT;
760  ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
761  break;
762 
764  case WID_GL_SNOW_COVERAGE_UP: // Snow coverage buttons
765  /* Don't allow too fast scrolling */
766  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
767  this->HandleButtonClick(widget);
768 
770  this->InvalidateData();
771  }
772  _left_button_clicked = false;
773  break;
774 
775  case WID_GL_SNOW_COVERAGE_TEXT: // Snow coverage text
776  this->widget_id = WID_GL_SNOW_COVERAGE_TEXT;
778  ShowQueryString(STR_JUST_INT, STR_MAPGEN_SNOW_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
779  break;
780 
782  case WID_GL_DESERT_COVERAGE_UP: // Desert coverage buttons
783  /* Don't allow too fast scrolling */
784  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
785  this->HandleButtonClick(widget);
786 
788  this->InvalidateData();
789  }
790  _left_button_clicked = false;
791  break;
792 
793  case WID_GL_DESERT_COVERAGE_TEXT: // Desert line text
794  this->widget_id = WID_GL_DESERT_COVERAGE_TEXT;
796  ShowQueryString(STR_JUST_INT, STR_MAPGEN_DESERT_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
797  break;
798 
799  case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: // Heightmap rotation
801  break;
802 
803  case WID_GL_TERRAIN_PULLDOWN: // Terrain type
804  /* For the original map generation only the first four are valid. */
806  break;
807 
808  case WID_GL_WATER_PULLDOWN: { // Water quantity
809  uint32_t hidden_mask = 0;
810  /* Disable custom water level when the original map generator is active. */
813  }
815  break;
816  }
817 
818  case WID_GL_RIVER_PULLDOWN: // Amount of rivers
820  break;
821 
822  case WID_GL_SMOOTHNESS_PULLDOWN: // Map smoothness
824  break;
825 
826  case WID_GL_VARIETY_PULLDOWN: // Map variety
828  break;
829 
830  /* Freetype map borders */
831  case WID_GL_WATER_NW:
833  this->InvalidateData();
834  break;
835 
836  case WID_GL_WATER_NE:
838  this->InvalidateData();
839  break;
840 
841  case WID_GL_WATER_SE:
843  this->InvalidateData();
844  break;
845 
846  case WID_GL_WATER_SW:
848  this->InvalidateData();
849  break;
850 
853  this->InvalidateData();
854  break;
855 
856  case WID_GL_AI_BUTTON:
858  break;
859 
860  case WID_GL_GS_BUTTON:
862  break;
863 
864  case WID_GL_NEWGRF_BUTTON:
865  ShowNewGRFSettings(true, true, false, &_grfconfig_newgame);
866  break;
867  }
868  }
869 
870  void OnTimeout() override
871  {
872  if (mode == GLWM_HEIGHTMAP) {
874  } else {
876  }
877  }
878 
879  void OnDropdownSelect(WidgetID widget, int index) override
880  {
881  switch (widget) {
887 
889 
891  if ((uint)index == CUSTOM_TOWN_NUMBER_DIFFICULTY) {
892  this->widget_id = widget;
894  ShowQueryString(STR_JUST_INT, STR_MAPGEN_NUMBER_OF_TOWNS, 5, this, CS_NUMERAL, QSF_NONE);
895  }
897  break;
898 
899  case WID_GL_TOWNNAME_DROPDOWN: // Town names
900  if (_game_mode == GM_MENU || Town::GetNumItems() == 0) {
903  }
904  break;
905 
907  if ((uint)index == ID_CUSTOM) {
908  this->widget_id = widget;
910  ShowQueryString(STR_JUST_INT, STR_MAPGEN_NUMBER_OF_INDUSTRIES, 5, this, CS_NUMERAL, QSF_NONE);
911  }
913  break;
914 
916  if ((uint)index == CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY) {
917  this->widget_id = widget;
919  ShowQueryString(STR_JUST_INT, STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_NONE);
920  }
922  break;
923  }
924 
925  case WID_GL_WATER_PULLDOWN: {
926  if ((uint)index == CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY) {
927  this->widget_id = widget;
929  ShowQueryString(STR_JUST_INT, STR_MAPGEN_SEA_LEVEL, 3, this, CS_NUMERAL, QSF_NONE);
930  }
932  break;
933  }
934  }
935  this->InvalidateData();
936  }
937 
938  void OnQueryTextFinished(std::optional<std::string> str) override
939  {
940  /* Was 'cancel' pressed? */
941  if (!str.has_value()) return;
942 
943  int32_t value;
944  if (!str->empty()) {
945  value = atoi(str->c_str());
946  } else {
947  /* An empty string means revert to the default */
948  switch (this->widget_id) {
950  case WID_GL_START_DATE_TEXT: value = CalendarTime::DEF_START_YEAR.base(); break;
951  case WID_GL_SNOW_COVERAGE_TEXT: value = DEF_SNOW_COVERAGE; break;
953  case WID_GL_TOWN_PULLDOWN: value = 1; break;
954  case WID_GL_INDUSTRY_PULLDOWN: value = 1; break;
955  case WID_GL_TERRAIN_PULLDOWN: value = MIN_MAP_HEIGHT_LIMIT; break;
957  default: NOT_REACHED();
958  }
959  }
960 
961  switch (this->widget_id) {
965  break;
966 
970  break;
971 
975  break;
976 
980  break;
981 
984  break;
985 
988  break;
989 
992  break;
993 
996  break;
997  }
998 
999  this->InvalidateData();
1000  }
1001 };
1002 
1003 static WindowDesc _generate_landscape_desc(
1004  WDP_CENTER, nullptr, 0, 0,
1006  0,
1008 );
1009 
1010 static WindowDesc _heightmap_load_desc(
1011  WDP_CENTER, nullptr, 0, 0,
1013  0,
1015 );
1016 
1017 static void _ShowGenerateLandscape(GenerateLandscapeWindowMode mode)
1018 {
1019  uint x = 0;
1020  uint y = 0;
1021 
1023 
1024  /* Generate a new seed when opening the window */
1025  _settings_newgame.game_creation.generation_seed = InteractiveRandom();
1026 
1027  if (mode == GLWM_HEIGHTMAP) {
1028  /* If the function returns negative, it means there was a problem loading the heightmap */
1030  }
1031 
1032  WindowDesc &desc = (mode == GLWM_HEIGHTMAP) ? _heightmap_load_desc : _generate_landscape_desc;
1033  GenerateLandscapeWindow *w = AllocateWindowDescFront<GenerateLandscapeWindow>(desc, mode, true);
1034 
1035  if (mode == GLWM_HEIGHTMAP) {
1036  w->x = x;
1037  w->y = y;
1038  w->name = _file_to_saveload.title;
1039  }
1040 
1042 }
1043 
1046 {
1047  _ShowGenerateLandscape(GLWM_GENERATE);
1048 }
1049 
1052 {
1053  _ShowGenerateLandscape(GLWM_HEIGHTMAP);
1054 }
1055 
1058 {
1059  StartGeneratingLandscape(GLWM_SCENARIO);
1060 }
1061 
1066 void StartNewGameWithoutGUI(uint32_t seed)
1067 {
1068  /* GenerateWorld takes care of the possible GENERATE_NEW_SEED value in 'seed' */
1070 
1071  StartGeneratingLandscape(GLWM_GENERATE);
1072 }
1073 
1075 {
1076  WidgetID widget_id;
1077 
1079  {
1080  this->InitNested(window_number);
1082  }
1083 
1084  void SetStringParameters(WidgetID widget) const override
1085  {
1086  switch (widget) {
1089  break;
1090 
1093  break;
1094 
1097  break;
1098 
1101  break;
1102  }
1103  }
1104 
1105  void OnPaint() override
1106  {
1111 
1116 
1117  this->DrawWidgets();
1118  }
1119 
1120  void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
1121  {
1122  StringID str = STR_JUST_INT;
1123  switch (widget) {
1124  case WID_CS_TEMPERATE: case WID_CS_ARCTIC:
1125  case WID_CS_TROPICAL: case WID_CS_TOYLAND:
1127  size.height += WidgetDimensions::scaled.fullbevel.Vertical();
1128  break;
1129 
1132  str = STR_JUST_DATE_LONG;
1133  break;
1134 
1138  break;
1139 
1142  break;
1143 
1144  default:
1145  return;
1146  }
1148  d.width += padding.width;
1149  d.height += padding.height;
1150  size = maxdim(size, d);
1151  }
1152 
1153  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1154  {
1155  switch (widget) {
1156  case WID_CS_TEMPERATE:
1157  case WID_CS_ARCTIC:
1158  case WID_CS_TROPICAL:
1159  case WID_CS_TOYLAND:
1162  break;
1163 
1164  case WID_CS_MAPSIZE_X_PULLDOWN: // Mapsize X
1166  break;
1167 
1168  case WID_CS_MAPSIZE_Y_PULLDOWN: // Mapsize Y
1170  break;
1171 
1172  case WID_CS_EMPTY_WORLD: // Empty world / flat world
1173  StartGeneratingLandscape(GLWM_SCENARIO);
1174  break;
1175 
1176  case WID_CS_RANDOM_WORLD: // Generate
1178  break;
1179 
1181  case WID_CS_START_DATE_UP: // Year buttons
1182  /* Don't allow too fast scrolling */
1183  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
1184  this->HandleButtonClick(widget);
1185  this->SetDirty();
1186 
1188  }
1189  _left_button_clicked = false;
1190  break;
1191 
1192  case WID_CS_START_DATE_TEXT: // Year text
1193  this->widget_id = WID_CS_START_DATE_TEXT;
1195  ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_NONE);
1196  break;
1197 
1199  case WID_CS_FLAT_LAND_HEIGHT_UP: // Height level buttons
1200  /* Don't allow too fast scrolling */
1201  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
1202  this->HandleButtonClick(widget);
1203  this->SetDirty();
1204 
1206  }
1207  _left_button_clicked = false;
1208  break;
1209 
1210  case WID_CS_FLAT_LAND_HEIGHT_TEXT: // Height level text
1211  this->widget_id = WID_CS_FLAT_LAND_HEIGHT_TEXT;
1213  ShowQueryString(STR_JUST_INT, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_NONE);
1214  break;
1215  }
1216  }
1217 
1218  void OnTimeout() override
1219  {
1221  }
1222 
1223  void OnDropdownSelect(WidgetID widget, int index) override
1224  {
1225  switch (widget) {
1228  }
1229  this->SetDirty();
1230  }
1231 
1232  void OnQueryTextFinished(std::optional<std::string> str) override
1233  {
1234  if (!str.has_value() || str->empty()) return;
1235 
1236  int32_t value = atoi(str->c_str());
1237 
1238  switch (this->widget_id) {
1242  break;
1243 
1247  break;
1248  }
1249 
1250  this->SetDirty();
1251  }
1252 };
1253 
1254 static constexpr NWidgetPart _nested_create_scenario_widgets[] = {
1256  NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
1257  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_SE_MAPGEN_CAPTION, STR_NULL),
1258  EndContainer(),
1259  NWidget(WWT_PANEL, COLOUR_BROWN),
1261  /* Landscape style selection. */
1263  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TEMPERATE), SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
1264  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_ARCTIC), SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
1265  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TROPICAL), SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
1266  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TOYLAND), SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
1267  EndContainer(),
1268 
1270  /* Green generation type buttons: 'Flat land' and 'Random land'. */
1272  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_CS_EMPTY_WORLD), SetDataTip(STR_SE_MAPGEN_FLAT_WORLD, STR_SE_MAPGEN_FLAT_WORLD_TOOLTIP), SetFill(1, 1),
1273  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_CS_RANDOM_WORLD), SetDataTip(STR_SE_MAPGEN_RANDOM_LAND, STR_TERRAFORM_TOOLTIP_GENERATE_RANDOM_LAND), SetFill(1, 1),
1274  EndContainer(),
1275 
1276  /* Labels + setting drop-downs */
1278  /* Labels. */
1280  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAPSIZE, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(0, 1),
1281  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_MAPGEN_DATE_TOOLTIP), SetFill(0, 1),
1282  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_SE_MAPGEN_FLAT_WORLD_HEIGHT, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_TOOLTIP), SetFill(0, 1),
1283  EndContainer(),
1284 
1286  /* Map size. */
1288  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_CS_MAPSIZE_X_PULLDOWN), SetDataTip(STR_JUST_INT, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
1289  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BY, STR_NULL), SetFill(0, 1), SetAlignment(SA_CENTER),
1290  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_CS_MAPSIZE_Y_PULLDOWN), SetDataTip(STR_JUST_INT, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
1291  EndContainer(),
1292 
1293  /* Date. */
1295  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_CS_START_DATE_DOWN), SetFill(0, 1), SetDataTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_BACKWARD), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
1296  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CS_START_DATE_TEXT), SetFill(1, 1), SetDataTip(STR_JUST_DATE_LONG, STR_MAPGEN_DATE_TOOLTIP),
1297  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_CS_START_DATE_UP), SetFill(0, 1), SetDataTip(SPR_ARROW_UP, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_FORWARD), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
1298  EndContainer(),
1299 
1300  /* Flat map height. */
1302  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_CS_FLAT_LAND_HEIGHT_DOWN), SetFill(0, 1), SetDataTip(SPR_ARROW_DOWN, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_DOWN), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
1303  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CS_FLAT_LAND_HEIGHT_TEXT), SetFill(1, 1), SetDataTip(STR_JUST_INT, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_TOOLTIP),
1304  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_CS_FLAT_LAND_HEIGHT_UP), SetFill(0, 1), SetDataTip(SPR_ARROW_UP, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_UP), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
1305  EndContainer(),
1306  EndContainer(),
1307  EndContainer(),
1308  EndContainer(),
1309  EndContainer(),
1310  EndContainer(),
1311 };
1312 
1313 static WindowDesc _create_scenario_desc(
1314  WDP_CENTER, nullptr, 0, 0,
1316  0,
1317  _nested_create_scenario_widgets
1318 );
1319 
1322 {
1324  new CreateScenarioWindow(_create_scenario_desc, GLWM_SCENARIO);
1325 }
1326 
1327 static constexpr NWidgetPart _nested_generate_progress_widgets[] = {
1328  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GENERATION_WORLD, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1329  NWidget(WWT_PANEL, COLOUR_GREY),
1331  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GP_PROGRESS_BAR), SetFill(1, 0),
1332  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GP_PROGRESS_TEXT), SetFill(1, 0),
1333  NWidget(WWT_TEXTBTN, COLOUR_WHITE, WID_GP_ABORT), SetDataTip(STR_GENERATION_ABORT, STR_NULL), SetFill(1, 0),
1334  EndContainer(),
1335  EndContainer(),
1336 };
1337 
1338 
1339 static WindowDesc _generate_progress_desc(
1340  WDP_CENTER, nullptr, 0, 0,
1342  0,
1343  _nested_generate_progress_widgets
1344 );
1345 
1347  uint percent;
1348  StringID cls;
1349  uint current;
1350  uint total;
1351  std::chrono::steady_clock::time_point next_update;
1352 };
1353 
1354 static GenWorldStatus _gws;
1355 
1356 static const StringID _generation_class_table[] = {
1357  STR_GENERATION_WORLD_GENERATION,
1358  STR_GENERATION_LANDSCAPE_GENERATION,
1359  STR_GENERATION_RIVER_GENERATION,
1360  STR_GENERATION_CLEARING_TILES,
1361  STR_GENERATION_TOWN_GENERATION,
1362  STR_GENERATION_INDUSTRY_GENERATION,
1363  STR_GENERATION_OBJECT_GENERATION,
1364  STR_GENERATION_TREE_GENERATION,
1365  STR_GENERATION_SETTINGUP_GAME,
1366  STR_GENERATION_PREPARING_TILELOOP,
1367  STR_GENERATION_PREPARING_SCRIPT,
1368  STR_GENERATION_PREPARING_GAME
1369 };
1370 static_assert(lengthof(_generation_class_table) == GWP_CLASS_COUNT);
1371 
1372 
1373 static void AbortGeneratingWorldCallback(Window *, bool confirmed)
1374 {
1375  if (confirmed) {
1377  } else if (HasModalProgress() && !IsGeneratingWorldAborted()) {
1378  SetMouseCursor(SPR_CURSOR_ZZZ, PAL_NONE);
1379  }
1380 }
1381 
1383 
1384  GenerateProgressWindow() : Window(_generate_progress_desc)
1385  {
1386  this->InitNested();
1387  }
1388 
1389  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1390  {
1391  switch (widget) {
1392  case WID_GP_ABORT:
1393  SetMouseCursorBusy(false);
1394  ShowQuery(
1395  STR_GENERATION_ABORT_CAPTION,
1396  STR_GENERATION_ABORT_MESSAGE,
1397  this,
1398  AbortGeneratingWorldCallback
1399  );
1400  break;
1401  }
1402  }
1403 
1404  void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
1405  {
1406  switch (widget) {
1407  case WID_GP_PROGRESS_BAR: {
1408  SetDParamMaxValue(0, 100);
1409  size = GetStringBoundingBox(STR_GENERATION_PROGRESS);
1410  /* We need some spacing for the 'border' */
1413  break;
1414  }
1415 
1416  case WID_GP_PROGRESS_TEXT:
1417  for (uint i = 0; i < GWP_CLASS_COUNT; i++) {
1418  size.width = std::max(size.width, GetStringBoundingBox(_generation_class_table[i]).width + padding.width);
1419  }
1421  break;
1422  }
1423  }
1424 
1425  void DrawWidget(const Rect &r, WidgetID widget) const override
1426  {
1427  switch (widget) {
1428  case WID_GP_PROGRESS_BAR: {
1429  /* Draw the % complete with a bar and a text */
1430  DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY | FR_LOWERED);
1431  Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
1432  DrawFrameRect(br.WithWidth(br.Width() * _gws.percent / 100, _current_text_dir == TD_RTL), COLOUR_MAUVE, FR_NONE);
1433  SetDParam(0, _gws.percent);
1434  DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, GetCharacterHeight(FS_NORMAL)), STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
1435  break;
1436  }
1437 
1438  case WID_GP_PROGRESS_TEXT:
1439  /* Tell which class we are generating */
1440  DrawString(r.left, r.right, r.top, _gws.cls, TC_FROMSTRING, SA_HOR_CENTER);
1441 
1442  /* And say where we are in that class */
1443  SetDParam(0, _gws.current);
1444  SetDParam(1, _gws.total);
1445  DrawString(r.left, r.right, r.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal, STR_GENERATION_PROGRESS_NUM, TC_FROMSTRING, SA_HOR_CENTER);
1446  }
1447  }
1448 };
1449 
1454 {
1455  _gws.cls = STR_GENERATION_WORLD_GENERATION;
1456  _gws.current = 0;
1457  _gws.total = 0;
1458  _gws.percent = 0;
1459  _gws.next_update = std::chrono::steady_clock::now();
1460 }
1461 
1466 {
1467  if (BringWindowToFrontById(WC_MODAL_PROGRESS, 0)) return;
1468  new GenerateProgressWindow();
1469 }
1470 
1471 static void _SetGeneratingWorldProgress(GenWorldProgress cls, uint progress, uint total)
1472 {
1473  static const int percent_table[] = {0, 5, 14, 17, 20, 40, 60, 65, 80, 85, 95, 99, 100 };
1474  static_assert(lengthof(percent_table) == GWP_CLASS_COUNT + 1);
1475  assert(cls < GWP_CLASS_COUNT);
1476 
1477  /* Check if we really are generating the world.
1478  * For example, placing trees via the SE also calls this function, but
1479  * shouldn't try to update the progress.
1480  */
1481  if (!HasModalProgress()) return;
1482 
1483  if (IsGeneratingWorldAborted()) {
1485  return;
1486  }
1487 
1488  if (total == 0) {
1489  assert(_gws.cls == _generation_class_table[cls]);
1490  _gws.current += progress;
1491  assert(_gws.current <= _gws.total);
1492  } else {
1493  _gws.cls = _generation_class_table[cls];
1494  _gws.current = progress;
1495  _gws.total = total;
1496  _gws.percent = percent_table[cls];
1497  }
1498 
1499  /* Percentage is about the number of completed tasks, so 'current - 1' */
1500  _gws.percent = percent_table[cls] + (percent_table[cls + 1] - percent_table[cls]) * (_gws.current == 0 ? 0 : _gws.current - 1) / _gws.total;
1501 
1502  if (_network_dedicated) {
1503  static uint last_percent = 0;
1504 
1505  /* Never display 0% */
1506  if (_gws.percent == 0) return;
1507  /* Reset if percent is lower than the last recorded */
1508  if (_gws.percent < last_percent) last_percent = 0;
1509  /* Display every 5%, but 6% is also very valid.. just not smaller steps than 5% */
1510  if (_gws.percent % 5 != 0 && _gws.percent <= last_percent + 5) return;
1511  /* Never show steps smaller than 2%, even if it is a mod 5% */
1512  if (_gws.percent <= last_percent + 2) return;
1513 
1514  Debug(net, 3, "Map generation percentage complete: {}", _gws.percent);
1515  last_percent = _gws.percent;
1516 
1517  return;
1518  }
1519 
1521 
1523 }
1524 
1534 {
1535  if (total == 0) return;
1536 
1537  _SetGeneratingWorldProgress(cls, 0, total);
1538 }
1539 
1548 {
1549  /* In fact the param 'class' isn't needed.. but for some security reasons, we want it around */
1550  _SetGeneratingWorldProgress(cls, 1, 0);
1551 }
void ShowAIConfigWindow()
Open the AI config window.
Definition: ai_gui.cpp:324
Window for configuring the AIs
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
constexpr T ToggleBit(T &x, const uint8_t y)
Toggles a bit in a variable.
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,...
void GameLoopPause()
Pause the game-loop for a bit, releasing the game-state lock.
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
RectPadding frametext
Padding inside frame with text.
Definition: window_gui.h:43
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
int vsep_normal
Normal vertical spacing.
Definition: window_gui.h:60
RectPadding fullbevel
Always-scaled bevel thickness.
Definition: window_gui.h:41
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
Functions related to debugging.
#define Debug(category, level, format_string,...)
Ouptut 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:441
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:404
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.
Definition: dropdown_type.h:50
Functions related to errors.
void ClearErrorMessages()
Clear all errors from the queue.
Definition: error_gui.cpp:328
Declarations for savegames operations.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition: fontcache.cpp:77
void ShowGSConfigWindow()
Open the GS config window.
Definition: game_gui.cpp:445
Window for configuring the Games
void HandleGeneratingWorldAbortion()
Really handle the abortion, i.e.
Definition: genworld.cpp:269
void AbortGeneratingWorld()
Initializes the abortion process.
Definition: genworld.cpp:252
bool IsGeneratingWorldAborted()
Is the generation being aborted?
Definition: genworld.cpp:261
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:51
static const uint CUSTOM_SEA_LEVEL_MAX_PERCENTAGE
Maximum percentage a user can specify for custom sea level.
Definition: genworld.h:49
static const uint CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY
Value for custom sea level in difficulty settings.
Definition: genworld.h:47
static const uint CUSTOM_SEA_LEVEL_MIN_PERCENTAGE
Minimum percentage a user can specify for custom sea level.
Definition: genworld.h:48
GenWorldProgress
Current stage of world generation process.
Definition: genworld.h:69
static const uint CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY
Value for custom terrain type in difficulty settings.
Definition: genworld.h:45
@ LG_ORIGINAL
The original landscape generator.
Definition: genworld.h:20
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 SetNewLandscapeType(uint8_t landscape)
Changes landscape type and sets genworld window dirty.
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.
GenerateLandscapeWindowMode
Enum for the modes we can generate in.
@ GLWM_GENERATE
Generate new game.
@ GLWM_HEIGHTMAP
Load from heightmap.
@ GLWM_SCENARIO
Generate flat land.
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 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.
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.
void SetMouseCursor(CursorID sprite, PaletteID pal)
Assign a single non-animated sprite to the cursor.
Definition: gfx.cpp:1686
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:851
Dimension GetStringListBoundingBox(std::span< const StringID > list, FontSize fontsize)
Get maximum dimension of a list of strings.
Definition: gfx.cpp:889
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:657
bool _left_button_clicked
Is left mouse button clicked?
Definition: gfx.cpp:42
void SetMouseCursorBusy(bool busy)
Set or unset the ZZZ cursor.
Definition: gfx.cpp:1670
SwitchMode _switch_mode
The next mainloop command.
Definition: gfx.cpp:49
int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
Definition: gfx_func.h:166
@ SA_RIGHT
Right align the text (must be a single bit).
Definition: gfx_type.h:345
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_type.h:344
@ SA_CENTER
Center both horizontally and vertically.
Definition: gfx_type.h:353
@ SA_VERT_CENTER
Vertically center the text.
Definition: gfx_type.h:349
@ FS_NORMAL
Index of the normal font in the font tables.
Definition: gfx_type.h:209
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1181
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1260
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.
Definition: widget_type.h:1228
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1202
constexpr NWidgetPart SetTextStyle(TextColour colour, FontSize size=FS_NORMAL)
Widget part function for setting the text style.
Definition: widget_type.h:1160
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1309
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1191
constexpr NWidgetPart SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition: widget_type.h:1149
constexpr NWidgetPart SetAlignment(StringAlignment align)
Widget part function for setting the alignment of text/images.
Definition: widget_type.h:1170
constexpr NWidgetPart SetAspect(float ratio, AspectFlags flags=AspectFlags::ResizeX)
Widget part function for setting the aspect ratio.
Definition: widget_type.h:1295
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.
Definition: widget_type.h:1272
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:940
bool GetHeightmapDimensions(DetailedFileType dft, const char *filename, uint *x, uint *y)
Get the dimensions of a heightmap.
Definition: heightmap.cpp:488
Functions related to creating heightmaps from files.
@ HM_CLOCKWISE
Rotate the map clockwise 45 degrees.
Definition: heightmap.h:21
Base of all industries.
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(StringID caption, StringID 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...
Definition: misc_gui.cpp:1223
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
Definition: misc_gui.cpp:1079
bool _network_dedicated
are we a dedicated server?
Definition: network.cpp:68
Basic functions/variables used all over the place.
void ResetGRFConfig(bool defaults)
Reset the current GRF Config to either blank or newgame settings.
GRFConfig * _grfconfig_newgame
First item in list of default GRF set up.
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **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:60
Functions/types related to saving and loading games.
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Definition: settings.cpp:58
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:56
@ ID_CUSTOM
Custom number of industries.
Definition: settings_type.h:62
@ ID_END
Number of industry density settings.
Definition: settings_type.h:64
Functions related to sound.
@ SND_15_BEEP
19 == 0x13 GUI button click
Definition: sound_type.h:58
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:280
Functions related to low-level strings.
@ CS_NUMERAL
Only numeric ones.
Definition: string_type.h:26
void SetDParamMaxValue(size_t n, uint64_t max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
Definition: strings.cpp:127
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings.cpp:104
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:56
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Definition: strings.cpp:357
Functions related to OTTD's strings.
@ TD_RTL
Text is written right-to-left by default.
Definition: strings_type.h:24
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
SoundSettings sound
sound effect settings
bool freeform_edges
allow terraforming the tiles at the map edges
uint8_t map_height_limit
the maximum allowed heightlevel
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.
DetailedFileType detail_ftype
Concrete file type (PNG, BMP, old save, etc).
Definition: saveload.h:408
std::string title
Internal name of the game.
Definition: saveload.h:411
std::string name
Name of the file.
Definition: saveload.h:410
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
uint8_t map_x
X size of map.
uint8_t land_generator
the landscape generator
uint8_t landscape
the landscape we're currently in
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
uint32_t generation_seed
noise seed for world generation
uint8_t heightmap_height
highest mountain for heightmap (towards what it scales)
uint8_t water_borders
bitset of the borders that are water
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 OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
void OnTimeout() override
Called when this window's timeout has been reached.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:1075
Coordinates of a point in 2D.
static size_t GetNumItems()
Returns number of valid items in the pool.
Definition: pool_type.hpp:369
static constexpr size_t MAX_SIZE
Make template parameter accessible from outside.
Definition: pool_type.hpp:84
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 WithWidth(int width, bool end) const
Copy Rect and set its width.
int Width() const
Get width of Rect.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
bool confirm
Play sound effect on successful constructions or other actions.
Templated helper to make a type-safe 'typedef' representing a single POD value.
High level window description.
Definition: window_gui.h:159
Data structure for an opened window.
Definition: window_gui.h:273
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:731
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Definition: window.cpp:3151
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
Definition: window_gui.h:475
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:551
uint8_t timeout_timer
Timer value of the WF_TIMEOUT for flags.
Definition: window_gui.h:306
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:521
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:447
void RaiseWidgetsWhenLowered(Args... widgets)
Raises the widgets and sets widgets dirty that are lowered.
Definition: window_gui.h:542
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1756
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition: window_gui.h:466
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:590
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1746
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:387
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
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
Definition: textbuf_gui.h:21
static const uint MIN_MAP_HEIGHT_LIMIT
Lower bound of maximum allowed heightlevel (in the construction settings)
Definition: tile_type.h:29
static const uint MIN_CUSTOM_TERRAIN_TYPE
Lowest possible peak value for world generation.
Definition: tile_type.h:27
static const uint DEF_DESERT_COVERAGE
Default desert coverage.
Definition: tile_type.h:37
static const uint MAX_TILE_HEIGHT
Maximum allowed tile height.
Definition: tile_type.h:24
static const uint MIN_HEIGHTMAP_HEIGHT
Lowest possible peak value for heightmap creation.
Definition: tile_type.h:26
static const uint MAX_MAP_HEIGHT_LIMIT
Upper bound of maximum allowed heightlevel (in the construction settings)
Definition: tile_type.h:30
static const 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:29
static const uint CUSTOM_TOWN_NUMBER_DIFFICULTY
value for custom town number in difficulty settings
Definition: town.h:28
Definition of structures used for generating town names.
static constexpr uint BUILTIN_TOWNNAME_GENERATOR_COUNT
Number of built-in town name generators.
Definition: townname_type.h:22
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:281
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:524
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:112
@ WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:52
@ WWT_IMGBTN_2
(Toggle) Button with diff image when clicked
Definition: widget_type.h:53
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:79
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:75
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:55
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:50
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:77
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:69
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition: widget_type.h:48
@ WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:70
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:58
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:80
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
Definition: window.cpp:1223
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Definition: window.cpp:1152
void CloseAllNonVitalWindows()
It is possible that a stickied window gets to a position where the 'close' button is outside the gami...
Definition: window.cpp:3272
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3093
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:3228
Window functions not directly related to making/drawing windows.
@ WF_TIMEOUT
Window timeout counter.
Definition: window_gui.h:228
@ FR_BORDERONLY
Draw border only, no background.
Definition: window_gui.h:27
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
Definition: window_gui.h:28
@ WDP_CENTER
Center the window.
Definition: window_gui.h:148
int WidgetID
Widget ID.
Definition: window_type.h:18
@ WN_GAME_OPTIONS_GAME_OPTIONS
Game options.
Definition: window_type.h:26
int32_t WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:737
@ WC_SELECT_GAME
Select game window; Window numbers:
Definition: window_type.h:448
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:45
@ WC_GENERATE_LANDSCAPE
Generate landscape (newgame); Window numbers:
Definition: window_type.h:462
@ WC_GAME_OPTIONS
Game options window; Window numbers:
Definition: window_type.h:624
@ WC_MODAL_PROGRESS
Progress report of landscape generation; Window numbers:
Definition: window_type.h:469