mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-08 23:19:40 +00:00
(svn r14973) -Codechange: recursively fold subpages (Alberth)
This commit is contained in:
parent
698fbe891c
commit
8e42e20ebe
@ -633,6 +633,7 @@ struct PatchEntry {
|
|||||||
PatchEntry(PatchPage *sub, StringID title);
|
PatchEntry(PatchPage *sub, StringID title);
|
||||||
|
|
||||||
void Init(byte level, bool last_field);
|
void Init(byte level, bool last_field);
|
||||||
|
void FoldAll();
|
||||||
void SetButtons(byte new_val);
|
void SetButtons(byte new_val);
|
||||||
|
|
||||||
uint Length() const;
|
uint Length() const;
|
||||||
@ -650,6 +651,7 @@ struct PatchPage {
|
|||||||
byte num; ///< Number of entries on the page (statically filled).
|
byte num; ///< Number of entries on the page (statically filled).
|
||||||
|
|
||||||
void Init(byte level = 0);
|
void Init(byte level = 0);
|
||||||
|
void FoldAll();
|
||||||
|
|
||||||
uint Length() const;
|
uint Length() const;
|
||||||
PatchEntry *FindEntry(uint row, uint *cur_row) 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
|
* 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
|
* @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 */
|
/** Return number of rows needed to display the whole page */
|
||||||
uint PatchPage::Length() const
|
uint PatchPage::Length() const
|
||||||
{
|
{
|
||||||
@ -1149,6 +1176,8 @@ struct PatchesSelectionWindow : Window {
|
|||||||
if (first_time) {
|
if (first_time) {
|
||||||
_patches_main_page.Init();
|
_patches_main_page.Init();
|
||||||
first_time = false;
|
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
|
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 = {
|
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,
|
WC_GAME_OPTIONS, WC_NONE,
|
||||||
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
|
||||||
_patches_selection_widgets,
|
_patches_selection_widgets,
|
||||||
|
Loading…
Reference in New Issue
Block a user