]> git.localhorst.tv Git - blank.git/blobdiff - src/app/UnloadState.cpp
split chunk stuff
[blank.git] / src / app / UnloadState.cpp
index 9da6989d128b5403e018daa4a4e39136fc695d8f..43aae056f27727ebc036e75d69dc044549dcec6f 100644 (file)
@@ -1,21 +1,24 @@
 #include "UnloadState.hpp"
 
 #include "Environment.hpp"
+#include "../io/WorldSave.hpp"
 #include "../world/ChunkLoader.hpp"
-#include "../world/WorldSave.hpp"
 
 
 namespace blank {
 
-UnloadState::UnloadState(Environment &env, ChunkLoader &loader)
+UnloadState::UnloadState(
+       Environment &env,
+       ChunkStore &chunks,
+       const WorldSave &save)
 : env(env)
-, loader(loader)
-, font(env.assets.LoadFont("DejaVuSans", 24))
-, progress(font)
-, cur(loader.Loaded().begin())
-, end(loader.Loaded().end())
+, chunks(chunks)
+, save(save)
+, progress(env.assets.large_ui_font)
+, cur(chunks.begin())
+, end(chunks.end())
 , done(0)
-, total(loader.Loaded().size())
+, total(chunks.NumLoaded())
 , per_update(64) {
        progress.Position(glm::vec3(0.0f), Gravity::CENTER);
        progress.Template("Unloading chunks: %d/%d (%d%%)");
@@ -23,10 +26,10 @@ UnloadState::UnloadState(Environment &env, ChunkLoader &loader)
 
 
 void UnloadState::OnResume() {
-       cur = loader.Loaded().begin();
-       end = loader.Loaded().end();
+       cur = chunks.begin();
+       end = chunks.end();
        done = 0;
-       total = loader.Loaded().size();
+       total = chunks.NumLoaded();
 }
 
 
@@ -37,7 +40,7 @@ void UnloadState::Handle(const SDL_Event &) {
 void UnloadState::Update(int dt) {
        for (std::size_t i = 0; i < per_update && cur != end; ++i, ++cur, ++done) {
                if (cur->ShouldUpdateSave()) {
-                       loader.SaveFile().Write(*cur);
+                       save.Write(*cur);
                }
        }
        if (cur == end) {