|
@@ -630,12 +630,13 @@ struct PatchEntry {
|
|
|
} d; ///< Data fields for each kind
|
|
|
|
|
|
PatchEntry(const char *nm);
|
|
|
PatchEntry(PatchPage *sub, StringID title);
|
|
|
|
|
|
void Init(byte level, bool last_field);
|
|
|
void FoldAll();
|
|
|
void SetButtons(byte new_val);
|
|
|
|
|
|
uint Length() const;
|
|
|
PatchEntry *FindEntry(uint row, uint *cur_row);
|
|
|
|
|
|
uint Draw(GameSettings *patches_ptr, int base_x, int base_y, uint first_row, uint max_row, uint cur_row, uint parent_last);
|
|
@@ -647,12 +648,13 @@ private:
|
|
|
/** Data structure describing one page of patches in the patch settings window. */
|
|
|
struct PatchPage {
|
|
|
PatchEntry *entries; ///< Array of patch entries of the page.
|
|
|
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;
|
|
|
|
|
|
uint Draw(GameSettings *patches_ptr, int base_x, int base_y, uint first_row, uint max_row, uint cur_row = 0, uint parent_last = 0) const;
|
|
|
};
|
|
@@ -706,12 +708,29 @@ void PatchEntry::Init(byte level, bool l
|
|
|
this->d.sub.page->Init(level + 1);
|
|
|
break;
|
|
|
default: NOT_REACHED();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/** 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
|
|
|
* @see PatchEntryFlags
|
|
|
*/
|
|
|
void PatchEntry::SetButtons(byte new_val)
|
|
@@ -900,12 +919,20 @@ void PatchPage::Init(byte level)
|
|
|
{
|
|
|
for (uint field = 0; field < this->num; field++) {
|
|
|
this->entries[field].Init(level, field + 1 == num);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/** 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
|
|
|
{
|
|
|
uint length = 0;
|
|
|
for (uint field = 0; field < this->num; field++) {
|
|
|
length += this->entries[field].Length();
|
|
@@ -1146,12 +1173,14 @@ struct PatchesSelectionWindow : Window {
|
|
|
patches_ptr = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game;
|
|
|
|
|
|
/* Build up the dynamic settings-array only once per OpenTTD session */
|
|
|
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
|
|
|
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;
|
|
@@ -1317,13 +1346,13 @@ static const Widget _patches_selection_w
|
|
|
{ WWT_SCROLLBAR, RESIZE_LRB, COLOUR_MAUVE, 400, 411, 14, 175, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // PATCHSEL_SCROLLBAR
|
|
|
{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_MAUVE, 400, 411, 176, 187, 0x0, STR_RESIZE_BUTTON}, // PATCHSEL_RESIZE
|
|
|
{ WIDGETS_END},
|
|
|
};
|
|
|
|
|
|
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,
|
|
|
};
|
|
|
|
|
|
void ShowPatchesSelection()
|