diff -r 2d679fecee66 src/settings_gui.cpp --- a/src/settings_gui.cpp Sun Nov 23 13:05:43 2008 +0100 +++ b/src/settings_gui.cpp Sun Nov 23 13:17:23 2008 +0100 @@ -1142,11 +1142,7 @@ PatchEntry(&_patches_economy_page, STR_CONFIG_PATCHES_TITLE_ECONOMY), PatchEntry(&_patches_ai_page, STR_CONFIG_PATCHES_TITLE_COMPETITORS), }; - -/** Array of pages (tabs), where each page holds a number of advanced settings. */ -static PatchPage _patches_page[] = { - {_patches_main, lengthof(_patches_main)}, -}; +static PatchPage _patches_main_page = {_patches_main, lengthof(_patches_main)}; /** Widget numbers of config patches window */ enum PatchesSelectionWidgets { @@ -1161,7 +1157,6 @@ static GameSettings *patches_ptr; ///< Pointer to the game settings being displayed and modified - int page; PatchEntry *valuewindow_entry; ///< If non-NULL, pointer to patch setting for which a value-entering window has been opened PatchEntry *depressed_entry; ///< If non-NULL, pointer to a clicked numeric patch setting (with a depressed left or right button) @@ -1180,18 +1175,16 @@ /* Build up the dynamic settings-array only once per OpenTTD session */ if (first_time) { - for (PatchPage *page = &_patches_page[0]; page != endof(_patches_page); page++) - page->Init(); + _patches_main_page.Init(); first_time = false; } valuewindow_entry = NULL; // No patch entry for which a entry window is opened depressed_entry = NULL; // No numeric patch setting buttons are depressed - page = 0; this->vscroll.pos = 0; this->vscroll.cap = (this->widget[PATCHSEL_OPTIONSPANEL].bottom - this->widget[PATCHSEL_OPTIONSPANEL].top - 8) / SETTING_HEIGHT; - SetVScrollCount(this, _patches_page[page].Length()); + SetVScrollCount(this, _patches_main_page.Length()); this->resize.step_height = SETTING_HEIGHT; this->resize.height = this->height; @@ -1203,11 +1196,8 @@ virtual void OnPaint() { - const PatchPage *page = &_patches_page[this->page]; - - /* Draw selected page */ this->DrawWidgets(); - page->Draw(patches_ptr, SETTINGTREE_LEFT_OFFSET, SETTINGTREE_TOP_OFFSET, vscroll.pos, vscroll.pos + vscroll.cap); + _patches_main_page.Draw(patches_ptr, SETTINGTREE_LEFT_OFFSET, SETTINGTREE_TOP_OFFSET, vscroll.pos, vscroll.pos + vscroll.cap); } virtual void OnClick(Point pt, int widget) @@ -1219,9 +1209,8 @@ byte btn = this->vscroll.pos + y / SETTING_HEIGHT; // Compute which setting is selected if (y % SETTING_HEIGHT > SETTING_HEIGHT - 2) return; // Clicked too low at the setting - const PatchPage *page = &_patches_page[this->page]; uint cur_row = 0; - PatchEntry *pe = page->FindEntry(btn, &cur_row); + PatchEntry *pe = _patches_main_page.FindEntry(btn, &cur_row); if (pe == NULL) return; // Clicked below the last setting of the page @@ -1232,7 +1221,7 @@ if ((pe->flags & PEF_KIND_MASK) == PEF_SUBTREE_KIND) { pe->d.sub.folded = !pe->d.sub.folded; // Flip 'folded'-ness of the sub-page - SetVScrollCount(this, page->Length()); // Update the scrollbar and redraw + SetVScrollCount(this, _patches_main_page.Length()); // Update the scrollbar and redraw this->SetDirty(); return; } @@ -1338,7 +1327,7 @@ virtual void OnResize(Point new_size, Point delta) { this->vscroll.cap += delta.y / SETTING_HEIGHT; - SetVScrollCount(this, _patches_page[page].Length()); + SetVScrollCount(this, _patches_main_page.Length()); } };