refactored some functions from main.cpp

This commit is contained in:
2025-12-19 18:16:17 +01:00
parent fe0cd289e2
commit adf418dff9
4 changed files with 129 additions and 288 deletions

31
src/app/TextureLoader.h Normal file
View File

@ -0,0 +1,31 @@
#pragma once
#include <SDL3/SDL.h>
#include <atomic>
#include <mutex>
#include <string>
#include <vector>
class TextureLoader {
public:
TextureLoader(
std::atomic<int>& loadedTasks,
std::string& currentLoadingFile,
std::mutex& currentLoadingMutex,
std::vector<std::string>& assetLoadErrors,
std::mutex& assetLoadErrorsMutex);
SDL_Texture* loadFromImage(SDL_Renderer* renderer, const std::string& path, int* outW = nullptr, int* outH = nullptr);
private:
std::atomic<int>& loadedTasks_;
std::string& currentLoadingFile_;
std::mutex& currentLoadingMutex_;
std::vector<std::string>& assetLoadErrors_;
std::mutex& assetLoadErrorsMutex_;
void setCurrentLoadingFile(const std::string& filename);
void clearCurrentLoadingFile();
void recordAssetLoadError(const std::string& message);
};