OpenTTD Source  13.0-beta1
genworld_gui.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "stdafx.h"
11 #include "heightmap.h"
12 #include "debug.h"
13 #include "genworld.h"
14 #include "network/network.h"
15 #include "strings_func.h"
16 #include "window_func.h"
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),
126  EndContainer(),
127  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_NULL), SetFill(1, 1),
128  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SMOOTHNESS, STR_NULL), SetFill(1, 1),
129  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_NULL), SetFill(1, 1),
130  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_GAME_OPTIONS_TOWN_NAMES_FRAME, STR_NULL), SetFill(1, 1),
131  EndContainer(),
134  /* Snow coverage. */
136  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_COVERAGE_DOWN), SetFill(0, 1),
137  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_TEXT), SetDataTip(STR_MAPGEN_SNOW_COVERAGE_TEXT, STR_NULL), SetFill(1, 0),
138  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_COVERAGE_UP), SetFill(0, 1),
139  EndContainer(),
140  /* Desert coverage. */
142  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_DESERT_COVERAGE_DOWN), SetFill(0, 1),
143  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_TEXT), SetDataTip(STR_MAPGEN_DESERT_COVERAGE_TEXT, STR_NULL), SetFill(1, 0),
144  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_DESERT_COVERAGE_UP), SetFill(0, 1),
145  EndContainer(),
146  /* Temperate/Toyland spacer */
148  EndContainer(),
149  /* Starting date. */
151  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),
152  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetDataTip(STR_BLACK_DATE_LONG, STR_NULL), SetFill(1, 0),
153  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),
154  EndContainer(),
155  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_SMOOTHNESS_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
156  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_RIVER_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
157  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWNNAME_DROPDOWN), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_TOWN_NAMES_DROPDOWN_TOOLTIP), SetFill(1, 0),
158  EndContainer(),
159  EndContainer(),
160  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_GL_GENERATE_BUTTON), SetMinimalSize(84, 0), SetDataTip(STR_MAPGEN_GENERATE, STR_NULL), SetFill(1, 1),
161  EndContainer(),
162  EndContainer(),
164  /* Map borders buttons for each edge. */
166  NWidget(NWID_HORIZONTAL), SetPIP(0, 0, 3),
167  NWidget(NWID_SPACER), SetFill(1, 1),
168  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NORTHWEST, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(0, 1),
169  EndContainer(),
170  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_NW), SetDataTip(STR_JUST_STRING, STR_MAPGEN_NORTHWEST), SetFill(1, 1),
171  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_NE), SetDataTip(STR_JUST_STRING, STR_MAPGEN_NORTHEAST), SetFill(1, 1),
172  NWidget(NWID_HORIZONTAL), SetPIP(3, 0, 0),
173  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NORTHEAST, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(0, 1),
174  NWidget(NWID_SPACER), SetFill(1, 1),
175  EndContainer(),
176  EndContainer(),
178  NWidget(NWID_HORIZONTAL), SetPIP(0, 0, 3),
179  NWidget(NWID_SPACER), SetFill(1, 1),
180  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SOUTHWEST, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(0, 1),
181  EndContainer(),
182  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_SW), SetDataTip(STR_JUST_STRING, STR_MAPGEN_SOUTHWEST), SetFill(1, 1),
183  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_SE), SetDataTip(STR_JUST_STRING, STR_MAPGEN_SOUTHEAST), SetFill(1, 1),
184  NWidget(NWID_HORIZONTAL), SetPIP(3, 0, 0),
185  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SOUTHEAST, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(0, 1),
186  NWidget(NWID_SPACER), SetFill(1, 1),
187  EndContainer(),
188  EndContainer(),
189  NWidget(NWID_SPACER), SetMinimalSize(0, 9), SetFill(1, 1),
190  EndContainer(),
191 };
192 
195  /* Window header. */
197  NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
198  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_MAPGEN_WORLD_GENERATION_CAPTION, STR_NULL),
199  EndContainer(),
200  NWidget(WWT_PANEL, COLOUR_BROWN),
202  /* Landscape selection. */
203  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 10),
204  NWidget(NWID_SPACER), SetFill(1, 0),
205  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TEMPERATE), SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
206  NWidget(NWID_SPACER), SetFill(1, 0),
207  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_ARCTIC), SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
208  NWidget(NWID_SPACER), SetFill(1, 0),
209  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TROPICAL), SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
210  NWidget(NWID_SPACER), SetFill(1, 0),
211  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TOYLAND), SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
212  NWidget(NWID_SPACER), SetFill(1, 0),
213  EndContainer(),
214  NWidget(NWID_SPACER), SetMinimalSize(0, 11), SetFill(0, 1),
215  NWidget(NWID_HORIZONTAL), SetPIP(10, 3, 10),
216  /* Labels at the left side. */
218  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_NAME, STR_NULL), SetFill(1, 1),
219  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_SIZE_LABEL, STR_NULL), SetFill(1, 1),
220  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAPSIZE, STR_NULL), SetFill(1, 1),
221  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_ROTATION, STR_NULL), SetFill(1, 1),
222  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_TOWNS, STR_NULL), SetFill(1, 1),
223  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES, STR_NULL), SetFill(1, 1),
224  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_NULL), SetFill(1, 1),
225  EndContainer(),
226  /* Widgets at the right of the labels. */
227  NWidget(NWID_VERTICAL), SetPIP(0, 4, 0),
228  NWidget(WWT_TEXT, COLOUR_ORANGE, WID_GL_HEIGHTMAP_NAME_TEXT), SetTextColour(TC_ORANGE), SetDataTip(STR_JUST_RAW_STRING, STR_EMPTY), SetFill(1, 0),
229  NWidget(NWID_HORIZONTAL), SetPIP(0, 5, 0),
231  NWidget(WWT_TEXT, COLOUR_ORANGE, WID_GL_HEIGHTMAP_SIZE_TEXT), SetDataTip(STR_MAPGEN_HEIGHTMAP_SIZE, STR_NULL), SetFill(1, 0),
232  /* Mapsize X * Y. */
233  NWidget(NWID_HORIZONTAL), SetPIP(0, 4, 0),
234  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_X_PULLDOWN), SetDataTip(STR_JUST_INT, STR_NULL), SetFill(1, 0),
235  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BY, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(1, 1),
236  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_Y_PULLDOWN), SetDataTip(STR_JUST_INT, STR_NULL), SetFill(1, 0),
237  EndContainer(),
238  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_ROTATION_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
239  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWN_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
240  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_INDUSTRY_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
241  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_RIVER_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
242  EndContainer(),
243  NWidget(NWID_VERTICAL), SetPIP(0, 4, 0),
244  NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0),
246  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_HEIGHT, STR_NULL), SetFill(1, 1),
248  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SNOW_COVERAGE, STR_NULL), SetFill(1, 1),
249  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DESERT_COVERAGE, STR_NULL), SetFill(1, 1),
251  EndContainer(),
252  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_NULL), SetFill(1, 1),
253  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_GAME_OPTIONS_TOWN_NAMES_FRAME, STR_NULL), SetFill(1, 1),
254  EndContainer(),
257  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_HEIGHTMAP_HEIGHT_DOWN), SetFill(0, 1),
258  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL), SetFill(1, 0),
259  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_HEIGHTMAP_HEIGHT_UP), SetFill(0, 1),
260  EndContainer(),
263  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_COVERAGE_DOWN), SetFill(0, 1),
264  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_TEXT), SetDataTip(STR_MAPGEN_SNOW_COVERAGE_TEXT, STR_NULL), SetFill(1, 0),
265  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_COVERAGE_UP), SetFill(0, 1),
266  EndContainer(),
268  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_DESERT_COVERAGE_DOWN), SetFill(0, 1),
269  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_TEXT), SetDataTip(STR_MAPGEN_DESERT_COVERAGE_TEXT, STR_NULL), SetFill(1, 0),
270  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_DESERT_COVERAGE_UP), SetFill(0, 1),
271  EndContainer(),
273  EndContainer(),
275  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),
276  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetDataTip(STR_BLACK_DATE_LONG, STR_NULL), SetFill(1, 0),
277  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),
278  EndContainer(),
279  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWNNAME_DROPDOWN), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_TOWN_NAMES_DROPDOWN_TOOLTIP), SetFill(1, 0),
280  EndContainer(),
281  EndContainer(),
282  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_GL_GENERATE_BUTTON), SetMinimalSize(84, 0), SetDataTip(STR_MAPGEN_GENERATE, STR_NULL), SetFill(1, 1),
283  EndContainer(),
284  EndContainer(),
285  EndContainer(),
286  EndContainer(),
287  NWidget(NWID_SPACER), SetMinimalSize(0, 9), SetFill(1, 1),
288  EndContainer(),
289 };
290 
291 static void StartGeneratingLandscape(GenerateLandscapeWindowMode mode)
292 {
295 
296  /* Copy all XXX_newgame to XXX when coming from outside the editor */
297  MakeNewgameSettingsLive();
298  ResetGRFConfig(true);
299 
300  if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP);
301  switch (mode) {
302  case GLWM_GENERATE: _switch_mode = (_game_mode == GM_EDITOR) ? SM_GENRANDLAND : SM_NEWGAME; break;
303  case GLWM_HEIGHTMAP: _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_HEIGHTMAP : SM_START_HEIGHTMAP; break;
304  case GLWM_SCENARIO: _switch_mode = SM_EDITOR; break;
305  default: NOT_REACHED();
306  }
307 }
308 
309 static void LandscapeGenerationCallback(Window *w, bool confirmed)
310 {
311  if (confirmed) StartGeneratingLandscape((GenerateLandscapeWindowMode)w->window_number);
312 }
313 
314 static DropDownList BuildMapsizeDropDown()
315 {
316  DropDownList list;
317 
318  for (uint i = MIN_MAP_SIZE_BITS; i <= MAX_MAP_SIZE_BITS; i++) {
319  DropDownListParamStringItem *item = new DropDownListParamStringItem(STR_JUST_INT, i, false);
320  item->SetParam(0, 1LL << i);
321  list.emplace_back(item);
322  }
323 
324  return list;
325 }
326 
327 static DropDownList BuildTownNameDropDown()
328 {
329  DropDownList list;
330 
331  /* Add and sort newgrf townnames generators */
332  const auto &grf_names = GetGRFTownNameList();
333  for (uint i = 0; i < grf_names.size(); i++) {
334  list.emplace_back(new DropDownListStringItem(grf_names[i], BUILTIN_TOWNNAME_GENERATOR_COUNT + i, false));
335  }
336  std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
337 
338  size_t newgrf_size = list.size();
339  /* Insert newgrf_names at the top of the list */
340  if (newgrf_size > 0) {
341  list.emplace_back(new DropDownListItem(-1, false)); // separator line
342  newgrf_size++;
343  }
344 
345  /* Add and sort original townnames generators */
346  for (uint i = 0; i < BUILTIN_TOWNNAME_GENERATOR_COUNT; i++) {
347  list.emplace_back(new DropDownListStringItem(STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + i, i, false));
348  }
349  std::sort(list.begin() + newgrf_size, list.end(), DropDownListStringItem::NatSortFunc);
350 
351  return list;
352 }
353 
354 
355 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};
356 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};
357 static const StringID _rivers[] = {STR_RIVERS_NONE, STR_RIVERS_FEW, STR_RIVERS_MODERATE, STR_RIVERS_LOT, INVALID_STRING_ID};
358 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};
359 static const StringID _rotation[] = {STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE, INVALID_STRING_ID};
360 static const StringID _landscape[] = {STR_CONFIG_SETTING_LAND_GENERATOR_ORIGINAL, STR_CONFIG_SETTING_LAND_GENERATOR_TERRA_GENESIS, INVALID_STRING_ID};
361 static const StringID _num_towns[] = {STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM, INVALID_STRING_ID};
362 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};
363 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};
364 
365 static_assert(lengthof(_num_inds) == ID_END + 1);
366 
368  uint widget_id;
369  uint x;
370  uint y;
371  char name[64];
373 
374  GenerateLandscapeWindow(WindowDesc *desc, WindowNumber number = 0) : Window(desc)
375  {
376  this->InitNested(number);
377 
379 
380  this->mode = (GenerateLandscapeWindowMode)this->window_number;
381 
382  /* Disable town and industry in SE */
383  this->SetWidgetDisabledState(WID_GL_TOWN_PULLDOWN, _game_mode == GM_EDITOR);
384  this->SetWidgetDisabledState(WID_GL_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR);
385 
386  /* In case the map_height_limit is changed, clamp heightmap_height and custom_terrain_type. */
389 
390  this->OnInvalidateData();
391  }
392 
393 
394  void SetStringParameters(int widget) const override
395  {
396  switch (widget) {
403 
405  if (_game_mode == GM_EDITOR) {
406  SetDParam(0, STR_CONFIG_SETTING_OFF);
408  SetDParam(0, STR_NUM_CUSTOM_NUMBER);
410  } else {
412  }
413  break;
414 
418  STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + gen :
419  GetGRFTownNameName(gen - BUILTIN_TOWNNAME_GENERATOR_COUNT);
420  SetDParam(0, name);
421  break;
422  }
423 
424  case WID_GL_INDUSTRY_PULLDOWN: SetDParam(0, _game_mode == GM_EDITOR ? STR_CONFIG_SETTING_OFF : _num_inds[_settings_newgame.difficulty.industry_density]); break;
428  SetDParam(0, STR_TERRAIN_TYPE_CUSTOM_VALUE);
430  } else {
431  SetDParam(0, _elevations[_settings_newgame.difficulty.terrain_type]); break;
432  }
433  break;
434 
437  SetDParam(0, STR_SEA_LEVEL_CUSTOM_PERCENTAGE);
439  } else {
441  }
442  break;
443 
444  case WID_GL_HEIGHTMAP_NAME_TEXT: SetDParamStr(0, this->name); break;
448  case WID_GL_BORDERS_RANDOM: SetDParam(0, (_settings_newgame.game_creation.water_borders == BORDERS_RANDOM) ? STR_MAPGEN_BORDER_RANDOMIZE : STR_MAPGEN_BORDER_MANUAL); break;
449  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;
450  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;
451  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;
452  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;
454 
457  SetDParam(0, this->y);
458  SetDParam(1, this->x);
459  } else {
460  SetDParam(0, this->x);
461  SetDParam(1, this->y);
462  }
463  break;
464  }
465  }
466 
472  void OnInvalidateData(int data = 0, bool gui_scope = true) override
473  {
474  if (!gui_scope) return;
475  /* Update the climate buttons */
480 
481  /* You can't select smoothness / non-water borders if not terragenesis */
482  if (mode == GLWM_GENERATE) {
488 
490 
495 
498  }
499 
500  /* Disable snowline if not arctic */
502  /* Disable desert if not tropic */
504 
505  /* Set snow/rainforest selections */
506  int climate_plane = 0;
508  case LT_TEMPERATE: climate_plane = 2; break;
509  case LT_ARCTIC: climate_plane = 0; break;
510  case LT_TROPIC: climate_plane = 1; break;
511  case LT_TOYLAND: climate_plane = 2; break;
512  }
513  this->GetWidget<NWidgetStacked>(WID_GL_CLIMATE_SEL_LABEL)->SetDisplayedPlane(climate_plane);
514  this->GetWidget<NWidgetStacked>(WID_GL_CLIMATE_SEL_SELECTOR)->SetDisplayedPlane(climate_plane);
515 
516  /* Update availability of decreasing / increasing start date and snow level */
517  if (mode == GLWM_HEIGHTMAP) {
520  }
527 
528  /* Do not allow a custom sea level or terrain type with the original land generator. */
532  }
535  }
536  }
537 
538  }
539 
540  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
541  {
542  const StringID *strs = nullptr;
543  switch (widget) {
546  *size = GetStringBoundingBox(STR_JUST_INT);
547  break;
548 
551  *size = maxdim(*size, GetStringBoundingBox(STR_BLACK_DATE_LONG));
552  break;
553 
557  *size = maxdim(*size, GetStringBoundingBox(STR_JUST_INT));
558  break;
559 
562  *size = maxdim(*size, GetStringBoundingBox(STR_MAPGEN_SNOW_COVERAGE_TEXT));
563  break;
564 
567  *size = maxdim(*size, GetStringBoundingBox(STR_MAPGEN_DESERT_COVERAGE_TEXT));
568  break;
569 
571  SetDParam(0, this->x);
572  SetDParam(1, this->y);
573  *size = maxdim(*size, GetStringBoundingBox(STR_MAPGEN_HEIGHTMAP_SIZE));
574  break;
575 
577  strs = _num_towns;
579  *size = maxdim(*size, GetStringBoundingBox(STR_NUM_CUSTOM_NUMBER));
580  break;
581 
582  case WID_GL_INDUSTRY_PULLDOWN: strs = _num_inds; break;
583  case WID_GL_LANDSCAPE_PULLDOWN: strs = _landscape; break;
584 
586  strs = _elevations;
588  *size = maxdim(*size, GetStringBoundingBox(STR_TERRAIN_TYPE_CUSTOM_VALUE));
589  break;
590 
592  strs = _sea_lakes;
594  *size = maxdim(*size, GetStringBoundingBox(STR_SEA_LEVEL_CUSTOM_PERCENTAGE));
595  break;
596 
597  case WID_GL_RIVER_PULLDOWN: strs = _rivers; break;
598  case WID_GL_SMOOTHNESS_PULLDOWN: strs = _smoothness; break;
599  case WID_GL_VARIETY_PULLDOWN: strs = _variety; break;
600  case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: strs = _rotation; break;
602  *size = maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_RANDOMIZE), GetStringBoundingBox(STR_MAPGEN_BORDER_MANUAL));
603  break;
604 
605  case WID_GL_WATER_NE:
606  case WID_GL_WATER_NW:
607  case WID_GL_WATER_SE:
608  case WID_GL_WATER_SW:
609  *size = maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_RANDOM), maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_WATER), GetStringBoundingBox(STR_MAPGEN_BORDER_FREEFORM)));
610  break;
611 
613  size->width = 0;
614  break;
615 
616  default:
617  return;
618  }
619  if (strs != nullptr) {
620  while (*strs != INVALID_STRING_ID) {
621  *size = maxdim(*size, GetStringBoundingBox(*strs++));
622  }
623  }
624  size->width += padding.width;
625  size->height = std::max(size->height, (uint)(FONT_HEIGHT_NORMAL + WD_DROPDOWNTEXT_TOP + WD_DROPDOWNTEXT_BOTTOM));
626  }
627 
628  void OnClick(Point pt, int widget, int click_count) override
629  {
630  switch (widget) {
631  case WID_GL_TEMPERATE:
632  case WID_GL_ARCTIC:
633  case WID_GL_TROPICAL:
634  case WID_GL_TOYLAND:
636  break;
637 
638  case WID_GL_MAPSIZE_X_PULLDOWN: // Mapsize X
640  break;
641 
642  case WID_GL_MAPSIZE_Y_PULLDOWN: // Mapsize Y
644  break;
645 
646  case WID_GL_TOWN_PULLDOWN: // Number of towns
648  break;
649 
650  case WID_GL_TOWNNAME_DROPDOWN: // Townname generator
652  break;
653 
654  case WID_GL_INDUSTRY_PULLDOWN: // Number of industries
656  break;
657 
658  case WID_GL_GENERATE_BUTTON: { // Generate
659  /* Get rotated map size. */
660  uint map_x;
661  uint map_y;
663  map_x = this->y;
664  map_y = this->x;
665  } else {
666  map_x = this->x;
667  map_y = this->y;
668  }
669  if (mode == GLWM_HEIGHTMAP &&
670  (map_x * 2 < (1U << _settings_newgame.game_creation.map_x) ||
671  map_x / 2 > (1U << _settings_newgame.game_creation.map_x) ||
672  map_y * 2 < (1U << _settings_newgame.game_creation.map_y) ||
673  map_y / 2 > (1U << _settings_newgame.game_creation.map_y))) {
674  ShowQuery(
675  STR_WARNING_HEIGHTMAP_SCALE_CAPTION,
676  STR_WARNING_HEIGHTMAP_SCALE_MESSAGE,
677  this,
678  LandscapeGenerationCallback);
679  } else {
680  StartGeneratingLandscape(mode);
681  }
682  break;
683  }
684 
686  case WID_GL_HEIGHTMAP_HEIGHT_UP: // Height level buttons
687  /* Don't allow too fast scrolling */
688  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
689  this->HandleButtonClick(widget);
690 
692  this->InvalidateData();
693  }
694  _left_button_clicked = false;
695  break;
696 
697  case WID_GL_HEIGHTMAP_HEIGHT_TEXT: // Height level text
698  this->widget_id = WID_GL_HEIGHTMAP_HEIGHT_TEXT;
700  ShowQueryString(STR_JUST_INT, STR_MAPGEN_HEIGHTMAP_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
701  break;
702 
703 
705  case WID_GL_START_DATE_UP: // Year buttons
706  /* Don't allow too fast scrolling */
707  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
708  this->HandleButtonClick(widget);
709 
711  this->InvalidateData();
712  }
713  _left_button_clicked = false;
714  break;
715 
716  case WID_GL_START_DATE_TEXT: // Year text
717  this->widget_id = WID_GL_START_DATE_TEXT;
719  ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
720  break;
721 
723  case WID_GL_SNOW_COVERAGE_UP: // Snow coverage buttons
724  /* Don't allow too fast scrolling */
725  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
726  this->HandleButtonClick(widget);
727 
729  this->InvalidateData();
730  }
731  _left_button_clicked = false;
732  break;
733 
734  case WID_GL_SNOW_COVERAGE_TEXT: // Snow coverage text
735  this->widget_id = WID_GL_SNOW_COVERAGE_TEXT;
737  ShowQueryString(STR_JUST_INT, STR_MAPGEN_SNOW_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
738  break;
739 
741  case WID_GL_DESERT_COVERAGE_UP: // Desert coverage buttons
742  /* Don't allow too fast scrolling */
743  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
744  this->HandleButtonClick(widget);
745 
747  this->InvalidateData();
748  }
749  _left_button_clicked = false;
750  break;
751 
752  case WID_GL_DESERT_COVERAGE_TEXT: // Desert line text
753  this->widget_id = WID_GL_DESERT_COVERAGE_TEXT;
755  ShowQueryString(STR_JUST_INT, STR_MAPGEN_DESERT_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
756  break;
757 
758  case WID_GL_LANDSCAPE_PULLDOWN: // Landscape generator
760  break;
761 
762  case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: // Heightmap rotation
764  break;
765 
766  case WID_GL_TERRAIN_PULLDOWN: // Terrain type
767  /* For the original map generation only the first four are valid. */
769  break;
770 
771  case WID_GL_WATER_PULLDOWN: { // Water quantity
772  uint32 hidden_mask = 0;
773  /* Disable custom water level when the original map generator is active. */
776  }
778  break;
779  }
780 
781  case WID_GL_RIVER_PULLDOWN: // Amount of rivers
783  break;
784 
785  case WID_GL_SMOOTHNESS_PULLDOWN: // Map smoothness
787  break;
788 
789  case WID_GL_VARIETY_PULLDOWN: // Map variety
791  break;
792 
793  /* Freetype map borders */
794  case WID_GL_WATER_NW:
796  this->InvalidateData();
797  break;
798 
799  case WID_GL_WATER_NE:
801  this->InvalidateData();
802  break;
803 
804  case WID_GL_WATER_SE:
806  this->InvalidateData();
807  break;
808 
809  case WID_GL_WATER_SW:
811  this->InvalidateData();
812  break;
813 
816  this->InvalidateData();
817  break;
818  }
819  }
820 
821  void OnTimeout() override
822  {
825 
826  const int *widget = (mode == GLWM_HEIGHTMAP) ? heightmap_raise_widgets : newgame_raise_widgets;
827 
828  for (; *widget != WIDGET_LIST_END; widget++) {
829  if (this->IsWidgetLowered(*widget)) {
830  this->RaiseWidget(*widget);
831  this->SetWidgetDirty(*widget);
832  }
833  }
834  }
835 
836  void OnDropdownSelect(int widget, int index) override
837  {
838  switch (widget) {
844 
846  /* If original landgenerator is selected and alpinist terrain_type was selected, revert to mountainous. */
849  }
850  break;
851 
853 
855  if ((uint)index == CUSTOM_TOWN_NUMBER_DIFFICULTY) {
856  this->widget_id = widget;
858  ShowQueryString(STR_JUST_INT, STR_MAPGEN_NUMBER_OF_TOWNS, 5, this, CS_NUMERAL, QSF_NONE);
859  }
861  break;
862 
863  case WID_GL_TOWNNAME_DROPDOWN: // Town names
864  if (_game_mode == GM_MENU || Town::GetNumItems() == 0) {
867  }
868  break;
869 
872  if ((uint)index == CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY) {
873  this->widget_id = widget;
875  ShowQueryString(STR_JUST_INT, STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_NONE);
876  }
878  break;
879  }
880 
881  case WID_GL_WATER_PULLDOWN: {
882  if ((uint)index == CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY) {
883  this->widget_id = widget;
885  ShowQueryString(STR_JUST_INT, STR_MAPGEN_QUANTITY_OF_SEA_LAKES, 3, this, CS_NUMERAL, QSF_NONE);
886  }
888  break;
889  }
890  }
891  this->InvalidateData();
892  }
893 
894  void OnQueryTextFinished(char *str) override
895  {
896  /* Was 'cancel' pressed? */
897  if (str == nullptr) return;
898 
899  int32 value;
900  if (!StrEmpty(str)) {
901  value = atoi(str);
902  } else {
903  /* An empty string means revert to the default */
904  switch (this->widget_id) {
906  case WID_GL_START_DATE_TEXT: value = DEF_START_YEAR; break;
907  case WID_GL_SNOW_COVERAGE_TEXT: value = DEF_SNOW_COVERAGE; break;
909  case WID_GL_TOWN_PULLDOWN: value = 1; break;
910  case WID_GL_TERRAIN_PULLDOWN: value = MIN_MAP_HEIGHT_LIMIT; break;
912  default: NOT_REACHED();
913  }
914  }
915 
916  switch (this->widget_id) {
920  break;
921 
925  break;
926 
930  break;
931 
935  break;
936 
939  break;
940 
943  break;
944 
947  break;
948  }
949 
950  this->InvalidateData();
951  }
952 };
953 
954 static WindowDesc _generate_landscape_desc(
955  WDP_CENTER, nullptr, 0, 0,
957  0,
959 );
960 
961 static WindowDesc _heightmap_load_desc(
962  WDP_CENTER, nullptr, 0, 0,
964  0,
966 );
967 
968 static void _ShowGenerateLandscape(GenerateLandscapeWindowMode mode)
969 {
970  uint x = 0;
971  uint y = 0;
972 
974 
975  /* Generate a new seed when opening the window */
976  _settings_newgame.game_creation.generation_seed = InteractiveRandom();
977 
978  if (mode == GLWM_HEIGHTMAP) {
979  /* If the function returns negative, it means there was a problem loading the heightmap */
981  }
982 
983  WindowDesc *desc = (mode == GLWM_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc;
984  GenerateLandscapeWindow *w = AllocateWindowDescFront<GenerateLandscapeWindow>(desc, mode, true);
985 
986  if (mode == GLWM_HEIGHTMAP) {
987  w->x = x;
988  w->y = y;
989  strecpy(w->name, _file_to_saveload.title, lastof(w->name));
990  }
991 
993 }
994 
997 {
998  _ShowGenerateLandscape(GLWM_GENERATE);
999 }
1000 
1003 {
1004  _ShowGenerateLandscape(GLWM_HEIGHTMAP);
1005 }
1006 
1009 {
1010  StartGeneratingLandscape(GLWM_SCENARIO);
1011 }
1012 
1017 void StartNewGameWithoutGUI(uint32 seed)
1018 {
1019  /* GenerateWorld takes care of the possible GENERATE_NEW_SEED value in 'seed' */
1021 
1022  StartGeneratingLandscape(GLWM_GENERATE);
1023 }
1024 
1026 {
1027  uint widget_id;
1028 
1030  {
1031  this->InitNested(window_number);
1033  }
1034 
1035  void SetStringParameters(int widget) const override
1036  {
1037  switch (widget) {
1040  break;
1041 
1044  break;
1045 
1048  break;
1049 
1052  break;
1053  }
1054  }
1055 
1056  void OnPaint() override
1057  {
1062 
1067 
1068  this->DrawWidgets();
1069  }
1070 
1071  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1072  {
1073  StringID str = STR_JUST_INT;
1074  switch (widget) {
1076  SetDParam(0, ConvertYMDToDate(MAX_YEAR, 0, 1));
1077  str = STR_BLACK_DATE_LONG;
1078  break;
1079 
1083  break;
1084 
1087  break;
1088 
1089  default:
1090  return;
1091  }
1092  *size = maxdim(*size, GetStringBoundingBox(str));
1093  size->width += padding.width;
1094  size->height += padding.height;
1095  }
1096 
1097  void OnClick(Point pt, int widget, int click_count) override
1098  {
1099  switch (widget) {
1100  case WID_CS_TEMPERATE:
1101  case WID_CS_ARCTIC:
1102  case WID_CS_TROPICAL:
1103  case WID_CS_TOYLAND:
1106  break;
1107 
1108  case WID_CS_MAPSIZE_X_PULLDOWN: // Mapsize X
1110  break;
1111 
1112  case WID_CS_MAPSIZE_Y_PULLDOWN: // Mapsize Y
1114  break;
1115 
1116  case WID_CS_EMPTY_WORLD: // Empty world / flat world
1117  StartGeneratingLandscape(GLWM_SCENARIO);
1118  break;
1119 
1120  case WID_CS_RANDOM_WORLD: // Generate
1122  break;
1123 
1125  case WID_CS_START_DATE_UP: // Year buttons
1126  /* Don't allow too fast scrolling */
1127  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
1128  this->HandleButtonClick(widget);
1129  this->SetDirty();
1130 
1132  }
1133  _left_button_clicked = false;
1134  break;
1135 
1136  case WID_CS_START_DATE_TEXT: // Year text
1137  this->widget_id = WID_CS_START_DATE_TEXT;
1139  ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_NONE);
1140  break;
1141 
1143  case WID_CS_FLAT_LAND_HEIGHT_UP: // Height level buttons
1144  /* Don't allow too fast scrolling */
1145  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
1146  this->HandleButtonClick(widget);
1147  this->SetDirty();
1148 
1150  }
1151  _left_button_clicked = false;
1152  break;
1153 
1154  case WID_CS_FLAT_LAND_HEIGHT_TEXT: // Height level text
1155  this->widget_id = WID_CS_FLAT_LAND_HEIGHT_TEXT;
1157  ShowQueryString(STR_JUST_INT, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_NONE);
1158  break;
1159  }
1160  }
1161 
1162  void OnTimeout() override
1163  {
1165  for (const int *widget = raise_widgets; *widget != WIDGET_LIST_END; widget++) {
1166  if (this->IsWidgetLowered(*widget)) {
1167  this->RaiseWidget(*widget);
1168  this->SetWidgetDirty(*widget);
1169  }
1170  }
1171  }
1172 
1173  void OnDropdownSelect(int widget, int index) override
1174  {
1175  switch (widget) {
1178  }
1179  this->SetDirty();
1180  }
1181 
1182  void OnQueryTextFinished(char *str) override
1183  {
1184  if (!StrEmpty(str)) {
1185  int32 value = atoi(str);
1186 
1187  switch (this->widget_id) {
1191  break;
1192 
1196  break;
1197  }
1198 
1199  this->SetDirty();
1200  }
1201  }
1202 };
1203 
1204 static const NWidgetPart _nested_create_scenario_widgets[] = {
1206  NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
1207  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_SE_MAPGEN_CAPTION, STR_NULL),
1208  EndContainer(),
1209  NWidget(WWT_PANEL, COLOUR_BROWN),
1211  /* Landscape style selection. */
1212  NWidget(NWID_HORIZONTAL), SetPIP(10, 3, 10),
1213  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TEMPERATE), SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
1214  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_ARCTIC), SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
1215  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TROPICAL), SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
1216  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TOYLAND), SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
1217  EndContainer(),
1218  NWidget(NWID_HORIZONTAL), SetPIP(10, 8, 10),
1219  /* Green generation type buttons: 'Flat land' and 'Random land'. */
1220  NWidget(NWID_VERTICAL), SetPIP(10, 6, 10),
1221  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_CS_EMPTY_WORLD), SetDataTip(STR_SE_MAPGEN_FLAT_WORLD, STR_SE_MAPGEN_FLAT_WORLD_TOOLTIP), SetFill(1, 1),
1222  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_CS_RANDOM_WORLD), SetDataTip(STR_SE_MAPGEN_RANDOM_LAND, STR_TERRAFORM_TOOLTIP_GENERATE_RANDOM_LAND), SetFill(1, 1),
1223  EndContainer(),
1224  /* Labels + setting drop-downs */
1225  NWidget(NWID_VERTICAL), SetPIP(10, 6, 10),
1226  /* Map size. */
1228  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAPSIZE, STR_NULL), SetPadding(1, 0, 0, 0),
1229  NWidget(NWID_SPACER), SetMinimalSize(6, 0), SetFill(1, 0),
1230  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_CS_MAPSIZE_X_PULLDOWN), SetDataTip(STR_JUST_INT, STR_NULL), SetPadding(0, 4, 0, 0),
1231  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BY, STR_NULL), SetPadding(1, 2, 0, 0),
1232  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_CS_MAPSIZE_Y_PULLDOWN), SetDataTip(STR_JUST_INT, STR_NULL),
1233  EndContainer(),
1234  /* Date. */
1236  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_NULL), SetPadding(1, 0, 0, 0),
1237  NWidget(NWID_SPACER), SetMinimalSize(6, 0), SetFill(1, 0),
1238  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),
1239  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CS_START_DATE_TEXT), SetDataTip(STR_BLACK_DATE_LONG, STR_NULL),
1240  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),
1241  EndContainer(),
1242  /* Flat map height. */
1244  NWidget(WWT_TEXT, COLOUR_ORANGE),
1245  SetDataTip(STR_SE_MAPGEN_FLAT_WORLD_HEIGHT, STR_NULL), SetPadding(1, 0, 0, 0),
1246  NWidget(NWID_SPACER), SetMinimalSize(6, 0), SetFill(1, 0),
1247  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),
1248  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CS_FLAT_LAND_HEIGHT_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL),
1249  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),
1250  EndContainer(),
1251  EndContainer(),
1252  EndContainer(),
1253  EndContainer(),
1254 };
1255 
1256 static WindowDesc _create_scenario_desc(
1257  WDP_CENTER, nullptr, 0, 0,
1259  0,
1260  _nested_create_scenario_widgets, lengthof(_nested_create_scenario_widgets)
1261 );
1262 
1265 {
1267  new CreateScenarioWindow(&_create_scenario_desc, GLWM_SCENARIO);
1268 }
1269 
1270 static const NWidgetPart _nested_generate_progress_widgets[] = {
1271  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GENERATION_WORLD, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1272  NWidget(WWT_PANEL, COLOUR_GREY),
1273  NWidget(NWID_HORIZONTAL), SetPIP(20, 0, 20),
1274  NWidget(NWID_VERTICAL), SetPIP(11, 8, 11),
1275  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GP_PROGRESS_BAR), SetFill(1, 0),
1276  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GP_PROGRESS_TEXT), SetFill(1, 0),
1277  NWidget(WWT_TEXTBTN, COLOUR_WHITE, WID_GP_ABORT), SetDataTip(STR_GENERATION_ABORT, STR_NULL), SetFill(1, 0),
1278  EndContainer(),
1279  EndContainer(),
1280  EndContainer(),
1281 };
1282 
1283 
1284 static WindowDesc _generate_progress_desc(
1285  WDP_CENTER, nullptr, 0, 0,
1287  0,
1288  _nested_generate_progress_widgets, lengthof(_nested_generate_progress_widgets)
1289 );
1290 
1292  uint percent;
1293  StringID cls;
1294  uint current;
1295  uint total;
1296  std::chrono::steady_clock::time_point next_update;
1297 };
1298 
1299 static GenWorldStatus _gws;
1300 
1301 static const StringID _generation_class_table[] = {
1302  STR_GENERATION_WORLD_GENERATION,
1303  STR_SCENEDIT_TOOLBAR_LANDSCAPE_GENERATION,
1304  STR_GENERATION_RIVER_GENERATION,
1305  STR_GENERATION_CLEARING_TILES,
1306  STR_SCENEDIT_TOOLBAR_TOWN_GENERATION,
1307  STR_SCENEDIT_TOOLBAR_INDUSTRY_GENERATION,
1308  STR_GENERATION_OBJECT_GENERATION,
1309  STR_GENERATION_TREE_GENERATION,
1310  STR_GENERATION_SETTINGUP_GAME,
1311  STR_GENERATION_PREPARING_TILELOOP,
1312  STR_GENERATION_PREPARING_SCRIPT,
1313  STR_GENERATION_PREPARING_GAME
1314 };
1315 static_assert(lengthof(_generation_class_table) == GWP_CLASS_COUNT);
1316 
1317 
1318 static void AbortGeneratingWorldCallback(Window *w, bool confirmed)
1319 {
1320  if (confirmed) {
1322  } else if (HasModalProgress() && !IsGeneratingWorldAborted()) {
1323  SetMouseCursor(SPR_CURSOR_ZZZ, PAL_NONE);
1324  }
1325 }
1326 
1328 
1329  GenerateProgressWindow() : Window(&_generate_progress_desc)
1330  {
1331  this->InitNested();
1332  }
1333 
1334  void OnClick(Point pt, int widget, int click_count) override
1335  {
1336  switch (widget) {
1337  case WID_GP_ABORT:
1338  SetMouseCursorBusy(false);
1339  ShowQuery(
1340  STR_GENERATION_ABORT_CAPTION,
1341  STR_GENERATION_ABORT_MESSAGE,
1342  this,
1343  AbortGeneratingWorldCallback
1344  );
1345  break;
1346  }
1347  }
1348 
1349  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1350  {
1351  switch (widget) {
1352  case WID_GP_PROGRESS_BAR: {
1353  SetDParamMaxValue(0, 100);
1354  *size = GetStringBoundingBox(STR_GENERATION_PROGRESS);
1355  /* We need some spacing for the 'border' */
1356  size->height += 8;
1357  size->width += 8;
1358  break;
1359  }
1360 
1361  case WID_GP_PROGRESS_TEXT:
1362  for (uint i = 0; i < GWP_CLASS_COUNT; i++) {
1363  size->width = std::max(size->width, GetStringBoundingBox(_generation_class_table[i]).width);
1364  }
1365  size->height = FONT_HEIGHT_NORMAL * 2 + WD_PAR_VSEP_NORMAL;
1366  break;
1367  }
1368  }
1369 
1370  void DrawWidget(const Rect &r, int widget) const override
1371  {
1372  switch (widget) {
1373  case WID_GP_PROGRESS_BAR:
1374  /* Draw the % complete with a bar and a text */
1375  DrawFrameRect(r.left, r.top, r.right, r.bottom, COLOUR_GREY, FR_BORDERONLY);
1376  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);
1377  SetDParam(0, _gws.percent);
1378  DrawString(r.left, r.right, r.top + 5, STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
1379  break;
1380 
1381  case WID_GP_PROGRESS_TEXT:
1382  /* Tell which class we are generating */
1383  DrawString(r.left, r.right, r.top, _gws.cls, TC_FROMSTRING, SA_HOR_CENTER);
1384 
1385  /* And say where we are in that class */
1386  SetDParam(0, _gws.current);
1387  SetDParam(1, _gws.total);
1388  DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL, STR_GENERATION_PROGRESS_NUM, TC_FROMSTRING, SA_HOR_CENTER);
1389  }
1390  }
1391 };
1392 
1397 {
1398  _gws.cls = STR_GENERATION_WORLD_GENERATION;
1399  _gws.current = 0;
1400  _gws.total = 0;
1401  _gws.percent = 0;
1402  _gws.next_update = std::chrono::steady_clock::now();
1403 }
1404 
1409 {
1410  if (BringWindowToFrontById(WC_MODAL_PROGRESS, 0)) return;
1411  new GenerateProgressWindow();
1412 }
1413 
1414 static void _SetGeneratingWorldProgress(GenWorldProgress cls, uint progress, uint total)
1415 {
1416  static const int percent_table[] = {0, 5, 14, 17, 20, 40, 60, 65, 80, 85, 95, 99, 100 };
1417  static_assert(lengthof(percent_table) == GWP_CLASS_COUNT + 1);
1418  assert(cls < GWP_CLASS_COUNT);
1419 
1420  /* Check if we really are generating the world.
1421  * For example, placing trees via the SE also calls this function, but
1422  * shouldn't try to update the progress.
1423  */
1424  if (!HasModalProgress()) return;
1425 
1426  if (IsGeneratingWorldAborted()) {
1428  return;
1429  }
1430 
1431  if (total == 0) {
1432  assert(_gws.cls == _generation_class_table[cls]);
1433  _gws.current += progress;
1434  assert(_gws.current <= _gws.total);
1435  } else {
1436  _gws.cls = _generation_class_table[cls];
1437  _gws.current = progress;
1438  _gws.total = total;
1439  _gws.percent = percent_table[cls];
1440  }
1441 
1442  /* Percentage is about the number of completed tasks, so 'current - 1' */
1443  _gws.percent = percent_table[cls] + (percent_table[cls + 1] - percent_table[cls]) * (_gws.current == 0 ? 0 : _gws.current - 1) / _gws.total;
1444 
1445  if (_network_dedicated) {
1446  static uint last_percent = 0;
1447 
1448  /* Never display 0% */
1449  if (_gws.percent == 0) return;
1450  /* Reset if percent is lower than the last recorded */
1451  if (_gws.percent < last_percent) last_percent = 0;
1452  /* Display every 5%, but 6% is also very valid.. just not smaller steps than 5% */
1453  if (_gws.percent % 5 != 0 && _gws.percent <= last_percent + 5) return;
1454  /* Never show steps smaller than 2%, even if it is a mod 5% */
1455  if (_gws.percent <= last_percent + 2) return;
1456 
1457  Debug(net, 3, "Map generation percentage complete: {}", _gws.percent);
1458  last_percent = _gws.percent;
1459 
1460  return;
1461  }
1462 
1464 
1466 }
1467 
1477 {
1478  if (total == 0) return;
1479 
1480  _SetGeneratingWorldProgress(cls, 0, total);
1481 }
1482 
1491 {
1492  /* In fact the param 'class' isn't needed.. but for some security reasons, we want it around */
1493  _SetGeneratingWorldProgress(cls, 1, 0);
1494 }
FileToSaveLoad::title
char title[255]
Internal name of the game.
Definition: saveload.h:362
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:1894
sound_func.h
GameCreationSettings::generation_seed
uint32 generation_seed
noise seed for world generation
Definition: settings_type.h:307
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:1370
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:3136
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:1327
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:328
ShowCreateScenario
void ShowCreateScenario()
Show the window to create a scenario.
Definition: genworld_gui.cpp:1264
AbortGeneratingWorld
void AbortGeneratingWorld()
Initializes the abortion process.
Definition: genworld.cpp:237
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:1141
GameCreationSettings::map_y
uint8 map_y
Y size of map.
Definition: settings_type.h:311
dropdown_func.h
GameCreationSettings::landscape
byte landscape
the landscape we're currently in
Definition: settings_type.h:323
GameCreationSettings::tgen_smoothness
byte tgen_smoothness
how rough is the terrain from 0-3
Definition: settings_type.h:318
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:836
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:361
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:336
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:580
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:326
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:1334
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:322
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:53
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:645
MIN_CUSTOM_TERRAIN_TYPE
static const uint MIN_CUSTOM_TERRAIN_TYPE
Lowest possible peak value for world generation.
Definition: tile_type.h:27
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget 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:1097
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:24
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:973
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:1109
GameCreationSettings::heightmap_height
byte heightmap_height
highest mountain for heightmap (towards what it scales)
Definition: settings_type.h:317
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:891
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:1071
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:581
_nested_heightmap_load_widgets
static const NWidgetPart _nested_heightmap_load_widgets[]
Widgets of GenerateLandscapeWindow when loading heightmap.
Definition: genworld_gui.cpp:194
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:464
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:1396
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:601
SetMouseCursor
void SetMouseCursor(CursorID sprite, PaletteID pal)
Assign a single non-animated sprite to the cursor.
Definition: gfx.cpp:1909
ShowGenerateLandscape
void ShowGenerateLandscape()
Start with a normal game.
Definition: genworld_gui.cpp:996
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:30
DifficultySettings::terrain_type
byte terrain_type
the mountainousness of the landscape
Definition: settings_type.h:87
GameCreationSettings::custom_town_number
uint16 custom_town_number
manually entered number of towns
Definition: settings_type.h:325
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:37
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:324
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:821
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:1125
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:327
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:348
WF_TIMEOUT
@ WF_TIMEOUT
Window timeout counter.
Definition: window_gui.h:234
CreateScenarioWindow
Definition: genworld_gui.cpp:1025
StrEmpty
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:67
DifficultySettings::quantity_sea_lakes
byte quantity_sea_lakes
the amount of seas/lakes
Definition: settings_type.h:88
DifficultySettings::industry_density
byte industry_density
The industry density.
Definition: settings_type.h:78
GameCreationSettings::se_flat_world_height
byte se_flat_world_height
land height a flat world gets in SE
Definition: settings_type.h:321
GenWorldStatus
Definition: genworld_gui.cpp:1291
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:61
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:1490
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:3174
VideoDriver::GetInstance
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Definition: video_driver.hpp:204
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:1002
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:1017
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:1349
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:26
_switch_mode
SwitchMode _switch_mode
The next mainloop command.
Definition: gfx.cpp:49
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:540
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:211
GameCreationSettings::heightmap_rotation
byte heightmap_rotation
rotation director for the heightmap
Definition: settings_type.h:320
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:1094
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:29
MAX_MAP_SIZE_BITS
static const uint MAX_MAP_SIZE_BITS
Maximal size of map is equal to 2 ^ MAX_MAP_SIZE_BITS.
Definition: map_type.h: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:1408
GenerateLandscapeWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: genworld_gui.cpp:394
HandleGeneratingWorldAbortion
void HandleGeneratingWorldAbortion()
Really handle the abortion, i.e.
Definition: genworld.cpp:254
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:310
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:316
GameCreationSettings::amount_of_rivers
byte amount_of_rivers
the amount of rivers
Definition: settings_type.h:331
GameCreationSettings::land_generator
byte land_generator
the landscape generator
Definition: settings_type.h:312
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:168
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:1209
geometry_func.hpp
CreateScenarioWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: genworld_gui.cpp:1162
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:3251
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1012
_file_to_saveload
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
Definition: saveload.cpp:63
GenerateLandscapeWindow
Definition: genworld_gui.cpp:367
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:628
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:1182
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:308
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:386
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:1171
IsGeneratingWorldAborted
bool IsGeneratingWorldAborted()
Is the generation being aborted?
Definition: genworld.cpp:246
GameCreationSettings::snow_coverage
byte snow_coverage
the amount of snow coverage on the map
Definition: settings_type.h:315
_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:1008
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:1078
ID_END
@ ID_END
Number of industry density settings.
Definition: settings_type.h:61
SetGeneratingWorldProgress
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
Definition: genworld_gui.cpp:1476
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition: settings_type.h:582
WD_DROPDOWNTEXT_BOTTOM
@ WD_DROPDOWNTEXT_BOTTOM
Bottom offset of the dropdown widget string.
Definition: window_gui.h:137
SetTextColour
static NWidgetPart SetTextColour(TextColour colour)
Widget part function for setting the text colour.
Definition: widget_type.h:1047
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:3299
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:359
GetMapHeightLimit
static uint GetMapHeightLimit()
Get the map height limit, or if set to "auto", the absolute limit.
Definition: genworld_gui.cpp:51
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:113
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:77
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:1056
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:402
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:894
_left_button_clicked
bool _left_button_clicked
Is left mouse button clicked?
Definition: gfx.cpp:42
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:1035
CreateScenarioWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: genworld_gui.cpp:1173
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
SetDParamStr
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Definition: strings.cpp:296
_settings_newgame
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Definition: settings.cpp:55
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:472
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:36
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