From 1efe8510151ecc8de2cc841a31f344337eea6755 Mon Sep 17 00:00:00 2001 From: dP Date: Tue, 16 Feb 2021 19:08:42 +0300 Subject: [PATCH] Update station window when selection moves --- src/citymania/cm_station_gui.cpp | 15 ++++++++------- src/citymania/cm_station_gui.hpp | 2 +- src/station_gui.cpp | 5 ++++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/citymania/cm_station_gui.cpp b/src/citymania/cm_station_gui.cpp index aee71b4aad..62e90a3905 100644 --- a/src/citymania/cm_station_gui.cpp +++ b/src/citymania/cm_station_gui.cpp @@ -344,21 +344,21 @@ static void FindStationsAroundSelection(const TileArea &location) _station_building_status = (adjacent == nullptr ? StationBuildingStatus::NEW : StationBuildingStatus::JOIN); } -void CheckRedrawStationCoverage() { +bool CheckRedrawStationCoverage() { // static bool last_ctrl_pressed = false; static TileArea last_location; static bool last_station_mode = false; - static bool last_coverage = false; + static bool last_fn_mod = false; TileArea location(TileVirtXY(_thd.pos.x, _thd.pos.y), _thd.size.x / TILE_SIZE - 1, _thd.size.y / TILE_SIZE - 1); bool station_mode = ((_thd.drawstyle & HT_DRAG_MASK) == HT_RECT && _thd.outersize.x > 0); bool location_changed = (location.tile != last_location.tile || location.w != last_location.w || location.h != last_location.h); bool mode_changed = (last_station_mode != station_mode); - // if (!location_changed && _ctrl_pressed == last_ctrl_pressed && !mode_changed) - // return; + if (!location_changed && citymania::_fn_mod == last_fn_mod && !mode_changed) + return false; - // last_ctrl_pressed = _ctrl_pressed; - // last_location = location; - // last_station_mode = station_mode; + last_fn_mod = citymania::_fn_mod; + last_location = location; + last_station_mode = station_mode; if (citymania::_fn_mod) { Station *st = nullptr; @@ -375,6 +375,7 @@ void CheckRedrawStationCoverage() { FindStationsAroundSelection(location); } } + return true; } diff --git a/src/citymania/cm_station_gui.hpp b/src/citymania/cm_station_gui.hpp index 54ea3f5a3d..22fe0b2f01 100644 --- a/src/citymania/cm_station_gui.hpp +++ b/src/citymania/cm_station_gui.hpp @@ -29,7 +29,7 @@ void PlaceAirport(TileIndex tile); void SelectStationToJoin(const Station *station); // const Station *GetStationToJoin(); void MarkCoverageHighlightDirty(); -void CheckRedrawStationCoverage(); +bool CheckRedrawStationCoverage(); void AbortStationPlacement(); std::string GetStationCoverageProductionText(TileIndex tile, int w, int h, int rad, StationCoverageType sct); diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 7a36674da4..1f850ee627 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -153,10 +153,13 @@ static void FindStationsAroundSelection() */ void CheckRedrawStationCoverage(const Window *w) { + /* CityMania code begin */ if (_settings_client.gui.cm_use_improved_station_join) { - citymania::CheckRedrawStationCoverage(); + if (citymania::CheckRedrawStationCoverage()) w->SetDirty(); return; } + /* CityMania code end */ + /* Test if ctrl state changed */ static bool _last_fn_pressed; if (citymania::_fn_mod != _last_fn_pressed) {