191 static const StringID rotation[] = {STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE, STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION_CLOCKWISE, INVALID_STRING_ID}; |
190 static const StringID rotation[] = {STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE, STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION_CLOCKWISE, INVALID_STRING_ID}; |
192 static const StringID landscape[] = {STR_CONFIG_PATCHES_LAND_GENERATOR_ORIGINAL, STR_CONFIG_PATCHES_LAND_GENERATOR_TERRA_GENESIS, INVALID_STRING_ID}; |
191 static const StringID landscape[] = {STR_CONFIG_PATCHES_LAND_GENERATOR_ORIGINAL, STR_CONFIG_PATCHES_LAND_GENERATOR_TERRA_GENESIS, INVALID_STRING_ID}; |
193 static const StringID num_towns[] = {STR_6816_LOW, STR_6817_NORMAL, STR_6818_HIGH, INVALID_STRING_ID}; |
192 static const StringID num_towns[] = {STR_6816_LOW, STR_6817_NORMAL, STR_6818_HIGH, INVALID_STRING_ID}; |
194 static const StringID num_inds[] = {STR_26816_NONE, STR_6816_LOW, STR_6817_NORMAL, STR_6818_HIGH, INVALID_STRING_ID}; |
193 static const StringID num_inds[] = {STR_26816_NONE, STR_6816_LOW, STR_6817_NORMAL, STR_6818_HIGH, INVALID_STRING_ID}; |
195 |
194 |
|
195 /* Data used for the generate seed edit box */ |
|
196 static querystr_d _genseed_query; |
|
197 static char _genseed_buffer[LEN_RND_SEED]; |
|
198 |
196 uint mode = w->window_number; |
199 uint mode = w->window_number; |
197 uint y; |
200 uint y; |
198 |
201 |
199 switch (e->event) { |
202 switch (e->event) { |
200 case WE_CREATE: LowerWindowWidget(w, _opt_newgame.landscape + 3); break; |
203 case WE_CREATE: |
|
204 LowerWindowWidget(w, _opt_newgame.landscape + 3); |
|
205 |
|
206 snprintf(_genseed_buffer, sizeof(_genseed_buffer), "%u", _patches_newgame.generation_seed); |
|
207 InitializeTextBuffer(&_genseed_query.text, _genseed_buffer, lengthof(_genseed_buffer), 120); |
|
208 _genseed_query.caption = STR_NULL; |
|
209 _genseed_query.afilter = CS_NUMERAL; |
|
210 break; |
201 |
211 |
202 case WE_PAINT: |
212 case WE_PAINT: |
203 /* You can't select smoothness if not terragenesis */ |
213 /* You can't select smoothness if not terragenesis */ |
204 if (mode == GLWP_GENERATE) { |
214 if (mode == GLWP_GENERATE) { |
205 SetWindowWidgetDisabledState(w, 32, _patches_newgame.land_generator == 0); |
215 SetWindowWidgetDisabledState(w, 32, _patches_newgame.land_generator == 0); |
242 DrawString(118, 113 + y, num_towns[_opt_newgame.diff.number_towns], 0x10); |
252 DrawString(118, 113 + y, num_towns[_opt_newgame.diff.number_towns], 0x10); |
243 DrawString(118, 131 + y, num_inds[_opt_newgame.diff.number_industries], 0x10); |
253 DrawString(118, 131 + y, num_inds[_opt_newgame.diff.number_industries], 0x10); |
244 } |
254 } |
245 |
255 |
246 DrawString( 12, 153 + y, STR_RANDOM_SEED, 0); |
256 DrawString( 12, 153 + y, STR_RANDOM_SEED, 0); |
247 DrawEditBox(w, &WP(w, querystr_d), SEED_EDIT); |
257 DrawEditBox(w, &_genseed_query, SEED_EDIT); |
248 |
258 |
249 DrawString(182, 113 + y, STR_DATE, 0); |
259 DrawString(182, 113 + y, STR_DATE, 0); |
250 SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); |
260 SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); |
251 DrawStringCentered(271, 113 + y, STR_GENERATE_DATE, 0); |
261 DrawStringCentered(271, 113 + y, STR_GENERATE_DATE, 0); |
252 |
262 |
313 case 13: case 14: // Number of industries |
323 case 13: case 14: // Number of industries |
314 ShowDropDownMenu(w, num_inds, _opt_newgame.diff.number_industries, 14, 0, 0); |
324 ShowDropDownMenu(w, num_inds, _opt_newgame.diff.number_industries, 14, 0, 0); |
315 break; |
325 break; |
316 case 16: // Random seed |
326 case 16: // Random seed |
317 _patches_newgame.generation_seed = InteractiveRandom(); |
327 _patches_newgame.generation_seed = InteractiveRandom(); |
318 snprintf(_edit_str_buf, lengthof(_edit_str_buf), "%u", _patches_newgame.generation_seed); |
328 snprintf(_genseed_buffer, lengthof(_genseed_buffer), "%u", _patches_newgame.generation_seed); |
319 UpdateTextBufferSize(&WP(w, querystr_d).text); |
329 UpdateTextBufferSize(&_genseed_query.text); |
320 SetWindowDirty(w); |
330 SetWindowDirty(w); |
321 break; |
331 break; |
322 case 17: // Generate |
332 case 17: // Generate |
323 if (mode == GLWP_HEIGHTMAP && ( |
333 if (mode == GLWP_HEIGHTMAP && ( |
324 _heightmap_x * 2 < (1U << _patches_newgame.map_x) || _heightmap_x / 2 > (1U << _patches_newgame.map_x) || |
334 _heightmap_x * 2 < (1U << _patches_newgame.map_x) || _heightmap_x / 2 > (1U << _patches_newgame.map_x) || |
383 break; |
393 break; |
384 } |
394 } |
385 break; |
395 break; |
386 |
396 |
387 case WE_MOUSELOOP: |
397 case WE_MOUSELOOP: |
388 HandleEditBox(w, &WP(w, querystr_d), SEED_EDIT); |
398 HandleEditBox(w, &_genseed_query, SEED_EDIT); |
389 break; |
399 break; |
390 |
400 |
391 case WE_KEYPRESS: |
401 case WE_KEYPRESS: |
392 HandleEditBoxKey(w, &WP(w, querystr_d), SEED_EDIT, e); |
402 HandleEditBoxKey(w, &_genseed_query, SEED_EDIT, e); |
393 /* the seed is unsigned, therefore atoi cannot be used. |
403 /* the seed is unsigned, therefore atoi cannot be used. |
394 * As 2^32 - 1 (MAX_UVALUE(uint32)) is a 'magic' value |
404 * As 2^32 - 1 (MAX_UVALUE(uint32)) is a 'magic' value |
395 * (use random seed) it should not be possible to be |
405 * (use random seed) it should not be possible to be |
396 * entered into the input field; the generate seed |
406 * entered into the input field; the generate seed |
397 * button can be used instead. */ |
407 * button can be used instead. */ |
398 _patches_newgame.generation_seed = minu(strtoul(_edit_str_buf, NULL, 10), MAX_UVALUE(uint32) - 1); |
408 _patches_newgame.generation_seed = minu(strtoul(_genseed_buffer, NULL, sizeof(_genseed_buffer) - 1), MAX_UVALUE(uint32) - 1); |
399 break; |
409 break; |
400 |
410 |
401 case WE_DROPDOWN_SELECT: |
411 case WE_DROPDOWN_SELECT: |
402 switch (e->we.dropdown.button) { |
412 switch (e->we.dropdown.button) { |
403 case 8: _patches_newgame.map_x = e->we.dropdown.index + 6; break; |
413 case 8: _patches_newgame.map_x = e->we.dropdown.index + 6; break; |
501 } |
511 } |
502 |
512 |
503 w = AllocateWindowDescFront((mode == GLWP_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc, mode); |
513 w = AllocateWindowDescFront((mode == GLWP_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc, mode); |
504 |
514 |
505 if (w != NULL) { |
515 if (w != NULL) { |
506 querystr_d *querystr = &WP(w, querystr_d); |
|
507 |
|
508 snprintf(_edit_str_buf, lengthof(_edit_str_buf), "%u", _patches_newgame.generation_seed); |
|
509 |
|
510 InitializeTextBuffer(&querystr->text, _edit_str_buf, lengthof(_edit_str_buf), 120); |
|
511 querystr->caption = STR_NULL; |
|
512 querystr->afilter = CS_NUMERAL; |
|
513 |
516 |
514 InvalidateWindow(WC_GENERATE_LANDSCAPE, mode); |
517 InvalidateWindow(WC_GENERATE_LANDSCAPE, mode); |
515 } |
518 } |
516 } |
519 } |
517 |
520 |