Skip to content

Commit

Permalink
Write total edit time to map root property bag.
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jan 19, 2020
1 parent bf353d5 commit 3126a33
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions radiant/map/EditingStopwatch.cpp
Expand Up @@ -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() :
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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<EditingStopwatch> _stopwatchModule;

Expand Down
1 change: 1 addition & 0 deletions radiant/map/EditingStopwatch.h
Expand Up @@ -50,6 +50,7 @@ class EditingStopwatch :
void onMapEvent(IMap::MapEvent ev);
void onRadiantStartup();
void onIntervalReached(wxTimerEvent& ev);
void writeToMapProperties();
};

}
Expand Down

0 comments on commit 3126a33

Please sign in to comment.