![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
#include <DataManager.h>
Classes | |
| struct | LevelPreloadResult |
| struct | PreloadStats |
| struct | TilesetInfo |
Public Member Functions | |
| DataManager () | |
| virtual | ~DataManager () |
| void | Initialize () |
| void | Shutdown () |
| bool | PreloadTexture (const std::string &id, const std::string &path, ResourceCategory category=ResourceCategory::System) |
| bool | PreloadSprite (const std::string &id, const std::string &path, ResourceCategory category=ResourceCategory::GameEntity) |
| Sprite * | GetTexture (const std::string &id) const |
| Sprite * | GetSprite (const std::string &id, const std::string &path, ResourceCategory category=ResourceCategory::GameEntity) |
| bool | GetSprite_data (const std::string &id, const std::string &path, VisualSprite_data &outData) |
| bool | GetSpriteEditor_data (const std::string &id, const std::string &path, VisualEditor_data &outData) |
| bool | ReleaseResource (const std::string &id) |
| void | UnloadAll () |
| bool | HasResource (const std::string &id) const |
| std::vector< std::string > | ListResourcesByType (ResourceType type) const |
| std::vector< std::string > | ListResourcesByCategory (ResourceCategory category) const |
| bool | SaveJSONForObject (const std::string &videogameName, const std::string &objectName, const std::string &jsonContent) const |
| bool | LoadJSONForObject (const std::string &videogameName, const std::string &objectName, std::string &outJson) const |
| bool | SaveTextFile (const std::string &filepath, const std::string &content) const |
| bool | LoadTextFile (const std::string &filepath, std::string &outContent) const |
| bool | EnsureDirectoryExists (const std::string &dirpath) const |
| bool | PreloadSystemResources (const std::string &configFilePath) |
| PreloadStats | PreloadTextures (const std::vector< std::string > &paths, ResourceCategory category=ResourceCategory::Level, bool enableFallbackScan=true) |
| PreloadStats | PreloadSprites (const std::vector< std::string > &paths, ResourceCategory category=ResourceCategory::GameEntity, bool enableFallbackScan=true) |
| PreloadStats | PreloadAudioFiles (const std::vector< std::string > &paths, bool enableFallbackScan=true) |
| PreloadStats | PreloadTilesets (const std::vector< TilesetInfo > &tilesets, bool enableFallbackScan=true) |
| std::string | FindResourceRecursive (const std::string &filename, const std::string &rootDir="GameData") const |
| std::string | ResolveFilePath (const std::string &relativePath) const |
| std::vector< std::string > | GetBehaviorTreeFiles (const std::string &directory="./Gamedata") const |
| Lists all .bt.json behavior tree files in a directory. | |
| std::string | SelectBehaviorTreeFile (const std::string ¤tPath="") const |
| Opens a file browser dialog for selecting a behavior tree file. | |
| std::string | OpenFilePickerModal (Olympe::FilePickerType fileType, const std::string ¤tPath="") |
| Opens a centralized file picker modal for the specified file type. | |
| void | RenderFilePickerModal () |
| Renders the file picker modal if one is open. | |
| bool | IsFilePickerModalOpen () const |
| Checks if the file picker modal is currently visible. | |
| void | CloseFilePickerModal () |
| Closes the file picker modal without user selection. | |
| std::string | GetSelectedFileFromModal () const |
| Retrieves the selected file from the file picker modal. | |
| void | OpenSaveFilePickerModal (Olympe::SaveFileType fileType, const std::string &directory, const std::string &suggestedFilename="") |
| Opens the Save As file picker modal. | |
| void | RenderSaveFilePickerModal () |
| Renders the Save As file picker modal UI. | |
| bool | IsSaveFilePickerModalOpen () const |
| Checks if the Save As file picker modal is currently visible. | |
| void | CloseSaveFilePickerModal () |
| Closes the Save As file picker modal. | |
| std::string | GetSelectedSaveFile () const |
| Retrieves the selected file from the Save As modal. | |
Static Public Member Functions | |
| static DataManager & | GetInstance () |
| static DataManager & | Get () |
| static std::string | BuildGameDataPath (const std::string &videogameName, const std::string &objectName) |
Private Member Functions | |
| std::string | FindResourceRecursive_Unix (const std::string &filename, const std::string &rootDir) const |
Private Attributes | |
| std::string | name |
| std::mutex | m_mutex_ |
| std::unordered_map< std::string, std::shared_ptr< Resource > > | m_resources_ |
| bool | m_enableFallbackScan = true |
| std::unique_ptr< Olympe::FilePickerModal > | m_filePickerModal |
| std::unique_ptr< Olympe::SaveFilePickerModal > | m_saveFilePickerModal |
Definition at line 83 of file DataManager.h.
| DataManager::DataManager | ( | ) |
Definition at line 43 of file DataManager.cpp.
References name, and SYSTEM_LOG.
|
virtual |
Definition at line 49 of file DataManager.cpp.
References SYSTEM_LOG, and UnloadAll().
Here is the call graph for this function:
|
static |
Definition at line 301 of file DataManager.cpp.
References GetComponentTypeID_Static().
Referenced by LoadJSONForObject(), and SaveJSONForObject().
Here is the call graph for this function:
Here is the caller graph for this function:| void DataManager::CloseFilePickerModal | ( | ) |
Closes the file picker modal without user selection.
Definition at line 999 of file DataManager.cpp.
References m_filePickerModal.
| void DataManager::CloseSaveFilePickerModal | ( | ) |
Closes the Save As file picker modal.
Definition at line 1049 of file DataManager.cpp.
References m_saveFilePickerModal.
Definition at line 354 of file DataManager.cpp.
References GetComponentTypeID_Static(), and SYSTEM_LOG.
Referenced by SaveTextFile().
Here is the call graph for this function:
Here is the caller graph for this function:| std::string DataManager::FindResourceRecursive | ( | const std::string & | filename, |
| const std::string & | rootDir = "GameData" |
||
| ) | const |
Definition at line 689 of file DataManager.cpp.
References FindResourceRecursive_Unix(), and GetComponentTypeID_Static().
Referenced by World::InstantiatePass1_VisualLayers(), TilesetManager::LoadTilesets(), PreloadSprites(), PreloadTextures(), PreloadTilesets(), and ResolveFilePath().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 744 of file DataManager.cpp.
References FindResourceRecursive_Unix(), GetComponentTypeID_Static(), and name.
Referenced by FindResourceRecursive(), and FindResourceRecursive_Unix().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinestatic |
Definition at line 91 of file DataManager.h.
References GetInstance().
Referenced by World::CreateMissingPrefabPlaceholder(), OlympeEffectSystem::Initialize(), GameEngine::Initialize(), World::InstantiatePass1_VisualLayers(), PrefabFactory::InstantiateVisualEditor(), PrefabFactory::InstantiateVisualSprite(), World::LoadLevelFromTiled(), Olympe::AnimationEditorWindow::LoadSpritesheetTexture(), TilesetManager::LoadTilesets(), OlympeAnimation::AnimationBank::ParseJSON(), _Sprite::Preload(), Olympe::BehaviorTreeRenderer::Render(), Olympe::BTNodePropertyPanel::RenderSubGraphControls(), Olympe::VisualScriptRenderer::ResolvePath(), SDL_AppInit(), SDL_AppQuit(), _Sprite::SetSprite(), and AnimationSystem::UpdateEntity().
Here is the call graph for this function:
Here is the caller graph for this function:| std::vector< std::string > DataManager::GetBehaviorTreeFiles | ( | const std::string & | directory = "./Gamedata" | ) | const |
Lists all .bt.json behavior tree files in a directory.
| directory | Directory to search (e.g., "Gamedata/BehaviorTree") |
Definition at line 864 of file DataManager.cpp.
References GetComponentTypeID_Static(), and SYSTEM_LOG.
Referenced by SelectBehaviorTreeFile().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 56 of file DataManager.cpp.
References GetComponentTypeID_Static().
Referenced by Get(), and GameEngine::Initialize().
Here is the call graph for this function:
Here is the caller graph for this function:| std::string DataManager::GetSelectedFileFromModal | ( | ) | const |
Retrieves the selected file from the file picker modal.
Call this after IsFilePickerModalOpen() returns false to check if user selected a file.
Example usage: if (DataManager::Get().IsFilePickerModalOpen() == false && wasOpen) { std::string file = DataManager::Get().GetSelectedFileFromModal(); if (!file.empty()) { // Process selected file } }
Definition at line 1007 of file DataManager.cpp.
References m_filePickerModal.
Referenced by Olympe::BTNodePropertyPanel::RenderSubGraphControls().
Here is the caller graph for this function:| std::string DataManager::GetSelectedSaveFile | ( | ) | const |
Retrieves the selected file from the Save As modal.
Only valid after IsSaveFilePickerModalOpen() returns false and user confirmed.
Definition at line 1057 of file DataManager.cpp.
References m_saveFilePickerModal.
| Sprite * DataManager::GetSprite | ( | const std::string & | id, |
| const std::string & | path, | ||
| ResourceCategory | category = ResourceCategory::GameEntity |
||
| ) |
Definition at line 172 of file DataManager.cpp.
References GetComponentTypeID_Static(), GetTexture(), m_mutex_, m_resources_, and PreloadSprite().
Referenced by World::CreateMissingPrefabPlaceholder(), GetSprite_data(), GetSpriteEditor_data(), OlympeEffectSystem::Initialize(), PrefabFactory::InstantiateVisualEditor(), PrefabFactory::InstantiateVisualSprite(), Olympe::AnimationEditorWindow::LoadSpritesheetTexture(), and AnimationSystem::UpdateEntity().
Here is the call graph for this function:
Here is the caller graph for this function:| bool DataManager::GetSprite_data | ( | const std::string & | id, |
| const std::string & | path, | ||
| VisualSprite_data & | outData | ||
| ) |
Definition at line 191 of file DataManager.cpp.
References GameEntity, GetComponentTypeID_Static(), GetSprite(), and SYSTEM_LOG.
Here is the call graph for this function:| bool DataManager::GetSpriteEditor_data | ( | const std::string & | id, |
| const std::string & | path, | ||
| VisualEditor_data & | outData | ||
| ) |
Definition at line 207 of file DataManager.cpp.
References GameEntity, GetComponentTypeID_Static(), GetSprite(), and SYSTEM_LOG.
Here is the call graph for this function:| SDL_Texture * DataManager::GetTexture | ( | const std::string & | id | ) | const |
Definition at line 138 of file DataManager.cpp.
References GetComponentTypeID_Static(), m_mutex_, m_resources_, GameEngine::renderer, renderer, and SYSTEM_LOG.
Referenced by GetSprite(), and OlympeAnimation::AnimationBank::ParseJSON().
Here is the call graph for this function:
Here is the caller graph for this function:Definition at line 268 of file DataManager.cpp.
References GetComponentTypeID_Static(), m_mutex_, and m_resources_.
Here is the call graph for this function:| void DataManager::Initialize | ( | ) |
Definition at line 62 of file DataManager.cpp.
References SYSTEM_LOG.
Referenced by SDL_AppInit().
Here is the caller graph for this function:| bool DataManager::IsFilePickerModalOpen | ( | ) | const |
Checks if the file picker modal is currently visible.
Definition at line 991 of file DataManager.cpp.
References m_filePickerModal.
Referenced by Olympe::BTNodePropertyPanel::RenderSubGraphControls().
Here is the caller graph for this function:| bool DataManager::IsSaveFilePickerModalOpen | ( | ) | const |
Checks if the Save As file picker modal is currently visible.
Definition at line 1040 of file DataManager.cpp.
References m_saveFilePickerModal.
| std::vector< std::string > DataManager::ListResourcesByCategory | ( | ResourceCategory | category | ) | const |
Definition at line 287 of file DataManager.cpp.
References GetComponentTypeID_Static(), m_mutex_, and m_resources_.
Here is the call graph for this function:| std::vector< std::string > DataManager::ListResourcesByType | ( | ResourceType | type | ) | const |
Definition at line 274 of file DataManager.cpp.
References GetComponentTypeID_Static(), m_mutex_, and m_resources_.
Here is the call graph for this function:| bool DataManager::LoadJSONForObject | ( | const std::string & | videogameName, |
| const std::string & | objectName, | ||
| std::string & | outJson | ||
| ) | const |
Definition at line 348 of file DataManager.cpp.
References BuildGameDataPath(), GetComponentTypeID_Static(), and LoadTextFile().
Here is the call graph for this function:Definition at line 330 of file DataManager.cpp.
References GetComponentTypeID_Static().
Referenced by LoadJSONForObject(), and PreloadSystemResources().
Here is the call graph for this function:
Here is the caller graph for this function:| std::string DataManager::OpenFilePickerModal | ( | Olympe::FilePickerType | fileType, |
| const std::string & | currentPath = "" |
||
| ) |
Opens a centralized file picker modal for the specified file type.
| fileType | Type of files to browse (BehaviorTree, SubGraph, Audio, etc.) |
| currentPath | Optional current path to display initially |
This method manages a centralized modal dialog that supports multiple file types. Call this from UI elements that need file selection, then check the return value to see if user made a selection.
Example usage: std::string selected = DataManager::Get().OpenFilePickerModal( Olympe::FilePickerType::BehaviorTree, "./Gamedata" ); if (!selected.empty()) { // User selected a file nodeProperties["subgraphPath"] = selected; }
Definition at line 964 of file DataManager.cpp.
References GetComponentTypeID_Static(), m_filePickerModal, and SYSTEM_LOG.
Referenced by Olympe::BTNodePropertyPanel::RenderSubGraphControls().
Here is the call graph for this function:
Here is the caller graph for this function:| void DataManager::OpenSaveFilePickerModal | ( | Olympe::SaveFileType | fileType, |
| const std::string & | directory, | ||
| const std::string & | suggestedFilename = "" |
||
| ) |
Opens the Save As file picker modal.
| fileType | Type of file to save (BehaviorTree, Blueprint, etc.) |
| directory | Starting directory path |
| suggestedFilename | Suggested filename without extension |
Extension will be auto-appended based on file type. Call RenderSaveFilePickerModal() every frame. After modal closes, check IsSaveFilePickerModalOpen() and GetSelectedSaveFile().
Definition at line 1020 of file DataManager.cpp.
References GetComponentTypeID_Static(), m_saveFilePickerModal, and SYSTEM_LOG.
Here is the call graph for this function:| DataManager::PreloadStats DataManager::PreloadAudioFiles | ( | const std::vector< std::string > & | paths, |
| bool | enableFallbackScan = true |
||
| ) |
Definition at line 568 of file DataManager.cpp.
References DataManager::PreloadStats::completelyFailed, DataManager::PreloadStats::failedPaths, GetComponentTypeID_Static(), SYSTEM_LOG, and DataManager::PreloadStats::totalRequested.
Here is the call graph for this function:| bool DataManager::PreloadSprite | ( | const std::string & | id, |
| const std::string & | path, | ||
| ResourceCategory | category = ResourceCategory::GameEntity |
||
| ) |
Definition at line 133 of file DataManager.cpp.
References PreloadTexture().
Referenced by GetSprite(), _Sprite::Preload(), PreloadSprites(), and PreloadSystemResources().
Here is the call graph for this function:
Here is the caller graph for this function:| DataManager::PreloadStats DataManager::PreloadSprites | ( | const std::vector< std::string > & | paths, |
| ResourceCategory | category = ResourceCategory::GameEntity, |
||
| bool | enableFallbackScan = true |
||
| ) |
Definition at line 512 of file DataManager.cpp.
References DataManager::PreloadStats::completelyFailed, DataManager::PreloadStats::failedPaths, DataManager::PreloadStats::failedWithFallback, DataManager::PreloadStats::fallbackPaths, FindResourceRecursive(), GetComponentTypeID_Static(), m_enableFallbackScan, PreloadSprite(), DataManager::PreloadStats::successfullyLoaded, SYSTEM_LOG, and DataManager::PreloadStats::totalRequested.
Here is the call graph for this function:Definition at line 405 of file DataManager.cpp.
References GameEntity, GetComponentTypeID_Static(), Level, LoadTextFile(), PreloadSprite(), PreloadTexture(), System, and SYSTEM_LOG.
Referenced by GameEngine::Initialize().
Here is the call graph for this function:
Here is the caller graph for this function:| bool DataManager::PreloadTexture | ( | const std::string & | id, |
| const std::string & | path, | ||
| ResourceCategory | category = ResourceCategory::System |
||
| ) |
Definition at line 74 of file DataManager.cpp.
References GetComponentTypeID_Static(), m_mutex_, m_resources_, GameEngine::renderer, renderer, SYSTEM_LOG, and Texture.
Referenced by OlympeAnimation::AnimationBank::ParseJSON(), PreloadSprite(), PreloadSystemResources(), PreloadTextures(), and PreloadTilesets().
Here is the call graph for this function:
Here is the caller graph for this function:| DataManager::PreloadStats DataManager::PreloadTextures | ( | const std::vector< std::string > & | paths, |
| ResourceCategory | category = ResourceCategory::Level, |
||
| bool | enableFallbackScan = true |
||
| ) |
Definition at line 456 of file DataManager.cpp.
References DataManager::PreloadStats::completelyFailed, DataManager::PreloadStats::failedPaths, DataManager::PreloadStats::failedWithFallback, DataManager::PreloadStats::fallbackPaths, FindResourceRecursive(), GetComponentTypeID_Static(), m_enableFallbackScan, PreloadTexture(), DataManager::PreloadStats::successfullyLoaded, SYSTEM_LOG, and DataManager::PreloadStats::totalRequested.
Here is the call graph for this function:| DataManager::PreloadStats DataManager::PreloadTilesets | ( | const std::vector< TilesetInfo > & | tilesets, |
| bool | enableFallbackScan = true |
||
| ) |
Definition at line 587 of file DataManager.cpp.
References DataManager::PreloadStats::completelyFailed, DataManager::PreloadStats::failedPaths, DataManager::PreloadStats::failedWithFallback, DataManager::PreloadStats::fallbackPaths, FindResourceRecursive(), GetComponentTypeID_Static(), Level, m_enableFallbackScan, PreloadTexture(), DataManager::PreloadStats::successfullyLoaded, SYSTEM_LOG, and DataManager::PreloadStats::totalRequested.
Here is the call graph for this function:Definition at line 222 of file DataManager.cpp.
References GetComponentTypeID_Static(), m_mutex_, m_resources_, and SYSTEM_LOG.
Here is the call graph for this function:| void DataManager::RenderFilePickerModal | ( | ) |
Renders the file picker modal if one is open.
Call this every frame within the main ImGui rendering loop to display the modal UI. This is automatically called by the editor UI systems that integrate with DataManager.
Definition at line 983 of file DataManager.cpp.
References m_filePickerModal.
Referenced by Olympe::BehaviorTreeRenderer::Render().
Here is the caller graph for this function:| void DataManager::RenderSaveFilePickerModal | ( | ) |
Renders the Save As file picker modal UI.
Must be called every frame during the main ImGui rendering loop.
Definition at line 1032 of file DataManager.cpp.
References m_saveFilePickerModal.
| std::string DataManager::ResolveFilePath | ( | const std::string & | relativePath | ) | const |
Definition at line 793 of file DataManager.cpp.
References FindResourceRecursive(), GetComponentTypeID_Static(), and SYSTEM_LOG.
Referenced by Olympe::VisualScriptRenderer::ResolvePath().
Here is the call graph for this function:
Here is the caller graph for this function:| bool DataManager::SaveJSONForObject | ( | const std::string & | videogameName, |
| const std::string & | objectName, | ||
| const std::string & | jsonContent | ||
| ) | const |
Definition at line 342 of file DataManager.cpp.
References BuildGameDataPath(), GetComponentTypeID_Static(), and SaveTextFile().
Here is the call graph for this function:Definition at line 309 of file DataManager.cpp.
References EnsureDirectoryExists(), GetComponentTypeID_Static(), and SYSTEM_LOG.
Referenced by SaveJSONForObject().
Here is the call graph for this function:
Here is the caller graph for this function:| std::string DataManager::SelectBehaviorTreeFile | ( | const std::string & | currentPath = "" | ) | const |
Opens a file browser dialog for selecting a behavior tree file.
| currentPath | Optional current path to display initially |
This is a framework-level service providing reusable file browsing for SubGraph node path selection and other file operations.
Definition at line 921 of file DataManager.cpp.
References GetBehaviorTreeFiles(), GetComponentTypeID_Static(), and SYSTEM_LOG.
Here is the call graph for this function:| void DataManager::Shutdown | ( | ) |
Definition at line 68 of file DataManager.cpp.
References SYSTEM_LOG, and UnloadAll().
Referenced by SDL_AppQuit().
Here is the call graph for this function:
Here is the caller graph for this function:| void DataManager::UnloadAll | ( | ) |
Definition at line 247 of file DataManager.cpp.
References GetComponentTypeID_Static(), m_mutex_, and m_resources_.
Referenced by Shutdown(), and ~DataManager().
Here is the call graph for this function:
Here is the caller graph for this function:Definition at line 353 of file DataManager.h.
Referenced by PreloadSprites(), PreloadTextures(), and PreloadTilesets().
|
private |
Definition at line 356 of file DataManager.h.
Referenced by CloseFilePickerModal(), GetSelectedFileFromModal(), IsFilePickerModalOpen(), OpenFilePickerModal(), and RenderFilePickerModal().
|
mutableprivate |
Definition at line 351 of file DataManager.h.
Referenced by GetSprite(), GetTexture(), HasResource(), ListResourcesByCategory(), ListResourcesByType(), PreloadTexture(), ReleaseResource(), and UnloadAll().
|
private |
Definition at line 352 of file DataManager.h.
Referenced by GetSprite(), GetTexture(), HasResource(), ListResourcesByCategory(), ListResourcesByType(), PreloadTexture(), ReleaseResource(), and UnloadAll().
|
private |
Definition at line 357 of file DataManager.h.
Referenced by CloseSaveFilePickerModal(), GetSelectedSaveFile(), IsSaveFilePickerModalOpen(), OpenSaveFilePickerModal(), and RenderSaveFilePickerModal().
|
private |
Definition at line 350 of file DataManager.h.
Referenced by DataManager(), and FindResourceRecursive_Unix().