OpenTTD Source  14.0-beta1
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 "widgets/dropdown_type.h"
22 #include "widgets/dropdown_func.h"
23 #include "querystring_gui.h"
24 #include "town.h"
25 #include "core/geometry_func.hpp"
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"
32 #include "video/video_driver.hpp"
33 #include "ai/ai_gui.hpp"
34 #include "game/game_gui.hpp"
35 #include "industry.h"
36 
38 
39 #include "safeguards.h"
40 
41 
42 extern void MakeNewgameSettingsLive();
43 
49 };
50 
54 static uint GetMapHeightLimit()
55 {
58 }
59 
64 void SetNewLandscapeType(byte landscape)
65 {
69 }
70 
74  NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
75  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_MAPGEN_WORLD_GENERATION_CAPTION, STR_NULL),
76  EndContainer(),
77  NWidget(WWT_PANEL, COLOUR_BROWN),
79  /* Landscape selection. */
81  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TEMPERATE), SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
82  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_ARCTIC), SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
83  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TROPICAL), SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
84  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TOYLAND), SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
85  EndContainer(),
86 
87  /* Generation options. */
89  /* Left half (land generation options) */
91  /* Labels on the left side (global column 1). */
93  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAPSIZE, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
94  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_TERRAIN_TYPE, STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT), SetFill(1, 1),
95  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_VARIETY, STR_CONFIG_SETTING_VARIETY_HELPTEXT), SetFill(1, 1),
96  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SMOOTHNESS, STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT), SetFill(1, 1),
97  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT), SetFill(1, 1),
98  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BORDER_TYPE, STR_MAPGEN_BORDER_TYPE_TOOLTIP), SetFill(1, 1),
99  EndContainer(),
100 
101  /* Widgets on the right side (global column 2). */
103  /* Mapsize X * Y. */
105  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_X_PULLDOWN), SetDataTip(STR_JUST_INT, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
106  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BY, STR_NULL), SetFill(0, 1), SetAlignment(SA_CENTER),
107  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_Y_PULLDOWN), SetDataTip(STR_JUST_INT, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
108  EndContainer(),
109  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TERRAIN_PULLDOWN), SetDataTip(STR_JUST_STRING1, STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT), SetFill(1, 1),
110  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_VARIETY_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_CONFIG_SETTING_VARIETY_HELPTEXT), SetFill(1, 1),
111  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_SMOOTHNESS_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT), SetFill(1, 1),
112  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_RIVER_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT), SetFill(1, 1),
113  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_BORDERS_RANDOM), SetDataTip(STR_JUST_STRING, STR_MAPGEN_BORDER_TYPE_TOOLTIP), SetFill(1, 1),
114  EndContainer(),
115  EndContainer(),
116 
117  /* Right half (all other options) */
119  /* Labels on the left side (global column 3). */
122  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SNOW_COVERAGE, STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT), SetFill(1, 1),
123  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DESERT_COVERAGE, STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT), SetFill(1, 1),
124  NWidget(NWID_SPACER), SetFill(1, 1),
125  EndContainer(),
126  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_MAPGEN_DATE_TOOLTIP), SetFill(1, 1),
127  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_TOWN_NAME_LABEL, STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP), SetFill(1, 1),
128  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_TOWNS, STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP), SetFill(1, 1),
129  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES, STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP), SetFill(1, 1),
130  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SEA_LEVEL, STR_MAPGEN_SEA_LEVEL_TOOLTIP), SetFill(1, 1),
131  EndContainer(),
132 
133  /* Widgets on the right side (global column 4). */
135  /* Climate selector. */
137  /* Snow coverage. */
139  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_COVERAGE_DOWN), SetFill(0, 1),
140  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),
141  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_COVERAGE_UP), SetFill(0, 1),
142  EndContainer(),
143  /* Desert coverage. */
145  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_DESERT_COVERAGE_DOWN), SetFill(0, 1),
146  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),
147  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_DESERT_COVERAGE_UP), SetFill(0, 1),
148  EndContainer(),
149  /* Temperate/Toyland spacer. */
150  NWidget(NWID_SPACER), SetFill(1, 1),
151  EndContainer(),
152  /* Starting date. */
154  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),
155  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetDataTip(STR_JUST_DATE_LONG, STR_MAPGEN_DATE_TOOLTIP), SetFill(1, 1),
156  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),
157  EndContainer(),
158  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWNNAME_DROPDOWN), SetDataTip(STR_JUST_STRING, STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP), SetFill(1, 1),
159  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWN_PULLDOWN), SetDataTip(STR_JUST_STRING1, STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP), SetFill(1, 1),
160  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_INDUSTRY_PULLDOWN), SetDataTip(STR_JUST_STRING1, STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP), SetFill(1, 1),
161  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_WATER_PULLDOWN), SetDataTip(STR_JUST_STRING1, STR_MAPGEN_SEA_LEVEL_TOOLTIP), SetFill(1, 1),
162  EndContainer(),
163  EndContainer(),
164  EndContainer(),
165 
166  /* Map borders buttons for each edge. */
169  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),
170  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_NW), SetDataTip(STR_JUST_STRING, STR_MAPGEN_NORTHWEST), SetFill(1, 1),
171  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_NE), SetDataTip(STR_JUST_STRING, STR_MAPGEN_NORTHEAST), SetFill(1, 1),
172  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NORTHEAST, STR_NULL), SetPadding(0, 0, 0, WidgetDimensions::unscaled.hsep_normal), SetFill(1, 1),
173  EndContainer(),
175  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),
176  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_SW), SetDataTip(STR_JUST_STRING, STR_MAPGEN_SOUTHWEST), SetFill(1, 1),
177  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_SE), SetDataTip(STR_JUST_STRING, STR_MAPGEN_SOUTHEAST), SetFill(1, 1),
178  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SOUTHEAST, STR_NULL), SetPadding(0, 0, 0, WidgetDimensions::unscaled.hsep_normal), SetFill(1, 1),
179  EndContainer(),
180  EndContainer(),
181 
182  /* AI, GS, and NewGRF settings */
184  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),
185  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),
186  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),
187  EndContainer(),
188 
189  /* Generate */
190  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_GL_GENERATE_BUTTON), SetMinimalTextLines(3, 0), SetDataTip(STR_MAPGEN_GENERATE, STR_MAPGEN_GENERATE_TOOLTIP), SetFill(1, 1),
191  EndContainer(),
192  EndContainer(),
193 };
194 
197  /* Window header. */
199  NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
200  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_MAPGEN_WORLD_GENERATION_CAPTION, STR_NULL),
201  EndContainer(),
202  NWidget(WWT_PANEL, COLOUR_BROWN),
204  /* Landscape selection. */
206  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TEMPERATE), SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
207  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_ARCTIC), SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
208  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TROPICAL), SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
209  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TOYLAND), SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
210  EndContainer(),
211 
213  /* Heightmap name label. */
214  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_NAME, STR_MAPGEN_HEIGHTMAP_NAME_TOOLTIP),
215  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),
216  EndContainer(),
217 
218  /* Generation options. */
220  /* Left half (land generation options) */
222  /* Labels on the left side (global column 1). */
224  /* Land generation option labels. */
225  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_SIZE_LABEL, STR_MAPGEN_HEIGHTMAP_SIZE_LABEL_TOOLTIP), SetFill(1, 1),
226  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAPSIZE, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
227  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_ROTATION, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_TOOLTIP), SetFill(1, 1),
228  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_HEIGHT, STR_MAPGEN_HEIGHTMAP_HEIGHT_TOOLTIP), SetFill(1, 1),
229  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT), SetFill(1, 1),
230  EndContainer(),
231 
232  /* Left half widgets (global column 2) */
234  NWidget(WWT_TEXT, COLOUR_ORANGE, WID_GL_HEIGHTMAP_SIZE_TEXT), SetDataTip(STR_MAPGEN_HEIGHTMAP_SIZE, STR_MAPGEN_HEIGHTMAP_SIZE_LABEL_TOOLTIP), SetFill(1, 1),
235  /* Mapsize X * Y. */
237  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_X_PULLDOWN), SetDataTip(STR_JUST_INT, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
238  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BY, STR_NULL), SetFill(0, 1), SetAlignment(SA_CENTER),
239  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_Y_PULLDOWN), SetDataTip(STR_JUST_INT, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
240  EndContainer(),
241  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_ROTATION_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_TOOLTIP), SetFill(1, 1),
242  /* Heightmap highest peak. */
244  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_HEIGHTMAP_HEIGHT_DOWN), SetFill(0, 1),
245  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_TEXT), SetDataTip(STR_JUST_INT, STR_MAPGEN_HEIGHTMAP_HEIGHT_TOOLTIP), SetFill(1, 1),
246  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_HEIGHTMAP_HEIGHT_UP), SetFill(0, 1),
247  EndContainer(),
248  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_RIVER_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT), SetFill(1, 1),
249  EndContainer(),
250  EndContainer(),
251 
252  /* Right half (all other options) */
254  /* Right half labels (global column 3) */
257  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SNOW_COVERAGE, STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT), SetFill(1, 1),
258  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DESERT_COVERAGE, STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT), SetFill(1, 1),
259  NWidget(NWID_SPACER), SetFill(1, 1),
260  EndContainer(),
261  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_MAPGEN_DATE_TOOLTIP), SetFill(1, 1),
262  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_TOWN_NAME_LABEL, STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP), SetFill(1, 1),
263  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_TOWNS, STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP), SetFill(1, 1),
264  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES, STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP), SetFill(1, 1),
265  EndContainer(),
266 
267  /* Right half widgets (global column 4) */
269  /* Climate selector. */
271  /* Snow coverage. */
273  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_COVERAGE_DOWN), SetFill(0, 1),
274  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),
275  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_COVERAGE_UP), SetFill(0, 1),
276  EndContainer(),
277  /* Desert coverage. */
279  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_DESERT_COVERAGE_DOWN), SetFill(0, 1),
280  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),
281  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_DESERT_COVERAGE_UP), SetFill(0, 1),
282  EndContainer(),
283  /* Temperate/Toyland spacer. */
284  NWidget(NWID_SPACER), SetFill(1, 1),
285  EndContainer(),
286  /* Starting date. */
288  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),
289  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetDataTip(STR_JUST_DATE_LONG, STR_MAPGEN_DATE_TOOLTIP), SetFill(1, 1),
290  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),
291  EndContainer(),
292  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWNNAME_DROPDOWN), SetDataTip(STR_JUST_STRING, STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP), SetFill(1, 1),
293  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWN_PULLDOWN), SetDataTip(STR_JUST_STRING1, STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP), SetFill(1, 1),
294  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_INDUSTRY_PULLDOWN), SetDataTip(STR_JUST_STRING1, STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP), SetFill(1, 1),
295  EndContainer(),
296  EndContainer(),
297  EndContainer(),
298 
299  /* AI, GS, and NewGRF settings */
301  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),
302  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),
303  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),
304  EndContainer(),
305 
306  /* Generate */
307  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_GL_GENERATE_BUTTON), SetMinimalTextLines(3, 0), SetDataTip(STR_MAPGEN_GENERATE, STR_MAPGEN_GENERATE_TOOLTIP), SetFill(1, 1),
308  EndContainer(),
309  EndContainer(),
310 };
311 
312 static void StartGeneratingLandscape(GenerateLandscapeWindowMode mode)
313 {
316 
317  /* Copy all XXX_newgame to XXX when coming from outside the editor */
318  MakeNewgameSettingsLive();
319  ResetGRFConfig(true);
320 
321  if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP);
322  switch (mode) {
323  case GLWM_GENERATE: _switch_mode = (_game_mode == GM_EDITOR) ? SM_GENRANDLAND : SM_NEWGAME; break;
324  case GLWM_HEIGHTMAP: _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_HEIGHTMAP : SM_START_HEIGHTMAP; break;
325  case GLWM_SCENARIO: _switch_mode = SM_EDITOR; break;
326  default: NOT_REACHED();
327  }
328 }
329 
330 static void LandscapeGenerationCallback(Window *w, bool confirmed)
331 {
332  if (confirmed) StartGeneratingLandscape((GenerateLandscapeWindowMode)w->window_number);
333 }
334 
335 static DropDownList BuildMapsizeDropDown()
336 {
337  DropDownList list;
338 
339  for (uint i = MIN_MAP_SIZE_BITS; i <= MAX_MAP_SIZE_BITS; i++) {
340  SetDParam(0, 1LL << i);
341  list.push_back(std::make_unique<DropDownListStringItem>(STR_JUST_INT, i, false));
342  }
343 
344  return list;
345 }
346 
347 static DropDownList BuildTownNameDropDown()
348 {
349  DropDownList list;
350 
351  /* Add and sort newgrf townnames generators */
352  const auto &grf_names = GetGRFTownNameList();
353  for (uint i = 0; i < grf_names.size(); i++) {
354  list.push_back(std::make_unique<DropDownListStringItem>(grf_names[i], BUILTIN_TOWNNAME_GENERATOR_COUNT + i, false));
355  }
356  std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
357 
358  size_t newgrf_size = list.size();
359  /* Insert newgrf_names at the top of the list */
360  if (newgrf_size > 0) {
361  list.push_back(std::make_unique<DropDownListDividerItem>(-1, false)); // separator line
362  newgrf_size++;
363  }
364 
365  /* Add and sort original townnames generators */
366  for (uint i = 0; i < BUILTIN_TOWNNAME_GENERATOR_COUNT; i++) {
367  list.push_back(std::make_unique<DropDownListStringItem>(STR_MAPGEN_TOWN_NAME_ORIGINAL_ENGLISH + i, i, false));
368  }
369  std::sort(list.begin() + newgrf_size, list.end(), DropDownListStringItem::NatSortFunc);
370 
371  return list;
372 }
373 
374 
375 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, INVALID_STRING_ID};
376 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, INVALID_STRING_ID};
377 static const StringID _rivers[] = {STR_RIVERS_NONE, STR_RIVERS_FEW, STR_RIVERS_MODERATE, STR_RIVERS_LOT, INVALID_STRING_ID};
378 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, INVALID_STRING_ID};
379 static const StringID _rotation[] = {STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE, INVALID_STRING_ID};
380 static const StringID _num_towns[] = {STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM, INVALID_STRING_ID};
381 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, INVALID_STRING_ID};
382 static const StringID _variety[] = {STR_VARIETY_NONE, STR_VARIETY_VERY_LOW, STR_VARIETY_LOW, STR_VARIETY_MEDIUM, STR_VARIETY_HIGH, STR_VARIETY_VERY_HIGH, INVALID_STRING_ID};
383 
384 static_assert(lengthof(_num_inds) == ID_END + 1);
385 
387  WidgetID widget_id;
388  uint x;
389  uint y;
390  std::string name;
392 
393  GenerateLandscapeWindow(WindowDesc *desc, WindowNumber number = 0) : Window(desc)
394  {
395  this->InitNested(number);
396 
398 
399  this->mode = (GenerateLandscapeWindowMode)this->window_number;
400 
401  /* Disable town and industry in SE */
402  this->SetWidgetDisabledState(WID_GL_TOWN_PULLDOWN, _game_mode == GM_EDITOR);
403  this->SetWidgetDisabledState(WID_GL_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR);
404 
405  /* In case the map_height_limit is changed, clamp heightmap_height and custom_terrain_type. */
408 
409  /* If original landgenerator is selected and alpinist terrain_type was selected, revert to mountainous. */
412  }
413 
414  this->OnInvalidateData();
415  }
416 
417 
418  void SetStringParameters(WidgetID widget) const override
419  {
420  switch (widget) {
427 
429  if (_game_mode == GM_EDITOR) {
430  SetDParam(0, STR_CONFIG_SETTING_OFF);
432  SetDParam(0, STR_NUM_CUSTOM_NUMBER);
434  } else {
436  }
437  break;
438 
442  STR_MAPGEN_TOWN_NAME_ORIGINAL_ENGLISH + gen :
443  GetGRFTownNameName(gen - BUILTIN_TOWNNAME_GENERATOR_COUNT);
444  SetDParam(0, name);
445  break;
446  }
447 
449  if (_game_mode == GM_EDITOR) {
450  SetDParam(0, STR_CONFIG_SETTING_OFF);
452  SetDParam(0, STR_NUM_CUSTOM_NUMBER);
454  } else {
456  }
457  break;
458 
461  SetDParam(0, STR_TERRAIN_TYPE_CUSTOM_VALUE);
463  } else {
464  SetDParam(0, _elevations[_settings_newgame.difficulty.terrain_type]); break;
465  }
466  break;
467 
470  SetDParam(0, STR_SEA_LEVEL_CUSTOM_PERCENTAGE);
472  } else {
474  }
475  break;
476 
477  case WID_GL_HEIGHTMAP_NAME_TEXT: SetDParamStr(0, this->name); break;
481  case WID_GL_BORDERS_RANDOM: SetDParam(0, (_settings_newgame.game_creation.water_borders == BORDERS_RANDOM) ? STR_MAPGEN_BORDER_RANDOMIZE : STR_MAPGEN_BORDER_MANUAL); break;
482  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;
483  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;
484  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;
485  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;
487 
490  SetDParam(0, this->y);
491  SetDParam(1, this->x);
492  } else {
493  SetDParam(0, this->x);
494  SetDParam(1, this->y);
495  }
496  break;
497  }
498  }
499 
505  void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
506  {
507  if (!gui_scope) return;
508  /* Update the climate buttons */
513 
514  /* You can't select smoothness / non-water borders if not terragenesis */
515  if (mode == GLWM_GENERATE) {
521 
523 
528 
531  }
532 
533  /* Disable snowline if not arctic */
535  /* Disable desert if not tropic */
537 
538  /* Set snow/rainforest selections */
539  int climate_plane = 0;
541  case LT_TEMPERATE: climate_plane = 2; break;
542  case LT_ARCTIC: climate_plane = 0; break;
543  case LT_TROPIC: climate_plane = 1; break;
544  case LT_TOYLAND: climate_plane = 2; break;
545  }
546  this->GetWidget<NWidgetStacked>(WID_GL_CLIMATE_SEL_LABEL)->SetDisplayedPlane(climate_plane);
547  this->GetWidget<NWidgetStacked>(WID_GL_CLIMATE_SEL_SELECTOR)->SetDisplayedPlane(climate_plane);
548 
549  /* Update availability of decreasing / increasing start date and snow level */
550  if (mode == GLWM_HEIGHTMAP) {
553  }
560 
561  /* Do not allow a custom sea level or terrain type with the original land generator. */
565  }
568  }
569  }
570 
571  }
572 
573  void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
574  {
576  const StringID *strs = nullptr;
577  switch (widget) {
578  case WID_GL_TEMPERATE: case WID_GL_ARCTIC:
579  case WID_GL_TROPICAL: case WID_GL_TOYLAND:
581  size->height += WidgetDimensions::scaled.fullbevel.Vertical();
582  break;
583 
586  d = GetStringBoundingBox(STR_JUST_INT);
587  break;
588 
591  d = GetStringBoundingBox(STR_JUST_DATE_LONG);
592  break;
593 
597  d = GetStringBoundingBox(STR_JUST_INT);
598  break;
599 
602  d = GetStringBoundingBox(STR_MAPGEN_SNOW_COVERAGE_TEXT);
603  break;
604 
607  d = GetStringBoundingBox(STR_MAPGEN_DESERT_COVERAGE_TEXT);
608  break;
609 
611  SetDParam(0, this->x);
612  SetDParam(1, this->y);
613  d = GetStringBoundingBox(STR_MAPGEN_HEIGHTMAP_SIZE);
614  break;
615 
617  strs = _num_towns;
619  d = GetStringBoundingBox(STR_NUM_CUSTOM_NUMBER);
620  break;
621 
623  strs = _num_inds;
625  d = GetStringBoundingBox(STR_NUM_CUSTOM_NUMBER);
626  break;
627 
629  strs = _elevations;
631  d = GetStringBoundingBox(STR_TERRAIN_TYPE_CUSTOM_VALUE);
632  break;
633 
635  strs = _sea_lakes;
637  d = GetStringBoundingBox(STR_SEA_LEVEL_CUSTOM_PERCENTAGE);
638  break;
639 
640  case WID_GL_RIVER_PULLDOWN: strs = _rivers; break;
641  case WID_GL_SMOOTHNESS_PULLDOWN: strs = _smoothness; break;
642  case WID_GL_VARIETY_PULLDOWN: strs = _variety; break;
643  case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: strs = _rotation; break;
645  d = maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_RANDOMIZE), GetStringBoundingBox(STR_MAPGEN_BORDER_MANUAL));
646  break;
647 
648  case WID_GL_WATER_NE:
649  case WID_GL_WATER_NW:
650  case WID_GL_WATER_SE:
651  case WID_GL_WATER_SW:
652  d = maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_RANDOM), maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_WATER), GetStringBoundingBox(STR_MAPGEN_BORDER_FREEFORM)));
653  break;
654 
656  size->width = 0;
657  break;
658 
659  default:
660  return;
661  }
662  if (strs != nullptr) {
663  while (*strs != INVALID_STRING_ID) {
664  d = maxdim(d, GetStringBoundingBox(*strs++));
665  }
666  }
667  d.width += padding.width;
668  d.height += padding.height;
669  *size = maxdim(*size, d);
670  }
671 
672  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
673  {
674  switch (widget) {
675  case WID_GL_TEMPERATE:
676  case WID_GL_ARCTIC:
677  case WID_GL_TROPICAL:
678  case WID_GL_TOYLAND:
680  break;
681 
682  case WID_GL_MAPSIZE_X_PULLDOWN: // Mapsize X
684  break;
685 
686  case WID_GL_MAPSIZE_Y_PULLDOWN: // Mapsize Y
688  break;
689 
690  case WID_GL_TOWN_PULLDOWN: // Number of towns
692  break;
693 
694  case WID_GL_TOWNNAME_DROPDOWN: // Townname generator
696  break;
697 
698  case WID_GL_INDUSTRY_PULLDOWN: // Number of industries
700  break;
701 
702  case WID_GL_GENERATE_BUTTON: { // Generate
703  /* Get rotated map size. */
704  uint map_x;
705  uint map_y;
707  map_x = this->y;
708  map_y = this->x;
709  } else {
710  map_x = this->x;
711  map_y = this->y;
712  }
713  if (mode == GLWM_HEIGHTMAP &&
714  (map_x * 2 < (1U << _settings_newgame.game_creation.map_x) ||
715  map_x / 2 > (1U << _settings_newgame.game_creation.map_x) ||
716  map_y * 2 < (1U << _settings_newgame.game_creation.map_y) ||
717  map_y / 2 > (1U << _settings_newgame.game_creation.map_y))) {
718  ShowQuery(
719  STR_WARNING_HEIGHTMAP_SCALE_CAPTION,
720  STR_WARNING_HEIGHTMAP_SCALE_MESSAGE,
721  this,
722  LandscapeGenerationCallback);
723  } else {
724  StartGeneratingLandscape(mode);
725  }
726  break;
727  }
728 
730  case WID_GL_HEIGHTMAP_HEIGHT_UP: // Height level buttons
731  /* Don't allow too fast scrolling */
732  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
733  this->HandleButtonClick(widget);
734 
736  this->InvalidateData();
737  }
738  _left_button_clicked = false;
739  break;
740 
741  case WID_GL_HEIGHTMAP_HEIGHT_TEXT: // Height level text
742  this->widget_id = WID_GL_HEIGHTMAP_HEIGHT_TEXT;
744  ShowQueryString(STR_JUST_INT, STR_MAPGEN_HEIGHTMAP_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
745  break;
746 
747 
749  case WID_GL_START_DATE_UP: // Year buttons
750  /* Don't allow too fast scrolling */
751  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
752  this->HandleButtonClick(widget);
753 
755  this->InvalidateData();
756  }
757  _left_button_clicked = false;
758  break;
759 
760  case WID_GL_START_DATE_TEXT: // Year text
761  this->widget_id = WID_GL_START_DATE_TEXT;
763  ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
764  break;
765 
767  case WID_GL_SNOW_COVERAGE_UP: // Snow coverage buttons
768  /* Don't allow too fast scrolling */
769  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
770  this->HandleButtonClick(widget);
771 
773  this->InvalidateData();
774  }
775  _left_button_clicked = false;
776  break;
777 
778  case WID_GL_SNOW_COVERAGE_TEXT: // Snow coverage text
779  this->widget_id = WID_GL_SNOW_COVERAGE_TEXT;
781  ShowQueryString(STR_JUST_INT, STR_MAPGEN_SNOW_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
782  break;
783 
785  case WID_GL_DESERT_COVERAGE_UP: // Desert coverage buttons
786  /* Don't allow too fast scrolling */
787  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
788  this->HandleButtonClick(widget);
789 
791  this->InvalidateData();
792  }
793  _left_button_clicked = false;
794  break;
795 
796  case WID_GL_DESERT_COVERAGE_TEXT: // Desert line text
797  this->widget_id = WID_GL_DESERT_COVERAGE_TEXT;
799  ShowQueryString(STR_JUST_INT, STR_MAPGEN_DESERT_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
800  break;
801 
802  case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: // Heightmap rotation
804  break;
805 
806  case WID_GL_TERRAIN_PULLDOWN: // Terrain type
807  /* For the original map generation only the first four are valid. */
809  break;
810 
811  case WID_GL_WATER_PULLDOWN: { // Water quantity
812  uint32_t hidden_mask = 0;
813  /* Disable custom water level when the original map generator is active. */
816  }
818  break;
819  }
820 
821  case WID_GL_RIVER_PULLDOWN: // Amount of rivers
823  break;
824 
825  case WID_GL_SMOOTHNESS_PULLDOWN: // Map smoothness
827  break;
828 
829  case WID_GL_VARIETY_PULLDOWN: // Map variety
831  break;
832 
833  /* Freetype map borders */
834  case WID_GL_WATER_NW:
836  this->InvalidateData();
837  break;
838 
839  case WID_GL_WATER_NE:
841  this->InvalidateData();
842  break;
843 
844  case WID_GL_WATER_SE:
846  this->InvalidateData();
847  break;
848 
849  case WID_GL_WATER_SW:
851  this->InvalidateData();
852  break;
853 
856  this->InvalidateData();
857  break;
858 
859  case WID_GL_AI_BUTTON:
861  break;
862 
863  case WID_GL_GS_BUTTON:
865  break;
866 
867  case WID_GL_NEWGRF_BUTTON:
868  ShowNewGRFSettings(true, true, false, &_grfconfig_newgame);
869  break;
870  }
871  }
872 
873  void OnTimeout() override
874  {
875  if (mode == GLWM_HEIGHTMAP) {
877  } else {
879  }
880  }
881 
882  void OnDropdownSelect(WidgetID widget, int index) override
883  {
884  switch (widget) {
890 
892 
894  if ((uint)index == CUSTOM_TOWN_NUMBER_DIFFICULTY) {
895  this->widget_id = widget;
897  ShowQueryString(STR_JUST_INT, STR_MAPGEN_NUMBER_OF_TOWNS, 5, this, CS_NUMERAL, QSF_NONE);
898  }
900  break;
901 
902  case WID_GL_TOWNNAME_DROPDOWN: // Town names
903  if (_game_mode == GM_MENU || Town::GetNumItems() == 0) {
906  }
907  break;
908 
910  if ((uint)index == ID_CUSTOM) {
911  this->widget_id = widget;
913  ShowQueryString(STR_JUST_INT, STR_MAPGEN_NUMBER_OF_INDUSTRIES, 5, this, CS_NUMERAL, QSF_NONE);
914  }
916  break;
917 
919  if ((uint)index == CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY) {
920  this->widget_id = widget;
922  ShowQueryString(STR_JUST_INT, STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_NONE);
923  }
925  break;
926  }
927 
928  case WID_GL_WATER_PULLDOWN: {
929  if ((uint)index == CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY) {
930  this->widget_id = widget;
932  ShowQueryString(STR_JUST_INT, STR_MAPGEN_SEA_LEVEL, 3, this, CS_NUMERAL, QSF_NONE);
933  }
935  break;
936  }
937  }
938  this->InvalidateData();
939  }
940 
941  void OnQueryTextFinished(char *str) override
942  {
943  /* Was 'cancel' pressed? */
944  if (str == nullptr) return;
945 
946  int32_t value;
947  if (!StrEmpty(str)) {
948  value = atoi(str);
949  } else {
950  /* An empty string means revert to the default */
951  switch (this->widget_id) {
953  case WID_GL_START_DATE_TEXT: value = CalendarTime::DEF_START_YEAR.base(); break;
954  case WID_GL_SNOW_COVERAGE_TEXT: value = DEF_SNOW_COVERAGE; break;
956  case WID_GL_TOWN_PULLDOWN: value = 1; break;
957  case WID_GL_INDUSTRY_PULLDOWN: value = 1; break;
958  case WID_GL_TERRAIN_PULLDOWN: value = MIN_MAP_HEIGHT_LIMIT; break;
960  default: NOT_REACHED();
961  }
962  }
963 
964  switch (this->widget_id) {
968  break;
969 
973  break;
974 
978  break;
979 
983  break;
984 
987  break;
988 
991  break;
992 
995  break;
996 
999  break;
1000  }
1001 
1002  this->InvalidateData();
1003  }
1004 };
1005 
1006 static WindowDesc _generate_landscape_desc(__FILE__, __LINE__,
1007  WDP_CENTER, nullptr, 0, 0,
1009  0,
1011 );
1012 
1013 static WindowDesc _heightmap_load_desc(__FILE__, __LINE__,
1014  WDP_CENTER, nullptr, 0, 0,
1016  0,
1018 );
1019 
1020 static void _ShowGenerateLandscape(GenerateLandscapeWindowMode mode)
1021 {
1022  uint x = 0;
1023  uint y = 0;
1024 
1026 
1027  /* Generate a new seed when opening the window */
1028  _settings_newgame.game_creation.generation_seed = InteractiveRandom();
1029 
1030  if (mode == GLWM_HEIGHTMAP) {
1031  /* If the function returns negative, it means there was a problem loading the heightmap */
1033  }
1034 
1035  WindowDesc *desc = (mode == GLWM_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc;
1036  GenerateLandscapeWindow *w = AllocateWindowDescFront<GenerateLandscapeWindow>(desc, mode, true);
1037 
1038  if (mode == GLWM_HEIGHTMAP) {
1039  w->x = x;
1040  w->y = y;
1041  w->name = _file_to_saveload.title;
1042  }
1043 
1045 }
1046 
1049 {
1050  _ShowGenerateLandscape(GLWM_GENERATE);
1051 }
1052 
1055 {
1056  _ShowGenerateLandscape(GLWM_HEIGHTMAP);
1057 }
1058 
1061 {
1062  StartGeneratingLandscape(GLWM_SCENARIO);
1063 }
1064 
1069 void StartNewGameWithoutGUI(uint32_t seed)
1070 {
1071  /* GenerateWorld takes care of the possible GENERATE_NEW_SEED value in 'seed' */
1073 
1074  StartGeneratingLandscape(GLWM_GENERATE);
1075 }
1076 
1078 {
1079  WidgetID widget_id;
1080 
1082  {
1083  this->InitNested(window_number);
1085  }
1086 
1087  void SetStringParameters(WidgetID widget) const override
1088  {
1089  switch (widget) {
1092  break;
1093 
1096  break;
1097 
1100  break;
1101 
1104  break;
1105  }
1106  }
1107 
1108  void OnPaint() override
1109  {
1114 
1119 
1120  this->DrawWidgets();
1121  }
1122 
1123  void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
1124  {
1125  StringID str = STR_JUST_INT;
1126  switch (widget) {
1127  case WID_CS_TEMPERATE: case WID_CS_ARCTIC:
1128  case WID_CS_TROPICAL: case WID_CS_TOYLAND:
1130  size->height += WidgetDimensions::scaled.fullbevel.Vertical();
1131  break;
1132 
1135  str = STR_JUST_DATE_LONG;
1136  break;
1137 
1141  break;
1142 
1145  break;
1146 
1147  default:
1148  return;
1149  }
1151  d.width += padding.width;
1152  d.height += padding.height;
1153  *size = maxdim(*size, d);
1154  }
1155 
1156  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1157  {
1158  switch (widget) {
1159  case WID_CS_TEMPERATE:
1160  case WID_CS_ARCTIC:
1161  case WID_CS_TROPICAL:
1162  case WID_CS_TOYLAND:
1165  break;
1166 
1167  case WID_CS_MAPSIZE_X_PULLDOWN: // Mapsize X
1169  break;
1170 
1171  case WID_CS_MAPSIZE_Y_PULLDOWN: // Mapsize Y
1173  break;
1174 
1175  case WID_CS_EMPTY_WORLD: // Empty world / flat world
1176  StartGeneratingLandscape(GLWM_SCENARIO);
1177  break;
1178 
1179  case WID_CS_RANDOM_WORLD: // Generate
1181  break;
1182 
1184  case WID_CS_START_DATE_UP: // Year buttons
1185  /* Don't allow too fast scrolling */
1186  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
1187  this->HandleButtonClick(widget);
1188  this->SetDirty();
1189 
1191  }
1192  _left_button_clicked = false;
1193  break;
1194 
1195  case WID_CS_START_DATE_TEXT: // Year text
1196  this->widget_id = WID_CS_START_DATE_TEXT;
1198  ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_NONE);
1199  break;
1200 
1202  case WID_CS_FLAT_LAND_HEIGHT_UP: // Height level buttons
1203  /* Don't allow too fast scrolling */
1204  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
1205  this->HandleButtonClick(widget);
1206  this->SetDirty();
1207 
1209  }
1210  _left_button_clicked = false;
1211  break;
1212 
1213  case WID_CS_FLAT_LAND_HEIGHT_TEXT: // Height level text
1214  this->widget_id = WID_CS_FLAT_LAND_HEIGHT_TEXT;
1216  ShowQueryString(STR_JUST_INT, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_NONE);
1217  break;
1218  }
1219  }
1220 
1221  void OnTimeout() override
1222  {
1224  }
1225 
1226  void OnDropdownSelect(WidgetID widget, int index) override
1227  {
1228  switch (widget) {
1231  }
1232  this->SetDirty();
1233  }
1234 
1235  void OnQueryTextFinished(char *str) override
1236  {
1237  if (!StrEmpty(str)) {
1238  int32_t value = atoi(str);
1239 
1240  switch (this->widget_id) {
1244  break;
1245 
1249  break;
1250  }
1251 
1252  this->SetDirty();
1253  }
1254  }
1255 };
1256 
1257 static constexpr NWidgetPart _nested_create_scenario_widgets[] = {
1259  NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
1260  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_SE_MAPGEN_CAPTION, STR_NULL),
1261  EndContainer(),
1262  NWidget(WWT_PANEL, COLOUR_BROWN),
1264  /* Landscape style selection. */
1266  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TEMPERATE), SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
1267  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_ARCTIC), SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
1268  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TROPICAL), SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
1269  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TOYLAND), SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
1270  EndContainer(),
1271 
1273  /* Green generation type buttons: 'Flat land' and 'Random land'. */
1275  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_CS_EMPTY_WORLD), SetDataTip(STR_SE_MAPGEN_FLAT_WORLD, STR_SE_MAPGEN_FLAT_WORLD_TOOLTIP), SetFill(1, 1),
1276  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_CS_RANDOM_WORLD), SetDataTip(STR_SE_MAPGEN_RANDOM_LAND, STR_TERRAFORM_TOOLTIP_GENERATE_RANDOM_LAND), SetFill(1, 1),
1277  EndContainer(),
1278 
1279  /* Labels + setting drop-downs */
1281  /* Labels. */
1283  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAPSIZE, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(0, 1),
1284  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_MAPGEN_DATE_TOOLTIP), SetFill(0, 1),
1285  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_SE_MAPGEN_FLAT_WORLD_HEIGHT, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_TOOLTIP), SetFill(0, 1),
1286  EndContainer(),
1287 
1289  /* Map size. */
1291  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_CS_MAPSIZE_X_PULLDOWN), SetDataTip(STR_JUST_INT, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
1292  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BY, STR_NULL), SetFill(0, 1), SetAlignment(SA_CENTER),
1293  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_CS_MAPSIZE_Y_PULLDOWN), SetDataTip(STR_JUST_INT, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
1294  EndContainer(),
1295 
1296  /* Date. */
1298  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),
1299  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CS_START_DATE_TEXT), SetFill(1, 1), SetDataTip(STR_JUST_DATE_LONG, STR_MAPGEN_DATE_TOOLTIP),
1300  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),
1301  EndContainer(),
1302 
1303  /* Flat map height. */
1305  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),
1306  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),
1307  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),
1308  EndContainer(),
1309  EndContainer(),
1310  EndContainer(),
1311  EndContainer(),
1312  EndContainer(),
1313  EndContainer(),
1314 };
1315 
1316 static WindowDesc _create_scenario_desc(__FILE__, __LINE__,
1317  WDP_CENTER, nullptr, 0, 0,
1319  0,
1320  std::begin(_nested_create_scenario_widgets), std::end(_nested_create_scenario_widgets)
1321 );
1322 
1325 {
1327  new CreateScenarioWindow(&_create_scenario_desc, GLWM_SCENARIO);
1328 }
1329 
1330 static constexpr NWidgetPart _nested_generate_progress_widgets[] = {
1331  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GENERATION_WORLD, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1332  NWidget(WWT_PANEL, COLOUR_GREY),
1334  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GP_PROGRESS_BAR), SetFill(1, 0),
1335  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GP_PROGRESS_TEXT), SetFill(1, 0),
1336  NWidget(WWT_TEXTBTN, COLOUR_WHITE, WID_GP_ABORT), SetDataTip(STR_GENERATION_ABORT, STR_NULL), SetFill(1, 0),
1337  EndContainer(),
1338  EndContainer(),
1339 };
1340 
1341 
1342 static WindowDesc _generate_progress_desc(__FILE__, __LINE__,
1343  WDP_CENTER, nullptr, 0, 0,
1345  0,
1346  std::begin(_nested_generate_progress_widgets), std::end(_nested_generate_progress_widgets)
1347 );
1348 
1350  uint percent;
1351  StringID cls;
1352  uint current;
1353  uint total;
1354  std::chrono::steady_clock::time_point next_update;
1355 };
1356 
1357 static GenWorldStatus _gws;
1358 
1359 static const StringID _generation_class_table[] = {
1360  STR_GENERATION_WORLD_GENERATION,
1361  STR_SCENEDIT_TOOLBAR_LANDSCAPE_GENERATION,
1362  STR_GENERATION_RIVER_GENERATION,
1363  STR_GENERATION_CLEARING_TILES,
1364  STR_SCENEDIT_TOOLBAR_TOWN_GENERATION,
1365  STR_SCENEDIT_TOOLBAR_INDUSTRY_GENERATION,
1366  STR_GENERATION_OBJECT_GENERATION,
1367  STR_GENERATION_TREE_GENERATION,
1368  STR_GENERATION_SETTINGUP_GAME,
1369  STR_GENERATION_PREPARING_TILELOOP,
1370  STR_GENERATION_PREPARING_SCRIPT,
1371  STR_GENERATION_PREPARING_GAME
1372 };
1373 static_assert(lengthof(_generation_class_table) == GWP_CLASS_COUNT);
1374 
1375 
1376 static void AbortGeneratingWorldCallback(Window *, bool confirmed)
1377 {
1378  if (confirmed) {
1380  } else if (HasModalProgress() && !IsGeneratingWorldAborted()) {
1381  SetMouseCursor(SPR_CURSOR_ZZZ, PAL_NONE);
1382  }
1383 }
1384 
1386 
1387  GenerateProgressWindow() : Window(&_generate_progress_desc)
1388  {
1389  this->InitNested();
1390  }
1391 
1392  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1393  {
1394  switch (widget) {
1395  case WID_GP_ABORT:
1396  SetMouseCursorBusy(false);
1397  ShowQuery(
1398  STR_GENERATION_ABORT_CAPTION,
1399  STR_GENERATION_ABORT_MESSAGE,
1400  this,
1401  AbortGeneratingWorldCallback
1402  );
1403  break;
1404  }
1405  }
1406 
1407  void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
1408  {
1409  switch (widget) {
1410  case WID_GP_PROGRESS_BAR: {
1411  SetDParamMaxValue(0, 100);
1412  *size = GetStringBoundingBox(STR_GENERATION_PROGRESS);
1413  /* We need some spacing for the 'border' */
1414  size->height += WidgetDimensions::scaled.frametext.Horizontal();
1415  size->width += WidgetDimensions::scaled.frametext.Vertical();
1416  break;
1417  }
1418 
1419  case WID_GP_PROGRESS_TEXT:
1420  for (uint i = 0; i < GWP_CLASS_COUNT; i++) {
1421  size->width = std::max(size->width, GetStringBoundingBox(_generation_class_table[i]).width + padding.width);
1422  }
1424  break;
1425  }
1426  }
1427 
1428  void DrawWidget(const Rect &r, WidgetID widget) const override
1429  {
1430  switch (widget) {
1431  case WID_GP_PROGRESS_BAR: {
1432  /* Draw the % complete with a bar and a text */
1433  DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY | FR_LOWERED);
1434  Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
1435  DrawFrameRect(br.WithWidth(br.Width() * _gws.percent / 100, false), COLOUR_MAUVE, FR_NONE);
1436  SetDParam(0, _gws.percent);
1437  DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, GetCharacterHeight(FS_NORMAL)), STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
1438  break;
1439  }
1440 
1441  case WID_GP_PROGRESS_TEXT:
1442  /* Tell which class we are generating */
1443  DrawString(r.left, r.right, r.top, _gws.cls, TC_FROMSTRING, SA_HOR_CENTER);
1444 
1445  /* And say where we are in that class */
1446  SetDParam(0, _gws.current);
1447  SetDParam(1, _gws.total);
1448  DrawString(r.left, r.right, r.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal, STR_GENERATION_PROGRESS_NUM, TC_FROMSTRING, SA_HOR_CENTER);
1449  }
1450  }
1451 };
1452 
1457 {
1458  _gws.cls = STR_GENERATION_WORLD_GENERATION;
1459  _gws.current = 0;
1460  _gws.total = 0;
1461  _gws.percent = 0;
1462  _gws.next_update = std::chrono::steady_clock::now();
1463 }
1464 
1469 {
1470  if (BringWindowToFrontById(WC_MODAL_PROGRESS, 0)) return;
1471  new GenerateProgressWindow();
1472 }
1473 
1474 static void _SetGeneratingWorldProgress(GenWorldProgress cls, uint progress, uint total)
1475 {
1476  static const int percent_table[] = {0, 5, 14, 17, 20, 40, 60, 65, 80, 85, 95, 99, 100 };
1477  static_assert(lengthof(percent_table) == GWP_CLASS_COUNT + 1);
1478  assert(cls < GWP_CLASS_COUNT);
1479 
1480  /* Check if we really are generating the world.
1481  * For example, placing trees via the SE also calls this function, but
1482  * shouldn't try to update the progress.
1483  */
1484  if (!HasModalProgress()) return;
1485 
1486  if (IsGeneratingWorldAborted()) {
1488  return;
1489  }
1490 
1491  if (total == 0) {
1492  assert(_gws.cls == _generation_class_table[cls]);
1493  _gws.current += progress;
1494  assert(_gws.current <= _gws.total);
1495  } else {
1496  _gws.cls = _generation_class_table[cls];
1497  _gws.current = progress;
1498  _gws.total = total;
1499  _gws.percent = percent_table[cls];
1500  }
1501 
1502  /* Percentage is about the number of completed tasks, so 'current - 1' */
1503  _gws.percent = percent_table[cls] + (percent_table[cls + 1] - percent_table[cls]) * (_gws.current == 0 ? 0 : _gws.current - 1) / _gws.total;
1504 
1505  if (_network_dedicated) {
1506  static uint last_percent = 0;
1507 
1508  /* Never display 0% */
1509  if (_gws.percent == 0) return;
1510  /* Reset if percent is lower than the last recorded */
1511  if (_gws.percent < last_percent) last_percent = 0;
1512  /* Display every 5%, but 6% is also very valid.. just not smaller steps than 5% */
1513  if (_gws.percent % 5 != 0 && _gws.percent <= last_percent + 5) return;
1514  /* Never show steps smaller than 2%, even if it is a mod 5% */
1515  if (_gws.percent <= last_percent + 2) return;
1516 
1517  Debug(net, 3, "Map generation percentage complete: {}", _gws.percent);
1518  last_percent = _gws.percent;
1519 
1520  return;
1521  }
1522 
1524 
1526 }
1527 
1537 {
1538  if (total == 0) return;
1539 
1540  _SetGeneratingWorldProgress(cls, 0, total);
1541 }
1542 
1551 {
1552  /* In fact the param 'class' isn't needed.. but for some security reasons, we want it around */
1553  _SetGeneratingWorldProgress(cls, 1, 0);
1554 }
ShowNewGRFSettings
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
Definition: newgrf_gui.cpp:2023
Window::timeout_timer
uint8_t timeout_timer
Timer value of the WF_TIMEOUT for flags.
Definition: window_gui.h:300
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1141
SetMouseCursorBusy
void SetMouseCursorBusy(bool busy)
Set or unset the ZZZ cursor.
Definition: gfx.cpp:1693
CloseWindowByClass
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Definition: window.cpp:1153
sound_func.h
WID_GL_TOWN_PULLDOWN
@ WID_GL_TOWN_PULLDOWN
Dropdown 'No. of towns'.
Definition: genworld_widget.h:23
WWT_IMGBTN_2
@ WWT_IMGBTN_2
(Toggle) Button with diff image when clicked
Definition: widget_type.h:55
SetBit
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
Definition: bitmath_func.hpp:121
SetNewLandscapeType
void SetNewLandscapeType(byte landscape)
Changes landscape type and sets genworld window dirty.
Definition: genworld_gui.cpp:64
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3082
querystring_gui.h
ShowQuery
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:1227
SM_START_HEIGHTMAP
@ SM_START_HEIGHTMAP
Load a heightmap and start a new game from it.
Definition: openttd.h:38
GenerateProgressWindow
Definition: genworld_gui.cpp:1385
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:30
GameCreationSettings::custom_sea_level
byte custom_sea_level
manually entered percentage of water in the map
Definition: settings_type.h:362
ShowCreateScenario
void ShowCreateScenario()
Show the window to create a scenario.
Definition: genworld_gui.cpp:1324
AbortGeneratingWorld
void AbortGeneratingWorld()
Initializes the abortion process.
Definition: genworld.cpp:243
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
WID_GL_START_DATE_DOWN
@ WID_GL_START_DATE_DOWN
Decrease start year.
Definition: genworld_widget.h:33
DropDownString< DropDownListItem >::NatSortFunc
static bool NatSortFunc(std::unique_ptr< const DropDownListItem > const &first, std::unique_ptr< const DropDownListItem > const &second)
Natural sorting comparator function for DropDownList::sort().
Definition: dropdown_type.h:126
WID_GL_START_DATE_UP
@ WID_GL_START_DATE_UP
Increase start year.
Definition: genworld_widget.h:35
dropdown_func.h
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:98
GameCreationSettings::landscape
byte landscape
the landscape we're currently in
Definition: settings_type.h:356
ID_CUSTOM
@ ID_CUSTOM
Custom number of industries.
Definition: settings_type.h:62
WID_GL_TEMPERATE
@ WID_GL_TEMPERATE
Button with icon "Temperate".
Definition: genworld_widget.h:15
GameCreationSettings::tgen_smoothness
byte tgen_smoothness
how rough is the terrain from 0-3
Definition: settings_type.h:351
FileToSaveLoad::title
std::string title
Internal name of the game.
Definition: saveload.h:395
CUSTOM_SEA_LEVEL_MIN_PERCENTAGE
static const uint CUSTOM_SEA_LEVEL_MIN_PERCENTAGE
Minimum percentage a user can specify for custom sea level.
Definition: genworld.h:48
timer_game_calendar.h
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:63
WC_SELECT_GAME
@ WC_SELECT_GAME
Select game window; Window numbers:
Definition: window_type.h:442
Window::SetWidgetDirty
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:552
HM_CLOCKWISE
@ HM_CLOCKWISE
Rotate the map clockwise 45 degrees.
Definition: heightmap.h:21
SetAlignment
constexpr NWidgetPart SetAlignment(StringAlignment align)
Widget part function for setting the alignment of text/images.
Definition: widget_type.h:1130
SM_EDITOR
@ SM_EDITOR
Switch to scenario editor.
Definition: openttd.h:31
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:54
MIN_MAP_SIZE_BITS
static const uint MIN_MAP_SIZE_BITS
Minimal and maximal map width and height.
Definition: map_type.h:37
FileToSaveLoad::name
std::string name
Name of the file.
Definition: saveload.h:394
DropDownList
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
Definition: dropdown_type.h:210
WID_GL_HEIGHTMAP_HEIGHT_UP
@ WID_GL_HEIGHTMAP_HEIGHT_UP
Increase max. heightmap highest mountain.
Definition: genworld_widget.h:31
_nested_heightmap_load_widgets
static constexpr NWidgetPart _nested_heightmap_load_widgets[]
Widgets of GenerateLandscapeWindow when loading heightmap.
Definition: genworld_gui.cpp:196
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:77
_nested_generate_landscape_widgets
static constexpr NWidgetPart _nested_generate_landscape_widgets[]
Widgets of GenerateLandscapeWindow when generating world.
Definition: genworld_gui.cpp:72
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
LG_ORIGINAL
@ LG_ORIGINAL
The original landscape generator.
Definition: genworld.h:20
WID_GL_MAPSIZE_Y_PULLDOWN
@ WID_GL_MAPSIZE_Y_PULLDOWN
Dropdown 'map Y size'.
Definition: genworld_widget.h:21
GameSettings::difficulty
DifficultySettings difficulty
settings related to the difficulty
Definition: settings_type.h:618
ai_gui.hpp
GameCreationSettings::variety
byte variety
variety level applied to TGP
Definition: settings_type.h:360
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1151
SND_15_BEEP
@ SND_15_BEEP
19 == 0x13 GUI button click
Definition: sound_type.h:58
WID_GL_HEIGHTMAP_NAME_TEXT
@ WID_GL_HEIGHTMAP_NAME_TEXT
Heightmap name.
Definition: genworld_widget.h:47
saveload.h
GameCreationSettings::town_name
byte town_name
the town name generator used for town names
Definition: settings_type.h:355
WC_GENERATE_LANDSCAPE
@ WC_GENERATE_LANDSCAPE
Generate landscape (newgame); Window numbers:
Definition: window_type.h:456
newgrf_townname.h
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:54
WID_GL_WATER_NW
@ WID_GL_WATER_NW
NW 'Water'/'Freeform'.
Definition: genworld_widget.h:58
MIN_CUSTOM_TERRAIN_TYPE
static const uint MIN_CUSTOM_TERRAIN_TYPE
Lowest possible peak value for world generation.
Definition: tile_type.h:27
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition: widget_type.h:50
town.h
RectPadding::Vertical
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Definition: geometry_type.hpp:69
StrongType::Typedef
Templated helper to make a type-safe 'typedef' representing a single POD value.
Definition: strong_typedef_type.hpp:150
WID_CS_MAPSIZE_X_PULLDOWN
@ WID_CS_MAPSIZE_X_PULLDOWN
Pull-down arrow for x map size.
Definition: genworld_widget.h:79
FR_LOWERED
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
Definition: window_gui.h:28
WID_GL_RIVER_PULLDOWN
@ WID_GL_RIVER_PULLDOWN
Dropdown 'Rivers'.
Definition: genworld_widget.h:53
MAX_TILE_HEIGHT
static const uint MAX_TILE_HEIGHT
Maximum allowed tile height.
Definition: tile_type.h:24
SA_RIGHT
@ SA_RIGHT
Right align the text (must be a single bit).
Definition: gfx_type.h:340
SA_VERT_CENTER
@ SA_VERT_CENTER
Vertically center the text.
Definition: gfx_type.h:344
fios.h
StrEmpty
bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:56
StartNewGameWithoutGUI
void StartNewGameWithoutGUI(uint32_t seed)
Start a normal game without the GUI.
Definition: genworld_gui.cpp:1069
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1757
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:1038
genworld.h
GameCreationSettings::custom_industry_number
uint16_t custom_industry_number
manually entered number of industries
Definition: settings_type.h:359
GameCreationSettings::heightmap_height
byte heightmap_height
highest mountain for heightmap (towards what it scales)
Definition: settings_type.h:350
WID_CS_RANDOM_WORLD
@ WID_CS_RANDOM_WORLD
Generate random land button.
Definition: genworld_widget.h:78
WID_GL_ARCTIC
@ WID_GL_ARCTIC
Button with icon "Arctic".
Definition: genworld_widget.h:16
Debug
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
Definition: debug.h:37
townname_type.h
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:619
WN_GAME_OPTIONS_GAME_OPTIONS
@ WN_GAME_OPTIONS_GAME_OPTIONS
Game options.
Definition: window_type.h:26
WindowDesc
High level window description.
Definition: window_gui.h:153
WidgetID
int WidgetID
Widget ID.
Definition: window_type.h:18
RectPadding::Horizontal
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
Definition: geometry_type.hpp:63
WID_GL_AI_BUTTON
@ WID_GL_AI_BUTTON
'AI Settings' button.
Definition: genworld_widget.h:63
Pool::MAX_SIZE
static constexpr size_t MAX_SIZE
Make template parameter accessible from outside.
Definition: pool_type.hpp:84
WC_MODAL_PROGRESS
@ WC_MODAL_PROGRESS
Progress report of landscape generation; Window numbers:
Definition: window_type.h:463
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:508
PrepareGenerateWorldProgress
void PrepareGenerateWorldProgress()
Initializes the progress counters to the starting point.
Definition: genworld_gui.cpp:1456
SetPadding
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:1188
heightmap.h
CUSTOM_TOWN_MAX_NUMBER
static const uint CUSTOM_TOWN_MAX_NUMBER
this is the maximum number of towns a user can specify in customisation
Definition: town.h:27
ClearErrorMessages
void ClearErrorMessages()
Clear all errors from the queue.
Definition: error_gui.cpp:328
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:308
GenerateLandscapeWindowMode
GenerateLandscapeWindowMode
Enum for the modes we can generate in.
Definition: genworld_gui.cpp:45
GenerateLandscapeWindow::OnInvalidateData
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Definition: genworld_gui.cpp:505
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:639
WindowNumber
int32_t WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:732
WID_GL_DESERT_COVERAGE_DOWN
@ WID_GL_DESERT_COVERAGE_DOWN
Decrease desert coverage.
Definition: genworld_widget.h:41
WID_GL_GENERATE_BUTTON
@ WID_GL_GENERATE_BUTTON
'Generate' button.
Definition: genworld_widget.h:27
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition: gfx_type.h:203
SetMouseCursor
void SetMouseCursor(CursorID sprite, PaletteID pal)
Assign a single non-animated sprite to the cursor.
Definition: gfx.cpp:1708
ShowGenerateLandscape
void ShowGenerateLandscape()
Start with a normal game.
Definition: genworld_gui.cpp:1048
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1747
SM_NEWGAME
@ SM_NEWGAME
New Game --> 'Random game'.
Definition: openttd.h:28
GameCreationSettings::custom_town_number
uint16_t custom_town_number
manually entered number of towns
Definition: settings_type.h:358
GenerateLandscapeWindow::OnClick
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
Definition: genworld_gui.cpp:672
Window::HandleButtonClick
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:591
WID_CS_TROPICAL
@ WID_CS_TROPICAL
Select tropical landscape style.
Definition: genworld_widget.h:75
MAX_MAP_HEIGHT_LIMIT
static const uint MAX_MAP_HEIGHT_LIMIT
Upper bound of maximum allowed heightlevel (in the construction settings)
Definition: tile_type.h:30
DifficultySettings::terrain_type
byte terrain_type
the mountainousness of the landscape
Definition: settings_type.h:111
game_gui.hpp
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:941
ConstructionSettings::map_height_limit
uint8_t map_height_limit
the maximum allowed heightlevel
Definition: settings_type.h:370
WID_GP_PROGRESS_BAR
@ WID_GP_PROGRESS_BAR
Progress bar.
Definition: genworld_widget.h:91
WID_GL_MAPSIZE_X_PULLDOWN
@ WID_GL_MAPSIZE_X_PULLDOWN
Dropdown 'map X size'.
Definition: genworld_widget.h:20
TimerGameCalendar::ConvertYMDToDate
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition: timer_game_calendar.cpp:55
DEF_DESERT_COVERAGE
static const uint DEF_DESERT_COVERAGE
Default desert coverage.
Definition: tile_type.h:37
GameCreationSettings::water_borders
byte water_borders
bitset of the borders that are water
Definition: settings_type.h:357
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:110
WID_GL_SNOW_COVERAGE_TEXT
@ WID_GL_SNOW_COVERAGE_TEXT
Snow coverage.
Definition: genworld_widget.h:38
WID_GL_TOWNNAME_DROPDOWN
@ WID_GL_TOWNNAME_DROPDOWN
Dropdown 'Townnames'.
Definition: genworld_widget.h:24
WID_CS_START_DATE_TEXT
@ WID_CS_START_DATE_TEXT
Clickable start date value.
Definition: genworld_widget.h:82
WID_GL_SNOW_COVERAGE_DOWN
@ WID_GL_SNOW_COVERAGE_DOWN
Decrease snow coverage.
Definition: genworld_widget.h:37
WID_CS_START_DATE_UP
@ WID_CS_START_DATE_UP
Increase start year (start later).
Definition: genworld_widget.h:83
dropdown_type.h
WID_GL_DESERT_COVERAGE_UP
@ WID_GL_DESERT_COVERAGE_UP
Increase desert coverage.
Definition: genworld_widget.h:43
CUSTOM_SEA_LEVEL_MAX_PERCENTAGE
static const uint CUSTOM_SEA_LEVEL_MAX_PERCENTAGE
Maximum percentage a user can specify for custom sea level.
Definition: genworld.h:49
HasModalProgress
bool HasModalProgress()
Check if we are currently in a modal progress state.
Definition: progress.h:17
MAP_HEIGHT_LIMIT_AUTO_MINIMUM
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
WID_CS_FLAT_LAND_HEIGHT_UP
@ WID_CS_FLAT_LAND_HEIGHT_UP
Increase flat land height.
Definition: genworld_widget.h:86
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1258
industry.h
safeguards.h
GenerateLandscapeWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: genworld_gui.cpp:873
ShowQueryString
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:1083
Window::LowerWidget
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition: window_gui.h:460
WID_GL_WATER_PULLDOWN
@ WID_GL_WATER_PULLDOWN
Dropdown 'Sea level'.
Definition: genworld_widget.h:52
GameCreationSettings::starting_year
TimerGameCalendar::Year starting_year
starting date
Definition: settings_type.h:341
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:294
GameCreationSettings::custom_terrain_type
byte custom_terrain_type
manually entered height for TGP to aim for
Definition: settings_type.h:361
ConstructionSettings::freeform_edges
bool freeform_edges
allow terraforming the tiles at the map edges
Definition: settings_type.h:383
WF_TIMEOUT
@ WF_TIMEOUT
Window timeout counter.
Definition: window_gui.h:222
CreateScenarioWindow
Definition: genworld_gui.cpp:1077
WID_GL_SMOOTHNESS_PULLDOWN
@ WID_GL_SMOOTHNESS_PULLDOWN
Dropdown 'Smoothness'.
Definition: genworld_widget.h:54
DifficultySettings::quantity_sea_lakes
byte quantity_sea_lakes
the amount of seas/lakes
Definition: settings_type.h:112
DifficultySettings::industry_density
byte industry_density
The industry density.
Definition: settings_type.h:102
GameCreationSettings::se_flat_world_height
byte se_flat_world_height
land height a flat world gets in SE
Definition: settings_type.h:354
Rect::WithWidth
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
Definition: geometry_type.hpp:185
GenWorldStatus
Definition: genworld_gui.cpp:1349
GLWM_SCENARIO
@ GLWM_SCENARIO
Generate flat land.
Definition: genworld_gui.cpp:48
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
error.h
WID_GL_TERRAIN_PULLDOWN
@ WID_GL_TERRAIN_PULLDOWN
Dropdown 'Terrain type'.
Definition: genworld_widget.h:51
TimerGameConst< struct Calendar >::MAX_YEAR
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,...
Definition: timer_game_common.h:173
CenterBounds
int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
Definition: gfx_func.h:166
TimerGameConst< struct Calendar >::DEF_START_YEAR
static constexpr TimerGame< struct Calendar >::Year DEF_START_YEAR
The default starting year.
Definition: timer_game_common.h:179
ShowDropDownMenu
void ShowDropDownMenu(Window *w, 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:386
_network_dedicated
bool _network_dedicated
are we a dedicated server?
Definition: network.cpp:62
stdafx.h
SM_GENRANDLAND
@ SM_GENRANDLAND
Generate random land within scenario editor.
Definition: openttd.h:36
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:296
WID_GL_HEIGHTMAP_HEIGHT_DOWN
@ WID_GL_HEIGHTMAP_HEIGHT_DOWN
Decrease heightmap highest mountain.
Definition: genworld_widget.h:29
ShowGSConfigWindow
void ShowGSConfigWindow()
Open the GS config window.
Definition: game_gui.cpp:476
IncreaseGeneratingWorldProgress
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
Definition: genworld_gui.cpp:1550
Window::InvalidateData
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Definition: window.cpp:3140
VideoDriver::GetInstance
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Definition: video_driver.hpp:200
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:45
WID_GL_CLIMATE_SEL_SELECTOR
@ WID_GL_CLIMATE_SEL_SELECTOR
NWID_SELECTION for snow or desert coverage selector.
Definition: genworld_widget.h:68
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_type.h:339
Window::SetWidgetLoweredState
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:441
BUILTIN_TOWNNAME_GENERATOR_COUNT
static constexpr uint BUILTIN_TOWNNAME_GENERATOR_COUNT
Number of built-in town name generators.
Definition: townname_type.h:22
WID_GL_SNOW_COVERAGE_UP
@ WID_GL_SNOW_COVERAGE_UP
Increase snow coverage.
Definition: genworld_widget.h:39
ShowHeightmapLoad
void ShowHeightmapLoad()
Start with loading a heightmap.
Definition: genworld_gui.cpp:1054
GetHeightmapDimensions
bool GetHeightmapDimensions(DetailedFileType dft, const char *filename, uint *x, uint *y)
Get the dimensions of a heightmap.
Definition: heightmap.cpp:511
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:79
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
Window::SetWidgetDisabledState
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:381
SM_LOAD_HEIGHTMAP
@ SM_LOAD_HEIGHTMAP
Load heightmap from scenario editor.
Definition: openttd.h:39
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:71
GenWorldProgress
GenWorldProgress
Current stage of world generation process.
Definition: genworld.h:69
VideoDriver::GameLoopPause
void GameLoopPause()
Pause the game-loop for a bit, releasing the game-state lock.
Definition: video_driver.cpp:66
WID_GL_VARIETY_PULLDOWN
@ WID_GL_VARIETY_PULLDOWN
Dropdown 'Variety distribution'.
Definition: genworld_widget.h:55
WID_CS_MAPSIZE_Y_PULLDOWN
@ WID_CS_MAPSIZE_Y_PULLDOWN
Pull-down arrow for y map size.
Definition: genworld_widget.h:80
WID_GL_HEIGHTMAP_HEIGHT_TEXT
@ WID_GL_HEIGHTMAP_HEIGHT_TEXT
Max. heightmap highest mountain.
Definition: genworld_widget.h:30
string_func.h
MIN_HEIGHTMAP_HEIGHT
static const uint MIN_HEIGHTMAP_HEIGHT
Lowest possible peak value for heightmap creation.
Definition: tile_type.h:26
WID_GP_ABORT
@ WID_GP_ABORT
Abort button.
Definition: genworld_widget.h:93
_switch_mode
SwitchMode _switch_mode
The next mainloop command.
Definition: gfx.cpp:48
GLWM_HEIGHTMAP
@ GLWM_HEIGHTMAP
Load from heightmap.
Definition: genworld_gui.cpp:47
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:240
GameCreationSettings::heightmap_rotation
byte heightmap_rotation
rotation director for the heightmap
Definition: settings_type.h:353
WC_GAME_OPTIONS
@ WC_GAME_OPTIONS
Game options window; Window numbers:
Definition: window_type.h:619
WID_GL_HEIGHTMAP_ROTATION_PULLDOWN
@ WID_GL_HEIGHTMAP_ROTATION_PULLDOWN
Dropdown 'Heightmap rotation'.
Definition: genworld_widget.h:49
strings_func.h
WID_GL_WATER_NE
@ WID_GL_WATER_NE
NE 'Water'/'Freeform'.
Definition: genworld_widget.h:59
ShowDropDownList
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close)
Show a drop down list.
Definition: dropdown.cpp:349
WID_GL_GS_BUTTON
@ WID_GL_GS_BUTTON
'Game Script Settings' button.
Definition: genworld_widget.h:64
WID_GL_NEWGRF_BUTTON
@ WID_GL_NEWGRF_BUTTON
'NewGRF Settings' button.
Definition: genworld_widget.h:65
GameCreationSettings::generation_seed
uint32_t generation_seed
noise seed for world generation
Definition: settings_type.h:340
MIN_MAP_HEIGHT_LIMIT
static const uint MIN_MAP_HEIGHT_LIMIT
Lower bound of maximum allowed heightlevel (in the construction settings)
Definition: tile_type.h:29
MAX_MAP_SIZE_BITS
static const uint MAX_MAP_SIZE_BITS
Maximal size of map is equal to 2 ^ MAX_MAP_SIZE_BITS.
Definition: map_type.h:38
Pool::PoolItem<&_town_pool >::GetNumItems
static size_t GetNumItems()
Returns number of valid items in the pool.
Definition: pool_type.hpp:365
ShowGenerateWorldProgress
void ShowGenerateWorldProgress()
Show the window where a user can follow the process of the map generation.
Definition: genworld_gui.cpp:1468
HandleGeneratingWorldAbortion
void HandleGeneratingWorldAbortion()
Really handle the abortion, i.e.
Definition: genworld.cpp:260
GameCreationSettings::map_y
uint8_t map_y
Y size of map.
Definition: settings_type.h:344
GameCreationSettings::map_x
uint8_t map_x
X size of map.
Definition: settings_type.h:343
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:60
SetPIP
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:1220
WID_CS_TEMPERATE
@ WID_CS_TEMPERATE
Select temperate landscape style.
Definition: genworld_widget.h:73
SetDParamMaxValue
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
GameCreationSettings::desert_coverage
byte desert_coverage
the amount of desert coverage on the map
Definition: settings_type.h:349
GameCreationSettings::amount_of_rivers
byte amount_of_rivers
the amount of rivers
Definition: settings_type.h:365
GameCreationSettings::land_generator
byte land_generator
the landscape generator
Definition: settings_type.h:345
video_driver.hpp
SetDParam
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
geometry_func.hpp
CreateScenarioWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: genworld_gui.cpp:1221
InvalidateWindowClassesData
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:3217
_file_to_saveload
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
Definition: saveload.cpp:60
GenerateLandscapeWindow
Definition: genworld_gui.cpp:386
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:52
WidgetDimensions::vsep_normal
int vsep_normal
Normal vertical spacing.
Definition: window_gui.h:60
CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY
static const uint CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY
Value for custom terrain type in difficulty settings.
Definition: genworld.h:45
WID_GL_INDUSTRY_PULLDOWN
@ WID_GL_INDUSTRY_PULLDOWN
Dropdown 'No. of industries'.
Definition: genworld_widget.h:25
WID_GL_WATER_SE
@ WID_GL_WATER_SE
SE 'Water'/'Freeform'.
Definition: genworld_widget.h:60
TimerGameConst< struct Calendar >::MIN_YEAR
static constexpr TimerGame< struct Calendar >::Year MIN_YEAR
The absolute minimum year in OTTD.
Definition: timer_game_common.h:176
GLWM_GENERATE
@ GLWM_GENERATE
Generate new game.
Definition: genworld_gui.cpp:46
progress.h
SetDParamStr
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:352
WID_GL_DESERT_COVERAGE_TEXT
@ WID_GL_DESERT_COVERAGE_TEXT
Desert coverage.
Definition: genworld_widget.h:42
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:81
WID_GL_BORDERS_RANDOM
@ WID_GL_BORDERS_RANDOM
'Random'/'Manual' borders.
Definition: genworld_widget.h:57
WID_GL_HEIGHTMAP_SIZE_TEXT
@ WID_GL_HEIGHTMAP_SIZE_TEXT
Size of heightmap.
Definition: genworld_widget.h:48
WidgetDimensions::fullbevel
RectPadding fullbevel
Always-scaled bevel thickness.
Definition: window_gui.h:41
WID_GL_CLIMATE_SEL_LABEL
@ WID_GL_CLIMATE_SEL_LABEL
NWID_SELECTION for snow or desert coverage label.
Definition: genworld_widget.h:67
WID_CS_START_DATE_DOWN
@ WID_CS_START_DATE_DOWN
Decrease start year (start earlier).
Definition: genworld_widget.h:81
Window::RaiseWidget
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
Definition: window_gui.h:469
DrawFrameRect
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition: widget.cpp:281
network.h
WID_CS_FLAT_LAND_HEIGHT_DOWN
@ WID_CS_FLAT_LAND_HEIGHT_DOWN
Decrease flat land height.
Definition: genworld_widget.h:84
window_func.h
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition: gfx_type.h:348
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition: fontcache.cpp:78
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:300
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:305
SetPIPRatio
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:1232
random_func.hpp
WID_CS_EMPTY_WORLD
@ WID_CS_EMPTY_WORLD
Generate an empty flat world.
Definition: genworld_widget.h:77
WID_GL_START_DATE_TEXT
@ WID_GL_START_DATE_TEXT
Start year.
Definition: genworld_widget.h:34
IsGeneratingWorldAborted
bool IsGeneratingWorldAborted()
Is the generation being aborted?
Definition: genworld.cpp:252
WID_GL_TOYLAND
@ WID_GL_TOYLAND
Button with icon "Toyland".
Definition: genworld_widget.h:18
DrawString
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:658
GameCreationSettings::snow_coverage
byte snow_coverage
the amount of snow coverage on the map
Definition: settings_type.h:348
StartScenarioEditor
void StartScenarioEditor()
Start with a scenario editor.
Definition: genworld_gui.cpp:1060
ID_END
@ ID_END
Number of industry density settings.
Definition: settings_type.h:64
Window::RaiseWidgetsWhenLowered
void RaiseWidgetsWhenLowered(Args... widgets)
Raises the widgets and sets widgets dirty that are lowered.
Definition: window_gui.h:536
SetGeneratingWorldProgress
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
Definition: genworld_gui.cpp:1536
WidgetDimensions::frametext
RectPadding frametext
Padding inside frame with text.
Definition: window_gui.h:43
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition: settings_type.h:620
CloseAllNonVitalWindows
void CloseAllNonVitalWindows()
It is possible that a stickied window gets to a position where the 'close' button is outside the gami...
Definition: window.cpp:3261
Window
Data structure for an opened window.
Definition: window_gui.h:267
FileToSaveLoad::detail_ftype
DetailedFileType detail_ftype
Concrete file type (PNG, BMP, old save, etc).
Definition: saveload.h:392
GetMapHeightLimit
static uint GetMapHeightLimit()
Get the map height limit, or if set to "auto", the absolute limit.
Definition: genworld_gui.cpp:54
WID_CS_TOYLAND
@ WID_CS_TOYLAND
Select toy-land landscape style.
Definition: genworld_widget.h:76
ResetGRFConfig
void ResetGRFConfig(bool defaults)
Reset the current GRF Config to either blank or newgame settings.
Definition: newgrf_config.cpp:451
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:731
Clamp
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:79
MAX_MAP_SIZE
static const uint MAX_MAP_SIZE
Maximal map size = 4096.
Definition: map_type.h:40
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1162
SetMinimalTextLines
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:1109
Rect::Width
int Width() const
Get width of Rect.
Definition: geometry_type.hpp:85
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:82
WID_CS_FLAT_LAND_HEIGHT_TEXT
@ WID_CS_FLAT_LAND_HEIGHT_TEXT
Clickable flat land height value.
Definition: genworld_widget.h:85
CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY
static const uint CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY
Value for custom sea level in difficulty settings.
Definition: genworld.h:47
ShowAIConfigWindow
void ShowAIConfigWindow()
Open the AI config window.
Definition: ai_gui.cpp:320
WID_GL_TROPICAL
@ WID_GL_TROPICAL
Button with icon "Tropical".
Definition: genworld_widget.h:17
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:75
BringWindowToFrontById
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
Definition: window.cpp:1224
DifficultySettings::number_towns
byte number_towns
the amount of towns
Definition: settings_type.h:101
Window::SetWidgetsDisabledState
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
Definition: window_gui.h:515
QSF_ENABLE_DEFAULT
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
Definition: textbuf_gui.h:21
CreateScenarioWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: genworld_gui.cpp:1108
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition: window_gui.h:142
WID_CS_ARCTIC
@ WID_CS_ARCTIC
Select arctic landscape style.
Definition: genworld_widget.h:74
_left_button_clicked
bool _left_button_clicked
Is left mouse button clicked?
Definition: gfx.cpp:41
SetTextStyle
constexpr NWidgetPart SetTextStyle(TextColour colour, FontSize size=FS_NORMAL)
Widget part function for setting the text style.
Definition: widget_type.h:1120
CS_NUMERAL
@ CS_NUMERAL
Only numeric ones.
Definition: string_type.h:26
ToggleBit
constexpr T ToggleBit(T &x, const uint8_t y)
Toggles a bit in a variable.
Definition: bitmath_func.hpp:181
CUSTOM_TOWN_NUMBER_DIFFICULTY
static const uint CUSTOM_TOWN_NUMBER_DIFFICULTY
value for custom town number in difficulty settings
Definition: town.h:26
GetStringBoundingBox
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:852
WID_GP_PROGRESS_TEXT
@ WID_GP_PROGRESS_TEXT
Text with the progress bar.
Definition: genworld_widget.h:92
genworld_widget.h
_settings_newgame
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Definition: settings.cpp:56
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:57
INVALID_STRING_ID
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:17
debug.h
FR_BORDERONLY
@ FR_BORDERONLY
Draw border only, no background.
Definition: window_gui.h:27
_grfconfig_newgame
GRFConfig * _grfconfig_newgame
First item in list of default GRF set up.
Definition: newgrf_config.cpp:165
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:72
WID_GL_WATER_SW
@ WID_GL_WATER_SW
SW 'Water'/'Freeform'.
Definition: genworld_widget.h:61
DEF_SNOW_COVERAGE
static const uint DEF_SNOW_COVERAGE
Default snow coverage.
Definition: tile_type.h:36
HasBit
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103