OpenTTD Source  1.11.0-RC1
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"
17 #include "date_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 
35 
36 #include "safeguards.h"
37 
38 
39 extern void MakeNewgameSettingsLive();
40 
46 };
47 
52 void SetNewLandscapeType(byte landscape)
53 {
57 }
58 
62  NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
63  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_MAPGEN_WORLD_GENERATION_CAPTION, STR_NULL),
64  EndContainer(),
65  NWidget(WWT_PANEL, COLOUR_BROWN),
67  /* Landscape selection. */
68  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 10),
69  NWidget(NWID_SPACER), SetFill(1, 0),
70  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TEMPERATE), SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
71  NWidget(NWID_SPACER), SetFill(1, 0),
72  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_ARCTIC), SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
73  NWidget(NWID_SPACER), SetFill(1, 0),
74  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TROPICAL), SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
75  NWidget(NWID_SPACER), SetFill(1, 0),
76  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TOYLAND), SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
77  NWidget(NWID_SPACER), SetFill(1, 0),
78  EndContainer(),
80  NWidget(NWID_HORIZONTAL), SetPIP(10, 5, 10),
81  NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0),
82  /* Left column with labels. */
84  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAPSIZE, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
85  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_LAND_GENERATOR, STR_NULL), SetFill(1, 1),
86  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_TERRAIN_TYPE, STR_NULL), SetFill(1, 1),
87  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_VARIETY, STR_NULL), SetFill(1, 1),
88  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_QUANTITY_OF_SEA_LAKES, STR_NULL), SetFill(1, 1),
89  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_TOWNS, STR_NULL), SetFill(1, 1),
90  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES, STR_NULL), SetFill(1, 1),
91  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BORDER_TYPE, STR_NULL), SetFill(1, 1),
92  EndContainer(),
93  /* Widgets at the right of the labels. */
95  /* Mapsize X * Y. */
96  NWidget(NWID_HORIZONTAL), SetPIP(0, 4, 0),
97  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_X_PULLDOWN), SetDataTip(STR_JUST_INT, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 0),
98  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BY, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(1, 1),
99  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_Y_PULLDOWN), SetDataTip(STR_JUST_INT, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 0),
100  EndContainer(),
101  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_LANDSCAPE_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
102  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TERRAIN_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
103  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_VARIETY_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
104  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_WATER_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
105  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWN_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
106  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_INDUSTRY_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
107  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_BORDERS_RANDOM), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
108  EndContainer(),
109  EndContainer(),
110  NWidget(NWID_VERTICAL), SetPIP(0, 4, 0),
111  NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0),
113  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAX_HEIGHTLEVEL, STR_NULL), SetFill(1, 1),
114  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SNOW_LINE_HEIGHT, STR_NULL), SetFill(1, 1),
115  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_NULL), SetFill(1, 1),
116  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SMOOTHNESS, STR_NULL), SetFill(1, 1),
117  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_NULL), SetFill(1, 1),
118  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_GAME_OPTIONS_TOWN_NAMES_FRAME, STR_NULL), SetFill(1, 1),
119  EndContainer(),
121  /* Max. heightlevel. */
123  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_MAX_HEIGHTLEVEL_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_MAX_HEIGHTLEVEL_DOWN), SetFill(0, 1),
124  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_MAX_HEIGHTLEVEL_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL), SetFill(1, 0),
125  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_MAX_HEIGHTLEVEL_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_MAX_HEIGHTLEVEL_UP), SetFill(0, 1),
126  EndContainer(),
127  /* Snow line. */
129  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_LINE_DOWN), SetFill(0, 1),
130  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL), SetFill(1, 0),
131  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_LINE_UP), SetFill(0, 1),
132  EndContainer(),
133  /* Starting date. */
135  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),
136  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetDataTip(STR_BLACK_DATE_LONG, STR_NULL), SetFill(1, 0),
137  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),
138  EndContainer(),
139  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_SMOOTHNESS_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
140  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_RIVER_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
141  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWNNAME_DROPDOWN), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_TOWN_NAMES_DROPDOWN_TOOLTIP), SetFill(1, 0),
142  EndContainer(),
143  EndContainer(),
144  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_GL_GENERATE_BUTTON), SetMinimalSize(84, 0), SetDataTip(STR_MAPGEN_GENERATE, STR_NULL), SetFill(1, 1),
145  EndContainer(),
146  EndContainer(),
148  /* Map borders buttons for each edge. */
150  NWidget(NWID_HORIZONTAL), SetPIP(0, 0, 3),
151  NWidget(NWID_SPACER), SetFill(1, 1),
152  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NORTHWEST, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(0, 1),
153  EndContainer(),
154  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_NW), SetDataTip(STR_JUST_STRING, STR_MAPGEN_NORTHWEST), SetFill(1, 1),
155  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_NE), SetDataTip(STR_JUST_STRING, STR_MAPGEN_NORTHEAST), SetFill(1, 1),
156  NWidget(NWID_HORIZONTAL), SetPIP(3, 0, 0),
157  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NORTHEAST, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(0, 1),
158  NWidget(NWID_SPACER), SetFill(1, 1),
159  EndContainer(),
160  EndContainer(),
162  NWidget(NWID_HORIZONTAL), SetPIP(0, 0, 3),
163  NWidget(NWID_SPACER), SetFill(1, 1),
164  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SOUTHWEST, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(0, 1),
165  EndContainer(),
166  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_SW), SetDataTip(STR_JUST_STRING, STR_MAPGEN_SOUTHWEST), SetFill(1, 1),
167  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_SE), SetDataTip(STR_JUST_STRING, STR_MAPGEN_SOUTHEAST), SetFill(1, 1),
168  NWidget(NWID_HORIZONTAL), SetPIP(3, 0, 0),
169  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SOUTHEAST, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(0, 1),
170  NWidget(NWID_SPACER), SetFill(1, 1),
171  EndContainer(),
172  EndContainer(),
173  NWidget(NWID_SPACER), SetMinimalSize(0, 9), SetFill(1, 1),
174  EndContainer(),
175 };
176 
179  /* Window header. */
181  NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
182  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_MAPGEN_WORLD_GENERATION_CAPTION, STR_NULL),
183  EndContainer(),
184  NWidget(WWT_PANEL, COLOUR_BROWN),
186  /* Landscape selection. */
187  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 10),
188  NWidget(NWID_SPACER), SetFill(1, 0),
189  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TEMPERATE), SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
190  NWidget(NWID_SPACER), SetFill(1, 0),
191  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_ARCTIC), SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
192  NWidget(NWID_SPACER), SetFill(1, 0),
193  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TROPICAL), SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
194  NWidget(NWID_SPACER), SetFill(1, 0),
195  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TOYLAND), SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
196  NWidget(NWID_SPACER), SetFill(1, 0),
197  EndContainer(),
198  NWidget(NWID_SPACER), SetMinimalSize(0, 11), SetFill(0, 1),
199  NWidget(NWID_HORIZONTAL), SetPIP(10, 3, 10),
200  /* Labels at the left side. */
202  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_NAME, STR_NULL), SetFill(1, 1),
203  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_SIZE_LABEL, STR_NULL), SetFill(1, 1),
204  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAPSIZE, STR_NULL), SetFill(1, 1),
205  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_ROTATION, STR_NULL), SetFill(1, 1),
206  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_TOWNS, STR_NULL), SetFill(1, 1),
207  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES, STR_NULL), SetFill(1, 1),
208  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_NULL), SetFill(1, 1),
209  EndContainer(),
210  /* Widgets at the right of the labels. */
211  NWidget(NWID_VERTICAL), SetPIP(0, 4, 0),
212  NWidget(WWT_EMPTY, COLOUR_ORANGE, WID_GL_HEIGHTMAP_NAME_TEXT), SetFill(1, 0),
213  NWidget(NWID_HORIZONTAL), SetPIP(0, 5, 0),
215  NWidget(WWT_TEXT, COLOUR_ORANGE, WID_GL_HEIGHTMAP_SIZE_TEXT), SetDataTip(STR_MAPGEN_HEIGHTMAP_SIZE, STR_NULL), SetFill(1, 0),
216  /* Mapsize X * Y. */
217  NWidget(NWID_HORIZONTAL), SetPIP(0, 4, 0),
218  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_X_PULLDOWN), SetDataTip(STR_JUST_INT, STR_NULL), SetFill(1, 0),
219  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BY, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(1, 1),
220  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_Y_PULLDOWN), SetDataTip(STR_JUST_INT, STR_NULL), SetFill(1, 0),
221  EndContainer(),
222  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_ROTATION_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
223  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWN_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
224  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_INDUSTRY_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
225  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_RIVER_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
226  EndContainer(),
227  NWidget(NWID_VERTICAL), SetPIP(0, 4, 0),
228  NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0),
230  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAX_HEIGHTLEVEL, STR_NULL), SetFill(1, 1),
231  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SNOW_LINE_HEIGHT, STR_NULL), SetFill(1, 1),
232  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_NULL), SetFill(1, 1),
233  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_GAME_OPTIONS_TOWN_NAMES_FRAME, STR_NULL), SetFill(1, 1),
234  EndContainer(),
237  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_MAX_HEIGHTLEVEL_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_MAX_HEIGHTLEVEL_DOWN), SetFill(0, 1),
238  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_MAX_HEIGHTLEVEL_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL), SetFill(1, 0),
239  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_MAX_HEIGHTLEVEL_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_MAX_HEIGHTLEVEL_UP), SetFill(0, 1),
240  EndContainer(),
242  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_LINE_DOWN), SetFill(0, 1),
243  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL), SetFill(1, 0),
244  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_LINE_UP), SetFill(0, 1),
245  EndContainer(),
247  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),
248  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetDataTip(STR_BLACK_DATE_LONG, STR_NULL), SetFill(1, 0),
249  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),
250  EndContainer(),
251  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWNNAME_DROPDOWN), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_TOWN_NAMES_DROPDOWN_TOOLTIP), SetFill(1, 0),
252  EndContainer(),
253  EndContainer(),
254  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_GL_GENERATE_BUTTON), SetMinimalSize(84, 0), SetDataTip(STR_MAPGEN_GENERATE, STR_NULL), SetFill(1, 1),
255  EndContainer(),
256  EndContainer(),
257  EndContainer(),
258  EndContainer(),
259  NWidget(NWID_SPACER), SetMinimalSize(0, 9), SetFill(1, 1),
260  EndContainer(),
261 };
262 
263 static void StartGeneratingLandscape(GenerateLandscapeWindowMode mode)
264 {
267 
268  /* Copy all XXX_newgame to XXX when coming from outside the editor */
269  MakeNewgameSettingsLive();
270  ResetGRFConfig(true);
271 
272  if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP);
273  switch (mode) {
274  case GLWM_GENERATE: _switch_mode = (_game_mode == GM_EDITOR) ? SM_GENRANDLAND : SM_NEWGAME; break;
275  case GLWM_HEIGHTMAP: _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_HEIGHTMAP : SM_START_HEIGHTMAP; break;
276  case GLWM_SCENARIO: _switch_mode = SM_EDITOR; break;
277  default: NOT_REACHED();
278  }
279 }
280 
281 static void LandscapeGenerationCallback(Window *w, bool confirmed)
282 {
283  if (confirmed) StartGeneratingLandscape((GenerateLandscapeWindowMode)w->window_number);
284 }
285 
286 static DropDownList BuildMapsizeDropDown()
287 {
288  DropDownList list;
289 
290  for (uint i = MIN_MAP_SIZE_BITS; i <= MAX_MAP_SIZE_BITS; i++) {
291  DropDownListParamStringItem *item = new DropDownListParamStringItem(STR_JUST_INT, i, false);
292  item->SetParam(0, 1LL << i);
293  list.emplace_back(item);
294  }
295 
296  return list;
297 }
298 
299 static DropDownList BuildTownNameDropDown()
300 {
301  DropDownList list;
302 
303  /* Add and sort newgrf townnames generators */
304  const auto &grf_names = GetGRFTownNameList();
305  for (uint i = 0; i < grf_names.size(); i++) {
306  list.emplace_back(new DropDownListStringItem(grf_names[i], BUILTIN_TOWNNAME_GENERATOR_COUNT + i, false));
307  }
308  std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
309 
310  size_t newgrf_size = list.size();
311  /* Insert newgrf_names at the top of the list */
312  if (newgrf_size > 0) {
313  list.emplace_back(new DropDownListItem(-1, false)); // separator line
314  newgrf_size++;
315  }
316 
317  /* Add and sort original townnames generators */
318  for (uint i = 0; i < BUILTIN_TOWNNAME_GENERATOR_COUNT; i++) {
319  list.emplace_back(new DropDownListStringItem(STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + i, i, false));
320  }
321  std::sort(list.begin() + newgrf_size, list.end(), DropDownListStringItem::NatSortFunc);
322 
323  return list;
324 }
325 
326 
327 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, INVALID_STRING_ID};
328 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};
329 static const StringID _rivers[] = {STR_RIVERS_NONE, STR_RIVERS_FEW, STR_RIVERS_MODERATE, STR_RIVERS_LOT, INVALID_STRING_ID};
330 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};
331 static const StringID _rotation[] = {STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE, INVALID_STRING_ID};
332 static const StringID _landscape[] = {STR_CONFIG_SETTING_LAND_GENERATOR_ORIGINAL, STR_CONFIG_SETTING_LAND_GENERATOR_TERRA_GENESIS, INVALID_STRING_ID};
333 static const StringID _num_towns[] = {STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM, INVALID_STRING_ID};
334 static const StringID _num_inds[] = {STR_FUNDING_ONLY, STR_MINIMAL, STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, INVALID_STRING_ID};
335 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};
336 
337 static_assert(lengthof(_num_inds) == ID_END + 1);
338 
340  uint widget_id;
341  uint x;
342  uint y;
343  char name[64];
345 
346  GenerateLandscapeWindow(WindowDesc *desc, WindowNumber number = 0) : Window(desc)
347  {
348  this->InitNested(number);
349 
351 
352  this->mode = (GenerateLandscapeWindowMode)this->window_number;
353 
354  /* Disable town and industry in SE */
355  this->SetWidgetDisabledState(WID_GL_TOWN_PULLDOWN, _game_mode == GM_EDITOR);
356  this->SetWidgetDisabledState(WID_GL_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR);
357 
358  this->OnInvalidateData();
359  }
360 
361 
362  void SetStringParameters(int widget) const override
363  {
364  switch (widget) {
370 
372  if (_game_mode == GM_EDITOR) {
373  SetDParam(0, STR_CONFIG_SETTING_OFF);
375  SetDParam(0, STR_NUM_CUSTOM_NUMBER);
377  } else {
379  }
380  break;
381 
385  STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + gen :
386  GetGRFTownNameName(gen - BUILTIN_TOWNNAME_GENERATOR_COUNT);
387  SetDParam(0, name);
388  break;
389  }
390 
391  case WID_GL_INDUSTRY_PULLDOWN: SetDParam(0, _game_mode == GM_EDITOR ? STR_CONFIG_SETTING_OFF : _num_inds[_settings_newgame.difficulty.industry_density]); break;
394 
397  SetDParam(0, STR_SEA_LEVEL_CUSTOM_PERCENTAGE);
399  } else {
401  }
402  break;
403 
407  case WID_GL_BORDERS_RANDOM: SetDParam(0, (_settings_newgame.game_creation.water_borders == BORDERS_RANDOM) ? STR_MAPGEN_BORDER_RANDOMIZE : STR_MAPGEN_BORDER_MANUAL); break;
408  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;
409  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;
410  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;
411  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;
413 
416  SetDParam(0, this->y);
417  SetDParam(1, this->x);
418  } else {
419  SetDParam(0, this->x);
420  SetDParam(1, this->y);
421  }
422  break;
423  }
424  }
425 
431  void OnInvalidateData(int data = 0, bool gui_scope = true) override
432  {
433  if (!gui_scope) return;
434  /* Update the climate buttons */
439 
440  /* You can't select smoothness / non-water borders if not terragenesis */
441  if (mode == GLWM_GENERATE) {
447 
449 
454 
457  }
458 
459  /* Disable snowline if not arctic */
461 
462  /* Update availability of decreasing / increasing start date and snow level */
469 
470  /* Do not allow a custom sea level with the original land generator. */
474  }
475 
476  }
477 
478  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
479  {
480  const StringID *strs = nullptr;
481  switch (widget) {
484  *size = GetStringBoundingBox(STR_JUST_INT);
485  break;
486 
489  *size = maxdim(*size, GetStringBoundingBox(STR_BLACK_DATE_LONG));
490  break;
491 
495  *size = maxdim(*size, GetStringBoundingBox(STR_JUST_INT));
496  break;
497 
500  *size = maxdim(*size, GetStringBoundingBox(STR_JUST_INT));
501  break;
502 
504  SetDParam(0, this->x);
505  SetDParam(1, this->y);
506  *size = maxdim(*size, GetStringBoundingBox(STR_MAPGEN_HEIGHTMAP_SIZE));
507  break;
508 
510  strs = _num_towns;
512  *size = maxdim(*size, GetStringBoundingBox(STR_NUM_CUSTOM_NUMBER));
513  break;
514 
515  case WID_GL_INDUSTRY_PULLDOWN: strs = _num_inds; break;
516  case WID_GL_LANDSCAPE_PULLDOWN: strs = _landscape; break;
517  case WID_GL_TERRAIN_PULLDOWN: strs = _elevations; break;
519  strs = _sea_lakes;
521  *size = maxdim(*size, GetStringBoundingBox(STR_SEA_LEVEL_CUSTOM_PERCENTAGE));
522  break;
523 
524  case WID_GL_RIVER_PULLDOWN: strs = _rivers; break;
525  case WID_GL_SMOOTHNESS_PULLDOWN: strs = _smoothness; break;
526  case WID_GL_VARIETY_PULLDOWN: strs = _variety; break;
527  case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: strs = _rotation; break;
529  *size = maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_RANDOMIZE), GetStringBoundingBox(STR_MAPGEN_BORDER_MANUAL));
530  break;
531 
532  case WID_GL_WATER_NE:
533  case WID_GL_WATER_NW:
534  case WID_GL_WATER_SE:
535  case WID_GL_WATER_SW:
536  *size = maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_RANDOM), maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_WATER), GetStringBoundingBox(STR_MAPGEN_BORDER_FREEFORM)));
537  break;
538 
540  size->width = 0;
541  break;
542 
543  default:
544  return;
545  }
546  if (strs != nullptr) {
547  while (*strs != INVALID_STRING_ID) {
548  *size = maxdim(*size, GetStringBoundingBox(*strs++));
549  }
550  }
551  size->width += padding.width;
552  size->height = std::max(size->height, (uint)(FONT_HEIGHT_NORMAL + WD_DROPDOWNTEXT_TOP + WD_DROPDOWNTEXT_BOTTOM));
553  }
554 
555  void DrawWidget(const Rect &r, int widget) const override
556  {
557  switch (widget) {
559  DrawString(r.left, r.right, r.top, this->name, TC_ORANGE);
560  break;
561  }
562  }
563  }
564 
565  void OnClick(Point pt, int widget, int click_count) override
566  {
567  switch (widget) {
568  case WID_GL_TEMPERATE:
569  case WID_GL_ARCTIC:
570  case WID_GL_TROPICAL:
571  case WID_GL_TOYLAND:
573  break;
574 
575  case WID_GL_MAPSIZE_X_PULLDOWN: // Mapsize X
577  break;
578 
579  case WID_GL_MAPSIZE_Y_PULLDOWN: // Mapsize Y
581  break;
582 
583  case WID_GL_TOWN_PULLDOWN: // Number of towns
585  break;
586 
587  case WID_GL_TOWNNAME_DROPDOWN: // Townname generator
589  break;
590 
591  case WID_GL_INDUSTRY_PULLDOWN: // Number of industries
593  break;
594 
595  case WID_GL_GENERATE_BUTTON: { // Generate
596  /* Get rotated map size. */
597  uint map_x;
598  uint map_y;
600  map_x = this->y;
601  map_y = this->x;
602  } else {
603  map_x = this->x;
604  map_y = this->y;
605  }
606  if (mode == GLWM_HEIGHTMAP &&
607  (map_x * 2 < (1U << _settings_newgame.game_creation.map_x) ||
608  map_x / 2 > (1U << _settings_newgame.game_creation.map_x) ||
609  map_y * 2 < (1U << _settings_newgame.game_creation.map_y) ||
610  map_y / 2 > (1U << _settings_newgame.game_creation.map_y))) {
611  ShowQuery(
612  STR_WARNING_HEIGHTMAP_SCALE_CAPTION,
613  STR_WARNING_HEIGHTMAP_SCALE_MESSAGE,
614  this,
615  LandscapeGenerationCallback);
616  } else {
617  StartGeneratingLandscape(mode);
618  }
619  break;
620  }
621 
623  case WID_GL_MAX_HEIGHTLEVEL_UP: // Height level buttons
624  /* Don't allow too fast scrolling */
625  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
626  this->HandleButtonClick(widget);
627 
629  this->InvalidateData();
630  }
631  _left_button_clicked = false;
632  break;
633 
634  case WID_GL_MAX_HEIGHTLEVEL_TEXT: // Height level text
635  this->widget_id = WID_GL_MAX_HEIGHTLEVEL_TEXT;
637  ShowQueryString(STR_JUST_INT, STR_MAPGEN_MAX_HEIGHTLEVEL_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
638  break;
639 
640 
642  case WID_GL_START_DATE_UP: // Year buttons
643  /* Don't allow too fast scrolling */
644  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
645  this->HandleButtonClick(widget);
646 
648  this->InvalidateData();
649  }
650  _left_button_clicked = false;
651  break;
652 
653  case WID_GL_START_DATE_TEXT: // Year text
654  this->widget_id = WID_GL_START_DATE_TEXT;
656  ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
657  break;
658 
660  case WID_GL_SNOW_LEVEL_UP: // Snow line buttons
661  /* Don't allow too fast scrolling */
662  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
663  this->HandleButtonClick(widget);
664 
666  this->InvalidateData();
667  }
668  _left_button_clicked = false;
669  break;
670 
671  case WID_GL_SNOW_LEVEL_TEXT: // Snow line text
672  this->widget_id = WID_GL_SNOW_LEVEL_TEXT;
674  ShowQueryString(STR_JUST_INT, STR_MAPGEN_SNOW_LINE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
675  break;
676 
677  case WID_GL_LANDSCAPE_PULLDOWN: // Landscape generator
679  break;
680 
681  case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: // Heightmap rotation
683  break;
684 
685  case WID_GL_TERRAIN_PULLDOWN: // Terrain type
686  /* For the original map generation only the first four are valid. */
688  break;
689 
690  case WID_GL_WATER_PULLDOWN: { // Water quantity
691  uint32 hidden_mask = 0;
692  /* Disable custom water level when the original map generator is active. */
695  }
697  break;
698  }
699 
700  case WID_GL_RIVER_PULLDOWN: // Amount of rivers
702  break;
703 
704  case WID_GL_SMOOTHNESS_PULLDOWN: // Map smoothness
706  break;
707 
708  case WID_GL_VARIETY_PULLDOWN: // Map variety
710  break;
711 
712  /* Freetype map borders */
713  case WID_GL_WATER_NW:
715  this->InvalidateData();
716  break;
717 
718  case WID_GL_WATER_NE:
720  this->InvalidateData();
721  break;
722 
723  case WID_GL_WATER_SE:
725  this->InvalidateData();
726  break;
727 
728  case WID_GL_WATER_SW:
730  this->InvalidateData();
731  break;
732 
735  this->InvalidateData();
736  break;
737  }
738  }
739 
740  void OnTimeout() override
741  {
743  for (const int *widget = raise_widgets; *widget != WIDGET_LIST_END; widget++) {
744  if (this->IsWidgetLowered(*widget)) {
745  this->RaiseWidget(*widget);
746  this->SetWidgetDirty(*widget);
747  }
748  }
749  }
750 
751  void OnDropdownSelect(int widget, int index) override
752  {
753  switch (widget) {
759 
761  /* If original landgenerator is selected and alpinist terrain_type was selected, revert to mountainous. */
764  }
765  break;
766 
768 
770  if ((uint)index == CUSTOM_TOWN_NUMBER_DIFFICULTY) {
771  this->widget_id = widget;
773  ShowQueryString(STR_JUST_INT, STR_MAPGEN_NUMBER_OF_TOWNS, 5, this, CS_NUMERAL, QSF_NONE);
774  }
776  break;
777 
778  case WID_GL_TOWNNAME_DROPDOWN: // Town names
779  if (_game_mode == GM_MENU || Town::GetNumItems() == 0) {
782  }
783  break;
784 
787 
788  case WID_GL_WATER_PULLDOWN: {
789  if ((uint)index == CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY) {
790  this->widget_id = widget;
792  ShowQueryString(STR_JUST_INT, STR_MAPGEN_QUANTITY_OF_SEA_LAKES, 3, this, CS_NUMERAL, QSF_NONE);
793  }
795  break;
796  }
797  }
798  this->InvalidateData();
799  }
800 
801  void OnQueryTextFinished(char *str) override
802  {
803  /* Was 'cancel' pressed? */
804  if (str == nullptr) return;
805 
806  int32 value;
807  if (!StrEmpty(str)) {
808  value = atoi(str);
809  } else {
810  /* An empty string means revert to the default */
811  switch (this->widget_id) {
813  case WID_GL_START_DATE_TEXT: value = DEF_START_YEAR; break;
814  case WID_GL_SNOW_LEVEL_TEXT: value = DEF_SNOWLINE_HEIGHT; break;
815  case WID_GL_TOWN_PULLDOWN: value = 1; break;
817  default: NOT_REACHED();
818  }
819  }
820 
821  switch (this->widget_id) {
825  break;
826 
830  break;
831 
835  break;
836 
839  break;
840 
843  break;
844  }
845 
846  this->InvalidateData();
847  }
848 };
849 
850 static WindowDesc _generate_landscape_desc(
851  WDP_CENTER, nullptr, 0, 0,
853  0,
855 );
856 
857 static WindowDesc _heightmap_load_desc(
858  WDP_CENTER, nullptr, 0, 0,
860  0,
862 );
863 
864 static void _ShowGenerateLandscape(GenerateLandscapeWindowMode mode)
865 {
866  uint x = 0;
867  uint y = 0;
868 
870 
871  /* Generate a new seed when opening the window */
872  _settings_newgame.game_creation.generation_seed = InteractiveRandom();
873 
874  if (mode == GLWM_HEIGHTMAP) {
875  /* If the function returns negative, it means there was a problem loading the heightmap */
877  }
878 
879  WindowDesc *desc = (mode == GLWM_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc;
880  GenerateLandscapeWindow *w = AllocateWindowDescFront<GenerateLandscapeWindow>(desc, mode, true);
881 
882  if (mode == GLWM_HEIGHTMAP) {
883  w->x = x;
884  w->y = y;
885  strecpy(w->name, _file_to_saveload.title, lastof(w->name));
886  }
887 
889 }
890 
893 {
894  _ShowGenerateLandscape(GLWM_GENERATE);
895 }
896 
899 {
900  _ShowGenerateLandscape(GLWM_HEIGHTMAP);
901 }
902 
905 {
906  StartGeneratingLandscape(GLWM_SCENARIO);
907 }
908 
913 void StartNewGameWithoutGUI(uint32 seed)
914 {
915  /* GenerateWorld takes care of the possible GENERATE_NEW_SEED value in 'seed' */
917 
918  StartGeneratingLandscape(GLWM_GENERATE);
919 }
920 
922 {
923  uint widget_id;
924 
926  {
927  this->InitNested(window_number);
929  }
930 
931  void SetStringParameters(int widget) const override
932  {
933  switch (widget) {
936  break;
937 
940  break;
941 
944  break;
945 
948  break;
949  }
950  }
951 
952  void OnPaint() override
953  {
958 
963 
964  this->DrawWidgets();
965  }
966 
967  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
968  {
969  StringID str = STR_JUST_INT;
970  switch (widget) {
973  str = STR_BLACK_DATE_LONG;
974  break;
975 
979  break;
980 
983  break;
984 
985  default:
986  return;
987  }
988  *size = maxdim(*size, GetStringBoundingBox(str));
989  size->width += padding.width;
990  size->height += padding.height;
991  }
992 
993  void OnClick(Point pt, int widget, int click_count) override
994  {
995  switch (widget) {
996  case WID_CS_TEMPERATE:
997  case WID_CS_ARCTIC:
998  case WID_CS_TROPICAL:
999  case WID_CS_TOYLAND:
1002  break;
1003 
1004  case WID_CS_MAPSIZE_X_PULLDOWN: // Mapsize X
1006  break;
1007 
1008  case WID_CS_MAPSIZE_Y_PULLDOWN: // Mapsize Y
1010  break;
1011 
1012  case WID_CS_EMPTY_WORLD: // Empty world / flat world
1013  StartGeneratingLandscape(GLWM_SCENARIO);
1014  break;
1015 
1016  case WID_CS_RANDOM_WORLD: // Generate
1018  break;
1019 
1021  case WID_CS_START_DATE_UP: // Year buttons
1022  /* Don't allow too fast scrolling */
1023  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
1024  this->HandleButtonClick(widget);
1025  this->SetDirty();
1026 
1028  }
1029  _left_button_clicked = false;
1030  break;
1031 
1032  case WID_CS_START_DATE_TEXT: // Year text
1033  this->widget_id = WID_CS_START_DATE_TEXT;
1035  ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_NONE);
1036  break;
1037 
1039  case WID_CS_FLAT_LAND_HEIGHT_UP: // Height level buttons
1040  /* Don't allow too fast scrolling */
1041  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
1042  this->HandleButtonClick(widget);
1043  this->SetDirty();
1044 
1046  }
1047  _left_button_clicked = false;
1048  break;
1049 
1050  case WID_CS_FLAT_LAND_HEIGHT_TEXT: // Height level text
1051  this->widget_id = WID_CS_FLAT_LAND_HEIGHT_TEXT;
1053  ShowQueryString(STR_JUST_INT, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_NONE);
1054  break;
1055  }
1056  }
1057 
1058  void OnTimeout() override
1059  {
1061  for (const int *widget = raise_widgets; *widget != WIDGET_LIST_END; widget++) {
1062  if (this->IsWidgetLowered(*widget)) {
1063  this->RaiseWidget(*widget);
1064  this->SetWidgetDirty(*widget);
1065  }
1066  }
1067  }
1068 
1069  void OnDropdownSelect(int widget, int index) override
1070  {
1071  switch (widget) {
1074  }
1075  this->SetDirty();
1076  }
1077 
1078  void OnQueryTextFinished(char *str) override
1079  {
1080  if (!StrEmpty(str)) {
1081  int32 value = atoi(str);
1082 
1083  switch (this->widget_id) {
1087  break;
1088 
1092  break;
1093  }
1094 
1095  this->SetDirty();
1096  }
1097  }
1098 };
1099 
1100 static const NWidgetPart _nested_create_scenario_widgets[] = {
1102  NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
1103  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_SE_MAPGEN_CAPTION, STR_NULL),
1104  EndContainer(),
1105  NWidget(WWT_PANEL, COLOUR_BROWN),
1107  /* Landscape style selection. */
1108  NWidget(NWID_HORIZONTAL), SetPIP(10, 3, 10),
1109  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TEMPERATE), SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
1110  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_ARCTIC), SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
1111  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TROPICAL), SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
1112  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TOYLAND), SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
1113  EndContainer(),
1114  NWidget(NWID_HORIZONTAL), SetPIP(10, 8, 10),
1115  /* Green generation type buttons: 'Flat land' and 'Random land'. */
1116  NWidget(NWID_VERTICAL), SetPIP(10, 6, 10),
1117  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_CS_EMPTY_WORLD), SetDataTip(STR_SE_MAPGEN_FLAT_WORLD, STR_SE_MAPGEN_FLAT_WORLD_TOOLTIP), SetFill(1, 1),
1118  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_CS_RANDOM_WORLD), SetDataTip(STR_SE_MAPGEN_RANDOM_LAND, STR_TERRAFORM_TOOLTIP_GENERATE_RANDOM_LAND), SetFill(1, 1),
1119  EndContainer(),
1120  /* Labels + setting drop-downs */
1121  NWidget(NWID_VERTICAL), SetPIP(10, 6, 10),
1122  /* Map size. */
1124  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAPSIZE, STR_NULL), SetPadding(1, 0, 0, 0),
1125  NWidget(NWID_SPACER), SetMinimalSize(6, 0), SetFill(1, 0),
1126  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_CS_MAPSIZE_X_PULLDOWN), SetDataTip(STR_JUST_INT, STR_NULL), SetPadding(0, 4, 0, 0),
1127  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BY, STR_NULL), SetPadding(1, 2, 0, 0),
1128  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_CS_MAPSIZE_Y_PULLDOWN), SetDataTip(STR_JUST_INT, STR_NULL),
1129  EndContainer(),
1130  /* Date. */
1132  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_NULL), SetPadding(1, 0, 0, 0),
1133  NWidget(NWID_SPACER), SetMinimalSize(6, 0), SetFill(1, 0),
1134  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),
1135  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CS_START_DATE_TEXT), SetDataTip(STR_BLACK_DATE_LONG, STR_NULL),
1136  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),
1137  EndContainer(),
1138  /* Flat map height. */
1140  NWidget(WWT_TEXT, COLOUR_ORANGE),
1141  SetDataTip(STR_SE_MAPGEN_FLAT_WORLD_HEIGHT, STR_NULL), SetPadding(1, 0, 0, 0),
1142  NWidget(NWID_SPACER), SetMinimalSize(6, 0), SetFill(1, 0),
1143  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),
1144  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CS_FLAT_LAND_HEIGHT_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL),
1145  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),
1146  EndContainer(),
1147  EndContainer(),
1148  EndContainer(),
1149  EndContainer(),
1150 };
1151 
1152 static WindowDesc _create_scenario_desc(
1153  WDP_CENTER, nullptr, 0, 0,
1155  0,
1156  _nested_create_scenario_widgets, lengthof(_nested_create_scenario_widgets)
1157 );
1158 
1161 {
1163  new CreateScenarioWindow(&_create_scenario_desc, GLWM_SCENARIO);
1164 }
1165 
1166 static const NWidgetPart _nested_generate_progress_widgets[] = {
1167  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GENERATION_WORLD, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1168  NWidget(WWT_PANEL, COLOUR_GREY),
1169  NWidget(NWID_HORIZONTAL), SetPIP(20, 0, 20),
1170  NWidget(NWID_VERTICAL), SetPIP(11, 8, 11),
1171  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GP_PROGRESS_BAR), SetFill(1, 0),
1172  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GP_PROGRESS_TEXT), SetFill(1, 0),
1173  NWidget(WWT_TEXTBTN, COLOUR_WHITE, WID_GP_ABORT), SetDataTip(STR_GENERATION_ABORT, STR_NULL), SetFill(1, 0),
1174  EndContainer(),
1175  EndContainer(),
1176  EndContainer(),
1177 };
1178 
1179 
1180 static WindowDesc _generate_progress_desc(
1181  WDP_CENTER, nullptr, 0, 0,
1183  0,
1184  _nested_generate_progress_widgets, lengthof(_nested_generate_progress_widgets)
1185 );
1186 
1188  uint percent;
1189  StringID cls;
1190  uint current;
1191  uint total;
1192  std::chrono::steady_clock::time_point next_update;
1193 };
1194 
1195 static GenWorldStatus _gws;
1196 
1197 static const StringID _generation_class_table[] = {
1198  STR_GENERATION_WORLD_GENERATION,
1199  STR_SCENEDIT_TOOLBAR_LANDSCAPE_GENERATION,
1200  STR_GENERATION_RIVER_GENERATION,
1201  STR_GENERATION_CLEARING_TILES,
1202  STR_SCENEDIT_TOOLBAR_TOWN_GENERATION,
1203  STR_SCENEDIT_TOOLBAR_INDUSTRY_GENERATION,
1204  STR_GENERATION_OBJECT_GENERATION,
1205  STR_GENERATION_TREE_GENERATION,
1206  STR_GENERATION_SETTINGUP_GAME,
1207  STR_GENERATION_PREPARING_TILELOOP,
1208  STR_GENERATION_PREPARING_SCRIPT,
1209  STR_GENERATION_PREPARING_GAME
1210 };
1211 static_assert(lengthof(_generation_class_table) == GWP_CLASS_COUNT);
1212 
1213 
1214 static void AbortGeneratingWorldCallback(Window *w, bool confirmed)
1215 {
1216  if (confirmed) {
1218  } else if (HasModalProgress() && !IsGeneratingWorldAborted()) {
1219  SetMouseCursor(SPR_CURSOR_ZZZ, PAL_NONE);
1220  }
1221 }
1222 
1224 
1225  GenerateProgressWindow() : Window(&_generate_progress_desc)
1226  {
1227  this->InitNested();
1228  }
1229 
1230  void OnClick(Point pt, int widget, int click_count) override
1231  {
1232  switch (widget) {
1233  case WID_GP_ABORT:
1234  SetMouseCursorBusy(false);
1235  ShowQuery(
1236  STR_GENERATION_ABORT_CAPTION,
1237  STR_GENERATION_ABORT_MESSAGE,
1238  this,
1239  AbortGeneratingWorldCallback
1240  );
1241  break;
1242  }
1243  }
1244 
1245  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1246  {
1247  switch (widget) {
1248  case WID_GP_PROGRESS_BAR: {
1249  SetDParamMaxValue(0, 100);
1250  *size = GetStringBoundingBox(STR_GENERATION_PROGRESS);
1251  /* We need some spacing for the 'border' */
1252  size->height += 8;
1253  size->width += 8;
1254  break;
1255  }
1256 
1257  case WID_GP_PROGRESS_TEXT:
1258  for (uint i = 0; i < GWP_CLASS_COUNT; i++) {
1259  size->width = std::max(size->width, GetStringBoundingBox(_generation_class_table[i]).width);
1260  }
1261  size->height = FONT_HEIGHT_NORMAL * 2 + WD_PAR_VSEP_NORMAL;
1262  break;
1263  }
1264  }
1265 
1266  void DrawWidget(const Rect &r, int widget) const override
1267  {
1268  switch (widget) {
1269  case WID_GP_PROGRESS_BAR:
1270  /* Draw the % complete with a bar and a text */
1271  DrawFrameRect(r.left, r.top, r.right, r.bottom, COLOUR_GREY, FR_BORDERONLY);
1272  DrawFrameRect(r.left + 1, r.top + 1, (int)((r.right - r.left - 2) * _gws.percent / 100) + r.left + 1, r.bottom - 1, COLOUR_MAUVE, FR_NONE);
1273  SetDParam(0, _gws.percent);
1274  DrawString(r.left, r.right, r.top + 5, STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
1275  break;
1276 
1277  case WID_GP_PROGRESS_TEXT:
1278  /* Tell which class we are generating */
1279  DrawString(r.left, r.right, r.top, _gws.cls, TC_FROMSTRING, SA_HOR_CENTER);
1280 
1281  /* And say where we are in that class */
1282  SetDParam(0, _gws.current);
1283  SetDParam(1, _gws.total);
1284  DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL, STR_GENERATION_PROGRESS_NUM, TC_FROMSTRING, SA_HOR_CENTER);
1285  }
1286  }
1287 };
1288 
1293 {
1294  _gws.cls = STR_GENERATION_WORLD_GENERATION;
1295  _gws.current = 0;
1296  _gws.total = 0;
1297  _gws.percent = 0;
1298  _gws.next_update = std::chrono::steady_clock::now();
1299 }
1300 
1305 {
1306  if (BringWindowToFrontById(WC_MODAL_PROGRESS, 0)) return;
1307  new GenerateProgressWindow();
1308 }
1309 
1310 static void _SetGeneratingWorldProgress(GenWorldProgress cls, uint progress, uint total)
1311 {
1312  static const int percent_table[] = {0, 5, 14, 17, 20, 40, 60, 65, 80, 85, 95, 99, 100 };
1313  static_assert(lengthof(percent_table) == GWP_CLASS_COUNT + 1);
1314  assert(cls < GWP_CLASS_COUNT);
1315 
1316  if (IsGeneratingWorldAborted()) {
1318  return;
1319  }
1320 
1321  if (total == 0) {
1322  assert(_gws.cls == _generation_class_table[cls]);
1323  _gws.current += progress;
1324  assert(_gws.current <= _gws.total);
1325  } else {
1326  _gws.cls = _generation_class_table[cls];
1327  _gws.current = progress;
1328  _gws.total = total;
1329  _gws.percent = percent_table[cls];
1330  }
1331 
1332  /* Percentage is about the number of completed tasks, so 'current - 1' */
1333  _gws.percent = percent_table[cls] + (percent_table[cls + 1] - percent_table[cls]) * (_gws.current == 0 ? 0 : _gws.current - 1) / _gws.total;
1334 
1335  if (_network_dedicated) {
1336  static uint last_percent = 0;
1337 
1338  /* Never display 0% */
1339  if (_gws.percent == 0) return;
1340  /* Reset if percent is lower than the last recorded */
1341  if (_gws.percent < last_percent) last_percent = 0;
1342  /* Display every 5%, but 6% is also very valid.. just not smaller steps than 5% */
1343  if (_gws.percent % 5 != 0 && _gws.percent <= last_percent + 5) return;
1344  /* Never show steps smaller than 2%, even if it is a mod 5% */
1345  if (_gws.percent <= last_percent + 2) return;
1346 
1347  DEBUG(net, 1, "Map generation percentage complete: %d", _gws.percent);
1348  last_percent = _gws.percent;
1349 
1350  return;
1351  }
1352 
1354 
1356 }
1357 
1367 {
1368  if (total == 0) return;
1369 
1370  _SetGeneratingWorldProgress(cls, 0, total);
1371 }
1372 
1381 {
1382  /* In fact the param 'class' isn't needed.. but for some security reasons, we want it around */
1383  _SetGeneratingWorldProgress(cls, 1, 0);
1384 }
MIN_MAX_HEIGHTLEVEL
static const uint MIN_MAX_HEIGHTLEVEL
Lower bound of maximum allowed heightlevel (in the construction settings)
Definition: tile_type.h:24
FileToSaveLoad::title
char title[255]
Internal name of the game.
Definition: saveload.h:344
SetMouseCursorBusy
void SetMouseCursorBusy(bool busy)
Set or unset the ZZZ cursor.
Definition: gfx.cpp:1738
sound_func.h
GameCreationSettings::generation_seed
uint32 generation_seed
noise seed for world generation
Definition: settings_type.h:292
DEF_MAX_HEIGHTLEVEL
static const uint DEF_MAX_HEIGHTLEVEL
Default maximum allowed heightlevel (in the construction settings)
Definition: tile_type.h:25
WWT_IMGBTN_2
@ WWT_IMGBTN_2
(Toggle) Button with diff image when clicked
Definition: widget_type.h:51
GenerateProgressWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: genworld_gui.cpp:1266
SetNewLandscapeType
void SetNewLandscapeType(byte landscape)
Changes landscape type and sets genworld window dirty.
Definition: genworld_gui.cpp:52
Window::timeout_timer
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
Definition: window_gui.h:314
MIN_SNOWLINE_HEIGHT
static const uint MIN_SNOWLINE_HEIGHT
Minimum snowline height.
Definition: tile_type.h:28
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3220
querystring_gui.h
DropDownListParamStringItem
String list item with parameters.
Definition: dropdown_type.h:56
SM_START_HEIGHTMAP
@ SM_START_HEIGHTMAP
Load a heightmap and start a new game from it.
Definition: openttd.h:36
GenerateProgressWindow
Definition: genworld_gui.cpp:1223
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
GameCreationSettings::custom_sea_level
byte custom_sea_level
manually entered percentage of water in the map
Definition: settings_type.h:309
ShowCreateScenario
void ShowCreateScenario()
Show the window to create a scenario.
Definition: genworld_gui.cpp:1160
AbortGeneratingWorld
void AbortGeneratingWorld()
Initializes the abortion process.
Definition: genworld.cpp:235
SetPadding
static NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1045
ConstructionSettings::max_heightlevel
uint8 max_heightlevel
maximum allowed heightlevel
Definition: settings_type.h:317
GameCreationSettings::map_y
uint8 map_y
Y size of map.
Definition: settings_type.h:296
dropdown_func.h
GameCreationSettings::landscape
byte landscape
the landscape we're currently in
Definition: settings_type.h:305
GameCreationSettings::tgen_smoothness
byte tgen_smoothness
how rough is the terrain from 0-3
Definition: settings_type.h:300
WID_GP_PROGRESS_BAR
@ WID_GP_PROGRESS_BAR
Progress bar.
Definition: genworld_widget.h:80
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:46
WID_CS_TOYLAND
@ WID_CS_TOYLAND
Select toy-land landscape style.
Definition: genworld_widget.h:65
GenerateLandscapeWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: genworld_gui.cpp:751
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
WC_SELECT_GAME
@ WC_SELECT_GAME
Select game window; Window numbers:
Definition: window_type.h:435
WID_GL_TEMPERATE
@ WID_GL_TEMPERATE
Button with icon "Temperate".
Definition: genworld_widget.h:15
HM_CLOCKWISE
@ HM_CLOCKWISE
Rotate the map clockwise 45 degrees.
Definition: heightmap.h:21
SM_EDITOR
@ SM_EDITOR
Switch to scenario editor.
Definition: openttd.h:29
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:50
WID_CS_START_DATE_TEXT
@ WID_CS_START_DATE_TEXT
Clickable start date value.
Definition: genworld_widget.h:71
MIN_MAP_SIZE_BITS
static const uint MIN_MAP_SIZE_BITS
Minimal and maximal map width and height.
Definition: map_type.h:63
FileToSaveLoad::name
std::string name
Name of the file.
Definition: saveload.h:343
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:100
WID_GL_WATER_SE
@ WID_GL_WATER_SE
SE 'Water'/'Freeform'.
Definition: genworld_widget.h:56
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
WID_CS_FLAT_LAND_HEIGHT_DOWN
@ WID_CS_FLAT_LAND_HEIGHT_DOWN
Decrease flat land height.
Definition: genworld_widget.h:73
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
GameSettings::difficulty
DifficultySettings difficulty
settings related to the difficulty
Definition: settings_type.h:559
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
GameCreationSettings::variety
byte variety
variety level applied to TGP
Definition: settings_type.h:308
WID_GL_SNOW_LEVEL_TEXT
@ WID_GL_SNOW_LEVEL_TEXT
Snow level.
Definition: genworld_widget.h:38
WID_GL_HEIGHTMAP_SIZE_TEXT
@ WID_GL_HEIGHTMAP_SIZE_TEXT
Size of heightmap.
Definition: genworld_widget.h:44
GenerateProgressWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: genworld_gui.cpp:1230
SND_15_BEEP
@ SND_15_BEEP
19 == 0x13 GUI button click
Definition: sound_type.h:58
saveload.h
GameCreationSettings::town_name
byte town_name
the town name generator used for town names
Definition: settings_type.h:304
WID_GL_HEIGHTMAP_ROTATION_PULLDOWN
@ WID_GL_HEIGHTMAP_ROTATION_PULLDOWN
Dropdown 'Heightmap rotation'.
Definition: genworld_widget.h:45
WC_GENERATE_LANDSCAPE
@ WC_GENERATE_LANDSCAPE
Generate landscape (newgame); Window numbers:
Definition: window_type.h:449
DropDownListItem
Base list item class from which others are derived.
Definition: dropdown_type.h:22
newgrf_townname.h
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:79
DrawString
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:640
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
DeleteWindowByClass
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
Definition: window.cpp:1178
town.h
WID_GL_WATER_PULLDOWN
@ WID_GL_WATER_PULLDOWN
Dropdown 'Sea level'.
Definition: genworld_widget.h:48
CreateScenarioWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: genworld_gui.cpp:993
DEF_SNOWLINE_HEIGHT
static const uint DEF_SNOWLINE_HEIGHT
Default snowline height.
Definition: tile_type.h:29
WindowNumber
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:711
MAX_TILE_HEIGHT
static const uint MAX_TILE_HEIGHT
Maximum allowed tile height.
Definition: tile_type.h:22
MAX_MAX_HEIGHTLEVEL
static const uint MAX_MAX_HEIGHTLEVEL
Upper bound of maximum allowed heightlevel (in the construction settings)
Definition: tile_type.h:26
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_func.h:97
Window::HandleButtonClick
void HandleButtonClick(byte widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
Definition: window.cpp:635
fios.h
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1871
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:199
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:909
WID_GL_TROPICAL
@ WID_GL_TROPICAL
Button with icon "Tropical".
Definition: genworld_widget.h:17
genworld.h
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1013
WID_GL_START_DATE_UP
@ WID_GL_START_DATE_UP
Increase start year.
Definition: genworld_widget.h:35
WID_GL_TOYLAND
@ WID_GL_TOYLAND
Button with icon "Toyland".
Definition: genworld_widget.h:18
townname_type.h
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:842
CreateScenarioWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: genworld_gui.cpp:967
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:560
_nested_heightmap_load_widgets
static const NWidgetPart _nested_heightmap_load_widgets[]
Widgets of GenerateLandscapeWindow when loading heightmap.
Definition: genworld_gui.cpp:178
WN_GAME_OPTIONS_GAME_OPTIONS
@ WN_GAME_OPTIONS_GAME_OPTIONS
Game options.
Definition: window_type.h:18
WindowDesc
High level window description.
Definition: window_gui.h:166
WC_MODAL_PROGRESS
@ WC_MODAL_PROGRESS
Progress report of landscape generation; Window numbers:
Definition: window_type.h:456
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:428
WID_GL_GENERATE_BUTTON
@ WID_GL_GENERATE_BUTTON
'Generate' button.
Definition: genworld_widget.h:27
PrepareGenerateWorldProgress
void PrepareGenerateWorldProgress()
Initializes the progress counters to the starting point.
Definition: genworld_gui.cpp:1292
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:330
WID_GL_BORDERS_RANDOM
@ WID_GL_BORDERS_RANDOM
'Random'/'Manual' borders.
Definition: genworld_widget.h:53
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:322
WID_GL_SMOOTHNESS_PULLDOWN
@ WID_GL_SMOOTHNESS_PULLDOWN
Dropdown 'Smoothness'.
Definition: genworld_widget.h:50
GenerateLandscapeWindowMode
GenerateLandscapeWindowMode
Enum for the modes we can generate in.
Definition: genworld_gui.cpp:42
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:580
SetMouseCursor
void SetMouseCursor(CursorID sprite, PaletteID pal)
Assign a single non-animated sprite to the cursor.
Definition: gfx.cpp:1753
ShowGenerateLandscape
void ShowGenerateLandscape()
Start with a normal game.
Definition: genworld_gui.cpp:892
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1861
SM_NEWGAME
@ SM_NEWGAME
New Game --> 'Random game'.
Definition: openttd.h:26
MIN_YEAR
static const Year MIN_YEAR
The absolute minimum & maximum years in OTTD.
Definition: date_type.h:83
DifficultySettings::terrain_type
byte terrain_type
the mountainousness of the landscape
Definition: settings_type.h:74
DEBUG
#define DEBUG(name, level,...)
Output a line of debugging information.
Definition: debug.h:35
GameCreationSettings::custom_town_number
uint16 custom_town_number
manually entered number of towns
Definition: settings_type.h:307
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:984
WID_GP_PROGRESS_TEXT
@ WID_GP_PROGRESS_TEXT
Text with the progress bar.
Definition: genworld_widget.h:81
ConvertYMDToDate
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition: date.cpp:149
WID_GL_MAPSIZE_Y_PULLDOWN
@ WID_GL_MAPSIZE_Y_PULLDOWN
Dropdown 'map Y size'.
Definition: genworld_widget.h:21
WD_PAR_VSEP_NORMAL
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
Definition: window_gui.h:137
GameCreationSettings::water_borders
byte water_borders
bitset of the borders that are water
Definition: settings_type.h:306
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:102
ShowDropDownList
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
Definition: dropdown.cpp:453
WID_CS_TROPICAL
@ WID_CS_TROPICAL
Select tropical landscape style.
Definition: genworld_widget.h:64
WID_GL_TOWN_PULLDOWN
@ WID_GL_TOWN_PULLDOWN
Dropdown 'No. of towns'.
Definition: genworld_widget.h:23
dropdown_type.h
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:80
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:47
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:392
DropDownListStringItem
Common string list item.
Definition: dropdown_type.h:39
GameCreationSettings::snow_line_height
byte snow_line_height
the configured snow line height
Definition: settings_type.h:299
safeguards.h
GenerateLandscapeWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: genworld_gui.cpp:740
WID_GL_START_DATE_TEXT
@ WID_GL_START_DATE_TEXT
Start year.
Definition: genworld_widget.h:34
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:1131
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:310
WID_GL_TERRAIN_PULLDOWN
@ WID_GL_TERRAIN_PULLDOWN
Dropdown 'Terrain type'.
Definition: genworld_widget.h:47
ConstructionSettings::freeform_edges
bool freeform_edges
allow terraforming the tiles at the map edges
Definition: settings_type.h:329
WF_TIMEOUT
@ WF_TIMEOUT
Window timeout counter.
Definition: window_gui.h:232
CreateScenarioWindow
Definition: genworld_gui.cpp:921
StrEmpty
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:60
DifficultySettings::quantity_sea_lakes
byte quantity_sea_lakes
the amount of seas/lakes
Definition: settings_type.h:75
DifficultySettings::industry_density
byte industry_density
The industry density.
Definition: settings_type.h:66
GameCreationSettings::se_flat_world_height
byte se_flat_world_height
land height a flat world gets in SE
Definition: settings_type.h:303
GenWorldStatus
Definition: genworld_gui.cpp:1187
GLWM_SCENARIO
@ GLWM_SCENARIO
Generate flat land.
Definition: genworld_gui.cpp:45
WID_CS_TEMPERATE
@ WID_CS_TEMPERATE
Select temperate landscape style.
Definition: genworld_widget.h:62
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
error.h
ShowDropDownMenu
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width)
Show a dropdown menu window near a widget of the parent window.
Definition: dropdown.cpp:494
_network_dedicated
bool _network_dedicated
are we a dedicated server?
Definition: network.cpp:55
date_func.h
stdafx.h
SM_GENRANDLAND
@ SM_GENRANDLAND
Generate random land within scenario editor.
Definition: openttd.h:34
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:312
IncreaseGeneratingWorldProgress
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
Definition: genworld_gui.cpp:1380
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:3261
VideoDriver::GetInstance
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Definition: video_driver.hpp:187
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
BUILTIN_TOWNNAME_GENERATOR_COUNT
static constexpr uint BUILTIN_TOWNNAME_GENERATOR_COUNT
Number of built-in town name generators.
Definition: townname_type.h:24
ShowHeightmapLoad
void ShowHeightmapLoad()
Start with loading a heightmap.
Definition: genworld_gui.cpp:898
GetHeightmapDimensions
bool GetHeightmapDimensions(DetailedFileType dft, const char *filename, uint *x, uint *y)
Get the dimensions of a heightmap.
Definition: heightmap.cpp:477
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
StartNewGameWithoutGUI
void StartNewGameWithoutGUI(uint32 seed)
Start a normal game without the GUI.
Definition: genworld_gui.cpp:913
GenerateProgressWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: genworld_gui.cpp:1245
SM_LOAD_HEIGHTMAP
@ SM_LOAD_HEIGHTMAP
Load heightmap from scenario editor.
Definition: openttd.h:37
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
GenWorldProgress
GenWorldProgress
Current stage of world generation process.
Definition: genworld.h:64
VideoDriver::GameLoopPause
void GameLoopPause()
Pause the game-loop for a bit, releasing the game-state lock.
Definition: video_driver.cpp:63
WID_GL_INDUSTRY_PULLDOWN
@ WID_GL_INDUSTRY_PULLDOWN
Dropdown 'No. of industries'.
Definition: genworld_widget.h:25
WD_DROPDOWNTEXT_TOP
@ WD_DROPDOWNTEXT_TOP
Top offset of the dropdown widget string.
Definition: window_gui.h:134
string_func.h
WID_GL_MAX_HEIGHTLEVEL_DOWN
@ WID_GL_MAX_HEIGHTLEVEL_DOWN
Decrease max. heightlevel.
Definition: genworld_widget.h:29
_switch_mode
SwitchMode _switch_mode
The next mainloop command.
Definition: gfx.cpp:46
GLWM_HEIGHTMAP
@ GLWM_HEIGHTMAP
Load from heightmap.
Definition: genworld_gui.cpp:44
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
GenerateLandscapeWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: genworld_gui.cpp:478
ShowQuery
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback)
Show a modal confirmation window with standard 'yes' and 'no' buttons The window is aligned to the ce...
Definition: misc_gui.cpp:1274
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:197
GameCreationSettings::heightmap_rotation
byte heightmap_rotation
rotation director for the heightmap
Definition: settings_type.h:302
WC_GAME_OPTIONS
@ WC_GAME_OPTIONS
Game options window; Window numbers:
Definition: window_type.h:606
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:998
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:77
WID_GL_SNOW_LEVEL_DOWN
@ WID_GL_SNOW_LEVEL_DOWN
Decrease snow level.
Definition: genworld_widget.h:37
strings_func.h
WID_GL_START_DATE_DOWN
@ WID_GL_START_DATE_DOWN
Decrease start year.
Definition: genworld_widget.h:33
WID_CS_MAPSIZE_Y_PULLDOWN
@ WID_CS_MAPSIZE_Y_PULLDOWN
Pull-down arrow for y map size.
Definition: genworld_widget.h:69
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:64
Pool::PoolItem<&_town_pool >::GetNumItems
static size_t GetNumItems()
Returns number of valid items in the pool.
Definition: pool_type.hpp:359
ShowGenerateWorldProgress
void ShowGenerateWorldProgress()
Show the window where a user can follow the process of the map generation.
Definition: genworld_gui.cpp:1304
GenerateLandscapeWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: genworld_gui.cpp:362
HandleGeneratingWorldAbortion
void HandleGeneratingWorldAbortion()
Really handle the abortion, i.e.
Definition: genworld.cpp:252
WIDGET_LIST_END
static const int WIDGET_LIST_END
indicate the end of widgets' list for vararg functions
Definition: widget_type.h:20
GameCreationSettings::map_x
uint8 map_x
X size of map.
Definition: settings_type.h:295
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:56
GameCreationSettings::amount_of_rivers
byte amount_of_rivers
the amount of rivers
Definition: settings_type.h:312
MAX_SNOWLINE_HEIGHT
static const uint MAX_SNOWLINE_HEIGHT
Maximum allowed snowline height.
Definition: tile_type.h:30
GameCreationSettings::land_generator
byte land_generator
the landscape generator
Definition: settings_type.h:297
DeleteAllNonVitalWindows
void DeleteAllNonVitalWindows()
It is possible that a stickied window gets to a position where the 'close' button is outside the gami...
Definition: window.cpp:3396
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:179
video_driver.hpp
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1113
geometry_func.hpp
CreateScenarioWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: genworld_gui.cpp:1058
WID_GL_ARCTIC
@ WID_GL_ARCTIC
Button with icon "Arctic".
Definition: genworld_widget.h:16
SetDParamMaxValue
void SetDParamMaxValue(uint n, uint64 max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
Definition: strings.cpp:104
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:3339
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:946
_file_to_saveload
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
Definition: saveload.cpp:62
WID_GL_MAX_HEIGHTLEVEL_TEXT
@ WID_GL_MAX_HEIGHTLEVEL_TEXT
Max. heightlevel.
Definition: genworld_widget.h:30
GenerateLandscapeWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: genworld_gui.cpp:555
GenerateLandscapeWindow
Definition: genworld_gui.cpp:339
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
Window::SetWidgetsDisabledState
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
Definition: window.cpp:536
WID_GL_HEIGHTMAP_NAME_TEXT
@ WID_GL_HEIGHTMAP_NAME_TEXT
Heightmap name.
Definition: genworld_widget.h:43
GenerateLandscapeWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: genworld_gui.cpp:565
Window::IsWidgetLowered
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:493
CreateScenarioWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: genworld_gui.cpp:1078
GLWM_GENERATE
@ GLWM_GENERATE
Generate new game.
Definition: genworld_gui.cpp:43
progress.h
WID_GL_WATER_NW
@ WID_GL_WATER_NW
NW 'Water'/'Freeform'.
Definition: genworld_widget.h:54
WID_GL_SNOW_LEVEL_UP
@ WID_GL_SNOW_LEVEL_UP
Increase snow level.
Definition: genworld_widget.h:39
GameCreationSettings::starting_year
Year starting_year
starting date
Definition: settings_type.h:293
WID_CS_EMPTY_WORLD
@ WID_CS_EMPTY_WORLD
Generate an empty flat world.
Definition: genworld_widget.h:66
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
WID_GL_MAPSIZE_X_PULLDOWN
@ WID_GL_MAPSIZE_X_PULLDOWN
Dropdown 'map X size'.
Definition: genworld_widget.h:20
WID_GL_VARIETY_PULLDOWN
@ WID_GL_VARIETY_PULLDOWN
Dropdown 'Variety distribution'.
Definition: genworld_widget.h:51
WID_GP_ABORT
@ WID_GP_ABORT
Abort button.
Definition: genworld_widget.h:82
DEF_START_YEAR
static const Year DEF_START_YEAR
The default starting year.
Definition: date_type.h:86
WID_GL_TOWNNAME_DROPDOWN
@ WID_GL_TOWNNAME_DROPDOWN
Dropdown 'Townnames'.
Definition: genworld_widget.h:24
WID_GL_LANDSCAPE_PULLDOWN
@ WID_GL_LANDSCAPE_PULLDOWN
Dropdown 'Land generator'.
Definition: genworld_widget.h:41
DrawFrameRect
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition: widget.cpp:175
WID_CS_MAPSIZE_X_PULLDOWN
@ WID_CS_MAPSIZE_X_PULLDOWN
Pull-down arrow for x map size.
Definition: genworld_widget.h:68
network.h
window_func.h
ToggleBit
static T ToggleBit(T &x, const uint8 y)
Toggles a bit in a variable.
Definition: bitmath_func.hpp:181
SetBit
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
Definition: bitmath_func.hpp:121
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:367
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:319
random_func.hpp
WID_GL_MAX_HEIGHTLEVEL_UP
@ WID_GL_MAX_HEIGHTLEVEL_UP
Increase max. heightlevel.
Definition: genworld_widget.h:31
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1075
IsGeneratingWorldAborted
bool IsGeneratingWorldAborted()
Is the generation being aborted?
Definition: genworld.cpp:244
_nested_generate_landscape_widgets
static const NWidgetPart _nested_generate_landscape_widgets[]
Widgets of GenerateLandscapeWindow when generating world.
Definition: genworld_gui.cpp:60
StartScenarioEditor
void StartScenarioEditor()
Start with a scenario editor.
Definition: genworld_gui.cpp:904
WID_GL_WATER_SW
@ WID_GL_WATER_SW
SW 'Water'/'Freeform'.
Definition: genworld_widget.h:57
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:982
ID_END
@ ID_END
Number of industry density settings.
Definition: settings_type.h:59
SetGeneratingWorldProgress
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
Definition: genworld_gui.cpp:1366
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition: settings_type.h:561
WD_DROPDOWNTEXT_BOTTOM
@ WD_DROPDOWNTEXT_BOTTOM
Bottom offset of the dropdown widget string.
Definition: window_gui.h:135
WID_CS_FLAT_LAND_HEIGHT_TEXT
@ WID_CS_FLAT_LAND_HEIGHT_TEXT
Clickable flat land height value.
Definition: genworld_widget.h:74
Window
Data structure for an opened window.
Definition: window_gui.h:276
FileToSaveLoad::detail_ftype
DetailedFileType detail_ftype
Concrete file type (PNG, BMP, old save, etc).
Definition: saveload.h:341
ResetGRFConfig
void ResetGRFConfig(bool defaults)
Reset the current GRF Config to either blank or newgame settings.
Definition: newgrf_config.cpp:496
Window::RaiseWidget
void RaiseWidget(byte widget_index)
Marks a widget as raised.
Definition: window_gui.h:483
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:602
HasModalProgress
static bool HasModalProgress()
Check if we are currently in a modal progress state.
Definition: progress.h:17
MAX_MAP_SIZE
static const uint MAX_MAP_SIZE
Maximal map size = 4096.
Definition: map_type.h:66
WID_CS_START_DATE_UP
@ WID_CS_START_DATE_UP
Increase start year (start later).
Definition: genworld_widget.h:72
strecpy
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
Definition: string.cpp:112
WID_CS_ARCTIC
@ WID_CS_ARCTIC
Select arctic landscape style.
Definition: genworld_widget.h:63
CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY
static const uint CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY
Value for custom sea level in difficulty settings.
Definition: genworld.h:45
Window::SetWidgetDirty
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:597
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47
Window::LowerWidget
void LowerWidget(byte widget_index)
Marks a widget as lowered.
Definition: window_gui.h:474
BringWindowToFrontById
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
Definition: window.cpp:1262
WID_CS_START_DATE_DOWN
@ WID_CS_START_DATE_DOWN
Decrease start year (start earlier).
Definition: genworld_widget.h:70
DifficultySettings::number_towns
byte number_towns
the amount of towns
Definition: settings_type.h:65
WID_GL_RIVER_PULLDOWN
@ WID_GL_RIVER_PULLDOWN
Dropdown 'Rivers'.
Definition: genworld_widget.h:49
WID_CS_RANDOM_WORLD
@ WID_CS_RANDOM_WORLD
Generate random land button.
Definition: genworld_widget.h:67
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:952
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:383
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition: window_gui.h:155
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:453
GenerateLandscapeWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: genworld_gui.cpp:801
_left_button_clicked
bool _left_button_clicked
Is left mouse button clicked?
Definition: gfx.cpp:39
CS_NUMERAL
@ CS_NUMERAL
Only numeric ones.
Definition: string_type.h:28
CreateScenarioWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: genworld_gui.cpp:931
CreateScenarioWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: genworld_gui.cpp:1069
CUSTOM_TOWN_NUMBER_DIFFICULTY
static const uint CUSTOM_TOWN_NUMBER_DIFFICULTY
value for custom town number in difficulty settings
Definition: town.h:26
WID_GL_WATER_NE
@ WID_GL_WATER_NE
NE 'Water'/'Freeform'.
Definition: genworld_widget.h:55
genworld_widget.h
_settings_newgame
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Definition: settings.cpp:81
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:53
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
GenerateLandscapeWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: genworld_gui.cpp:431
debug.h
FR_BORDERONLY
@ FR_BORDERONLY
Draw border only, no background.
Definition: window_gui.h:28
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:68
WID_CS_FLAT_LAND_HEIGHT_UP
@ WID_CS_FLAT_LAND_HEIGHT_UP
Increase flat land height.
Definition: genworld_widget.h:75
MAX_YEAR
static const Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date,...
Definition: date_type.h:94
DropDownListStringItem::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.cpp:52