Merge remote-tracking branch 'upstream/master'

This commit is contained in:
pelya
2021-01-25 00:50:42 +02:00
1076 changed files with 25433 additions and 61762 deletions

View File

@@ -297,18 +297,31 @@ struct BuildRoadToolbarWindow : Window {
void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (!gui_scope) return;
RoadTramType rtt = GetRoadTramType(this->roadtype);
if (_game_mode != GM_EDITOR && !CanBuildVehicleInfrastructure(VEH_ROAD, GetRoadTramType(this->roadtype))) delete this;
bool can_build = _game_mode != GM_EDITOR;
bool can_build = CanBuildVehicleInfrastructure(VEH_ROAD, rtt);
this->SetWidgetsDisabledState(!can_build,
WID_ROT_DEPOT,
WID_ROT_BUS_STATION,
WID_ROT_TRUCK_STATION,
WIDGET_LIST_END);
WID_ROT_DEPOT,
WID_ROT_BUS_STATION,
WID_ROT_TRUCK_STATION,
WIDGET_LIST_END);
if (!can_build) {
DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_ROAD);
DeleteWindowById(WC_BUS_STATION, TRANSPORT_ROAD);
DeleteWindowById(WC_TRUCK_STATION, TRANSPORT_ROAD);
DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_ROAD);
}
if (_game_mode != GM_EDITOR) {
if (!can_build) {
/* Show in the tooltip why this button is disabled. */
this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
this->GetWidget<NWidgetCore>(WID_ROT_BUS_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
this->GetWidget<NWidgetCore>(WID_ROT_TRUCK_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
} else {
this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_VEHICLE_DEPOT : STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAM_VEHICLE_DEPOT);
this->GetWidget<NWidgetCore>(WID_ROT_BUS_STATION)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_BUILD_BUS_STATION : STR_ROAD_TOOLBAR_TOOLTIP_BUILD_PASSENGER_TRAM_STATION);
this->GetWidget<NWidgetCore>(WID_ROT_TRUCK_STATION)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRUCK_LOADING_BAY : STR_ROAD_TOOLBAR_TOOLTIP_BUILD_CARGO_TRAM_STATION);
}
}
}
@@ -439,7 +452,6 @@ struct BuildRoadToolbarWindow : Window {
break;
case WID_ROT_DEPOT:
if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD, GetRoadTramType(this->roadtype))) return;
if (HandlePlacePushButton(this, WID_ROT_DEPOT, this->rti->cursor.depot, HT_RECT | HT_SCROLL_VIEWPORT)) {
ShowRoadDepotPicker(this);
this->last_started_action = widget;
@@ -447,7 +459,6 @@ struct BuildRoadToolbarWindow : Window {
break;
case WID_ROT_BUS_STATION:
if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD, GetRoadTramType(this->roadtype))) return;
if (HandlePlacePushButton(this, WID_ROT_BUS_STATION, SPR_CURSOR_BUS_STATION, HT_RECT)) {
ShowRVStationPicker(this, ROADSTOP_BUS);
this->last_started_action = widget;
@@ -455,7 +466,6 @@ struct BuildRoadToolbarWindow : Window {
break;
case WID_ROT_TRUCK_STATION:
if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD, GetRoadTramType(this->roadtype))) return;
if (HandlePlacePushButton(this, WID_ROT_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, HT_RECT)) {
ShowRVStationPicker(this, ROADSTOP_TRUCK);
this->last_started_action = widget;
@@ -753,26 +763,37 @@ struct BuildRoadToolbarWindow : Window {
* @param last_build Last build road type
* @return ES_HANDLED if hotkey was accepted.
*/
static EventState RoadTramToolbarGlobalHotkeys(int hotkey, RoadType last_build)
static EventState RoadTramToolbarGlobalHotkeys(int hotkey, RoadType last_build, RoadTramType rtt)
{
Window *w = (_game_mode == GM_NORMAL) ? ShowBuildRoadToolbar(last_build) : ShowBuildRoadScenToolbar(last_build);
Window* w = nullptr;
switch (_game_mode) {
case GM_NORMAL:
w = ShowBuildRoadToolbar(last_build);
break;
case GM_EDITOR:
if ((GetRoadTypes(true) & ((rtt == RTT_ROAD) ? ~_roadtypes_type : _roadtypes_type)) == ROADTYPES_NONE) return ES_NOT_HANDLED;
w = ShowBuildRoadScenToolbar(last_build);
break;
default:
break;
}
if (w == nullptr) return ES_NOT_HANDLED;
return w->OnHotkey(hotkey);
}
static EventState RoadToolbarGlobalHotkeys(int hotkey)
{
if (_game_mode == GM_NORMAL && !CanBuildVehicleInfrastructure(VEH_ROAD, RTT_ROAD)) return ES_NOT_HANDLED;
extern RoadType _last_built_roadtype;
return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_roadtype);
return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_roadtype, RTT_ROAD);
}
static EventState TramToolbarGlobalHotkeys(int hotkey)
{
if (_game_mode != GM_NORMAL || !CanBuildVehicleInfrastructure(VEH_ROAD, RTT_TRAM)) return ES_NOT_HANDLED;
extern RoadType _last_built_tramtype;
return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_tramtype);
return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_tramtype, RTT_TRAM);
}
static Hotkey roadtoolbar_hotkeys[] = {
@@ -1182,6 +1203,7 @@ struct BuildRoadStationWindow : public PickerWindowBase {
this->LowerWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
this->SetDirty();
SetViewportCatchmentStation(nullptr, true);
break;
default:
@@ -1394,7 +1416,7 @@ DropDownList GetScenRoadTypeDropDownList(RoadTramTypes rtts)
DropDownListIconItem *item = new DropDownListIconItem(rti->gui_sprites.build_x_road, PAL_NONE, str, rt, !HasBit(avail_roadtypes, rt));
item->SetDimension(d);
item->SetParam(0, rti->strings.menu_text);
item->SetParam(1, rti->max_speed);
item->SetParam(1, rti->max_speed / 2);
list.emplace_back(item);
}