mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-31 03:12:41 +00:00
(svn r7949) -Backport from trunk (r7733):
- do not use WP(w, querystr_d) and WP(w, def_d) for the same window
This commit is contained in:
parent
630f81c382
commit
bae0695ac9
@ -43,7 +43,6 @@ typedef enum glwp_modes {
|
|||||||
GLWP_END
|
GLWP_END
|
||||||
} glwp_modes;
|
} glwp_modes;
|
||||||
|
|
||||||
static char _edit_str_buf[LEN_RND_SEED];
|
|
||||||
static uint _heightmap_x = 0;
|
static uint _heightmap_x = 0;
|
||||||
static uint _heightmap_y = 0;
|
static uint _heightmap_y = 0;
|
||||||
static StringID _heightmap_str = STR_NULL;
|
static StringID _heightmap_str = STR_NULL;
|
||||||
@ -200,11 +199,22 @@ void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
|
|||||||
static const StringID num_towns[] = {STR_6816_LOW, STR_6817_NORMAL, STR_6818_HIGH, INVALID_STRING_ID};
|
static const StringID num_towns[] = {STR_6816_LOW, STR_6817_NORMAL, STR_6818_HIGH, INVALID_STRING_ID};
|
||||||
static const StringID num_inds[] = {STR_26816_NONE, STR_6816_LOW, STR_6817_NORMAL, STR_6818_HIGH, INVALID_STRING_ID};
|
static const StringID num_inds[] = {STR_26816_NONE, STR_6816_LOW, STR_6817_NORMAL, STR_6818_HIGH, INVALID_STRING_ID};
|
||||||
|
|
||||||
|
/* Data used for the generate seed edit box */
|
||||||
|
static querystr_d _genseed_query;
|
||||||
|
static char _genseed_buffer[LEN_RND_SEED];
|
||||||
|
|
||||||
uint mode = w->window_number;
|
uint mode = w->window_number;
|
||||||
uint y;
|
uint y;
|
||||||
|
|
||||||
switch (e->event) {
|
switch (e->event) {
|
||||||
case WE_CREATE: LowerWindowWidget(w, _opt_newgame.landscape + 3); break;
|
case WE_CREATE:
|
||||||
|
LowerWindowWidget(w, _opt_newgame.landscape + 3);
|
||||||
|
|
||||||
|
snprintf(_genseed_buffer, sizeof(_genseed_buffer), "%u", _patches_newgame.generation_seed);
|
||||||
|
InitializeTextBuffer(&_genseed_query.text, _genseed_buffer, lengthof(_genseed_buffer), 120);
|
||||||
|
_genseed_query.caption = STR_NULL;
|
||||||
|
_genseed_query.afilter = CS_NUMERAL;
|
||||||
|
break;
|
||||||
|
|
||||||
case WE_PAINT:
|
case WE_PAINT:
|
||||||
/* You can't select smoothness if not terragenesis */
|
/* You can't select smoothness if not terragenesis */
|
||||||
@ -251,7 +261,7 @@ void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DrawString( 12, 153 + y, STR_RANDOM_SEED, 0);
|
DrawString( 12, 153 + y, STR_RANDOM_SEED, 0);
|
||||||
DrawEditBox(w, &WP(w, querystr_d), SEED_EDIT);
|
DrawEditBox(w, &_genseed_query, SEED_EDIT);
|
||||||
|
|
||||||
DrawString(182, 113 + y, STR_DATE, 0);
|
DrawString(182, 113 + y, STR_DATE, 0);
|
||||||
SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
|
SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
|
||||||
@ -322,8 +332,8 @@ void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
|
|||||||
break;
|
break;
|
||||||
case 16: // Random seed
|
case 16: // Random seed
|
||||||
_patches_newgame.generation_seed = InteractiveRandom();
|
_patches_newgame.generation_seed = InteractiveRandom();
|
||||||
snprintf(_edit_str_buf, lengthof(_edit_str_buf), "%u", _patches_newgame.generation_seed);
|
snprintf(_genseed_buffer, lengthof(_genseed_buffer), "%u", _patches_newgame.generation_seed);
|
||||||
UpdateTextBufferSize(&WP(w, querystr_d).text);
|
UpdateTextBufferSize(&_genseed_query.text);
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
case 17: // Generate
|
case 17: // Generate
|
||||||
@ -388,17 +398,17 @@ void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_MOUSELOOP:
|
case WE_MOUSELOOP:
|
||||||
HandleEditBox(w, &WP(w, querystr_d), SEED_EDIT);
|
HandleEditBox(w, &_genseed_query, SEED_EDIT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_KEYPRESS:
|
case WE_KEYPRESS:
|
||||||
HandleEditBoxKey(w, &WP(w, querystr_d), SEED_EDIT, e);
|
HandleEditBoxKey(w, &_genseed_query, SEED_EDIT, e);
|
||||||
/* the seed is unsigned, therefore atoi cannot be used.
|
/* the seed is unsigned, therefore atoi cannot be used.
|
||||||
* As 2^32 - 1 (MAX_UVALUE(uint32)) is a 'magic' value
|
* As 2^32 - 1 (MAX_UVALUE(uint32)) is a 'magic' value
|
||||||
* (use random seed) it should not be possible to be
|
* (use random seed) it should not be possible to be
|
||||||
* entered into the input field; the generate seed
|
* entered into the input field; the generate seed
|
||||||
* button can be used instead. */
|
* button can be used instead. */
|
||||||
_patches_newgame.generation_seed = minu(strtoul(_edit_str_buf, NULL, 10), MAX_UVALUE(uint32) - 1);
|
_patches_newgame.generation_seed = minu(strtoul(_genseed_buffer, NULL, sizeof(_genseed_buffer) - 1), MAX_UVALUE(uint32) - 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_DROPDOWN_SELECT:
|
case WE_DROPDOWN_SELECT:
|
||||||
@ -506,13 +516,6 @@ static void _ShowGenerateLandscape(glwp_modes mode)
|
|||||||
w = AllocateWindowDescFront((mode == GLWP_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc, mode);
|
w = AllocateWindowDescFront((mode == GLWP_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc, mode);
|
||||||
|
|
||||||
if (w != NULL) {
|
if (w != NULL) {
|
||||||
querystr_d *querystr = &WP(w, querystr_d);
|
|
||||||
|
|
||||||
snprintf(_edit_str_buf, lengthof(_edit_str_buf), "%u", _patches_newgame.generation_seed);
|
|
||||||
|
|
||||||
InitializeTextBuffer(&querystr->text, _edit_str_buf, lengthof(_edit_str_buf), 120);
|
|
||||||
querystr->caption = STR_NULL;
|
|
||||||
querystr->afilter = CS_NUMERAL;
|
|
||||||
|
|
||||||
InvalidateWindow(WC_GENERATE_LANDSCAPE, mode);
|
InvalidateWindow(WC_GENERATE_LANDSCAPE, mode);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user