104 { WWT_IMGBTN_2, RESIZE_NONE, 12, 10, 86, 24, 78, SPR_SELECT_TEMPERATE, STR_030E_SELECT_TEMPERATE_LANDSCAPE}, |
112 { WWT_IMGBTN_2, RESIZE_NONE, 12, 10, 86, 24, 78, SPR_SELECT_TEMPERATE, STR_030E_SELECT_TEMPERATE_LANDSCAPE}, |
105 { WWT_IMGBTN_2, RESIZE_NONE, 12, 90, 166, 24, 78, SPR_SELECT_SUB_ARCTIC, STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE}, |
113 { WWT_IMGBTN_2, RESIZE_NONE, 12, 90, 166, 24, 78, SPR_SELECT_SUB_ARCTIC, STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE}, |
106 { WWT_IMGBTN_2, RESIZE_NONE, 12, 170, 246, 24, 78, SPR_SELECT_SUB_TROPICAL, STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE}, |
114 { WWT_IMGBTN_2, RESIZE_NONE, 12, 170, 246, 24, 78, SPR_SELECT_SUB_TROPICAL, STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE}, |
107 { WWT_IMGBTN_2, RESIZE_NONE, 12, 250, 326, 24, 78, SPR_SELECT_TOYLAND, STR_0311_SELECT_TOYLAND_LANDSCAPE}, |
115 { WWT_IMGBTN_2, RESIZE_NONE, 12, 250, 326, 24, 78, SPR_SELECT_TOYLAND, STR_0311_SELECT_TOYLAND_LANDSCAPE}, |
108 |
116 |
109 { WWT_PANEL, RESIZE_NONE, 12, 114, 149, 90, 101, 0x0, STR_NULL}, |
117 { WWT_TEXT, RESIZE_NONE, 0, 12, 110, 91, 101, STR_MAPSIZE, STR_NULL}, |
110 { WWT_TEXTBTN, RESIZE_NONE, 12, 150, 161, 90, 101, STR_0225, STR_NULL}, // Mapsize X |
118 { WWT_DROPDOWN, RESIZE_NONE, 12, 114, 161, 90, 101, STR_NUM_1, STR_NULL}, // Mapsize X |
111 { WWT_PANEL, RESIZE_NONE, 12, 180, 215, 90, 101, 0x0, STR_NULL}, |
119 { WWT_TEXT, RESIZE_NONE, 0, 168, 176, 91, 101, STR_BY, STR_NULL}, |
112 { WWT_TEXTBTN, RESIZE_NONE, 12, 216, 227, 90, 101, STR_0225, STR_NULL}, // Mapsize Y |
120 { WWT_DROPDOWN, RESIZE_NONE, 12, 180, 227, 90, 101, STR_NUM_2, STR_NULL}, // Mapsize Y |
113 |
121 |
114 { WWT_PANEL, RESIZE_NONE, 12, 114, 163, 112, 123, 0x0, STR_NULL}, |
122 { WWT_TEXT, RESIZE_NONE, 0, 12, 110, 113, 123, STR_NUMBER_OF_TOWNS, STR_NULL}, |
115 { WWT_TEXTBTN, RESIZE_NONE, 12, 164, 175, 112, 123, STR_0225, STR_NULL}, // Number of towns |
123 { WWT_DROPDOWN, RESIZE_NONE, 12, 114, 175, 112, 123, 0x0, STR_NULL}, // Number of towns |
116 { WWT_PANEL, RESIZE_NONE, 12, 114, 163, 130, 141, 0x0, STR_NULL}, |
124 |
117 { WWT_TEXTBTN, RESIZE_NONE, 12, 164, 175, 130, 141, STR_0225, STR_NULL}, // Number of industries |
125 { WWT_TEXT, RESIZE_NONE, 0, 12, 110, 131, 141, STR_NUMBER_OF_INDUSTRIES, STR_NULL}, |
118 |
126 { WWT_DROPDOWN, RESIZE_NONE, 12, 114, 175, 130, 141, 0x0, STR_NULL}, // Number of industries |
|
127 |
|
128 { WWT_TEXT, RESIZE_NONE, 0, 12, 110, 153, 163, STR_RANDOM_SEED, STR_NULL}, |
119 { WWT_PANEL, RESIZE_NONE, 15, 114, 207, 152, 163, 0x0, STR_RANDOM_SEED_HELP}, // Edit box for seed |
129 { WWT_PANEL, RESIZE_NONE, 15, 114, 207, 152, 163, 0x0, STR_RANDOM_SEED_HELP}, // Edit box for seed |
120 { WWT_TEXTBTN, RESIZE_NONE, 12, 216, 326, 152, 163, STR_RANDOM, STR_RANDOM_HELP}, |
130 { WWT_TEXTBTN, RESIZE_NONE, 12, 216, 326, 152, 163, STR_RANDOM, STR_RANDOM_HELP}, |
121 |
131 |
122 { WWT_TEXTBTN, RESIZE_NONE, 6, 243, 326, 228, 257, STR_GENERATE, STR_NULL}, // Generate button |
132 { WWT_TEXTBTN, RESIZE_NONE, 6, 243, 326, 228, 257, STR_GENERATE, STR_NULL}, // Generate button |
123 |
133 |
|
134 { WWT_TEXT, RESIZE_NONE, 0, 182, 212, 113, 123, STR_DATE, STR_NULL}, |
124 { WWT_IMGBTN, RESIZE_NONE, 12, 216, 227, 112, 123, SPR_ARROW_DOWN, STR_029E_MOVE_THE_STARTING_DATE}, |
135 { WWT_IMGBTN, RESIZE_NONE, 12, 216, 227, 112, 123, SPR_ARROW_DOWN, STR_029E_MOVE_THE_STARTING_DATE}, |
125 { WWT_PANEL, RESIZE_NONE, 12, 228, 314, 112, 123, 0x0, STR_NULL}, |
136 { WWT_TEXTBTN, RESIZE_NONE, 12, 228, 314, 112, 123, STR_GENERATE_DATE, STR_NULL}, |
126 { WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 112, 123, SPR_ARROW_UP, STR_029F_MOVE_THE_STARTING_DATE}, |
137 { WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 112, 123, SPR_ARROW_UP, STR_029F_MOVE_THE_STARTING_DATE}, |
127 |
138 |
|
139 { WWT_TEXT, RESIZE_NONE, 0, 182, 278, 131, 141, STR_SNOW_LINE_HEIGHT, STR_NULL}, |
128 { WWT_IMGBTN, RESIZE_NONE, 12, 282, 293, 130, 141, SPR_ARROW_DOWN, STR_SNOW_LINE_DOWN}, |
140 { WWT_IMGBTN, RESIZE_NONE, 12, 282, 293, 130, 141, SPR_ARROW_DOWN, STR_SNOW_LINE_DOWN}, |
129 { WWT_PANEL, RESIZE_NONE, 12, 294, 314, 130, 141, 0x0, STR_NULL}, |
141 { WWT_TEXTBTN, RESIZE_NONE, 12, 294, 314, 130, 141, STR_NUM_3, STR_NULL}, |
130 { WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 130, 141, SPR_ARROW_UP, STR_SNOW_LINE_UP}, |
142 { WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 130, 141, SPR_ARROW_UP, STR_SNOW_LINE_UP}, |
131 |
143 |
132 { WWT_PANEL, RESIZE_NONE, 12, 114, 219, 192, 203, 0x0, STR_NULL}, |
144 { WWT_TEXT, RESIZE_NONE, 0, 12, 110, 193, 203, STR_TREE_PLACER, STR_NULL}, |
133 { WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 192, 203, STR_0225, STR_NULL}, // Tree placer |
145 { WWT_DROPDOWN, RESIZE_NONE, 12, 114, 231, 192, 203, 0x0, STR_NULL}, // Tree placer |
134 { WWT_PANEL, RESIZE_NONE, 12, 114, 219, 174, 185, 0x0, STR_NULL}, |
146 |
135 { WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 174, 185, STR_0225, STR_NULL}, // Landscape generator |
147 { WWT_TEXT, RESIZE_NONE, 0, 12, 110, 175, 185, STR_LAND_GENERATOR, STR_NULL}, |
136 { WWT_PANEL, RESIZE_NONE, 12, 114, 219, 210, 221, 0x0, STR_NULL}, |
148 { WWT_DROPDOWN, RESIZE_NONE, 12, 114, 231, 174, 185, 0x0, STR_NULL}, // Landscape generator |
137 { WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 210, 221, STR_0225, STR_NULL}, // Terrain type |
149 |
138 { WWT_PANEL, RESIZE_NONE, 12, 113, 219, 228, 239, 0x0, STR_NULL}, |
150 { WWT_TEXT, RESIZE_NONE, 0, 12, 110, 211, 221, STR_TERRAIN_TYPE, STR_NULL}, |
139 { WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 228, 239, STR_0225, STR_NULL}, // Water quantity |
151 { WWT_DROPDOWN, RESIZE_NONE, 12, 114, 231, 210, 221, 0x0, STR_NULL}, // Terrain type |
140 { WWT_PANEL, RESIZE_NONE, 12, 113, 219, 246, 257, 0x0, STR_NULL}, |
152 |
141 { WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 246, 257, STR_0225, STR_NULL}, // Map smoothness |
153 { WWT_TEXT, RESIZE_NONE, 0, 12, 110, 229, 239, STR_QUANTITY_OF_SEA_LAKES, STR_NULL}, |
|
154 { WWT_DROPDOWN, RESIZE_NONE, 12, 114, 231, 228, 239, 0x0, STR_NULL}, // Water quantity |
|
155 |
|
156 { WWT_TEXT, RESIZE_NONE, 0, 12, 110, 245, 257, STR_SMOOTHNESS, STR_NULL}, |
|
157 { WWT_DROPDOWN, RESIZE_NONE, 12, 114, 231, 246, 257, 0x0, STR_NULL}, // Map smoothness |
142 { WIDGETS_END}, |
158 { WIDGETS_END}, |
143 }; |
159 }; |
144 |
160 |
145 static const Widget _heightmap_load_widgets[] = { |
161 static const Widget _heightmap_load_widgets[] = { |
146 { WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
162 { WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
150 { WWT_IMGBTN_2, RESIZE_NONE, 12, 10, 86, 24, 78, SPR_SELECT_TEMPERATE, STR_030E_SELECT_TEMPERATE_LANDSCAPE}, |
166 { WWT_IMGBTN_2, RESIZE_NONE, 12, 10, 86, 24, 78, SPR_SELECT_TEMPERATE, STR_030E_SELECT_TEMPERATE_LANDSCAPE}, |
151 { WWT_IMGBTN_2, RESIZE_NONE, 12, 90, 166, 24, 78, SPR_SELECT_SUB_ARCTIC, STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE}, |
167 { WWT_IMGBTN_2, RESIZE_NONE, 12, 90, 166, 24, 78, SPR_SELECT_SUB_ARCTIC, STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE}, |
152 { WWT_IMGBTN_2, RESIZE_NONE, 12, 170, 246, 24, 78, SPR_SELECT_SUB_TROPICAL, STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE}, |
168 { WWT_IMGBTN_2, RESIZE_NONE, 12, 170, 246, 24, 78, SPR_SELECT_SUB_TROPICAL, STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE}, |
153 { WWT_IMGBTN_2, RESIZE_NONE, 12, 250, 326, 24, 78, SPR_SELECT_TOYLAND, STR_0311_SELECT_TOYLAND_LANDSCAPE}, |
169 { WWT_IMGBTN_2, RESIZE_NONE, 12, 250, 326, 24, 78, SPR_SELECT_TOYLAND, STR_0311_SELECT_TOYLAND_LANDSCAPE}, |
154 |
170 |
155 { WWT_PANEL, RESIZE_NONE, 12, 114, 149, 112, 123, 0x0, STR_NULL}, |
171 { WWT_TEXT, RESIZE_NONE, 0, 12, 110, 113, 123, STR_MAPSIZE, STR_NULL}, |
156 { WWT_TEXTBTN, RESIZE_NONE, 12, 150, 161, 112, 123, STR_0225, STR_NULL}, // Mapsize X |
172 { WWT_DROPDOWN, RESIZE_NONE, 12, 114, 161, 112, 123, STR_NUM_1, STR_NULL}, // Mapsize X |
157 { WWT_PANEL, RESIZE_NONE, 12, 180, 215, 112, 123, 0x0, STR_NULL}, |
173 { WWT_TEXT, RESIZE_NONE, 0, 168, 176, 113, 123, STR_BY, STR_NULL}, |
158 { WWT_TEXTBTN, RESIZE_NONE, 12, 216, 227, 112, 123, STR_0225, STR_NULL}, // Mapsize Y |
174 { WWT_DROPDOWN, RESIZE_NONE, 12, 180, 227, 112, 123, STR_NUM_2, STR_NULL}, // Mapsize Y |
159 |
175 |
160 { WWT_PANEL, RESIZE_NONE, 12, 114, 163, 134, 145, 0x0, STR_NULL}, |
176 { WWT_TEXT, RESIZE_NONE, 0, 12, 110, 135, 145, STR_NUMBER_OF_TOWNS, STR_NULL}, |
161 { WWT_TEXTBTN, RESIZE_NONE, 12, 164, 175, 134, 145, STR_0225, STR_NULL}, // Number of towns |
177 { WWT_DROPDOWN, RESIZE_NONE, 12, 114, 175, 134, 145, 0x0, STR_NULL}, // Number of towns |
162 { WWT_PANEL, RESIZE_NONE, 12, 114, 163, 152, 163, 0x0, STR_NULL}, |
178 |
163 { WWT_TEXTBTN, RESIZE_NONE, 12, 164, 175, 152, 163, STR_0225, STR_NULL}, // Number of industries |
179 { WWT_TEXT, RESIZE_NONE, 0, 12, 110, 153, 163, STR_NUMBER_OF_INDUSTRIES, STR_NULL}, |
164 |
180 { WWT_DROPDOWN, RESIZE_NONE, 12, 114, 175, 152, 163, 0x0, STR_NULL}, // Number of industries |
165 { WWT_PANEL, RESIZE_NONE, 15, 114, 194, 174, 185, 0x0, STR_RANDOM_SEED_HELP}, // Edit box for seed |
181 |
166 { WWT_TEXTBTN, RESIZE_NONE, 12, 203, 285, 174, 185, STR_RANDOM, STR_RANDOM_HELP}, |
182 { WWT_TEXT, RESIZE_NONE, 0, 12, 110, 175, 185, STR_RANDOM_SEED, STR_NULL}, |
|
183 { WWT_PANEL, RESIZE_NONE, 15, 114, 207, 174, 185, 0x0, STR_RANDOM_SEED_HELP}, // Edit box for seed |
|
184 { WWT_TEXTBTN, RESIZE_NONE, 12, 216, 326, 174, 185, STR_RANDOM, STR_RANDOM_HELP}, |
167 |
185 |
168 { WWT_TEXTBTN, RESIZE_NONE, 6, 243, 326, 196, 225, STR_GENERATE, STR_NULL}, // Generate button |
186 { WWT_TEXTBTN, RESIZE_NONE, 6, 243, 326, 196, 225, STR_GENERATE, STR_NULL}, // Generate button |
169 |
187 |
|
188 { WWT_TEXT, RESIZE_NONE, 0, 182, 212, 135, 145, STR_DATE, STR_NULL}, |
170 { WWT_IMGBTN, RESIZE_NONE, 12, 216, 227, 134, 145, SPR_ARROW_DOWN, STR_029E_MOVE_THE_STARTING_DATE}, |
189 { WWT_IMGBTN, RESIZE_NONE, 12, 216, 227, 134, 145, SPR_ARROW_DOWN, STR_029E_MOVE_THE_STARTING_DATE}, |
171 { WWT_PANEL, RESIZE_NONE, 12, 228, 314, 134, 145, 0x0, STR_NULL}, |
190 { WWT_TEXTBTN, RESIZE_NONE, 12, 228, 314, 134, 145, STR_GENERATE_DATE, STR_NULL}, |
172 { WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 134, 145, SPR_ARROW_UP, STR_029F_MOVE_THE_STARTING_DATE}, |
191 { WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 134, 145, SPR_ARROW_UP, STR_029F_MOVE_THE_STARTING_DATE}, |
173 |
192 |
|
193 { WWT_TEXT, RESIZE_NONE, 0, 182, 278, 153, 163, STR_SNOW_LINE_HEIGHT, STR_NULL}, |
174 { WWT_IMGBTN, RESIZE_NONE, 12, 282, 293, 152, 163, SPR_ARROW_DOWN, STR_SNOW_LINE_DOWN}, |
194 { WWT_IMGBTN, RESIZE_NONE, 12, 282, 293, 152, 163, SPR_ARROW_DOWN, STR_SNOW_LINE_DOWN}, |
175 { WWT_PANEL, RESIZE_NONE, 12, 294, 314, 152, 163, 0x0, STR_NULL}, |
195 { WWT_TEXTBTN, RESIZE_NONE, 12, 294, 314, 152, 163, STR_NUM_3, STR_NULL}, |
176 { WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 152, 163, SPR_ARROW_UP, STR_SNOW_LINE_UP}, |
196 { WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 152, 163, SPR_ARROW_UP, STR_SNOW_LINE_UP}, |
177 |
197 |
178 { WWT_PANEL, RESIZE_NONE, 12, 114, 219, 196, 207, 0x0, STR_NULL}, |
198 { WWT_TEXT, RESIZE_NONE, 0, 12, 110, 197, 207, STR_TREE_PLACER, STR_NULL}, |
179 { WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 196, 207, STR_0225, STR_NULL}, // Tree placer |
199 { WWT_DROPDOWN, RESIZE_NONE, 12, 114, 231, 196, 207, STR_0225, STR_NULL}, // Tree placer |
180 |
200 |
181 { WWT_PANEL, RESIZE_NONE, 12, 114, 219, 214, 225, 0x0, STR_NULL}, |
201 { WWT_TEXT, RESIZE_NONE, 0, 12, 110, 215, 225, STR_HEIGHTMAP_ROTATION, STR_NULL}, |
182 { WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 214, 225, STR_0225, STR_NULL}, // Heightmap rotation |
202 { WWT_DROPDOWN, RESIZE_NONE, 12, 114, 231, 214, 225, STR_0225, STR_NULL}, // Heightmap rotation |
|
203 |
183 { WIDGETS_END}, |
204 { WIDGETS_END}, |
184 }; |
205 }; |
185 |
206 |
186 void StartGeneratingLandscape(glwp_modes mode) |
207 void StartGeneratingLandscape(glwp_modes mode) |
187 { |
208 { |
222 /* Data used for the generate seed edit box */ |
255 /* Data used for the generate seed edit box */ |
223 static querystr_d _genseed_query; |
256 static querystr_d _genseed_query; |
224 static char _genseed_buffer[11]; |
257 static char _genseed_buffer[11]; |
225 |
258 |
226 glwp_modes mode = (glwp_modes)w->window_number; |
259 glwp_modes mode = (glwp_modes)w->window_number; |
227 uint y; |
|
228 |
260 |
229 switch (e->event) { |
261 switch (e->event) { |
230 case WE_CREATE: |
262 case WE_CREATE: |
231 w->LowerWidget(_opt_newgame.landscape + GLAND_TEMPERATE); |
263 w->LowerWidget(_opt_newgame.landscape + GLAND_TEMPERATE); |
232 |
264 |
233 snprintf(_genseed_buffer, sizeof(_genseed_buffer), "%u", _patches_newgame.generation_seed); |
265 snprintf(_genseed_buffer, sizeof(_genseed_buffer), "%u", _patches_newgame.generation_seed); |
234 InitializeTextBuffer(&_genseed_query.text, _genseed_buffer, lengthof(_genseed_buffer), 120); |
266 InitializeTextBuffer(&_genseed_query.text, _genseed_buffer, lengthof(_genseed_buffer), 120); |
235 _genseed_query.caption = STR_NULL; |
267 _genseed_query.caption = STR_NULL; |
236 _genseed_query.afilter = CS_NUMERAL; |
268 _genseed_query.afilter = CS_NUMERAL; |
237 break; |
269 break; |
238 |
270 |
239 case WE_PAINT: |
271 case WE_PAINT: |
240 /* You can't select smoothness if not terragenesis */ |
272 /* You can't select smoothness if not terragenesis */ |
241 if (mode == GLWP_GENERATE) { |
273 if (mode == GLWP_GENERATE) { |
242 w->SetWidgetDisabledState(GLAND_SMOOTHNESS_TEXT, _patches_newgame.land_generator == 0); |
274 w->SetWidgetDisabledState(GLAND_SMOOTHNESS_PULLDOWN, _patches_newgame.land_generator == 0); |
243 w->SetWidgetDisabledState(GLAND_SMOOTHNESS_PULLDOWN, _patches_newgame.land_generator == 0); |
275 } |
244 } |
276 /* Disable snowline if not hilly */ |
245 /* Disable snowline if not hilly */ |
277 w->SetWidgetDisabledState(GLAND_SNOW_LEVEL_TEXT, _opt_newgame.landscape != LT_ARCTIC); |
246 w->SetWidgetDisabledState(GLAND_SNOW_LEVEL_TEXT, _opt_newgame.landscape != LT_ARCTIC); |
278 /* Disable town, industry and trees in SE */ |
247 /* Disable town, industry and trees in SE */ |
279 w->SetWidgetDisabledState(GLAND_TOWN_PULLDOWN, _game_mode == GM_EDITOR); |
248 w->SetWidgetDisabledState(GLAND_TOWN_TEXT, _game_mode == GM_EDITOR); |
280 w->SetWidgetDisabledState(GLAND_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR); |
249 w->SetWidgetDisabledState(GLAND_TOWN_PULLDOWN, _game_mode == GM_EDITOR); |
281 w->SetWidgetDisabledState(GLAND_TREE_PULLDOWN, _game_mode == GM_EDITOR); |
250 w->SetWidgetDisabledState(GLAND_INDUSTRY_TEXT, _game_mode == GM_EDITOR); |
282 |
251 w->SetWidgetDisabledState(GLAND_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR); |
283 w->SetWidgetDisabledState(GLAND_START_DATE_DOWN, _patches_newgame.starting_year <= MIN_YEAR); |
252 w->SetWidgetDisabledState(GLAND_TREE_TEXT, _game_mode == GM_EDITOR); |
284 w->SetWidgetDisabledState(GLAND_START_DATE_UP, _patches_newgame.starting_year >= MAX_YEAR); |
253 w->SetWidgetDisabledState(GLAND_TREE_PULLDOWN, _game_mode == GM_EDITOR); |
285 w->SetWidgetDisabledState(GLAND_SNOW_LEVEL_DOWN, _patches_newgame.snow_line_height <= 2 || _opt_newgame.landscape != LT_ARCTIC); |
254 |
286 w->SetWidgetDisabledState(GLAND_SNOW_LEVEL_UP, _patches_newgame.snow_line_height >= MAX_SNOWLINE_HEIGHT || _opt_newgame.landscape != LT_ARCTIC); |
255 w->SetWidgetDisabledState(GLAND_START_DATE_DOWN, _patches_newgame.starting_year <= MIN_YEAR); |
287 |
256 w->SetWidgetDisabledState(GLAND_START_DATE_UP, _patches_newgame.starting_year >= MAX_YEAR); |
288 w->SetWidgetLoweredState(GLAND_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE); |
257 w->SetWidgetDisabledState(GLAND_SNOW_LEVEL_DOWN, _patches_newgame.snow_line_height <= 2 || _opt_newgame.landscape != LT_ARCTIC); |
289 w->SetWidgetLoweredState(GLAND_ARCTIC, _opt_newgame.landscape == LT_ARCTIC); |
258 w->SetWidgetDisabledState(GLAND_SNOW_LEVEL_UP, _patches_newgame.snow_line_height >= MAX_SNOWLINE_HEIGHT || _opt_newgame.landscape != LT_ARCTIC); |
290 w->SetWidgetLoweredState(GLAND_TROPICAL, _opt_newgame.landscape == LT_TROPIC); |
259 |
291 w->SetWidgetLoweredState(GLAND_TOYLAND, _opt_newgame.landscape == LT_TOYLAND); |
260 w->SetWidgetLoweredState(GLAND_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE); |
292 |
261 w->SetWidgetLoweredState(GLAND_ARCTIC, _opt_newgame.landscape == LT_ARCTIC); |
293 if (_game_mode == GM_EDITOR) { |
262 w->SetWidgetLoweredState(GLAND_TROPICAL, _opt_newgame.landscape == LT_TROPIC); |
294 w->widget[GLAND_TOWN_PULLDOWN].data = STR_6836_OFF; |
263 w->SetWidgetLoweredState(GLAND_TOYLAND, _opt_newgame.landscape == LT_TOYLAND); |
295 w->widget[GLAND_INDUSTRY_PULLDOWN].data = STR_6836_OFF; |
264 DrawWindowWidgets(w); |
|
265 |
|
266 y = (mode == GLWP_HEIGHTMAP) ? 22 : 0; |
|
267 |
|
268 DrawString( 12, 91 + y, STR_MAPSIZE, TC_FROMSTRING); |
|
269 DrawString(119, 91 + y, mapsizes[_patches_newgame.map_x - 6], TC_BLACK); |
|
270 DrawString(168, 91 + y, STR_BY, TC_FROMSTRING); |
|
271 DrawString(182, 91 + y, mapsizes[_patches_newgame.map_y - 6], TC_BLACK); |
|
272 |
|
273 DrawString( 12, 113 + y, STR_NUMBER_OF_TOWNS, TC_FROMSTRING); |
|
274 DrawString( 12, 131 + y, STR_NUMBER_OF_INDUSTRIES, TC_FROMSTRING); |
|
275 if (_game_mode == GM_EDITOR) { |
|
276 DrawString(118, 113 + y, STR_6836_OFF, TC_BLACK); |
|
277 DrawString(118, 131 + y, STR_6836_OFF, TC_BLACK); |
|
278 } else { |
|
279 DrawString(118, 113 + y, num_towns[_opt_newgame.diff.number_towns], TC_BLACK); |
|
280 DrawString(118, 131 + y, num_inds[_opt_newgame.diff.number_industries], TC_BLACK); |
|
281 } |
|
282 |
|
283 DrawString( 12, 153 + y, STR_RANDOM_SEED, TC_FROMSTRING); |
|
284 DrawEditBox(w, &_genseed_query, GLAND_RANDOM_EDITBOX); |
|
285 |
|
286 DrawString(182, 113 + y, STR_DATE, TC_FROMSTRING); |
|
287 SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); |
|
288 DrawStringCentered(271, 113 + y, STR_GENERATE_DATE, TC_FROMSTRING); |
|
289 |
|
290 DrawString(182, 131 + y, STR_SNOW_LINE_HEIGHT, TC_FROMSTRING); |
|
291 SetDParam(0, _patches_newgame.snow_line_height); |
|
292 DrawStringCentered(303, 131 + y, STR_SNOW_LINE_HEIGHT_NUM, TC_BLACK); |
|
293 |
|
294 if (mode == GLWP_GENERATE) { |
|
295 DrawString( 12, 175, STR_LAND_GENERATOR, TC_FROMSTRING); |
|
296 DrawString(118, 175, landscape[_patches_newgame.land_generator], TC_BLACK); |
|
297 |
|
298 DrawString( 12, 193, STR_TREE_PLACER, TC_FROMSTRING); |
|
299 DrawString(118, 193, tree_placer[_patches_newgame.tree_placer], TC_BLACK); |
|
300 |
|
301 DrawString( 12, 211, STR_TERRAIN_TYPE, TC_FROMSTRING); |
|
302 DrawString(118, 211, elevations[_opt_newgame.diff.terrain_type], TC_BLACK); |
|
303 |
|
304 DrawString( 12, 229, STR_QUANTITY_OF_SEA_LAKES, TC_FROMSTRING); |
|
305 DrawString(118, 229, sea_lakes[_opt_newgame.diff.quantity_sea_lakes], TC_BLACK); |
|
306 |
|
307 DrawString( 12, 247, STR_SMOOTHNESS, TC_FROMSTRING); |
|
308 DrawString(118, 247, smoothness[_patches_newgame.tgen_smoothness], TC_BLACK); |
|
309 } else { |
|
310 char buffer[512]; |
|
311 |
|
312 if (_patches_newgame.heightmap_rotation == HM_CLOCKWISE) { |
|
313 SetDParam(0, WP(w, generate_d).y); |
|
314 SetDParam(1, WP(w, generate_d).x); |
|
315 } else { |
296 } else { |
316 SetDParam(0, WP(w, generate_d).x); |
297 w->widget[GLAND_TOWN_PULLDOWN].data = num_towns[_opt_newgame.diff.number_towns]; |
317 SetDParam(1, WP(w, generate_d).y); |
298 w->widget[GLAND_INDUSTRY_PULLDOWN].data = num_inds[_opt_newgame.diff.number_industries]; |
318 } |
299 } |
319 GetString(buffer, STR_HEIGHTMAP_SIZE, lastof(buffer)); |
300 |
320 DrawStringRightAligned(326, 91, STR_HEIGHTMAP_SIZE, TC_BLACK); |
301 if (mode == GLWP_GENERATE) { |
321 |
302 w->widget[GLAND_LANDSCAPE_PULLDOWN].data = landscape[_patches_newgame.land_generator]; |
322 DrawString( 12, 91, STR_HEIGHTMAP_NAME, TC_BLACK); |
303 w->widget[GLAND_TREE_PULLDOWN].data = tree_placer[_patches_newgame.tree_placer]; |
323 SetDParamStr(0, WP(w, generate_d).name); |
304 w->widget[GLAND_TERRAIN_PULLDOWN].data = elevations[_opt_newgame.diff.terrain_type]; |
324 DrawStringTruncated(114, 91, STR_ORANGE, TC_BLACK, 326 - 114 - GetStringBoundingBox(buffer).width - 5); |
305 w->widget[GLAND_WATER_PULLDOWN].data = sea_lakes[_opt_newgame.diff.quantity_sea_lakes]; |
325 |
306 w->widget[GLAND_SMOOTHNESS_PULLDOWN].data = smoothness[_patches_newgame.tgen_smoothness]; |
326 DrawString( 12, 197, STR_TREE_PLACER, TC_FROMSTRING); |
307 } else { |
327 DrawString(118, 197, tree_placer[_patches_newgame.tree_placer], TC_BLACK); |
308 w->widget[GLAND_TREE_PULLDOWN].data = tree_placer[_patches_newgame.tree_placer]; |
328 |
309 w->widget[GLAND_HEIGHTMAP_ROTATION_PULLDOWN].data = rotation[_patches_newgame.heightmap_rotation]; |
329 DrawString( 12, 215, STR_HEIGHTMAP_ROTATION, TC_FROMSTRING); |
310 } |
330 DrawString(118, 215, rotation[_patches_newgame.heightmap_rotation], TC_BLACK); |
311 |
331 } |
312 /* Set parameters for widget text that requires them. */ |
332 |
313 SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); // GLAND_START_DATE_TEXT |
333 break; |
314 SetDParam(1, 1 << _patches_newgame.map_x); // GLAND_MAPSIZE_X_PULLDOWN |
334 case WE_CLICK: |
315 SetDParam(2, 1 << _patches_newgame.map_y); // GLAND_MAPSIZE_Y_PULLDOWN |
335 switch (e->we.click.widget) { |
316 SetDParam(3, _patches_newgame.snow_line_height); // GLAND_SNOW_LEVEL_TEXT |
336 case 0: DeleteWindow(w); break; |
317 |
337 case GLAND_TEMPERATE: case GLAND_ARCTIC: case GLAND_TROPICAL: case GLAND_TOYLAND: |
318 DrawWindowWidgets(w); |
338 w->RaiseWidget(_opt_newgame.landscape + GLAND_TEMPERATE); |
319 |
339 SetNewLandscapeType(e->we.click.widget - GLAND_TEMPERATE); |
320 DrawEditBox(w, &_genseed_query, GLAND_RANDOM_EDITBOX); |
340 break; |
321 |
341 case GLAND_MAPSIZE_X_TEXT: case GLAND_MAPSIZE_X_PULLDOWN: // Mapsize X |
322 if (mode != GLWP_GENERATE) { |
342 ShowDropDownMenu(w, mapsizes, _patches_newgame.map_x - 6, GLAND_MAPSIZE_X_PULLDOWN, 0, 0); |
323 char buffer[512]; |
343 break; |
324 |
344 case GLAND_MAPSIZE_Y_TEXT: case GLAND_MAPSIZE_Y_PULLDOWN: // Mapsize Y |
325 if (_patches_newgame.heightmap_rotation == HM_CLOCKWISE) { |
345 ShowDropDownMenu(w, mapsizes, _patches_newgame.map_y - 6, GLAND_MAPSIZE_Y_PULLDOWN, 0, 0); |
326 SetDParam(0, WP(w, generate_d).y); |
346 break; |
327 SetDParam(1, WP(w, generate_d).x); |
347 case GLAND_TOWN_TEXT: case GLAND_TOWN_PULLDOWN: // Number of towns |
328 } else { |
348 ShowDropDownMenu(w, num_towns, _opt_newgame.diff.number_towns, GLAND_TOWN_PULLDOWN, 0, 0); |
329 SetDParam(0, WP(w, generate_d).x); |
349 break; |
330 SetDParam(1, WP(w, generate_d).y); |
350 case GLAND_INDUSTRY_TEXT: case GLAND_INDUSTRY_PULLDOWN: // Number of industries |
331 } |
351 ShowDropDownMenu(w, num_inds, _opt_newgame.diff.number_industries, GLAND_INDUSTRY_PULLDOWN, 0, 0); |
332 GetString(buffer, STR_HEIGHTMAP_SIZE, lastof(buffer)); |
352 break; |
333 DrawStringRightAligned(326, 91, STR_HEIGHTMAP_SIZE, TC_BLACK); |
353 case GLAND_RANDOM_BUTTON: // Random seed |
334 |
354 _patches_newgame.generation_seed = InteractiveRandom(); |
335 DrawString( 12, 91, STR_HEIGHTMAP_NAME, TC_BLACK); |
355 snprintf(_genseed_buffer, lengthof(_genseed_buffer), "%u", _patches_newgame.generation_seed); |
336 SetDParamStr(0, WP(w, generate_d).name); |
356 UpdateTextBufferSize(&_genseed_query.text); |
337 DrawStringTruncated(114, 91, STR_ORANGE, TC_BLACK, 326 - 114 - GetStringBoundingBox(buffer).width - 5); |
|
338 } |
|
339 break; |
|
340 |
|
341 case WE_CLICK: |
|
342 switch (e->we.click.widget) { |
|
343 case 0: DeleteWindow(w); break; |
|
344 |
|
345 case GLAND_TEMPERATE: |
|
346 case GLAND_ARCTIC: |
|
347 case GLAND_TROPICAL: |
|
348 case GLAND_TOYLAND: |
|
349 w->RaiseWidget(_opt_newgame.landscape + GLAND_TEMPERATE); |
|
350 SetNewLandscapeType(e->we.click.widget - GLAND_TEMPERATE); |
|
351 break; |
|
352 |
|
353 case GLAND_MAPSIZE_X_PULLDOWN: // Mapsize X |
|
354 ShowDropDownList(w, BuildMapsizeDropDown(), _patches_newgame.map_x, GLAND_MAPSIZE_X_PULLDOWN); |
|
355 break; |
|
356 |
|
357 case GLAND_MAPSIZE_Y_PULLDOWN: // Mapsize Y |
|
358 ShowDropDownList(w, BuildMapsizeDropDown(), _patches_newgame.map_y, GLAND_MAPSIZE_Y_PULLDOWN); |
|
359 break; |
|
360 |
|
361 case GLAND_TOWN_PULLDOWN: // Number of towns |
|
362 ShowDropDownMenu(w, num_towns, _opt_newgame.diff.number_towns, GLAND_TOWN_PULLDOWN, 0, 0); |
|
363 break; |
|
364 |
|
365 case GLAND_INDUSTRY_PULLDOWN: // Number of industries |
|
366 ShowDropDownMenu(w, num_inds, _opt_newgame.diff.number_industries, GLAND_INDUSTRY_PULLDOWN, 0, 0); |
|
367 break; |
|
368 |
|
369 case GLAND_RANDOM_BUTTON: // Random seed |
|
370 _patches_newgame.generation_seed = InteractiveRandom(); |
|
371 snprintf(_genseed_buffer, lengthof(_genseed_buffer), "%u", _patches_newgame.generation_seed); |
|
372 UpdateTextBufferSize(&_genseed_query.text); |
|
373 SetWindowDirty(w); |
|
374 break; |
|
375 |
|
376 case GLAND_GENERATE_BUTTON: // Generate |
|
377 |
|
378 UpdatePatches(); |
|
379 |
|
380 if (_patches.town_layout == TL_NO_ROADS) { |
|
381 ShowQuery( |
|
382 STR_TOWN_LAYOUT_WARNING_CAPTION, |
|
383 STR_TOWN_LAYOUT_WARNING_MESSAGE, |
|
384 w, |
|
385 LandscapeGenerationCallback); |
|
386 } else if (mode == GLWP_HEIGHTMAP && |
|
387 (WP(w, generate_d).x * 2 < (1U << _patches_newgame.map_x) || |
|
388 WP(w, generate_d).x / 2 > (1U << _patches_newgame.map_x) || |
|
389 WP(w, generate_d).y * 2 < (1U << _patches_newgame.map_y) || |
|
390 WP(w, generate_d).y / 2 > (1U << _patches_newgame.map_y))) { |
|
391 ShowQuery( |
|
392 STR_HEIGHTMAP_SCALE_WARNING_CAPTION, |
|
393 STR_HEIGHTMAP_SCALE_WARNING_MESSAGE, |
|
394 w, |
|
395 LandscapeGenerationCallback); |
|
396 } else { |
|
397 StartGeneratingLandscape(mode); |
|
398 } |
|
399 break; |
|
400 |
|
401 case GLAND_START_DATE_DOWN: |
|
402 case GLAND_START_DATE_UP: // Year buttons |
|
403 /* Don't allow too fast scrolling */ |
|
404 if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { |
|
405 w->HandleButtonClick(e->we.click.widget); |
|
406 SetWindowDirty(w); |
|
407 |
|
408 _patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + e->we.click.widget - GLAND_START_DATE_TEXT, MIN_YEAR, MAX_YEAR); |
|
409 } |
|
410 _left_button_clicked = false; |
|
411 break; |
|
412 |
|
413 case GLAND_START_DATE_TEXT: // Year text |
|
414 WP(w, generate_d).widget_id = GLAND_START_DATE_TEXT; |
|
415 SetDParam(0, _patches_newgame.starting_year); |
|
416 ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, w, CS_NUMERAL); |
|
417 break; |
|
418 |
|
419 case GLAND_SNOW_LEVEL_DOWN: |
|
420 case GLAND_SNOW_LEVEL_UP: // Snow line buttons |
|
421 /* Don't allow too fast scrolling */ |
|
422 if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { |
|
423 w->HandleButtonClick(e->we.click.widget); |
|
424 SetWindowDirty(w); |
|
425 |
|
426 _patches_newgame.snow_line_height = Clamp(_patches_newgame.snow_line_height + e->we.click.widget - GLAND_SNOW_LEVEL_TEXT, 2, MAX_SNOWLINE_HEIGHT); |
|
427 } |
|
428 _left_button_clicked = false; |
|
429 break; |
|
430 |
|
431 case GLAND_SNOW_LEVEL_TEXT: // Snow line text |
|
432 WP(w, generate_d).widget_id = GLAND_SNOW_LEVEL_TEXT; |
|
433 SetDParam(0, _patches_newgame.snow_line_height); |
|
434 ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_SNOW_LINE_QUERY_CAPT, 3, 100, w, CS_NUMERAL); |
|
435 break; |
|
436 |
|
437 case GLAND_TREE_PULLDOWN: // Tree placer |
|
438 ShowDropDownMenu(w, tree_placer, _patches_newgame.tree_placer, GLAND_TREE_PULLDOWN, 0, 0); |
|
439 break; |
|
440 |
|
441 case GLAND_LANDSCAPE_PULLDOWN: // Landscape generator OR Heightmap rotation |
|
442 /* case GLAND_HEIGHTMAP_ROTATION_TEXT: case GLAND_HEIGHTMAP_ROTATION_PULLDOWN:*/ |
|
443 if (mode == GLWP_HEIGHTMAP) { |
|
444 ShowDropDownMenu(w, rotation, _patches_newgame.heightmap_rotation, GLAND_HEIGHTMAP_ROTATION_PULLDOWN, 0, 0); |
|
445 } else { |
|
446 ShowDropDownMenu(w, landscape, _patches_newgame.land_generator, GLAND_LANDSCAPE_PULLDOWN, 0, 0); |
|
447 } |
|
448 break; |
|
449 |
|
450 case GLAND_TERRAIN_PULLDOWN: // Terrain type |
|
451 ShowDropDownMenu(w, elevations, _opt_newgame.diff.terrain_type, GLAND_TERRAIN_PULLDOWN, 0, 0); |
|
452 break; |
|
453 |
|
454 case GLAND_WATER_PULLDOWN: // Water quantity |
|
455 ShowDropDownMenu(w, sea_lakes, _opt_newgame.diff.quantity_sea_lakes, GLAND_WATER_PULLDOWN, 0, 0); |
|
456 break; |
|
457 |
|
458 case GLAND_SMOOTHNESS_PULLDOWN: // Map smoothness |
|
459 ShowDropDownMenu(w, smoothness, _patches_newgame.tgen_smoothness, GLAND_SMOOTHNESS_PULLDOWN, 0, 0); |
|
460 break; |
|
461 } |
|
462 break; |
|
463 |
|
464 case WE_MOUSELOOP: |
|
465 HandleEditBox(w, &_genseed_query, GLAND_RANDOM_EDITBOX); |
|
466 break; |
|
467 |
|
468 case WE_KEYPRESS: |
|
469 HandleEditBoxKey(w, &_genseed_query, GLAND_RANDOM_EDITBOX, e); |
|
470 /* the seed is unsigned, therefore atoi cannot be used. |
|
471 * As 2^32 - 1 (MAX_UVALUE(uint32)) is a 'magic' value |
|
472 * (use random seed) it should not be possible to be |
|
473 * entered into the input field; the generate seed |
|
474 * button can be used instead. */ |
|
475 _patches_newgame.generation_seed = minu(strtoul(_genseed_buffer, NULL, sizeof(_genseed_buffer) - 1), MAX_UVALUE(uint32) - 1); |
|
476 break; |
|
477 |
|
478 case WE_DROPDOWN_SELECT: |
|
479 switch (e->we.dropdown.button) { |
|
480 case GLAND_MAPSIZE_X_PULLDOWN: _patches_newgame.map_x = e->we.dropdown.index; break; |
|
481 case GLAND_MAPSIZE_Y_PULLDOWN: _patches_newgame.map_y = e->we.dropdown.index; break; |
|
482 case GLAND_TREE_PULLDOWN: _patches_newgame.tree_placer = e->we.dropdown.index; break; |
|
483 case GLAND_SMOOTHNESS_PULLDOWN: _patches_newgame.tgen_smoothness = e->we.dropdown.index; break; |
|
484 |
|
485 case GLAND_TOWN_PULLDOWN: |
|
486 _opt_newgame.diff.number_towns = e->we.dropdown.index; |
|
487 if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0); |
|
488 DoCommandP(0, 2, _opt_newgame.diff.number_towns, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); |
|
489 break; |
|
490 |
|
491 case GLAND_INDUSTRY_PULLDOWN: |
|
492 _opt_newgame.diff.number_industries = e->we.dropdown.index; |
|
493 if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0); |
|
494 DoCommandP(0, 3, _opt_newgame.diff.number_industries, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); |
|
495 break; |
|
496 |
|
497 case GLAND_LANDSCAPE_PULLDOWN: |
|
498 /* case GLAND_HEIGHTMAP_PULLDOWN: */ |
|
499 if (mode == GLWP_HEIGHTMAP) { |
|
500 _patches_newgame.heightmap_rotation = e->we.dropdown.index; |
|
501 } else { |
|
502 _patches_newgame.land_generator = e->we.dropdown.index; |
|
503 } |
|
504 break; |
|
505 |
|
506 case GLAND_TERRAIN_PULLDOWN: |
|
507 _opt_newgame.diff.terrain_type = e->we.dropdown.index; |
|
508 if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0); |
|
509 DoCommandP(0, 12, _opt_newgame.diff.terrain_type, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); |
|
510 break; |
|
511 |
|
512 case GLAND_WATER_PULLDOWN: |
|
513 _opt_newgame.diff.quantity_sea_lakes = e->we.dropdown.index; |
|
514 if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0); |
|
515 DoCommandP(0, 13, _opt_newgame.diff.quantity_sea_lakes, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); |
|
516 break; |
|
517 } |
357 SetWindowDirty(w); |
518 SetWindowDirty(w); |
358 break; |
519 break; |
359 case GLAND_GENERATE_BUTTON: // Generate |
520 |
360 |
521 case WE_ON_EDIT_TEXT: |
361 UpdatePatches(); |
522 if (e->we.edittext.str != NULL) { |
362 |
523 int32 value = atoi(e->we.edittext.str); |
363 if (_patches.town_layout == TL_NO_ROADS) { |
524 |
364 ShowQuery( |
525 switch (WP(w, generate_d).widget_id) { |
365 STR_TOWN_LAYOUT_WARNING_CAPTION, |
526 case GLAND_START_DATE_TEXT: |
366 STR_TOWN_LAYOUT_WARNING_MESSAGE, |
527 w->InvalidateWidget(GLAND_START_DATE_TEXT); |
367 w, |
528 _patches_newgame.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR); |
368 LandscapeGenerationCallback); |
529 break; |
369 } else if (mode == GLWP_HEIGHTMAP && |
530 |
370 (WP(w, generate_d).x * 2 < (1U << _patches_newgame.map_x) || |
531 case GLAND_SNOW_LEVEL_TEXT: |
371 WP(w, generate_d).x / 2 > (1U << _patches_newgame.map_x) || |
532 w->InvalidateWidget(GLAND_SNOW_LEVEL_TEXT); |
372 WP(w, generate_d).y * 2 < (1U << _patches_newgame.map_y) || |
533 _patches_newgame.snow_line_height = Clamp(value, 2, MAX_SNOWLINE_HEIGHT); |
373 WP(w, generate_d).y / 2 > (1U << _patches_newgame.map_y))) { |
534 break; |
374 ShowQuery( |
535 } |
375 STR_HEIGHTMAP_SCALE_WARNING_CAPTION, |
536 |
376 STR_HEIGHTMAP_SCALE_WARNING_MESSAGE, |
|
377 w, |
|
378 LandscapeGenerationCallback); |
|
379 |
|
380 } else { |
|
381 StartGeneratingLandscape(mode); |
|
382 } |
|
383 break; |
|
384 case GLAND_START_DATE_DOWN: case GLAND_START_DATE_UP: // Year buttons |
|
385 /* Don't allow too fast scrolling */ |
|
386 if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { |
|
387 HandleButtonClick(w, e->we.click.widget); |
|
388 SetWindowDirty(w); |
537 SetWindowDirty(w); |
389 |
538 } |
390 _patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + e->we.click.widget - GLAND_START_DATE_TEXT, MIN_YEAR, MAX_YEAR); |
539 break; |
391 } |
|
392 _left_button_clicked = false; |
|
393 break; |
|
394 case GLAND_START_DATE_TEXT: // Year text |
|
395 WP(w, generate_d).widget_id = GLAND_START_DATE_TEXT; |
|
396 SetDParam(0, _patches_newgame.starting_year); |
|
397 ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, w, CS_NUMERAL); |
|
398 break; |
|
399 case GLAND_SNOW_LEVEL_DOWN: case GLAND_SNOW_LEVEL_UP: // Snow line buttons |
|
400 /* Don't allow too fast scrolling */ |
|
401 if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { |
|
402 HandleButtonClick(w, e->we.click.widget); |
|
403 SetWindowDirty(w); |
|
404 |
|
405 _patches_newgame.snow_line_height = Clamp(_patches_newgame.snow_line_height + e->we.click.widget - GLAND_SNOW_LEVEL_TEXT, 2, MAX_SNOWLINE_HEIGHT); |
|
406 } |
|
407 _left_button_clicked = false; |
|
408 break; |
|
409 case GLAND_SNOW_LEVEL_TEXT: // Snow line text |
|
410 WP(w, generate_d).widget_id = GLAND_SNOW_LEVEL_TEXT; |
|
411 SetDParam(0, _patches_newgame.snow_line_height); |
|
412 ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_SNOW_LINE_QUERY_CAPT, 3, 100, w, CS_NUMERAL); |
|
413 break; |
|
414 case GLAND_TREE_TEXT: case GLAND_TREE_PULLDOWN: // Tree placer |
|
415 ShowDropDownMenu(w, tree_placer, _patches_newgame.tree_placer, GLAND_TREE_PULLDOWN, 0, 0); |
|
416 break; |
|
417 case GLAND_LANDSCAPE_TEXT: case GLAND_LANDSCAPE_PULLDOWN: // Landscape generator OR Heightmap rotation |
|
418 /* case GLAND_HEIGHTMAP_ROTATION_TEXT: case GLAND_HEIGHTMAP_ROTATION_PULLDOWN:*/ |
|
419 if (mode == GLWP_HEIGHTMAP) { |
|
420 ShowDropDownMenu(w, rotation, _patches_newgame.heightmap_rotation, GLAND_HEIGHTMAP_ROTATION_PULLDOWN, 0, 0); |
|
421 } else { |
|
422 ShowDropDownMenu(w, landscape, _patches_newgame.land_generator, GLAND_LANDSCAPE_PULLDOWN, 0, 0); |
|
423 } |
|
424 break; |
|
425 case GLAND_TERRAIN_TEXT: case GLAND_TERRAIN_PULLDOWN: // Terrain type |
|
426 ShowDropDownMenu(w, elevations, _opt_newgame.diff.terrain_type, GLAND_TERRAIN_PULLDOWN, 0, 0); |
|
427 break; |
|
428 case GLAND_WATER_TEXT: case GLAND_WATER_PULLDOWN: // Water quantity |
|
429 ShowDropDownMenu(w, sea_lakes, _opt_newgame.diff.quantity_sea_lakes, GLAND_WATER_PULLDOWN, 0, 0); |
|
430 break; |
|
431 case GLAND_SMOOTHNESS_TEXT: case GLAND_SMOOTHNESS_PULLDOWN: // Map smoothness |
|
432 ShowDropDownMenu(w, smoothness, _patches_newgame.tgen_smoothness, GLAND_SMOOTHNESS_PULLDOWN, 0, 0); |
|
433 break; |
|
434 } |
|
435 break; |
|
436 |
|
437 case WE_MOUSELOOP: |
|
438 HandleEditBox(w, &_genseed_query, GLAND_RANDOM_EDITBOX); |
|
439 break; |
|
440 |
|
441 case WE_KEYPRESS: |
|
442 HandleEditBoxKey(w, &_genseed_query, GLAND_RANDOM_EDITBOX, e); |
|
443 /* the seed is unsigned, therefore atoi cannot be used. |
|
444 * As 2^32 - 1 (MAX_UVALUE(uint32)) is a 'magic' value |
|
445 * (use random seed) it should not be possible to be |
|
446 * entered into the input field; the generate seed |
|
447 * button can be used instead. */ |
|
448 _patches_newgame.generation_seed = minu(strtoul(_genseed_buffer, NULL, sizeof(_genseed_buffer) - 1), MAX_UVALUE(uint32) - 1); |
|
449 break; |
|
450 |
|
451 case WE_DROPDOWN_SELECT: |
|
452 switch (e->we.dropdown.button) { |
|
453 case GLAND_MAPSIZE_X_PULLDOWN: _patches_newgame.map_x = e->we.dropdown.index + 6; break; |
|
454 case GLAND_MAPSIZE_Y_PULLDOWN: _patches_newgame.map_y = e->we.dropdown.index + 6; break; |
|
455 case GLAND_TREE_PULLDOWN: _patches_newgame.tree_placer = e->we.dropdown.index; break; |
|
456 case GLAND_SMOOTHNESS_PULLDOWN: _patches_newgame.tgen_smoothness = e->we.dropdown.index; break; |
|
457 |
|
458 case GLAND_TOWN_PULLDOWN: |
|
459 _opt_newgame.diff.number_towns = e->we.dropdown.index; |
|
460 if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0); |
|
461 DoCommandP(0, 2, _opt_newgame.diff.number_towns, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); |
|
462 break; |
|
463 case GLAND_INDUSTRY_PULLDOWN: |
|
464 _opt_newgame.diff.number_industries = e->we.dropdown.index; |
|
465 if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0); |
|
466 DoCommandP(0, 3, _opt_newgame.diff.number_industries, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); |
|
467 break; |
|
468 case GLAND_LANDSCAPE_PULLDOWN: |
|
469 /* case GLAND_HEIGHTMAP_PULLDOWN: */ |
|
470 if (mode == GLWP_HEIGHTMAP) { |
|
471 _patches_newgame.heightmap_rotation = e->we.dropdown.index; |
|
472 } else { |
|
473 _patches_newgame.land_generator = e->we.dropdown.index; |
|
474 } |
|
475 break; |
|
476 case GLAND_TERRAIN_PULLDOWN: |
|
477 _opt_newgame.diff.terrain_type = e->we.dropdown.index; |
|
478 if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0); |
|
479 DoCommandP(0, 12, _opt_newgame.diff.terrain_type, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); |
|
480 break; |
|
481 case GLAND_WATER_PULLDOWN: |
|
482 _opt_newgame.diff.quantity_sea_lakes = e->we.dropdown.index; |
|
483 if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0); |
|
484 DoCommandP(0, 13, _opt_newgame.diff.quantity_sea_lakes, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); |
|
485 break; |
|
486 } |
|
487 SetWindowDirty(w); |
|
488 break; |
|
489 |
|
490 case WE_ON_EDIT_TEXT: { |
|
491 if (e->we.edittext.str != NULL) { |
|
492 int32 value = atoi(e->we.edittext.str); |
|
493 |
|
494 switch (WP(w, generate_d).widget_id) { |
|
495 case GLAND_START_DATE_TEXT: |
|
496 InvalidateWidget(w, GLAND_START_DATE_TEXT); |
|
497 _patches_newgame.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR); |
|
498 break; |
|
499 case GLAND_SNOW_LEVEL_TEXT: |
|
500 InvalidateWidget(w, GLAND_SNOW_LEVEL_TEXT); |
|
501 _patches_newgame.snow_line_height = Clamp(value, 2, MAX_SNOWLINE_HEIGHT); |
|
502 break; |
|
503 } |
|
504 |
|
505 SetWindowDirty(w); |
|
506 } |
|
507 break; |
|
508 } |
|
509 } |
540 } |
510 } |
541 } |
511 |
542 |
512 static const WindowDesc _generate_landscape_desc = { |
543 static const WindowDesc _generate_landscape_desc = { |
513 WDP_CENTER, WDP_CENTER, 338, 268, 338, 268, |
544 WDP_CENTER, WDP_CENTER, 338, 268, 338, 268, |
589 CSCEN_RANDOM_WORLD, |
620 CSCEN_RANDOM_WORLD, |
590 CSCEN_MAPSIZE_X_TEXT, |
621 CSCEN_MAPSIZE_X_TEXT, |
591 CSCEN_MAPSIZE_X_PULLDOWN, |
622 CSCEN_MAPSIZE_X_PULLDOWN, |
592 CSCEN_MAPSIZE_Y_TEXT, |
623 CSCEN_MAPSIZE_Y_TEXT, |
593 CSCEN_MAPSIZE_Y_PULLDOWN, |
624 CSCEN_MAPSIZE_Y_PULLDOWN, |
|
625 CSCEN_START_DATE_LABEL, |
594 CSCEN_START_DATE_DOWN, |
626 CSCEN_START_DATE_DOWN, |
595 CSCEN_START_DATE_TEXT, |
627 CSCEN_START_DATE_TEXT, |
596 CSCEN_START_DATE_UP, |
628 CSCEN_START_DATE_UP, |
|
629 CSCEN_FLAT_LAND_HEIGHT_LABEL, |
597 CSCEN_FLAT_LAND_HEIGHT_DOWN, |
630 CSCEN_FLAT_LAND_HEIGHT_DOWN, |
598 CSCEN_FLAT_LAND_HEIGHT_TEXT, |
631 CSCEN_FLAT_LAND_HEIGHT_TEXT, |
599 CSCEN_FLAT_LAND_HEIGHT_UP |
632 CSCEN_FLAT_LAND_HEIGHT_UP |
600 }; |
633 }; |
601 |
634 |
602 |
635 |
603 static void CreateScenarioWndProc(Window *w, WindowEvent *e) |
636 static void CreateScenarioWndProc(Window *w, WindowEvent *e) |
604 { |
637 { |
605 static const StringID mapsizes[] = {STR_64, STR_128, STR_256, STR_512, STR_1024, STR_2048, INVALID_STRING_ID}; |
|
606 |
|
607 switch (e->event) { |
638 switch (e->event) { |
608 case WE_CREATE: w->LowerWidget(_opt_newgame.landscape + CSCEN_TEMPERATE); break; |
639 case WE_CREATE: |
609 |
640 w->LowerWidget(_opt_newgame.landscape + CSCEN_TEMPERATE); |
610 case WE_PAINT: |
641 break; |
611 w->SetWidgetDisabledState(CSCEN_START_DATE_DOWN, _patches_newgame.starting_year <= MIN_YEAR); |
642 |
612 w->SetWidgetDisabledState(CSCEN_START_DATE_UP, _patches_newgame.starting_year >= MAX_YEAR); |
643 case WE_PAINT: |
613 w->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_DOWN, _patches_newgame.se_flat_world_height <= 0); |
644 w->SetWidgetDisabledState(CSCEN_START_DATE_DOWN, _patches_newgame.starting_year <= MIN_YEAR); |
614 w->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_UP, _patches_newgame.se_flat_world_height >= MAX_TILE_HEIGHT); |
645 w->SetWidgetDisabledState(CSCEN_START_DATE_UP, _patches_newgame.starting_year >= MAX_YEAR); |
615 |
646 w->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_DOWN, _patches_newgame.se_flat_world_height <= 0); |
616 w->SetWidgetLoweredState(CSCEN_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE); |
647 w->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_UP, _patches_newgame.se_flat_world_height >= MAX_TILE_HEIGHT); |
617 w->SetWidgetLoweredState(CSCEN_ARCTIC, _opt_newgame.landscape == LT_ARCTIC); |
648 |
618 w->SetWidgetLoweredState(CSCEN_TROPICAL, _opt_newgame.landscape == LT_TROPIC); |
649 w->SetWidgetLoweredState(CSCEN_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE); |
619 w->SetWidgetLoweredState(CSCEN_TOYLAND, _opt_newgame.landscape == LT_TOYLAND); |
650 w->SetWidgetLoweredState(CSCEN_ARCTIC, _opt_newgame.landscape == LT_ARCTIC); |
620 DrawWindowWidgets(w); |
651 w->SetWidgetLoweredState(CSCEN_TROPICAL, _opt_newgame.landscape == LT_TROPIC); |
621 |
652 w->SetWidgetLoweredState(CSCEN_TOYLAND, _opt_newgame.landscape == LT_TOYLAND); |
622 DrawStringRightAligned(211, 97, STR_MAPSIZE, TC_FROMSTRING); |
653 |
623 DrawString( 221, 97, mapsizes[_patches_newgame.map_x - 6], TC_BLACK); |
654 /* Set parameters for widget text that requires them */ |
624 DrawStringCentered( 272, 97, STR_BY, TC_FROMSTRING); |
655 SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); // CSCEN_START_DATE_TEXT |
625 DrawString( 284, 97, mapsizes[_patches_newgame.map_y - 6], TC_BLACK); |
656 SetDParam(1, 1 << _patches_newgame.map_x); // CSCEN_MAPSIZE_X_PULLDOWN |
626 |
657 SetDParam(2, 1 << _patches_newgame.map_y); // CSCEN_MAPSIZE_Y_PULLDOWN |
627 DrawStringRightAligned(211, 115, STR_DATE, TC_FROMSTRING); |
658 SetDParam(3, _patches_newgame.se_flat_world_height); // CSCEN_FLAT_LAND_HEIGHT_TEXT |
628 SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); |
659 |
629 DrawStringCentered(271, 115, STR_GENERATE_DATE, TC_FROMSTRING); |
660 DrawWindowWidgets(w); |
630 |
661 |
631 DrawStringRightAligned(278, 133, STR_FLAT_WORLD_HEIGHT, TC_FROMSTRING); |
662 break; |
632 SetDParam(0, _patches_newgame.se_flat_world_height); |
663 |
633 DrawStringCentered(303, 133, STR_FLAT_WORLD_HEIGHT_NUM, TC_BLACK); |
664 case WE_CLICK: |
634 |
665 switch (e->we.click.widget) { |
635 break; |
666 case CSCEN_TEMPERATE: |
636 case WE_CLICK: |
667 case CSCEN_ARCTIC: |
637 switch (e->we.click.widget) { |
668 case CSCEN_TROPICAL: |
638 case CSCEN_TEMPERATE: case CSCEN_ARCTIC: case CSCEN_TROPICAL: case CSCEN_TOYLAND: |
669 case CSCEN_TOYLAND: |
639 w->RaiseWidget(_opt_newgame.landscape + CSCEN_TEMPERATE); |
670 w->RaiseWidget(_opt_newgame.landscape + CSCEN_TEMPERATE); |
640 SetNewLandscapeType(e->we.click.widget - CSCEN_TEMPERATE); |
671 SetNewLandscapeType(e->we.click.widget - CSCEN_TEMPERATE); |
641 break; |
672 break; |
642 case CSCEN_MAPSIZE_X_TEXT: case CSCEN_MAPSIZE_X_PULLDOWN: // Mapsize X |
673 |
643 ShowDropDownMenu(w, mapsizes, _patches_newgame.map_x - 6, CSCEN_MAPSIZE_X_PULLDOWN, 0, 0); |
674 case CSCEN_MAPSIZE_X_PULLDOWN: // Mapsize X |
644 break; |
675 ShowDropDownList(w, BuildMapsizeDropDown(), _patches_newgame.map_x, CSCEN_MAPSIZE_X_PULLDOWN); |
645 case CSCEN_MAPSIZE_Y_TEXT: case CSCEN_MAPSIZE_Y_PULLDOWN: // Mapsize Y |
676 break; |
646 ShowDropDownMenu(w, mapsizes, _patches_newgame.map_y - 6, CSCEN_MAPSIZE_Y_PULLDOWN, 0, 0); |
677 |
647 break; |
678 case CSCEN_MAPSIZE_Y_PULLDOWN: // Mapsize Y |
648 case CSCEN_EMPTY_WORLD: // Empty world / flat world |
679 ShowDropDownList(w, BuildMapsizeDropDown(), _patches_newgame.map_y, CSCEN_MAPSIZE_Y_PULLDOWN); |
649 StartGeneratingLandscape(GLWP_SCENARIO); |
680 break; |
650 break; |
681 |
651 case CSCEN_RANDOM_WORLD: // Generate |
682 case CSCEN_EMPTY_WORLD: // Empty world / flat world |
652 ShowGenerateLandscape(); |
683 StartGeneratingLandscape(GLWP_SCENARIO); |
653 break; |
684 break; |
654 case CSCEN_START_DATE_DOWN: case CSCEN_START_DATE_UP: // Year buttons |
685 |
655 /* Don't allow too fast scrolling */ |
686 case CSCEN_RANDOM_WORLD: // Generate |
656 if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { |
687 ShowGenerateLandscape(); |
657 HandleButtonClick(w, e->we.click.widget); |
688 break; |
|
689 |
|
690 case CSCEN_START_DATE_DOWN: |
|
691 case CSCEN_START_DATE_UP: // Year buttons |
|
692 /* Don't allow too fast scrolling */ |
|
693 if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { |
|
694 w->HandleButtonClick(e->we.click.widget); |
|
695 SetWindowDirty(w); |
|
696 |
|
697 _patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + e->we.click.widget - CSCEN_START_DATE_TEXT, MIN_YEAR, MAX_YEAR); |
|
698 } |
|
699 _left_button_clicked = false; |
|
700 break; |
|
701 |
|
702 case CSCEN_START_DATE_TEXT: // Year text |
|
703 WP(w, generate_d).widget_id = CSCEN_START_DATE_TEXT; |
|
704 SetDParam(0, _patches_newgame.starting_year); |
|
705 ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, w, CS_NUMERAL); |
|
706 break; |
|
707 |
|
708 case CSCEN_FLAT_LAND_HEIGHT_DOWN: |
|
709 case CSCEN_FLAT_LAND_HEIGHT_UP: // Height level buttons |
|
710 /* Don't allow too fast scrolling */ |
|
711 if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { |
|
712 w->HandleButtonClick(e->we.click.widget); |
|
713 SetWindowDirty(w); |
|
714 |
|
715 _patches_newgame.se_flat_world_height = Clamp(_patches_newgame.se_flat_world_height + e->we.click.widget - CSCEN_FLAT_LAND_HEIGHT_TEXT, 0, MAX_TILE_HEIGHT); |
|
716 } |
|
717 _left_button_clicked = false; |
|
718 break; |
|
719 |
|
720 case CSCEN_FLAT_LAND_HEIGHT_TEXT: // Height level text |
|
721 WP(w, generate_d).widget_id = CSCEN_FLAT_LAND_HEIGHT_TEXT; |
|
722 SetDParam(0, _patches_newgame.se_flat_world_height); |
|
723 ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_FLAT_WORLD_HEIGHT_QUERY_CAPT, 3, 100, w, CS_NUMERAL); |
|
724 break; |
|
725 } |
|
726 break; |
|
727 |
|
728 case WE_DROPDOWN_SELECT: |
|
729 switch (e->we.dropdown.button) { |
|
730 case CSCEN_MAPSIZE_X_PULLDOWN: _patches_newgame.map_x = e->we.dropdown.index; break; |
|
731 case CSCEN_MAPSIZE_Y_PULLDOWN: _patches_newgame.map_y = e->we.dropdown.index; break; |
|
732 } |
|
733 SetWindowDirty(w); |
|
734 break; |
|
735 |
|
736 case WE_ON_EDIT_TEXT: |
|
737 if (e->we.edittext.str != NULL) { |
|
738 int32 value = atoi(e->we.edittext.str); |
|
739 |
|
740 switch (WP(w, generate_d).widget_id) { |
|
741 case CSCEN_START_DATE_TEXT: |
|
742 w->InvalidateWidget(CSCEN_START_DATE_TEXT); |
|
743 _patches_newgame.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR); |
|
744 break; |
|
745 |
|
746 case CSCEN_FLAT_LAND_HEIGHT_TEXT: |
|
747 w->InvalidateWidget(CSCEN_FLAT_LAND_HEIGHT_TEXT); |
|
748 _patches_newgame.se_flat_world_height = Clamp(value, 0, MAX_TILE_HEIGHT); |
|
749 break; |
|
750 } |
|
751 |
658 SetWindowDirty(w); |
752 SetWindowDirty(w); |
659 |
753 } |
660 _patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + e->we.click.widget - CSCEN_START_DATE_TEXT, MIN_YEAR, MAX_YEAR); |
754 break; |
661 } |
|
662 _left_button_clicked = false; |
|
663 break; |
|
664 case CSCEN_START_DATE_TEXT: // Year text |
|
665 WP(w, generate_d).widget_id = CSCEN_START_DATE_TEXT; |
|
666 SetDParam(0, _patches_newgame.starting_year); |
|
667 ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, w, CS_NUMERAL); |
|
668 break; |
|
669 case CSCEN_FLAT_LAND_HEIGHT_DOWN: case CSCEN_FLAT_LAND_HEIGHT_UP: // Height level buttons |
|
670 /* Don't allow too fast scrolling */ |
|
671 if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { |
|
672 HandleButtonClick(w, e->we.click.widget); |
|
673 SetWindowDirty(w); |
|
674 |
|
675 _patches_newgame.se_flat_world_height = Clamp(_patches_newgame.se_flat_world_height + e->we.click.widget - CSCEN_FLAT_LAND_HEIGHT_TEXT, 0, MAX_TILE_HEIGHT); |
|
676 } |
|
677 _left_button_clicked = false; |
|
678 break; |
|
679 case CSCEN_FLAT_LAND_HEIGHT_TEXT: // Height level text |
|
680 WP(w, generate_d).widget_id = CSCEN_FLAT_LAND_HEIGHT_TEXT; |
|
681 SetDParam(0, _patches_newgame.se_flat_world_height); |
|
682 ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_FLAT_WORLD_HEIGHT_QUERY_CAPT, 3, 100, w, CS_NUMERAL); |
|
683 break; |
|
684 } |
|
685 break; |
|
686 |
|
687 case WE_DROPDOWN_SELECT: |
|
688 switch (e->we.dropdown.button) { |
|
689 case CSCEN_MAPSIZE_X_PULLDOWN: _patches_newgame.map_x = e->we.dropdown.index + 6; break; |
|
690 case CSCEN_MAPSIZE_Y_PULLDOWN: _patches_newgame.map_y = e->we.dropdown.index + 6; break; |
|
691 } |
|
692 SetWindowDirty(w); |
|
693 break; |
|
694 |
|
695 case WE_ON_EDIT_TEXT: { |
|
696 if (e->we.edittext.str != NULL) { |
|
697 int32 value = atoi(e->we.edittext.str); |
|
698 |
|
699 switch (WP(w, generate_d).widget_id) { |
|
700 case CSCEN_START_DATE_TEXT: |
|
701 InvalidateWidget(w, CSCEN_START_DATE_TEXT); |
|
702 _patches_newgame.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR); |
|
703 break; |
|
704 case CSCEN_FLAT_LAND_HEIGHT_TEXT: |
|
705 InvalidateWidget(w, CSCEN_FLAT_LAND_HEIGHT_TEXT); |
|
706 _patches_newgame.se_flat_world_height = Clamp(value, 0, MAX_TILE_HEIGHT); |
|
707 break; |
|
708 } |
|
709 |
|
710 SetWindowDirty(w); |
|
711 } |
|
712 break; |
|
713 } |
|
714 } |
755 } |
715 } |
756 } |
716 |
757 |
717 static const Widget _create_scenario_widgets[] = { |
758 static const Widget _create_scenario_widgets[] = { |
718 { WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
759 { WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
725 { WWT_IMGBTN_2, RESIZE_NONE, 12, 250, 326, 24, 78, SPR_SELECT_TOYLAND, STR_0311_SELECT_TOYLAND_LANDSCAPE}, |
766 { WWT_IMGBTN_2, RESIZE_NONE, 12, 250, 326, 24, 78, SPR_SELECT_TOYLAND, STR_0311_SELECT_TOYLAND_LANDSCAPE}, |
726 |
767 |
727 { WWT_TEXTBTN, RESIZE_NONE, 6, 12, 115, 95, 124, STR_SE_FLAT_WORLD, STR_SE_FLAT_WORLD_TIP}, // Empty (sea-level) map |
768 { WWT_TEXTBTN, RESIZE_NONE, 6, 12, 115, 95, 124, STR_SE_FLAT_WORLD, STR_SE_FLAT_WORLD_TIP}, // Empty (sea-level) map |
728 { WWT_TEXTBTN, RESIZE_NONE, 6, 12, 115, 131, 160, STR_SE_RANDOM_LAND, STR_022A_GENERATE_RANDOM_LAND}, // Generate |
769 { WWT_TEXTBTN, RESIZE_NONE, 6, 12, 115, 131, 160, STR_SE_RANDOM_LAND, STR_022A_GENERATE_RANDOM_LAND}, // Generate |
729 |
770 |
730 { WWT_PANEL, RESIZE_NONE, 12, 216, 251, 95, 106, 0x0, STR_NULL}, |
771 { WWT_TEXT, RESIZE_NONE, 12, 182, 212, 96, 106, STR_MAPSIZE, STR_NULL}, |
731 { WWT_TEXTBTN, RESIZE_NONE, 12, 252, 263, 95, 106, STR_0225, STR_NULL}, // Mapsize X |
772 { WWT_DROPDOWN, RESIZE_NONE, 12, 216, 263, 95, 106, STR_NUM_1, STR_NULL}, // Mapsize X |
732 { WWT_PANEL, RESIZE_NONE, 12, 279, 314, 95, 106, 0x0, STR_NULL}, |
773 { WWT_TEXT, RESIZE_NONE, 12, 268, 276, 96, 106, STR_BY, STR_NULL}, |
733 { WWT_TEXTBTN, RESIZE_NONE, 12, 315, 326, 95, 106, STR_0225, STR_NULL}, // Mapsize Y |
774 { WWT_DROPDOWN, RESIZE_NONE, 12, 279, 326, 95, 106, STR_NUM_2, STR_NULL}, // Mapsize Y |
734 |
775 |
|
776 { WWT_TEXT, RESIZE_NONE, 0, 182, 212, 114, 124, STR_DATE, STR_NULL}, |
735 { WWT_IMGBTN, RESIZE_NONE, 12, 216, 227, 113, 124, SPR_ARROW_DOWN, STR_029E_MOVE_THE_STARTING_DATE}, |
777 { WWT_IMGBTN, RESIZE_NONE, 12, 216, 227, 113, 124, SPR_ARROW_DOWN, STR_029E_MOVE_THE_STARTING_DATE}, |
736 { WWT_PANEL, RESIZE_NONE, 12, 228, 314, 113, 124, 0x0, STR_NULL}, |
778 { WWT_TEXTBTN, RESIZE_NONE, 12, 228, 314, 113, 124, STR_GENERATE_DATE, STR_NULL}, |
737 { WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 113, 124, SPR_ARROW_UP, STR_029F_MOVE_THE_STARTING_DATE}, |
779 { WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 113, 124, SPR_ARROW_UP, STR_029F_MOVE_THE_STARTING_DATE}, |
738 |
780 |
|
781 { WWT_TEXT, RESIZE_NONE, 0, 182, 278, 132, 142, STR_FLAT_WORLD_HEIGHT, STR_NULL}, |
739 { WWT_IMGBTN, RESIZE_NONE, 12, 282, 293, 131, 142, SPR_ARROW_DOWN, STR_FLAT_WORLD_HEIGHT_DOWN}, |
782 { WWT_IMGBTN, RESIZE_NONE, 12, 282, 293, 131, 142, SPR_ARROW_DOWN, STR_FLAT_WORLD_HEIGHT_DOWN}, |
740 { WWT_PANEL, RESIZE_NONE, 12, 294, 314, 131, 142, 0x0, STR_NULL}, |
783 { WWT_TEXTBTN, RESIZE_NONE, 12, 294, 314, 131, 142, STR_NUM_3, STR_NULL}, |
741 { WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 131, 142, SPR_ARROW_UP, STR_FLAT_WORLD_HEIGHT_UP}, |
784 { WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 131, 142, SPR_ARROW_UP, STR_FLAT_WORLD_HEIGHT_UP}, |
742 { WIDGETS_END}, |
785 { WIDGETS_END}, |
743 }; |
786 }; |
744 |
787 |
745 static const WindowDesc _create_scenario_desc = { |
788 static const WindowDesc _create_scenario_desc = { |