Merge pull request #292 from VacuumBreather/minor_additions
Minor additions
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -1044,6 +1045,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);
|
||||
|
@@ -1340,6 +1340,7 @@ public:
|
||||
}
|
||||
}
|
||||
size->width = std::max(size->width, d.width + padding.width);
|
||||
size->width = std::min<uint>(size->width, ScaleGUITrad(400));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -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<uint16>(1, resort_interval);
|
||||
this->resort_timer = std::min<uint16>(this->resort_timer, this->resort_interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the sort order is descending
|
||||
*
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
@@ -2232,6 +2240,7 @@ public:
|
||||
switch (widget) {
|
||||
case WID_VL_SORT_ORDER: // Flip sorting method ascending/descending
|
||||
this->vehgroups.ToggleSortOrder();
|
||||
this->vehgroups.ForceResort();
|
||||
this->SetDirty();
|
||||
break;
|
||||
|
||||
@@ -2313,6 +2322,7 @@ public:
|
||||
|
||||
case WID_VL_SORT_BY_PULLDOWN:
|
||||
this->vehgroups.SetSortType(index);
|
||||
this->UpdateSortingInterval();
|
||||
break;
|
||||
|
||||
case WID_VL_FILTER_BY_CARGO:
|
||||
|
@@ -133,6 +133,7 @@ public:
|
||||
|
||||
void OnInit() override;
|
||||
|
||||
void UpdateSortingInterval();
|
||||
void UpdateSortingFromGrouping();
|
||||
|
||||
void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const;
|
||||
|
Reference in New Issue
Block a user