fixed main screen
This commit is contained in:
39
src/states/LoadingManager.cpp
Normal file
39
src/states/LoadingManager.cpp
Normal 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();
|
||||
}
|
||||
36
src/states/LoadingManager.h
Normal file
36
src/states/LoadingManager.h
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user