Debian Codegraph @

include/ieditstopwatch.h

raw
1 #pragma once
2
3 #include "imodule.h"
4 #include <sigc++/signal.h>
5
6 namespace map
7 {
8
9 /**
10 * Stopwatch to measure the time spent editing a particular map.
11 * The time is persisted to the .darkradiant/.mapx file and keeps running
12 * as long as the application is in focus.
13 *
14 * The class will maintain its own internal timer class, but will broadcast
15 * a query message (type is IMessage::ApplicationIsActiveQuery) over the
16 * MessageBus such that the UI module can react and prevent the timer
17 * from increasing when the application is not in focus or blocked
18 * in some other way.
19 */
20 class IMapEditStopwatch :
21 public RegisterableModule
22 {
23 public:
24 virtual ~IMapEditStopwatch() {}
25
26 // Starts the stopwatch, the map edit timer will start ticking (again)
27 // This does not reset the timings
28 virtual void start() = 0;
29
30 // Stops the stopwatch, the map edit timer will not be increased anymore
31 // This does not reset the timings
32 virtual void stop() = 0;
33
34 // Gets the total number of seconds the map has been edited
35 virtual unsigned long getTotalSecondsEdited() = 0;
36
37 // Sets the total number of seconds the map has been edited so far
38 // This is used when loading maps from disk, to restore the timer to its previous state
39 virtual void setTotalSecondsEdited(unsigned long newValue) = 0;
40
41 // Signal emitted when the timer value changes
42 virtual sigc::signal<void>& sig_TimerChanged() = 0;
43 };
44
45 }
46
47 const char* const MODULE_EDITING_STOPWATCH("EditingStopwatch");
48
49 inline map::IMapEditStopwatch& GlobalMapEditStopwatch()
50 {
51 static module::InstanceReference<map::IMapEditStopwatch> _reference(MODULE_EDITING_STOPWATCH);
52 return _reference;
53 }