diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index aa51f568c0..d316a011ae 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -60,9 +60,7 @@ struct AIListWindow : public Window { this->InitNested(desc); // Initializes 'this->line_height' as side effect. - this->vscroll.SetCapacity(this->GetWidget(AIL_WIDGET_LIST)->current_y / this->line_height); this->vscroll.SetCount((int)this->ai_info_list->size() + 1); - this->GetWidget(AIL_WIDGET_LIST)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); /* Try if we can find the currently selected AI */ this->selected = -1; @@ -277,9 +275,7 @@ struct AISettingsWindow : public Window { this->InitNested(desc); // Initializes 'this->line_height' as side effect. - this->vscroll.SetCapacity(this->GetWidget(AIS_WIDGET_BACKGROUND)->current_y / this->line_height); this->vscroll.SetCount((int)this->ai_config->GetConfigList()->size()); - this->GetWidget(AIS_WIDGET_BACKGROUND)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *resize) @@ -677,8 +673,6 @@ struct AIDebugWindow : public Window { } this->DisableWidget(AID_WIDGET_RELOAD_TOGGLE); - this->vscroll.SetCapacity(this->GetWidget(AID_WIDGET_LOG_PANEL)->current_y / this->resize.step_height); - this->last_vscroll_pos = 0; this->autoscroll = true; diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 0f30cb4232..73359d8e97 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -143,13 +143,11 @@ public: this->SortBridgeList(); this->vscroll.SetCount(bl->Length()); - this->vscroll.SetCapacity(this->GetWidget(BBSW_BRIDGE_LIST)->current_y / this->resize.step_height); if (this->last_size < this->vscroll.GetCapacity()) this->last_size = this->vscroll.GetCapacity(); if (this->last_size > this->vscroll.GetCount()) this->last_size = this->vscroll.GetCount(); /* Resize the bridge selection window if we used a bigger one the last time. */ if (this->last_size > this->vscroll.GetCapacity()) { ResizeWindow(this, 0, (this->last_size - this->vscroll.GetCapacity()) * this->resize.step_height); - this->vscroll.SetCapacity(this->last_size); } this->GetWidget(BBSW_BRIDGE_LIST)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 4b06bc576d..a55f4c8a32 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -225,6 +225,8 @@ struct DepotWindow : Window { DepotWindow(const WindowDesc *desc, TileIndex tile, VehicleType type) : Window() { + assert(IsCompanyBuildableVehicleType(type)); // ensure that we make the call with a valid type + this->sel = INVALID_VEHICLE; this->generate_list = true; this->type = type; @@ -234,7 +236,8 @@ struct DepotWindow : Window { this->FinishInitNested(desc, tile); this->owner = GetTileOwner(tile); - this->CreateDepotListWindow(type); + _backup_orders_tile = 0; + } ~DepotWindow() @@ -593,21 +596,6 @@ struct DepotWindow : Window { } } - void CreateDepotListWindow(VehicleType type) - { - _backup_orders_tile = 0; - - assert(IsCompanyBuildableVehicleType(type)); // ensure that we make the call with a valid type - - /* Set the number of blocks in each direction */ - this->hscroll.SetCapacity(_resize_cap[type].width); - this->vscroll.SetCapacity(_resize_cap[type].height); - - this->GetWidget(DEPOT_WIDGET_MATRIX)->widget_data = - (this->vscroll.GetCapacity() << MAT_ROW_START) // number of rows to draw on the background - + ((type == VEH_TRAIN ? 1 : this->hscroll.GetCapacity()) << MAT_COL_START); // number of boxes in each row. Trains always have just one - } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *resize) { switch (widget) { diff --git a/src/group_gui.cpp b/src/group_gui.cpp index bf5e553202..58b516bb2d 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -206,23 +206,6 @@ public: this->CreateNestedTree(desc); this->vehicle_type = (VehicleType)GB(window_number, 11, 5); - switch (this->vehicle_type) { - default: NOT_REACHED(); - case VEH_TRAIN: - case VEH_ROAD: - this->vscroll2.SetCapacity(9); - this->vscroll.SetCapacity(6); - break; - case VEH_SHIP: - case VEH_AIRCRAFT: - this->vscroll2.SetCapacity(9); - this->vscroll.SetCapacity(4); - break; - } - - this->GetWidget(GRP_WIDGET_LIST_GROUP)->widget_data = (this->vscroll2.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); - this->GetWidget(GRP_WIDGET_LIST_VEHICLE)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); - switch (this->vehicle_type) { default: NOT_REACHED(); case VEH_TRAIN: this->sorting = &_sorting.train; break; diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 37563de68f..9173cc11cf 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -1036,7 +1036,6 @@ public: this->BuildSortIndustriesList(); this->InitNested(desc, 0); - this->vscroll.SetCapacity(this->GetWidget(IDW_INDUSTRY_LIST)->current_y / this->resize.step_height); } ~IndustryDirectoryWindow() diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 28c2090136..11ef35b5cd 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -1777,7 +1777,6 @@ public: this->FinishInitNested(desc, 0); this->LowerWidget(SLWW_DRIVES_DIRECTORIES_LIST); - this->vscroll.SetCapacity(this->GetWidget(SLWW_DRIVES_DIRECTORIES_LIST)->current_y / this->resize.step_height); /* pause is only used in single-player, non-editor mode, non-menu mode. It * will be unpaused in the WE_DESTROY event handler. */ diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index 06ed8a047e..ca706330c2 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -363,9 +363,6 @@ public: this->FilterContentList(); this->SortContentList(); this->InvalidateData(); - - this->vscroll.SetCapacity(this->GetWidget(NCLWW_MATRIX)->current_y / this->resize.step_height); - this->GetWidget(NCLWW_MATRIX)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } /** Free everything we allocated */ diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 4e6bcead16..434fdb6d74 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -462,10 +462,6 @@ public: this->servers.SetSortFuncs(this->sorter_funcs); this->servers.ForceRebuild(); this->SortNetworkGameList(); - - NWidgetCore *nwi = this->GetWidget(NGWW_MATRIX); - this->vscroll.SetCapacity(nwi->current_y / this->resize.step_height); - nwi->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); } ~NetworkGameWindow() diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 7980733b23..53348f0e75 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -262,7 +262,6 @@ public: this->BuildGrfList(); this->SetWidgetDisabledState(ANGRFW_ADD, this->sel == NULL || this->sel->IsOpenTTDBaseGRF()); - this->vscroll.SetCapacity((this->GetWidget(ANGRFW_GRF_LIST)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / this->resize.step_height); } virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *resize) diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 55aec1c22e..ba6cf20592 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -922,7 +922,6 @@ struct MessageHistoryWindow : Window { MessageHistoryWindow(const WindowDesc *desc) : Window() { this->InitNested(desc); // Initializes 'this->line_height' and 'this->date_width'. - this->vscroll.SetCapacity((this->GetWidget(MHW_BACKGROUND)->current_y - this->top_spacing - this->bottom_spacing) / this->line_height); this->OnInvalidateData(0); } diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 36f5dba410..1cb88c3461 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -677,9 +677,6 @@ public: this->selected_order = -1; this->owner = v->owner; - int num_lines = (this->GetWidget(ORDER_WIDGET_ORDER_LIST)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / this->resize.step_height; - this->vscroll.SetCapacity(num_lines); - if (_settings_client.gui.quick_goto && v->owner == _local_company) { /* If there are less than 2 station, make Go To active. */ int station_orders = 0; diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 3849d53dcf..b65770cbd2 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1464,7 +1464,6 @@ struct GameSettingsWindow : Window { this->InitNested(desc, 0); - this->vscroll.SetCapacity((this->GetWidget(SETTINGSEL_OPTIONSPANEL)->current_y - SETTINGTREE_TOP_OFFSET - SETTINGTREE_BOTTOM_OFFSET) / this->resize.step_height); this->vscroll.SetCount(_settings_main_page.Length()); } diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index 212e7f5b02..412f432607 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -95,8 +95,6 @@ struct SignListWindow : Window, SignList { { this->InitNested(desc, window_number); - this->vscroll.SetCapacity((this->GetWidget(SLW_LIST)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / this->resize.step_height); - /* Create initial list. */ this->signs.ForceRebuild(); this->signs.ForceResort(); diff --git a/src/station_gui.cpp b/src/station_gui.cpp index f9b304593a..d3974523e5 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -266,7 +266,6 @@ public: this->InitNested(desc, window_number); this->owner = (Owner)this->window_number; - this->vscroll.SetCapacity((this->GetWidget(SLW_LIST)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / FONT_HEIGHT_NORMAL); for (uint i = 0; i < NUM_CARGO; i++) { const CargoSpec *cs = CargoSpec::Get(i); @@ -792,8 +791,6 @@ struct StationViewWindow : public Window { Owner owner = Station::Get(window_number)->owner; if (owner != OWNER_NONE) this->owner = owner; - - this->vscroll.SetCapacity((this->GetWidget(SVW_WAITING)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / this->resize.step_height); } ~StationViewWindow() @@ -1280,8 +1277,6 @@ struct SelectStationWindow : Window { this->CreateNestedTree(desc); this->GetWidget(JSW_WIDGET_CAPTION)->widget_data = T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CAPTION : STR_JOIN_STATION_CAPTION; this->FinishInitNested(desc, 0); - - this->vscroll.SetCapacity((this->GetWidget(JSW_PANEL)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / this->resize.step_height); this->OnInvalidateData(0); } diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index 6cbae2da0e..da41901e23 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -39,7 +39,6 @@ struct SubsidyListWindow : Window { { this->InitNested(desc, window_number); this->OnInvalidateData(0); - this->vscroll.SetCapacity(this->GetWidget(SLW_PANEL)->current_y / this->resize.step_height); } virtual void OnClick(Point pt, int widget) diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index fe19a27e4f..fff8325b06 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -60,7 +60,6 @@ struct TimetableWindow : Window { this->InitNested(desc, window_number); this->owner = this->vehicle->owner; this->sel_index = -1; - this->vscroll.SetCapacity((this->GetWidget(TTV_TIMETABLE_PANEL)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / this->resize.step_height); } virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *resize) diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 2e60e57044..fa36382af4 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -659,7 +659,6 @@ public: this->BuildSortTownList(); this->InitNested(desc, 0); - this->vscroll.SetCapacity(this->GetWidget(TDW_CENTERTOWN)->current_y / this->resize.step_height); } ~TownDirectoryWindow() diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 63a944c142..627d85871c 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -298,7 +298,6 @@ struct RefitWindow : public Window { this->FinishInitNested(desc, v->index); this->owner = v->owner; - this->vscroll.SetCapacity(this->GetWidget(VRW_MATRIX)->current_y / this->resize.step_height); this->order = order; this->sel = -1; @@ -895,9 +894,6 @@ public: this->FinishInitNested(desc, window_number); this->owner = company; - this->vscroll.SetCapacity(this->GetWidget(VLW_WIDGET_LIST)->current_y / this->resize.step_height); - this->GetWidget(VLW_WIDGET_LIST)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); - if (this->vehicle_type == VEH_TRAIN) ResizeWindow(this, 65, 0); } @@ -1307,11 +1303,6 @@ struct VehicleDetailsWindow : Window { this->GetWidget(VLD_WIDGET_RENAME_VEHICLE)->tool_tip = STR_VEHICLE_DETAILS_TRAIN_RENAME + v->type; - if (v->type == VEH_TRAIN) { - NWidgetCore *nwi = this->GetWidget(VLD_WIDGET_MATRIX); - this->vscroll.SetCapacity(nwi->current_y / this->resize.step_height); - nwi->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); - } this->owner = v->owner; this->tab = TDW_TAB_CARGO; }