From fa6bf27183a0a40f2ce12625973d3f3f5c237e79 Mon Sep 17 00:00:00 2001 From: Joey Pollack Date: Wed, 2 Nov 2022 18:16:13 -0400 Subject: [PATCH] Editor assets switched to use UUIDs --- docs/tasks/Bugs.todo | 1 + src/gui/console.cpp | 7 +-- src/gui/gui.cpp | 2 +- .../editor/contents/content_manager.cpp | 43 ++++++++++--------- .../editor/contents/content_manager.h | 2 +- .../editor/contents/editor_asset.cpp | 2 +- src/run_modes/editor/contents/editor_asset.h | 5 ++- .../editor/panels/editor_console.cpp | 2 +- 8 files changed, 35 insertions(+), 29 deletions(-) diff --git a/docs/tasks/Bugs.todo b/docs/tasks/Bugs.todo index e498a54..329daed 100644 --- a/docs/tasks/Bugs.todo +++ b/docs/tasks/Bugs.todo @@ -12,6 +12,7 @@ High Importance: ✔ @high Editor asset file paths are saved as absolute paths. They need to be relative to the project root. @done(22-03-18 20:41) Medium Importance: + ✔ Console log output has extra vertical spacing between each line @done(22-11-02 18:15) ☐ Lines do not rotate correctly ☐ Map Editor can be docked into the main window. The window IDs should prevent this. ✔ Map Editor does not grab tile sets if the Map Editor is opened before a project is loaded @done(22-09-07 15:00) diff --git a/src/gui/console.cpp b/src/gui/console.cpp index b2c3491..0c87762 100644 --- a/src/gui/console.cpp +++ b/src/gui/console.cpp @@ -33,8 +33,8 @@ namespace lunarium std::ostringstream oss; - oss << std::endl << Logger::TimeStamp() << Logger::GetCategoryName(message.LogCategory) - << Logger::GetLevelName(message.LogLevel) << message.Message << std::flush; + oss << Logger::TimeStamp() << Logger::GetCategoryName(message.LogCategory) + << Logger::GetLevelName(message.LogLevel) << message.Message; mpConsole->mMsgHistory.push_back(oss.str()); return true; @@ -92,11 +92,12 @@ namespace lunarium void Console::DoFrame() { //float history_height = ImGui::GetWindowSize().y - 45; - ImGui::BeginChild("history", ImVec2(ImGui::GetContentRegionAvailWidth(), ImGui::GetContentRegionAvail().y - (GetInputWindowHeight() + 5))); + ImGui::BeginChild("history", ImVec2(ImGui::GetContentRegionAvailWidth(), ImGui::GetContentRegionAvail().y - (GetInputWindowHeight() + 10))); mIsFocused = ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows); for (int i = 0; i < mMsgHistory.size(); i++) { + if ((mMsgHistory[i].find("[GRAPHICS INTERNAL DEBUG]") != std::string::npos && !mbOglDebug) || (mMsgHistory[i].find("[TRACE]") != std::string::npos && !mbInfoVerbose)) { diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 759e865..23a647c 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -64,7 +64,7 @@ namespace lunarium DataManager::GenerateFontFileAt(Font::F_ROBOTO, "robo.ttf"); //io.Fonts->AddFontFromFileTTF("open.ttf", 16.0f); mFonts[GuiFont::FONT_ROBO] = io.Fonts->AddFontFromFileTTF("robo.ttf", 16.0f); - mFonts[GuiFont::FONT_ROBO_SMALL] = io.Fonts->AddFontFromFileTTF("robo.ttf", 12.0f); + mFonts[GuiFont::FONT_ROBO_SMALL] = io.Fonts->AddFontFromFileTTF("robo.ttf", 13.0f); //io.Fonts->AddFontFromFileTTF("Karla-Regular.ttf", 16.0f); // Setup Dear ImGui style diff --git a/src/run_modes/editor/contents/content_manager.cpp b/src/run_modes/editor/contents/content_manager.cpp index 5abd99d..8fe205d 100644 --- a/src/run_modes/editor/contents/content_manager.cpp +++ b/src/run_modes/editor/contents/content_manager.cpp @@ -16,6 +16,7 @@ #include #include +#include // Asset types #include "tile_set.h" @@ -26,7 +27,7 @@ namespace lunarium { namespace editor ContentManager* ContentManager::mpInstance = nullptr; ContentManager::ContentManager() - : mpProject(nullptr), mNextID(0), mpEditor(nullptr) + : mpProject(nullptr), mpEditor(nullptr) { } @@ -87,12 +88,12 @@ namespace lunarium { namespace editor return OpRes::Fail("content_meta.json missing Project element"); } - if (p["NextID"].is_null()) - { - return OpRes::Fail("content_meta.xml missing NextID node"); - } + // if (p["NextID"].is_null()) + // { + // return OpRes::Fail("content_meta.xml missing NextID node"); + // } - mNextID = p["NextID"].get(); + //mNextID = p["NextID"].get(); auto c = p["Contents"]; @@ -175,7 +176,7 @@ namespace lunarium { namespace editor // Save header info p["Name"] = mpProject->GetName(); - p["NextID"] = mNextID; + //p["NextID"] = mNextID; // Save all assets auto& c = p["Contents"]; @@ -218,7 +219,7 @@ namespace lunarium { namespace editor mpProject = nullptr; FreeAssets(); mContentFile = ""; - mNextID = 0; + //mNextID = 0; } void ContentManager::GetAllAssetIDs(std::vector& container) const @@ -269,14 +270,15 @@ namespace lunarium { namespace editor OpRes ContentManager::AddGeneratedAsset(EditorAsset* asset, uint64_t& id) { - if (mAssets.find(mNextID) != mAssets.end()) - { - return OpRes::Fail("Could not import asset, ID collision. ID: %llu", mNextID); - } + // if (mAssets.find(mNextID) != mAssets.end()) + // { + // return OpRes::Fail("Could not import asset, ID collision. ID: %llu", mNextID); + // } asset->mAssetDir = mpProject->GetAssetDirectory(); - asset->mID = mNextID; - mNextID++; + // asset->mID = mNextID; + asset->mID = UUID::GetNewID(); + //mNextID++; mAssets[asset->mID] = asset; id = asset->mID; @@ -287,10 +289,10 @@ namespace lunarium { namespace editor OpRes ContentManager::ImportFile(std::filesystem::path file, std::filesystem::path to_location, AssetType type, uint64_t& id) { - if (mAssets.find(mNextID) != mAssets.end()) - { - return OpRes::Fail("Could not import asset, ID collision. ID: %llu", mNextID); - } + // if (mAssets.find(mNextID) != mAssets.end()) + // { + // return OpRes::Fail("Could not import asset, ID collision. ID: %llu", mNextID); + // } if (std::filesystem::exists(to_location)) { @@ -306,8 +308,9 @@ namespace lunarium { namespace editor EditorAsset* pAsset = CreateAsset(type); pAsset->mAssetDir = mpProject->GetAssetDirectory(); - pAsset->mID = mNextID; - mNextID++; + // pAsset->mID = mNextID; + pAsset->mID = UUID::GetNewID(); + // mNextID++; pAsset->mLocation = mpProject->MakeRelativeToAssets(to_location); if (Failed(pAsset->LoadRawFile().LogIfFailed(Editor::LogCat))) { diff --git a/src/run_modes/editor/contents/content_manager.h b/src/run_modes/editor/contents/content_manager.h index c6b73a1..6ae9e0e 100644 --- a/src/run_modes/editor/contents/content_manager.h +++ b/src/run_modes/editor/contents/content_manager.h @@ -62,7 +62,7 @@ namespace lunarium { namespace editor Project* mpProject; std::filesystem::path mContentFile; std::map mAssets; - uint64_t mNextID; + //uint64_t mNextID; private: ContentManager(); diff --git a/src/run_modes/editor/contents/editor_asset.cpp b/src/run_modes/editor/contents/editor_asset.cpp index e6d8c9b..40fabfa 100644 --- a/src/run_modes/editor/contents/editor_asset.cpp +++ b/src/run_modes/editor/contents/editor_asset.cpp @@ -21,7 +21,7 @@ namespace lunarium { namespace editor { return mType; } - uint64_t EditorAsset::GetID() + LUUID EditorAsset::GetID() { return mID; } diff --git a/src/run_modes/editor/contents/editor_asset.h b/src/run_modes/editor/contents/editor_asset.h index 2e00e4d..26adb42 100644 --- a/src/run_modes/editor/contents/editor_asset.h +++ b/src/run_modes/editor/contents/editor_asset.h @@ -10,6 +10,7 @@ #define EDITOR_ASSETS_H_ #include "definitions.h" +#include #include "content_manager.h" #include #include @@ -25,7 +26,7 @@ namespace lunarium { namespace editor EditorAsset(AssetType type); AssetType GetType(); - uint64_t GetID(); + LUUID GetID(); std::filesystem::path GetFileLocation(); bool GetIsTrashed() const; @@ -41,7 +42,7 @@ namespace lunarium { namespace editor private: friend class ContentManager; AssetType mType; - uint64_t mID; + LUUID mID; bool mIsTrashed; protected: diff --git a/src/run_modes/editor/panels/editor_console.cpp b/src/run_modes/editor/panels/editor_console.cpp index 1606096..b39afbd 100644 --- a/src/run_modes/editor/panels/editor_console.cpp +++ b/src/run_modes/editor/panels/editor_console.cpp @@ -32,7 +32,7 @@ namespace lunarium { namespace editor float child_height = ImGui::GetFrameHeight() * 1.75; ImGui::BeginChild("World View Toolbar", ImVec2(ImGui::GetContentRegionAvailWidth(), child_height), true); DoToolBar(); - ImGui::EndChild(); + ImGui::EndChild();; ImGui::PushFont(Core::GUI().GetFont(GuiFont::FONT_ROBO_SMALL)); //ImVec2 region = ImGui::GetContentRegionAvail();