From a2607bffb1c0f8699021b1b4b3e54fa372e3ed0a Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sun, 3 Nov 2024 15:09:05 +0100 Subject: more WIP savemanager --- src/example/savemgr.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/example/savemgr.cpp') diff --git a/src/example/savemgr.cpp b/src/example/savemgr.cpp index 2c03e3a..6d011e5 100644 --- a/src/example/savemgr.cpp +++ b/src/example/savemgr.cpp @@ -7,23 +7,39 @@ #include #include #include +#include using namespace crepe; using namespace crepe::api; using namespace crepe::util; +// unrelated setup code +int _ = [] () { + // make sure all log messages get printed + auto & cfg = Config::get_instance(); + cfg.log.level = util::LogLevel::TRACE; + + return 0; // satisfy compiler +} (); + int main() { const char * key = "mygame.test"; SaveManager & mgr = SaveManager::get_instance(); - ValueBroker & prop = mgr.get(key, 0); - Proxy val = mgr.get(key, 0); + dbg_logf("has key = %s", mgr.has(key) ? "true" : "false"); + ValueBroker prop = mgr.get(key, 0); + Proxy val = mgr.get(key, 0); + dbg_logf("val = %d", mgr.get(key).get()); prop.set(1); + dbg_logf("val = %d", mgr.get(key).get()); val = 2; - mgr.set(key, 3); + dbg_logf("val = %d", mgr.get(key).get()); + mgr.set(key, 3); + dbg_logf("val = %d", mgr.get(key).get()); + dbg_logf("has key = %s", mgr.has(key) ? "true" : "false"); assert(true == mgr.has(key)); return 0; -- cgit v1.2.3