15#ifndef LUX_AUTO_SAVE_H
16#define LUX_AUTO_SAVE_H
65 if(s.size() < p.size())
return false;
66 for(
size_t i = 0; i < p.size(); ++i)
68 wchar_t a = s[i], b = p[i];
69 if(a >= L
'A' && a <= L
'Z') a = (wchar_t)(a - L
'A' + L
'a');
70 if(b >= L
'A' && b <= L
'Z') b = (wchar_t)(b - L
'A' + L
'a');
71 if(a != b)
return false;
85inline bool LuxAutoSaveSafe(
bool abPlayerActive,
bool abDead,
bool abStoryScene,
bool abInDanger,
bool abInMenu)
87 return abPlayerActive && !abDead && !abStoryScene && !abInDanger && !abInMenu;
98 void SetLevel(
int alLevel) { mlLevel = alLevel; }
104 void OnSaved() { mfSinceSave = 0; mbMapChangePending =
false; }
107 bool Update(
float afTimeStep,
bool abPlaying,
bool abSafe)
109 if(abPlaying && afTimeStep > 0) mfSinceSave += afTimeStep;
110 if(abSafe ==
false)
return false;
111 if(mbMapChangePending)
return true;
113 return fInterval > 0 && mfSinceSave >= fInterval;
122 bool mbMapChangePending;
static const wchar_t *const kLuxAutoSavePrefix
bool LuxStartsWithI(const std::wstring &s, const std::wstring &p)
static const int kLuxAutoSavesKept
bool LuxAutoSaveSafe(bool abPlayerActive, bool abDead, bool abStoryScene, bool abInDanger, bool abInMenu)
A moment the game can be saved without surprising the player on load.
bool LuxAutoSaveOnMapChange(int alLevel)
float LuxAutoSaveInterval(int alLevel)
Seconds between timed saves, 0 = none.
int LuxSaveKind(const std::wstring &asFile)
Which kind a save file name is ("AutoSave_<map>_...sav", "Save_<map>_...sav").
static const wchar_t *const kLuxManualSavePrefix
int LuxAutoSavesToKeep(int alLevel, int alShippedMax)
How many autosaves to keep, the new one included.
float GetSinceSave() const
bool IsMapChangePending() const
void OnSaved()
Any save (script, quit, manual, ours) restarts the wait and covers a pending one.
bool Update(float afTimeStep, bool abPlaying, bool abSafe)
True when a save should happen now.
void SetLevel(int alLevel)
void OnMapChange()
A map change started: save at the next safe moment, unless something saves first.