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

@ -96,15 +96,15 @@ namespace lunarium { namespace editor
mNextID = ID.attribute("ID").as_ullong(); 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 // 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)) if (!IsValidAsset(asset))
{ {
@ -134,7 +134,7 @@ namespace lunarium { namespace editor
} }
// Store asset // 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", return OpRes::Fail("Asset ID collision, ID: %llu, File: %s",
pAsset->GetID(), pAsset->GetFileLocation().filename().string().c_str()); pAsset->GetID(), pAsset->GetFileLocation().filename().string().c_str());
@ -283,9 +283,9 @@ namespace lunarium { namespace editor
bool ContentManager::IsValidAsset(pugi::xml_node& node) bool ContentManager::IsValidAsset(pugi::xml_node& node)
{ {
if (!node.child("ID")) { return false; } if (!node.attribute("ID")) { return false; }
if (!node.child("Type")) { return false; } if (!node.attribute("Type")) { return false; }
if (!node.child("Location")) { return false; } if (!node.attribute("Location")) { return false; }
return true; return true;
} }

@ -75,6 +75,11 @@ namespace lunarium { namespace editor
mLocation = location.parent_path(); mLocation = location.parent_path();
mName = location.filename().string(); 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; mIsLoaded = true;
return OpRes::OK(); return OpRes::OK();
} }
@ -88,8 +93,7 @@ namespace lunarium { namespace editor
void Project::SaveProject() void Project::SaveProject()
{ {
// HACK LOGGING lol ContentManager::GetInstance().Save().LogIfFailed(Editor::LogCat);
OpRes::Fail("Project::SaveProject not implemented yet").LogIfFailed(0);
} }
const std::string& Project::GetName() const const std::string& Project::GetName() const

Loading…
Cancel
Save