diff -r 6873d220198f src/lang/english.txt --- a/src/lang/english.txt Sun Nov 02 16:04:06 2008 +0100 +++ b/src/lang/english.txt Sun Nov 02 16:38:52 2008 +0100 @@ -1211,13 +1211,6 @@ STR_CONFIG_PATCHES_LARGER_TOWNS_DISABLED :{LTBLUE}Proportion of towns that will become cities: {ORANGE}None STR_CONFIG_PATCHES_CITY_SIZE_MULTIPLIER :{LTBLUE}Initial city size multiplier: {ORANGE}{STRING1} STR_CONFIG_MODIFIED_ROAD_REBUILD :{LTBLUE}Remove absurd road-elements during the road construction - -STR_CONFIG_PATCHES_GUI :{BLACK}Interface -STR_CONFIG_PATCHES_CONSTRUCTION :{BLACK}Construction -STR_CONFIG_PATCHES_VEHICLES :{BLACK}Vehicles -STR_CONFIG_PATCHES_STATIONS :{BLACK}Stations -STR_CONFIG_PATCHES_ECONOMY :{BLACK}Economy -STR_CONFIG_PATCHES_AI :{BLACK}Competitors STR_TREEVIEW_USER_INTERFACE :{ORANGE}User interface STR_TREEVIEW_CONSTRUCTION :{ORANGE}Construction diff -r 6873d220198f src/settings_gui.cpp --- a/src/settings_gui.cpp Sun Nov 02 16:04:06 2008 +0100 +++ b/src/settings_gui.cpp Sun Nov 02 16:38:52 2008 +0100 @@ -1224,13 +1224,9 @@ /** Widget numbers of config patches window */ enum PatchesSelectionWidgets { - PATCHSEL_OPTIONSPANEL = 3, ///< Panel widget containing the option lists - PATCHSEL_INTERFACE, ///< Button 'Interface' - PATCHSEL_CONSTRUCTION, ///< Button 'Construction' - PATCHSEL_VEHICLES, ///< Button 'Vehicles' - PATCHSEL_STATIONS, ///< Button 'Stations' - PATCHSEL_ECONOMY, ///< Button 'Economy' - PATCHSEL_COMPETITORS ///< Button 'Competitors' + PATCHSEL_OPTIONSPANEL = 2, ///< Panel widget containing the option lists + PATCHSEL_SCROLLBAR, ///< Vertical scrollbar + PATCHSEL_RESIZEBOX, ///< Resize box }; struct PatchesSelectionWindow : Window { @@ -1238,8 +1234,6 @@ static const int SETTINGTREE_TOP_OFFSET; ///< Position of top edge of patch values static GameSettings *patches_ptr; ///< Pointer to the game settings being displayed and modified - static int patches_max; ///< Maximal number of patches on a single page - TreeField *tf_entry; ///< Currently selected TreeField (used for storing new value from editbox back into patch settings) PatchesSelectionWindow(const WindowDesc *desc) : Window(desc) @@ -1259,17 +1253,16 @@ /* Build up the dynamic settings-array only once per OpenTTD session */ if (first_time) { _treeview.Init(); - patches_max = 15; // Some nice number so the window has non-zero size, will be removed later first_time = false; } - /* Resize the window to fit the largest patch tab */ - ResizeWindowForWidget(this, PATCHSEL_OPTIONSPANEL, 0, patches_max * SETTING_HEIGHT); - - /* Recentre the window for the new size */ - this->top = this->top - (patches_max * SETTING_HEIGHT) / 2; - - this->LowerWidget(PATCHSEL_INTERFACE); + this->vscroll.pos = 0; + this->vscroll.cap = (this->widget[PATCHSEL_OPTIONSPANEL].bottom - this->widget[PATCHSEL_OPTIONSPANEL].top - 8) / SETTING_HEIGHT; + SetVScrollCount(this, _treeview.Length()); + this->resize.step_height = SETTING_HEIGHT; + this->resize.height = this->height; + this->resize.step_width = 1; + this->resize.width = this->width; this->FindWindowPlacementAndResize(desc); } @@ -1278,9 +1271,8 @@ { this->DrawWidgets(); - int x = SETTINGTREE_LEFT_OFFSET; - int y = SETTINGTREE_TOP_OFFSET; - _treeview.DrawRows(patches_ptr, x, y, 0, 0 + patches_max); + _treeview.DrawRows(patches_ptr, SETTINGTREE_LEFT_OFFSET, SETTINGTREE_TOP_OFFSET, + this->vscroll.pos, this->vscroll.pos + this->vscroll.cap); } virtual void OnClick(Point pt, int widget) @@ -1306,6 +1298,7 @@ /* reverse folding of sub-tree */ tf->df.sub.unfolded = !tf->df.sub.unfolded; + SetVScrollCount(this, _treeview.Length()); this->SetDirty(); return; } @@ -1400,32 +1393,30 @@ this->SetDirty(); } } + + virtual void OnResize(Point new_size, Point delta) + { + this->vscroll.cap += delta.y / SETTING_HEIGHT; + } }; GameSettings *PatchesSelectionWindow::patches_ptr = NULL; const int PatchesSelectionWindow::SETTINGTREE_LEFT_OFFSET = 5; -const int PatchesSelectionWindow::SETTINGTREE_TOP_OFFSET = 47; -int PatchesSelectionWindow::patches_max = 0; +const int PatchesSelectionWindow::SETTINGTREE_TOP_OFFSET = 19; static const Widget _patches_selection_widgets[] = { -{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_MAUVE, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, -{ WWT_CAPTION, RESIZE_NONE, COLOUR_MAUVE, 11, 369, 0, 13, STR_CONFIG_PATCHES_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, -{ WWT_PANEL, RESIZE_NONE, COLOUR_MAUVE, 0, 369, 14, 41, 0x0, STR_NULL}, -{ WWT_PANEL, RESIZE_NONE, COLOUR_MAUVE, 0, 369, 42, 50, 0x0, STR_NULL}, // PATCHSEL_OPTIONSPANEL - -{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, 10, 96, 16, 27, STR_CONFIG_PATCHES_GUI, STR_NULL}, // PATCHSEL_INTERFACE -{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, 97, 183, 16, 27, STR_CONFIG_PATCHES_CONSTRUCTION, STR_NULL}, // PATCHSEL_CONSTRUCTION -{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, 184, 270, 16, 27, STR_CONFIG_PATCHES_VEHICLES, STR_NULL}, // PATCHSEL_VEHICLES -{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, 271, 357, 16, 27, STR_CONFIG_PATCHES_STATIONS, STR_NULL}, // PATCHSEL_STATIONS -{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, 10, 96, 28, 39, STR_CONFIG_PATCHES_ECONOMY, STR_NULL}, // PATCHSEL_ECONOMY -{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, 97, 183, 28, 39, STR_CONFIG_PATCHES_AI, STR_NULL}, // PATCHSEL_COMPETITORS +{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_MAUVE, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, +{ WWT_CAPTION, RESIZE_NONE, COLOUR_MAUVE, 11, 426, 0, 13, STR_CONFIG_PATCHES_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, +{ WWT_PANEL, RESIZE_BOTTOM, COLOUR_MAUVE, 0, 414, 14, 242, 0x0, STR_NULL}, // PATCHSEL_OPTIONSPANEL +{ WWT_SCROLLBAR, RESIZE_BOTTOM, COLOUR_MAUVE, 415, 426, 14, 230, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // PATCHSEL_SCROLLBAR +{ WWT_RESIZEBOX, RESIZE_TB, COLOUR_MAUVE, 415, 426, 231, 242, 0x0, STR_RESIZE_BUTTON}, // PATCHSEL_RESIZEBOX { WIDGETS_END}, }; static const WindowDesc _patches_selection_desc = { - WDP_CENTER, WDP_CENTER, 370, 51, 370, 51, + WDP_CENTER, WDP_CENTER, 427, 243, 427, 243, WC_GAME_OPTIONS, WC_NONE, - WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, + WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE, _patches_selection_widgets, };