OpenTTD Source: src/genworld_gui.cpp Source File

OpenTTD Source 15.0-RC2

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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
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 "timer/timer_game_calendar.h"
18#include "sound_func.h"
19#include "fios.h"
20#include "string_func.h"
21#include "dropdown_type.h"
22#include "dropdown_func.h"
23#include "querystring_gui.h"
24#include "town.h"
25#include "core/geometry_func.hpp"
26#include "core/random_func.hpp"
27#include "saveload/saveload.h"
28#include "progress.h"
29#include "error.h"
30#include "newgrf_townname.h"
31#include "townname_type.h"
32#include "video/video_driver.hpp"
33#include "ai/ai_gui.hpp"
34#include "game/game_gui.hpp"
35#include "industry.h"
36#include "core/string_consumer.hpp"
37
38#include "widgets/genworld_widget.h"
39
40#include "table/strings.h"
41
42#include "dropdown_common_type.h"
43
44#include "safeguards.h"
45
46
47extern void MakeNewgameSettingsLive();
48
50 enum GenerateLandscapeWindowMode : uint8_t {
51 GLWM_GENERATE,
52 GLWM_HEIGHTMAP,
53 GLWM_SCENARIO,
54};
55
59 static uint GetMapHeightLimit()
60{
61 if (_settings_newgame.construction.map_height_limit == 0) return MAX_MAP_HEIGHT_LIMIT;
62 return _settings_newgame.construction.map_height_limit;
63}
64
69 void SetNewLandscapeType(LandscapeType landscape)
70{
71 _settings_newgame.game_creation.landscape = landscape;
72 InvalidateWindowClassesData(WC_SELECT_GAME);
73 InvalidateWindowClassesData(WC_GENERATE_LANDSCAPE);
74}
75
77 static constexpr std::initializer_list<NWidgetPart> _nested_generate_landscape_widgets = {
78 NWidget(NWID_HORIZONTAL),
79 NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
80 NWidget(WWT_CAPTION, COLOUR_BROWN), SetStringTip(STR_MAPGEN_WORLD_GENERATION_CAPTION),
81 EndContainer(),
82 NWidget(WWT_PANEL, COLOUR_BROWN),
83 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0), SetPadding(WidgetDimensions::unscaled.sparse),
84 /* Landscape selection. */
85 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0), SetPIPRatio(1, 1, 1),
86 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TEMPERATE), SetSpriteTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
87 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_ARCTIC), SetSpriteTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
88 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TROPICAL), SetSpriteTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
89 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TOYLAND), SetSpriteTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
90 EndContainer(),
91
92 /* Generation options. */
93 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
94 /* Left half (land generation options) */
95 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
96 /* Labels on the left side (global column 1). */
97 NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
98 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_MAPSIZE, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
99 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_TERRAIN_TYPE, STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT), SetFill(1, 1),
100 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_VARIETY, STR_CONFIG_SETTING_VARIETY_HELPTEXT), SetFill(1, 1),
101 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_SMOOTHNESS, STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT), SetFill(1, 1),
102 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT), SetFill(1, 1),
103 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_BORDER_TYPE, STR_MAPGEN_BORDER_TYPE_TOOLTIP), SetFill(1, 1),
104 EndContainer(),
105
106 /* Widgets on the right side (global column 2). */
107 NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
108 /* Mapsize X * Y. */
109 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
110 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_X_PULLDOWN), SetToolTip(STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
111 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_BY), SetFill(0, 1), SetAlignment(SA_CENTER),
112 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_Y_PULLDOWN), SetToolTip(STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
113 EndContainer(),
114 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TERRAIN_PULLDOWN), SetToolTip(STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT), SetFill(1, 1),
115 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_VARIETY_PULLDOWN), SetToolTip(STR_CONFIG_SETTING_VARIETY_HELPTEXT), SetFill(1, 1),
116 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_SMOOTHNESS_PULLDOWN), SetToolTip(STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT), SetFill(1, 1),
117 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_RIVER_PULLDOWN), SetToolTip(STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT), SetFill(1, 1),
118 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_BORDERS_PULLDOWN), SetToolTip(STR_MAPGEN_BORDER_TYPE_TOOLTIP), SetFill(1, 1),
119 EndContainer(),
120 EndContainer(),
121
122 /* Right half (all other options) */
123 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
124 /* Labels on the left side (global column 3). */
125 NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
126 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GL_CLIMATE_SEL_LABEL),
127 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_SNOW_COVERAGE, STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT), SetFill(1, 1),
128 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_DESERT_COVERAGE, STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT), SetFill(1, 1),
129 NWidget(NWID_SPACER), SetFill(1, 1),
130 EndContainer(),
131 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_DATE, STR_MAPGEN_DATE_TOOLTIP), SetFill(1, 1),
132 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_TOWN_NAME_LABEL, STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP), SetFill(1, 1),
133 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_NUMBER_OF_TOWNS, STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP), SetFill(1, 1),
134 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES, STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP), SetFill(1, 1),
135 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_SEA_LEVEL, STR_MAPGEN_SEA_LEVEL_TOOLTIP), SetFill(1, 1),
136 EndContainer(),
137
138 /* Widgets on the right side (global column 4). */
139 NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
140 /* Climate selector. */
141 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GL_CLIMATE_SEL_SELECTOR),
142 /* Snow coverage. */
143 NWidget(NWID_HORIZONTAL),
144 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_DOWN), SetSpriteTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_COVERAGE_DOWN_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
145 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_TEXT), SetToolTip(STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT), SetFill(1, 1),
146 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_UP), SetSpriteTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_COVERAGE_UP_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
147 EndContainer(),
148 /* Desert coverage. */
149 NWidget(NWID_HORIZONTAL),
150 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_DOWN), SetSpriteTip(SPR_ARROW_DOWN, STR_MAPGEN_DESERT_COVERAGE_DOWN_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
151 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_TEXT), SetToolTip(STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT), SetFill(1, 1),
152 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_UP), SetSpriteTip(SPR_ARROW_UP, STR_MAPGEN_DESERT_COVERAGE_UP_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
153 EndContainer(),
154 /* Temperate/Toyland spacer. */
155 NWidget(NWID_SPACER), SetFill(1, 1),
156 EndContainer(),
157 /* Starting date. */
158 NWidget(NWID_HORIZONTAL),
159 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_DOWN), SetSpriteTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_MOVE_THE_STARTING_DATE_BACKWARD_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
160 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetToolTip(STR_MAPGEN_DATE_TOOLTIP), SetFill(1, 1),
161 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_UP), SetSpriteTip(SPR_ARROW_UP, STR_SCENEDIT_TOOLBAR_MOVE_THE_STARTING_DATE_FORWARD_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
162 EndContainer(),
163 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWNNAME_DROPDOWN), SetToolTip(STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP), SetFill(1, 1),
164 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWN_PULLDOWN), SetToolTip(STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP), SetFill(1, 1),
165 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_INDUSTRY_PULLDOWN), SetToolTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP), SetFill(1, 1),
166 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_WATER_PULLDOWN), SetToolTip(STR_MAPGEN_SEA_LEVEL_TOOLTIP), SetFill(1, 1),
167 EndContainer(),
168 EndContainer(),
169 EndContainer(),
170
171 /* Map borders buttons for each edge. */
172 NWidget(NWID_VERTICAL),
173 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize),
174 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_NORTHWEST), SetPadding(0, WidgetDimensions::unscaled.hsep_normal, 0, 0), SetFill(1, 1), SetAlignment(SA_RIGHT | SA_VERT_CENTER),
175 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_NW), SetToolTip(STR_MAPGEN_NORTHWEST_TOOLTIP), SetFill(1, 1),
176 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_NE), SetToolTip(STR_MAPGEN_NORTHEAST_TOOLTIP), SetFill(1, 1),
177 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_NORTHEAST), SetPadding(0, 0, 0, WidgetDimensions::unscaled.hsep_normal), SetFill(1, 1),
178 EndContainer(),
179 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize),
180 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_SOUTHWEST), SetPadding(0, WidgetDimensions::unscaled.hsep_normal, 0, 0), SetFill(1, 1), SetAlignment(SA_RIGHT | SA_VERT_CENTER),
181 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_SW), SetToolTip(STR_MAPGEN_SOUTHWEST_TOOLTIP), SetFill(1, 1),
182 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_WATER_SE), SetToolTip(STR_MAPGEN_SOUTHEAST_TOOLTIP), SetFill(1, 1),
183 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_SOUTHEAST), SetPadding(0, 0, 0, WidgetDimensions::unscaled.hsep_normal), SetFill(1, 1),
184 EndContainer(),
185 EndContainer(),
186
187 /* AI, GS, and NewGRF settings */
188 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize),
189 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_AI_BUTTON), SetMinimalTextLines(2, 0), SetStringTip(STR_MAPGEN_AI_SETTINGS, STR_MAPGEN_AI_SETTINGS_TOOLTIP), SetFill(1, 0),
190 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_GS_BUTTON), SetMinimalTextLines(2, 0), SetStringTip(STR_MAPGEN_GS_SETTINGS, STR_MAPGEN_GS_SETTINGS_TOOLTIP), SetFill(1, 0),
191 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_NEWGRF_BUTTON), SetMinimalTextLines(2, 0), SetStringTip(STR_MAPGEN_NEWGRF_SETTINGS, STR_MAPGEN_NEWGRF_SETTINGS_TOOLTIP), SetFill(1, 0),
192 EndContainer(),
193
194 /* Generate */
195 NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_GL_GENERATE_BUTTON), SetMinimalTextLines(3, 0), SetStringTip(STR_MAPGEN_GENERATE, STR_MAPGEN_GENERATE_TOOLTIP), SetFill(1, 1),
196 EndContainer(),
197 EndContainer(),
198};
199
201 static constexpr std::initializer_list<NWidgetPart> _nested_heightmap_load_widgets = {
202 /* Window header. */
203 NWidget(NWID_HORIZONTAL),
204 NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
205 NWidget(WWT_CAPTION, COLOUR_BROWN), SetStringTip(STR_MAPGEN_WORLD_GENERATION_CAPTION),
206 EndContainer(),
207 NWidget(WWT_PANEL, COLOUR_BROWN),
208 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0), SetPadding(WidgetDimensions::unscaled.sparse),
209 /* Landscape selection. */
210 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0), SetPIPRatio(1, 1, 1),
211 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TEMPERATE), SetSpriteTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
212 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_ARCTIC), SetSpriteTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
213 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TROPICAL), SetSpriteTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
214 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_GL_TOYLAND), SetSpriteTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
215 EndContainer(),
216
217 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
218 /* Heightmap name label. */
219 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_HEIGHTMAP_NAME, STR_MAPGEN_HEIGHTMAP_NAME_TOOLTIP),
220 NWidget(WWT_TEXT, INVALID_COLOUR, WID_GL_HEIGHTMAP_NAME_TEXT), SetTextStyle(TC_ORANGE), SetToolTip(STR_MAPGEN_HEIGHTMAP_NAME_TOOLTIP), SetFill(1, 0),
221 EndContainer(),
222
223 /* Generation options. */
224 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
225 /* Left half (land generation options) */
226 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
227 /* Labels on the left side (global column 1). */
228 NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
229 /* Land generation option labels. */
230 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_HEIGHTMAP_SIZE_LABEL, STR_MAPGEN_HEIGHTMAP_SIZE_LABEL_TOOLTIP), SetFill(1, 1),
231 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_MAPSIZE, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
232 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_HEIGHTMAP_ROTATION, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_TOOLTIP), SetFill(1, 1),
233 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_HEIGHTMAP_HEIGHT, STR_MAPGEN_HEIGHTMAP_HEIGHT_TOOLTIP), SetFill(1, 1),
234 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT), SetFill(1, 1),
235 EndContainer(),
236
237 /* Left half widgets (global column 2) */
238 NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
239 NWidget(WWT_TEXT, INVALID_COLOUR, WID_GL_HEIGHTMAP_SIZE_TEXT), SetStringTip(STR_MAPGEN_HEIGHTMAP_SIZE, STR_MAPGEN_HEIGHTMAP_SIZE_LABEL_TOOLTIP), SetFill(1, 1),
240 /* Mapsize X * Y. */
241 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
242 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_X_PULLDOWN), SetToolTip(STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
243 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_BY), SetFill(0, 1), SetAlignment(SA_CENTER),
244 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_Y_PULLDOWN), SetToolTip(STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
245 EndContainer(),
246 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_ROTATION_PULLDOWN), SetToolTip(STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_TOOLTIP), SetFill(1, 1),
247 /* Heightmap highest peak. */
248 NWidget(NWID_HORIZONTAL),
249 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_DOWN), SetSpriteTip(SPR_ARROW_DOWN, STR_MAPGEN_HEIGHTMAP_HEIGHT_DOWN_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
250 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_TEXT), SetToolTip(STR_MAPGEN_HEIGHTMAP_HEIGHT_TOOLTIP), SetFill(1, 1),
251 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_HEIGHT_UP), SetSpriteTip(SPR_ARROW_UP, STR_MAPGEN_HEIGHTMAP_HEIGHT_UP_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
252 EndContainer(),
253 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_RIVER_PULLDOWN), SetToolTip(STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT), SetFill(1, 1),
254 EndContainer(),
255 EndContainer(),
256
257 /* Right half (all other options) */
258 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
259 /* Right half labels (global column 3) */
260 NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
261 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GL_CLIMATE_SEL_LABEL),
262 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_SNOW_COVERAGE, STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT), SetFill(1, 1),
263 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_DESERT_COVERAGE, STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT), SetFill(1, 1),
264 NWidget(NWID_SPACER), SetFill(1, 1),
265 EndContainer(),
266 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_DATE, STR_MAPGEN_DATE_TOOLTIP), SetFill(1, 1),
267 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_TOWN_NAME_LABEL, STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP), SetFill(1, 1),
268 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_NUMBER_OF_TOWNS, STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP), SetFill(1, 1),
269 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES, STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP), SetFill(1, 1),
270 EndContainer(),
271
272 /* Right half widgets (global column 4) */
273 NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
274 /* Climate selector. */
275 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GL_CLIMATE_SEL_SELECTOR),
276 /* Snow coverage. */
277 NWidget(NWID_HORIZONTAL),
278 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_DOWN), SetSpriteTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_COVERAGE_DOWN_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
279 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_TEXT), SetToolTip(STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT), SetFill(1, 1),
280 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_UP), SetSpriteTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_COVERAGE_UP_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
281 EndContainer(),
282 /* Desert coverage. */
283 NWidget(NWID_HORIZONTAL),
284 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_DOWN), SetSpriteTip(SPR_ARROW_DOWN, STR_MAPGEN_DESERT_COVERAGE_DOWN_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
285 NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_TEXT), SetToolTip(STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT), SetFill(1, 1),
286 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_DESERT_COVERAGE_UP), SetSpriteTip(SPR_ARROW_UP, STR_MAPGEN_DESERT_COVERAGE_UP_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
287 EndContainer(),
288 /* Temperate/Toyland spacer. */
289 NWidget(NWID_SPACER), SetFill(1, 1),
290 EndContainer(),
291 /* Starting date. */
292 NWidget(NWID_HORIZONTAL),
293 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_DOWN), SetSpriteTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_MOVE_THE_STARTING_DATE_BACKWARD_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
294 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetToolTip(STR_MAPGEN_DATE_TOOLTIP), SetFill(1, 1),
295 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_UP), SetSpriteTip(SPR_ARROW_UP, STR_SCENEDIT_TOOLBAR_MOVE_THE_STARTING_DATE_FORWARD_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
296 EndContainer(),
297 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWNNAME_DROPDOWN), SetToolTip(STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP), SetFill(1, 1),
298 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWN_PULLDOWN), SetToolTip(STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP), SetFill(1, 1),
299 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_INDUSTRY_PULLDOWN), SetToolTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP), SetFill(1, 1),
300 EndContainer(),
301 EndContainer(),
302 EndContainer(),
303
304 /* AI, GS, and NewGRF settings */
305 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize),
306 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_AI_BUTTON), SetMinimalTextLines(2, 0), SetStringTip(STR_MAPGEN_AI_SETTINGS, STR_MAPGEN_AI_SETTINGS_TOOLTIP), SetFill(1, 0),
307 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_GS_BUTTON), SetMinimalTextLines(2, 0), SetStringTip(STR_MAPGEN_GS_SETTINGS, STR_MAPGEN_GS_SETTINGS_TOOLTIP), SetFill(1, 0),
308 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_NEWGRF_BUTTON), SetMinimalTextLines(2, 0), SetStringTip(STR_MAPGEN_NEWGRF_SETTINGS, STR_MAPGEN_NEWGRF_SETTINGS_TOOLTIP), SetFill(1, 0),
309 EndContainer(),
310
311 /* Generate */
312 NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_GL_GENERATE_BUTTON), SetMinimalTextLines(3, 0), SetStringTip(STR_MAPGEN_GENERATE, STR_MAPGEN_GENERATE_TOOLTIP), SetFill(1, 1),
313 EndContainer(),
314 EndContainer(),
315};
316
317static void StartGeneratingLandscape(GenerateLandscapeWindowMode mode)
318{
319 CloseAllNonVitalWindows();
320 ClearErrorMessages();
321
322 /* Copy all XXX_newgame to XXX when coming from outside the editor */
323 MakeNewgameSettingsLive();
324 ResetGRFConfig(true);
325
326 SndConfirmBeep();
327 switch (mode) {
328 case GLWM_GENERATE: _switch_mode = (_game_mode == GM_EDITOR) ? SM_GENRANDLAND : SM_NEWGAME; break;
329 case GLWM_HEIGHTMAP: _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_HEIGHTMAP : SM_START_HEIGHTMAP; break;
330 case GLWM_SCENARIO: _switch_mode = SM_EDITOR; break;
331 default: NOT_REACHED();
332 }
333}
334
335static void LandscapeGenerationCallback(Window *w, bool confirmed)
336{
337 if (confirmed) StartGeneratingLandscape(w->window_number);
338}
339
340static DropDownList BuildMapsizeDropDown()
341{
342 DropDownList list;
343
344 for (uint i = MIN_MAP_SIZE_BITS; i <= MAX_MAP_SIZE_BITS; i++) {
345 list.push_back(MakeDropDownListStringItem(GetString(STR_JUST_INT, 1ULL << i), i));
346 }
347
348 return list;
349}
350
351static DropDownList BuildTownNameDropDown()
352{
353 DropDownList list;
354
355 /* Add and sort newgrf townnames generators */
356 const auto &grf_names = GetGRFTownNameList();
357 for (uint i = 0; i < grf_names.size(); i++) {
358 list.push_back(MakeDropDownListStringItem(grf_names[i], BUILTIN_TOWNNAME_GENERATOR_COUNT + i));
359 }
360 std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
361
362 size_t newgrf_size = list.size();
363 /* Insert newgrf_names at the top of the list */
364 if (newgrf_size > 0) {
365 list.push_back(MakeDropDownListDividerItem()); // separator line
366 newgrf_size++;
367 }
368
369 /* Add and sort original townnames generators */
370 for (uint i = 0; i < BUILTIN_TOWNNAME_GENERATOR_COUNT; i++) {
371 list.push_back(MakeDropDownListStringItem(STR_MAPGEN_TOWN_NAME_ORIGINAL_ENGLISH + i, i));
372 }
373 std::sort(list.begin() + newgrf_size, list.end(), DropDownListStringItem::NatSortFunc);
374
375 return list;
376}
377
378
379static 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};
380static 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};
381static const StringID _rivers[] = {STR_RIVERS_NONE, STR_RIVERS_FEW, STR_RIVERS_MODERATE, STR_RIVERS_LOT};
382static const StringID _borders[] = {STR_MAPGEN_BORDER_RANDOMIZE, STR_MAPGEN_BORDER_MANUAL, STR_MAPGEN_BORDER_INFINITE_WATER};
383static 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};
384static const StringID _rotation[] = {STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE};
385static const StringID _num_towns[] = {STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM};
386static const StringID _num_inds[] = {STR_FUNDING_ONLY, STR_MINIMAL, STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM};
387static const StringID _variety[] = {STR_VARIETY_NONE, STR_VARIETY_VERY_LOW, STR_VARIETY_LOW, STR_VARIETY_MEDIUM, STR_VARIETY_HIGH, STR_VARIETY_VERY_HIGH};
388
389static_assert(std::size(_num_inds) == ID_END);
390
391 struct GenerateLandscapeWindow : public Window {
392 WidgetID widget_id{};
393 uint x = 0;
394 uint y = 0;
395 EncodedString name{};
396 GenerateLandscapeWindowMode mode{};
397
398 GenerateLandscapeWindow(WindowDesc &desc, WindowNumber number = 0) : Window(desc)
399 {
400 this->InitNested(number);
401
402 this->LowerWidget(to_underlying(_settings_newgame.game_creation.landscape) + WID_GL_TEMPERATE);
403
404 this->mode = this->window_number;
405
406 /* Disable town and industry in SE */
407 this->SetWidgetDisabledState(WID_GL_TOWN_PULLDOWN, _game_mode == GM_EDITOR);
408 this->SetWidgetDisabledState(WID_GL_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR);
409
410 /* In case the map_height_limit is changed, clamp heightmap_height and custom_terrain_type. */
411 _settings_newgame.game_creation.heightmap_height = Clamp(_settings_newgame.game_creation.heightmap_height, MIN_HEIGHTMAP_HEIGHT, GetMapHeightLimit());
412 _settings_newgame.game_creation.custom_terrain_type = Clamp(_settings_newgame.game_creation.custom_terrain_type, MIN_CUSTOM_TERRAIN_TYPE, GetMapHeightLimit());
413
414 /* If original landgenerator is selected and alpinist terrain_type was selected, revert to mountainous. */
415 if (_settings_newgame.game_creation.land_generator == LG_ORIGINAL) {
416 _settings_newgame.difficulty.terrain_type = Clamp(_settings_newgame.difficulty.terrain_type, 0, 3);
417 }
418
419 this->OnInvalidateData();
420 }
421
422
423 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
424 {
425 switch (widget) {
426 case WID_GL_START_DATE_TEXT: return GetString(STR_JUST_DATE_LONG, TimerGameCalendar::ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
427 case WID_GL_MAPSIZE_X_PULLDOWN: return GetString(STR_JUST_INT, 1LL << _settings_newgame.game_creation.map_x);
428 case WID_GL_MAPSIZE_Y_PULLDOWN: return GetString(STR_JUST_INT, 1LL << _settings_newgame.game_creation.map_y);
429 case WID_GL_HEIGHTMAP_HEIGHT_TEXT: return GetString(STR_JUST_INT, _settings_newgame.game_creation.heightmap_height);
430 case WID_GL_SNOW_COVERAGE_TEXT: return GetString(STR_MAPGEN_SNOW_COVERAGE_TEXT, _settings_newgame.game_creation.snow_coverage);
431 case WID_GL_DESERT_COVERAGE_TEXT: return GetString(STR_MAPGEN_DESERT_COVERAGE_TEXT, _settings_newgame.game_creation.desert_coverage);
432
433 case WID_GL_TOWN_PULLDOWN:
434 if (_game_mode == GM_EDITOR) {
435 return GetString(STR_CONFIG_SETTING_OFF);
436 }
437 if (_settings_newgame.difficulty.number_towns == CUSTOM_TOWN_NUMBER_DIFFICULTY) {
438 return GetString(STR_NUM_CUSTOM_NUMBER, _settings_newgame.game_creation.custom_town_number);
439 }
440 return GetString(_num_towns[_settings_newgame.difficulty.number_towns]);
441
442 case WID_GL_TOWNNAME_DROPDOWN: {
443 uint gen = _settings_newgame.game_creation.town_name;
444 StringID name = gen < BUILTIN_TOWNNAME_GENERATOR_COUNT ?
445 STR_MAPGEN_TOWN_NAME_ORIGINAL_ENGLISH + gen :
446 GetGRFTownNameName(gen - BUILTIN_TOWNNAME_GENERATOR_COUNT);
447 return GetString(name);
448 }
449
450 case WID_GL_INDUSTRY_PULLDOWN:
451 if (_game_mode == GM_EDITOR) {
452 return GetString(STR_CONFIG_SETTING_OFF);
453 }
454 if (_settings_newgame.difficulty.industry_density == ID_CUSTOM) {
455 return GetString(STR_NUM_CUSTOM_NUMBER, _settings_newgame.game_creation.custom_industry_number);
456 }
457 return GetString(_num_inds[_settings_newgame.difficulty.industry_density]);
458
459 case WID_GL_TERRAIN_PULLDOWN:
460 if (_settings_newgame.difficulty.terrain_type == CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY) {
461 return GetString(STR_TERRAIN_TYPE_CUSTOM_VALUE, _settings_newgame.game_creation.custom_terrain_type);
462 }
463 return GetString(_elevations[_settings_newgame.difficulty.terrain_type]);
464
465 case WID_GL_WATER_PULLDOWN:
466 if (_settings_newgame.difficulty.quantity_sea_lakes == CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY) {
467 return GetString(STR_SEA_LEVEL_CUSTOM_PERCENTAGE, _settings_newgame.game_creation.custom_sea_level);
468 }
469 return GetString(_sea_lakes[_settings_newgame.difficulty.quantity_sea_lakes]);
470
471 case WID_GL_HEIGHTMAP_NAME_TEXT: return this->name.GetDecodedString();
472 case WID_GL_RIVER_PULLDOWN: return GetString(_rivers[_settings_newgame.game_creation.amount_of_rivers]);
473 case WID_GL_SMOOTHNESS_PULLDOWN: return GetString(_smoothness[_settings_newgame.game_creation.tgen_smoothness]);
474 case WID_GL_VARIETY_PULLDOWN: return GetString(_variety[_settings_newgame.game_creation.variety]);
475 case WID_GL_BORDERS_PULLDOWN: return GetString(_borders[_settings_newgame.game_creation.water_border_presets]);
476 case WID_GL_WATER_NE: return GetString((_settings_newgame.game_creation.water_borders == BorderFlag::Random) ? STR_MAPGEN_BORDER_RANDOM : _settings_newgame.game_creation.water_borders.Test(BorderFlag::NorthEast) ? STR_MAPGEN_BORDER_WATER : STR_MAPGEN_BORDER_FREEFORM);
477 case WID_GL_WATER_NW: return GetString((_settings_newgame.game_creation.water_borders == BorderFlag::Random) ? STR_MAPGEN_BORDER_RANDOM : _settings_newgame.game_creation.water_borders.Test(BorderFlag::NorthWest) ? STR_MAPGEN_BORDER_WATER : STR_MAPGEN_BORDER_FREEFORM);
478 case WID_GL_WATER_SE: return GetString((_settings_newgame.game_creation.water_borders == BorderFlag::Random) ? STR_MAPGEN_BORDER_RANDOM : _settings_newgame.game_creation.water_borders.Test(BorderFlag::SouthEast) ? STR_MAPGEN_BORDER_WATER : STR_MAPGEN_BORDER_FREEFORM);
479 case WID_GL_WATER_SW: return GetString((_settings_newgame.game_creation.water_borders == BorderFlag::Random) ? STR_MAPGEN_BORDER_RANDOM : _settings_newgame.game_creation.water_borders.Test(BorderFlag::SouthWest) ? STR_MAPGEN_BORDER_WATER : STR_MAPGEN_BORDER_FREEFORM);
480 case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: return GetString(_rotation[_settings_newgame.game_creation.heightmap_rotation]);
481
482 case WID_GL_HEIGHTMAP_SIZE_TEXT:
483 if (_settings_newgame.game_creation.heightmap_rotation == HM_CLOCKWISE) {
484 return GetString(STR_MAPGEN_HEIGHTMAP_SIZE, this->y, this->x);
485 }
486 return GetString(STR_MAPGEN_HEIGHTMAP_SIZE, this->x, this->y);
487
488 default:
489 return this->Window::GetWidgetString(widget, stringid);
490 }
491 }
492
498 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
499 {
500 if (!gui_scope) return;
501 /* Update the climate buttons */
502 this->SetWidgetLoweredState(WID_GL_TEMPERATE, _settings_newgame.game_creation.landscape == LandscapeType::Temperate);
503 this->SetWidgetLoweredState(WID_GL_ARCTIC, _settings_newgame.game_creation.landscape == LandscapeType::Arctic);
504 this->SetWidgetLoweredState(WID_GL_TROPICAL, _settings_newgame.game_creation.landscape == LandscapeType::Tropic);
505 this->SetWidgetLoweredState(WID_GL_TOYLAND, _settings_newgame.game_creation.landscape == LandscapeType::Toyland);
506
507 /* You can't select smoothness / non-water borders if not terragenesis */
508 if (mode == GLWM_GENERATE) {
509 this->SetWidgetDisabledState(WID_GL_SMOOTHNESS_PULLDOWN, _settings_newgame.game_creation.land_generator == LG_ORIGINAL);
510 this->SetWidgetDisabledState(WID_GL_VARIETY_PULLDOWN, _settings_newgame.game_creation.land_generator == LG_ORIGINAL);
511 this->SetWidgetDisabledState(WID_GL_BORDERS_PULLDOWN, _settings_newgame.game_creation.land_generator == LG_ORIGINAL);
512 this->SetWidgetsDisabledState(_settings_newgame.game_creation.land_generator == LG_ORIGINAL || !_settings_newgame.construction.freeform_edges || _settings_newgame.game_creation.water_borders == BorderFlag::Random,
513 WID_GL_WATER_NW, WID_GL_WATER_NE, WID_GL_WATER_SE, WID_GL_WATER_SW);
514
515 this->SetWidgetLoweredState(WID_GL_WATER_NW, _settings_newgame.game_creation.water_borders.Test(BorderFlag::NorthWest));
516 this->SetWidgetLoweredState(WID_GL_WATER_NE, _settings_newgame.game_creation.water_borders.Test(BorderFlag::NorthEast));
517 this->SetWidgetLoweredState(WID_GL_WATER_SE, _settings_newgame.game_creation.water_borders.Test(BorderFlag::SouthEast));
518 this->SetWidgetLoweredState(WID_GL_WATER_SW, _settings_newgame.game_creation.water_borders.Test(BorderFlag::SouthWest));
519
520 this->SetWidgetsDisabledState(_settings_newgame.game_creation.land_generator == LG_ORIGINAL && (_settings_newgame.game_creation.landscape == LandscapeType::Arctic || _settings_newgame.game_creation.landscape == LandscapeType::Tropic),
521 WID_GL_TERRAIN_PULLDOWN, WID_GL_WATER_PULLDOWN);
522 }
523
524 /* Disable snowline if not arctic */
525 this->SetWidgetDisabledState(WID_GL_SNOW_COVERAGE_TEXT, _settings_newgame.game_creation.landscape != LandscapeType::Arctic);
526 /* Disable desert if not tropic */
527 this->SetWidgetDisabledState(WID_GL_DESERT_COVERAGE_TEXT, _settings_newgame.game_creation.landscape != LandscapeType::Tropic);
528
529 /* Set snow/rainforest selections */
530 int climate_plane = 0;
531 switch (_settings_newgame.game_creation.landscape) {
532 case LandscapeType::Temperate: climate_plane = 2; break;
533 case LandscapeType::Arctic: climate_plane = 0; break;
534 case LandscapeType::Tropic: climate_plane = 1; break;
535 case LandscapeType::Toyland: climate_plane = 2; break;
536 }
537 this->GetWidget<NWidgetStacked>(WID_GL_CLIMATE_SEL_LABEL)->SetDisplayedPlane(climate_plane);
538 this->GetWidget<NWidgetStacked>(WID_GL_CLIMATE_SEL_SELECTOR)->SetDisplayedPlane(climate_plane);
539
540 /* Update availability of decreasing / increasing start date and snow level */
541 if (mode == GLWM_HEIGHTMAP) {
542 this->SetWidgetDisabledState(WID_GL_HEIGHTMAP_HEIGHT_DOWN, _settings_newgame.game_creation.heightmap_height <= MIN_HEIGHTMAP_HEIGHT);
543 this->SetWidgetDisabledState(WID_GL_HEIGHTMAP_HEIGHT_UP, _settings_newgame.game_creation.heightmap_height >= GetMapHeightLimit());
544 }
545 this->SetWidgetDisabledState(WID_GL_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= CalendarTime::MIN_YEAR);
546 this->SetWidgetDisabledState(WID_GL_START_DATE_UP, _settings_newgame.game_creation.starting_year >= CalendarTime::MAX_YEAR);
547 this->SetWidgetDisabledState(WID_GL_SNOW_COVERAGE_DOWN, _settings_newgame.game_creation.snow_coverage <= 0 || _settings_newgame.game_creation.landscape != LandscapeType::Arctic);
548 this->SetWidgetDisabledState(WID_GL_SNOW_COVERAGE_UP, _settings_newgame.game_creation.snow_coverage >= 100 || _settings_newgame.game_creation.landscape != LandscapeType::Arctic);
549 this->SetWidgetDisabledState(WID_GL_DESERT_COVERAGE_DOWN, _settings_newgame.game_creation.desert_coverage <= 0 || _settings_newgame.game_creation.landscape != LandscapeType::Tropic);
550 this->SetWidgetDisabledState(WID_GL_DESERT_COVERAGE_UP, _settings_newgame.game_creation.desert_coverage >= 100 || _settings_newgame.game_creation.landscape != LandscapeType::Tropic);
551
552 /* Do not allow a custom sea level or terrain type with the original land generator. */
553 if (_settings_newgame.game_creation.land_generator == LG_ORIGINAL) {
554 if (_settings_newgame.difficulty.quantity_sea_lakes == CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY) {
555 _settings_newgame.difficulty.quantity_sea_lakes = 1;
556 }
557 if (_settings_newgame.difficulty.terrain_type == CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY) {
558 _settings_newgame.difficulty.terrain_type = 1;
559 }
560 }
561
562 }
563
564 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
565 {
566 Dimension d{0, (uint)GetCharacterHeight(FS_NORMAL)};
567 std::span<const StringID> strs;
568 switch (widget) {
569 case WID_GL_TEMPERATE: case WID_GL_ARCTIC:
570 case WID_GL_TROPICAL: case WID_GL_TOYLAND:
571 size.width += WidgetDimensions::scaled.fullbevel.Horizontal();
572 size.height += WidgetDimensions::scaled.fullbevel.Vertical();
573 break;
574
575 case WID_GL_HEIGHTMAP_HEIGHT_TEXT:
576 d = GetStringBoundingBox(GetString(STR_JUST_INT, MAX_TILE_HEIGHT));
577 break;
578
579 case WID_GL_START_DATE_TEXT:
580 d = GetStringBoundingBox(GetString(STR_JUST_DATE_LONG, TimerGameCalendar::ConvertYMDToDate(CalendarTime::MAX_YEAR, 0, 1)));
581 break;
582
583 case WID_GL_MAPSIZE_X_PULLDOWN:
584 case WID_GL_MAPSIZE_Y_PULLDOWN:
585 d = GetStringBoundingBox(GetString(STR_JUST_INT, GetParamMaxValue(MAX_MAP_SIZE)));
586 break;
587
588 case WID_GL_SNOW_COVERAGE_TEXT:
589 d = GetStringBoundingBox(GetString(STR_MAPGEN_SNOW_COVERAGE_TEXT, GetParamMaxValue(MAX_TILE_HEIGHT)));
590 break;
591
592 case WID_GL_DESERT_COVERAGE_TEXT:
593 d = GetStringBoundingBox(GetString(STR_MAPGEN_DESERT_COVERAGE_TEXT, GetParamMaxValue(MAX_TILE_HEIGHT)));
594 break;
595
596 case WID_GL_HEIGHTMAP_SIZE_TEXT:
597 d = GetStringBoundingBox(GetString(STR_MAPGEN_HEIGHTMAP_SIZE, this->x, this->y));
598 break;
599
600 case WID_GL_TOWN_PULLDOWN:
601 strs = _num_towns;
602 d = GetStringBoundingBox(GetString(STR_NUM_CUSTOM_NUMBER, GetParamMaxValue(CUSTOM_TOWN_MAX_NUMBER)));
603 break;
604
605 case WID_GL_INDUSTRY_PULLDOWN:
606 strs = _num_inds;
607 d = GetStringBoundingBox(GetString(STR_NUM_CUSTOM_NUMBER, GetParamMaxValue(IndustryPool::MAX_SIZE)));
608 break;
609
610 case WID_GL_TERRAIN_PULLDOWN:
611 strs = _elevations;
612 d = GetStringBoundingBox(GetString(STR_TERRAIN_TYPE_CUSTOM_VALUE, GetParamMaxValue(MAX_MAP_HEIGHT_LIMIT)));
613 break;
614
615 case WID_GL_WATER_PULLDOWN:
616 strs = _sea_lakes;
617 d = GetStringBoundingBox(GetString(STR_SEA_LEVEL_CUSTOM_PERCENTAGE, GetParamMaxValue(CUSTOM_SEA_LEVEL_MAX_PERCENTAGE)));
618 break;
619
620 case WID_GL_RIVER_PULLDOWN: strs = _rivers; break;
621 case WID_GL_SMOOTHNESS_PULLDOWN: strs = _smoothness; break;
622 case WID_GL_VARIETY_PULLDOWN: strs = _variety; break;
623 case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: strs = _rotation; break;
624 case WID_GL_BORDERS_PULLDOWN: strs = _borders; break;
625 case WID_GL_WATER_NE:
626 case WID_GL_WATER_NW:
627 case WID_GL_WATER_SE:
628 case WID_GL_WATER_SW:
629 d = maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_RANDOM), maxdim(GetStringBoundingBox(STR_MAPGEN_BORDER_WATER), GetStringBoundingBox(STR_MAPGEN_BORDER_FREEFORM)));
630 break;
631
632 case WID_GL_HEIGHTMAP_NAME_TEXT:
633 size.width = 0;
634 break;
635
636 default:
637 return;
638 }
639 d = maxdim(d, GetStringListBoundingBox(strs));
640 d.width += padding.width;
641 d.height += padding.height;
642 size = maxdim(size, d);
643 }
644
645 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
646 {
647 switch (widget) {
648 case WID_GL_TEMPERATE:
649 case WID_GL_ARCTIC:
650 case WID_GL_TROPICAL:
651 case WID_GL_TOYLAND:
652 SetNewLandscapeType(LandscapeType(widget - WID_GL_TEMPERATE));
653 SndClickBeep();
654 break;
655
656 case WID_GL_MAPSIZE_X_PULLDOWN: // Mapsize X
657 ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_x, WID_GL_MAPSIZE_X_PULLDOWN);
658 break;
659
660 case WID_GL_MAPSIZE_Y_PULLDOWN: // Mapsize Y
661 ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_y, WID_GL_MAPSIZE_Y_PULLDOWN);
662 break;
663
664 case WID_GL_TOWN_PULLDOWN: // Number of towns
665 ShowDropDownMenu(this, _num_towns, _settings_newgame.difficulty.number_towns, WID_GL_TOWN_PULLDOWN, 0, 0);
666 break;
667
668 case WID_GL_TOWNNAME_DROPDOWN: // Townname generator
669 ShowDropDownList(this, BuildTownNameDropDown(), _settings_newgame.game_creation.town_name, WID_GL_TOWNNAME_DROPDOWN);
670 break;
671
672 case WID_GL_INDUSTRY_PULLDOWN: // Number of industries
673 ShowDropDownMenu(this, _num_inds, _settings_newgame.difficulty.industry_density, WID_GL_INDUSTRY_PULLDOWN, 0, 0);
674 break;
675
676 case WID_GL_GENERATE_BUTTON: { // Generate
677 /* Get rotated map size. */
678 uint map_x;
679 uint map_y;
680 if (_settings_newgame.game_creation.heightmap_rotation == HM_CLOCKWISE) {
681 map_x = this->y;
682 map_y = this->x;
683 } else {
684 map_x = this->x;
685 map_y = this->y;
686 }
687 if (mode == GLWM_HEIGHTMAP &&
688 (map_x * 2 < (1U << _settings_newgame.game_creation.map_x) ||
689 map_x / 2 > (1U << _settings_newgame.game_creation.map_x) ||
690 map_y * 2 < (1U << _settings_newgame.game_creation.map_y) ||
691 map_y / 2 > (1U << _settings_newgame.game_creation.map_y))) {
692 ShowQuery(
693 GetEncodedString(STR_WARNING_HEIGHTMAP_SCALE_CAPTION),
694 GetEncodedString(STR_WARNING_HEIGHTMAP_SCALE_MESSAGE),
695 this,
696 LandscapeGenerationCallback);
697 } else {
698 StartGeneratingLandscape(mode);
699 }
700 break;
701 }
702
703 case WID_GL_HEIGHTMAP_HEIGHT_DOWN:
704 case WID_GL_HEIGHTMAP_HEIGHT_UP: // Height level buttons
705 /* Don't allow too fast scrolling */
706 if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
707 this->HandleButtonClick(widget);
708
709 _settings_newgame.game_creation.heightmap_height = Clamp(_settings_newgame.game_creation.heightmap_height + widget - WID_GL_HEIGHTMAP_HEIGHT_TEXT, MIN_HEIGHTMAP_HEIGHT, GetMapHeightLimit());
710 this->InvalidateData();
711 }
712 _left_button_clicked = false;
713 break;
714
715 case WID_GL_HEIGHTMAP_HEIGHT_TEXT: // Height level text
716 this->widget_id = WID_GL_HEIGHTMAP_HEIGHT_TEXT;
717 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.heightmap_height), STR_MAPGEN_HEIGHTMAP_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QueryStringFlag::EnableDefault);
718 SndClickBeep();
719 break;
720
721
722 case WID_GL_START_DATE_DOWN:
723 case WID_GL_START_DATE_UP: // Year buttons
724 /* Don't allow too fast scrolling */
725 if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
726 this->HandleButtonClick(widget);
727
728 _settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + widget - WID_GL_START_DATE_TEXT, CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
729 this->InvalidateData();
730 }
731 _left_button_clicked = false;
732 break;
733
734 case WID_GL_START_DATE_TEXT: // Year text
735 this->widget_id = WID_GL_START_DATE_TEXT;
736 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.starting_year), STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QueryStringFlag::EnableDefault);
737 break;
738
739 case WID_GL_SNOW_COVERAGE_DOWN:
740 case WID_GL_SNOW_COVERAGE_UP: // Snow coverage buttons
741 /* Don't allow too fast scrolling */
742 if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
743 this->HandleButtonClick(widget);
744
745 _settings_newgame.game_creation.snow_coverage = Clamp(_settings_newgame.game_creation.snow_coverage + (widget - WID_GL_SNOW_COVERAGE_TEXT) * 10, 0, 100);
746 this->InvalidateData();
747 }
748 _left_button_clicked = false;
749 break;
750
751 case WID_GL_SNOW_COVERAGE_TEXT: // Snow coverage text
752 this->widget_id = WID_GL_SNOW_COVERAGE_TEXT;
753 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.snow_coverage), STR_MAPGEN_SNOW_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QueryStringFlag::EnableDefault);
754 SndClickBeep();
755 break;
756
757 case WID_GL_DESERT_COVERAGE_DOWN:
758 case WID_GL_DESERT_COVERAGE_UP: // Desert coverage buttons
759 /* Don't allow too fast scrolling */
760 if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
761 this->HandleButtonClick(widget);
762
763 _settings_newgame.game_creation.desert_coverage = Clamp(_settings_newgame.game_creation.desert_coverage + (widget - WID_GL_DESERT_COVERAGE_TEXT) * 10, 0, 100);
764 this->InvalidateData();
765 }
766 _left_button_clicked = false;
767 break;
768
769 case WID_GL_DESERT_COVERAGE_TEXT: // Desert line text
770 this->widget_id = WID_GL_DESERT_COVERAGE_TEXT;
771 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.desert_coverage), STR_MAPGEN_DESERT_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QueryStringFlag::EnableDefault);
772 SndClickBeep();
773 break;
774
775 case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: // Heightmap rotation
776 ShowDropDownMenu(this, _rotation, _settings_newgame.game_creation.heightmap_rotation, WID_GL_HEIGHTMAP_ROTATION_PULLDOWN, 0, 0);
777 break;
778
779 case WID_GL_TERRAIN_PULLDOWN: // Terrain type
780 /* For the original map generation only the first four are valid. */
781 ShowDropDownMenu(this, _elevations, _settings_newgame.difficulty.terrain_type, WID_GL_TERRAIN_PULLDOWN, 0, _settings_newgame.game_creation.land_generator == LG_ORIGINAL ? ~0xF : 0);
782 break;
783
784 case WID_GL_WATER_PULLDOWN: { // Water quantity
785 uint32_t hidden_mask = 0;
786 /* Disable custom water level when the original map generator is active. */
787 if (_settings_newgame.game_creation.land_generator == LG_ORIGINAL) {
788 SetBit(hidden_mask, CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY);
789 }
790 ShowDropDownMenu(this, _sea_lakes, _settings_newgame.difficulty.quantity_sea_lakes, WID_GL_WATER_PULLDOWN, 0, hidden_mask);
791 break;
792 }
793
794 case WID_GL_RIVER_PULLDOWN: // Amount of rivers
795 ShowDropDownMenu(this, _rivers, _settings_newgame.game_creation.amount_of_rivers, WID_GL_RIVER_PULLDOWN, 0, 0);
796 break;
797
798 case WID_GL_SMOOTHNESS_PULLDOWN: // Map smoothness
799 ShowDropDownMenu(this, _smoothness, _settings_newgame.game_creation.tgen_smoothness, WID_GL_SMOOTHNESS_PULLDOWN, 0, 0);
800 break;
801
802 case WID_GL_VARIETY_PULLDOWN: // Map variety
803 ShowDropDownMenu(this, _variety, _settings_newgame.game_creation.variety, WID_GL_VARIETY_PULLDOWN, 0, 0);
804 break;
805
806 /* Map borders */
807 case WID_GL_BORDERS_PULLDOWN:
808 ShowDropDownMenu(this, _borders, _settings_newgame.game_creation.water_border_presets, WID_GL_BORDERS_PULLDOWN, 0, 0);
809 break;
810
811 case WID_GL_WATER_NW:
812 _settings_newgame.game_creation.water_borders.Flip(BorderFlag::NorthWest);
813 SndClickBeep();
814 this->InvalidateData();
815 break;
816
817 case WID_GL_WATER_NE:
818 _settings_newgame.game_creation.water_borders.Flip(BorderFlag::NorthEast);
819 SndClickBeep();
820 this->InvalidateData();
821 break;
822
823 case WID_GL_WATER_SE:
824 _settings_newgame.game_creation.water_borders.Flip(BorderFlag::SouthEast);
825 SndClickBeep();
826 this->InvalidateData();
827 break;
828
829 case WID_GL_WATER_SW:
830 _settings_newgame.game_creation.water_borders.Flip(BorderFlag::SouthWest);
831 SndClickBeep();
832 this->InvalidateData();
833 break;
834
835 case WID_GL_AI_BUTTON:
836 ShowAIConfigWindow();
837 break;
838
839 case WID_GL_GS_BUTTON:
840 ShowGSConfigWindow();
841 break;
842
843 case WID_GL_NEWGRF_BUTTON:
844 ShowNewGRFSettings(true, true, false, _grfconfig_newgame);
845 break;
846 }
847 }
848
849 void OnTimeout() override
850 {
851 if (mode == GLWM_HEIGHTMAP) {
852 this->RaiseWidgetsWhenLowered(WID_GL_HEIGHTMAP_HEIGHT_DOWN, WID_GL_HEIGHTMAP_HEIGHT_UP, WID_GL_START_DATE_DOWN, WID_GL_START_DATE_UP, WID_GL_SNOW_COVERAGE_UP, WID_GL_SNOW_COVERAGE_DOWN, WID_GL_DESERT_COVERAGE_UP, WID_GL_DESERT_COVERAGE_DOWN);
853 } else {
854 this->RaiseWidgetsWhenLowered(WID_GL_START_DATE_DOWN, WID_GL_START_DATE_UP, WID_GL_SNOW_COVERAGE_UP, WID_GL_SNOW_COVERAGE_DOWN, WID_GL_DESERT_COVERAGE_UP, WID_GL_DESERT_COVERAGE_DOWN);
855 }
856 }
857
858 void OnDropdownSelect(WidgetID widget, int index, int) override
859 {
860 switch (widget) {
861 case WID_GL_MAPSIZE_X_PULLDOWN: _settings_newgame.game_creation.map_x = index; break;
862 case WID_GL_MAPSIZE_Y_PULLDOWN: _settings_newgame.game_creation.map_y = index; break;
863 case WID_GL_RIVER_PULLDOWN: _settings_newgame.game_creation.amount_of_rivers = index; break;
864 case WID_GL_SMOOTHNESS_PULLDOWN: _settings_newgame.game_creation.tgen_smoothness = index; break;
865 case WID_GL_VARIETY_PULLDOWN: _settings_newgame.game_creation.variety = index; break;
866
867 case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: _settings_newgame.game_creation.heightmap_rotation = index; break;
868
869 case WID_GL_TOWN_PULLDOWN:
870 if ((uint)index == CUSTOM_TOWN_NUMBER_DIFFICULTY) {
871 this->widget_id = widget;
872 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.custom_town_number), STR_MAPGEN_NUMBER_OF_TOWNS, 5, this, CS_NUMERAL, {});
873 }
874 _settings_newgame.difficulty.number_towns = index;
875 break;
876
877 case WID_GL_TOWNNAME_DROPDOWN: // Town names
878 if (_game_mode == GM_MENU || Town::GetNumItems() == 0) {
879 _settings_newgame.game_creation.town_name = index;
880 SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_OPTIONS);
881 }
882 break;
883
884 case WID_GL_INDUSTRY_PULLDOWN:
885 if ((uint)index == ID_CUSTOM) {
886 this->widget_id = widget;
887 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.custom_industry_number), STR_MAPGEN_NUMBER_OF_INDUSTRIES, 5, this, CS_NUMERAL, {});
888 }
889 _settings_newgame.difficulty.industry_density = index;
890 break;
891
892 case WID_GL_TERRAIN_PULLDOWN: {
893 if ((uint)index == CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY) {
894 this->widget_id = widget;
895 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.custom_terrain_type), STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT, 4, this, CS_NUMERAL, {});
896 }
897 _settings_newgame.difficulty.terrain_type = index;
898 break;
899 }
900
901 case WID_GL_BORDERS_PULLDOWN: {
902 switch (index) {
903 case BFP_RANDOM:
904 _settings_newgame.game_creation.water_borders = BorderFlag::Random;
905 _settings_newgame.construction.freeform_edges = true;
906 break;
907 case BFP_MANUAL:
908 _settings_newgame.game_creation.water_borders = {};
909 _settings_newgame.construction.freeform_edges = true;
910 break;
911 case BFP_INFINITE_WATER:
912 _settings_newgame.game_creation.water_borders = BORDERFLAGS_ALL;
913 _settings_newgame.construction.freeform_edges = false;
914 break;
915 }
916 _settings_newgame.game_creation.water_border_presets = static_cast<BorderFlagPresets>(index);
917 break;
918 }
919
920 case WID_GL_WATER_PULLDOWN: {
921 if ((uint)index == CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY) {
922 this->widget_id = widget;
923 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.custom_sea_level), STR_MAPGEN_SEA_LEVEL, 3, this, CS_NUMERAL, {});
924 }
925 _settings_newgame.difficulty.quantity_sea_lakes = index;
926 break;
927 }
928 }
929 this->InvalidateData();
930 }
931
932 void OnQueryTextFinished(std::optional<std::string> str) override
933 {
934 /* Was 'cancel' pressed? */
935 if (!str.has_value()) return;
936
937 int32_t value;
938 if (!str->empty()) {
939 auto val = ParseInteger<int32_t>(*str, 10, true);
940 if (!val.has_value()) return;
941 value = *val;
942 } else {
943 /* An empty string means revert to the default */
944 switch (this->widget_id) {
945 case WID_GL_HEIGHTMAP_HEIGHT_TEXT: value = MAP_HEIGHT_LIMIT_AUTO_MINIMUM; break;
946 case WID_GL_START_DATE_TEXT: value = CalendarTime::DEF_START_YEAR.base(); break;
947 case WID_GL_SNOW_COVERAGE_TEXT: value = DEF_SNOW_COVERAGE; break;
948 case WID_GL_DESERT_COVERAGE_TEXT: value = DEF_DESERT_COVERAGE; break;
949 case WID_GL_TOWN_PULLDOWN: value = 1; break;
950 case WID_GL_INDUSTRY_PULLDOWN: value = 1; break;
951 case WID_GL_TERRAIN_PULLDOWN: value = MIN_MAP_HEIGHT_LIMIT; break;
952 case WID_GL_WATER_PULLDOWN: value = CUSTOM_SEA_LEVEL_MIN_PERCENTAGE; break;
953 default: NOT_REACHED();
954 }
955 }
956
957 switch (this->widget_id) {
958 case WID_GL_HEIGHTMAP_HEIGHT_TEXT:
959 this->SetWidgetDirty(WID_GL_HEIGHTMAP_HEIGHT_TEXT);
960 _settings_newgame.game_creation.heightmap_height = Clamp(value, MIN_HEIGHTMAP_HEIGHT, GetMapHeightLimit());
961 break;
962
963 case WID_GL_START_DATE_TEXT:
964 this->SetWidgetDirty(WID_GL_START_DATE_TEXT);
965 _settings_newgame.game_creation.starting_year = Clamp(TimerGameCalendar::Year(value), CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
966 break;
967
968 case WID_GL_SNOW_COVERAGE_TEXT:
969 this->SetWidgetDirty(WID_GL_SNOW_COVERAGE_TEXT);
970 _settings_newgame.game_creation.snow_coverage = Clamp(value, 0, 100);
971 break;
972
973 case WID_GL_DESERT_COVERAGE_TEXT:
974 this->SetWidgetDirty(WID_GL_DESERT_COVERAGE_TEXT);
975 _settings_newgame.game_creation.desert_coverage = Clamp(value, 0, 100);
976 break;
977
978 case WID_GL_TOWN_PULLDOWN:
979 _settings_newgame.game_creation.custom_town_number = Clamp(value, 1, CUSTOM_TOWN_MAX_NUMBER);
980 break;
981
982 case WID_GL_INDUSTRY_PULLDOWN:
983 _settings_newgame.game_creation.custom_industry_number = Clamp(value, 1, IndustryPool::MAX_SIZE);
984 break;
985
986 case WID_GL_TERRAIN_PULLDOWN:
987 _settings_newgame.game_creation.custom_terrain_type = Clamp(value, MIN_CUSTOM_TERRAIN_TYPE, GetMapHeightLimit());
988 break;
989
990 case WID_GL_WATER_PULLDOWN:
991 _settings_newgame.game_creation.custom_sea_level = Clamp(value, CUSTOM_SEA_LEVEL_MIN_PERCENTAGE, CUSTOM_SEA_LEVEL_MAX_PERCENTAGE);
992 break;
993 }
994
995 this->InvalidateData();
996 }
997};
998
999static WindowDesc _generate_landscape_desc(
1000 WDP_CENTER, {}, 0, 0,
1001 WC_GENERATE_LANDSCAPE, WC_NONE,
1002 {},
1003 _nested_generate_landscape_widgets
1004);
1005
1006static WindowDesc _heightmap_load_desc(
1007 WDP_CENTER, {}, 0, 0,
1008 WC_GENERATE_LANDSCAPE, WC_NONE,
1009 {},
1010 _nested_heightmap_load_widgets
1011);
1012
1013static void _ShowGenerateLandscape(GenerateLandscapeWindowMode mode)
1014{
1015 uint x = 0;
1016 uint y = 0;
1017
1018 CloseWindowByClass(WC_GENERATE_LANDSCAPE);
1019
1020 /* Generate a new seed when opening the window */
1021 _settings_newgame.game_creation.generation_seed = InteractiveRandom();
1022
1023 if (mode == GLWM_HEIGHTMAP) {
1024 /* If the function returns negative, it means there was a problem loading the heightmap */
1025 if (!GetHeightmapDimensions(_file_to_saveload.ftype.detailed, _file_to_saveload.name, &x, &y)) return;
1026 }
1027
1028 WindowDesc &desc = (mode == GLWM_HEIGHTMAP) ? _heightmap_load_desc : _generate_landscape_desc;
1029 GenerateLandscapeWindow *w = AllocateWindowDescFront<GenerateLandscapeWindow, true>(desc, mode);
1030
1031 if (mode == GLWM_HEIGHTMAP) {
1032 w->x = x;
1033 w->y = y;
1034 w->name = _file_to_saveload.title;
1035 }
1036
1037 SetWindowDirty(WC_GENERATE_LANDSCAPE, mode);
1038}
1039
1041 void ShowGenerateLandscape()
1042{
1043 _ShowGenerateLandscape(GLWM_GENERATE);
1044}
1045
1047 void ShowHeightmapLoad()
1048{
1049 _ShowGenerateLandscape(GLWM_HEIGHTMAP);
1050}
1051
1053 void StartScenarioEditor()
1054{
1055 StartGeneratingLandscape(GLWM_SCENARIO);
1056}
1057
1062 void StartNewGameWithoutGUI(uint32_t seed)
1063{
1064 /* GenerateWorld takes care of the possible GENERATE_NEW_SEED value in 'seed' */
1065 _settings_newgame.game_creation.generation_seed = seed;
1066
1067 StartGeneratingLandscape(GLWM_GENERATE);
1068}
1069
1070 struct CreateScenarioWindow : public Window
1071{
1072 WidgetID widget_id{};
1073
1074 CreateScenarioWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc)
1075 {
1076 this->InitNested(window_number);
1077 this->LowerWidget(to_underlying(_settings_newgame.game_creation.landscape) + WID_CS_TEMPERATE);
1078 }
1079
1080 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
1081 {
1082 switch (widget) {
1083 case WID_CS_START_DATE_TEXT:
1084 return GetString(STR_JUST_DATE_LONG, TimerGameCalendar::ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
1085
1086 case WID_CS_MAPSIZE_X_PULLDOWN:
1087 return GetString(STR_JUST_INT, 1LL << _settings_newgame.game_creation.map_x);
1088
1089 case WID_CS_MAPSIZE_Y_PULLDOWN:
1090 return GetString(STR_JUST_INT, 1LL << _settings_newgame.game_creation.map_y);
1091
1092 case WID_CS_FLAT_LAND_HEIGHT_TEXT:
1093 return GetString(STR_JUST_INT, _settings_newgame.game_creation.se_flat_world_height);
1094
1095 default:
1096 return this->Window::GetWidgetString(widget, stringid);
1097 }
1098 }
1099
1100 void OnPaint() override
1101 {
1102 this->SetWidgetDisabledState(WID_CS_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= CalendarTime::MIN_YEAR);
1103 this->SetWidgetDisabledState(WID_CS_START_DATE_UP, _settings_newgame.game_creation.starting_year >= CalendarTime::MAX_YEAR);
1104 this->SetWidgetDisabledState(WID_CS_FLAT_LAND_HEIGHT_DOWN, _settings_newgame.game_creation.se_flat_world_height <= 0);
1105 this->SetWidgetDisabledState(WID_CS_FLAT_LAND_HEIGHT_UP, _settings_newgame.game_creation.se_flat_world_height >= GetMapHeightLimit());
1106
1107 this->SetWidgetLoweredState(WID_CS_TEMPERATE, _settings_newgame.game_creation.landscape == LandscapeType::Temperate);
1108 this->SetWidgetLoweredState(WID_CS_ARCTIC, _settings_newgame.game_creation.landscape == LandscapeType::Arctic);
1109 this->SetWidgetLoweredState(WID_CS_TROPICAL, _settings_newgame.game_creation.landscape == LandscapeType::Tropic);
1110 this->SetWidgetLoweredState(WID_CS_TOYLAND, _settings_newgame.game_creation.landscape == LandscapeType::Toyland);
1111
1112 this->DrawWidgets();
1113 }
1114
1115 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
1116 {
1117 std::string str;
1118 switch (widget) {
1119 case WID_CS_TEMPERATE: case WID_CS_ARCTIC:
1120 case WID_CS_TROPICAL: case WID_CS_TOYLAND:
1121 size.width += WidgetDimensions::scaled.fullbevel.Horizontal();
1122 size.height += WidgetDimensions::scaled.fullbevel.Vertical();
1123 return;
1124
1125 case WID_CS_START_DATE_TEXT:
1126 str = GetString(STR_JUST_DATE_LONG, TimerGameCalendar::ConvertYMDToDate(CalendarTime::MAX_YEAR, 0, 1));
1127 break;
1128
1129 case WID_CS_MAPSIZE_X_PULLDOWN:
1130 case WID_CS_MAPSIZE_Y_PULLDOWN:
1131 str = GetString(STR_JUST_INT, GetParamMaxValue(MAX_MAP_SIZE));
1132 break;
1133
1134 case WID_CS_FLAT_LAND_HEIGHT_TEXT:
1135 str = GetString(STR_JUST_INT, GetParamMaxValue(MAX_TILE_HEIGHT));
1136 break;
1137
1138 default:
1139 return;
1140 }
1141 Dimension d = GetStringBoundingBox(str);
1142 d.width += padding.width;
1143 d.height += padding.height;
1144 size = maxdim(size, d);
1145 }
1146
1147 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1148 {
1149 switch (widget) {
1150 case WID_CS_TEMPERATE:
1151 case WID_CS_ARCTIC:
1152 case WID_CS_TROPICAL:
1153 case WID_CS_TOYLAND:
1154 this->RaiseWidget(to_underlying(_settings_newgame.game_creation.landscape) + WID_CS_TEMPERATE);
1155 SetNewLandscapeType(LandscapeType(widget - WID_CS_TEMPERATE));
1156 break;
1157
1158 case WID_CS_MAPSIZE_X_PULLDOWN: // Mapsize X
1159 ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_x, WID_CS_MAPSIZE_X_PULLDOWN);
1160 break;
1161
1162 case WID_CS_MAPSIZE_Y_PULLDOWN: // Mapsize Y
1163 ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_y, WID_CS_MAPSIZE_Y_PULLDOWN);
1164 break;
1165
1166 case WID_CS_EMPTY_WORLD: // Empty world / flat world
1167 StartGeneratingLandscape(GLWM_SCENARIO);
1168 break;
1169
1170 case WID_CS_RANDOM_WORLD: // Generate
1171 ShowGenerateLandscape();
1172 break;
1173
1174 case WID_CS_START_DATE_DOWN:
1175 case WID_CS_START_DATE_UP: // Year buttons
1176 /* Don't allow too fast scrolling */
1177 if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
1178 this->HandleButtonClick(widget);
1179 this->SetDirty();
1180
1181 _settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + widget - WID_CS_START_DATE_TEXT, CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
1182 }
1183 _left_button_clicked = false;
1184 break;
1185
1186 case WID_CS_START_DATE_TEXT: // Year text
1187 this->widget_id = WID_CS_START_DATE_TEXT;
1188 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.starting_year), STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, {});
1189 break;
1190
1191 case WID_CS_FLAT_LAND_HEIGHT_DOWN:
1192 case WID_CS_FLAT_LAND_HEIGHT_UP: // Height level buttons
1193 /* Don't allow too fast scrolling */
1194 if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
1195 this->HandleButtonClick(widget);
1196 this->SetDirty();
1197
1198 _settings_newgame.game_creation.se_flat_world_height = Clamp(_settings_newgame.game_creation.se_flat_world_height + widget - WID_CS_FLAT_LAND_HEIGHT_TEXT, 0, GetMapHeightLimit());
1199 }
1200 _left_button_clicked = false;
1201 break;
1202
1203 case WID_CS_FLAT_LAND_HEIGHT_TEXT: // Height level text
1204 this->widget_id = WID_CS_FLAT_LAND_HEIGHT_TEXT;
1205 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.se_flat_world_height), STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, {});
1206 break;
1207 }
1208 }
1209
1210 void OnTimeout() override
1211 {
1212 this->RaiseWidgetsWhenLowered(WID_CS_START_DATE_DOWN, WID_CS_START_DATE_UP, WID_CS_FLAT_LAND_HEIGHT_DOWN, WID_CS_FLAT_LAND_HEIGHT_UP);
1213 }
1214
1215 void OnDropdownSelect(WidgetID widget, int index, int) override
1216 {
1217 switch (widget) {
1218 case WID_CS_MAPSIZE_X_PULLDOWN: _settings_newgame.game_creation.map_x = index; break;
1219 case WID_CS_MAPSIZE_Y_PULLDOWN: _settings_newgame.game_creation.map_y = index; break;
1220 }
1221 this->SetDirty();
1222 }
1223
1224 void OnQueryTextFinished(std::optional<std::string> str) override
1225 {
1226 if (!str.has_value()) return;
1227
1228 auto value = ParseInteger<int32_t>(*str, 10, true);
1229 if (!value.has_value()) return;
1230
1231 switch (this->widget_id) {
1232 case WID_CS_START_DATE_TEXT:
1233 this->SetWidgetDirty(WID_CS_START_DATE_TEXT);
1234 _settings_newgame.game_creation.starting_year = Clamp(TimerGameCalendar::Year(*value), CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
1235 break;
1236
1237 case WID_CS_FLAT_LAND_HEIGHT_TEXT:
1238 this->SetWidgetDirty(WID_CS_FLAT_LAND_HEIGHT_TEXT);
1239 _settings_newgame.game_creation.se_flat_world_height = Clamp(*value, 0, GetMapHeightLimit());
1240 break;
1241 }
1242
1243 this->SetDirty();
1244 }
1245};
1246
1247static constexpr std::initializer_list<NWidgetPart> _nested_create_scenario_widgets = {
1248 NWidget(NWID_HORIZONTAL),
1249 NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
1250 NWidget(WWT_CAPTION, COLOUR_BROWN), SetStringTip(STR_SE_MAPGEN_CAPTION),
1251 EndContainer(),
1252 NWidget(WWT_PANEL, COLOUR_BROWN),
1253 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0), SetPadding(WidgetDimensions::unscaled.sparse),
1254 /* Landscape style selection. */
1255 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0), SetPIPRatio(1, 1, 1),
1256 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TEMPERATE), SetSpriteTip(SPR_SELECT_TEMPERATE, STR_INTRO_TOOLTIP_TEMPERATE),
1257 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_ARCTIC), SetSpriteTip(SPR_SELECT_SUB_ARCTIC, STR_INTRO_TOOLTIP_SUB_ARCTIC_LANDSCAPE),
1258 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TROPICAL), SetSpriteTip(SPR_SELECT_SUB_TROPICAL, STR_INTRO_TOOLTIP_SUB_TROPICAL_LANDSCAPE),
1259 NWidget(WWT_IMGBTN_2, COLOUR_ORANGE, WID_CS_TOYLAND), SetSpriteTip(SPR_SELECT_TOYLAND, STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE),
1260 EndContainer(),
1261
1262 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1263 /* Green generation type buttons: 'Flat land' and 'Random land'. */
1264 NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
1265 NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_CS_EMPTY_WORLD), SetStringTip(STR_SE_MAPGEN_FLAT_WORLD, STR_SE_MAPGEN_FLAT_WORLD_TOOLTIP), SetFill(1, 1),
1266 NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_CS_RANDOM_WORLD), SetStringTip(STR_SE_MAPGEN_RANDOM_LAND, STR_TERRAFORM_TOOLTIP_GENERATE_RANDOM_LAND), SetFill(1, 1),
1267 EndContainer(),
1268
1269 /* Labels + setting drop-downs */
1270 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
1271 /* Labels. */
1272 NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
1273 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_MAPSIZE, STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(0, 1),
1274 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_DATE, STR_MAPGEN_DATE_TOOLTIP), SetFill(0, 1),
1275 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_SE_MAPGEN_FLAT_WORLD_HEIGHT, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_TOOLTIP), SetFill(0, 1),
1276 EndContainer(),
1277
1278 NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
1279 /* Map size. */
1280 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
1281 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_CS_MAPSIZE_X_PULLDOWN), SetToolTip(STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
1282 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_BY), SetFill(0, 1), SetAlignment(SA_CENTER),
1283 NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_CS_MAPSIZE_Y_PULLDOWN), SetToolTip(STR_MAPGEN_MAPSIZE_TOOLTIP), SetFill(1, 1),
1284 EndContainer(),
1285
1286 /* Date. */
1287 NWidget(NWID_HORIZONTAL),
1288 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_CS_START_DATE_DOWN), SetFill(0, 1), SetSpriteTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_MOVE_THE_STARTING_DATE_BACKWARD_TOOLTIP), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
1289 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CS_START_DATE_TEXT), SetFill(1, 1), SetToolTip(STR_MAPGEN_DATE_TOOLTIP),
1290 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_CS_START_DATE_UP), SetFill(0, 1), SetSpriteTip(SPR_ARROW_UP, STR_SCENEDIT_TOOLBAR_MOVE_THE_STARTING_DATE_FORWARD_TOOLTIP), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
1291 EndContainer(),
1292
1293 /* Flat map height. */
1294 NWidget(NWID_HORIZONTAL),
1295 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_CS_FLAT_LAND_HEIGHT_DOWN), SetFill(0, 1), SetSpriteTip(SPR_ARROW_DOWN, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_DOWN_TOOLTIP), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
1296 NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CS_FLAT_LAND_HEIGHT_TEXT), SetFill(1, 1), SetToolTip(STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_TOOLTIP),
1297 NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_CS_FLAT_LAND_HEIGHT_UP), SetFill(0, 1), SetSpriteTip(SPR_ARROW_UP, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_UP_TOOLTIP), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
1298 EndContainer(),
1299 EndContainer(),
1300 EndContainer(),
1301 EndContainer(),
1302 EndContainer(),
1303 EndContainer(),
1304};
1305
1306static WindowDesc _create_scenario_desc(
1307 WDP_CENTER, {}, 0, 0,
1308 WC_GENERATE_LANDSCAPE, WC_NONE,
1309 {},
1310 _nested_create_scenario_widgets
1311);
1312
1314 void ShowCreateScenario()
1315{
1316 CloseWindowByClass(WC_GENERATE_LANDSCAPE);
1317 new CreateScenarioWindow(_create_scenario_desc, GLWM_SCENARIO);
1318}
1319
1320static constexpr std::initializer_list<NWidgetPart> _nested_generate_progress_widgets = {
1321 NWidget(WWT_CAPTION, COLOUR_GREY), SetStringTip(STR_GENERATION_WORLD, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1322 NWidget(WWT_PANEL, COLOUR_GREY),
1323 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0), SetPadding(WidgetDimensions::unscaled.modalpopup),
1324 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GP_PROGRESS_BAR), SetFill(1, 0),
1325 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GP_PROGRESS_TEXT), SetFill(1, 0),
1326 NWidget(WWT_TEXTBTN, COLOUR_WHITE, WID_GP_ABORT), SetStringTip(STR_GENERATION_ABORT), SetFill(1, 0),
1327 EndContainer(),
1328 EndContainer(),
1329};
1330
1331
1332static WindowDesc _generate_progress_desc(
1333 WDP_CENTER, {}, 0, 0,
1334 WC_MODAL_PROGRESS, WC_NONE,
1335 WindowDefaultFlag::NoClose,
1336 _nested_generate_progress_widgets
1337);
1338
1339 struct GenWorldStatus {
1340 static inline uint percent;
1341 static inline StringID cls;
1342 static inline uint current;
1343 static inline uint total;
1344};
1345
1346static const StringID _generation_class_table[] = {
1347 STR_GENERATION_WORLD_GENERATION,
1348 STR_GENERATION_LANDSCAPE_GENERATION,
1349 STR_GENERATION_RIVER_GENERATION,
1350 STR_GENERATION_CLEARING_TILES,
1351 STR_GENERATION_TOWN_GENERATION,
1352 STR_GENERATION_LAND_INDUSTRY_GENERATION,
1353 STR_GENERATION_WATER_INDUSTRY_GENERATION,
1354 STR_GENERATION_OBJECT_GENERATION,
1355 STR_GENERATION_TREE_GENERATION,
1356 STR_GENERATION_SETTINGUP_GAME,
1357 STR_GENERATION_PREPARING_TILELOOP,
1358 STR_GENERATION_PREPARING_SCRIPT,
1359 STR_GENERATION_PREPARING_GAME
1360};
1361static_assert(lengthof(_generation_class_table) == GWP_CLASS_COUNT);
1362
1363
1364static void AbortGeneratingWorldCallback(Window *, bool confirmed)
1365{
1366 if (confirmed) {
1367 AbortGeneratingWorld();
1368 } else if (HasModalProgress() && !IsGeneratingWorldAborted()) {
1369 SetMouseCursor(SPR_CURSOR_ZZZ, PAL_NONE);
1370 }
1371}
1372
1373 struct GenerateProgressWindow : public Window {
1374
1375 GenerateProgressWindow() : Window(_generate_progress_desc)
1376 {
1377 this->InitNested();
1378 }
1379
1380 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1381 {
1382 switch (widget) {
1383 case WID_GP_ABORT:
1384 SetMouseCursorBusy(false);
1385 ShowQuery(
1386 GetEncodedString(STR_GENERATION_ABORT_CAPTION),
1387 GetEncodedString(STR_GENERATION_ABORT_MESSAGE),
1388 this,
1389 AbortGeneratingWorldCallback
1390 );
1391 break;
1392 }
1393 }
1394
1395 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
1396 {
1397 switch (widget) {
1398 case WID_GP_PROGRESS_BAR: {
1399 size = GetStringBoundingBox(GetString(STR_GENERATION_PROGRESS, GetParamMaxValue(100)));
1400 /* We need some spacing for the 'border' */
1401 size.height += WidgetDimensions::scaled.frametext.Horizontal();
1402 size.width += WidgetDimensions::scaled.frametext.Vertical();
1403 break;
1404 }
1405
1406 case WID_GP_PROGRESS_TEXT:
1407 for (uint i = 0; i < GWP_CLASS_COUNT; i++) {
1408 size.width = std::max(size.width, GetStringBoundingBox(_generation_class_table[i]).width + padding.width);
1409 }
1410 size.height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal;
1411 break;
1412 }
1413 }
1414
1415 void DrawWidget(const Rect &r, WidgetID widget) const override
1416 {
1417 switch (widget) {
1418 case WID_GP_PROGRESS_BAR: {
1419 /* Draw the % complete with a bar and a text */
1420 DrawFrameRect(r, COLOUR_GREY, {FrameFlag::BorderOnly, FrameFlag::Lowered});
1421 Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
1422 DrawFrameRect(br.WithWidth(br.Width() * GenWorldStatus::percent / 100, _current_text_dir == TD_RTL), COLOUR_MAUVE, {});
1423 DrawString(br.CentreToHeight(GetCharacterHeight(FS_NORMAL)), GetString(STR_GENERATION_PROGRESS, GenWorldStatus::percent), TC_FROMSTRING, SA_HOR_CENTER);
1424 break;
1425 }
1426
1427 case WID_GP_PROGRESS_TEXT:
1428 /* Tell which class we are generating */
1429 DrawString(r.left, r.right, r.top, GenWorldStatus::cls, TC_FROMSTRING, SA_HOR_CENTER);
1430
1431 /* And say where we are in that class */
1432 DrawString(r.left, r.right, r.top + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal,
1433 GetString(STR_GENERATION_PROGRESS_NUM, GenWorldStatus::current, GenWorldStatus::total), TC_FROMSTRING, SA_HOR_CENTER);
1434 }
1435 }
1436};
1437
1441 void PrepareGenerateWorldProgress()
1442{
1443 GenWorldStatus::cls = STR_GENERATION_WORLD_GENERATION;
1444 GenWorldStatus::current = 0;
1445 GenWorldStatus::total = 0;
1446 GenWorldStatus::percent = 0;
1447}
1448
1452 void ShowGenerateWorldProgress()
1453{
1454 if (BringWindowToFrontById(WC_MODAL_PROGRESS, 0)) return;
1455 new GenerateProgressWindow();
1456}
1457
1458static void _SetGeneratingWorldProgress(GenWorldProgress cls, uint progress, uint total)
1459{
1460 static const int percent_table[] = {0, 5, 14, 17, 20, 40, 55, 60, 65, 80, 85, 95, 99, 100 };
1461 static_assert(lengthof(percent_table) == GWP_CLASS_COUNT + 1);
1462 assert(cls < GWP_CLASS_COUNT);
1463
1464 /* Check if we really are generating the world.
1465 * For example, placing trees via the SE also calls this function, but
1466 * shouldn't try to update the progress.
1467 */
1468 if (!HasModalProgress()) return;
1469
1470 if (IsGeneratingWorldAborted()) {
1471 HandleGeneratingWorldAbortion();
1472 return;
1473 }
1474
1475 if (total == 0) {
1476 assert(GenWorldStatus::cls == _generation_class_table[cls]);
1477 GenWorldStatus::current += progress;
1478 assert(GenWorldStatus::current <= GenWorldStatus::total);
1479 } else {
1480 GenWorldStatus::cls = _generation_class_table[cls];
1481 GenWorldStatus::current = progress;
1482 GenWorldStatus::total = total;
1483 GenWorldStatus::percent = percent_table[cls];
1484 }
1485
1486 /* Percentage is about the number of completed tasks, so 'current - 1' */
1487 GenWorldStatus::percent = percent_table[cls] + (percent_table[cls + 1] - percent_table[cls]) * (GenWorldStatus::current == 0 ? 0 : GenWorldStatus::current - 1) / GenWorldStatus::total;
1488
1489 if (_network_dedicated) {
1490 static uint last_percent = 0;
1491
1492 /* Never display 0% */
1493 if (GenWorldStatus::percent == 0) return;
1494 /* Reset if percent is lower than the last recorded */
1495 if (GenWorldStatus::percent < last_percent) last_percent = 0;
1496 /* Display every 5%, but 6% is also very valid.. just not smaller steps than 5% */
1497 if (GenWorldStatus::percent % 5 != 0 && GenWorldStatus::percent <= last_percent + 5) return;
1498 /* Never show steps smaller than 2%, even if it is a mod 5% */
1499 if (GenWorldStatus::percent <= last_percent + 2) return;
1500
1501 Debug(net, 3, "Map generation percentage complete: {}", GenWorldStatus::percent);
1502 last_percent = GenWorldStatus::percent;
1503
1504 return;
1505 }
1506
1507 SetWindowDirty(WC_MODAL_PROGRESS, 0);
1508
1509 VideoDriver::GetInstance()->GameLoopPause();
1510}
1511
1520 void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
1521{
1522 if (total == 0) return;
1523
1524 _SetGeneratingWorldProgress(cls, 0, total);
1525}
1526
1534 void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
1535{
1536 /* In fact the param 'class' isn't needed.. but for some security reasons, we want it around */
1537 _SetGeneratingWorldProgress(cls, 1, 0);
1538}
ShowAIConfigWindow
void ShowAIConfigWindow()
Open the AI config window.
Definition ai_gui.cpp:334
ai_gui.hpp
Window for configuring the AIs
SetBit
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
Definition bitmath_func.hpp:121
BaseBitSet::Test
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Definition base_bitset_type.hpp:141
BaseBitSet::Flip
constexpr Timpl & Flip(Tvalue_type value)
Flip the value-th bit.
Definition base_bitset_type.hpp:116
DropDownString< DropDownListItem >::NatSortFunc
static bool NatSortFunc(std::unique_ptr< const DropDownListItem > const &first, std::unique_ptr< const DropDownListItem > const &second)
Natural sorting comparator function for DropDownList::sort().
Definition dropdown_common_type.h:99
EncodedString
Container for an encoded string, created by GetEncodedString.
Definition strings_type.h:98
EncodedString::GetDecodedString
std::string GetDecodedString() const
Decode the encoded string.
Definition strings.cpp:207
TimerGameCalendar::ConvertYMDToDate
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition timer_game_calendar.cpp:55
TimerGameConst< struct Calendar >::DEF_START_YEAR
static constexpr TimerGame< struct Calendar >::Year DEF_START_YEAR
The default starting year.
Definition timer_game_common.h:179
TimerGameConst< struct Calendar >::MIN_YEAR
static constexpr TimerGame< struct Calendar >::Year MIN_YEAR
The absolute minimum year in OTTD.
Definition timer_game_common.h:176
TimerGameConst< struct Calendar >::MAX_YEAR
static constexpr TimerGame< struct Calendar >::Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date,...
Definition timer_game_common.h:173
VideoDriver::GetInstance
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Definition video_driver.hpp:192
VideoDriver::GameLoopPause
void GameLoopPause()
Pause the game-loop for a bit, releasing the game-state lock.
Definition video_driver.cpp:68
WidgetDimensions::frametext
RectPadding frametext
Padding inside frame with text.
Definition window_gui.h:41
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition window_gui.h:30
WidgetDimensions::vsep_normal
int vsep_normal
Normal vertical spacing.
Definition window_gui.h:58
WidgetDimensions::fullbevel
RectPadding fullbevel
Always-scaled bevel thickness.
Definition window_gui.h:39
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:93
debug.h
Functions related to debugging.
Debug
#define Debug(category, level, format_string,...)
Output a line of debugging information.
Definition debug.h:37
ShowDropDownMenu
void ShowDropDownMenu(Window *w, std::span< const StringID > strings, int selected, WidgetID button, uint32_t disabled_mask, uint32_t hidden_mask, uint width)
Show a dropdown menu window near a widget of the parent window.
Definition dropdown.cpp:458
ShowDropDownList
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, DropDownOptions options)
Show a drop down list.
Definition dropdown.cpp:418
dropdown_common_type.h
Common drop down list components.
dropdown_func.h
Functions related to the drop down widget.
dropdown_type.h
Types related to the drop down widget.
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:56
to_underlying
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23)
Definition enum_type.hpp:17
error.h
Functions related to errors.
ClearErrorMessages
void ClearErrorMessages()
Clear all errors from the queue.
Definition error_gui.cpp:251
fios.h
Declarations for savegames operations.
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition fontcache.cpp:87
ShowGSConfigWindow
void ShowGSConfigWindow()
Open the GS config window.
Definition game_gui.cpp:425
game_gui.hpp
Window for configuring the Games
HandleGeneratingWorldAbortion
void HandleGeneratingWorldAbortion()
Really handle the abortion, i.e.
Definition genworld.cpp:278
AbortGeneratingWorld
void AbortGeneratingWorld()
Initializes the abortion process.
Definition genworld.cpp:261
IsGeneratingWorldAborted
bool IsGeneratingWorldAborted()
Is the generation being aborted?
Definition genworld.cpp:270
genworld.h
Functions related to world/map generation.
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:54
LG_ORIGINAL
@ LG_ORIGINAL
The original landscape generator.
Definition genworld.h:21
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:50
CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY
static const uint CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY
Value for custom sea level in difficulty settings.
Definition genworld.h:48
GenWorldProgress
GenWorldProgress
Current stage of world generation process.
Definition genworld.h:61
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:49
CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY
static const uint CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY
Value for custom terrain type in difficulty settings.
Definition genworld.h:46
_nested_generate_landscape_widgets
static constexpr std::initializer_list< NWidgetPart > _nested_generate_landscape_widgets
Widgets of GenerateLandscapeWindow when generating world.
Definition genworld_gui.cpp:77
IncreaseGeneratingWorldProgress
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
Definition genworld_gui.cpp:1534
ShowGenerateWorldProgress
void ShowGenerateWorldProgress()
Show the window where a user can follow the process of the map generation.
Definition genworld_gui.cpp:1452
ShowGenerateLandscape
void ShowGenerateLandscape()
Start with a normal game.
Definition genworld_gui.cpp:1041
ShowCreateScenario
void ShowCreateScenario()
Show the window to create a scenario.
Definition genworld_gui.cpp:1314
_nested_heightmap_load_widgets
static constexpr std::initializer_list< NWidgetPart > _nested_heightmap_load_widgets
Widgets of GenerateLandscapeWindow when loading heightmap.
Definition genworld_gui.cpp:201
GetMapHeightLimit
static uint GetMapHeightLimit()
Get the map height limit, or if set to "auto", the absolute limit.
Definition genworld_gui.cpp:59
SetNewLandscapeType
void SetNewLandscapeType(LandscapeType landscape)
Changes landscape type and sets genworld window dirty.
Definition genworld_gui.cpp:69
StartScenarioEditor
void StartScenarioEditor()
Start with a scenario editor.
Definition genworld_gui.cpp:1053
SetGeneratingWorldProgress
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
Definition genworld_gui.cpp:1520
PrepareGenerateWorldProgress
void PrepareGenerateWorldProgress()
Initializes the progress counters to the starting point.
Definition genworld_gui.cpp:1441
GenerateLandscapeWindowMode
GenerateLandscapeWindowMode
Enum for the modes we can generate in.
Definition genworld_gui.cpp:50
GLWM_GENERATE
@ GLWM_GENERATE
Generate new game.
Definition genworld_gui.cpp:51
GLWM_HEIGHTMAP
@ GLWM_HEIGHTMAP
Load from heightmap.
Definition genworld_gui.cpp:52
GLWM_SCENARIO
@ GLWM_SCENARIO
Generate flat land.
Definition genworld_gui.cpp:53
ShowHeightmapLoad
void ShowHeightmapLoad()
Start with loading a heightmap.
Definition genworld_gui.cpp:1047
StartNewGameWithoutGUI
void StartNewGameWithoutGUI(uint32_t seed)
Start a normal game without the GUI.
Definition genworld_gui.cpp:1062
genworld_widget.h
Types related to the genworld widgets.
WID_CS_TROPICAL
@ WID_CS_TROPICAL
Select tropical landscape style.
Definition genworld_widget.h:75
WID_CS_TEMPERATE
@ WID_CS_TEMPERATE
Select temperate landscape style.
Definition genworld_widget.h:73
WID_CS_MAPSIZE_X_PULLDOWN
@ WID_CS_MAPSIZE_X_PULLDOWN
Pull-down arrow for x map size.
Definition genworld_widget.h:79
WID_CS_TOYLAND
@ WID_CS_TOYLAND
Select toy-land landscape style.
Definition genworld_widget.h:76
WID_CS_FLAT_LAND_HEIGHT_TEXT
@ WID_CS_FLAT_LAND_HEIGHT_TEXT
Clickable flat land height value.
Definition genworld_widget.h:85
WID_CS_START_DATE_TEXT
@ WID_CS_START_DATE_TEXT
Clickable start date value.
Definition genworld_widget.h:82
WID_CS_START_DATE_DOWN
@ WID_CS_START_DATE_DOWN
Decrease start year (start earlier).
Definition genworld_widget.h:81
WID_CS_EMPTY_WORLD
@ WID_CS_EMPTY_WORLD
Generate an empty flat world.
Definition genworld_widget.h:77
WID_CS_ARCTIC
@ WID_CS_ARCTIC
Select arctic landscape style.
Definition genworld_widget.h:74
WID_CS_MAPSIZE_Y_PULLDOWN
@ WID_CS_MAPSIZE_Y_PULLDOWN
Pull-down arrow for y map size.
Definition genworld_widget.h:80
WID_CS_FLAT_LAND_HEIGHT_DOWN
@ WID_CS_FLAT_LAND_HEIGHT_DOWN
Decrease flat land height.
Definition genworld_widget.h:84
WID_CS_FLAT_LAND_HEIGHT_UP
@ WID_CS_FLAT_LAND_HEIGHT_UP
Increase flat land height.
Definition genworld_widget.h:86
WID_CS_RANDOM_WORLD
@ WID_CS_RANDOM_WORLD
Generate random land button.
Definition genworld_widget.h:78
WID_CS_START_DATE_UP
@ WID_CS_START_DATE_UP
Increase start year (start later).
Definition genworld_widget.h:83
WID_GL_TOWNNAME_DROPDOWN
@ WID_GL_TOWNNAME_DROPDOWN
Dropdown 'Townnames'.
Definition genworld_widget.h:24
WID_GL_WATER_SE
@ WID_GL_WATER_SE
SE 'Water'/'Freeform'.
Definition genworld_widget.h:60
WID_GL_WATER_PULLDOWN
@ WID_GL_WATER_PULLDOWN
Dropdown 'Sea level'.
Definition genworld_widget.h:52
WID_GL_MAPSIZE_X_PULLDOWN
@ WID_GL_MAPSIZE_X_PULLDOWN
Dropdown 'map X size'.
Definition genworld_widget.h:20
WID_GL_SNOW_COVERAGE_TEXT
@ WID_GL_SNOW_COVERAGE_TEXT
Snow coverage.
Definition genworld_widget.h:38
WID_GL_WATER_NE
@ WID_GL_WATER_NE
NE 'Water'/'Freeform'.
Definition genworld_widget.h:59
WID_GL_VARIETY_PULLDOWN
@ WID_GL_VARIETY_PULLDOWN
Dropdown 'Variety distribution'.
Definition genworld_widget.h:55
WID_GL_TOYLAND
@ WID_GL_TOYLAND
Button with icon "Toyland".
Definition genworld_widget.h:18
WID_GL_GENERATE_BUTTON
@ WID_GL_GENERATE_BUTTON
'Generate' button.
Definition genworld_widget.h:27
WID_GL_ARCTIC
@ WID_GL_ARCTIC
Button with icon "Arctic".
Definition genworld_widget.h:16
WID_GL_HEIGHTMAP_HEIGHT_TEXT
@ WID_GL_HEIGHTMAP_HEIGHT_TEXT
Max. heightmap highest mountain.
Definition genworld_widget.h:30
WID_GL_HEIGHTMAP_ROTATION_PULLDOWN
@ WID_GL_HEIGHTMAP_ROTATION_PULLDOWN
Dropdown 'Heightmap rotation'.
Definition genworld_widget.h:49
WID_GL_MAPSIZE_Y_PULLDOWN
@ WID_GL_MAPSIZE_Y_PULLDOWN
Dropdown 'map Y size'.
Definition genworld_widget.h:21
WID_GL_TROPICAL
@ WID_GL_TROPICAL
Button with icon "Tropical".
Definition genworld_widget.h:17
WID_GL_HEIGHTMAP_NAME_TEXT
@ WID_GL_HEIGHTMAP_NAME_TEXT
Heightmap name.
Definition genworld_widget.h:47
WID_GL_RIVER_PULLDOWN
@ WID_GL_RIVER_PULLDOWN
Dropdown 'Rivers'.
Definition genworld_widget.h:53
WID_GL_DESERT_COVERAGE_TEXT
@ WID_GL_DESERT_COVERAGE_TEXT
Desert coverage.
Definition genworld_widget.h:42
WID_GL_AI_BUTTON
@ WID_GL_AI_BUTTON
'AI Settings' button.
Definition genworld_widget.h:63
WID_GL_SNOW_COVERAGE_DOWN
@ WID_GL_SNOW_COVERAGE_DOWN
Decrease snow coverage.
Definition genworld_widget.h:37
WID_GL_HEIGHTMAP_HEIGHT_UP
@ WID_GL_HEIGHTMAP_HEIGHT_UP
Increase max. heightmap highest mountain.
Definition genworld_widget.h:31
WID_GL_NEWGRF_BUTTON
@ WID_GL_NEWGRF_BUTTON
'NewGRF Settings' button.
Definition genworld_widget.h:65
WID_GL_CLIMATE_SEL_LABEL
@ WID_GL_CLIMATE_SEL_LABEL
NWID_SELECTION for snow or desert coverage label.
Definition genworld_widget.h:67
WID_GL_HEIGHTMAP_SIZE_TEXT
@ WID_GL_HEIGHTMAP_SIZE_TEXT
Size of heightmap.
Definition genworld_widget.h:48
WID_GL_WATER_NW
@ WID_GL_WATER_NW
NW 'Water'/'Freeform'.
Definition genworld_widget.h:58
WID_GL_BORDERS_PULLDOWN
@ WID_GL_BORDERS_PULLDOWN
Dropdown 'Map edges'.
Definition genworld_widget.h:57
WID_GL_TEMPERATE
@ WID_GL_TEMPERATE
Button with icon "Temperate".
Definition genworld_widget.h:15
WID_GL_SMOOTHNESS_PULLDOWN
@ WID_GL_SMOOTHNESS_PULLDOWN
Dropdown 'Smoothness'.
Definition genworld_widget.h:54
WID_GL_GS_BUTTON
@ WID_GL_GS_BUTTON
'Game Script Settings' button.
Definition genworld_widget.h:64
WID_GL_START_DATE_DOWN
@ WID_GL_START_DATE_DOWN
Decrease start year.
Definition genworld_widget.h:33
WID_GL_START_DATE_TEXT
@ WID_GL_START_DATE_TEXT
Start year.
Definition genworld_widget.h:34
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_DESERT_COVERAGE_UP
@ WID_GL_DESERT_COVERAGE_UP
Increase desert coverage.
Definition genworld_widget.h:43
WID_GL_TOWN_PULLDOWN
@ WID_GL_TOWN_PULLDOWN
Dropdown 'No. of towns'.
Definition genworld_widget.h:23
WID_GL_HEIGHTMAP_HEIGHT_DOWN
@ WID_GL_HEIGHTMAP_HEIGHT_DOWN
Decrease heightmap highest mountain.
Definition genworld_widget.h:29
WID_GL_WATER_SW
@ WID_GL_WATER_SW
SW 'Water'/'Freeform'.
Definition genworld_widget.h:61
WID_GL_SNOW_COVERAGE_UP
@ WID_GL_SNOW_COVERAGE_UP
Increase snow coverage.
Definition genworld_widget.h:39
WID_GL_INDUSTRY_PULLDOWN
@ WID_GL_INDUSTRY_PULLDOWN
Dropdown 'No. of industries'.
Definition genworld_widget.h:25
WID_GL_DESERT_COVERAGE_DOWN
@ WID_GL_DESERT_COVERAGE_DOWN
Decrease desert coverage.
Definition genworld_widget.h:41
WID_GL_TERRAIN_PULLDOWN
@ WID_GL_TERRAIN_PULLDOWN
Dropdown 'Terrain type'.
Definition genworld_widget.h:51
WID_GL_START_DATE_UP
@ WID_GL_START_DATE_UP
Increase start year.
Definition genworld_widget.h:35
WID_GP_PROGRESS_TEXT
@ WID_GP_PROGRESS_TEXT
Text with the progress bar.
Definition genworld_widget.h:92
WID_GP_PROGRESS_BAR
@ WID_GP_PROGRESS_BAR
Progress bar.
Definition genworld_widget.h:91
WID_GP_ABORT
@ WID_GP_ABORT
Abort button.
Definition genworld_widget.h:93
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition geometry_func.cpp:22
geometry_func.hpp
Geometry functions.
SetMouseCursor
void SetMouseCursor(CursorID sprite, PaletteID pal)
Assign a single non-animated sprite to the cursor.
Definition gfx.cpp:1703
GetStringBoundingBox
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition gfx.cpp:894
GetStringListBoundingBox
Dimension GetStringListBoundingBox(std::span< const StringID > list, FontSize fontsize)
Get maximum dimension of a list of strings.
Definition gfx.cpp:932
DrawString
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition gfx.cpp:665
_left_button_clicked
bool _left_button_clicked
Is left mouse button clicked?
Definition gfx.cpp:42
SetMouseCursorBusy
void SetMouseCursorBusy(bool busy)
Set or unset the ZZZ cursor.
Definition gfx.cpp:1687
_switch_mode
SwitchMode _switch_mode
The next mainloop command.
Definition gfx.cpp:49
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition gfx_type.h:249
SA_RIGHT
@ SA_RIGHT
Right align the text (must be a single bit).
Definition gfx_type.h:390
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition gfx_type.h:389
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition gfx_type.h:398
SA_VERT_CENTER
@ SA_VERT_CENTER
Vertically center the text.
Definition gfx_type.h:394
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition widget_type.h:1219
SetSpriteTip
constexpr NWidgetPart SetSpriteTip(SpriteID sprite, StringID tip={})
Widget part function for setting the sprite and tooltip.
Definition widget_type.h:1251
SetPIP
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
Definition widget_type.h:1375
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition widget_type.h:1332
SetStringTip
constexpr NWidgetPart SetStringTip(StringID string, StringID tip={})
Widget part function for setting the string and tooltip.
Definition widget_type.h:1240
SetAspect
constexpr NWidgetPart SetAspect(float ratio, AspectFlags flags=AspectFlag::ResizeX)
Widget part function for setting the aspect ratio.
Definition widget_type.h:1410
SetTextStyle
constexpr NWidgetPart SetTextStyle(TextColour colour, FontSize size=FS_NORMAL)
Widget part function for setting the text style.
Definition widget_type.h:1198
SetToolTip
constexpr NWidgetPart SetToolTip(StringID tip)
Widget part function for setting tooltip and clearing the widget data.
Definition widget_type.h:1318
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition widget_type.h:1229
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=INVALID_WIDGET)
Widget part function for starting a new 'real' widget.
Definition widget_type.h:1424
SetMinimalTextLines
constexpr NWidgetPart SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition widget_type.h:1187
SetAlignment
constexpr NWidgetPart SetAlignment(StringAlignment align)
Widget part function for setting the alignment of text/images.
Definition widget_type.h:1208
SetPIPRatio
constexpr NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post)
Widget part function for setting a pre/inter/post ratio.
Definition widget_type.h:1387
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition window.cpp:966
GetHeightmapDimensions
bool GetHeightmapDimensions(DetailedFileType dft, std::string_view filename, uint *x, uint *y)
Get the dimensions of a heightmap.
Definition heightmap.cpp:505
heightmap.h
Functions related to creating heightmaps from files.
HM_CLOCKWISE
@ HM_CLOCKWISE
Rotate the map clockwise 45 degrees.
Definition heightmap.h:21
industry.h
Base of all industries.
BORDERFLAGS_ALL
static constexpr BorderFlags BORDERFLAGS_ALL
Border on all sides.
Definition landscape_type.h:38
LandscapeType
LandscapeType
Landscape types.
Definition landscape_type.h:16
BorderFlag::NorthWest
@ NorthWest
Border on North West.
BorderFlag::Random
@ Random
Randomise borders.
BorderFlag::NorthEast
@ NorthEast
Border on North East.
BorderFlag::SouthEast
@ SouthEast
Border on South East.
BorderFlag::SouthWest
@ SouthWest
Border on South West.
MIN_MAP_SIZE_BITS
static const uint MIN_MAP_SIZE_BITS
Minimal and maximal map width and height.
Definition map_type.h:37
MAX_MAP_SIZE
static const uint MAX_MAP_SIZE
Maximal map size = 4096.
Definition map_type.h:40
MAX_MAP_SIZE_BITS
static const uint MAX_MAP_SIZE_BITS
Maximal size of map is equal to 2 ^ MAX_MAP_SIZE_BITS.
Definition map_type.h:38
Clamp
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition math_func.hpp:79
ShowQuery
void ShowQuery(EncodedString &&caption, EncodedString &&message, Window *parent, QueryCallbackProc *callback, bool focus)
Show a confirmation window with standard 'yes' and 'no' buttons The window is aligned to the centre o...
Definition misc_gui.cpp:1202
ShowQueryString
void ShowQueryString(std::string_view 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:1062
_network_dedicated
bool _network_dedicated
are we a dedicated server?
Definition network.cpp:69
network.h
Basic functions/variables used all over the place.
ResetGRFConfig
void ResetGRFConfig(bool defaults)
Reset the current GRF Config to either blank or newgame settings.
Definition newgrf_config.cpp:407
_grfconfig_newgame
GRFConfigList _grfconfig_newgame
First item in list of default GRF set up.
Definition newgrf_config.cpp:155
ShowNewGRFSettings
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfigList &config)
Setup the NewGRF gui.
Definition newgrf_gui.cpp:1966
newgrf_townname.h
Header of Action 0F "universal holder" structure and functions.
SM_START_HEIGHTMAP
@ SM_START_HEIGHTMAP
Load a heightmap and start a new game from it.
Definition openttd.h:38
SM_GENRANDLAND
@ SM_GENRANDLAND
Generate random land within scenario editor.
Definition openttd.h:36
SM_LOAD_HEIGHTMAP
@ SM_LOAD_HEIGHTMAP
Load heightmap from scenario editor.
Definition openttd.h:39
SM_EDITOR
@ SM_EDITOR
Switch to scenario editor.
Definition openttd.h:31
SM_NEWGAME
@ SM_NEWGAME
New Game --> 'Random game'.
Definition openttd.h:28
progress.h
Functions related to modal progress.
HasModalProgress
bool HasModalProgress()
Check if we are currently in a modal progress state.
Definition progress.h:17
querystring_gui.h
Base for the GUIs that have an edit box in them.
random_func.hpp
Pseudo random number generator.
safeguards.h
A number of safeguards to prevent using unsafe methods.
_file_to_saveload
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
Definition saveload.cpp:78
saveload.h
Functions/types related to saving and loading games.
_settings_newgame
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Definition settings.cpp:62
ID_CUSTOM
@ ID_CUSTOM
Custom number of industries.
Definition settings_type.h:63
ID_END
@ ID_END
Number of industry density settings.
Definition settings_type.h:65
BorderFlagPresets
BorderFlagPresets
Possible options for the Borders pulldown in the Genworld GUI.
Definition settings_type.h:69
SndConfirmBeep
void SndConfirmBeep()
Play a beep sound for a confirm event if enabled in settings.
Definition sound.cpp:261
SndClickBeep
void SndClickBeep()
Play a beep sound for a click event if enabled in settings.
Definition sound.cpp:253
sound_func.h
Functions related to sound.
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
lengthof
#define lengthof(array)
Return the length of an fixed size array.
Definition stdafx.h:271
string_consumer.hpp
Parse strings.
string_func.h
Functions related to low-level strings.
CS_NUMERAL
@ CS_NUMERAL
Only numeric ones.
Definition string_type.h:26
GetParamMaxValue
uint64_t GetParamMaxValue(uint64_t max_value, uint min_count, FontSize size)
Get some number that is suitable for string size computations.
Definition strings.cpp:236
GetEncodedString
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
Definition strings.cpp:90
GetString
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:424
_current_text_dir
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition strings.cpp:56
strings_func.h
Functions related to OTTD's strings.
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition strings_type.h:19
BUILTIN_TOWNNAME_GENERATOR_COUNT
static constexpr uint32_t BUILTIN_TOWNNAME_GENERATOR_COUNT
The number of builtin generators for town names.
Definition strings_type.h:61
TD_RTL
@ TD_RTL
Text is written right-to-left by default.
Definition strings_type.h:27
ConstructionSettings::freeform_edges
bool freeform_edges
allow terraforming the tiles at the map edges
Definition settings_type.h:423
ConstructionSettings::map_height_limit
uint8_t map_height_limit
the maximum allowed heightlevel
Definition settings_type.h:410
Coord2D< int >
CreateScenarioWindow
Definition genworld_gui.cpp:1071
CreateScenarioWindow::GetWidgetString
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
Definition genworld_gui.cpp:1080
CreateScenarioWindow::OnDropdownSelect
void OnDropdownSelect(WidgetID widget, int index, int) override
A dropdown option associated to this window has been selected.
Definition genworld_gui.cpp:1215
CreateScenarioWindow::OnClick
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition genworld_gui.cpp:1147
CreateScenarioWindow::OnQueryTextFinished
void OnQueryTextFinished(std::optional< std::string > str) override
The query window opened from this window has closed.
Definition genworld_gui.cpp:1224
CreateScenarioWindow::UpdateWidgetSize
void UpdateWidgetSize(WidgetID 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:1115
CreateScenarioWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition genworld_gui.cpp:1100
CreateScenarioWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition genworld_gui.cpp:1210
DifficultySettings::number_towns
uint8_t number_towns
the amount of towns
Definition settings_type.h:127
DifficultySettings::terrain_type
uint8_t terrain_type
the mountainousness of the landscape
Definition settings_type.h:137
DifficultySettings::industry_density
uint8_t industry_density
The industry density.
Definition settings_type.h:128
DifficultySettings::quantity_sea_lakes
uint8_t quantity_sea_lakes
the amount of seas/lakes
Definition settings_type.h:138
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition geometry_type.hpp:56
FileToSaveLoad::ftype
FiosType ftype
File type.
Definition saveload.h:429
FileToSaveLoad::name
std::string name
Name of the file.
Definition saveload.h:430
FileToSaveLoad::title
EncodedString title
Internal name of the game.
Definition saveload.h:431
FiosType::detailed
DetailedFileType detailed
Detailed file type.
Definition fileio_type.h:65
GameCreationSettings::water_border_presets
BorderFlagPresets water_border_presets
presets for map border options
Definition settings_type.h:397
GameCreationSettings::custom_sea_level
uint8_t custom_sea_level
manually entered percentage of water in the map
Definition settings_type.h:402
GameCreationSettings::amount_of_rivers
uint8_t amount_of_rivers
the amount of rivers
Definition settings_type.h:405
GameCreationSettings::custom_town_number
uint16_t custom_town_number
manually entered number of towns
Definition settings_type.h:398
GameCreationSettings::custom_industry_number
uint16_t custom_industry_number
manually entered number of industries
Definition settings_type.h:399
GameCreationSettings::variety
uint8_t variety
variety level applied to TGP
Definition settings_type.h:400
GameCreationSettings::snow_coverage
uint8_t snow_coverage
the amount of snow coverage on the map
Definition settings_type.h:387
GameCreationSettings::desert_coverage
uint8_t desert_coverage
the amount of desert coverage on the map
Definition settings_type.h:388
GameCreationSettings::custom_terrain_type
uint8_t custom_terrain_type
manually entered height for TGP to aim for
Definition settings_type.h:401
GameCreationSettings::landscape
LandscapeType landscape
the landscape we're currently in
Definition settings_type.h:395
GameCreationSettings::map_x
uint8_t map_x
X size of map.
Definition settings_type.h:382
GameCreationSettings::land_generator
uint8_t land_generator
the landscape generator
Definition settings_type.h:384
GameCreationSettings::tgen_smoothness
uint8_t tgen_smoothness
how rough is the terrain from 0-3
Definition settings_type.h:390
GameCreationSettings::se_flat_world_height
uint8_t se_flat_world_height
land height a flat world gets in SE
Definition settings_type.h:393
GameCreationSettings::town_name
uint8_t town_name
the town name generator used for town names
Definition settings_type.h:394
GameCreationSettings::map_y
uint8_t map_y
Y size of map.
Definition settings_type.h:383
GameCreationSettings::starting_year
TimerGameCalendar::Year starting_year
starting date
Definition settings_type.h:380
GameCreationSettings::heightmap_rotation
uint8_t heightmap_rotation
rotation director for the heightmap
Definition settings_type.h:392
GameCreationSettings::water_borders
BorderFlags water_borders
bitset of the borders that are water
Definition settings_type.h:396
GameCreationSettings::generation_seed
uint32_t generation_seed
noise seed for world generation
Definition settings_type.h:379
GameCreationSettings::heightmap_height
uint8_t heightmap_height
highest mountain for heightmap (towards what it scales)
Definition settings_type.h:389
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition settings_type.h:635
GameSettings::difficulty
DifficultySettings difficulty
settings related to the difficulty
Definition settings_type.h:633
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition settings_type.h:634
GenWorldStatus
Definition genworld_gui.cpp:1339
GenerateLandscapeWindow
Definition genworld_gui.cpp:391
GenerateLandscapeWindow::UpdateWidgetSize
void UpdateWidgetSize(WidgetID 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:564
GenerateLandscapeWindow::OnDropdownSelect
void OnDropdownSelect(WidgetID widget, int index, int) override
A dropdown option associated to this window has been selected.
Definition genworld_gui.cpp:858
GenerateLandscapeWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition genworld_gui.cpp:849
GenerateLandscapeWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition genworld_gui.cpp:498
GenerateLandscapeWindow::OnClick
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition genworld_gui.cpp:645
GenerateLandscapeWindow::GetWidgetString
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
Definition genworld_gui.cpp:423
GenerateLandscapeWindow::OnQueryTextFinished
void OnQueryTextFinished(std::optional< std::string > str) override
The query window opened from this window has closed.
Definition genworld_gui.cpp:932
GenerateProgressWindow
Definition genworld_gui.cpp:1373
GenerateProgressWindow::OnClick
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition genworld_gui.cpp:1380
GenerateProgressWindow::UpdateWidgetSize
void UpdateWidgetSize(WidgetID 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:1395
GenerateProgressWindow::DrawWidget
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
Definition genworld_gui.cpp:1415
Pool::PoolItem<&_town_pool >::GetNumItems
static size_t GetNumItems()
Returns number of valid items in the pool.
Definition pool_type.hpp:417
Pool::MAX_SIZE
static constexpr size_t MAX_SIZE
Make template parameter accessible from outside.
Definition pool_type.hpp:135
RectPadding::Horizontal
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
Definition geometry_type.hpp:89
RectPadding::Vertical
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Definition geometry_type.hpp:95
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition geometry_type.hpp:101
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition geometry_type.hpp:124
StrongType::Typedef
Templated helper to make a type-safe 'typedef' representing a single POD value.
Definition strong_typedef_type.hpp:130
WindowDesc
High level window description.
Definition window_gui.h:168
WindowNumber
Number to differentiate different windows of the same class.
Definition window_type.h:760
Window
Data structure for an opened window.
Definition window_gui.h:274
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition widget.cpp:766
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:3234
Window::RaiseWidget
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
Definition window_gui.h:470
Window::SetWidgetDirty
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition window.cpp:556
Window::GetWidgetString
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
Definition window.cpp:504
Window::resize
ResizeInfo resize
Resize information.
Definition window_gui.h:315
Window::SetWidgetsDisabledState
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
Definition window_gui.h:516
Window::SetWidgetLoweredState
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition window_gui.h:442
Window::RaiseWidgetsWhenLowered
void RaiseWidgetsWhenLowered(Args... widgets)
Raises the widgets and sets widgets dirty that are lowered.
Definition window_gui.h:537
Window::LowerWidget
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition window_gui.h:461
Window::HandleButtonClick
void HandleButtonClick(WidgetID widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
Definition window.cpp:595
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition window.cpp:1820
Window::flags
WindowFlags flags
Window flags.
Definition window_gui.h:301
Window::SetWidgetDisabledState
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition window_gui.h:382
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition window_gui.h:312
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition window_gui.h:303
QueryStringFlag::EnableDefault
@ EnableDefault
enable the 'Default' button ("\0" is returned)
MAX_TILE_HEIGHT
static constexpr uint MAX_TILE_HEIGHT
Maximum allowed tile height.
Definition tile_type.h:24
MIN_CUSTOM_TERRAIN_TYPE
static constexpr uint MIN_CUSTOM_TERRAIN_TYPE
Lowest possible peak value for world generation.
Definition tile_type.h:27
DEF_DESERT_COVERAGE
static constexpr uint DEF_DESERT_COVERAGE
Default desert coverage.
Definition tile_type.h:37
MIN_MAP_HEIGHT_LIMIT
static constexpr uint MIN_MAP_HEIGHT_LIMIT
Lower bound of maximum allowed heightlevel (in the construction settings)
Definition tile_type.h:29
MAX_MAP_HEIGHT_LIMIT
static constexpr uint MAX_MAP_HEIGHT_LIMIT
Upper bound of maximum allowed heightlevel (in the construction settings)
Definition tile_type.h:30
MIN_HEIGHTMAP_HEIGHT
static constexpr uint MIN_HEIGHTMAP_HEIGHT
Lowest possible peak value for heightmap creation.
Definition tile_type.h:26
DEF_SNOW_COVERAGE
static constexpr uint DEF_SNOW_COVERAGE
Default snow coverage.
Definition tile_type.h:36
timer_game_calendar.h
Definition of the game-calendar-timer.
town.h
Base of the town class.
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:30
CUSTOM_TOWN_NUMBER_DIFFICULTY
static const uint CUSTOM_TOWN_NUMBER_DIFFICULTY
value for custom town number in difficulty settings
Definition town.h:29
townname_type.h
Definition of structures used for generating town names.
video_driver.hpp
Base of all video drivers.
DrawFrameRect
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition widget.cpp:289
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition widget_type.h:104
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition widget_type.h:41
WWT_IMGBTN_2
@ WWT_IMGBTN_2
(Toggle) Button with diff image when clicked
Definition widget_type.h:42
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition widget_type.h:70
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:66
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition widget_type.h:44
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:39
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition widget_type.h:52
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition widget_type.h:68
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition widget_type.h:60
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition widget_type.h:37
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition widget_type.h:61
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition widget_type.h:49
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition widget_type.h:71
EqualSize
@ EqualSize
Containers should keep all their (resizing) children equally large.
Definition widget_type.h:541
CloseWindowByClass
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Definition window.cpp:1205
BringWindowToFrontById
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
Definition window.cpp:1276
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:3355
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition window.cpp:3176
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:3311
window_func.h
Window functions not directly related to making/drawing windows.
WindowDefaultFlag::NoClose
@ NoClose
This window can't be interactively closed.
FrameFlag::BorderOnly
@ BorderOnly
Draw border only, no background.
FrameFlag::Lowered
@ Lowered
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
WindowFlag::Timeout
@ Timeout
Window timeout counter.
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition window_gui.h:145
WidgetID
int WidgetID
Widget ID.
Definition window_type.h:20
WN_GAME_OPTIONS_GAME_OPTIONS
@ WN_GAME_OPTIONS_GAME_OPTIONS
Game options.
Definition window_type.h:31
WC_SELECT_GAME
@ WC_SELECT_GAME
Select game window; Window numbers:
Definition window_type.h:453
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition window_type.h:50
WC_GENERATE_LANDSCAPE
@ WC_GENERATE_LANDSCAPE
Generate landscape (newgame); Window numbers:
Definition window_type.h:467
WC_GAME_OPTIONS
@ WC_GAME_OPTIONS
Game options window; Window numbers:
Definition window_type.h:635
WC_MODAL_PROGRESS
@ WC_MODAL_PROGRESS
Progress report of landscape generation; Window numbers:
Definition window_type.h:474