32 FontSizeMultiplier = 1;
60 FontSizeMultiplier = 1;
70 DataStore* Leviathan::DataStore::Staticaccess = NULL;
77 void Leviathan::DataStore::Load()
80 std::vector<std::shared_ptr<NamedVariableList>> tempvec;
83 Values.SetVec(tempvec);
86 Persistencestates.resize(tempvec.size(),
true);
89 void Leviathan::DataStore::Save()
91 std::string tosave =
"";
92 std::vector<std::shared_ptr<NamedVariableList>>* tempvec = Values.GetVec();
94 for(
unsigned int i = 0; i < Persistencestates.size(); i++) {
95 if(Persistencestates[i]) {
99 tosave += tempvec->at(i)->ToText(0);
104 tempvec->at(i)->GetName() +
"\": ");
109 if(i + 1 < Persistencestates.size()) {
121 return Values.GetValue(name, receiver);
126 return Values.GetValueCount(name);
130 const std::string& name, std::vector<const VariableBlock*>& receiver)
const 132 return Values.GetValues(name, receiver);
138 Persistencestates[index] = toset;
142 auto index = Values.
Find(name);
145 throw Exception(
"SetPersitance called for non-existent value");
147 Persistencestates[index] = toset;
152 return Persistencestates[index];
156 auto index = Values.
Find(name);
159 throw Exception(
"GetPersistance called for non-existent value");
161 return Persistencestates[index];
168 Values.SetValue(name, value1);
179 Values.SetValue(name, value1);
188 const std::string& name,
const std::vector<VariableBlock*>& values)
191 this->Values.SetValue(name, values);
202 ValueUpdate(nameandvalues.
GetName());
210 if(Values.Find(values->
GetName()) > Values.GetVariableCount()) {
212 this->Values.AddVar(values);
215 Persistencestates.push_back(
false);
221 if(index >= Values.GetVariableCount())
225 Values.Remove(index);
227 Persistencestates.erase(Persistencestates.begin() + index);
233 Remove(Values.Find(name));
238 return Values.GetVariableType(name);
243 return Values.GetVariableTypeOfAll(name);
253 if(tmpptre == NULL) {
256 Listeners[object] = std::make_shared<DataListenHolder>();
259 return RegisterListener(
object, listen);
271 Listeners.erase(
object);
278 if(tmpptre == NULL) {
318 void Leviathan::DataStore::ValueUpdate(
int index)
320 std::shared_ptr<NamedVariableList> updatedval(
nullptr);
322 for(
auto iter = Listeners.begin(); iter != Listeners.end(); ++iter) {
325 for(
size_t i = 0; i < iter->second->HandledListeners.size(); i++) {
328 if(iter->second->HandledListeners[i]->ListenIndex == index) {
330 if(updatedval.get() == NULL) {
332 updatedval = std::make_shared<NamedVariableList>(
337 iter->first->OnUpdate(updatedval);
343 void Leviathan::DataStore::ValueUpdate(
const std::string& name)
345 std::shared_ptr<NamedVariableList> updatedval(
nullptr);
347 for(
auto iter = Listeners.begin(); iter != Listeners.end(); ++iter) {
349 for(
size_t i = 0; i < iter->second->HandledListeners.size(); i++) {
351 if(iter->second->HandledListeners[i]->VarName == name) {
353 if(updatedval.get() == NULL) {
357 Values.GetValue(name)->GetBlockConst()->AllocateNewFromThis())));
361 iter->first->OnUpdate(updatedval);
461 return FrameTimeAverage;
489 return FrameTimeAverage;
509 FrameTimeMin = newval;
515 FrameTimeMax = newval;
521 FrameTimeAverage = newval;
545 return FontSizeMultiplier;
550 FontSizeMultiplier = newval;
556 std::string logName = StringOperations::RemoveEnding<std::string>(
559 return logName +
"Persist.txt";
566 ListenOnIndex =
false;
571 int index,
bool onindex,
const std::string& var)
575 ListenOnIndex = onindex;
DLLEXPORT int GetFontSizeMultiplier() const
#define DATAINDEX_FRAMETIME
DLLEXPORT int GetHeight() const
#define DATAINDEX_FRAMETIME_MIN
DLLEXPORT void SetFPS(int newval)
hosts one or more VariableBlocks keeping only one name for all of them
#define DATAINDEX_TICKTIME
DLLEXPORT void SetFPSAverage(int newval)
DLLEXPORT int GetFPSMax() const
DLLEXPORT void SetFPSMax(int newval)
DLLEXPORT int GetTicksBehind() const
DLLEXPORT int GetFPS() const
DLLEXPORT int GetFPSMin() const
DLLEXPORT void SetFontSizeMultiplier(int newval)
Non-template class for working with all types of DataBlocks.
#define DATAINDEX_TICKCOUNT
DLLEXPORT bool IsIndexValid(size_t index) const
DLLEXPORT int GetFrameTime() const
DLLEXPORT int GetTickTime() const
DLLEXPORT int GetFPSAverage() const
static const StringTypeN RemoveExtension(const StringTypeN &filepath, bool delpath=true)
DLLEXPORT int GetFrameTimeMin() const
static DLLEXPORT std::string GetPersistStorageFile()
DLLEXPORT int GetWidth() const
size_t Find(const std::string &name) const
Base class for all exceptions thrown by Leviathan.
DLLEXPORT void SetFrameTimeAverage(int newval)
#define DATAINDEX_FRAMETIME_AVERAGE
#define DATAINDEX_FPS_AVERAGE
DLLEXPORT int GetPersistance(unsigned int index) const
DLLEXPORT int GetFrameTimeMax() const
DLLEXPORT void SetFPSMin(int newval)
DLLEXPORT void SetFrameTimeMax(int newval)
#define DATAINDEX_FPS_MIN
static DLLEXPORT DataStore * Get()
DLLEXPORT void SetFrameTimeMin(int newval)
DLLEXPORT void SetHeight(int newval)
#define LEVIATHAN_ASSERT(x, msg)
static std::string ToString(const T &val)
DLLEXPORT bool SetValue(const std::string &name, const VariableBlock &value1)
DLLEXPORT void SetTicksBehind(int value)
DLLEXPORT bool GetValues(const std::string &name, std::vector< const VariableBlock * > &receiver) const
DataBlock< int > IntBlock
DLLEXPORT void SetPersistance(unsigned int index, bool toset)
DLLEXPORT void RegisterListener(AutoUpdateableObject *object, DataListener *listen)
static DLLEXPORT Logger * Get()
DLLEXPORT int GetGUiActive() const
DLLEXPORT void RemoveListener(AutoUpdateableObject *object, int valueid, const std::string &name="", bool all=false)
DLLEXPORT void Remove(size_t index)
DLLEXPORT void SetGUiActive(int newval)
#define DATAINDEX_FPS_MAX
#define DATAINDEX_FRAMETIME_MAX
DLLEXPORT int GetTickCount() const
static DLLEXPORT bool LoadDataDump(const std::string &file, std::vector< std::shared_ptr< NamedVariableList >> &vec, LErrorReporter *errorreport)
DLLEXPORT int GetValueFromValIndex(int valindex) const
DLLEXPORT void SetFrameTime(int newval)
DLLEXPORT int GetVariableType(const std::string &name) const
DLLEXPORT const VariableBlock * GetValue(const std::string &name) const
DLLEXPORT void SetTickTime(int newval)
DLLEXPORT size_t GetValueCount(const std::string &name) const
The access mask controls which registered functions and classes a script sees.
DLLEXPORT int GetVariableTypeOfAll(const std::string &name) const
DLLEXPORT void Error(const std::string &data) override
std::vector< DataListener * > HandledListeners
DLLEXPORT void AddVar(std::shared_ptr< NamedVariableList > values)
static DLLEXPORT bool WriteToFile(const std::string &data, const std::string &filename)
std::string GetName() const
DLLEXPORT void SetTickCount(int newval)
DLLEXPORT int GetFrameTimeAverage() const
virtual DLLEXPORT void PrintToLog() const noexcept
DLLEXPORT void SetWidth(int newval)