mirror of https://github.com/OpenTTD/OpenTTD
Fix 8f14894024: Badge widths were not updated on interface scale change. (#13630)
Prepare GUI badge class lists in OnInit() method of Windows, so that they handle scaling changes.pull/13641/head
parent
8566030c53
commit
bb4ac915ff
|
@ -84,6 +84,7 @@ class ReplaceVehicleWindow : public Window {
|
|||
bool reset_sel_engine; ///< Also reset #sel_engine while updating left and/or right and no valid engine selected.
|
||||
GroupID sel_group; ///< Group selected to replace.
|
||||
int details_height; ///< Minimal needed height of the details panels, in text lines (found so far).
|
||||
VehicleType vehicle_type; ///< Type of vehicle in this window.
|
||||
uint8_t sort_criteria; ///< Criteria of sorting vehicles.
|
||||
bool descending_sort_order; ///< Order of sorting vehicles.
|
||||
bool show_hidden_engines; ///< Whether to show the hidden engines.
|
||||
|
@ -267,6 +268,7 @@ class ReplaceVehicleWindow : public Window {
|
|||
public:
|
||||
ReplaceVehicleWindow(WindowDesc &desc, VehicleType vehicletype, GroupID id_g) : Window(desc)
|
||||
{
|
||||
this->vehicle_type = vehicletype;
|
||||
this->sel_railtype = INVALID_RAILTYPE;
|
||||
this->sel_roadtype = INVALID_ROADTYPE;
|
||||
this->replace_engines = true; // start with locomotives (all other vehicles will not read this bool)
|
||||
|
@ -278,8 +280,6 @@ public:
|
|||
this->sel_engine[1] = EngineID::Invalid();
|
||||
this->show_hidden_engines = _engine_sort_show_hidden_engines[vehicletype];
|
||||
|
||||
this->badge_classes = GUIBadgeClasses(static_cast<GrfSpecFeature>(GSF_TRAINS + vehicletype));
|
||||
|
||||
this->CreateNestedTree();
|
||||
this->vscroll[0] = this->GetScrollbar(WID_RV_LEFT_SCROLLBAR);
|
||||
this->vscroll[1] = this->GetScrollbar(WID_RV_RIGHT_SCROLLBAR);
|
||||
|
@ -295,6 +295,11 @@ public:
|
|||
this->sel_group = id_g;
|
||||
}
|
||||
|
||||
void OnInit() override
|
||||
{
|
||||
this->badge_classes = GUIBadgeClasses(static_cast<GrfSpecFeature>(GSF_TRAINS + this->vehicle_type));
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
|
|
|
@ -1167,11 +1167,6 @@ struct BuildVehicleWindow : Window {
|
|||
}
|
||||
}
|
||||
|
||||
void BuildBadgeClasses()
|
||||
{
|
||||
this->badge_classes = GUIBadgeClasses(static_cast<GrfSpecFeature>(GSF_TRAINS + this->vehicle_type));
|
||||
}
|
||||
|
||||
BuildVehicleWindow(WindowDesc &desc, TileIndex tile, VehicleType type) : Window(desc), vehicle_editbox(MAX_LENGTH_VEHICLE_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_VEHICLE_NAME_CHARS)
|
||||
{
|
||||
this->vehicle_type = type;
|
||||
|
@ -1184,8 +1179,6 @@ struct BuildVehicleWindow : Window {
|
|||
this->descending_sort_order = _engine_sort_last_order[type];
|
||||
this->show_hidden_engines = _engine_sort_show_hidden_engines[type];
|
||||
|
||||
this->BuildBadgeClasses();
|
||||
|
||||
this->UpdateFilterByTile();
|
||||
|
||||
this->CreateNestedTree();
|
||||
|
@ -1315,6 +1308,7 @@ struct BuildVehicleWindow : Window {
|
|||
|
||||
void OnInit() override
|
||||
{
|
||||
this->badge_classes = GUIBadgeClasses(static_cast<GrfSpecFeature>(GSF_TRAINS + this->vehicle_type));
|
||||
this->SetCargoFilterArray();
|
||||
}
|
||||
|
||||
|
|
|
@ -311,7 +311,7 @@ class BuildIndustryWindow : public Window {
|
|||
bool enabled; ///< Availability state of the selected industry.
|
||||
Scrollbar *vscroll;
|
||||
Dimension legend; ///< Dimension of the legend 'blob'.
|
||||
GUIBadgeClasses badge_classes{GSF_INDUSTRIES};
|
||||
GUIBadgeClasses badge_classes;
|
||||
|
||||
/** The largest allowed minimum-width of the window, given in line heights */
|
||||
static const int MAX_MINWIDTH_LINEHEIGHTS = 20;
|
||||
|
@ -419,6 +419,8 @@ public:
|
|||
|
||||
void OnInit() override
|
||||
{
|
||||
this->badge_classes = GUIBadgeClasses{GSF_INDUSTRIES};
|
||||
|
||||
/* Width of the legend blob -- slightly larger than the smallmap legend blob. */
|
||||
this->legend.height = GetCharacterHeight(FS_SMALL);
|
||||
this->legend.width = this->legend.height * 9 / 6;
|
||||
|
|
|
@ -238,11 +238,14 @@ void PickerWindow::ConstructWindow()
|
|||
|
||||
this->FinishInitNested(this->window_number);
|
||||
|
||||
this->badge_classes = GUIBadgeClasses(this->callbacks.GetFeature());
|
||||
|
||||
this->InvalidateData(PICKER_INVALIDATION_ALL);
|
||||
}
|
||||
|
||||
void PickerWindow::OnInit()
|
||||
{
|
||||
this->badge_classes = GUIBadgeClasses(this->callbacks.GetFeature());
|
||||
}
|
||||
|
||||
void PickerWindow::Close(int data)
|
||||
{
|
||||
this->callbacks.Close(data);
|
||||
|
|
|
@ -179,6 +179,7 @@ public:
|
|||
bool has_type_picker = false; ///< Set if this window has a type picker 'component'.
|
||||
|
||||
PickerWindow(WindowDesc &desc, Window *parent, int window_number, PickerCallbacks &callbacks);
|
||||
void OnInit() override;
|
||||
void Close(int data = 0) override;
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override;
|
||||
void DrawWidget(const Rect &r, WidgetID widget) const override;
|
||||
|
|
Loading…
Reference in New Issue