diff options
author | rubidium <rubidium@openttd.org> | 2009-01-10 16:46:10 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-01-10 16:46:10 +0000 |
commit | 75a776770b69372e370f13dc6b13405cff5e74b2 (patch) | |
tree | 97fa308d0bcc228d045439f35516e0674f915ac9 | |
parent | b467902e657c81474cb9ec424ee88ac423ce3c1b (diff) | |
download | openttd-75a776770b69372e370f13dc6b13405cff5e74b2.tar.xz |
(svn r14965) -Codechange: remember the patch entry instead of the page and index of the entry for handling the "input box" (Alberth)
-rw-r--r-- | src/settings_gui.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index a1c03e7eb..a40f05016 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -909,7 +909,7 @@ struct PatchesSelectionWindow : Window { static GameSettings *patches_ptr; ///< Pointer to the game settings being displayed and modified int page; - int entry; + PatchEntry *valuewindow_entry; ///< If non-NULL, pointer to patch setting for which a value-entering window has been opened PatchEntry *clicked_entry; ///< If non-NULL, pointer to a clicked numeric patch setting (with a depressed left or right button) PatchesSelectionWindow(const WindowDesc *desc) : Window(desc) @@ -934,6 +934,7 @@ struct PatchesSelectionWindow : Window { } this->page = 0; + this->valuewindow_entry = NULL; // No patch entry for which a entry window is opened this->clicked_entry = NULL; // No numeric patch setting buttons are depressed this->vscroll.pos = 0; this->vscroll.cap = (this->widget[PATCHSEL_OPTIONSPANEL].bottom - this->widget[PATCHSEL_OPTIONSPANEL].top - 8) / SETTING_HEIGHT; @@ -1095,7 +1096,7 @@ struct PatchesSelectionWindow : Window { /* Show the correct currency-translated value */ if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate; - this->entry = btn; + this->valuewindow_entry = &page->entries[btn]; SetDParam(0, value); ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, this, CS_NUMERAL, QSF_NONE); } @@ -1126,15 +1127,15 @@ struct PatchesSelectionWindow : Window { virtual void OnQueryTextFinished(char *str) { if (!StrEmpty(str)) { - const PatchEntry *pe = &_patches_page[this->page].entries[this->entry]; - assert((pe->flags & PEF_KIND_MASK) == PEF_SETTING_KIND); - const SettingDesc *sd = pe->d.entry.setting; + assert(this->valuewindow_entry != NULL); + assert((this->valuewindow_entry->flags & PEF_KIND_MASK) == PEF_SETTING_KIND); + const SettingDesc *sd = this->valuewindow_entry->d.entry.setting; int32 value = atoi(str); /* Save the correct currency-translated value */ if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate; - SetPatchValue(pe->d.entry.index, value); + SetPatchValue(this->valuewindow_entry->d.entry.index, value); this->SetDirty(); } } |