Working on loading screen
This commit is contained in:
1 parent
1c2c80f0ea
commit
44f5136f1d
8 files changed
+272
-187
No files matched your search
+23
-2
@@ -10,6 +10,7 @@
|
||||
#include "items/Item.h"
|
||||
#include "items/InteractiveObject.h"
|
||||
#include <queue>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
@@ -49,6 +50,22 @@ namespace ZL {
|
||||
VertexRenderStruct loadingMesh;
|
||||
bool loadingCompleted = false;
|
||||
|
||||
// setupPart2() populates this queue with one closure per loading step instead of
|
||||
// running the work itself; Game::update() drains one step per frame so the window
|
||||
// keeps pumping events / repainting (and, on Emscripten, the browser keeps the tab
|
||||
// responsive) instead of freezing for the whole duration of loading.
|
||||
std::queue<std::function<void()>> loadSteps;
|
||||
size_t loadStepsTotal = 0;
|
||||
size_t loadStepsDone = 0;
|
||||
float currentLoadingProgress() const {
|
||||
return loadStepsTotal ? (float)loadStepsDone / (float)loadStepsTotal : resourcesDownloadProgress;
|
||||
}
|
||||
|
||||
// The progress bar only reflects the initial resource load (its steps are
|
||||
// pre-counted upfront). Later loadSteps runs, like MenuManager's localized
|
||||
// content reload, don't have a meaningful denominator, so the bar is hidden.
|
||||
bool showLoadingProgressBar = true;
|
||||
|
||||
GameState gameState;
|
||||
|
||||
EditorMode editorMode = EditorMode::None;
|
||||
@@ -138,8 +155,13 @@ namespace ZL {
|
||||
static void onResourcesZipLoaded(unsigned handle, void* userData, const char* filename);
|
||||
static void onResourcesZipError(unsigned handle, void* userData, int httpStatus);
|
||||
static void onResourcesZipProgress(unsigned handle, void* userData, int percentComplete);
|
||||
|
||||
#endif
|
||||
// Only meaningful during the Emscripten zip-download phase, before loadSteps
|
||||
// exists (see currentLoadingProgress() above); harmless/unused on other platforms.
|
||||
float resourcesDownloadProgress = 0.0f;
|
||||
|
||||
// Progress bar assets/meshes, loaded and drawn on every platform so setupPart2's
|
||||
// step-by-step progress is visible during desktop/Android loading too.
|
||||
std::shared_ptr<Texture> loadingProgressBarTexture;
|
||||
std::shared_ptr<Texture> loadingProgressBarFrameTexture;
|
||||
VertexRenderStruct loadingProgressBarFrameMesh;
|
||||
@@ -147,7 +169,6 @@ namespace ZL {
|
||||
float loadingBarLastRenderedProgress = -1.0f;
|
||||
float loadingBarLastW = -1.0f;
|
||||
float loadingBarLastH = -1.0f;
|
||||
#endif
|
||||
|
||||
// Screen-flash transition state (shared by darklands and night transitions)
|
||||
float darklandsFlashAlpha = 0.0f;
|
||||
|
||||
Reference in new issue
Block a user