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)
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)

@ -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))
{

@ -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

@ -16,6 +16,7 @@
#include <fstream>
#include <utils/logger.h>
#include <utils/uuid.h>
// 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<u64>();
//mNextID = p["NextID"].get<u64>();
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<uint64_t>& 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)))
{

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

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

@ -10,6 +10,7 @@
#define EDITOR_ASSETS_H_
#include "definitions.h"
#include <core/common_defs.h>
#include "content_manager.h"
#include <utils/op_res.h>
#include <assets/serializing/json_serializable.h>
@ -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:

@ -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();

Loading…
Cancel
Save