OpenTTD Source  13.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 #include "ai/ai_gui.hpp"
34 #include "game/game_gui.hpp"
35 
37 
38 #include "safeguards.h"
39 
40 
41 extern void MakeNewgameSettingsLive();
42 
48 };
49 
53 static uint GetMapHeightLimit()
54 {
57 }
58 
63 void SetNewLandscapeType(byte landscape)
64 {
68 }
69 
73  NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
74  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_MAPGEN_WORLD_GENERATION_CAPTION, STR_NULL),
75  EndContainer(),
76  NWidget(WWT_PANEL, COLOUR_BROWN),
78  /* Landscape selection. */
79  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 10),
80  NWidget(NWID_SPACER), SetFill(1, 0),
81  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TEMPERATE), SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
82  NWidget(NWID_SPACER), SetFill(1, 0),
83  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_ARCTIC), SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
84  NWidget(NWID_SPACER), SetFill(1, 0),
85  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TROPICAL), SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
86  NWidget(NWID_SPACER), SetFill(1, 0),
87  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TOYLAND), SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
88  NWidget(NWID_SPACER), SetFill(1, 0),
89  EndContainer(),
91  /* Generation options. */
92  NWidget(NWID_HORIZONTAL), SetPIP(10, 5, 10),
93  /* Left half (land generation options) */
95  NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0),
96  /* Labels on the left side (global column 1). */
98  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAPSIZE, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
99  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_LAND_GENERATOR, STR_NULL), SetFill(1, 1),
100  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_TERRAIN_TYPE, STR_NULL), SetFill(1, 1),
101  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_VARIETY, STR_NULL), SetFill(1, 1),
102  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SMOOTHNESS, STR_NULL), SetFill(1, 1),
103  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_NULL), SetFill(1, 1),
104  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BORDER_TYPE, STR_NULL), SetFill(1, 1),
105  EndContainer(),
106  /* Widgets on the right side (global column 2). */
108  /* Mapsize X * Y. */
109  NWidget(NWID_HORIZONTAL), SetPIP(0, 4, 0),
110  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_X_PULLDOWN), SetDataTip(STR_JUST_INT, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 0),
111  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BY, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(1, 1),
112  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_Y_PULLDOWN), SetDataTip(STR_JUST_INT, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 0),
113  EndContainer(),
114  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_LANDSCAPE_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
115  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TERRAIN_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
116  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_VARIETY_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
117  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_SMOOTHNESS_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
118  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_RIVER_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
119  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_BORDERS_RANDOM), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
120  EndContainer(),
121  EndContainer(),
122  EndContainer(),
123  /* Right half (all other options) */
125  NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0),
126  /* Labels on the left side (global column 3). */
129  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SNOW_COVERAGE, STR_NULL), SetFill(1, 1),
130  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DESERT_COVERAGE, STR_NULL), SetFill(1, 1),
132  EndContainer(),
133  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_NULL), SetFill(1, 1),
134  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_TOWN_NAME_LABEL, STR_NULL), SetFill(1, 1),
135  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_TOWNS, STR_NULL), SetFill(1, 1),
136  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES, STR_NULL), SetFill(1, 1),
137  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SEA_LEVEL, STR_NULL), SetFill(1, 1),
138  EndContainer(),
139  /* Widgets on the right side (global column 4). */
141  /* Climate selector. */
143  /* Snow coverage. */
145  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_COVERAGE_DOWN), SetFill(0, 1),
146  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_TEXT), SetDataTip(STR_MAPGEN_SNOW_COVERAGE_TEXT, STR_NULL), SetFill(1, 0),
147  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_COVERAGE_UP), SetFill(0, 1),
148  EndContainer(),
149  /* Desert coverage. */
151  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_DESERT_COVERAGE_DOWN), SetFill(0, 1),
152  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_TEXT), SetDataTip(STR_MAPGEN_DESERT_COVERAGE_TEXT, STR_NULL), SetFill(1, 0),
153  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_DESERT_COVERAGE_UP), SetFill(0, 1),
154  EndContainer(),
155  /* Temperate/Toyland spacer. */
157  EndContainer(),
158  /* Starting date. */
160  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),
161  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetDataTip(STR_BLACK_DATE_LONG, STR_NULL), SetFill(1, 0),
162  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),
163  EndContainer(),
164  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWNNAME_DROPDOWN), SetDataTip(STR_BLACK_STRING, STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP), SetFill(1, 0),
165  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWN_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
166  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_INDUSTRY_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
167  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_WATER_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
168  EndContainer(),
169  EndContainer(),
170  EndContainer(),
171  EndContainer(),
173  /* Map borders buttons for each edge. */
175  NWidget(NWID_HORIZONTAL), SetPIP(0, 0, 3),
176  NWidget(NWID_SPACER), SetFill(1, 1),
177  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NORTHWEST, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(0, 1),
178  EndContainer(),
179  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_NW), SetDataTip(STR_JUST_STRING, STR_MAPGEN_NORTHWEST), SetFill(1, 1),
180  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_NE), SetDataTip(STR_JUST_STRING, STR_MAPGEN_NORTHEAST), SetFill(1, 1),
181  NWidget(NWID_HORIZONTAL), SetPIP(3, 0, 0),
182  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NORTHEAST, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(0, 1),
183  NWidget(NWID_SPACER), SetFill(1, 1),
184  EndContainer(),
185  EndContainer(),
187  NWidget(NWID_HORIZONTAL), SetPIP(0, 0, 3),
188  NWidget(NWID_SPACER), SetFill(1, 1),
189  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SOUTHWEST, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(0, 1),
190  EndContainer(),
191  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_SW), SetDataTip(STR_JUST_STRING, STR_MAPGEN_SOUTHWEST), SetFill(1, 1),
192  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_SE), SetDataTip(STR_JUST_STRING, STR_MAPGEN_SOUTHEAST), SetFill(1, 1),
193  NWidget(NWID_HORIZONTAL), SetPIP(3, 0, 0),
194  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SOUTHEAST, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(0, 1),
195  NWidget(NWID_SPACER), SetFill(1, 1),
196  EndContainer(),
197  EndContainer(),
198  NWidget(NWID_SPACER), SetMinimalSize(0, 6), SetFill(1, 1),
199  /* AI, GS, and NewGRF settings */
201  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_AI_BUTTON), SetMinimalSize(0, 24), SetDataTip(STR_MAPGEN_AI_SETTINGS, STR_MAPGEN_AI_SETTINGS_TOOLTIP), SetFill(1, 0),
202  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_GS_BUTTON), SetMinimalSize(0, 24), SetDataTip(STR_MAPGEN_GS_SETTINGS, STR_MAPGEN_GS_SETTINGS_TOOLTIP), SetFill(1, 0),
203  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_NEWGRF_BUTTON), SetMinimalSize(0, 24), SetDataTip(STR_MAPGEN_NEWGRF_SETTINGS, STR_MAPGEN_NEWGRF_SETTINGS_TOOLTIP), SetFill(1, 0),
204  EndContainer(),
205  NWidget(NWID_SPACER), SetMinimalSize(0, 7), SetFill(1, 1),
206  /* Generate */
207  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_GL_GENERATE_BUTTON), SetMinimalSize(84, 36), SetDataTip(STR_MAPGEN_GENERATE, STR_NULL), SetPadding(0, 10, 0, 10), SetFill(1, 1),
208  NWidget(NWID_SPACER), SetMinimalSize(0, 9), SetFill(1, 1),
209  EndContainer(),
210 };
211 
214  /* Window header. */
216  NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
217  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_MAPGEN_WORLD_GENERATION_CAPTION, STR_NULL),
218  EndContainer(),
219  NWidget(WWT_PANEL, COLOUR_BROWN),
221  /* Landscape selection. */
222  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 10),
223  NWidget(NWID_SPACER), SetFill(1, 0),
224  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TEMPERATE), SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
225  NWidget(NWID_SPACER), SetFill(1, 0),
226  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_ARCTIC), SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
227  NWidget(NWID_SPACER), SetFill(1, 0),
228  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TROPICAL), SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
229  NWidget(NWID_SPACER), SetFill(1, 0),
230  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TOYLAND), SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
231  NWidget(NWID_SPACER), SetFill(1, 0),
232  EndContainer(),
233  NWidget(NWID_SPACER), SetMinimalSize(0, 11), SetFill(0, 1),
234  /* Generation options. */
235  NWidget(NWID_HORIZONTAL), SetPIP(10, 3, 10),
236  /* Left half labels (global column 1) and heightmap name label */
238  /* Heightmap name label. */
239  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_NAME, STR_NULL), SetFill(1, 1),
240  /* Land generation option labels */
241  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_SIZE_LABEL, STR_NULL), SetFill(1, 1),
242  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAPSIZE, STR_NULL), SetFill(1, 1),
243  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_ROTATION, STR_NULL), SetFill(1, 1),
244  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_HEIGHT, STR_NULL), SetFill(1, 1),
245  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_NULL), SetFill(1, 1),
246  EndContainer(),
247  /* All other columns. */
248  NWidget(NWID_VERTICAL), SetPIP(0, 4, 0),
249  NWidget(WWT_TEXT, COLOUR_ORANGE, WID_GL_HEIGHTMAP_NAME_TEXT), SetTextColour(TC_ORANGE), SetDataTip(STR_JUST_RAW_STRING, STR_EMPTY), SetFill(1, 0),
250  NWidget(NWID_HORIZONTAL), SetPIP(0, 5, 0),
251  /* Left half widgets (global column 2) */
253  NWidget(WWT_TEXT, COLOUR_ORANGE, WID_GL_HEIGHTMAP_SIZE_TEXT), SetDataTip(STR_MAPGEN_HEIGHTMAP_SIZE, STR_NULL), SetFill(1, 0),
254  /* Mapsize X * Y. */
255  NWidget(NWID_HORIZONTAL), SetPIP(0, 4, 0),
256  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_X_PULLDOWN), SetDataTip(STR_JUST_INT, STR_NULL), SetFill(1, 0),
257  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BY, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(1, 1),
258  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_Y_PULLDOWN), SetDataTip(STR_JUST_INT, STR_NULL), SetFill(1, 0),
259  EndContainer(),
260  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_ROTATION_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
261  /* Heightmap highest peak. */
263  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_HEIGHTMAP_HEIGHT_DOWN), SetFill(0, 1),
264  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL), SetFill(1, 0),
265  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_HEIGHTMAP_HEIGHT_UP), SetFill(0, 1),
266  EndContainer(),
267  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_RIVER_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
268  EndContainer(),
269  NWidget(NWID_VERTICAL), SetPIP(0, 4, 0),
270  NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0),
271  /* Right half labels (global column 3) */
274  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SNOW_COVERAGE, STR_NULL), SetFill(1, 1),
275  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DESERT_COVERAGE, STR_NULL), SetFill(1, 1),
277  EndContainer(),
278  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_NULL), SetFill(1, 1),
279  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_TOWN_NAME_LABEL, STR_NULL), SetFill(1, 1),
280  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_TOWNS, STR_NULL), SetFill(1, 1),
281  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES, STR_NULL), SetFill(1, 1),
282  EndContainer(),
283  /* Right half widgets (global column 4) */
285  /* Climate selector. */
287  /* Snow coverage. */
289  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_COVERAGE_DOWN), SetFill(0, 1),
290  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_TEXT), SetDataTip(STR_MAPGEN_SNOW_COVERAGE_TEXT, STR_NULL), SetFill(1, 0),
291  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_COVERAGE_UP), SetFill(0, 1),
292  EndContainer(),
293  /* Desert coverage. */
295  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_DESERT_COVERAGE_DOWN), SetFill(0, 1),
296  NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_TEXT), SetDataTip(STR_MAPGEN_DESERT_COVERAGE_TEXT, STR_NULL), SetFill(1, 0),
297  NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_DESERT_COVERAGE_UP), SetFill(0, 1),
298  EndContainer(),
299  /* Temperate/Toyland spacer. */
301  EndContainer(),
302  /* Starting date. */
304  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),
305  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetDataTip(STR_BLACK_DATE_LONG, STR_NULL), SetFill(1, 0),
306  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),
307  EndContainer(),
308  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWNNAME_DROPDOWN), SetDataTip(STR_BLACK_STRING, STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP), SetFill(1, 0),
309  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWN_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
310  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_INDUSTRY_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0),
311  EndContainer(),
312  EndContainer(),
313  EndContainer(),
314  EndContainer(),
315  EndContainer(),
316  EndContainer(),
317  NWidget(NWID_SPACER), SetMinimalSize(0, 6), SetFill(1, 1),
318  /* AI, GS, and NewGRF settings */
320  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_AI_BUTTON), SetMinimalSize(0, 24), SetDataTip(STR_MAPGEN_AI_SETTINGS, STR_MAPGEN_AI_SETTINGS_TOOLTIP), SetFill(1, 0),
321  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_GS_BUTTON), SetMinimalSize(0, 24), SetDataTip(STR_MAPGEN_GS_SETTINGS, STR_MAPGEN_GS_SETTINGS_TOOLTIP), SetFill(1, 0),
322  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_NEWGRF_BUTTON), SetMinimalSize(0, 24), SetDataTip(STR_MAPGEN_NEWGRF_SETTINGS, STR_MAPGEN_NEWGRF_SETTINGS_TOOLTIP), SetFill(1, 0),
323  EndContainer(),
324  NWidget(NWID_SPACER), SetMinimalSize(0, 7), SetFill(1, 1),
325  /* Generate */
326  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_GL_GENERATE_BUTTON), SetMinimalSize(84, 36), SetDataTip(STR_MAPGEN_GENERATE, STR_NULL), SetPadding(0, 10, 0, 10), SetFill(1, 1),
327  NWidget(NWID_SPACER), SetMinimalSize(0, 9), SetFill(1, 1),
328  EndContainer(),
329 };
330 
331 static void StartGeneratingLandscape(GenerateLandscapeWindowMode mode)
332 {
335 
336  /* Copy all XXX_newgame to XXX when coming from outside the editor */
337  MakeNewgameSettingsLive();
338  ResetGRFConfig(true);
339 
340  if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP);
341  switch (mode) {
342  case GLWM_GENERATE: _switch_mode = (_game_mode == GM_EDITOR) ? SM_GENRANDLAND : SM_NEWGAME; break;
343  case GLWM_HEIGHTMAP: _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_HEIGHTMAP : SM_START_HEIGHTMAP; break;
344  case GLWM_SCENARIO: _switch_mode = SM_EDITOR; break;
345  default: NOT_REACHED();
346  }
347 }
348 
349 static void LandscapeGenerationCallback(Window *w, bool confirmed)
350 {
351  if (confirmed) StartGeneratingLandscape((GenerateLandscapeWindowMode)w->window_number);
352 }
353 
354 static DropDownList BuildMapsizeDropDown()
355 {
356  DropDownList list;
357 
358  for (uint i = MIN_MAP_SIZE_BITS; i <= MAX_MAP_SIZE_BITS; i++) {
359  DropDownListParamStringItem *item = new DropDownListParamStringItem(STR_JUST_INT, i, false);
360  item->SetParam(0, 1LL << i);
361  list.emplace_back(item);
362  }
363 
364  return list;
365 }
366 
367 static DropDownList BuildTownNameDropDown()
368 {
369  DropDownList list;
370 
371  /* Add and sort newgrf townnames generators */
372  const auto &grf_names = GetGRFTownNameList();
373  for (uint i = 0; i < grf_names.size(); i++) {
374  list.emplace_back(new DropDownListStringItem(grf_names[i], BUILTIN_TOWNNAME_GENERATOR_COUNT + i, false));
375  }
376  std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
377 
378  size_t newgrf_size = list.size();
379  /* Insert newgrf_names at the top of the list */
380  if (newgrf_size > 0) {
381  list.emplace_back(new DropDownListItem(-1, false)); // separator line
382  newgrf_size++;
383  }
384 
385  /* Add and sort original townnames generators */
386  for (uint i = 0; i < BUILTIN_TOWNNAME_GENERATOR_COUNT; i++) {
387  list.emplace_back(new DropDownListStringItem(STR_MAPGEN_TOWN_NAME_ORIGINAL_ENGLISH + i, i, false));
388  }
389  std::sort(list.begin() + newgrf_size, list.end(), DropDownListStringItem::NatSortFunc);
390 
391  return list;
392 }
393 
394 
395 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};
396 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};
397 static const StringID _rivers[] = {STR_RIVERS_NONE, STR_RIVERS_FEW, STR_RIVERS_MODERATE, STR_RIVERS_LOT, INVALID_STRING_ID};
398 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};
399 static const StringID _rotation[] = {STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE, INVALID_STRING_ID};
400 static const StringID _landscape[] = {STR_CONFIG_SETTING_LAND_GENERATOR_ORIGINAL, STR_CONFIG_SETTING_LAND_GENERATOR_TERRA_GENESIS, INVALID_STRING_ID};
401 static const StringID _num_towns[] = {STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM, INVALID_STRING_ID};
402 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};
403 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};
404 
405 static_assert(lengthof(_num_inds) == ID_END + 1);
406 
408  uint widget_id;
409  uint x;
410  uint y;
411  char name[64];
413 
414  GenerateLandscapeWindow(WindowDesc *desc, WindowNumber number = 0) : Window(desc)
415  {
416  this->InitNested(number);
417 
419 
420  this->mode = (GenerateLandscapeWindowMode)this->window_number;
421 
422  /* Disable town and industry in SE */
423  this->SetWidgetDisabledState(WID_GL_TOWN_PULLDOWN, _game_mode == GM_EDITOR);
424  this->SetWidgetDisabledState(WID_GL_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR);
425 
426  /* In case the map_height_limit is changed, clamp heightmap_height and custom_terrain_type. */
429 
430  this->OnInvalidateData();
431  }
432 
433 
434  void SetStringParameters(int widget) const override
435  {
436  switch (widget) {
443 
445  if (_game_mode == GM_EDITOR) {
446  SetDParam(0, STR_CONFIG_SETTING_OFF);
448  SetDParam(0, STR_NUM_CUSTOM_NUMBER);
450  } else {
452  }
453  break;
454 
458  STR_MAPGEN_TOWN_NAME_ORIGINAL_ENGLISH + gen :
459  GetGRFTownNameName(gen - BUILTIN_TOWNNAME_GENERATOR_COUNT);
460  SetDParam(0, name);
461  break;
462  }
463 
464  case WID_GL_INDUSTRY_PULLDOWN: SetDParam(0, _game_mode == GM_EDITOR ? STR_CONFIG_SETTING_OFF : _num_inds[_settings_newgame.difficulty.industry_density]); break;
468  SetDParam(0, STR_TERRAIN_TYPE_CUSTOM_VALUE);
470  } else {
471  SetDParam(0, _elevations[_settings_newgame.difficulty.terrain_type]); break;
472  }
473  break;
474 
477  SetDParam(0, STR_SEA_LEVEL_CUSTOM_PERCENTAGE);
479  } else {
481  }
482  break;
483 
484  case WID_GL_HEIGHTMAP_NAME_TEXT: SetDParamStr(0, this->name); break;
488  case WID_GL_BORDERS_RANDOM: SetDParam(0, (_settings_newgame.game_creation.water_borders == BORDERS_RANDOM) ? STR_MAPGEN_BORDER_RANDOMIZE : STR_MAPGEN_BORDER_MANUAL); break;
489  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;
490  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;
491  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;
492  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;
494 
497  SetDParam(0, this->y);
498  SetDParam(1, this->x);
499  } else {
500  SetDParam(0, this->x);
501  SetDParam(1, this->y);
502  }
503  break;
504  }
505  }
506 
512  void OnInvalidateData(int data = 0, bool gui_scope = true) override
513  {
514  if (!gui_scope) return;
515  /* Update the climate buttons */
520 
521  /* You can't select smoothness / non-water borders if not terragenesis */
522  if (mode == GLWM_GENERATE) {
528 
530 
535 
538  }
539 
540  /* Disable snowline if not arctic */
542  /* Disable desert if not tropic */
544 
545  /* Set snow/rainforest selections */
546  int climate_plane = 0;
548  case LT_TEMPERATE: climate_plane = 2; break;
549  case LT_ARCTIC: climate_plane = 0; break;
550  case LT_TROPIC: climate_plane = 1; break;
551  case LT_TOYLAND: climate_plane = 2; break;
552  }
553  this->GetWidget<NWidgetStacked>(WID_GL_CLIMATE_SEL_LABEL)->SetDisplayedPlane(climate_plane);
554  this->GetWidget<NWidgetStacked>(WID_GL_CLIMATE_SEL_SELECTOR)->SetDisplayedPlane(climate_plane);
555 
556  /* Update availability of decreasing / increasing start date and snow level */
557  if (mode == GLWM_HEIGHTMAP) {
560  }
567 
568  /* Do not allow a custom sea level or terrain type with the original land generator. */
572  }
575  }
576  }
577 
578  }
579 
580  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
581  {
582  const StringID *strs = nullptr;
583  switch (widget) {
586  *size = GetStringBoundingBox(STR_JUST_INT);
587  break;
588 
591  *size = maxdim(*size, GetStringBoundingBox(STR_BLACK_DATE_LONG));
592  break;
593 
597  *size = maxdim(*size, GetStringBoundingBox(STR_JUST_INT));
598  break;
599 
602  *size = maxdim(*size, GetStringBoundingBox(STR_MAPGEN_SNOW_COVERAGE_TEXT));
603  break;
604 
607  *size = maxdim(*size, GetStringBoundingBox(STR_MAPGEN_DESERT_COVERAGE_TEXT));
608  break;
609 
611  SetDParam(0, this->x);
612  SetDParam(1, this->y);
613  *size = maxdim(*size, GetStringBoundingBox(STR_MAPGEN_HEIGHTMAP_SIZE));
614  break;
615 
617  strs = _num_towns;
619  *size = maxdim(*size, GetStringBoundingBox(STR_NUM_CUSTOM_NUMBER));
620  break;
621 
622  case WID_GL_INDUSTRY_PULLDOWN: strs = _num_inds; break;
623  case WID_GL_LANDSCAPE_PULLDOWN: strs = _landscape; break;
624 
626  strs = _elevations;
628  *size = maxdim(*size, GetStringBoundingBox(STR_TERRAIN_TYPE_CUSTOM_VALUE));
629  break;
630 
632  strs = _sea_lakes;
634  *size = maxdim(*size, GetStringBoundingBox(STR_SEA_LEVEL_CUSTOM_PERCENTAGE));
635  break;
636 
637  case WID_GL_RIVER_PULLDOWN: strs = _rivers; break;
638  case WID_GL_SMOOTHNESS_PULLDOWN: strs = _smoothness; break;
639  case WID_GL_VARIETY_PULLDOWN: strs = _variety; break;
640  case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: strs = _rotation; break;
642  *size = maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_RANDOMIZE), GetStringBoundingBox(STR_MAPGEN_BORDER_MANUAL));
643  break;
644 
645  case WID_GL_WATER_NE:
646  case WID_GL_WATER_NW:
647  case WID_GL_WATER_SE:
648  case WID_GL_WATER_SW:
649  *size = maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_RANDOM), maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_WATER), GetStringBoundingBox(STR_MAPGEN_BORDER_FREEFORM)));
650  break;
651 
653  size->width = 0;
654  break;
655 
656  default:
657  return;
658  }
659  if (strs != nullptr) {
660  while (*strs != INVALID_STRING_ID) {
661  *size = maxdim(*size, GetStringBoundingBox(*strs++));
662  }
663  }
664  size->width += padding.width;
665  size->height = std::max(size->height, (uint)(FONT_HEIGHT_NORMAL + padding.height));
666  }
667 
668  void OnClick(Point pt, int widget, int click_count) override
669  {
670  switch (widget) {
671  case WID_GL_TEMPERATE:
672  case WID_GL_ARCTIC:
673  case WID_GL_TROPICAL:
674  case WID_GL_TOYLAND:
676  break;
677 
678  case WID_GL_MAPSIZE_X_PULLDOWN: // Mapsize X
680  break;
681 
682  case WID_GL_MAPSIZE_Y_PULLDOWN: // Mapsize Y
684  break;
685 
686  case WID_GL_TOWN_PULLDOWN: // Number of towns
688  break;
689 
690  case WID_GL_TOWNNAME_DROPDOWN: // Townname generator
692  break;
693 
694  case WID_GL_INDUSTRY_PULLDOWN: // Number of industries
696  break;
697 
698  case WID_GL_GENERATE_BUTTON: { // Generate
699  /* Get rotated map size. */
700  uint map_x;
701  uint map_y;
703  map_x = this->y;
704  map_y = this->x;
705  } else {
706  map_x = this->x;
707  map_y = this->y;
708  }
709  if (mode == GLWM_HEIGHTMAP &&
710  (map_x * 2 < (1U << _settings_newgame.game_creation.map_x) ||
711  map_x / 2 > (1U << _settings_newgame.game_creation.map_x) ||
712  map_y * 2 < (1U << _settings_newgame.game_creation.map_y) ||
713  map_y / 2 > (1U << _settings_newgame.game_creation.map_y))) {
714  ShowQuery(
715  STR_WARNING_HEIGHTMAP_SCALE_CAPTION,
716  STR_WARNING_HEIGHTMAP_SCALE_MESSAGE,
717  this,
718  LandscapeGenerationCallback);
719  } else {
720  StartGeneratingLandscape(mode);
721  }
722  break;
723  }
724 
726  case WID_GL_HEIGHTMAP_HEIGHT_UP: // Height level buttons
727  /* Don't allow too fast scrolling */
728  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
729  this->HandleButtonClick(widget);
730 
732  this->InvalidateData();
733  }
734  _left_button_clicked = false;
735  break;
736 
737  case WID_GL_HEIGHTMAP_HEIGHT_TEXT: // Height level text
738  this->widget_id = WID_GL_HEIGHTMAP_HEIGHT_TEXT;
740  ShowQueryString(STR_JUST_INT, STR_MAPGEN_HEIGHTMAP_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
741  break;
742 
743 
745  case WID_GL_START_DATE_UP: // Year 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_START_DATE_TEXT: // Year text
757  this->widget_id = WID_GL_START_DATE_TEXT;
759  ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
760  break;
761 
763  case WID_GL_SNOW_COVERAGE_UP: // Snow coverage buttons
764  /* Don't allow too fast scrolling */
765  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
766  this->HandleButtonClick(widget);
767 
769  this->InvalidateData();
770  }
771  _left_button_clicked = false;
772  break;
773 
774  case WID_GL_SNOW_COVERAGE_TEXT: // Snow coverage text
775  this->widget_id = WID_GL_SNOW_COVERAGE_TEXT;
777  ShowQueryString(STR_JUST_INT, STR_MAPGEN_SNOW_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
778  break;
779 
781  case WID_GL_DESERT_COVERAGE_UP: // Desert coverage buttons
782  /* Don't allow too fast scrolling */
783  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
784  this->HandleButtonClick(widget);
785 
787  this->InvalidateData();
788  }
789  _left_button_clicked = false;
790  break;
791 
792  case WID_GL_DESERT_COVERAGE_TEXT: // Desert line text
793  this->widget_id = WID_GL_DESERT_COVERAGE_TEXT;
795  ShowQueryString(STR_JUST_INT, STR_MAPGEN_DESERT_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
796  break;
797 
798  case WID_GL_LANDSCAPE_PULLDOWN: // Landscape generator
800  break;
801 
802  case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: // Heightmap rotation
804  break;
805 
806  case WID_GL_TERRAIN_PULLDOWN: // Terrain type
807  /* For the original map generation only the first four are valid. */
809  break;
810 
811  case WID_GL_WATER_PULLDOWN: { // Water quantity
812  uint32 hidden_mask = 0;
813  /* Disable custom water level when the original map generator is active. */
816  }
818  break;
819  }
820 
821  case WID_GL_RIVER_PULLDOWN: // Amount of rivers
823  break;
824 
825  case WID_GL_SMOOTHNESS_PULLDOWN: // Map smoothness
827  break;
828 
829  case WID_GL_VARIETY_PULLDOWN: // Map variety
831  break;
832 
833  /* Freetype map borders */
834  case WID_GL_WATER_NW:
836  this->InvalidateData();
837  break;
838 
839  case WID_GL_WATER_NE:
841  this->InvalidateData();
842  break;
843 
844  case WID_GL_WATER_SE:
846  this->InvalidateData();
847  break;
848 
849  case WID_GL_WATER_SW:
851  this->InvalidateData();
852  break;
853 
856  this->InvalidateData();
857  break;
858 
859  case WID_GL_AI_BUTTON:
861  break;
862 
863  case WID_GL_GS_BUTTON:
865  break;
866 
867  case WID_GL_NEWGRF_BUTTON:
868  ShowNewGRFSettings(true, true, false, &_grfconfig_newgame);
869  break;
870  }
871  }
872 
873  void OnTimeout() override
874  {
877 
878  const int *widget = (mode == GLWM_HEIGHTMAP) ? heightmap_raise_widgets : newgame_raise_widgets;
879 
880  for (; *widget != WIDGET_LIST_END; widget++) {
881  if (this->IsWidgetLowered(*widget)) {
882  this->RaiseWidget(*widget);
883  this->SetWidgetDirty(*widget);
884  }
885  }
886  }
887 
888  void OnDropdownSelect(int widget, int index) override
889  {
890  switch (widget) {
896 
898  /* If original landgenerator is selected and alpinist terrain_type was selected, revert to mountainous. */
901  }
902  break;
903 
905 
907  if ((uint)index == CUSTOM_TOWN_NUMBER_DIFFICULTY) {
908  this->widget_id = widget;
910  ShowQueryString(STR_JUST_INT, STR_MAPGEN_NUMBER_OF_TOWNS, 5, this, CS_NUMERAL, QSF_NONE);
911  }
913  break;
914 
915  case WID_GL_TOWNNAME_DROPDOWN: // Town names
916  if (_game_mode == GM_MENU || Town::GetNumItems() == 0) {
919  }
920  break;
921 
924  if ((uint)index == CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY) {
925  this->widget_id = widget;
927  ShowQueryString(STR_JUST_INT, STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_NONE);
928  }
930  break;
931  }
932 
933  case WID_GL_WATER_PULLDOWN: {
934  if ((uint)index == CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY) {
935  this->widget_id = widget;
937  ShowQueryString(STR_JUST_INT, STR_MAPGEN_SEA_LEVEL, 3, this, CS_NUMERAL, QSF_NONE);
938  }
940  break;
941  }
942  }
943  this->InvalidateData();
944  }
945 
946  void OnQueryTextFinished(char *str) override
947  {
948  /* Was 'cancel' pressed? */
949  if (str == nullptr) return;
950 
951  int32 value;
952  if (!StrEmpty(str)) {
953  value = atoi(str);
954  } else {
955  /* An empty string means revert to the default */
956  switch (this->widget_id) {
958  case WID_GL_START_DATE_TEXT: value = DEF_START_YEAR; break;
959  case WID_GL_SNOW_COVERAGE_TEXT: value = DEF_SNOW_COVERAGE; break;
961  case WID_GL_TOWN_PULLDOWN: value = 1; break;
962  case WID_GL_TERRAIN_PULLDOWN: value = MIN_MAP_HEIGHT_LIMIT; break;
964  default: NOT_REACHED();
965  }
966  }
967 
968  switch (this->widget_id) {
972  break;
973 
977  break;
978 
982  break;
983 
987  break;
988 
991  break;
992 
995  break;
996 
999  break;
1000  }
1001 
1002  this->InvalidateData();
1003  }
1004 };
1005 
1006 static WindowDesc _generate_landscape_desc(
1007  WDP_CENTER, nullptr, 0, 0,
1009  0,
1011 );
1012 
1013 static WindowDesc _heightmap_load_desc(
1014  WDP_CENTER, nullptr, 0, 0,
1016  0,
1018 );
1019 
1020 static void _ShowGenerateLandscape(GenerateLandscapeWindowMode mode)
1021 {
1022  uint x = 0;
1023  uint y = 0;
1024 
1026 
1027  /* Generate a new seed when opening the window */
1028  _settings_newgame.game_creation.generation_seed = InteractiveRandom();
1029 
1030  if (mode == GLWM_HEIGHTMAP) {
1031  /* If the function returns negative, it means there was a problem loading the heightmap */
1033  }
1034 
1035  WindowDesc *desc = (mode == GLWM_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc;
1036  GenerateLandscapeWindow *w = AllocateWindowDescFront<GenerateLandscapeWindow>(desc, mode, true);
1037 
1038  if (mode == GLWM_HEIGHTMAP) {
1039  w->x = x;
1040  w->y = y;
1041  strecpy(w->name, _file_to_saveload.title, lastof(w->name));
1042  }
1043 
1045 }
1046 
1049 {
1050  _ShowGenerateLandscape(GLWM_GENERATE);
1051 }
1052 
1055 {
1056  _ShowGenerateLandscape(GLWM_HEIGHTMAP);
1057 }
1058 
1061 {
1062  StartGeneratingLandscape(GLWM_SCENARIO);
1063 }
1064 
1069 void StartNewGameWithoutGUI(uint32 seed)
1070 {
1071  /* GenerateWorld takes care of the possible GENERATE_NEW_SEED value in 'seed' */
1073 
1074  StartGeneratingLandscape(GLWM_GENERATE);
1075 }
1076 
1078 {
1079  uint widget_id;
1080 
1082  {
1083  this->InitNested(window_number);
1085  }
1086 
1087  void SetStringParameters(int widget) const override
1088  {
1089  switch (widget) {
1092  break;
1093 
1096  break;
1097 
1100  break;
1101 
1104  break;
1105  }
1106  }
1107 
1108  void OnPaint() override
1109  {
1114 
1119 
1120  this->DrawWidgets();
1121  }
1122 
1123  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1124  {
1125  StringID str = STR_JUST_INT;
1126  switch (widget) {
1128  SetDParam(0, ConvertYMDToDate(MAX_YEAR, 0, 1));
1129  str = STR_BLACK_DATE_LONG;
1130  break;
1131 
1135  break;
1136 
1139  break;
1140 
1141  default:
1142  return;
1143  }
1144  *size = maxdim(*size, GetStringBoundingBox(str));
1145  size->width += padding.width;
1146  size->height += padding.height;
1147  }
1148 
1149  void OnClick(Point pt, int widget, int click_count) override
1150  {
1151  switch (widget) {
1152  case WID_CS_TEMPERATE:
1153  case WID_CS_ARCTIC:
1154  case WID_CS_TROPICAL:
1155  case WID_CS_TOYLAND:
1158  break;
1159 
1160  case WID_CS_MAPSIZE_X_PULLDOWN: // Mapsize X
1162  break;
1163 
1164  case WID_CS_MAPSIZE_Y_PULLDOWN: // Mapsize Y
1166  break;
1167 
1168  case WID_CS_EMPTY_WORLD: // Empty world / flat world
1169  StartGeneratingLandscape(GLWM_SCENARIO);
1170  break;
1171 
1172  case WID_CS_RANDOM_WORLD: // Generate
1174  break;
1175 
1177  case WID_CS_START_DATE_UP: // Year buttons
1178  /* Don't allow too fast scrolling */
1179  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
1180  this->HandleButtonClick(widget);
1181  this->SetDirty();
1182 
1184  }
1185  _left_button_clicked = false;
1186  break;
1187 
1188  case WID_CS_START_DATE_TEXT: // Year text
1189  this->widget_id = WID_CS_START_DATE_TEXT;
1191  ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_NONE);
1192  break;
1193 
1195  case WID_CS_FLAT_LAND_HEIGHT_UP: // Height level buttons
1196  /* Don't allow too fast scrolling */
1197  if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
1198  this->HandleButtonClick(widget);
1199  this->SetDirty();
1200 
1202  }
1203  _left_button_clicked = false;
1204  break;
1205 
1206  case WID_CS_FLAT_LAND_HEIGHT_TEXT: // Height level text
1207  this->widget_id = WID_CS_FLAT_LAND_HEIGHT_TEXT;
1209  ShowQueryString(STR_JUST_INT, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_NONE);
1210  break;
1211  }
1212  }
1213 
1214  void OnTimeout() override
1215  {
1217  for (const int *widget = raise_widgets; *widget != WIDGET_LIST_END; widget++) {
1218  if (this->IsWidgetLowered(*widget)) {
1219  this->RaiseWidget(*widget);
1220  this->SetWidgetDirty(*widget);
1221  }
1222  }
1223  }
1224 
1225  void OnDropdownSelect(int widget, int index) override
1226  {
1227  switch (widget) {
1230  }
1231  this->SetDirty();
1232  }
1233 
1234  void OnQueryTextFinished(char *str) override
1235  {
1236  if (!StrEmpty(str)) {
1237  int32 value = atoi(str);
1238 
1239  switch (this->widget_id) {
1243  break;
1244 
1248  break;
1249  }
1250 
1251  this->SetDirty();
1252  }
1253  }
1254 };
1255 
1256 static const NWidgetPart _nested_create_scenario_widgets[] = {
1258  NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
1259  NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_SE_MAPGEN_CAPTION, STR_NULL),
1260  EndContainer(),
1261  NWidget(WWT_PANEL, COLOUR_BROWN),
1263  /* Landscape style selection. */
1264  NWidget(NWID_HORIZONTAL), SetPIP(10, 3, 10),
1265  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TEMPERATE), SetDataTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
1266  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_ARCTIC), SetDataTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
1267  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TROPICAL), SetDataTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
1268  NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TOYLAND), SetDataTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
1269  EndContainer(),
1270  NWidget(NWID_HORIZONTAL), SetPIP(10, 8, 10),
1271  /* Green generation type buttons: 'Flat land' and 'Random land'. */
1272  NWidget(NWID_VERTICAL), SetPIP(10, 6, 10),
1273  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_CS_EMPTY_WORLD), SetDataTip(STR_SE_MAPGEN_FLAT_WORLD, STR_SE_MAPGEN_FLAT_WORLD_TOOLTIP), SetFill(1, 1),
1274  NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_CS_RANDOM_WORLD), SetDataTip(STR_SE_MAPGEN_RANDOM_LAND, STR_TERRAFORM_TOOLTIP_GENERATE_RANDOM_LAND), SetFill(1, 1),
1275  EndContainer(),
1276  /* Labels + setting drop-downs */
1277  NWidget(NWID_VERTICAL), SetPIP(10, 6, 10),
1278  /* Map size. */
1280  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAPSIZE, STR_NULL), SetPadding(1, 0, 0, 0),
1281  NWidget(NWID_SPACER), SetMinimalSize(6, 0), SetFill(1, 0),
1282  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_CS_MAPSIZE_X_PULLDOWN), SetDataTip(STR_JUST_INT, STR_NULL), SetPadding(0, 4, 0, 0),
1283  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BY, STR_NULL), SetPadding(1, 2, 0, 0),
1284  NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_CS_MAPSIZE_Y_PULLDOWN), SetDataTip(STR_JUST_INT, STR_NULL),
1285  EndContainer(),
1286  /* Date. */
1288  NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_NULL), SetPadding(1, 0, 0, 0),
1289  NWidget(NWID_SPACER), SetMinimalSize(6, 0), SetFill(1, 0),
1290  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),
1291  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CS_START_DATE_TEXT), SetDataTip(STR_BLACK_DATE_LONG, STR_NULL),
1292  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),
1293  EndContainer(),
1294  /* Flat map height. */
1296  NWidget(WWT_TEXT, COLOUR_ORANGE),
1297  SetDataTip(STR_SE_MAPGEN_FLAT_WORLD_HEIGHT, STR_NULL), SetPadding(1, 0, 0, 0),
1298  NWidget(NWID_SPACER), SetMinimalSize(6, 0), SetFill(1, 0),
1299  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),
1300  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CS_FLAT_LAND_HEIGHT_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL),
1301  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),
1302  EndContainer(),
1303  EndContainer(),
1304  EndContainer(),
1305  EndContainer(),
1306 };
1307 
1308 static WindowDesc _create_scenario_desc(
1309  WDP_CENTER, nullptr, 0, 0,
1311  0,
1312  _nested_create_scenario_widgets, lengthof(_nested_create_scenario_widgets)
1313 );
1314 
1317 {
1319  new CreateScenarioWindow(&_create_scenario_desc, GLWM_SCENARIO);
1320 }
1321 
1322 static const NWidgetPart _nested_generate_progress_widgets[] = {
1323  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GENERATION_WORLD, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1324  NWidget(WWT_PANEL, COLOUR_GREY),
1326  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GP_PROGRESS_BAR), SetFill(1, 0),
1327  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GP_PROGRESS_TEXT), SetFill(1, 0),
1328  NWidget(WWT_TEXTBTN, COLOUR_WHITE, WID_GP_ABORT), SetDataTip(STR_GENERATION_ABORT, STR_NULL), SetFill(1, 0),
1329  EndContainer(),
1330  EndContainer(),
1331 };
1332 
1333 
1334 static WindowDesc _generate_progress_desc(
1335  WDP_CENTER, nullptr, 0, 0,
1337  0,
1338  _nested_generate_progress_widgets, lengthof(_nested_generate_progress_widgets)
1339 );
1340 
1342  uint percent;
1343  StringID cls;
1344  uint current;
1345  uint total;
1346  std::chrono::steady_clock::time_point next_update;
1347 };
1348 
1349 static GenWorldStatus _gws;
1350 
1351 static const StringID _generation_class_table[] = {
1352  STR_GENERATION_WORLD_GENERATION,
1353  STR_SCENEDIT_TOOLBAR_LANDSCAPE_GENERATION,
1354  STR_GENERATION_RIVER_GENERATION,
1355  STR_GENERATION_CLEARING_TILES,
1356  STR_SCENEDIT_TOOLBAR_TOWN_GENERATION,
1357  STR_SCENEDIT_TOOLBAR_INDUSTRY_GENERATION,
1358  STR_GENERATION_OBJECT_GENERATION,
1359  STR_GENERATION_TREE_GENERATION,
1360  STR_GENERATION_SETTINGUP_GAME,
1361  STR_GENERATION_PREPARING_TILELOOP,
1362  STR_GENERATION_PREPARING_SCRIPT,
1363  STR_GENERATION_PREPARING_GAME
1364 };
1365 static_assert(lengthof(_generation_class_table) == GWP_CLASS_COUNT);
1366 
1367 
1368 static void AbortGeneratingWorldCallback(Window *w, bool confirmed)
1369 {
1370  if (confirmed) {
1372  } else if (HasModalProgress() && !IsGeneratingWorldAborted()) {
1373  SetMouseCursor(SPR_CURSOR_ZZZ, PAL_NONE);
1374  }
1375 }
1376 
1378 
1379  GenerateProgressWindow() : Window(&_generate_progress_desc)
1380  {
1381  this->InitNested();
1382  }
1383 
1384  void OnClick(Point pt, int widget, int click_count) override
1385  {
1386  switch (widget) {
1387  case WID_GP_ABORT:
1388  SetMouseCursorBusy(false);
1389  ShowQuery(
1390  STR_GENERATION_ABORT_CAPTION,
1391  STR_GENERATION_ABORT_MESSAGE,
1392  this,
1393  AbortGeneratingWorldCallback
1394  );
1395  break;
1396  }
1397  }
1398 
1399  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1400  {
1401  switch (widget) {
1402  case WID_GP_PROGRESS_BAR: {
1403  SetDParamMaxValue(0, 100);
1404  *size = GetStringBoundingBox(STR_GENERATION_PROGRESS);
1405  /* We need some spacing for the 'border' */
1406  size->height += WidgetDimensions::scaled.frametext.Horizontal();
1407  size->width += WidgetDimensions::scaled.frametext.Vertical();
1408  break;
1409  }
1410 
1411  case WID_GP_PROGRESS_TEXT:
1412  for (uint i = 0; i < GWP_CLASS_COUNT; i++) {
1413  size->width = std::max(size->width, GetStringBoundingBox(_generation_class_table[i]).width);
1414  }
1416  break;
1417  }
1418  }
1419 
1420  void DrawWidget(const Rect &r, int widget) const override
1421  {
1422  switch (widget) {
1423  case WID_GP_PROGRESS_BAR: {
1424  /* Draw the % complete with a bar and a text */
1425  DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY | FR_LOWERED);
1426  Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
1427  DrawFrameRect(br.WithWidth(br.Width() * _gws.percent / 100, false), COLOUR_MAUVE, FR_NONE);
1428  SetDParam(0, _gws.percent);
1429  DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, FONT_HEIGHT_NORMAL), STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
1430  break;
1431  }
1432 
1433  case WID_GP_PROGRESS_TEXT:
1434  /* Tell which class we are generating */
1435  DrawString(r.left, r.right, r.top, _gws.cls, TC_FROMSTRING, SA_HOR_CENTER);
1436 
1437  /* And say where we are in that class */
1438  SetDParam(0, _gws.current);
1439  SetDParam(1, _gws.total);
1440  DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal, STR_GENERATION_PROGRESS_NUM, TC_FROMSTRING, SA_HOR_CENTER);
1441  }
1442  }
1443 };
1444 
1449 {
1450  _gws.cls = STR_GENERATION_WORLD_GENERATION;
1451  _gws.current = 0;
1452  _gws.total = 0;
1453  _gws.percent = 0;
1454  _gws.next_update = std::chrono::steady_clock::now();
1455 }
1456 
1461 {
1462  if (BringWindowToFrontById(WC_MODAL_PROGRESS, 0)) return;
1463  new GenerateProgressWindow();
1464 }
1465 
1466 static void _SetGeneratingWorldProgress(GenWorldProgress cls, uint progress, uint total)
1467 {
1468  static const int percent_table[] = {0, 5, 14, 17, 20, 40, 60, 65, 80, 85, 95, 99, 100 };
1469  static_assert(lengthof(percent_table) == GWP_CLASS_COUNT + 1);
1470  assert(cls < GWP_CLASS_COUNT);
1471 
1472  /* Check if we really are generating the world.
1473  * For example, placing trees via the SE also calls this function, but
1474  * shouldn't try to update the progress.
1475  */
1476  if (!HasModalProgress()) return;
1477 
1478  if (IsGeneratingWorldAborted()) {
1480  return;
1481  }
1482 
1483  if (total == 0) {
1484  assert(_gws.cls == _generation_class_table[cls]);
1485  _gws.current += progress;
1486  assert(_gws.current <= _gws.total);
1487  } else {
1488  _gws.cls = _generation_class_table[cls];
1489  _gws.current = progress;
1490  _gws.total = total;
1491  _gws.percent = percent_table[cls];
1492  }
1493 
1494  /* Percentage is about the number of completed tasks, so 'current - 1' */
1495  _gws.percent = percent_table[cls] + (percent_table[cls + 1] - percent_table[cls]) * (_gws.current == 0 ? 0 : _gws.current - 1) / _gws.total;
1496 
1497  if (_network_dedicated) {
1498  static uint last_percent = 0;
1499 
1500  /* Never display 0% */
1501  if (_gws.percent == 0) return;
1502  /* Reset if percent is lower than the last recorded */
1503  if (_gws.percent < last_percent) last_percent = 0;
1504  /* Display every 5%, but 6% is also very valid.. just not smaller steps than 5% */
1505  if (_gws.percent % 5 != 0 && _gws.percent <= last_percent + 5) return;
1506  /* Never show steps smaller than 2%, even if it is a mod 5% */
1507  if (_gws.percent <= last_percent + 2) return;
1508 
1509  Debug(net, 3, "Map generation percentage complete: {}", _gws.percent);
1510  last_percent = _gws.percent;
1511 
1512  return;
1513  }
1514 
1516 
1518 }
1519 
1529 {
1530  if (total == 0) return;
1531 
1532  _SetGeneratingWorldProgress(cls, 0, total);
1533 }
1534 
1543 {
1544  /* In fact the param 'class' isn't needed.. but for some security reasons, we want it around */
1545  _SetGeneratingWorldProgress(cls, 1, 0);
1546 }
FileToSaveLoad::title
char title[255]
Internal name of the game.
Definition: saveload.h:363
ShowNewGRFSettings
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
Definition: newgrf_gui.cpp:1999
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:1893
sound_func.h
GameCreationSettings::generation_seed
uint32 generation_seed
noise seed for world generation
Definition: settings_type.h:310
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:1420
SetNewLandscapeType
void SetNewLandscapeType(byte landscape)
Changes landscape type and sets genworld window dirty.
Definition: genworld_gui.cpp:63
Window::timeout_timer
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
Definition: window_gui.h:243
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:3143
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:1377
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:331
ShowCreateScenario
void ShowCreateScenario()
Show the window to create a scenario.
Definition: genworld_gui.cpp:1316
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:1143
GameCreationSettings::map_y
uint8 map_y
Y size of map.
Definition: settings_type.h:314
dropdown_func.h
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:92
GameCreationSettings::landscape
byte landscape
the landscape we're currently in
Definition: settings_type.h:326
GameCreationSettings::tgen_smoothness
byte tgen_smoothness
how rough is the terrain from 0-3
Definition: settings_type.h:321
WID_GP_PROGRESS_BAR
@ WID_GP_PROGRESS_BAR
Progress bar.
Definition: genworld_widget.h:91
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
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:76
GenerateLandscapeWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: genworld_gui.cpp:888
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
WC_SELECT_GAME
@ WC_SELECT_GAME
Select game window; Window numbers:
Definition: window_type.h:435
WID_GL_TEMPERATE
@ WID_GL_TEMPERATE
Button with icon "Temperate".
Definition: genworld_widget.h:15
HM_CLOCKWISE
@ HM_CLOCKWISE
Rotate the map clockwise 45 degrees.
Definition: heightmap.h:21
SM_EDITOR
@ SM_EDITOR
Switch to scenario editor.
Definition: openttd.h: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:82
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:362
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:339
WID_GL_CLIMATE_SEL_SELECTOR
@ WID_GL_CLIMATE_SEL_SELECTOR
NWID_SELECTION for snow or desert coverage selector.
Definition: genworld_widget.h:68
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:84
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:583
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
ai_gui.hpp
GameCreationSettings::variety
byte variety
variety level applied to TGP
Definition: settings_type.h:329
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:1384
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:325
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:449
DropDownListItem
Base list item class from which others are derived.
Definition: dropdown_type.h:22
newgrf_townname.h
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp: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:644
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:1149
WindowNumber
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:713
FR_LOWERED
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
Definition: window_gui.h:34
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:975
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:1111
GameCreationSettings::heightmap_height
byte heightmap_height
highest mountain for heightmap (towards what it scales)
Definition: settings_type.h:320
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:890
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:1123
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:584
_nested_heightmap_load_widgets
static const NWidgetPart _nested_heightmap_load_widgets[]
Widgets of GenerateLandscapeWindow when loading heightmap.
Definition: genworld_gui.cpp:213
WN_GAME_OPTIONS_GAME_OPTIONS
@ WN_GAME_OPTIONS_GAME_OPTIONS
Game options.
Definition: window_type.h:19
WindowDesc
High level window description.
Definition: window_gui.h:102
WC_MODAL_PROGRESS
@ WC_MODAL_PROGRESS
Progress report of landscape generation; Window numbers:
Definition: window_type.h:456
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:467
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:1448
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:335
WID_GL_GS_BUTTON
@ WID_GL_GS_BUTTON
'Game Script Settings' button.
Definition: genworld_widget.h:64
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:251
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:44
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:604
SetMouseCursor
void SetMouseCursor(CursorID sprite, PaletteID pal)
Assign a single non-animated sprite to the cursor.
Definition: gfx.cpp:1908
ShowGenerateLandscape
void ShowGenerateLandscape()
Start with a normal game.
Definition: genworld_gui.cpp:1048
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp: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
game_gui.hpp
GameCreationSettings::custom_town_number
uint16 custom_town_number
manually entered number of towns
Definition: settings_type.h:328
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:92
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
RectPadding::Horizontal
uint Horizontal() const
Get total horizontal padding of RectPadding.
Definition: geometry_type.hpp:59
DEF_DESERT_COVERAGE
static const uint DEF_DESERT_COVERAGE
Default desert coverage.
Definition: tile_type.h:37
GameCreationSettings::water_borders
byte water_borders
bitset of the borders that are water
Definition: settings_type.h:327
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:450
WID_CS_TROPICAL
@ WID_CS_TROPICAL
Select tropical landscape style.
Definition: genworld_widget.h:75
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:320
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:873
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:1109
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:239
GameCreationSettings::custom_terrain_type
byte custom_terrain_type
manually entered height for TGP to aim for
Definition: settings_type.h:330
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:351
WF_TIMEOUT
@ WF_TIMEOUT
Window timeout counter.
Definition: window_gui.h:168
CreateScenarioWindow
Definition: genworld_gui.cpp:1077
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:324
Rect::WithWidth
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
Definition: geometry_type.hpp:179
GenWorldStatus
Definition: genworld_gui.cpp:1341
GLWM_SCENARIO
@ GLWM_SCENARIO
Generate flat land.
Definition: genworld_gui.cpp:47
WID_CS_TEMPERATE
@ WID_CS_TEMPERATE
Select temperate landscape style.
Definition: genworld_widget.h:73
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:487
_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:241
RectPadding::Vertical
uint Vertical() const
Get total vertical padding of RectPadding.
Definition: geometry_type.hpp:65
ShowGSConfigWindow
void ShowGSConfigWindow()
Open the GS config window.
Definition: game_gui.cpp:461
IncreaseGeneratingWorldProgress
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
Definition: genworld_gui.cpp:1542
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:3181
VideoDriver::GetInstance
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Definition: video_driver.hpp:202
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
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:1054
GetHeightmapDimensions
bool GetHeightmapDimensions(DetailedFileType dft, const char *filename, uint *x, uint *y)
Get the dimensions of a heightmap.
Definition: heightmap.cpp:511
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
StartNewGameWithoutGUI
void StartNewGameWithoutGUI(uint32 seed)
Start a normal game without the GUI.
Definition: genworld_gui.cpp:1069
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:1399
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
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:46
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:580
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:1260
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:214
GameCreationSettings::heightmap_rotation
byte heightmap_rotation
rotation director for the heightmap
Definition: settings_type.h:323
WC_GAME_OPTIONS
@ WC_GAME_OPTIONS
Game options window; Window numbers:
Definition: window_type.h:606
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1096
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_NEWGRF_BUTTON
@ WID_GL_NEWGRF_BUTTON
'NewGRF Settings' button.
Definition: genworld_widget.h:65
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:80
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:1460
GenerateLandscapeWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: genworld_gui.cpp:434
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:313
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:319
GameCreationSettings::amount_of_rivers
byte amount_of_rivers
the amount of rivers
Definition: settings_type.h:334
GameCreationSettings::land_generator
byte land_generator
the landscape generator
Definition: settings_type.h:315
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:205
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:1229
geometry_func.hpp
CreateScenarioWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: genworld_gui.cpp:1214
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:3258
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1014
_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:407
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
WID_GL_AI_BUTTON
@ WID_GL_AI_BUTTON
'AI Settings' button.
Definition: genworld_widget.h:63
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:668
Window::IsWidgetLowered
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:421
CreateScenarioWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: genworld_gui.cpp:1234
GLWM_GENERATE
@ GLWM_GENERATE
Generate new game.
Definition: genworld_gui.cpp:45
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:311
WID_CS_EMPTY_WORLD
@ WID_CS_EMPTY_WORLD
Generate an empty flat world.
Definition: genworld_widget.h:77
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:93
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:414
WID_CS_MAPSIZE_X_PULLDOWN
@ WID_CS_MAPSIZE_X_PULLDOWN
Pull-down arrow for x map size.
Definition: genworld_widget.h:79
network.h
window_func.h
CenterBounds
static int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
Definition: gfx_func.h:177
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:248
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:1191
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:318
_nested_generate_landscape_widgets
static const NWidgetPart _nested_generate_landscape_widgets[]
Widgets of GenerateLandscapeWindow when generating world.
Definition: genworld_gui.cpp:71
StartScenarioEditor
void StartScenarioEditor()
Start with a scenario editor.
Definition: genworld_gui.cpp:1060
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:67
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1080
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:1528
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition: settings_type.h:585
SetTextColour
static NWidgetPart SetTextColour(TextColour colour)
Widget part function for setting the text colour.
Definition: widget_type.h:1049
WID_CS_FLAT_LAND_HEIGHT_TEXT
@ WID_CS_FLAT_LAND_HEIGHT_TEXT
Clickable flat land height value.
Definition: genworld_widget.h:85
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:3306
Window
Data structure for an opened window.
Definition: window_gui.h:213
FileToSaveLoad::detail_ftype
DetailedFileType detail_ftype
Concrete file type (PNG, BMP, old save, etc).
Definition: saveload.h:360
GetMapHeightLimit
static uint GetMapHeightLimit()
Get the map height limit, or if set to "auto", the absolute limit.
Definition: genworld_gui.cpp:53
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:411
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:858
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:83
WidgetDimensions::frametext
RectPadding frametext
Offsets within a text frame area.
Definition: window_gui.h:48
Rect::Width
int Width() const
Get width of Rect.
Definition: geometry_type.hpp:79
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
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:74
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
ShowAIConfigWindow
void ShowAIConfigWindow()
Open the AI config window.
Definition: ai_gui.cpp:911
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:69
Window::LowerWidget
void LowerWidget(byte widget_index)
Marks a widget as lowered.
Definition: window_gui.h:402
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:81
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:78
QSF_ENABLE_DEFAULT
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
Definition: textbuf_gui.h:21
CreateScenarioWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: genworld_gui.cpp:1108
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:91
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:381
GenerateLandscapeWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: genworld_gui.cpp:946
_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:1087
CreateScenarioWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: genworld_gui.cpp:1225
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:512
debug.h
FR_BORDERONLY
@ FR_BORDERONLY
Draw border only, no background.
Definition: window_gui.h:33
_grfconfig_newgame
GRFConfig * _grfconfig_newgame
First item in list of default GRF set up.
Definition: newgrf_config.cpp:172
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:86
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:54
WidgetDimensions::vsep_normal
int vsep_normal
Normal vertical spacing.
Definition: window_gui.h:61