Road stops: Auto-select an available type on selecting a class
Or on opening the road stop window
This commit is contained in:
@@ -1327,6 +1327,8 @@ public:
|
|||||||
_roadstop_gui_settings.roadstop_class = ROADSTOP_CLASS_DFLT;
|
_roadstop_gui_settings.roadstop_class = ROADSTOP_CLASS_DFLT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->SelectFirstAvailableTypeIfUnavailable();
|
||||||
|
|
||||||
NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BROS_MATRIX);
|
NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BROS_MATRIX);
|
||||||
matrix->SetScrollbar(this->vscrollMatrix);
|
matrix->SetScrollbar(this->vscrollMatrix);
|
||||||
matrix->SetCount(_roadstop_gui_settings.roadstop_count);
|
matrix->SetCount(_roadstop_gui_settings.roadstop_count);
|
||||||
@@ -1390,6 +1392,20 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SelectFirstAvailableTypeIfUnavailable()
|
||||||
|
{
|
||||||
|
const RoadStopClass *rs_class = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class);
|
||||||
|
StationType st = GetRoadStationTypeByWindowClass(this->window_class);
|
||||||
|
|
||||||
|
if (IsRoadStopAvailable(rs_class->GetSpec(_roadstop_gui_settings.roadstop_type), st)) return;
|
||||||
|
for (uint i = 0; i < _roadstop_gui_settings.roadstop_count; i++) {
|
||||||
|
if (IsRoadStopAvailable(rs_class->GetSpec(i), st)) {
|
||||||
|
_roadstop_gui_settings.roadstop_type = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||||
{
|
{
|
||||||
if (!gui_scope) return;
|
if (!gui_scope) return;
|
||||||
@@ -1629,9 +1645,10 @@ public:
|
|||||||
RoadStopClassID class_id = this->roadstop_classes[y];
|
RoadStopClassID class_id = this->roadstop_classes[y];
|
||||||
if (_roadstop_gui_settings.roadstop_class != class_id && GetIfClassHasNewStopsByType(RoadStopClass::Get(class_id), roadStopType, _cur_roadtype)) {
|
if (_roadstop_gui_settings.roadstop_class != class_id && GetIfClassHasNewStopsByType(RoadStopClass::Get(class_id), roadStopType, _cur_roadtype)) {
|
||||||
_roadstop_gui_settings.roadstop_class = class_id;
|
_roadstop_gui_settings.roadstop_class = class_id;
|
||||||
RoadStopClass *rsclass = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class);
|
RoadStopClass *rsclass = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class);
|
||||||
_roadstop_gui_settings.roadstop_count = rsclass->GetSpecCount();
|
_roadstop_gui_settings.roadstop_count = rsclass->GetSpecCount();
|
||||||
_roadstop_gui_settings.roadstop_type = std::min((int)_roadstop_gui_settings.roadstop_type, std::max(0, (int)_roadstop_gui_settings.roadstop_count - 1));
|
_roadstop_gui_settings.roadstop_type = std::min((int)_roadstop_gui_settings.roadstop_type, std::max(0, (int)_roadstop_gui_settings.roadstop_count - 1));
|
||||||
|
this->SelectFirstAvailableTypeIfUnavailable();
|
||||||
|
|
||||||
NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BROS_MATRIX);
|
NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BROS_MATRIX);
|
||||||
matrix->SetCount(_roadstop_gui_settings.roadstop_count);
|
matrix->SetCount(_roadstop_gui_settings.roadstop_count);
|
||||||
|
Reference in New Issue
Block a user