Merge branch 'master' into jgrpp
# Conflicts: # src/autoreplace_cmd.cpp # src/company_base.h # src/company_gui.cpp # src/cpu.cpp # src/debug.h # src/group.h # src/group_cmd.cpp # src/house.h # src/industry.h # src/newgrf_house.cpp # src/news_type.h # src/openttd.cpp # src/saveload/company_sl.cpp # src/settings_type.h # src/sl/oldloader_sl.cpp # src/story.cpp # src/table/town_land.h # src/viewport.cpp
This commit is contained in:
@@ -516,6 +516,7 @@ struct BuildRailToolbarWindow : Window {
|
||||
this->FinishInitNested(TRANSPORT_RAIL);
|
||||
this->SetupRailToolbar(railtype);
|
||||
this->DisableWidget(WID_RAT_REMOVE);
|
||||
this->OnInvalidateData();
|
||||
this->last_user_action = INVALID_WID_RAT;
|
||||
|
||||
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
|
||||
@@ -530,6 +531,53 @@ struct BuildRailToolbarWindow : Window {
|
||||
this->Window::Close();
|
||||
}
|
||||
|
||||
/** List of widgets to be disabled if infrastructure limit prevents building. */
|
||||
static inline const std::initializer_list<WidgetID> can_build_widgets = {
|
||||
WID_RAT_BUILD_NS, WID_RAT_BUILD_X, WID_RAT_BUILD_EW, WID_RAT_BUILD_Y, WID_RAT_AUTORAIL,
|
||||
WID_RAT_BUILD_DEPOT, WID_RAT_BUILD_WAYPOINT, WID_RAT_BUILD_STATION, WID_RAT_BUILD_SIGNALS,
|
||||
WID_RAT_BUILD_BRIDGE, WID_RAT_BUILD_TUNNEL, WID_RAT_CONVERT_RAIL,
|
||||
};
|
||||
|
||||
void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
|
||||
{
|
||||
if (!gui_scope) return;
|
||||
|
||||
if (this->GetWidget<NWidgetStacked>(WID_RAT_POLYRAIL_SEL)->SetDisplayedPlane(_settings_client.gui.show_rail_polyline_tool ? 0 : SZSP_NONE)) {
|
||||
if (this->IsWidgetLowered(WID_RAT_POLYRAIL)) {
|
||||
ResetObjectToPlace();
|
||||
}
|
||||
this->ReInit();
|
||||
}
|
||||
|
||||
bool can_build = CanBuildVehicleInfrastructure(VEH_TRAIN);
|
||||
for (const WidgetID widget : can_build_widgets) this->SetWidgetDisabledState(widget, !can_build);
|
||||
if (!can_build) {
|
||||
CloseWindowById(WC_BUILD_SIGNAL, TRANSPORT_RAIL);
|
||||
CloseWindowById(WC_BUILD_STATION, TRANSPORT_RAIL);
|
||||
CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_RAIL);
|
||||
CloseWindowById(WC_BUILD_WAYPOINT, TRANSPORT_RAIL);
|
||||
CloseWindowById(WC_SELECT_STATION, 0);
|
||||
}
|
||||
}
|
||||
|
||||
bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override
|
||||
{
|
||||
bool can_build = CanBuildVehicleInfrastructure(VEH_TRAIN);
|
||||
if (can_build) {
|
||||
if (widget == WID_RAT_CONVERT_RAIL) {
|
||||
SetDParam(0, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL);
|
||||
GuiShowTooltips(this, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL_EXTRA, close_cond, 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (std::find(std::begin(can_build_widgets), std::end(can_build_widgets), widget) == std::end(can_build_widgets)) return false;
|
||||
|
||||
GuiShowTooltips(this, STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE, close_cond);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the rail toolbar for railtype given
|
||||
* @param railtype the railtype to display
|
||||
@@ -747,16 +795,6 @@ struct BuildRailToolbarWindow : Window {
|
||||
if (_ctrl_pressed) RailToolbar_CtrlChanged(this);
|
||||
}
|
||||
|
||||
virtual bool OnTooltip(Point pt, WidgetID widget, TooltipCloseCondition close_cond) override
|
||||
{
|
||||
if (widget == WID_RAT_CONVERT_RAIL) {
|
||||
SetDParam(0, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL);
|
||||
GuiShowTooltips(this, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL_EXTRA, close_cond, 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
EventState OnHotkey(int hotkey) override
|
||||
{
|
||||
MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection
|
||||
@@ -965,18 +1003,6 @@ struct BuildRailToolbarWindow : Window {
|
||||
if (this->IsWidgetLowered(WID_RAT_BUILD_WAYPOINT)) CheckRedrawWaypointCoverage(this, false);
|
||||
}
|
||||
|
||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||
{
|
||||
if (!gui_scope) return;
|
||||
|
||||
if (this->GetWidget<NWidgetStacked>(WID_RAT_POLYRAIL_SEL)->SetDisplayedPlane(_settings_client.gui.show_rail_polyline_tool ? 0 : SZSP_NONE)) {
|
||||
if (this->IsWidgetLowered(WID_RAT_POLYRAIL)) {
|
||||
ResetObjectToPlace();
|
||||
}
|
||||
this->ReInit();
|
||||
}
|
||||
}
|
||||
|
||||
static HotkeyList hotkeys;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user