From 3126a33474d2c2466d8ca1e6e0a9d1d3d7cc3076 Mon Sep 17 00:00:00 2001 From: codereader Date: Sun, 19 Jan 2020 06:00:37 +0100 Subject: [PATCH] Write total edit time to map root property bag. --- radiant/map/EditingStopwatch.cpp | 12 ++++++++++++ radiant/map/EditingStopwatch.h | 1 + 2 files changed, 13 insertions(+) diff --git a/radiant/map/EditingStopwatch.cpp b/radiant/map/EditingStopwatch.cpp index c17df4ef9c..46af4531d0 100644 --- a/radiant/map/EditingStopwatch.cpp +++ b/radiant/map/EditingStopwatch.cpp @@ -21,6 +21,7 @@ namespace { const int TIMER_INTERVAL_SECS = 1; const char* const STATUS_BAR_ELEMENT = "EditTime"; + const char* const MAP_PROPERTY_KEY = "EditTimeInSeconds"; } EditingStopwatch::EditingStopwatch() : @@ -126,6 +127,7 @@ void EditingStopwatch::onMapEvent(IMap::MapEvent ev) // We start/stop during save operations case IMap::MapSaving: + writeToMapProperties(); stop(); break; case IMap::MapSaved: @@ -163,6 +165,16 @@ void EditingStopwatch::setTotalSecondsEdited(unsigned long newValue) _secondsEdited = newValue; } +void EditingStopwatch::writeToMapProperties() +{ + auto root = GlobalMapModule().getRoot(); + + if (root) + { + root->setProperty(MAP_PROPERTY_KEY, string::to_string(getTotalSecondsEdited())); + } +} + // Static module registration module::StaticModule _stopwatchModule; diff --git a/radiant/map/EditingStopwatch.h b/radiant/map/EditingStopwatch.h index bd66e2c199..749b9907eb 100644 --- a/radiant/map/EditingStopwatch.h +++ b/radiant/map/EditingStopwatch.h @@ -50,6 +50,7 @@ class EditingStopwatch : void onMapEvent(IMap::MapEvent ev); void onRadiantStartup(); void onIntervalReached(wxTimerEvent& ev); + void writeToMapProperties(); }; }