]> git.localhorst.tv Git - blank.git/blobdiff - src/app/runtime.cpp
give feedback to stdout when profiling
[blank.git] / src / app / runtime.cpp
index 30b15aeb4b0d105b713255fbba892837481d45a7..d77cf47c228fbbdbc573f1e5e26f2473f2ab00ed 100644 (file)
@@ -1,14 +1,15 @@
 #include "Application.hpp"
 #include "Environment.hpp"
-#include "PreloadState.hpp"
 #include "Runtime.hpp"
 #include "WorldState.hpp"
 
 #include "init.hpp"
-#include "../world/WorldSave.hpp"
+#include "../io/filesystem.hpp"
+#include "../io/WorldSave.hpp"
 
 #include <cctype>
 #include <cstdlib>
+#include <fstream>
 #include <iostream>
 #include <SDL.h>
 
@@ -50,7 +51,9 @@ Environment::Environment(Window &win, const string &asset_path)
 , window(win)
 , assets(asset_path)
 , counter() {
-
+       viewport.Clear();
+       window.Flip();
+       keymap.LoadDefault();
 }
 
 
@@ -232,21 +235,28 @@ int Runtime::Execute() {
        Environment env(init.window, config.asset_path);
        env.viewport.VSync(config.vsync);
 
+       std::string keys_path = config.save_path + "keys.conf";
+       if (!is_file(keys_path)) {
+               std::ofstream file(keys_path);
+               env.keymap.Save(file);
+       } else {
+               std::ifstream file(keys_path);
+               env.keymap.Load(file);
+       }
+
+
        WorldSave save(config.save_path + config.world_name + '/');
        if (save.Exists()) {
                save.Read(config.world);
        } else {
-               save.Create(config.world);
+               save.Write(config.world);
        }
 
        Application app(env);
 
-       WorldState world_state(env, config.interface, config.world);
+       WorldState world_state(env, config.interface, config.world, save);
        app.PushState(&world_state);
 
-       PreloadState preloader(env, world_state.GetWorld().Loader());
-       app.PushState(&preloader);
-
        switch (mode) {
                default:
                case NORMAL: