OpenTTD Source  12.0-beta2
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 
51 static uint GetMapHeightLimit()
52 {
55 }
56 
61 void SetNewLandscapeType(byte landscape)
62 {
66 }
67 
71  NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
72  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_MAPGEN_WORLD_GENERATION_CAPTION, STR_NULL),
73  EndContainer(),
74  NWidget(WWT_PANEL, COLOUR_BROWN),
76  /* Landscape selection. */
77  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 10),
78  NWidget(NWID_SPACER), SetFill(1, 0),
79  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TEMPERATE), SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
80  NWidget(NWID_SPACER), SetFill(1, 0),
81  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_ARCTIC), SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
82  NWidget(NWID_SPACER), SetFill(1, 0),
83  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TROPICAL), SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
84  NWidget(NWID_SPACER), SetFill(1, 0),
85  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TOYLAND), SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
86  NWidget(NWID_SPACER), SetFill(1, 0),
87  EndContainer(),
89  NWidget(NWID_HORIZONTAL), SetPIP(10, 5, 10),
90  NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0),
91  /* Left column with labels. */
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_LAND_GENERATOR, STR_NULL), SetFill(1, 1),
95  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_TERRAIN_TYPE, STR_NULL), SetFill(1, 1),
96  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_VARIETY, STR_NULL), SetFill(1, 1),
97  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_QUANTITY_OF_SEA_LAKES, STR_NULL), SetFill(1, 1),
98  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_TOWNS, STR_NULL), SetFill(1, 1),
99  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES, STR_NULL), SetFill(1, 1),
100  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BORDER_TYPE, STR_NULL), SetFill(1, 1),
101  EndContainer(),
102  /* Widgets at the right of the labels. */
104  /* Mapsize X * Y. */
105  NWidget(NWID_HORIZONTAL), SetPIP(0, 4, 0),
106  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_X_PULLDOWN), SetDataTip(STR_JUST_INT, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 0),
107  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BY, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(1, 1),
108  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_Y_PULLDOWN), SetDataTip(STR_JUST_INT, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 0),
109  EndContainer(),
110  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_LANDSCAPE_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
111  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TERRAIN_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
112  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_VARIETY_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
113  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_WATER_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
114  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWN_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
115  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_INDUSTRY_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
116  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_BORDERS_RANDOM), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
117  EndContainer(),
118  EndContainer(),
119  NWidget(NWID_VERTICAL), SetPIP(0, 4, 0),
120  NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0),
123  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SNOW_COVERAGE, STR_NULL), SetFill(1, 1),
124  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DESERT_COVERAGE, STR_NULL), SetFill(1, 1),
125  EndContainer(),
126  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_NULL), SetFill(1, 1),
127  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SMOOTHNESS, STR_NULL), SetFill(1, 1),
128  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_NULL), SetFill(1, 1),
129  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_GAME_OPTIONS_TOWN_NAMES_FRAME, STR_NULL), SetFill(1, 1),
130  EndContainer(),
133  /* Snow coverage. */
135  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_COVERAGE_DOWN), SetFill(0, 1),
136  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_TEXT), SetDataTip(STR_MAPGEN_SNOW_COVERAGE_TEXT, STR_NULL), SetFill(1, 0),
137  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_COVERAGE_UP), SetFill(0, 1),
138  EndContainer(),
139  /* Desert coverage. */
141  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_DESERT_COVERAGE_DOWN), SetFill(0, 1),
142  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_TEXT), SetDataTip(STR_MAPGEN_DESERT_COVERAGE_TEXT, STR_NULL), SetFill(1, 0),
143  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_DESERT_COVERAGE_UP), SetFill(0, 1),
144  EndContainer(),
145  EndContainer(),
146  /* Starting date. */
148  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),
149  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetDataTip(STR_BLACK_DATE_LONG, STR_NULL), SetFill(1, 0),
150  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),
151  EndContainer(),
152  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_SMOOTHNESS_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
153  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_RIVER_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
154  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWNNAME_DROPDOWN), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_TOWN_NAMES_DROPDOWN_TOOLTIP), SetFill(1, 0),
155  EndContainer(),
156  EndContainer(),
157  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_GL_GENERATE_BUTTON), SetMinimalSize(84, 0), SetDataTip(STR_MAPGEN_GENERATE, STR_NULL), SetFill(1, 1),
158  EndContainer(),
159  EndContainer(),
161  /* Map borders buttons for each edge. */
163  NWidget(NWID_HORIZONTAL), SetPIP(0, 0, 3),
164  NWidget(NWID_SPACER), SetFill(1, 1),
165  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NORTHWEST, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(0, 1),
166  EndContainer(),
167  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_NW), SetDataTip(STR_JUST_STRING, STR_MAPGEN_NORTHWEST), SetFill(1, 1),
168  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_NE), SetDataTip(STR_JUST_STRING, STR_MAPGEN_NORTHEAST), SetFill(1, 1),
169  NWidget(NWID_HORIZONTAL), SetPIP(3, 0, 0),
170  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NORTHEAST, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(0, 1),
171  NWidget(NWID_SPACER), SetFill(1, 1),
172  EndContainer(),
173  EndContainer(),
175  NWidget(NWID_HORIZONTAL), SetPIP(0, 0, 3),
176  NWidget(NWID_SPACER), SetFill(1, 1),
177  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SOUTHWEST, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(0, 1),
178  EndContainer(),
179  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_SW), SetDataTip(STR_JUST_STRING, STR_MAPGEN_SOUTHWEST), SetFill(1, 1),
180  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_SE), SetDataTip(STR_JUST_STRING, STR_MAPGEN_SOUTHEAST), SetFill(1, 1),
181  NWidget(NWID_HORIZONTAL), SetPIP(3, 0, 0),
182  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SOUTHEAST, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(0, 1),
183  NWidget(NWID_SPACER), SetFill(1, 1),
184  EndContainer(),
185  EndContainer(),
186  NWidget(NWID_SPACER), SetMinimalSize(0, 9), SetFill(1, 1),
187  EndContainer(),
188 };
189 
192  /* Window header. */
194  NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
195  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_MAPGEN_WORLD_GENERATION_CAPTION, STR_NULL),
196  EndContainer(),
197  NWidget(WWT_PANEL, COLOUR_BROWN),
199  /* Landscape selection. */
200  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 10),
201  NWidget(NWID_SPACER), SetFill(1, 0),
202  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TEMPERATE), SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
203  NWidget(NWID_SPACER), SetFill(1, 0),
204  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_ARCTIC), SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
205  NWidget(NWID_SPACER), SetFill(1, 0),
206  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TROPICAL), SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
207  NWidget(NWID_SPACER), SetFill(1, 0),
208  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TOYLAND), SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
209  NWidget(NWID_SPACER), SetFill(1, 0),
210  EndContainer(),
211  NWidget(NWID_SPACER), SetMinimalSize(0, 11), SetFill(0, 1),
212  NWidget(NWID_HORIZONTAL), SetPIP(10, 3, 10),
213  /* Labels at the left side. */
215  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_NAME, STR_NULL), SetFill(1, 1),
216  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_SIZE_LABEL, STR_NULL), SetFill(1, 1),
217  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAPSIZE, STR_NULL), SetFill(1, 1),
218  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_ROTATION, STR_NULL), SetFill(1, 1),
219  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_TOWNS, STR_NULL), SetFill(1, 1),
220  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES, STR_NULL), SetFill(1, 1),
221  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_NULL), SetFill(1, 1),
222  EndContainer(),
223  /* Widgets at the right of the labels. */
224  NWidget(NWID_VERTICAL), SetPIP(0, 4, 0),
225  NWidget(WWT_EMPTY, COLOUR_ORANGE, WID_GL_HEIGHTMAP_NAME_TEXT), SetFill(1, 0),
226  NWidget(NWID_HORIZONTAL), SetPIP(0, 5, 0),
228  NWidget(WWT_TEXT, COLOUR_ORANGE, WID_GL_HEIGHTMAP_SIZE_TEXT), SetDataTip(STR_MAPGEN_HEIGHTMAP_SIZE, STR_NULL), SetFill(1, 0),
229  /* Mapsize X * Y. */
230  NWidget(NWID_HORIZONTAL), SetPIP(0, 4, 0),
231  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_X_PULLDOWN), SetDataTip(STR_JUST_INT, STR_NULL), SetFill(1, 0),
232  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BY, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(1, 1),
233  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_Y_PULLDOWN), SetDataTip(STR_JUST_INT, STR_NULL), SetFill(1, 0),
234  EndContainer(),
235  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_ROTATION_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
236  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWN_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
237  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_INDUSTRY_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
238  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_RIVER_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
239  EndContainer(),
240  NWidget(NWID_VERTICAL), SetPIP(0, 4, 0),
241  NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0),
243  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_HEIGHT, STR_NULL), SetFill(1, 1),
245  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SNOW_COVERAGE, STR_NULL), SetFill(1, 1),
246  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DESERT_COVERAGE, STR_NULL), SetFill(1, 1),
247  EndContainer(),
248  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_NULL), SetFill(1, 1),
249  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_GAME_OPTIONS_TOWN_NAMES_FRAME, STR_NULL), SetFill(1, 1),
250  EndContainer(),
253  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_HEIGHTMAP_HEIGHT_DOWN), SetFill(0, 1),
254  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL), SetFill(1, 0),
255  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_HEIGHTMAP_HEIGHT_UP), SetFill(0, 1),
256  EndContainer(),
259  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_COVERAGE_DOWN), SetFill(0, 1),
260  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_TEXT), SetDataTip(STR_MAPGEN_SNOW_COVERAGE_TEXT, STR_NULL), SetFill(1, 0),
261  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_COVERAGE_UP), SetFill(0, 1),
262  EndContainer(),
264  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_DESERT_COVERAGE_DOWN), SetFill(0, 1),
265  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_TEXT), SetDataTip(STR_MAPGEN_DESERT_COVERAGE_TEXT, STR_NULL), SetFill(1, 0),
266  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_DESERT_COVERAGE_UP), SetFill(0, 1),
267  EndContainer(),
268  EndContainer(),
270  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),
271  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetDataTip(STR_BLACK_DATE_LONG, STR_NULL), SetFill(1, 0),
272  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),
273  EndContainer(),
274  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWNNAME_DROPDOWN), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_TOWN_NAMES_DROPDOWN_TOOLTIP), SetFill(1, 0),
275  EndContainer(),
276  EndContainer(),
277  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_GL_GENERATE_BUTTON), SetMinimalSize(84, 0), SetDataTip(STR_MAPGEN_GENERATE, STR_NULL), SetFill(1, 1),
278  EndContainer(),
279  EndContainer(),
280  EndContainer(),
281  EndContainer(),
282  NWidget(NWID_SPACER), SetMinimalSize(0, 9), SetFill(1, 1),
283  EndContainer(),
284 };
285 
286 static void StartGeneratingLandscape(GenerateLandscapeWindowMode mode)
287 {
290 
291  /* Copy all XXX_newgame to XXX when coming from outside the editor */
292  MakeNewgameSettingsLive();
293  ResetGRFConfig(true);
294 
295  if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP);
296  switch (mode) {
297  case GLWM_GENERATE: _switch_mode = (_game_mode == GM_EDITOR) ? SM_GENRANDLAND : SM_NEWGAME; break;
298  case GLWM_HEIGHTMAP: _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_HEIGHTMAP : SM_START_HEIGHTMAP; break;
299  case GLWM_SCENARIO: _switch_mode = SM_EDITOR; break;
300  default: NOT_REACHED();
301  }
302 }
303 
304 static void LandscapeGenerationCallback(Window *w, bool confirmed)
305 {
306  if (confirmed) StartGeneratingLandscape((GenerateLandscapeWindowMode)w->window_number);
307 }
308 
309 static DropDownList BuildMapsizeDropDown()
310 {
311  DropDownList list;
312 
313  for (uint i = MIN_MAP_SIZE_BITS; i <= MAX_MAP_SIZE_BITS; i++) {
314  DropDownListParamStringItem *item = new DropDownListParamStringItem(STR_JUST_INT, i, false);
315  item->SetParam(0, 1LL << i);
316  list.emplace_back(item);
317  }
318 
319  return list;
320 }
321 
322 static DropDownList BuildTownNameDropDown()
323 {
324  DropDownList list;
325 
326  /* Add and sort newgrf townnames generators */
327  const auto &grf_names = GetGRFTownNameList();
328  for (uint i = 0; i < grf_names.size(); i++) {
329  list.emplace_back(new DropDownListStringItem(grf_names[i], BUILTIN_TOWNNAME_GENERATOR_COUNT + i, false));
330  }
331  std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
332 
333  size_t newgrf_size = list.size();
334  /* Insert newgrf_names at the top of the list */
335  if (newgrf_size > 0) {
336  list.emplace_back(new DropDownListItem(-1, false)); // separator line
337  newgrf_size++;
338  }
339 
340  /* Add and sort original townnames generators */
341  for (uint i = 0; i < BUILTIN_TOWNNAME_GENERATOR_COUNT; i++) {
342  list.emplace_back(new DropDownListStringItem(STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + i, i, false));
343  }
344  std::sort(list.begin() + newgrf_size, list.end(), DropDownListStringItem::NatSortFunc);
345 
346  return list;
347 }
348 
349 
350 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};
351 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};
352 static const StringID _rivers[] = {STR_RIVERS_NONE, STR_RIVERS_FEW, STR_RIVERS_MODERATE, STR_RIVERS_LOT, INVALID_STRING_ID};
353 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};
354 static const StringID _rotation[] = {STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE, INVALID_STRING_ID};
355 static const StringID _landscape[] = {STR_CONFIG_SETTING_LAND_GENERATOR_ORIGINAL, STR_CONFIG_SETTING_LAND_GENERATOR_TERRA_GENESIS, INVALID_STRING_ID};
356 static const StringID _num_towns[] = {STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM, INVALID_STRING_ID};
357 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};
358 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};
359 
360 static_assert(lengthof(_num_inds) == ID_END + 1);
361 
363  uint widget_id;
364  uint x;
365  uint y;
366  char name[64];
368 
369  GenerateLandscapeWindow(WindowDesc *desc, WindowNumber number = 0) : Window(desc)
370  {
371  this->InitNested(number);
372 
374 
375  this->mode = (GenerateLandscapeWindowMode)this->window_number;
376 
377  /* Disable town and industry in SE */
378  this->SetWidgetDisabledState(WID_GL_TOWN_PULLDOWN, _game_mode == GM_EDITOR);
379  this->SetWidgetDisabledState(WID_GL_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR);
380 
381  /* In case the map_height_limit is changed, clamp heightmap_height and custom_terrain_type. */
384 
385  this->OnInvalidateData();
386  }
387 
388 
389  void SetStringParameters(int widget) const override
390  {
391  switch (widget) {
398 
400  if (_game_mode == GM_EDITOR) {
401  SetDParam(0, STR_CONFIG_SETTING_OFF);
403  SetDParam(0, STR_NUM_CUSTOM_NUMBER);
405  } else {
407  }
408  break;
409 
413  STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + gen :
414  GetGRFTownNameName(gen - BUILTIN_TOWNNAME_GENERATOR_COUNT);
415  SetDParam(0, name);
416  break;
417  }
418 
419  case WID_GL_INDUSTRY_PULLDOWN: SetDParam(0, _game_mode == GM_EDITOR ? STR_CONFIG_SETTING_OFF : _num_inds[_settings_newgame.difficulty.industry_density]); break;
423  SetDParam(0, STR_TERRAIN_TYPE_CUSTOM_VALUE);
425  } else {
426  SetDParam(0, _elevations[_settings_newgame.difficulty.terrain_type]); break;
427  }
428  break;
429 
432  SetDParam(0, STR_SEA_LEVEL_CUSTOM_PERCENTAGE);
434  } else {
436  }
437  break;
438 
442  case WID_GL_BORDERS_RANDOM: SetDParam(0, (_settings_newgame.game_creation.water_borders == BORDERS_RANDOM) ? STR_MAPGEN_BORDER_RANDOMIZE : STR_MAPGEN_BORDER_MANUAL); break;
443  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;
444  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;
445  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;
446  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;
448 
451  SetDParam(0, this->y);
452  SetDParam(1, this->x);
453  } else {
454  SetDParam(0, this->x);
455  SetDParam(1, this->y);
456  }
457  break;
458  }
459  }
460 
466  void OnInvalidateData(int data = 0, bool gui_scope = true) override
467  {
468  if (!gui_scope) return;
469  /* Update the climate buttons */
474 
475  /* You can't select smoothness / non-water borders if not terragenesis */
476  if (mode == GLWM_GENERATE) {
482 
484 
489 
492  }
493 
494  /* Disable snowline if not arctic */
496  /* Disable desert if not tropic */
498 
499  /* Set snow/rainforest selections */
500  int climate_plane = 0;
502  case LT_TEMPERATE: climate_plane = SZSP_VERTICAL; break;
503  case LT_ARCTIC: climate_plane = 0; break;
504  case LT_TROPIC: climate_plane = 1; break;
505  case LT_TOYLAND: climate_plane = SZSP_VERTICAL; break;
506  }
507  this->GetWidget<NWidgetStacked>(WID_GL_CLIMATE_SEL_LABEL)->SetDisplayedPlane(climate_plane);
508  this->GetWidget<NWidgetStacked>(WID_GL_CLIMATE_SEL_SELECTOR)->SetDisplayedPlane(climate_plane);
509 
510  /* Update availability of decreasing / increasing start date and snow level */
511  if (mode == GLWM_HEIGHTMAP) {
514  }
521 
522  /* Do not allow a custom sea level or terrain type with the original land generator. */
526  }
529  }
530  }
531 
532  }
533 
534  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
535  {
536  const StringID *strs = nullptr;
537  switch (widget) {
540  *size = GetStringBoundingBox(STR_JUST_INT);
541  break;
542 
545  *size = maxdim(*size, GetStringBoundingBox(STR_BLACK_DATE_LONG));
546  break;
547 
551  *size = maxdim(*size, GetStringBoundingBox(STR_JUST_INT));
552  break;
553 
556  *size = maxdim(*size, GetStringBoundingBox(STR_MAPGEN_SNOW_COVERAGE_TEXT));
557  break;
558 
561  *size = maxdim(*size, GetStringBoundingBox(STR_MAPGEN_DESERT_COVERAGE_TEXT));
562  break;
563 
565  SetDParam(0, this->x);
566  SetDParam(1, this->y);
567  *size = maxdim(*size, GetStringBoundingBox(STR_MAPGEN_HEIGHTMAP_SIZE));
568  break;
569 
571  strs = _num_towns;
573  *size = maxdim(*size, GetStringBoundingBox(STR_NUM_CUSTOM_NUMBER));
574  break;
575 
576  case WID_GL_INDUSTRY_PULLDOWN: strs = _num_inds; break;
577  case WID_GL_LANDSCAPE_PULLDOWN: strs = _landscape; break;
578 
580  strs = _elevations;
582  *size = maxdim(*size, GetStringBoundingBox(STR_TERRAIN_TYPE_CUSTOM_VALUE));
583  break;
584 
586  strs = _sea_lakes;
588  *size = maxdim(*size, GetStringBoundingBox(STR_SEA_LEVEL_CUSTOM_PERCENTAGE));
589  break;
590 
591  case WID_GL_RIVER_PULLDOWN: strs = _rivers; break;
592  case WID_GL_SMOOTHNESS_PULLDOWN: strs = _smoothness; break;
593  case WID_GL_VARIETY_PULLDOWN: strs = _variety; break;
594  case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: strs = _rotation; break;
596  *size = maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_RANDOMIZE), GetStringBoundingBox(STR_MAPGEN_BORDER_MANUAL));
597  break;
598 
599  case WID_GL_WATER_NE:
600  case WID_GL_WATER_NW:
601  case WID_GL_WATER_SE:
602  case WID_GL_WATER_SW:
603  *size = maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_RANDOM), maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_WATER), GetStringBoundingBox(STR_MAPGEN_BORDER_FREEFORM)));
604  break;
605 
607  size->width = 0;
608  break;
609 
610  default:
611  return;
612  }
613  if (strs != nullptr) {
614  while (*strs != INVALID_STRING_ID) {
615  *size = maxdim(*size, GetStringBoundingBox(*strs++));
616  }
617  }
618  size->width += padding.width;
619  size->height = std::max(size->height, (uint)(FONT_HEIGHT_NORMAL + WD_DROPDOWNTEXT_TOP + WD_DROPDOWNTEXT_BOTTOM));
620  }
621 
622  void DrawWidget(const Rect &r, int widget) const override
623  {
624  switch (widget) {
626  DrawString(r.left, r.right, r.top, this->name, TC_ORANGE);
627  break;
628  }
629  }
630  }
631 
632  void OnClick(Point pt, int widget, int click_count) override
633  {
634  switch (widget) {
635  case WID_GL_TEMPERATE:
636  case WID_GL_ARCTIC:
637  case WID_GL_TROPICAL:
638  case WID_GL_TOYLAND:
640  break;
641 
642  case WID_GL_MAPSIZE_X_PULLDOWN: // Mapsize X
644  break;
645 
646  case WID_GL_MAPSIZE_Y_PULLDOWN: // Mapsize Y
648  break;
649 
650  case WID_GL_TOWN_PULLDOWN: // Number of towns
652  break;
653 
654  case WID_GL_TOWNNAME_DROPDOWN: // Townname generator
656  break;
657 
658  case WID_GL_INDUSTRY_PULLDOWN: // Number of industries
660  break;
661 
662  case WID_GL_GENERATE_BUTTON: { // Generate
663  /* Get rotated map size. */
664  uint map_x;
665  uint map_y;
667  map_x = this->y;
668  map_y = this->x;
669  } else {
670  map_x = this->x;
671  map_y = this->y;
672  }
673  if (mode == GLWM_HEIGHTMAP &&
674  (map_x * 2 < (1U << _settings_newgame.game_creation.map_x) ||
675  map_x / 2 > (1U << _settings_newgame.game_creation.map_x) ||
676  map_y * 2 < (1U << _settings_newgame.game_creation.map_y) ||
677  map_y / 2 > (1U << _settings_newgame.game_creation.map_y))) {
678  ShowQuery(
679  STR_WARNING_HEIGHTMAP_SCALE_CAPTION,
680  STR_WARNING_HEIGHTMAP_SCALE_MESSAGE,
681  this,
682  LandscapeGenerationCallback);
683  } else {
684  StartGeneratingLandscape(mode);
685  }
686  break;
687  }
688 
690  case WID_GL_HEIGHTMAP_HEIGHT_UP: // Height level buttons
691  /* Don't allow too fast scrolling */
692  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
693  this->HandleButtonClick(widget);
694 
696  this->InvalidateData();
697  }
698  _left_button_clicked = false;
699  break;
700 
701  case WID_GL_HEIGHTMAP_HEIGHT_TEXT: // Height level text
702  this->widget_id = WID_GL_HEIGHTMAP_HEIGHT_TEXT;
704  ShowQueryString(STR_JUST_INT, STR_MAPGEN_HEIGHTMAP_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
705  break;
706 
707 
709  case WID_GL_START_DATE_UP: // Year buttons
710  /* Don't allow too fast scrolling */
711  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
712  this->HandleButtonClick(widget);
713 
715  this->InvalidateData();
716  }
717  _left_button_clicked = false;
718  break;
719 
720  case WID_GL_START_DATE_TEXT: // Year text
721  this->widget_id = WID_GL_START_DATE_TEXT;
723  ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
724  break;
725 
727  case WID_GL_SNOW_COVERAGE_UP: // Snow coverage buttons
728  /* Don't allow too fast scrolling */
729  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
730  this->HandleButtonClick(widget);
731 
733  this->InvalidateData();
734  }
735  _left_button_clicked = false;
736  break;
737 
738  case WID_GL_SNOW_COVERAGE_TEXT: // Snow coverage text
739  this->widget_id = WID_GL_SNOW_COVERAGE_TEXT;
741  ShowQueryString(STR_JUST_INT, STR_MAPGEN_SNOW_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
742  break;
743 
745  case WID_GL_DESERT_COVERAGE_UP: // Desert coverage buttons
746  /* Don't allow too fast scrolling */
747  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
748  this->HandleButtonClick(widget);
749 
751  this->InvalidateData();
752  }
753  _left_button_clicked = false;
754  break;
755 
756  case WID_GL_DESERT_COVERAGE_TEXT: // Desert line text
757  this->widget_id = WID_GL_DESERT_COVERAGE_TEXT;
759  ShowQueryString(STR_JUST_INT, STR_MAPGEN_DESERT_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
760  break;
761 
762  case WID_GL_LANDSCAPE_PULLDOWN: // Landscape generator
764  break;
765 
766  case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: // Heightmap rotation
768  break;
769 
770  case WID_GL_TERRAIN_PULLDOWN: // Terrain type
771  /* For the original map generation only the first four are valid. */
773  break;
774 
775  case WID_GL_WATER_PULLDOWN: { // Water quantity
776  uint32 hidden_mask = 0;
777  /* Disable custom water level when the original map generator is active. */
780  }
782  break;
783  }
784 
785  case WID_GL_RIVER_PULLDOWN: // Amount of rivers
787  break;
788 
789  case WID_GL_SMOOTHNESS_PULLDOWN: // Map smoothness
791  break;
792 
793  case WID_GL_VARIETY_PULLDOWN: // Map variety
795  break;
796 
797  /* Freetype map borders */
798  case WID_GL_WATER_NW:
800  this->InvalidateData();
801  break;
802 
803  case WID_GL_WATER_NE:
805  this->InvalidateData();
806  break;
807 
808  case WID_GL_WATER_SE:
810  this->InvalidateData();
811  break;
812 
813  case WID_GL_WATER_SW:
815  this->InvalidateData();
816  break;
817 
820  this->InvalidateData();
821  break;
822  }
823  }
824 
825  void OnTimeout() override
826  {
829 
830  const int *widget = (mode == GLWM_HEIGHTMAP) ? heightmap_raise_widgets : newgame_raise_widgets;
831 
832  for (; *widget != WIDGET_LIST_END; widget++) {
833  if (this->IsWidgetLowered(*widget)) {
834  this->RaiseWidget(*widget);
835  this->SetWidgetDirty(*widget);
836  }
837  }
838  }
839 
840  void OnDropdownSelect(int widget, int index) override
841  {
842  switch (widget) {
848 
850  /* If original landgenerator is selected and alpinist terrain_type was selected, revert to mountainous. */
853  }
854  break;
855 
857 
859  if ((uint)index == CUSTOM_TOWN_NUMBER_DIFFICULTY) {
860  this->widget_id = widget;
862  ShowQueryString(STR_JUST_INT, STR_MAPGEN_NUMBER_OF_TOWNS, 5, this, CS_NUMERAL, QSF_NONE);
863  }
865  break;
866 
867  case WID_GL_TOWNNAME_DROPDOWN: // Town names
868  if (_game_mode == GM_MENU || Town::GetNumItems() == 0) {
871  }
872  break;
873 
876  if ((uint)index == CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY) {
877  this->widget_id = widget;
879  ShowQueryString(STR_JUST_INT, STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_NONE);
880  }
882  break;
883  }
884 
885  case WID_GL_WATER_PULLDOWN: {
886  if ((uint)index == CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY) {
887  this->widget_id = widget;
889  ShowQueryString(STR_JUST_INT, STR_MAPGEN_QUANTITY_OF_SEA_LAKES, 3, this, CS_NUMERAL, QSF_NONE);
890  }
892  break;
893  }
894  }
895  this->InvalidateData();
896  }
897 
898  void OnQueryTextFinished(char *str) override
899  {
900  /* Was 'cancel' pressed? */
901  if (str == nullptr) return;
902 
903  int32 value;
904  if (!StrEmpty(str)) {
905  value = atoi(str);
906  } else {
907  /* An empty string means revert to the default */
908  switch (this->widget_id) {
910  case WID_GL_START_DATE_TEXT: value = DEF_START_YEAR; break;
911  case WID_GL_SNOW_COVERAGE_TEXT: value = DEF_SNOW_COVERAGE; break;
913  case WID_GL_TOWN_PULLDOWN: value = 1; break;
914  case WID_GL_TERRAIN_PULLDOWN: value = MIN_MAP_HEIGHT_LIMIT; break;
916  default: NOT_REACHED();
917  }
918  }
919 
920  switch (this->widget_id) {
924  break;
925 
929  break;
930 
934  break;
935 
939  break;
940 
943  break;
944 
947  break;
948 
951  break;
952  }
953 
954  this->InvalidateData();
955  }
956 };
957 
958 static WindowDesc _generate_landscape_desc(
959  WDP_CENTER, nullptr, 0, 0,
961  0,
963 );
964 
965 static WindowDesc _heightmap_load_desc(
966  WDP_CENTER, nullptr, 0, 0,
968  0,
970 );
971 
972 static void _ShowGenerateLandscape(GenerateLandscapeWindowMode mode)
973 {
974  uint x = 0;
975  uint y = 0;
976 
978 
979  /* Generate a new seed when opening the window */
980  _settings_newgame.game_creation.generation_seed = InteractiveRandom();
981 
982  if (mode == GLWM_HEIGHTMAP) {
983  /* If the function returns negative, it means there was a problem loading the heightmap */
985  }
986 
987  WindowDesc *desc = (mode == GLWM_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc;
988  GenerateLandscapeWindow *w = AllocateWindowDescFront<GenerateLandscapeWindow>(desc, mode, true);
989 
990  if (mode == GLWM_HEIGHTMAP) {
991  w->x = x;
992  w->y = y;
993  strecpy(w->name, _file_to_saveload.title, lastof(w->name));
994  }
995 
997 }
998 
1001 {
1002  _ShowGenerateLandscape(GLWM_GENERATE);
1003 }
1004 
1007 {
1008  _ShowGenerateLandscape(GLWM_HEIGHTMAP);
1009 }
1010 
1013 {
1014  StartGeneratingLandscape(GLWM_SCENARIO);
1015 }
1016 
1021 void StartNewGameWithoutGUI(uint32 seed)
1022 {
1023  /* GenerateWorld takes care of the possible GENERATE_NEW_SEED value in 'seed' */
1025 
1026  StartGeneratingLandscape(GLWM_GENERATE);
1027 }
1028 
1030 {
1031  uint widget_id;
1032 
1034  {
1035  this->InitNested(window_number);
1037  }
1038 
1039  void SetStringParameters(int widget) const override
1040  {
1041  switch (widget) {
1044  break;
1045 
1048  break;
1049 
1052  break;
1053 
1056  break;
1057  }
1058  }
1059 
1060  void OnPaint() override
1061  {
1066 
1071 
1072  this->DrawWidgets();
1073  }
1074 
1075  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1076  {
1077  StringID str = STR_JUST_INT;
1078  switch (widget) {
1080  SetDParam(0, ConvertYMDToDate(MAX_YEAR, 0, 1));
1081  str = STR_BLACK_DATE_LONG;
1082  break;
1083 
1087  break;
1088 
1091  break;
1092 
1093  default:
1094  return;
1095  }
1096  *size = maxdim(*size, GetStringBoundingBox(str));
1097  size->width += padding.width;
1098  size->height += padding.height;
1099  }
1100 
1101  void OnClick(Point pt, int widget, int click_count) override
1102  {
1103  switch (widget) {
1104  case WID_CS_TEMPERATE:
1105  case WID_CS_ARCTIC:
1106  case WID_CS_TROPICAL:
1107  case WID_CS_TOYLAND:
1110  break;
1111 
1112  case WID_CS_MAPSIZE_X_PULLDOWN: // Mapsize X
1114  break;
1115 
1116  case WID_CS_MAPSIZE_Y_PULLDOWN: // Mapsize Y
1118  break;
1119 
1120  case WID_CS_EMPTY_WORLD: // Empty world / flat world
1121  StartGeneratingLandscape(GLWM_SCENARIO);
1122  break;
1123 
1124  case WID_CS_RANDOM_WORLD: // Generate
1126  break;
1127 
1129  case WID_CS_START_DATE_UP: // Year buttons
1130  /* Don't allow too fast scrolling */
1131  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
1132  this->HandleButtonClick(widget);
1133  this->SetDirty();
1134 
1136  }
1137  _left_button_clicked = false;
1138  break;
1139 
1140  case WID_CS_START_DATE_TEXT: // Year text
1141  this->widget_id = WID_CS_START_DATE_TEXT;
1143  ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_NONE);
1144  break;
1145 
1147  case WID_CS_FLAT_LAND_HEIGHT_UP: // Height level buttons
1148  /* Don't allow too fast scrolling */
1149  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
1150  this->HandleButtonClick(widget);
1151  this->SetDirty();
1152 
1154  }
1155  _left_button_clicked = false;
1156  break;
1157 
1158  case WID_CS_FLAT_LAND_HEIGHT_TEXT: // Height level text
1159  this->widget_id = WID_CS_FLAT_LAND_HEIGHT_TEXT;
1161  ShowQueryString(STR_JUST_INT, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_NONE);
1162  break;
1163  }
1164  }
1165 
1166  void OnTimeout() override
1167  {
1169  for (const int *widget = raise_widgets; *widget != WIDGET_LIST_END; widget++) {
1170  if (this->IsWidgetLowered(*widget)) {
1171  this->RaiseWidget(*widget);
1172  this->SetWidgetDirty(*widget);
1173  }
1174  }
1175  }
1176 
1177  void OnDropdownSelect(int widget, int index) override
1178  {
1179  switch (widget) {
1182  }
1183  this->SetDirty();
1184  }
1185 
1186  void OnQueryTextFinished(char *str) override
1187  {
1188  if (!StrEmpty(str)) {
1189  int32 value = atoi(str);
1190 
1191  switch (this->widget_id) {
1195  break;
1196 
1200  break;
1201  }
1202 
1203  this->SetDirty();
1204  }
1205  }
1206 };
1207 
1208 static const NWidgetPart _nested_create_scenario_widgets[] = {
1210  NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
1211  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_SE_MAPGEN_CAPTION, STR_NULL),
1212  EndContainer(),
1213  NWidget(WWT_PANEL, COLOUR_BROWN),
1215  /* Landscape style selection. */
1216  NWidget(NWID_HORIZONTAL), SetPIP(10, 3, 10),
1217  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TEMPERATE), SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
1218  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_ARCTIC), SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
1219  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TROPICAL), SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
1220  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TOYLAND), SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
1221  EndContainer(),
1222  NWidget(NWID_HORIZONTAL), SetPIP(10, 8, 10),
1223  /* Green generation type buttons: 'Flat land' and 'Random land'. */
1224  NWidget(NWID_VERTICAL), SetPIP(10, 6, 10),
1225  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_CS_EMPTY_WORLD), SetDataTip(STR_SE_MAPGEN_FLAT_WORLD, STR_SE_MAPGEN_FLAT_WORLD_TOOLTIP), SetFill(1, 1),
1226  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_CS_RANDOM_WORLD), SetDataTip(STR_SE_MAPGEN_RANDOM_LAND, STR_TERRAFORM_TOOLTIP_GENERATE_RANDOM_LAND), SetFill(1, 1),
1227  EndContainer(),
1228  /* Labels + setting drop-downs */
1229  NWidget(NWID_VERTICAL), SetPIP(10, 6, 10),
1230  /* Map size. */
1232  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAPSIZE, STR_NULL), SetPadding(1, 0, 0, 0),
1233  NWidget(NWID_SPACER), SetMinimalSize(6, 0), SetFill(1, 0),
1234  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_CS_MAPSIZE_X_PULLDOWN), SetDataTip(STR_JUST_INT, STR_NULL), SetPadding(0, 4, 0, 0),
1235  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BY, STR_NULL), SetPadding(1, 2, 0, 0),
1236  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_CS_MAPSIZE_Y_PULLDOWN), SetDataTip(STR_JUST_INT, STR_NULL),
1237  EndContainer(),
1238  /* Date. */
1240  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_NULL), SetPadding(1, 0, 0, 0),
1241  NWidget(NWID_SPACER), SetMinimalSize(6, 0), SetFill(1, 0),
1242  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),
1243  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CS_START_DATE_TEXT), SetDataTip(STR_BLACK_DATE_LONG, STR_NULL),
1244  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),
1245  EndContainer(),
1246  /* Flat map height. */
1248  NWidget(WWT_TEXT, COLOUR_ORANGE),
1249  SetDataTip(STR_SE_MAPGEN_FLAT_WORLD_HEIGHT, STR_NULL), SetPadding(1, 0, 0, 0),
1250  NWidget(NWID_SPACER), SetMinimalSize(6, 0), SetFill(1, 0),
1251  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),
1252  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CS_FLAT_LAND_HEIGHT_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL),
1253  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),
1254  EndContainer(),
1255  EndContainer(),
1256  EndContainer(),
1257  EndContainer(),
1258 };
1259 
1260 static WindowDesc _create_scenario_desc(
1261  WDP_CENTER, nullptr, 0, 0,
1263  0,
1264  _nested_create_scenario_widgets, lengthof(_nested_create_scenario_widgets)
1265 );
1266 
1269 {
1271  new CreateScenarioWindow(&_create_scenario_desc, GLWM_SCENARIO);
1272 }
1273 
1274 static const NWidgetPart _nested_generate_progress_widgets[] = {
1275  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GENERATION_WORLD, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1276  NWidget(WWT_PANEL, COLOUR_GREY),
1277  NWidget(NWID_HORIZONTAL), SetPIP(20, 0, 20),
1278  NWidget(NWID_VERTICAL), SetPIP(11, 8, 11),
1279  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GP_PROGRESS_BAR), SetFill(1, 0),
1280  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GP_PROGRESS_TEXT), SetFill(1, 0),
1281  NWidget(WWT_TEXTBTN, COLOUR_WHITE, WID_GP_ABORT), SetDataTip(STR_GENERATION_ABORT, STR_NULL), SetFill(1, 0),
1282  EndContainer(),
1283  EndContainer(),
1284  EndContainer(),
1285 };
1286 
1287 
1288 static WindowDesc _generate_progress_desc(
1289  WDP_CENTER, nullptr, 0, 0,
1291  0,
1292  _nested_generate_progress_widgets, lengthof(_nested_generate_progress_widgets)
1293 );
1294 
1296  uint percent;
1297  StringID cls;
1298  uint current;
1299  uint total;
1300  std::chrono::steady_clock::time_point next_update;
1301 };
1302 
1303 static GenWorldStatus _gws;
1304 
1305 static const StringID _generation_class_table[] = {
1306  STR_GENERATION_WORLD_GENERATION,
1307  STR_SCENEDIT_TOOLBAR_LANDSCAPE_GENERATION,
1308  STR_GENERATION_RIVER_GENERATION,
1309  STR_GENERATION_CLEARING_TILES,
1310  STR_SCENEDIT_TOOLBAR_TOWN_GENERATION,
1311  STR_SCENEDIT_TOOLBAR_INDUSTRY_GENERATION,
1312  STR_GENERATION_OBJECT_GENERATION,
1313  STR_GENERATION_TREE_GENERATION,
1314  STR_GENERATION_SETTINGUP_GAME,
1315  STR_GENERATION_PREPARING_TILELOOP,
1316  STR_GENERATION_PREPARING_SCRIPT,
1317  STR_GENERATION_PREPARING_GAME
1318 };
1319 static_assert(lengthof(_generation_class_table) == GWP_CLASS_COUNT);
1320 
1321 
1322 static void AbortGeneratingWorldCallback(Window *w, bool confirmed)
1323 {
1324  if (confirmed) {
1326  } else if (HasModalProgress() && !IsGeneratingWorldAborted()) {
1327  SetMouseCursor(SPR_CURSOR_ZZZ, PAL_NONE);
1328  }
1329 }
1330 
1332 
1333  GenerateProgressWindow() : Window(&_generate_progress_desc)
1334  {
1335  this->InitNested();
1336  }
1337 
1338  void OnClick(Point pt, int widget, int click_count) override
1339  {
1340  switch (widget) {
1341  case WID_GP_ABORT:
1342  SetMouseCursorBusy(false);
1343  ShowQuery(
1344  STR_GENERATION_ABORT_CAPTION,
1345  STR_GENERATION_ABORT_MESSAGE,
1346  this,
1347  AbortGeneratingWorldCallback
1348  );
1349  break;
1350  }
1351  }
1352 
1353  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1354  {
1355  switch (widget) {
1356  case WID_GP_PROGRESS_BAR: {
1357  SetDParamMaxValue(0, 100);
1358  *size = GetStringBoundingBox(STR_GENERATION_PROGRESS);
1359  /* We need some spacing for the 'border' */
1360  size->height += 8;
1361  size->width += 8;
1362  break;
1363  }
1364 
1365  case WID_GP_PROGRESS_TEXT:
1366  for (uint i = 0; i < GWP_CLASS_COUNT; i++) {
1367  size->width = std::max(size->width, GetStringBoundingBox(_generation_class_table[i]).width);
1368  }
1369  size->height = FONT_HEIGHT_NORMAL * 2 + WD_PAR_VSEP_NORMAL;
1370  break;
1371  }
1372  }
1373 
1374  void DrawWidget(const Rect &r, int widget) const override
1375  {
1376  switch (widget) {
1377  case WID_GP_PROGRESS_BAR:
1378  /* Draw the % complete with a bar and a text */
1379  DrawFrameRect(r.left, r.top, r.right, r.bottom, COLOUR_GREY, FR_BORDERONLY);
1380  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);
1381  SetDParam(0, _gws.percent);
1382  DrawString(r.left, r.right, r.top + 5, STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
1383  break;
1384 
1385  case WID_GP_PROGRESS_TEXT:
1386  /* Tell which class we are generating */
1387  DrawString(r.left, r.right, r.top, _gws.cls, TC_FROMSTRING, SA_HOR_CENTER);
1388 
1389  /* And say where we are in that class */
1390  SetDParam(0, _gws.current);
1391  SetDParam(1, _gws.total);
1392  DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL, STR_GENERATION_PROGRESS_NUM, TC_FROMSTRING, SA_HOR_CENTER);
1393  }
1394  }
1395 };
1396 
1401 {
1402  _gws.cls = STR_GENERATION_WORLD_GENERATION;
1403  _gws.current = 0;
1404  _gws.total = 0;
1405  _gws.percent = 0;
1406  _gws.next_update = std::chrono::steady_clock::now();
1407 }
1408 
1413 {
1414  if (BringWindowToFrontById(WC_MODAL_PROGRESS, 0)) return;
1415  new GenerateProgressWindow();
1416 }
1417 
1418 static void _SetGeneratingWorldProgress(GenWorldProgress cls, uint progress, uint total)
1419 {
1420  static const int percent_table[] = {0, 5, 14, 17, 20, 40, 60, 65, 80, 85, 95, 99, 100 };
1421  static_assert(lengthof(percent_table) == GWP_CLASS_COUNT + 1);
1422  assert(cls < GWP_CLASS_COUNT);
1423 
1424  /* Check if we really are generating the world.
1425  * For example, placing trees via the SE also calls this function, but
1426  * shouldn't try to update the progress.
1427  */
1428  if (!HasModalProgress()) return;
1429 
1430  if (IsGeneratingWorldAborted()) {
1432  return;
1433  }
1434 
1435  if (total == 0) {
1436  assert(_gws.cls == _generation_class_table[cls]);
1437  _gws.current += progress;
1438  assert(_gws.current <= _gws.total);
1439  } else {
1440  _gws.cls = _generation_class_table[cls];
1441  _gws.current = progress;
1442  _gws.total = total;
1443  _gws.percent = percent_table[cls];
1444  }
1445 
1446  /* Percentage is about the number of completed tasks, so 'current - 1' */
1447  _gws.percent = percent_table[cls] + (percent_table[cls + 1] - percent_table[cls]) * (_gws.current == 0 ? 0 : _gws.current - 1) / _gws.total;
1448 
1449  if (_network_dedicated) {
1450  static uint last_percent = 0;
1451 
1452  /* Never display 0% */
1453  if (_gws.percent == 0) return;
1454  /* Reset if percent is lower than the last recorded */
1455  if (_gws.percent < last_percent) last_percent = 0;
1456  /* Display every 5%, but 6% is also very valid.. just not smaller steps than 5% */
1457  if (_gws.percent % 5 != 0 && _gws.percent <= last_percent + 5) return;
1458  /* Never show steps smaller than 2%, even if it is a mod 5% */
1459  if (_gws.percent <= last_percent + 2) return;
1460 
1461  Debug(net, 3, "Map generation percentage complete: {}", _gws.percent);
1462  last_percent = _gws.percent;
1463 
1464  return;
1465  }
1466 
1468 
1470 }
1471 
1481 {
1482  if (total == 0) return;
1483 
1484  _SetGeneratingWorldProgress(cls, 0, total);
1485 }
1486 
1495 {
1496  /* In fact the param 'class' isn't needed.. but for some security reasons, we want it around */
1497  _SetGeneratingWorldProgress(cls, 1, 0);
1498 }
FileToSaveLoad::title
char title[255]
Internal name of the game.
Definition: saveload.h:358
WID_GL_SNOW_COVERAGE_DOWN
@ WID_GL_SNOW_COVERAGE_DOWN
Decrease snow coverage.
Definition: genworld_widget.h:37
SetMouseCursorBusy
void SetMouseCursorBusy(bool busy)
Set or unset the ZZZ cursor.
Definition: gfx.cpp:1830
sound_func.h
GameCreationSettings::generation_seed
uint32 generation_seed
noise seed for world generation
Definition: settings_type.h:304
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:1374
SetNewLandscapeType
void SetNewLandscapeType(byte landscape)
Changes landscape type and sets genworld window dirty.
Definition: genworld_gui.cpp:61
Window::timeout_timer
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
Definition: window_gui.h:309
WID_GL_DESERT_COVERAGE_UP
@ WID_GL_DESERT_COVERAGE_UP
Increase desert coverage.
Definition: genworld_widget.h:43
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3120
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:37
GenerateProgressWindow
Definition: genworld_gui.cpp:1331
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:325
ShowCreateScenario
void ShowCreateScenario()
Show the window to create a scenario.
Definition: genworld_gui.cpp:1268
AbortGeneratingWorld
void AbortGeneratingWorld()
Initializes the abortion process.
Definition: genworld.cpp:238
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:1139
GameCreationSettings::map_y
uint8 map_y
Y size of map.
Definition: settings_type.h:308
dropdown_func.h
GameCreationSettings::landscape
byte landscape
the landscape we're currently in
Definition: settings_type.h:320
GameCreationSettings::tgen_smoothness
byte tgen_smoothness
how rough is the terrain from 0-3
Definition: settings_type.h:315
WID_GP_PROGRESS_BAR
@ WID_GP_PROGRESS_BAR
Progress bar.
Definition: genworld_widget.h:87
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
WID_CS_TOYLAND
@ WID_CS_TOYLAND
Select toy-land landscape style.
Definition: genworld_widget.h:72
GenerateLandscapeWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: genworld_gui.cpp:840
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:434
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:30
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:78
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:357
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:99
ConstructionSettings::map_height_limit
uint8 map_height_limit
the maximum allowed heightlevel
Definition: settings_type.h:333
WID_GL_CLIMATE_SEL_SELECTOR
@ WID_GL_CLIMATE_SEL_SELECTOR
NWID_SELECTION for snow or desert coverage selector.
Definition: genworld_widget.h:64
WID_GL_WATER_SE
@ WID_GL_WATER_SE
SE 'Water'/'Freeform'.
Definition: genworld_widget.h:60
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:80
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:575
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:323
WID_GL_HEIGHTMAP_SIZE_TEXT
@ WID_GL_HEIGHTMAP_SIZE_TEXT
Size of heightmap.
Definition: genworld_widget.h:48
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:1338
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:319
WID_GL_HEIGHTMAP_ROTATION_PULLDOWN
@ WID_GL_HEIGHTMAP_ROTATION_PULLDOWN
Dropdown 'Heightmap rotation'.
Definition: genworld_widget.h:49
WC_GENERATE_LANDSCAPE
@ WC_GENERATE_LANDSCAPE
Generate landscape (newgame); Window numbers:
Definition: window_type.h:448
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:52
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:642
MIN_CUSTOM_TERRAIN_TYPE
static const uint MIN_CUSTOM_TERRAIN_TYPE
Lowest possible peak value for world generation.
Definition: tile_type.h:25
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
town.h
WID_GL_WATER_PULLDOWN
@ WID_GL_WATER_PULLDOWN
Dropdown 'Sea level'.
Definition: genworld_widget.h:52
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:1101
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
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:646
fios.h
WID_GL_HEIGHTMAP_HEIGHT_DOWN
@ WID_GL_HEIGHTMAP_HEIGHT_DOWN
Decrease heightmap highest mountain.
Definition: genworld_widget.h:29
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1799
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:196
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:971
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:1107
GameCreationSettings::heightmap_height
byte heightmap_height
highest mountain for heightmap (towards what it scales)
Definition: settings_type.h:314
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:888
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:1075
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:576
_nested_heightmap_load_widgets
static const NWidgetPart _nested_heightmap_load_widgets[]
Widgets of GenerateLandscapeWindow when loading heightmap.
Definition: genworld_gui.cpp:191
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:168
WC_MODAL_PROGRESS
@ WC_MODAL_PROGRESS
Progress report of landscape generation; Window numbers:
Definition: window_type.h:455
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:463
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:1400
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:341
WID_GL_BORDERS_RANDOM
@ WID_GL_BORDERS_RANDOM
'Random'/'Manual' borders.
Definition: genworld_widget.h:57
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:317
WID_GL_SMOOTHNESS_PULLDOWN
@ WID_GL_SMOOTHNESS_PULLDOWN
Dropdown 'Smoothness'.
Definition: genworld_widget.h:54
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:596
SetMouseCursor
void SetMouseCursor(CursorID sprite, PaletteID pal)
Assign a single non-animated sprite to the cursor.
Definition: gfx.cpp:1845
ShowGenerateLandscape
void ShowGenerateLandscape()
Start with a normal game.
Definition: genworld_gui.cpp:1000
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1789
SM_NEWGAME
@ SM_NEWGAME
New Game --> 'Random game'.
Definition: openttd.h:27
MIN_YEAR
static const Year MIN_YEAR
The absolute minimum & maximum years in OTTD.
Definition: date_type.h:84
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:28
DifficultySettings::terrain_type
byte terrain_type
the mountainousness of the landscape
Definition: settings_type.h:85
GameCreationSettings::custom_town_number
uint16 custom_town_number
manually entered number of towns
Definition: settings_type.h:322
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:993
WID_GP_PROGRESS_TEXT
@ WID_GP_PROGRESS_TEXT
Text with the progress bar.
Definition: genworld_widget.h:88
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
DEF_DESERT_COVERAGE
static const uint DEF_DESERT_COVERAGE
Default desert coverage.
Definition: tile_type.h:35
WD_PAR_VSEP_NORMAL
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
Definition: window_gui.h:139
GameCreationSettings::water_borders
byte water_borders
bitset of the borders that are water
Definition: settings_type.h:321
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
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:443
WID_CS_TROPICAL
@ WID_CS_TROPICAL
Select tropical landscape style.
Definition: genworld_widget.h:71
WID_GL_SNOW_COVERAGE_UP
@ WID_GL_SNOW_COVERAGE_UP
Increase snow coverage.
Definition: genworld_widget.h:39
WID_GL_TOWN_PULLDOWN
@ WID_GL_TOWN_PULLDOWN
Dropdown 'No. of towns'.
Definition: genworld_widget.h:23
dropdown_type.h
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
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_GL_HEIGHTMAP_HEIGHT_UP
@ WID_GL_HEIGHTMAP_HEIGHT_UP
Increase max. heightmap highest mountain.
Definition: genworld_widget.h:31
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:386
DropDownListStringItem
Common string list item.
Definition: dropdown_type.h:39
safeguards.h
GenerateLandscapeWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: genworld_gui.cpp:825
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:1118
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:305
GameCreationSettings::custom_terrain_type
byte custom_terrain_type
manually entered height for TGP to aim for
Definition: settings_type.h:324
WID_GL_TERRAIN_PULLDOWN
@ WID_GL_TERRAIN_PULLDOWN
Dropdown 'Terrain type'.
Definition: genworld_widget.h:51
ConstructionSettings::freeform_edges
bool freeform_edges
allow terraforming the tiles at the map edges
Definition: settings_type.h:345
WF_TIMEOUT
@ WF_TIMEOUT
Window timeout counter.
Definition: window_gui.h:234
CreateScenarioWindow
Definition: genworld_gui.cpp:1029
StrEmpty
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:64
DifficultySettings::quantity_sea_lakes
byte quantity_sea_lakes
the amount of seas/lakes
Definition: settings_type.h:86
DifficultySettings::industry_density
byte industry_density
The industry density.
Definition: settings_type.h:76
GameCreationSettings::se_flat_world_height
byte se_flat_world_height
land height a flat world gets in SE
Definition: settings_type.h:318
GenWorldStatus
Definition: genworld_gui.cpp:1295
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:69
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:480
_network_dedicated
bool _network_dedicated
are we a dedicated server?
Definition: network.cpp:59
date_func.h
stdafx.h
SM_GENRANDLAND
@ SM_GENRANDLAND
Generate random land within scenario editor.
Definition: openttd.h:35
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:307
IncreaseGeneratingWorldProgress
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
Definition: genworld_gui.cpp:1494
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:3158
VideoDriver::GetInstance
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Definition: video_driver.hpp:199
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:37
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_type.h:329
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:1006
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:75
StartNewGameWithoutGUI
void StartNewGameWithoutGUI(uint32 seed)
Start a normal game without the GUI.
Definition: genworld_gui.cpp:1021
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:1353
SM_LOAD_HEIGHTMAP
@ SM_LOAD_HEIGHTMAP
Load heightmap from scenario editor.
Definition: openttd.h:38
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:69
VideoDriver::GameLoopPause
void GameLoopPause()
Pause the game-loop for a bit, releasing the game-state lock.
Definition: video_driver.cpp:64
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:136
string_func.h
MIN_HEIGHTMAP_HEIGHT
static const uint MIN_HEIGHTMAP_HEIGHT
Lowest possible peak value for heightmap creation.
Definition: tile_type.h:24
_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:534
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:1267
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:208
GameCreationSettings::heightmap_rotation
byte heightmap_rotation
rotation director for the heightmap
Definition: settings_type.h:317
WC_GAME_OPTIONS
@ WC_GAME_OPTIONS
Game options window; Window numbers:
Definition: window_type.h:604
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1092
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:77
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:76
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:27
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:367
WID_GL_HEIGHTMAP_HEIGHT_TEXT
@ WID_GL_HEIGHTMAP_HEIGHT_TEXT
Max. heightmap highest mountain.
Definition: genworld_widget.h:30
ShowGenerateWorldProgress
void ShowGenerateWorldProgress()
Show the window where a user can follow the process of the map generation.
Definition: genworld_gui.cpp:1412
GenerateLandscapeWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: genworld_gui.cpp:389
HandleGeneratingWorldAbortion
void HandleGeneratingWorldAbortion()
Really handle the abortion, i.e.
Definition: genworld.cpp:255
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:307
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:56
GameCreationSettings::desert_coverage
byte desert_coverage
the amount of desert coverage on the map
Definition: settings_type.h:313
GameCreationSettings::amount_of_rivers
byte amount_of_rivers
the amount of rivers
Definition: settings_type.h:328
GameCreationSettings::land_generator
byte land_generator
the landscape generator
Definition: settings_type.h:309
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:165
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:1207
geometry_func.hpp
CreateScenarioWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: genworld_gui.cpp:1166
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:94
CloseWindowByClass
void CloseWindowByClass(WindowClass cls)
Close all windows of a given class.
Definition: window.cpp:1188
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:3235
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1010
_file_to_saveload
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
Definition: saveload.cpp:63
GenerateLandscapeWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: genworld_gui.cpp:622
GenerateLandscapeWindow
Definition: genworld_gui.cpp:362
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:547
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_HEIGHTMAP_NAME_TEXT
@ WID_GL_HEIGHTMAP_NAME_TEXT
Heightmap name.
Definition: genworld_widget.h:47
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:632
Window::IsWidgetLowered
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:487
CreateScenarioWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: genworld_gui.cpp:1186
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:58
GameCreationSettings::starting_year
Year starting_year
starting date
Definition: settings_type.h:305
WID_CS_EMPTY_WORLD
@ WID_CS_EMPTY_WORLD
Generate an empty flat world.
Definition: genworld_widget.h:73
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:55
WID_GP_ABORT
@ WID_GP_ABORT
Abort button.
Definition: genworld_widget.h:89
DEF_START_YEAR
static const Year DEF_START_YEAR
The default starting year.
Definition: date_type.h:87
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:45
DrawFrameRect
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition: widget.cpp:209
WID_CS_MAPSIZE_X_PULLDOWN
@ WID_CS_MAPSIZE_X_PULLDOWN
Pull-down arrow for x map size.
Definition: genworld_widget.h:75
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
Debug
#define Debug(name, level, format_string,...)
Ouptut a line of debugging information.
Definition: debug.h:37
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:378
WID_GL_SNOW_COVERAGE_TEXT
@ WID_GL_SNOW_COVERAGE_TEXT
Snow coverage.
Definition: genworld_widget.h:38
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:314
random_func.hpp
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1169
IsGeneratingWorldAborted
bool IsGeneratingWorldAborted()
Is the generation being aborted?
Definition: genworld.cpp:247
GameCreationSettings::snow_coverage
byte snow_coverage
the amount of snow coverage on the map
Definition: settings_type.h:312
_nested_generate_landscape_widgets
static const NWidgetPart _nested_generate_landscape_widgets[]
Widgets of GenerateLandscapeWindow when generating world.
Definition: genworld_gui.cpp:69
StartScenarioEditor
void StartScenarioEditor()
Start with a scenario editor.
Definition: genworld_gui.cpp:1012
WID_GL_WATER_SW
@ WID_GL_WATER_SW
SW 'Water'/'Freeform'.
Definition: genworld_widget.h:61
WID_GL_CLIMATE_SEL_LABEL
@ WID_GL_CLIMATE_SEL_LABEL
NWID_SELECTION for snow or desert coverage label.
Definition: genworld_widget.h:63
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1076
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:1480
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition: settings_type.h:577
WD_DROPDOWNTEXT_BOTTOM
@ WD_DROPDOWNTEXT_BOTTOM
Bottom offset of the dropdown widget string.
Definition: window_gui.h:137
WID_CS_FLAT_LAND_HEIGHT_TEXT
@ WID_CS_FLAT_LAND_HEIGHT_TEXT
Clickable flat land height value.
Definition: genworld_widget.h:81
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:3283
Window
Data structure for an opened window.
Definition: window_gui.h:279
FileToSaveLoad::detail_ftype
DetailedFileType detail_ftype
Concrete file type (PNG, BMP, old save, etc).
Definition: saveload.h:355
GetMapHeightLimit
static uint GetMapHeightLimit()
Get the map height limit, or if set to "auto", the absolute limit.
Definition: genworld_gui.cpp:51
SZSP_VERTICAL
@ SZSP_VERTICAL
Display plane with zero size horizontally, and filling and resizing vertically.
Definition: widget_type.h:421
ResetGRFConfig
void ResetGRFConfig(bool defaults)
Reset the current GRF Config to either blank or newgame settings.
Definition: newgrf_config.cpp:495
Window::RaiseWidget
void RaiseWidget(byte widget_index)
Marks a widget as raised.
Definition: window_gui.h:477
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:636
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:79
strecpy
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
Definition: string.cpp:112
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:78
WID_CS_ARCTIC
@ WID_CS_ARCTIC
Select arctic landscape style.
Definition: genworld_widget.h:70
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
Window::SetWidgetDirty
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:608
WID_GL_DESERT_COVERAGE_DOWN
@ WID_GL_DESERT_COVERAGE_DOWN
Decrease desert coverage.
Definition: genworld_widget.h:41
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:468
BringWindowToFrontById
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
Definition: window.cpp:1259
WID_CS_START_DATE_DOWN
@ WID_CS_START_DATE_DOWN
Decrease start year (start earlier).
Definition: genworld_widget.h:77
DifficultySettings::number_towns
byte number_towns
the amount of towns
Definition: settings_type.h:75
WID_GL_RIVER_PULLDOWN
@ WID_GL_RIVER_PULLDOWN
Dropdown 'Rivers'.
Definition: genworld_widget.h:53
WID_CS_RANDOM_WORLD
@ WID_CS_RANDOM_WORLD
Generate random land button.
Definition: genworld_widget.h:74
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:1060
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:394
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition: window_gui.h:157
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:447
GenerateLandscapeWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: genworld_gui.cpp:898
_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:1039
CreateScenarioWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: genworld_gui.cpp:1177
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:59
genworld_widget.h
_settings_newgame
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Definition: settings.cpp:54
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:466
debug.h
FR_BORDERONLY
@ FR_BORDERONLY
Draw border only, no background.
Definition: window_gui.h:30
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:68
WID_GL_DESERT_COVERAGE_TEXT
@ WID_GL_DESERT_COVERAGE_TEXT
Desert coverage.
Definition: genworld_widget.h:42
WID_CS_FLAT_LAND_HEIGHT_UP
@ WID_CS_FLAT_LAND_HEIGHT_UP
Increase flat land height.
Definition: genworld_widget.h:82
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:95
DEF_SNOW_COVERAGE
static const uint DEF_SNOW_COVERAGE
Default snow coverage.
Definition: tile_type.h:34
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