mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 14:24:56 +00:00
YAML RAII refactor
This commit is contained in:
@@ -12,12 +12,13 @@ static void WriteTag(athena::io::YAMLDocWriter& cacheWriter,
|
||||
{
|
||||
char idStr[9];
|
||||
snprintf(idStr, 9, "%08X", uint32_t(pathTag.id));
|
||||
cacheWriter.enterSubVector(idStr);
|
||||
cacheWriter.writeString(nullptr, pathTag.type.toString().c_str());
|
||||
cacheWriter.writeString(nullptr, path.getAuxInfo().size() ?
|
||||
(path.getRelativePathUTF8() + '|' + path.getAuxInfoUTF8()) :
|
||||
path.getRelativePathUTF8());
|
||||
cacheWriter.leaveSubVector();
|
||||
if (auto v = cacheWriter.enterSubVector(idStr))
|
||||
{
|
||||
cacheWriter.writeString(nullptr, pathTag.type.toString().c_str());
|
||||
cacheWriter.writeString(nullptr, path.getAuxInfo().size() ?
|
||||
(path.getRelativePathUTF8() + '|' + path.getAuxInfoUTF8()) :
|
||||
path.getRelativePathUTF8());
|
||||
}
|
||||
}
|
||||
|
||||
static void WriteNameTag(athena::io::YAMLDocWriter& nameWriter,
|
||||
|
||||
@@ -118,6 +118,19 @@ void ProjectResourceFactoryMP1::IndexMP1Resources(hecl::Database::Project& proj,
|
||||
m_origIds = sp.GetObj("MP1OriginalIDs");
|
||||
}
|
||||
|
||||
void ProjectResourceFactoryMP1::GetTagListForFile(const char* pakName, std::vector<SObjectTag>& out) const
|
||||
{
|
||||
std::string pathPrefix("MP1/");
|
||||
pathPrefix += pakName;
|
||||
pathPrefix += '/';
|
||||
|
||||
std::unique_lock<std::mutex> lk(
|
||||
const_cast<ProjectResourceFactoryMP1&>(*this).m_backgroundIndexMutex);
|
||||
for (const auto& tag : m_tagToPath)
|
||||
if (!tag.second.getRelativePathUTF8().compare(0, pathPrefix.size(), pathPrefix))
|
||||
out.push_back(tag.first);
|
||||
}
|
||||
|
||||
void ProjectResourceFactoryMP1::Shutdown()
|
||||
{
|
||||
m_origIds = TLockedToken<MP1OriginalIDs>();
|
||||
|
||||
@@ -15,6 +15,7 @@ class ProjectResourceFactoryMP1 : public ProjectResourceFactoryBase
|
||||
public:
|
||||
ProjectResourceFactoryMP1(hecl::ClientProcess& clientProc);
|
||||
void IndexMP1Resources(hecl::Database::Project& proj, CSimplePool& sp);
|
||||
void GetTagListForFile(const char* pakName, std::vector<SObjectTag>& out) const;
|
||||
void Shutdown();
|
||||
|
||||
ResId TranslateOriginalToNew(ResId id) const;
|
||||
|
||||
@@ -173,9 +173,8 @@ public:
|
||||
: RootSpace(vm)
|
||||
{
|
||||
m_state.read(r);
|
||||
r.enterSubRecord("spaceTree");
|
||||
m_spaceTree.reset(NewSpaceFromConfigStream(vm, this, r));
|
||||
r.leaveSubRecord();
|
||||
if (auto rec = r.enterSubRecord("spaceTree"))
|
||||
m_spaceTree.reset(NewSpaceFromConfigStream(vm, this, r));
|
||||
}
|
||||
|
||||
void think()
|
||||
@@ -200,12 +199,13 @@ public:
|
||||
w.writeUint32("class", atUint32(m_class));
|
||||
m_state.write(w);
|
||||
|
||||
w.enterSubRecord("spaceTree");
|
||||
if (m_spaceTree)
|
||||
m_spaceTree->saveState(w);
|
||||
else
|
||||
w.writeUint32("class", 0);
|
||||
w.leaveSubRecord();
|
||||
if (auto rec = w.enterSubRecord("spaceTree"))
|
||||
{
|
||||
if (m_spaceTree)
|
||||
m_spaceTree->saveState(w);
|
||||
else
|
||||
w.writeUint32("class", 0);
|
||||
}
|
||||
}
|
||||
|
||||
void setChild(std::unique_ptr<Space>&& space)
|
||||
@@ -248,12 +248,10 @@ public:
|
||||
: SplitSpace(vm, parent, specter::SplitView::Axis::Horizontal)
|
||||
{
|
||||
m_state.read(r);
|
||||
r.enterSubRecord("slot0");
|
||||
m_slots[0].reset(NewSpaceFromConfigStream(vm, this, r));
|
||||
r.leaveSubRecord();
|
||||
r.enterSubRecord("slot1");
|
||||
m_slots[1].reset(NewSpaceFromConfigStream(vm, this, r));
|
||||
r.leaveSubRecord();
|
||||
if (auto rec = r.enterSubRecord("slot0"))
|
||||
m_slots[0].reset(NewSpaceFromConfigStream(vm, this, r));
|
||||
if (auto rec = r.enterSubRecord("slot1"))
|
||||
m_slots[1].reset(NewSpaceFromConfigStream(vm, this, r));
|
||||
reloadState();
|
||||
}
|
||||
|
||||
@@ -300,19 +298,21 @@ public:
|
||||
w.writeUint32("class", atUint32(m_class));
|
||||
m_state.write(w);
|
||||
|
||||
w.enterSubRecord("slot0");
|
||||
if (m_slots[0])
|
||||
m_slots[0]->saveState(w);
|
||||
else
|
||||
w.writeUint32("class", 0);
|
||||
w.leaveSubRecord();
|
||||
if (auto rec = w.enterSubRecord("slot0"))
|
||||
{
|
||||
if (m_slots[0])
|
||||
m_slots[0]->saveState(w);
|
||||
else
|
||||
w.writeUint32("class", 0);
|
||||
}
|
||||
|
||||
w.enterSubRecord("slot1");
|
||||
if (m_slots[1])
|
||||
m_slots[1]->saveState(w);
|
||||
else
|
||||
w.writeUint32("class", 0);
|
||||
w.leaveSubRecord();
|
||||
if (auto rec = w.enterSubRecord("slot1"))
|
||||
{
|
||||
if (m_slots[1])
|
||||
m_slots[1]->saveState(w);
|
||||
else
|
||||
w.writeUint32("class", 0);
|
||||
}
|
||||
}
|
||||
|
||||
void setChildSlot(unsigned slot, std::unique_ptr<Space>&& space);
|
||||
|
||||
Reference in New Issue
Block a user