1
0
Fork 0

(svn r24859) -Codechange: Make the dropdown handling of the adv. settings GUI more generic.

release/1.3
frosch 2012-12-26 17:42:29 +00:00
parent 24e62f39e0
commit 9bce12a0ce
1 changed files with 44 additions and 40 deletions

View File

@ -2099,7 +2099,8 @@ struct GameSettingsWindow : Window {
virtual void OnDropdownSelect(int widget, int index) virtual void OnDropdownSelect(int widget, int index)
{ {
if (widget == WID_GS_RESTRICT_DROPDOWN) { switch (widget) {
case WID_GS_RESTRICT_DROPDOWN:
this->cur_restriction_mode = (RestrictionMode)index; this->cur_restriction_mode = (RestrictionMode)index;
if (this->cur_restriction_mode == RM_CHANGED_AGAINST_DEFAULT || if (this->cur_restriction_mode == RM_CHANGED_AGAINST_DEFAULT ||
this->cur_restriction_mode == RM_CHANGED_AGAINST_DEFAULT_WO_LOCAL || this->cur_restriction_mode == RM_CHANGED_AGAINST_DEFAULT_WO_LOCAL ||
@ -2115,9 +2116,10 @@ struct GameSettingsWindow : Window {
_settings_client.gui.settings_restriction_mode = this->cur_restriction_mode; _settings_client.gui.settings_restriction_mode = this->cur_restriction_mode;
} }
this->InvalidateData(); this->InvalidateData();
return; break;
}
default:
if (widget < 0) {
/* Deal with drop down boxes on the panel. */ /* Deal with drop down boxes on the panel. */
assert(this->valuedropdown_entry != NULL); assert(this->valuedropdown_entry != NULL);
const SettingDesc *sd = this->valuedropdown_entry->d.entry.setting; const SettingDesc *sd = this->valuedropdown_entry->d.entry.setting;
@ -2131,18 +2133,19 @@ struct GameSettingsWindow : Window {
this->SetDirty(); this->SetDirty();
} }
break;
}
}
virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close) virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close)
{ {
if (widget == WID_GS_RESTRICT_DROPDOWN) { if (widget >= 0) {
/* Normally the default implementation of OnDropdownClose() takes care of /* Normally the default implementation of OnDropdownClose() takes care of
* a few things. We want that behaviour here too, but only for this one * a few things. We want that behaviour here too, but only for
* "normal" dropdown box. The special dropdown boxes added for every * "normal" dropdown boxes. The special dropdown boxes added for every
* setting that needs one can't have this call. */ * setting that needs one can't have this call. */
Window::OnDropdownClose(pt, widget, index, instant_close); Window::OnDropdownClose(pt, widget, index, instant_close);
return; } else {
}
/* We cannot raise the dropdown button just yet. OnClick needs some hint, whether /* We cannot raise the dropdown button just yet. OnClick needs some hint, whether
* the same dropdown button was clicked again, and then not open the dropdown again. * the same dropdown button was clicked again, and then not open the dropdown again.
* So, we only remember that it was closed, and process it on the next OnPaint, which is * So, we only remember that it was closed, and process it on the next OnPaint, which is
@ -2151,6 +2154,7 @@ struct GameSettingsWindow : Window {
this->closing_dropdown = true; this->closing_dropdown = true;
this->SetDirty(); this->SetDirty();
} }
}
virtual void OnInvalidateData(int data = 0, bool gui_scope = true) virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{ {