diff options
author | rtk0c <[email protected]> | 2021-08-15 09:17:02 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2021-08-15 09:17:02 -0700 |
commit | 64a6dbcfdb89a5f57d93d47a2be0c741dda4662d (patch) | |
tree | 241eaba2351f3a7e6343ce93532e19a4b93757d3 /core/src/Model/Assets.hpp | |
parent | f0326e5c5deca0fb719d8522b45c59364b566300 (diff) |
Fix issues and cleanup
- Fix compile error on MSVC where <vector> is not included properly
- Fix creating a workflow actually saves to the templates/ directory
- Fix renaming assets are not saved to disk
- TODO ser/deser still not working
- Cleanup AssetList::* pure virtual setup (fewer splits)
Diffstat (limited to 'core/src/Model/Assets.hpp')
-rw-r--r-- | core/src/Model/Assets.hpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/core/src/Model/Assets.hpp b/core/src/Model/Assets.hpp index 9fd781f..0a050d6 100644 --- a/core/src/Model/Assets.hpp +++ b/core/src/Model/Assets.hpp @@ -3,6 +3,7 @@ #include "Utils/UUID.hpp" #include "cplt_fwd.hpp" +#include <tsl/array_map.h> #include <filesystem> #include <iosfwd> #include <memory> @@ -50,6 +51,9 @@ public: void Reload(); int GetCount() const; + // TODO convert to custom iterable + const tsl::array_map<char, SavedAsset>& GetAssets() const; + const SavedAsset* FindByName(std::string_view name) const; const SavedAsset& Create(SavedAsset asset); std::unique_ptr<Asset> CreateAndLoad(SavedAsset asset); @@ -79,21 +83,22 @@ protected: void DiscoverFilesByExtension(const std::function<void(SavedAsset)>& callback, const std::filesystem::path& containerDir, std::string_view extension) const; void DiscoverFilesByHeader(const std::function<void(SavedAsset)>& callback, const std::filesystem::path& containerDir, const std::function<bool(std::istream&)>& validater) const; - virtual void SaveEmptyInstance(const SavedAsset& asset) const = 0; - virtual Asset* CreateEmptyInstance(const SavedAsset& asset) const = 0; - - virtual Asset* LoadImpl(const SavedAsset& asset) const = 0; + /// Create an empty/default instance of this asset type on disk, potentially qualified by SavedAsset::Payload. + /// Return `true` on success and `false` on failure. + virtual bool SaveInstance(const SavedAsset& assetInfo, const Asset* asset) const = 0; + /// The returned pointer indicate ownership to the object. + virtual Asset* LoadInstance(const SavedAsset& assetInfo) const = 0; + /// Create an empty/default instance of this asset type, potentially qualified by SavedAsset::Payload. + /// The returned pointer indicate ownership to the object. + virtual Asset* CreateInstance(const SavedAsset& assetInfo) const = 0; + virtual bool RenameInstanceOnDisk(const SavedAsset& assetInfo, std::string_view oldName) const = 0; virtual std::string RetrieveNameFromFile(const std::filesystem::path& file) const = 0; virtual uuids::uuid RetrieveUuidFromFile(const std::filesystem::path& file) const = 0; virtual std::filesystem::path RetrievePathFromAsset(const SavedAsset& asset) const = 0; virtual void DisplayAssetCreator(ListState& state) = 0; - - /// This should call ImGui::BeginTable() along with other accessories such as setting up the header row. - virtual void SetupDetailsTable(const char* tableId) const = 0; - virtual void DrawBigIcon(ListState& state, const SavedAsset& asset) const = 0; - virtual void DrawDetailsTableRow(ListState& state, const SavedAsset& asset) const = 0; + virtual void DisplayDetailsTable(ListState& state) const = 0; }; template <class T> @@ -102,6 +107,8 @@ class AssetListTyped : public AssetList public: using AssetList::AssetList; +#pragma clang diagnostic push +#pragma ide diagnostic ignored "HidingNonVirtualFunction" std::unique_ptr<T> CreateAndLoad(SavedAsset asset) { return std::unique_ptr<T>(static_cast<T*>(AssetList::CreateAndLoad(asset).release())); @@ -116,4 +123,5 @@ public: { return std::unique_ptr<T>(static_cast<T*>(AssetList::Load(asset).release())); } +#pragma clang diagnostic pop }; |