1 #include "PreloadState.hpp"
3 #include "Environment.hpp"
4 #include "../world/ChunkLoader.hpp"
9 PreloadState::PreloadState(Environment &env, ChunkLoader &loader)
12 , progress(env.assets.large_ui_font)
13 , total(loader.ToLoad())
15 progress.Position(glm::vec3(0.0f), Gravity::CENTER);
16 progress.Template("Preloading chunks: %d/%d (%d%%)");
20 void PreloadState::Handle(const SDL_Event &e) {
21 if (e.type == SDL_QUIT) {
26 void PreloadState::Update(int dt) {
27 loader.LoadN(per_update);
28 if (loader.ToLoad() == 0) {
29 for (auto &chunk : loader.Loaded()) {
34 progress.Update(total - loader.ToLoad(), total);
38 void PreloadState::Render(Viewport &viewport) {
39 progress.Render(viewport);