Refactor viewport catchment overlay change handling
This commit is contained in:
@@ -6563,6 +6563,21 @@ void ResetRailPlacementSnapping()
|
|||||||
_current_snap_lock.x = -1;
|
_current_snap_lock.x = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
if (_viewport_highlight_tracerestrict_program != nullptr) InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ClearViewportCatchment()
|
||||||
|
{
|
||||||
|
MarkCatchmentTilesDirty();
|
||||||
|
_viewport_highlight_station = nullptr;
|
||||||
|
_viewport_highlight_town = nullptr;
|
||||||
|
_viewport_highlight_tracerestrict_program = 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.
|
||||||
@@ -6571,14 +6586,10 @@ void ResetRailPlacementSnapping()
|
|||||||
*/
|
*/
|
||||||
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;
|
|
||||||
if (_viewport_highlight_tracerestrict_program != nullptr) InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
|
||||||
_viewport_highlight_tracerestrict_program = nullptr;
|
|
||||||
MarkCatchmentTilesDirty();
|
MarkCatchmentTilesDirty();
|
||||||
} else if (!sel && _viewport_highlight_station == st) {
|
} else if (!sel && _viewport_highlight_station == st) {
|
||||||
MarkCatchmentTilesDirty();
|
MarkCatchmentTilesDirty();
|
||||||
@@ -6595,13 +6606,10 @@ 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;
|
||||||
if (_viewport_highlight_tracerestrict_program != nullptr) InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
|
||||||
_viewport_highlight_tracerestrict_program = nullptr;
|
|
||||||
MarkWholeNonMapViewportsDirty();
|
MarkWholeNonMapViewportsDirty();
|
||||||
} else if (!sel && _viewport_highlight_town == t) {
|
} else if (!sel && _viewport_highlight_town == t) {
|
||||||
_viewport_highlight_town = nullptr;
|
_viewport_highlight_town = nullptr;
|
||||||
@@ -6612,19 +6620,16 @@ void SetViewportCatchmentTown(const Town *t, bool sel)
|
|||||||
|
|
||||||
void SetViewportCatchmentTraceRestrictProgram(const TraceRestrictProgram *prog, bool sel)
|
void SetViewportCatchmentTraceRestrictProgram(const TraceRestrictProgram *prog, 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_tracerestrict_program != prog) {
|
if (sel && _viewport_highlight_tracerestrict_program != prog) {
|
||||||
_viewport_highlight_station = nullptr;
|
ClearViewportCatchment();
|
||||||
_viewport_highlight_town = nullptr;
|
|
||||||
_viewport_highlight_tracerestrict_program = prog;
|
_viewport_highlight_tracerestrict_program = prog;
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
|
||||||
MarkWholeNonMapViewportsDirty();
|
MarkWholeNonMapViewportsDirty();
|
||||||
} else if (!sel && _viewport_highlight_tracerestrict_program == prog) {
|
} else if (!sel && _viewport_highlight_tracerestrict_program == prog) {
|
||||||
_viewport_highlight_tracerestrict_program = nullptr;
|
_viewport_highlight_tracerestrict_program = nullptr;
|
||||||
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
|
||||||
MarkWholeNonMapViewportsDirty();
|
MarkWholeNonMapViewportsDirty();
|
||||||
}
|
}
|
||||||
|
if (_viewport_highlight_tracerestrict_program != nullptr) InvalidateWindowClassesData(WC_TRACE_RESTRICT);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetSlopeTreeBrightnessAdjust(Slope slope)
|
int GetSlopeTreeBrightnessAdjust(Slope slope)
|
||||||
|
Reference in New Issue
Block a user