Merge branch 'v14'
This commit is contained in:
@@ -2476,10 +2476,13 @@ HighLightStyle UpdateTileSelection(HighLightStyle new_drawstyle) {
|
|||||||
} else if (_thd.select_proc == CM_DDSP_BUILD_AIRPORT) {
|
} else if (_thd.select_proc == CM_DDSP_BUILD_AIRPORT) {
|
||||||
auto tile = TileXY(_thd.new_pos.x / TILE_SIZE, _thd.new_pos.y / TILE_SIZE);
|
auto tile = TileXY(_thd.new_pos.x / TILE_SIZE, _thd.new_pos.y / TILE_SIZE);
|
||||||
if (_selected_airport_index != -1) {
|
if (_selected_airport_index != -1) {
|
||||||
const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
|
auto ac = AirportClass::Get(_selected_airport_class);
|
||||||
|
auto as = (ac != nullptr ? ac->GetSpec(_selected_airport_index) : nullptr);
|
||||||
|
if (as != nullptr) {
|
||||||
_thd.cm_new = ObjectHighlight::make_airport(tile, as->GetIndex(), _selected_airport_layout);
|
_thd.cm_new = ObjectHighlight::make_airport(tile, as->GetIndex(), _selected_airport_layout);
|
||||||
new_drawstyle = HT_RECT;
|
new_drawstyle = HT_RECT;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (_thd.select_proc == DDSP_BUILD_STATION || _thd.select_proc == DDSP_BUILD_BUSSTOP
|
} else if (_thd.select_proc == DDSP_BUILD_STATION || _thd.select_proc == DDSP_BUILD_BUSSTOP
|
||||||
|| _thd.select_proc == DDSP_BUILD_TRUCKSTOP) { // station
|
|| _thd.select_proc == DDSP_BUILD_TRUCKSTOP) { // station
|
||||||
if (_thd.size.x >= (int)TILE_SIZE && _thd.size.y >= (int)TILE_SIZE) {
|
if (_thd.size.x >= (int)TILE_SIZE && _thd.size.y >= (int)TILE_SIZE) {
|
||||||
@@ -2862,8 +2865,6 @@ bool HandlePlacePushButton(Window *w, WidgetID widget, up<Tool> tool) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
w->LowerWidget(widget);
|
|
||||||
|
|
||||||
auto icon = tool->GetCursor();
|
auto icon = tool->GetCursor();
|
||||||
if ((icon & ANIMCURSOR_FLAG) != 0) {
|
if ((icon & ANIMCURSOR_FLAG) != 0) {
|
||||||
SetAnimatedMouseCursor(_animcursors[icon & ~ANIMCURSOR_FLAG]);
|
SetAnimatedMouseCursor(_animcursors[icon & ~ANIMCURSOR_FLAG]);
|
||||||
@@ -2873,9 +2874,9 @@ bool HandlePlacePushButton(Window *w, WidgetID widget, up<Tool> tool) {
|
|||||||
citymania::SetActiveTool(std::move(tool));
|
citymania::SetActiveTool(std::move(tool));
|
||||||
_thd.window_class = w->window_class;
|
_thd.window_class = w->window_class;
|
||||||
_thd.window_number = w->window_number;
|
_thd.window_number = w->window_number;
|
||||||
|
w->LowerWidget(widget);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace citymania
|
} // namespace citymania
|
||||||
|
|||||||
@@ -1025,6 +1025,7 @@ void SmallMapWindow::DrawIndustryProduction(const DrawPixelInfo *dpi) const
|
|||||||
[this] (auto &e) {
|
[this] (auto &e) {
|
||||||
auto ind = Industry::GetIfValid(e.index);
|
auto ind = Industry::GetIfValid(e.index);
|
||||||
if (ind == nullptr) return;
|
if (ind == nullptr) return;
|
||||||
|
if (!_legend_from_industries[_industry_to_list_pos[ind->type]].show_on_map) return;
|
||||||
auto pt = this->TileToPixel(
|
auto pt = this->TileToPixel(
|
||||||
TileX(ind->location.tile) * TILE_SIZE + ind->location.w * TILE_SIZE / 2,
|
TileX(ind->location.tile) * TILE_SIZE + ind->location.w * TILE_SIZE / 2,
|
||||||
TileY(ind->location.tile) * TILE_SIZE + ind->location.h * TILE_SIZE / 2
|
TileY(ind->location.tile) * TILE_SIZE + ind->location.h * TILE_SIZE / 2
|
||||||
|
|||||||
@@ -822,7 +822,7 @@ ToolGUIInfo RemoveAction::GetGUIInfo() {
|
|||||||
if (area.has_value()) {
|
if (area.has_value()) {
|
||||||
hlmap.AddTileAreaWithBorder(area.value(), CM_PALETTE_TINT_RED_DEEP);
|
hlmap.AddTileAreaWithBorder(area.value(), CM_PALETTE_TINT_RED_DEEP);
|
||||||
auto cmd = this->GetCommand(area.value());
|
auto cmd = this->GetCommand(area.value());
|
||||||
if (cmd) cost = cmd->test();
|
if (cmd != nullptr) cost = cmd->test();
|
||||||
}
|
}
|
||||||
return {hlmap, data, cost};
|
return {hlmap, data, cost};
|
||||||
}
|
}
|
||||||
@@ -832,7 +832,7 @@ void RemoveAction::OnStationRemoved(const Station *) {}
|
|||||||
// --- PlacementAction ---
|
// --- PlacementAction ---
|
||||||
|
|
||||||
ToolGUIInfo PlacementAction::PrepareGUIInfo(std::optional<ObjectHighlight> ohl, up<Command> cmd, StationCoverageType sct, uint rad) {
|
ToolGUIInfo PlacementAction::PrepareGUIInfo(std::optional<ObjectHighlight> ohl, up<Command> cmd, StationCoverageType sct, uint rad) {
|
||||||
if (!cmd || !ohl.has_value()) return {};
|
if (cmd == nullptr || !ohl.has_value()) return {};
|
||||||
ohl.value().UpdateTiles();
|
ohl.value().UpdateTiles();
|
||||||
auto palette = CM_PALETTE_TINT_WHITE;
|
auto palette = CM_PALETTE_TINT_WHITE;
|
||||||
auto area = ohl.value().GetArea();
|
auto area = ohl.value().GetArea();
|
||||||
@@ -1123,6 +1123,7 @@ extern void ShowSelectStationWindow(TileArea ta, StationPickerCmdProc&& proc);
|
|||||||
template<typename Taction, typename Tcallback, typename Targ>
|
template<typename Taction, typename Tcallback, typename Targ>
|
||||||
bool PostBuildStationCommand(Taction *action, Tcallback callback, Targ arg, StationID join_to) {
|
bool PostBuildStationCommand(Taction *action, Tcallback callback, Targ arg, StationID join_to) {
|
||||||
auto cmd = action->GetCommand(arg, join_to);
|
auto cmd = action->GetCommand(arg, join_to);
|
||||||
|
if (cmd == nullptr) return false;
|
||||||
if (UseImprovedStationJoin()) {
|
if (UseImprovedStationJoin()) {
|
||||||
cmd->with_callback([](bool res)->bool {
|
cmd->with_callback([](bool res)->bool {
|
||||||
if (!res) return false;
|
if (!res) return false;
|
||||||
@@ -1131,7 +1132,7 @@ bool PostBuildStationCommand(Taction *action, Tcallback callback, Targ arg, Stat
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return cmd ? cmd->post(callback) : false;
|
return cmd->post(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Taction, typename Tcallback, typename Targ>
|
template<typename Taction, typename Tcallback, typename Targ>
|
||||||
@@ -1146,7 +1147,7 @@ bool ExecuteBuildCommand(Taction *action, Tcallback callback, Targ arg) {
|
|||||||
[&](StationAction::Picker &) {
|
[&](StationAction::Picker &) {
|
||||||
auto cmd = action->GetCommand(arg, StationID::Invalid());
|
auto cmd = action->GetCommand(arg, StationID::Invalid());
|
||||||
auto proc = [cmd=sp<Command>{std::move(cmd)}, callback](bool test, StationID to_join) -> bool {
|
auto proc = [cmd=sp<Command>{std::move(cmd)}, callback](bool test, StationID to_join) -> bool {
|
||||||
if (!cmd) return false;
|
if (cmd == nullptr) return false;
|
||||||
auto station_cmd = dynamic_cast<StationBuildCommand *>(cmd.get());
|
auto station_cmd = dynamic_cast<StationBuildCommand *>(cmd.get());
|
||||||
if (station_cmd == nullptr) return false;
|
if (station_cmd == nullptr) return false;
|
||||||
station_cmd->station_to_join = to_join;
|
station_cmd->station_to_join = to_join;
|
||||||
@@ -1186,6 +1187,7 @@ up<Command> RailStationBuildTool::RemoveAction::GetCommand(TileArea area) {
|
|||||||
|
|
||||||
bool RailStationBuildTool::RemoveAction::Execute(TileArea area) {
|
bool RailStationBuildTool::RemoveAction::Execute(TileArea area) {
|
||||||
auto cmd = this->GetCommand(area);
|
auto cmd = this->GetCommand(area);
|
||||||
|
if (cmd == nullptr) return false;
|
||||||
return cmd->post(&CcPlaySound_CONSTRUCTION_RAIL);
|
return cmd->post(&CcPlaySound_CONSTRUCTION_RAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1317,6 +1319,7 @@ up<Command> RoadStopBuildTool::RemoveAction::GetCommand(TileArea area) {
|
|||||||
|
|
||||||
bool RoadStopBuildTool::RemoveAction::Execute(TileArea area) {
|
bool RoadStopBuildTool::RemoveAction::Execute(TileArea area) {
|
||||||
auto cmd = this->GetCommand(area);
|
auto cmd = this->GetCommand(area);
|
||||||
|
if (cmd == nullptr) return false;
|
||||||
return cmd->post(&CcPlaySound_CONSTRUCTION_OTHER);
|
return cmd->post(&CcPlaySound_CONSTRUCTION_OTHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1521,13 +1524,17 @@ bool AirportBuildTool::RemoveAction::Execute(TileArea area) {
|
|||||||
|
|
||||||
std::optional<TileArea> AirportBuildTool::SizedPlacementAction::GetArea() const {
|
std::optional<TileArea> AirportBuildTool::SizedPlacementAction::GetArea() const {
|
||||||
if (!IsValidTile(this->cur_tile)) return std::nullopt;
|
if (!IsValidTile(this->cur_tile)) return std::nullopt;
|
||||||
auto as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
|
auto ac = AirportClass::Get(_selected_airport_class);
|
||||||
|
if (ac == nullptr) return std::nullopt;
|
||||||
|
auto as = ac->GetSpec(_selected_airport_index);
|
||||||
if (as == nullptr) return std::nullopt;
|
if (as == nullptr) return std::nullopt;
|
||||||
return TileArea{this->cur_tile, as->size_x, as->size_y};
|
return TileArea{this->cur_tile, as->size_x, as->size_y};
|
||||||
}
|
}
|
||||||
|
|
||||||
up<Command> AirportBuildTool::SizedPlacementAction::GetCommand(TileIndex tile, StationID to_join) {
|
up<Command> AirportBuildTool::SizedPlacementAction::GetCommand(TileIndex tile, StationID to_join) {
|
||||||
auto as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
|
auto ac = AirportClass::Get(_selected_airport_class);
|
||||||
|
if (ac == nullptr) return nullptr;
|
||||||
|
auto as = ac->GetSpec(_selected_airport_index);
|
||||||
if (as == nullptr) return nullptr;
|
if (as == nullptr) return nullptr;
|
||||||
auto airport_type = as->GetIndex();
|
auto airport_type = as->GetIndex();
|
||||||
auto layout = _selected_airport_layout;
|
auto layout = _selected_airport_layout;
|
||||||
@@ -1547,14 +1554,21 @@ bool AirportBuildTool::SizedPlacementAction::Execute(TileIndex tile) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::optional<ObjectHighlight> AirportBuildTool::SizedPlacementAction::GetObjectHighlight(TileIndex tile) {
|
std::optional<ObjectHighlight> AirportBuildTool::SizedPlacementAction::GetObjectHighlight(TileIndex tile) {
|
||||||
auto airport_type = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->GetIndex();
|
auto ac = AirportClass::Get(_selected_airport_class);
|
||||||
auto layout = _selected_airport_layout;
|
if (ac == nullptr) return std::nullopt;
|
||||||
|
auto as = ac->GetSpec(_selected_airport_index);
|
||||||
|
if (as == nullptr) return std::nullopt;
|
||||||
|
byte airport_type = as->GetIndex();
|
||||||
|
byte layout = _selected_airport_layout;
|
||||||
return ObjectHighlight::make_airport(tile, airport_type, layout);
|
return ObjectHighlight::make_airport(tile, airport_type, layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<StationCoverageType, uint> AirportBuildTool::SizedPlacementAction::GetCatchmentParams() {
|
std::pair<StationCoverageType, uint> AirportBuildTool::SizedPlacementAction::GetCatchmentParams() {
|
||||||
auto rad = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->catchment;
|
auto ac = AirportClass::Get(_selected_airport_class);
|
||||||
return {SCT_ALL, rad};
|
if (ac == nullptr) return {SCT_ALL, 0};
|
||||||
|
auto as = ac->GetSpec(_selected_airport_index);
|
||||||
|
if (as == nullptr) return {SCT_ALL, 0};
|
||||||
|
return {SCT_ALL, as->catchment};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -613,8 +613,7 @@ struct BuildRoadToolbarWindow : Window {
|
|||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
}
|
}
|
||||||
citymania::RoadToolbar_UpdateOptionWidgetStatus(this, widget, _remove_button_clicked, RoadTypeIsRoad(this->roadtype));
|
citymania::RoadToolbar_UpdateOptionWidgetStatus(this, widget, _remove_button_clicked, RoadTypeIsRoad(this->roadtype));
|
||||||
// this->UpdateOptionWidgetStatus((RoadToolbarWidgets)widget);
|
//this->UpdateOptionWidgetStatus((RoadToolbarWidgets)widget);
|
||||||
// if (citymania::_remove_mod) RoadToolbar_CtrlChanged(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EventState OnHotkey(int hotkey) override
|
EventState OnHotkey(int hotkey) override
|
||||||
|
|||||||
Reference in New Issue
Block a user