Editor assets switched to use UUIDs

master
Joey Pollack 3 years ago
parent 50f338c68a
commit fa6bf27183

@ -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) ✔ @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: Medium Importance:
✔ Console log output has extra vertical spacing between each line @done(22-11-02 18:15)
☐ Lines do not rotate correctly ☐ Lines do not rotate correctly
☐ Map Editor can be docked into the main window. The window IDs should prevent this. ☐ 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) ✔ Map Editor does not grab tile sets if the Map Editor is opened before a project is loaded @done(22-09-07 15:00)

@ -33,8 +33,8 @@ namespace lunarium
std::ostringstream oss; std::ostringstream oss;
oss << std::endl << Logger::TimeStamp() << Logger::GetCategoryName(message.LogCategory) oss << Logger::TimeStamp() << Logger::GetCategoryName(message.LogCategory)
<< Logger::GetLevelName(message.LogLevel) << message.Message << std::flush; << Logger::GetLevelName(message.LogLevel) << message.Message;
mpConsole->mMsgHistory.push_back(oss.str()); mpConsole->mMsgHistory.push_back(oss.str());
return true; return true;
@ -92,11 +92,12 @@ namespace lunarium
void Console::DoFrame() void Console::DoFrame()
{ {
//float history_height = ImGui::GetWindowSize().y - 45; //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); mIsFocused = ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows);
for (int i = 0; i < mMsgHistory.size(); i++) for (int i = 0; i < mMsgHistory.size(); i++)
{ {
if ((mMsgHistory[i].find("[GRAPHICS INTERNAL DEBUG]") != std::string::npos && !mbOglDebug) if ((mMsgHistory[i].find("[GRAPHICS INTERNAL DEBUG]") != std::string::npos && !mbOglDebug)
|| (mMsgHistory[i].find("[TRACE]") != std::string::npos && !mbInfoVerbose)) || (mMsgHistory[i].find("[TRACE]") != std::string::npos && !mbInfoVerbose))
{ {

@ -64,7 +64,7 @@ namespace lunarium
DataManager::GenerateFontFileAt(Font::F_ROBOTO, "robo.ttf"); DataManager::GenerateFontFileAt(Font::F_ROBOTO, "robo.ttf");
//io.Fonts->AddFontFromFileTTF("open.ttf", 16.0f); //io.Fonts->AddFontFromFileTTF("open.ttf", 16.0f);
mFonts[GuiFont::FONT_ROBO] = io.Fonts->AddFontFromFileTTF("robo.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); //io.Fonts->AddFontFromFileTTF("Karla-Regular.ttf", 16.0f);
// Setup Dear ImGui style // Setup Dear ImGui style

@ -16,6 +16,7 @@
#include <fstream> #include <fstream>
#include <utils/logger.h> #include <utils/logger.h>
#include <utils/uuid.h>
// Asset types // Asset types
#include "tile_set.h" #include "tile_set.h"
@ -26,7 +27,7 @@ namespace lunarium { namespace editor
ContentManager* ContentManager::mpInstance = nullptr; ContentManager* ContentManager::mpInstance = nullptr;
ContentManager::ContentManager() 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"); return OpRes::Fail("content_meta.json missing Project element");
} }
if (p["NextID"].is_null()) // if (p["NextID"].is_null())
{ // {
return OpRes::Fail("content_meta.xml missing NextID node"); // return OpRes::Fail("content_meta.xml missing NextID node");
} // }
mNextID = p["NextID"].get<u64>(); //mNextID = p["NextID"].get<u64>();
auto c = p["Contents"]; auto c = p["Contents"];
@ -175,7 +176,7 @@ namespace lunarium { namespace editor
// Save header info // Save header info
p["Name"] = mpProject->GetName(); p["Name"] = mpProject->GetName();
p["NextID"] = mNextID; //p["NextID"] = mNextID;
// Save all assets // Save all assets
auto& c = p["Contents"]; auto& c = p["Contents"];
@ -218,7 +219,7 @@ namespace lunarium { namespace editor
mpProject = nullptr; mpProject = nullptr;
FreeAssets(); FreeAssets();
mContentFile = ""; mContentFile = "";
mNextID = 0; //mNextID = 0;
} }
void ContentManager::GetAllAssetIDs(std::vector<uint64_t>& container) const void ContentManager::GetAllAssetIDs(std::vector<uint64_t>& container) const
@ -269,14 +270,15 @@ namespace lunarium { namespace editor
OpRes ContentManager::AddGeneratedAsset(EditorAsset* asset, uint64_t& id) OpRes ContentManager::AddGeneratedAsset(EditorAsset* asset, uint64_t& id)
{ {
if (mAssets.find(mNextID) != mAssets.end()) // if (mAssets.find(mNextID) != mAssets.end())
{ // {
return OpRes::Fail("Could not import asset, ID collision. ID: %llu", mNextID); // return OpRes::Fail("Could not import asset, ID collision. ID: %llu", mNextID);
} // }
asset->mAssetDir = mpProject->GetAssetDirectory(); asset->mAssetDir = mpProject->GetAssetDirectory();
asset->mID = mNextID; // asset->mID = mNextID;
mNextID++; asset->mID = UUID::GetNewID();
//mNextID++;
mAssets[asset->mID] = asset; mAssets[asset->mID] = asset;
id = asset->mID; 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) OpRes ContentManager::ImportFile(std::filesystem::path file, std::filesystem::path to_location, AssetType type, uint64_t& id)
{ {
if (mAssets.find(mNextID) != mAssets.end()) // if (mAssets.find(mNextID) != mAssets.end())
{ // {
return OpRes::Fail("Could not import asset, ID collision. ID: %llu", mNextID); // return OpRes::Fail("Could not import asset, ID collision. ID: %llu", mNextID);
} // }
if (std::filesystem::exists(to_location)) if (std::filesystem::exists(to_location))
{ {
@ -306,8 +308,9 @@ namespace lunarium { namespace editor
EditorAsset* pAsset = CreateAsset(type); EditorAsset* pAsset = CreateAsset(type);
pAsset->mAssetDir = mpProject->GetAssetDirectory(); pAsset->mAssetDir = mpProject->GetAssetDirectory();
pAsset->mID = mNextID; // pAsset->mID = mNextID;
mNextID++; pAsset->mID = UUID::GetNewID();
// mNextID++;
pAsset->mLocation = mpProject->MakeRelativeToAssets(to_location); pAsset->mLocation = mpProject->MakeRelativeToAssets(to_location);
if (Failed(pAsset->LoadRawFile().LogIfFailed(Editor::LogCat))) if (Failed(pAsset->LoadRawFile().LogIfFailed(Editor::LogCat)))
{ {

@ -62,7 +62,7 @@ namespace lunarium { namespace editor
Project* mpProject; Project* mpProject;
std::filesystem::path mContentFile; std::filesystem::path mContentFile;
std::map<uint64_t, EditorAsset*> mAssets; std::map<uint64_t, EditorAsset*> mAssets;
uint64_t mNextID; //uint64_t mNextID;
private: private:
ContentManager(); ContentManager();

@ -21,7 +21,7 @@ namespace lunarium { namespace editor {
return mType; return mType;
} }
uint64_t EditorAsset::GetID() LUUID EditorAsset::GetID()
{ {
return mID; return mID;
} }

@ -10,6 +10,7 @@
#define EDITOR_ASSETS_H_ #define EDITOR_ASSETS_H_
#include "definitions.h" #include "definitions.h"
#include <core/common_defs.h>
#include "content_manager.h" #include "content_manager.h"
#include <utils/op_res.h> #include <utils/op_res.h>
#include <assets/serializing/json_serializable.h> #include <assets/serializing/json_serializable.h>
@ -25,7 +26,7 @@ namespace lunarium { namespace editor
EditorAsset(AssetType type); EditorAsset(AssetType type);
AssetType GetType(); AssetType GetType();
uint64_t GetID(); LUUID GetID();
std::filesystem::path GetFileLocation(); std::filesystem::path GetFileLocation();
bool GetIsTrashed() const; bool GetIsTrashed() const;
@ -41,7 +42,7 @@ namespace lunarium { namespace editor
private: private:
friend class ContentManager; friend class ContentManager;
AssetType mType; AssetType mType;
uint64_t mID; LUUID mID;
bool mIsTrashed; bool mIsTrashed;
protected: protected:

@ -32,7 +32,7 @@ namespace lunarium { namespace editor
float child_height = ImGui::GetFrameHeight() * 1.75; float child_height = ImGui::GetFrameHeight() * 1.75;
ImGui::BeginChild("World View Toolbar", ImVec2(ImGui::GetContentRegionAvailWidth(), child_height), true); ImGui::BeginChild("World View Toolbar", ImVec2(ImGui::GetContentRegionAvailWidth(), child_height), true);
DoToolBar(); DoToolBar();
ImGui::EndChild(); ImGui::EndChild();;
ImGui::PushFont(Core::GUI().GetFont(GuiFont::FONT_ROBO_SMALL)); ImGui::PushFont(Core::GUI().GetFont(GuiFont::FONT_ROBO_SMALL));
//ImVec2 region = ImGui::GetContentRegionAvail(); //ImVec2 region = ImGui::GetContentRegionAvail();

Loading…
Cancel
Save