contentpack removal feature + refactor

This commit is contained in:
MihailRis
2024-03-11 13:21:06 +03:00
parent 3f0c710a47
commit daaba374a3
24 changed files with 345 additions and 295 deletions
+47 -61
View File
@@ -22,100 +22,86 @@ class ResPaths;
namespace fs = std::filesystem;
namespace gui {
class GUI;
class GUI;
}
class initialize_error : public std::runtime_error {
public:
initialize_error(const std::string& message) : std::runtime_error(message) {}
initialize_error(const std::string& message) : std::runtime_error(message) {}
};
class Engine {
std::unique_ptr<Assets> assets = nullptr;
std::shared_ptr<Screen> screen = nullptr;
std::unique_ptr<Assets> assets = nullptr;
std::shared_ptr<Screen> screen = nullptr;
std::vector<ContentPack> contentPacks;
EngineSettings& settings;
std::unique_ptr<Content> content = nullptr;
EnginePaths* paths;
EngineSettings& settings;
std::unique_ptr<Content> content = nullptr;
EnginePaths* paths;
std::unique_ptr<ResPaths> resPaths = nullptr;
uint64_t frame = 0;
double lastTime = 0.0;
double delta = 0.0;
uint64_t frame = 0;
double lastTime = 0.0;
double delta = 0.0;
std::unique_ptr<gui::GUI> gui;
std::unique_ptr<gui::GUI> gui;
void updateTimers();
void updateHotkeys();
void updateHotkeys();
public:
Engine(EngineSettings& settings, EnginePaths* paths);
~Engine();
Engine(EngineSettings& settings, EnginePaths* paths);
~Engine();
/// @brief Start main engine input/update/render loop.
/// Automatically sets MenuScreen
void mainloop();
/**
* Start main engine input/update/render loop
* Automatically sets MenuScreen
*/
void mainloop();
/**
* Set screen (scene).
* nullptr may be used to delete previous screen before creating new one
* example:
*
* engine->setScreen(nullptr);
* engine->setScreen(std::make_shared<...>(...));
*
* not-null value must be set before next frame
*/
/// @brief Set screen (scene).
/// nullptr may be used to delete previous screen before creating new one,
/// not-null value must be set before next frame
/// @param screen nullable screen
void setScreen(std::shared_ptr<Screen> screen);
/**
* Change locale to specified
* @param locale isolanguage_ISOCOUNTRY (example: en_US)
*/
void setLanguage(std::string locale);
/// @brief Change locale to specified
/// @param locale isolanguage_ISOCOUNTRY (example: en_US)
void setLanguage(std::string locale);
/**
* Load all selected content-packs and reload assets
*/
/// @brief Load all selected content-packs and reload assets
void loadContent();
/**
* Collect world content-packs and load content
* @see loadContent
* @param folder world folder
*/
/// @brief Collect world content-packs and load content
/// @see loadContent
/// @param folder world folder
void loadWorldContent(const fs::path& folder);
/**
* Collect all available content-packs from res/content
*/
void loadAllPacks();
/// @brief Collect all available content-packs from res/content
void loadAllPacks();
/** Get current frame delta-time */
/// @brief Get current frame delta-time
double getDelta() const;
/** Get active assets storage instance */
Assets* getAssets();
/// @brief Get active assets storage instance
Assets* getAssets();
/** Get main UI controller */
gui::GUI* getGUI();
/// @brief Get main UI controller
gui::GUI* getGUI();
/** Get writeable engine settings structure instance */
EngineSettings& getSettings();
/// @brief Get writeable engine settings structure instance
EngineSettings& getSettings();
/** Get engine filesystem paths source */
EnginePaths* getPaths();
/// @brief Get engine filesystem paths source
EnginePaths* getPaths();
/** Get engine resource paths controller */
/// @brief Get engine resource paths controller
ResPaths* getResPaths();
/** Get current Content instance */
const Content* getContent() const;
/// @brief Get current Content instance
const Content* getContent() const;
/** Get selected content packs */
/// @brief Get selected content packs
std::vector<ContentPack>& getContentPacks();
/** Get current screen */
/// @brief Get current screen
std::shared_ptr<Screen> getScreen();
};