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