1 #include "PreloadState.hpp"
3 #include "../app/Environment.hpp"
4 #include "../world/ChunkLoader.hpp"
5 #include "../world/ChunkRenderer.hpp"
11 PreloadState::PreloadState(Environment &env, ChunkLoader &loader, ChunkRenderer &render)
15 , progress(env.assets.large_ui_font)
16 , total(loader.ToLoad())
18 progress.Position(glm::vec3(0.0f), Gravity::CENTER);
19 progress.Template("Preloading chunks: %d/%d (%d%%)");
23 void PreloadState::Handle(const SDL_Event &e) {
24 if (e.type == SDL_QUIT) {
29 void PreloadState::Update(int dt) {
30 loader.LoadN(per_update);
31 if (loader.ToLoad() <= 0) {
33 render.Update(render.MissingChunks());
35 progress.Update(total - loader.ToLoad(), total);
39 void PreloadState::Render(Viewport &viewport) {
40 progress.Render(viewport);