From 64a6dbcfdb89a5f57d93d47a2be0c741dda4662d Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sun, 15 Aug 2021 09:17:02 -0700 Subject: Fix issues and cleanup - Fix compile error on MSVC where 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) --- core/src/Model/Assets.hpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'core/src/Model/Assets.hpp') 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 #include #include #include @@ -50,6 +51,9 @@ public: void Reload(); int GetCount() const; + // TODO convert to custom iterable + const tsl::array_map& GetAssets() const; + const SavedAsset* FindByName(std::string_view name) const; const SavedAsset& Create(SavedAsset asset); std::unique_ptr CreateAndLoad(SavedAsset asset); @@ -79,21 +83,22 @@ protected: void DiscoverFilesByExtension(const std::function& callback, const std::filesystem::path& containerDir, std::string_view extension) const; void DiscoverFilesByHeader(const std::function& callback, const std::filesystem::path& containerDir, const std::function& 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 @@ -102,6 +107,8 @@ class AssetListTyped : public AssetList public: using AssetList::AssetList; +#pragma clang diagnostic push +#pragma ide diagnostic ignored "HidingNonVirtualFunction" std::unique_ptr CreateAndLoad(SavedAsset asset) { return std::unique_ptr(static_cast(AssetList::CreateAndLoad(asset).release())); @@ -116,4 +123,5 @@ public: { return std::unique_ptr(static_cast(AssetList::Load(asset).release())); } +#pragma clang diagnostic pop }; -- cgit v1.2.3-70-g09d2