| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "imodule.h" |
| 4 |
|
| 5 |
namespace map |
| 6 |
{ |
| 7 |
|
| 8 |
/** |
| 9 |
* Public interface to to automatic map save algorithms. |
| 10 |
* |
| 11 |
* DarkRadiant can be configured to create map backups on demand, |
| 12 |
* which can be a simple copy of the current map that is overwritten every time, |
| 13 |
* or it can create sequential snapshots in a separate folder including size limitations. |
| 14 |
* |
| 15 |
* The configuration of the save behaviour is done through registry keys. |
| 16 |
*/ |
| 17 |
class IAutomaticMapSaver : |
| 18 |
public RegisterableModule |
| 19 |
{ |
| 20 |
public: |
| 21 |
virtual ~IAutomaticMapSaver() {} |
| 22 |
|
| 23 |
// Run the checks to see if the map needs to be automatically saved. |
| 24 |
// If the auto saver is not enabled, nothing happens. |
| 25 |
// Returns true if the map is ready to be auto-saved, false otherwise. |
| 26 |
virtual bool runAutosaveCheck() = 0; |
| 27 |
|
| 28 |
// Perform an automatic save, unconditionally. This will run the save algorithms |
| 29 |
// for the currently loaded map, regardless whether it is due for a save or not. |
| 30 |
// Call the "runAutosaveCheck" method to see if an autosave is overdue. |
| 31 |
virtual void performAutosave() = 0; |
| 32 |
}; |
| 33 |
|
| 34 |
constexpr const char* const RKEY_AUTOSAVE_SNAPSHOTS_ENABLED = "user/ui/map/autoSaveSnapshots"; |
| 35 |
constexpr const char* const RKEY_AUTOSAVE_SNAPSHOTS_FOLDER = "user/ui/map/snapshotFolder"; |
| 36 |
constexpr const char* const RKEY_AUTOSAVE_MAX_SNAPSHOT_FOLDER_SIZE = "user/ui/map/maxSnapshotFolderSize"; |
| 37 |
constexpr const char* const RKEY_AUTOSAVE_SNAPSHOT_FOLDER_SIZE_HISTORY = "user/ui/map/snapshotFolderSizeHistory"; |
| 38 |
|
| 39 |
} |
| 40 |
|
| 41 |
constexpr const char* const MODULE_AUTOSAVER("AutomaticMapSaver"); |
| 42 |
|
| 43 |
// Application-wide Accessor to the global map auto saver |
| 44 |
inline map::IAutomaticMapSaver& GlobalAutoSaver() |
| 45 |
{ |
| 46 |
static module::InstanceReference<map::IAutomaticMapSaver> _reference(MODULE_AUTOSAVER); |
| 47 |
return _reference; |
| 48 |
} |