diff -r b367c7e56eb9 src/settings_gui.cpp --- a/src/settings_gui.cpp Sun Nov 16 17:01:56 2008 +0100 +++ b/src/settings_gui.cpp Mon Nov 17 20:29:38 2008 +0100 @@ -591,6 +591,8 @@ PEF_LEFT_DEPRESSED = 0x01, ///< Of a numeric patch entry, the left button is depressed PEF_RIGHT_DEPRESSED = 0x02, ///< Of a numeric patch entry, the right button is depressed + PEF_LAST_FIELD = 0x04, ///< This entry is the last one in a (sub-)page + /* Entry kind */ PEF_SETTING_KIND = 0x10, ///< Entry kind: Entry is a setting PEF_SUBTREE_KIND = 0x20, ///< Entry kind: Entry is a sub-tree @@ -599,9 +601,10 @@ struct PatchPage; // Forward declaration -/** Data structure describing a single patch in a tab */ +/** Data structure describing either a single patch in a page, or a complete sub-page */ struct PatchEntry { - uint16 flags; ///< Flags of the pach entry. @see PatchEntryFlags + uint16 flags; ///< Flags of the pach entry. @see PatchEntryFlags + byte level; ///< Nesting level of this patch entry union { struct { const char *name; ///< Name of the setting @@ -618,7 +621,7 @@ PatchEntry(const char *nm); PatchEntry(PatchPage *page, StringID title); - void Init(); + void Init(byte level, bool last_field); PatchEntry *FindEntry(uint row, uint *cur_row); byte Length() const; @@ -634,7 +637,7 @@ PatchEntry *entries; ///< Array of patch entries of the page. byte num; ///< Number of entries on the page (statically filled). - void Init(); + void Init(byte level = 0); PatchEntry *FindEntry(uint row, uint *cur_row) const; byte Length() const; @@ -647,6 +650,7 @@ PatchEntry::PatchEntry(const char *nm) { flags = PEF_SETTING_KIND; + level = 0; d.entry.name = nm; d.entry.setting = NULL; d.entry.index = 0; @@ -656,21 +660,29 @@ PatchEntry::PatchEntry(PatchPage *sub, StringID str) { flags = PEF_SUBTREE_KIND; + level = 0; d.sub.page = sub; d.sub.folded = true; d.sub.title = str; } -/** Initialization of a patch entry */ -void PatchEntry::Init() +/** + * Initialization of a patch entry + * @param lvl Page nesting level of this entry + * @param last_field Boolean indicating this entry is the last at the (sub-)page + */ +void PatchEntry::Init(byte lvl, bool last_field) { + level = lvl; + if (last_field) flags |= PEF_LAST_FIELD; + switch(flags & PEF_KIND_MASK) { case PEF_SETTING_KIND: d.entry.setting = GetPatchFromName(d.entry.name, &d.entry.index); assert(d.entry.setting != NULL); break; case PEF_SUBTREE_KIND: - d.sub.page->Init(); + d.sub.page->Init(lvl + 1); break; default: NOT_REACHED(); } @@ -822,11 +834,13 @@ /* == PatchPage methods == */ -/** Initialization of an entire patch page */ -void PatchPage::Init() +/** + * Initialization of an entire patch page + * @param level Nesting level of this page (internal variable, do not provide a value for it when calling)*/ +void PatchPage::Init(byte level) { for (uint fld = 0; fld < num; fld++) - entries[fld].Init(); + entries[fld].Init(level, fld + 1 == num); } /**