From dd0a1ca6c0fc99c2a4832411e9e89cc20f850fdd Mon Sep 17 00:00:00 2001 From: Andreas Schmitt Date: Wed, 23 Jun 2021 06:53:24 +0200 Subject: [PATCH 1/4] Set a maximum size for the left part of the build rail station window --- src/rail_gui.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 289f150068..4f2dd3795d 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1340,6 +1340,7 @@ public: } } size->width = std::max(size->width, d.width + padding.width); + size->width = std::min(size->width, ScaleGUITrad(400)); break; } From 0f07ae839d9e261ab255cc2dbacaaa53f7afd842 Mon Sep 17 00:00:00 2001 From: Andreas Schmitt Date: Wed, 23 Jun 2021 06:54:42 +0200 Subject: [PATCH 2/4] Make the sort order toggle button resort a vehicle list --- src/group_gui.cpp | 1 + src/vehicle_gui.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 5da1d41934..a46991d0ec 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -722,6 +722,7 @@ public: switch (widget) { case WID_GL_SORT_BY_ORDER: // Flip sorting method ascending/descending this->vehgroups.ToggleSortOrder(); + this->vehgroups.ForceResort(); this->SetDirty(); break; diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 9b7fabffee..c783e8bfe7 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -2232,6 +2232,7 @@ public: switch (widget) { case WID_VL_SORT_ORDER: // Flip sorting method ascending/descending this->vehgroups.ToggleSortOrder(); + this->vehgroups.ForceResort(); this->SetDirty(); break; From c9c6b4cd9298fe1d966f43332adb9603be7aa04a Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 19 Jun 2021 07:59:36 +0200 Subject: [PATCH 3/4] Make GUIList resort interval variable --- src/sortlist_type.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/sortlist_type.h b/src/sortlist_type.h index 9c14d382bd..28f3ab6ec6 100644 --- a/src/sortlist_type.h +++ b/src/sortlist_type.h @@ -55,6 +55,7 @@ protected: uint8 sort_type; ///< what criteria to sort on uint8 filter_type; ///< what criteria to filter on uint16 resort_timer; ///< resort list after a given amount of ticks if set + uint16 resort_interval; ///< value to re-initialise resort_timer with after sorting /** * Check if the list is sortable @@ -71,8 +72,7 @@ protected: */ void ResetResortTimer() { - /* Resort every 10 days */ - this->resort_timer = DAY_TICKS * 10; + this->resort_timer = this->resort_interval; } public: @@ -82,7 +82,8 @@ public: flags(VL_NONE), sort_type(0), filter_type(0), - resort_timer(1) + resort_timer(1), + resort_interval(DAY_TICKS * 10) /* Resort every 10 days by default */ {}; /** @@ -215,6 +216,12 @@ public: SETBITS(this->flags, VL_RESORT); } + void SetResortInterval(uint16 resort_interval) + { + this->resort_interval = std::max(1, resort_interval); + this->resort_timer = std::min(this->resort_timer, this->resort_interval); + } + /** * Check if the sort order is descending * From 906ee568d6c5d6738d563a96a920c895d8420fd0 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 28 Jun 2021 22:37:40 +0100 Subject: [PATCH 4/4] Use a lower resort interval in veh windows when sorting by timetable delay --- src/group_gui.cpp | 1 + src/tracerestrict_gui.cpp | 1 + src/vehicle_gui.cpp | 9 +++++++++ src/vehicle_gui_base.h | 1 + 4 files changed, 12 insertions(+) diff --git a/src/group_gui.cpp b/src/group_gui.cpp index a46991d0ec..45c57e6fa5 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -1032,6 +1032,7 @@ public: case WID_GL_SORT_BY_DROPDOWN: this->vehgroups.SetSortType(index); + this->UpdateSortingInterval(); break; case WID_GL_FILTER_BY_CARGO: // Select a cargo filter criteria this->SetCargoFilterIndex(index); diff --git a/src/tracerestrict_gui.cpp b/src/tracerestrict_gui.cpp index 45506cbb13..f2c1a5b31a 100644 --- a/src/tracerestrict_gui.cpp +++ b/src/tracerestrict_gui.cpp @@ -3680,6 +3680,7 @@ public: switch (widget) { case WID_TRSL_SORT_BY_DROPDOWN: this->vehgroups.SetSortType(index); + this->UpdateSortingInterval(); break; case WID_TRSL_FILTER_BY_CARGO: // Select a cargo filter criteria diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index c783e8bfe7..69e5ea5e99 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1995,6 +1995,13 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int } } +void BaseVehicleListWindow::UpdateSortingInterval() +{ + uint16 resort_interval = DAY_TICKS * 10; + if (this->grouping == GB_NONE && this->vehgroups.SortType() == VST_TIMETABLE_DELAY) resort_interval = DAY_TICKS; + this->vehgroups.SetResortInterval(resort_interval); +} + void BaseVehicleListWindow::UpdateSortingFromGrouping() { /* Set up sorting. Make the window-specific _sorting variable @@ -2011,6 +2018,7 @@ void BaseVehicleListWindow::UpdateSortingFromGrouping() this->vehgroups.SetListing(*this->sorting); this->vehgroups.ForceRebuild(); this->vehgroups.NeedResort(); + this->UpdateSortingInterval(); } void BaseVehicleListWindow::UpdateVehicleGroupBy(GroupBy group_by) @@ -2314,6 +2322,7 @@ public: case WID_VL_SORT_BY_PULLDOWN: this->vehgroups.SetSortType(index); + this->UpdateSortingInterval(); break; case WID_VL_FILTER_BY_CARGO: diff --git a/src/vehicle_gui_base.h b/src/vehicle_gui_base.h index 1c1b5f5a9f..c72d165657 100644 --- a/src/vehicle_gui_base.h +++ b/src/vehicle_gui_base.h @@ -133,6 +133,7 @@ public: void OnInit() override; + void UpdateSortingInterval(); void UpdateSortingFromGrouping(); void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const;