diff options
author | rubidium <rubidium@openttd.org> | 2009-01-10 17:27:11 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-01-10 17:27:11 +0000 |
commit | ffa31d118dc03de410874a2b19f52b1e77b8ae5f (patch) | |
tree | b95ccad4f3dc202c4dfe209c025eefdc902ecfcd /src/settings_gui.cpp | |
parent | e3b7f14183060076b8cd7272d88d9dd97f9800b2 (diff) | |
download | openttd-ffa31d118dc03de410874a2b19f52b1e77b8ae5f.tar.xz |
(svn r14973) -Codechange: recursively fold subpages (Alberth)
Diffstat (limited to 'src/settings_gui.cpp')
-rw-r--r-- | src/settings_gui.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 7057b5525..efcd535e3 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -633,6 +633,7 @@ struct PatchEntry { PatchEntry(PatchPage *sub, StringID title); void Init(byte level, bool last_field); + void FoldAll(); void SetButtons(byte new_val); uint Length() const; @@ -650,6 +651,7 @@ struct PatchPage { byte num; ///< Number of entries on the page (statically filled). void Init(byte level = 0); + void FoldAll(); uint Length() const; PatchEntry *FindEntry(uint row, uint *cur_row) const; @@ -709,6 +711,23 @@ void PatchEntry::Init(byte level, bool last_field) } } +/** Recursively close all folds of sub-pages */ +void PatchEntry::FoldAll() +{ + switch(this->flags & PEF_KIND_MASK) { + case PEF_SETTING_KIND: + break; + + case PEF_SUBTREE_KIND: + this->d.sub.folded = true; + this->d.sub.page->FoldAll(); + break; + + default: NOT_REACHED(); + } +} + + /** * Set the button-depressed flags (#PEF_LEFT_DEPRESSED and #PEF_RIGHT_DEPRESSED) to a specified value * @param new_val New value for the button flags @@ -903,6 +922,14 @@ void PatchPage::Init(byte level) } } +/** Recursively close all folds of sub-pages */ +void PatchPage::FoldAll() +{ + for (uint field = 0; field < this->num; field++) { + this->entries[field].FoldAll(); + } +} + /** Return number of rows needed to display the whole page */ uint PatchPage::Length() const { @@ -1149,6 +1176,8 @@ struct PatchesSelectionWindow : Window { if (first_time) { _patches_main_page.Init(); first_time = false; + } else { + _patches_main_page.FoldAll(); // Close all sub-pages } this->valuewindow_entry = NULL; // No patch entry for which a entry window is opened @@ -1320,7 +1349,7 @@ static const Widget _patches_selection_widgets[] = { }; static const WindowDesc _patches_selection_desc = { - WDP_CENTER, WDP_CENTER, 412, 188, 412, 397, + WDP_CENTER, WDP_CENTER, 412, 188, 450, 397, WC_GAME_OPTIONS, WC_NONE, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE, _patches_selection_widgets, |