Codechange: Refactor viewport catchment overlay change handling
This commit is contained in:

committed by
PeterN

parent
0f3dd9c796
commit
84b53213af
@@ -3513,6 +3513,19 @@ void MarkCatchmentTilesDirty()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void SetWindowDirtyForViewportCatchment()
|
||||||
|
{
|
||||||
|
if (_viewport_highlight_station != nullptr) SetWindowDirty(WC_STATION_VIEW, _viewport_highlight_station->index);
|
||||||
|
if (_viewport_highlight_town != nullptr) SetWindowDirty(WC_TOWN_VIEW, _viewport_highlight_town->index);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ClearViewportCatchment()
|
||||||
|
{
|
||||||
|
MarkCatchmentTilesDirty();
|
||||||
|
_viewport_highlight_station = nullptr;
|
||||||
|
_viewport_highlight_town = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select or deselect station for coverage area highlight.
|
* Select or deselect station for coverage area highlight.
|
||||||
* Selecting a station will deselect a town.
|
* Selecting a station will deselect a town.
|
||||||
@@ -3521,12 +3534,10 @@ void MarkCatchmentTilesDirty()
|
|||||||
*/
|
*/
|
||||||
void SetViewportCatchmentStation(const Station *st, bool sel)
|
void SetViewportCatchmentStation(const Station *st, bool sel)
|
||||||
{
|
{
|
||||||
if (_viewport_highlight_station != nullptr) SetWindowDirty(WC_STATION_VIEW, _viewport_highlight_station->index);
|
SetWindowDirtyForViewportCatchment();
|
||||||
if (_viewport_highlight_town != nullptr) SetWindowDirty(WC_TOWN_VIEW, _viewport_highlight_town->index);
|
|
||||||
if (sel && _viewport_highlight_station != st) {
|
if (sel && _viewport_highlight_station != st) {
|
||||||
MarkCatchmentTilesDirty();
|
ClearViewportCatchment();
|
||||||
_viewport_highlight_station = st;
|
_viewport_highlight_station = st;
|
||||||
_viewport_highlight_town = nullptr;
|
|
||||||
MarkCatchmentTilesDirty();
|
MarkCatchmentTilesDirty();
|
||||||
} else if (!sel && _viewport_highlight_station == st) {
|
} else if (!sel && _viewport_highlight_station == st) {
|
||||||
MarkCatchmentTilesDirty();
|
MarkCatchmentTilesDirty();
|
||||||
@@ -3543,10 +3554,9 @@ void SetViewportCatchmentStation(const Station *st, bool sel)
|
|||||||
*/
|
*/
|
||||||
void SetViewportCatchmentTown(const Town *t, bool sel)
|
void SetViewportCatchmentTown(const Town *t, bool sel)
|
||||||
{
|
{
|
||||||
if (_viewport_highlight_town != nullptr) SetWindowDirty(WC_TOWN_VIEW, _viewport_highlight_town->index);
|
SetWindowDirtyForViewportCatchment();
|
||||||
if (_viewport_highlight_station != nullptr) SetWindowDirty(WC_STATION_VIEW, _viewport_highlight_station->index);
|
|
||||||
if (sel && _viewport_highlight_town != t) {
|
if (sel && _viewport_highlight_town != t) {
|
||||||
_viewport_highlight_station = nullptr;
|
ClearViewportCatchment();
|
||||||
_viewport_highlight_town = t;
|
_viewport_highlight_town = t;
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
} else if (!sel && _viewport_highlight_town == t) {
|
} else if (!sel && _viewport_highlight_town == t) {
|
||||||
|
Reference in New Issue
Block a user