fixed main screen

This commit is contained in:
2025-12-17 18:13:59 +01:00
parent 3264672be0
commit cecf5cf68e
6 changed files with 479 additions and 147 deletions

View File

@ -0,0 +1,39 @@
#include "states/LoadingManager.h"
#include "app/AssetLoader.h"
LoadingManager::LoadingManager(AssetLoader* loader)
: m_loader(loader)
{
}
void LoadingManager::queueTexture(const std::string& path) {
if (!m_loader) return;
m_loader->queueTexture(path);
}
void LoadingManager::start() {
m_started = true;
}
bool LoadingManager::update() {
if (!m_loader) return true;
// perform a single step on the loader; AssetLoader::performStep returns true when
// there are no more queued tasks.
bool done = m_loader->performStep();
return done;
}
float LoadingManager::getProgress() const {
if (!m_loader) return 1.0f;
return m_loader->getProgress();
}
std::vector<std::string> LoadingManager::getAndClearErrors() {
if (!m_loader) return {};
return m_loader->getAndClearErrors();
}
std::string LoadingManager::getCurrentLoading() const {
if (!m_loader) return {};
return m_loader->getCurrentLoading();
}

View File

@ -0,0 +1,36 @@
#pragma once
#include <string>
#include <vector>
#include <memory>
class AssetLoader;
// LoadingManager: thin facade over AssetLoader for incremental loading.
// Main thread only. Call update() once per frame to perform a single step.
class LoadingManager {
public:
explicit LoadingManager(AssetLoader* loader);
// Queue a texture path (relative to base path) for loading.
void queueTexture(const std::string& path);
// Start loading (idempotent).
void start();
// Perform a single loading step. Returns true when loading complete.
bool update();
// Progress in [0,1]
float getProgress() const;
// Return and clear any accumulated loading errors.
std::vector<std::string> getAndClearErrors();
// Current path being loaded (or empty)
std::string getCurrentLoading() const;
private:
AssetLoader* m_loader = nullptr;
bool m_started = false;
};