Editor Assets are included when a project is saved and loaded

Gui_Panel_Refactor
Joeyrp 4 years ago
parent 6d85356368
commit 60bb47f25e

@ -0,0 +1,3 @@
High Importance:
☐ The Map Editor does not get the tile maps when a project is opened @high

@ -69,6 +69,8 @@ namespace editor
void Editor::Shutdown()
{
DataManager::Shutdown();
mPanelManager.Shutdown();
}
@ -218,10 +220,10 @@ namespace editor
Logger::Log(LogCat, LogLevel::INFO, "Opening project: %s", mpPath->string().c_str());
// Open project at mpPath
OpRes result = mProject.LoadProject(*mpPath);
if (Failed(result))
if (Failed(mProject.LoadProject(*mpPath).LogIfFailed(Editor::LogCat)))
{
Logger::Log(LogCat, LogLevel::ERROR, "Could not open project: %s -- reason: %s", mpPath->string().c_str(), result.Description);
mDoOpenProject = false;
return;
}
((AssetBrowser*)mPanelManager.GetPanel(PanelType::PT_ASSET_BROWSER))->SetAssetDirectory(mpPath->parent_path() / std::filesystem::path("contents/assets"));
mDoOpenProject = false;
@ -243,7 +245,7 @@ namespace editor
}
else
{
//mProject.SaveProject();
mProject.SaveProject();
mDoSaveProject = false;
}
}

@ -96,15 +96,15 @@ namespace lunarium { namespace editor
mNextID = ID.attribute("ID").as_ullong();
pugi::xml_node content = proj_node.child("Content");
pugi::xml_node contents = proj_node.child("Contents");
if (!content)
if (!contents)
{
return OpRes::Fail("content_meta.xml missing Content node");
return OpRes::Fail("content_meta.xml missing Contents node");
}
// Iterate through content
for (pugi::xml_node asset = content.child("Asset"); asset; asset = asset.next_sibling("Asset"))
for (pugi::xml_node asset = contents.child("Asset"); asset; asset = asset.next_sibling("Asset"))
{
if (!IsValidAsset(asset))
{
@ -134,7 +134,7 @@ namespace lunarium { namespace editor
}
// Store asset
if (mAssets.find(pAsset->mID) == mAssets.end())
if (mAssets.find(pAsset->mID) != mAssets.end())
{
return OpRes::Fail("Asset ID collision, ID: %llu, File: %s",
pAsset->GetID(), pAsset->GetFileLocation().filename().string().c_str());
@ -283,9 +283,9 @@ namespace lunarium { namespace editor
bool ContentManager::IsValidAsset(pugi::xml_node& node)
{
if (!node.child("ID")) { return false; }
if (!node.child("Type")) { return false; }
if (!node.child("Location")) { return false; }
if (!node.attribute("ID")) { return false; }
if (!node.attribute("Type")) { return false; }
if (!node.attribute("Location")) { return false; }
return true;
}

@ -75,6 +75,11 @@ namespace lunarium { namespace editor
mLocation = location.parent_path();
mName = location.filename().string();
if (Failed(ContentManager::GetInstance().Load(this).LogIfFailed(Editor::LogCat)))
{
return OpRes::Fail("Could not load project: %s", location.string().c_str());
}
mIsLoaded = true;
return OpRes::OK();
}
@ -88,8 +93,7 @@ namespace lunarium { namespace editor
void Project::SaveProject()
{
// HACK LOGGING lol
OpRes::Fail("Project::SaveProject not implemented yet").LogIfFailed(0);
ContentManager::GetInstance().Save().LogIfFailed(Editor::LogCat);
}
const std::string& Project::GetName() const

Loading…
Cancel
Save