From 5de9028a51e77c83e4ed668864b9f8ea31f79bd7 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 3 Jan 2016 19:31:02 -1000 Subject: [PATCH] YAML read/write refactor --- CMakeLists.txt | 6 ++ DataSpec/DNACommon/DNACommon.hpp | 20 +++--- DataSpec/DNAMP1/ANCS.cpp | 44 ++++++------- DataSpec/DNAMP1/EVNT.cpp | 4 +- DataSpec/DNAMP1/SCAN.hpp | 4 +- DataSpec/DNAMP1/SCLY.cpp | 12 ++-- DataSpec/DNAMP1/STRG.cpp | 4 +- DataSpec/DNAMP1/ScriptObjects/Oculus.hpp | 8 +-- DataSpec/DNAMP1/ScriptObjects/Ridley.hpp | 8 +-- .../DNAMP1/ScriptObjects/WorldTeleporter.hpp | 8 +-- DataSpec/DNAMP2/ANCS.cpp | 12 ++-- DataSpec/DNAMP2/STRG.cpp | 4 +- DataSpec/DNAMP3/CHAR.cpp | 24 +++---- DataSpec/DNAMP3/STRG.cpp | 4 +- Editor/CMakeLists.txt | 7 ++- Editor/ProjectManager.cpp | 63 +++++++++++++++++++ Editor/ProjectManager.hpp | 11 +++- Editor/ResourceOutliner.hpp | 14 ++++- Editor/Space.cpp | 20 +++++- Editor/Space.hpp | 52 +++++++++------ Editor/SplashScreen.hpp | 15 ++++- Editor/ViewManager.cpp | 45 +++++++------ Editor/ViewManager.hpp | 40 ++---------- hecl | 2 +- libSpecter | 2 +- 25 files changed, 265 insertions(+), 168 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e8c9aa3a8..009d40b00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,12 @@ set(BOO_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/hecl/extern/libBoo/include) set(HECL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/hecl/include ${CMAKE_CURRENT_SOURCE_DIR}/hecl/blender) +set(DATA_SPEC_LIBS + RetroDataSpec + DNAMP3 + DNAMP2 + DNAMP1 + DNACommon) set(HECL_DATASPEC_DECLS "/* RetroCommon specs */ namespace Retro diff --git a/DataSpec/DNACommon/DNACommon.hpp b/DataSpec/DNACommon/DNACommon.hpp index 166ff3e6c..52f53d29f 100644 --- a/DataSpec/DNACommon/DNACommon.hpp +++ b/DataSpec/DNACommon/DNACommon.hpp @@ -35,9 +35,9 @@ public: {reader.readUBytesToBuf(fcc, 4);} void write(Athena::io::IStreamWriter& writer) const {writer.writeUBytes((atUint8*)fcc, 4);} - void fromYAML(Athena::io::YAMLDocReader& reader) + void read(Athena::io::YAMLDocReader& reader) {std::string rs = reader.readString(nullptr); strncpy(fcc, rs.c_str(), 4);} - void toYAML(Athena::io::YAMLDocWriter& writer) const + void write(Athena::io::YAMLDocWriter& writer) const {writer.writeString(nullptr, std::string(fcc, 4));} size_t binarySize(size_t __isz) const {return __isz + 4;} @@ -56,9 +56,9 @@ public: {m_id = reader.readUint32Big();} void write(Athena::io::IStreamWriter& writer) const {writer.writeUint32Big(m_id);} - void fromYAML(Athena::io::YAMLDocReader& reader) + void read(Athena::io::YAMLDocReader& reader) {m_id = reader.readUint32(nullptr);} - void toYAML(Athena::io::YAMLDocWriter& writer) const + void write(Athena::io::YAMLDocWriter& writer) const {writer.writeUint32(nullptr, m_id);} size_t binarySize(size_t __isz) const {return __isz + 4;} @@ -109,9 +109,9 @@ public: {m_id = reader.readUint64Big();} void write(Athena::io::IStreamWriter& writer) const {writer.writeUint64Big(m_id);} - void fromYAML(Athena::io::YAMLDocReader& reader) + void read(Athena::io::YAMLDocReader& reader) {m_id = reader.readUint64(nullptr);} - void toYAML(Athena::io::YAMLDocWriter& writer) const + void write(Athena::io::YAMLDocWriter& writer) const {writer.writeUint64(nullptr, m_id);} size_t binarySize(size_t __isz) const {return __isz + 8;} @@ -184,7 +184,7 @@ public: writer.writeUint64Big(m_id[0]); writer.writeUint64Big(m_id[1]); } - void fromYAML(Athena::io::YAMLDocReader& reader) + void read(Athena::io::YAMLDocReader& reader) { std::string str = reader.readString(nullptr); while (str.size() < 32) @@ -194,7 +194,7 @@ public: m_id[0] = strtoull(hStr.c_str(), nullptr, 16); m_id[1] = strtoull(lStr.c_str(), nullptr, 16); } - void toYAML(Athena::io::YAMLDocWriter& writer) const + void write(Athena::io::YAMLDocWriter& writer) const { writer.writeString(nullptr, toString().c_str()); } @@ -259,7 +259,7 @@ public: {m_id.read(reader);} void write(Athena::io::IStreamWriter& writer) const {m_id.write(writer);} - void fromYAML(Athena::io::YAMLDocReader& reader) + void read(Athena::io::YAMLDocReader& reader) { if (!g_curSpec) LogDNACommon.report(LogVisor::FatalError, "current DataSpec not set for PAKPath"); @@ -273,7 +273,7 @@ public: m_path.assign(g_curSpec->getProject(), path); m_id = m_path; } - void toYAML(Athena::io::YAMLDocWriter& writer) const + void write(Athena::io::YAMLDocWriter& writer) const { if (m_path) { diff --git a/DataSpec/DNAMP1/ANCS.cpp b/DataSpec/DNAMP1/ANCS.cpp index b161759c7..f3eff9950 100644 --- a/DataSpec/DNAMP1/ANCS.cpp +++ b/DataSpec/DNAMP1/ANCS.cpp @@ -77,7 +77,7 @@ size_t ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::bina return __isz; } -void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::fromYAML(Athena::io::YAMLDocReader& reader) +void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::read(Athena::io::YAMLDocReader& reader) { parmType = reader.readUint32("parmType"); unk1 = reader.readUint32("unk1"); @@ -107,7 +107,7 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::fromYA reader.leaveSubVector(); } -void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::toYAML(Athena::io::YAMLDocWriter& writer) const +void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::write(Athena::io::YAMLDocWriter& writer) const { writer.writeUint32("parmType", parmType); writer.writeUint32("unk1", unk1); @@ -244,7 +244,7 @@ size_t ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::binarySize(siz return __isz; } -void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::fromYAML(Athena::io::YAMLDocReader& reader) +void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::read(Athena::io::YAMLDocReader& reader) { id = reader.readUint32("id"); atUint32 parmInfoCount = reader.readUint32("parmInfoCount"); @@ -282,7 +282,7 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::fromYAML(Athena: }); } -void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::toYAML(Athena::io::YAMLDocWriter& writer) const +void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::write(Athena::io::YAMLDocWriter& writer) const { writer.writeUint32("id", id); writer.writeUint32("parmInfoCount", parmInfos.size()); @@ -524,7 +524,7 @@ size_t ANCS::CharacterSet::CharacterInfo::binarySize(size_t __isz) const return __isz; } -void ANCS::CharacterSet::CharacterInfo::fromYAML(Athena::io::YAMLDocReader& reader) +void ANCS::CharacterSet::CharacterInfo::read(Athena::io::YAMLDocReader& reader) { idx = reader.readUint32("idx"); atUint16 sectionCount = reader.readUint16("sectionCount"); @@ -584,7 +584,7 @@ void ANCS::CharacterSet::CharacterInfo::fromYAML(Athena::io::YAMLDocReader& read } } -void ANCS::CharacterSet::CharacterInfo::toYAML(Athena::io::YAMLDocWriter& writer) const +void ANCS::CharacterSet::CharacterInfo::write(Athena::io::YAMLDocWriter& writer) const { writer.writeUint32("idx", idx); @@ -706,34 +706,34 @@ size_t ANCS::AnimationSet::MetaAnimFactory::binarySize(size_t __isz) const return m_anim->binarySize(__isz + 4); } -void ANCS::AnimationSet::MetaAnimFactory::fromYAML(Athena::io::YAMLDocReader& reader) +void ANCS::AnimationSet::MetaAnimFactory::read(Athena::io::YAMLDocReader& reader) { std::string type = reader.readString("type"); std::transform(type.begin(), type.end(), type.begin(), tolower); if (!type.compare("primitive")) { m_anim.reset(new struct MetaAnimPrimitive); - m_anim->fromYAML(reader); + m_anim->read(reader); } else if (!type.compare("blend")) { m_anim.reset(new struct MetaAnimBlend); - m_anim->fromYAML(reader); + m_anim->read(reader); } else if (!type.compare("phaseblend")) { m_anim.reset(new struct MetaAnimPhaseBlend); - m_anim->fromYAML(reader); + m_anim->read(reader); } else if (!type.compare("random")) { m_anim.reset(new struct MetaAnimRandom); - m_anim->fromYAML(reader); + m_anim->read(reader); } else if (!type.compare("sequence")) { m_anim.reset(new struct MetaAnimSequence); - m_anim->fromYAML(reader); + m_anim->read(reader); } else { @@ -742,12 +742,12 @@ void ANCS::AnimationSet::MetaAnimFactory::fromYAML(Athena::io::YAMLDocReader& re } -void ANCS::AnimationSet::MetaAnimFactory::toYAML(Athena::io::YAMLDocWriter& writer) const +void ANCS::AnimationSet::MetaAnimFactory::write(Athena::io::YAMLDocWriter& writer) const { if (!m_anim) return; writer.writeString("type", m_anim->m_typeStr); - m_anim->toYAML(writer); + m_anim->write(writer); } const char* ANCS::AnimationSet::MetaAnimFactory::DNAType() @@ -797,24 +797,24 @@ size_t ANCS::AnimationSet::MetaTransFactory::binarySize(size_t __isz) const return m_trans->binarySize(__isz + 4); } -void ANCS::AnimationSet::MetaTransFactory::fromYAML(Athena::io::YAMLDocReader& reader) +void ANCS::AnimationSet::MetaTransFactory::read(Athena::io::YAMLDocReader& reader) { std::string type = reader.readString("type"); std::transform(type.begin(), type.end(), type.begin(), tolower); if (!type.compare("metaanim")) { m_trans.reset(new struct MetaTransMetaAnim); - m_trans->fromYAML(reader); + m_trans->read(reader); } else if (!type.compare("trans")) { m_trans.reset(new struct MetaTransTrans); - m_trans->fromYAML(reader); + m_trans->read(reader); } else if (!type.compare("phasetrans")) { m_trans.reset(new struct MetaTransPhaseTrans); - m_trans->fromYAML(reader); + m_trans->read(reader); } else { @@ -823,7 +823,7 @@ void ANCS::AnimationSet::MetaTransFactory::fromYAML(Athena::io::YAMLDocReader& r } -void ANCS::AnimationSet::MetaTransFactory::toYAML(Athena::io::YAMLDocWriter& writer) const +void ANCS::AnimationSet::MetaTransFactory::write(Athena::io::YAMLDocWriter& writer) const { if (!m_trans) { @@ -831,7 +831,7 @@ void ANCS::AnimationSet::MetaTransFactory::toYAML(Athena::io::YAMLDocWriter& wri return; } writer.writeString("type", m_trans->m_typeStr?m_trans->m_typeStr:"NoTrans"); - m_trans->toYAML(writer); + m_trans->write(writer); } const char* ANCS::AnimationSet::MetaTransFactory::DNAType() @@ -957,7 +957,7 @@ size_t ANCS::AnimationSet::binarySize(size_t __isz) const return __isz; } -void ANCS::AnimationSet::fromYAML(Athena::io::YAMLDocReader& reader) +void ANCS::AnimationSet::read(Athena::io::YAMLDocReader& reader) { atUint16 sectionCount = reader.readUint16("sectionCount"); @@ -992,7 +992,7 @@ void ANCS::AnimationSet::fromYAML(Athena::io::YAMLDocReader& reader) } } -void ANCS::AnimationSet::toYAML(Athena::io::YAMLDocWriter& writer) const +void ANCS::AnimationSet::write(Athena::io::YAMLDocWriter& writer) const { atUint16 sectionCount; if (animResources.size()) diff --git a/DataSpec/DNAMP1/EVNT.cpp b/DataSpec/DNAMP1/EVNT.cpp index ef59b7888..9c0afdd17 100644 --- a/DataSpec/DNAMP1/EVNT.cpp +++ b/DataSpec/DNAMP1/EVNT.cpp @@ -46,7 +46,7 @@ void EVNT::write(Athena::io::IStreamWriter& writer) const writer.enumerate(sfxEvents); } -void EVNT::fromYAML(Athena::io::YAMLDocReader& reader) +void EVNT::read(Athena::io::YAMLDocReader& reader) { version = reader.readUint32("version"); @@ -67,7 +67,7 @@ void EVNT::fromYAML(Athena::io::YAMLDocReader& reader) reader.enumerate("sfxEvents", sfxEvents, sfxCount); } -void EVNT::toYAML(Athena::io::YAMLDocWriter& writer) const +void EVNT::write(Athena::io::YAMLDocWriter& writer) const { writer.writeUint32("version", version); diff --git a/DataSpec/DNAMP1/SCAN.hpp b/DataSpec/DNAMP1/SCAN.hpp index cd7c110c9..4482752a1 100644 --- a/DataSpec/DNAMP1/SCAN.hpp +++ b/DataSpec/DNAMP1/SCAN.hpp @@ -128,7 +128,7 @@ struct SCAN : BigYAML __dna_writer.writeFloatBig(fadeDuration); } - void fromYAML(Athena::io::YAMLDocReader& __dna_docin) + void read(Athena::io::YAMLDocReader& __dna_docin) { /* texture */ __dna_docin.enumerate("texture", texture); @@ -153,7 +153,7 @@ struct SCAN : BigYAML fadeDuration = __dna_docin.readFloat("fadeDuration"); } - void toYAML(Athena::io::YAMLDocWriter& __dna_docout) const + void write(Athena::io::YAMLDocWriter& __dna_docout) const { /* texture */ __dna_docout.enumerate("texture", texture); diff --git a/DataSpec/DNAMP1/SCLY.cpp b/DataSpec/DNAMP1/SCLY.cpp index 08ee2b5f5..ce9bcf335 100644 --- a/DataSpec/DNAMP1/SCLY.cpp +++ b/DataSpec/DNAMP1/SCLY.cpp @@ -80,7 +80,7 @@ void SCLY::ScriptLayer::nameIDs(PAKRouter& pakRouter) const obj->nameIDs(pakRouter); } -void SCLY::fromYAML(Athena::io::YAMLDocReader& docin) +void SCLY::read(Athena::io::YAMLDocReader& docin) { fourCC = docin.readUint32("fourCC"); version = docin.readUint32("version"); @@ -89,7 +89,7 @@ void SCLY::fromYAML(Athena::io::YAMLDocReader& docin) docin.enumerate("layers", layers, layerCount); } -void SCLY::toYAML(Athena::io::YAMLDocWriter& docout) const +void SCLY::write(Athena::io::YAMLDocWriter& docout) const { docout.writeUint32("fourCC", fourCC); docout.writeUint32("version", version); @@ -133,7 +133,7 @@ void SCLY::ScriptLayer::read(Athena::io::IStreamReader& rs) } } -void SCLY::ScriptLayer::fromYAML(Athena::io::YAMLDocReader& rs) +void SCLY::ScriptLayer::read(Athena::io::YAMLDocReader& rs) { unknown = rs.readUByte("unknown"); objectCount = rs.readUint32("objectCount"); @@ -149,7 +149,7 @@ void SCLY::ScriptLayer::fromYAML(Athena::io::YAMLDocReader& rs) if (iter != SCRIPT_OBJECT_DB.end()) { std::unique_ptr obj((*iter)->a()); - obj->fromYAML(rs); + obj->read(rs); obj->type = type; objects.push_back(std::move(obj)); } @@ -183,7 +183,7 @@ size_t SCLY::ScriptLayer::binarySize(size_t __isz) const return __isz; } -void SCLY::ScriptLayer::toYAML(Athena::io::YAMLDocWriter& ws) const +void SCLY::ScriptLayer::write(Athena::io::YAMLDocWriter& ws) const { ws.writeUByte("unknown", unknown); ws.writeUint32("objectCount", objectCount); @@ -192,7 +192,7 @@ void SCLY::ScriptLayer::toYAML(Athena::io::YAMLDocWriter& ws) const { ws.enterSubRecord(nullptr); ws.writeUByte("type", obj->type); - obj->toYAML(ws); + obj->write(ws); ws.leaveSubRecord(); }; ws.leaveSubVector(); diff --git a/DataSpec/DNAMP1/STRG.cpp b/DataSpec/DNAMP1/STRG.cpp index 71a165a80..e00873710 100644 --- a/DataSpec/DNAMP1/STRG.cpp +++ b/DataSpec/DNAMP1/STRG.cpp @@ -131,7 +131,7 @@ size_t STRG::binarySize(size_t __isz) const return __isz; } -void STRG::fromYAML(Athena::io::YAMLDocReader& reader) +void STRG::read(Athena::io::YAMLDocReader& reader) { const Athena::io::YAMLNode* root = reader.getRootNode(); @@ -182,7 +182,7 @@ void STRG::fromYAML(Athena::io::YAMLDocReader& reader) langMap.emplace(item.first, &item.second); } -void STRG::toYAML(Athena::io::YAMLDocWriter& writer) const +void STRG::write(Athena::io::YAMLDocWriter& writer) const { for (const auto& lang : langs) { diff --git a/DataSpec/DNAMP1/ScriptObjects/Oculus.hpp b/DataSpec/DNAMP1/ScriptObjects/Oculus.hpp index 0cc5fb5d7..f10378f19 100644 --- a/DataSpec/DNAMP1/ScriptObjects/Oculus.hpp +++ b/DataSpec/DNAMP1/ScriptObjects/Oculus.hpp @@ -109,9 +109,9 @@ struct Oculus : IScriptObject __dna_writer.writeFloatBig(unknown8); } - void fromYAML(Athena::io::YAMLDocReader& __dna_docin) + void read(Athena::io::YAMLDocReader& __dna_docin) { - IScriptObject::fromYAML(__dna_docin); + IScriptObject::read(__dna_docin); /* name */ name = __dna_docin.readString("name"); /* location */ @@ -149,9 +149,9 @@ struct Oculus : IScriptObject unknown8 = 0.0; } - void toYAML(Athena::io::YAMLDocWriter& __dna_docout) const + void write(Athena::io::YAMLDocWriter& __dna_docout) const { - IScriptObject::toYAML(__dna_docout); + IScriptObject::write(__dna_docout); /* name */ __dna_docout.writeString("name", name); /* location */ diff --git a/DataSpec/DNAMP1/ScriptObjects/Ridley.hpp b/DataSpec/DNAMP1/ScriptObjects/Ridley.hpp index 1683f1e9d..31e51fbf6 100644 --- a/DataSpec/DNAMP1/ScriptObjects/Ridley.hpp +++ b/DataSpec/DNAMP1/ScriptObjects/Ridley.hpp @@ -344,9 +344,9 @@ struct Ridley : IScriptObject damageInfo9.write(__dna_writer); } - void fromYAML(Athena::io::YAMLDocReader& __dna_docin) + void read(Athena::io::YAMLDocReader& __dna_docin) { - IScriptObject::fromYAML(__dna_docin); + IScriptObject::read(__dna_docin); /* name */ name = __dna_docin.readString("name"); /* location */ @@ -454,9 +454,9 @@ struct Ridley : IScriptObject __dna_docin.enumerate("damageInfo9", damageInfo9); } - void toYAML(Athena::io::YAMLDocWriter& __dna_docout) const + void write(Athena::io::YAMLDocWriter& __dna_docout) const { - IScriptObject::toYAML(__dna_docout); + IScriptObject::write(__dna_docout); /* name */ __dna_docout.writeString("name", name); /* location */ diff --git a/DataSpec/DNAMP1/ScriptObjects/WorldTeleporter.hpp b/DataSpec/DNAMP1/ScriptObjects/WorldTeleporter.hpp index 2633a9d00..67c5e93ac 100644 --- a/DataSpec/DNAMP1/ScriptObjects/WorldTeleporter.hpp +++ b/DataSpec/DNAMP1/ScriptObjects/WorldTeleporter.hpp @@ -160,9 +160,9 @@ struct WorldTeleporter : IScriptObject } } - void fromYAML(Athena::io::YAMLDocReader& __dna_docin) + void read(Athena::io::YAMLDocReader& __dna_docin) { - IScriptObject::fromYAML(__dna_docin); + IScriptObject::read(__dna_docin); /* name */ name = __dna_docin.readString("name"); /* unknown1 */ @@ -223,9 +223,9 @@ struct WorldTeleporter : IScriptObject } } - void toYAML(Athena::io::YAMLDocWriter& __dna_docout) const + void write(Athena::io::YAMLDocWriter& __dna_docout) const { - IScriptObject::toYAML(__dna_docout); + IScriptObject::write(__dna_docout); /* name */ __dna_docout.writeString("name", name); /* unknown1 */ diff --git a/DataSpec/DNAMP2/ANCS.cpp b/DataSpec/DNAMP2/ANCS.cpp index e67013fd7..813c104d8 100644 --- a/DataSpec/DNAMP2/ANCS.cpp +++ b/DataSpec/DNAMP2/ANCS.cpp @@ -238,7 +238,7 @@ size_t ANCS::CharacterSet::CharacterInfo::binarySize(size_t __isz) const return __isz; } -void ANCS::CharacterSet::CharacterInfo::fromYAML(Athena::io::YAMLDocReader& reader) +void ANCS::CharacterSet::CharacterInfo::read(Athena::io::YAMLDocReader& reader) { idx = reader.readUint32("idx"); atUint16 sectionCount = reader.readUint16("sectionCount"); @@ -309,7 +309,7 @@ void ANCS::CharacterSet::CharacterInfo::fromYAML(Athena::io::YAMLDocReader& read } } -void ANCS::CharacterSet::CharacterInfo::toYAML(Athena::io::YAMLDocWriter& writer) const +void ANCS::CharacterSet::CharacterInfo::write(Athena::io::YAMLDocWriter& writer) const { writer.writeUint32("idx", idx); @@ -516,7 +516,7 @@ size_t ANCS::AnimationSet::binarySize(size_t __isz) const return __isz; } -void ANCS::AnimationSet::fromYAML(Athena::io::YAMLDocReader& reader) +void ANCS::AnimationSet::read(Athena::io::YAMLDocReader& reader) { atUint16 sectionCount = reader.readUint16("sectionCount"); @@ -551,7 +551,7 @@ void ANCS::AnimationSet::fromYAML(Athena::io::YAMLDocReader& reader) } } -void ANCS::AnimationSet::toYAML(Athena::io::YAMLDocWriter& writer) const +void ANCS::AnimationSet::write(Athena::io::YAMLDocWriter& writer) const { atUint16 sectionCount; if (evnts.size()) @@ -661,7 +661,7 @@ size_t ANCS::AnimationSet::EVNT::binarySize(size_t __isz) const return __isz; } -void ANCS::AnimationSet::EVNT::fromYAML(Athena::io::YAMLDocReader& reader) +void ANCS::AnimationSet::EVNT::read(Athena::io::YAMLDocReader& reader) { version = reader.readUint32("version"); @@ -682,7 +682,7 @@ void ANCS::AnimationSet::EVNT::fromYAML(Athena::io::YAMLDocReader& reader) reader.enumerate("sfxEvents", sfxEvents, sfxCount); } -void ANCS::AnimationSet::EVNT::toYAML(Athena::io::YAMLDocWriter& writer) const +void ANCS::AnimationSet::EVNT::write(Athena::io::YAMLDocWriter& writer) const { writer.writeUint32("version", version); diff --git a/DataSpec/DNAMP2/STRG.cpp b/DataSpec/DNAMP2/STRG.cpp index 69214a504..2faf82197 100644 --- a/DataSpec/DNAMP2/STRG.cpp +++ b/DataSpec/DNAMP2/STRG.cpp @@ -166,7 +166,7 @@ size_t STRG::binarySize(size_t __isz) const return __isz; } -void STRG::fromYAML(Athena::io::YAMLDocReader& reader) +void STRG::read(Athena::io::YAMLDocReader& reader) { const Athena::io::YAMLNode* root = reader.getRootNode(); @@ -225,7 +225,7 @@ void STRG::fromYAML(Athena::io::YAMLDocReader& reader) langMap.emplace(item.first, &item.second); } -void STRG::toYAML(Athena::io::YAMLDocWriter& writer) const +void STRG::write(Athena::io::YAMLDocWriter& writer) const { for (const auto& lang : langs) { diff --git a/DataSpec/DNAMP3/CHAR.cpp b/DataSpec/DNAMP3/CHAR.cpp index 4d41d5556..3b5d35ce9 100644 --- a/DataSpec/DNAMP3/CHAR.cpp +++ b/DataSpec/DNAMP3/CHAR.cpp @@ -48,9 +48,9 @@ size_t CHAR::AnimationInfo::EVNT::SFXEvent::binarySize(size_t __isz) const return __isz; } -void CHAR::AnimationInfo::EVNT::SFXEvent::fromYAML(Athena::io::YAMLDocReader& reader) +void CHAR::AnimationInfo::EVNT::SFXEvent::read(Athena::io::YAMLDocReader& reader) { - EventBase::fromYAML(reader); + EventBase::read(reader); reader.enumerate("caudId", caudId); unk1 = reader.readUint32("unk1"); unk2 = reader.readUint32("unk2"); @@ -61,9 +61,9 @@ void CHAR::AnimationInfo::EVNT::SFXEvent::fromYAML(Athena::io::YAMLDocReader& re extraFloat = reader.readFloat("extraFloat"); } -void CHAR::AnimationInfo::EVNT::SFXEvent::toYAML(Athena::io::YAMLDocWriter& writer) const +void CHAR::AnimationInfo::EVNT::SFXEvent::write(Athena::io::YAMLDocWriter& writer) const { - EventBase::toYAML(writer); + EventBase::write(writer); writer.enumerate("caudId", caudId); writer.writeUint32("unk1", unk1); writer.writeUint32("unk2", unk2); @@ -125,34 +125,34 @@ size_t CHAR::AnimationInfo::MetaAnimFactory::binarySize(size_t __isz) const return m_anim->binarySize(__isz + 4); } -void CHAR::AnimationInfo::MetaAnimFactory::fromYAML(Athena::io::YAMLDocReader& reader) +void CHAR::AnimationInfo::MetaAnimFactory::read(Athena::io::YAMLDocReader& reader) { std::string type = reader.readString("type"); std::transform(type.begin(), type.end(), type.begin(), tolower); if (!type.compare("primitive")) { m_anim.reset(new struct MetaAnimPrimitive); - m_anim->fromYAML(reader); + m_anim->read(reader); } else if (!type.compare("blend")) { m_anim.reset(new struct MetaAnimBlend); - m_anim->fromYAML(reader); + m_anim->read(reader); } else if (!type.compare("phaseblend")) { m_anim.reset(new struct MetaAnimPhaseBlend); - m_anim->fromYAML(reader); + m_anim->read(reader); } else if (!type.compare("random")) { m_anim.reset(new struct MetaAnimRandom); - m_anim->fromYAML(reader); + m_anim->read(reader); } else if (!type.compare("sequence")) { m_anim.reset(new struct MetaAnimSequence); - m_anim->fromYAML(reader); + m_anim->read(reader); } else { @@ -161,12 +161,12 @@ void CHAR::AnimationInfo::MetaAnimFactory::fromYAML(Athena::io::YAMLDocReader& r } -void CHAR::AnimationInfo::MetaAnimFactory::toYAML(Athena::io::YAMLDocWriter& writer) const +void CHAR::AnimationInfo::MetaAnimFactory::write(Athena::io::YAMLDocWriter& writer) const { if (!m_anim) return; writer.writeString("type", m_anim->m_typeStr); - m_anim->toYAML(writer); + m_anim->write(writer); } const char* CHAR::AnimationInfo::MetaAnimFactory::DNAType() diff --git a/DataSpec/DNAMP3/STRG.cpp b/DataSpec/DNAMP3/STRG.cpp index 61fbcb016..a55de3216 100644 --- a/DataSpec/DNAMP3/STRG.cpp +++ b/DataSpec/DNAMP3/STRG.cpp @@ -85,7 +85,7 @@ void STRG::read(Athena::io::IStreamReader& reader) _read(reader); } -void STRG::fromYAML(Athena::io::YAMLDocReader& reader) +void STRG::read(Athena::io::YAMLDocReader& reader) { const Athena::io::YAMLNode* root = reader.getRootNode(); @@ -243,7 +243,7 @@ size_t STRG::binarySize(size_t __isz) const return __isz; } -void STRG::toYAML(Athena::io::YAMLDocWriter& writer) const +void STRG::write(Athena::io::YAMLDocWriter& writer) const { for (const auto& item : langs) { diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index 7e043cb67..020cbe1e0 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -2,12 +2,13 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_subdirectory(locale) atdna(atdna_Space.cpp Space.hpp) +atdna(atdna_ResourceOutliner.cpp ResourceOutliner.hpp) add_executable(rude WIN32 main.cpp Space.hpp Space.cpp atdna_Space.cpp SplashScreen.hpp SplashScreen.cpp - ResourceOutliner.hpp ResourceOutliner.cpp + ResourceOutliner.hpp ResourceOutliner.cpp atdna_ResourceOutliner.cpp ProjectManager.hpp ProjectManager.cpp ViewManager.hpp ViewManager.cpp) @@ -17,8 +18,8 @@ target_link_libraries(rude RuntimeCommonInput RuntimeCommon DNAMP3 DNAMP2 DNAMP1 - DNACommon Specter SpecterFonts freetype - HECLDatabase HECLBlender HECLRuntime HECLCommon AthenaCore NOD + DNACommon Specter SpecterFonts freetype ${DATA_SPEC_LIBS} + HECLDatabase HECLBackend HECLFrontend HECLBlender HECLRuntime HECLCommon AthenaCore NOD LogVisor AthenaLibYaml Boo ${PNG_LIB} squish xxhash Math ${ZLIB_LIBRARIES} ${LZO_LIB} ${BOO_SYS_LIBS}) diff --git a/Editor/ProjectManager.cpp b/Editor/ProjectManager.cpp index 9211f6d7d..3e1dffbc5 100644 --- a/Editor/ProjectManager.cpp +++ b/Editor/ProjectManager.cpp @@ -1,6 +1,69 @@ #include "ProjectManager.hpp" +#include "ViewManager.hpp" +#include "../DataSpecRegistry.hpp" namespace RUDE { +static LogVisor::LogModule Log("RUDE::ProjectManager"); + +bool ProjectManager::m_registeredSpecs = false; +ProjectManager::ProjectManager(ViewManager &vm) +: m_vm(vm) +{ + if (!m_registeredSpecs) + { + HECLRegisterDataSpecs(); + m_registeredSpecs = true; + } +} + +bool ProjectManager::newProject(const HECL::SystemString& path) +{ + HECL::ProjectRootPath projPath = HECL::SearchForProject(path); + if (projPath) + { + Log.report(LogVisor::Warning, _S("project already exists at '%s'"), path.c_str()); + return false; + } + + m_proj.reset(new HECL::Database::Project(path)); + if (!*m_proj) + { + m_proj.reset(); + return false; + } + + return true; +} + +bool ProjectManager::openProject(const HECL::SystemString& path) +{ + HECL::ProjectRootPath projPath = HECL::SearchForProject(path); + if (!projPath) + { + Log.report(LogVisor::Warning, _S("project doesn't exist at '%s'"), path.c_str()); + return false; + } + + m_proj.reset(new HECL::Database::Project(projPath)); + if (!*m_proj) + { + m_proj.reset(); + return false; + } + + HECL::ProjectPath rudeSpacesPath(*m_proj, _S(".hecl/rude_spaces.yaml")); + if (rudeSpacesPath.getPathType() == HECL::ProjectPath::Type::File) + { + + } + + return true; +} + +bool ProjectManager::extractGame(const HECL::SystemString& path) +{ + return false; +} } diff --git a/Editor/ProjectManager.hpp b/Editor/ProjectManager.hpp index 39013bade..0804c29c5 100644 --- a/Editor/ProjectManager.hpp +++ b/Editor/ProjectManager.hpp @@ -5,11 +5,20 @@ namespace RUDE { +class ViewManager; class ProjectManager { - HECL::Database::Project* m_proj = nullptr; + ViewManager& m_vm; + std::unique_ptr m_proj; + static bool m_registeredSpecs; public: + ProjectManager(ViewManager& vm); + operator bool() const {return m_proj.operator bool();} + + bool newProject(const HECL::SystemString& path); + bool openProject(const HECL::SystemString& path); + bool extractGame(const HECL::SystemString& path); }; diff --git a/Editor/ResourceOutliner.hpp b/Editor/ResourceOutliner.hpp index f8613d8dc..2f0c94c1d 100644 --- a/Editor/ResourceOutliner.hpp +++ b/Editor/ResourceOutliner.hpp @@ -8,11 +8,21 @@ namespace RUDE class ResourceOutliner : public Space { - struct State : SpaceState + struct State : Space::State { DECL_YAML } m_state; - SpaceState* spaceState() {return &m_state;} + Space::State& spaceState() {return m_state;} + +public: + ResourceOutliner(ViewManager& vm) : Space(vm, Class::ResourceOutliner) {} + ResourceOutliner(ViewManager& vm, Athena::io::YAMLDocReader& r) + : ResourceOutliner(vm) + { + m_state.read(r); + } + + Specter::View* buildContentView(Specter::ViewResources& res) {return nullptr;} }; } diff --git a/Editor/Space.cpp b/Editor/Space.cpp index ec3b91a9b..d31139dbf 100644 --- a/Editor/Space.cpp +++ b/Editor/Space.cpp @@ -1,19 +1,35 @@ #include "Space.hpp" #include "ViewManager.hpp" +#include "ResourceOutliner.hpp" namespace RUDE { -Specter::Space* Space::buildSpace(Specter::ViewResources& res) +Specter::Space* Space::buildSpaceView(Specter::ViewResources& res) { m_space.reset(new Specter::Space(res, m_vm.rootView(), Specter::Toolbar::Position::Bottom)); return m_space.get(); } -Specter::View* SplitSpace::buildContent(Specter::ViewResources& res) +Specter::View* SplitSpace::buildContentView(Specter::ViewResources& res) { m_splitView.reset(new Specter::SplitView(res, m_vm.rootView(), Specter::SplitView::Axis::Horizontal)); return m_splitView.get(); } +Space* Space::NewSpaceFromYAMLStream(ViewManager& vm, Athena::io::YAMLDocReader& r) +{ + StateHead head; + head.read(r); + switch (head.cls) + { + case Class::SplitSpace: + return new SplitSpace(vm, r); + case Class::ResourceOutliner: + return new ResourceOutliner(vm, r); + default: break; + } + return nullptr; +} + } diff --git a/Editor/Space.hpp b/Editor/Space.hpp index 35053aeaa..e88f11cd5 100644 --- a/Editor/Space.hpp +++ b/Editor/Space.hpp @@ -15,8 +15,6 @@ namespace RUDE { class ViewManager; -struct SpaceState : Athena::io::DNAYaml {Delete _d;}; - class Space { public: @@ -27,42 +25,58 @@ public: TestSpace, ResourceOutliner, }; + + struct StateHead : Athena::io::DNAYaml + { + DECL_YAML + Value cls; + }; + struct State : Athena::io::DNAYaml {Delete _d;}; + + static Space* NewSpaceFromYAMLStream(ViewManager& vm, Athena::io::YAMLDocReader& r); + protected: friend class ViewManager; ViewManager& m_vm; Class m_class = Class::None; std::unique_ptr m_space; Space(ViewManager& vm, Class cls) : m_vm(vm), m_class(cls) {} - Space(ViewManager& vm, Class cls, Athena::io::IStreamReader& r) : m_vm(vm), m_class(cls) - {if (spaceState()) spaceState()->read(r);} - void writeState(Athena::io::IStreamWriter& w) const; /* Allows common Space code to access DNA-encoded state */ - virtual SpaceState* spaceState() {return nullptr;} + virtual Space::State& spaceState()=0; /* Structural control */ virtual bool usesToolbar() const {return false;} - virtual void buildToolbar(Specter::ViewResources& res, Specter::Toolbar& tb) {} - virtual Specter::View* buildContent(Specter::ViewResources& res)=0; - Specter::Space* buildSpace(Specter::ViewResources& res); + virtual void buildToolbarView(Specter::ViewResources& res, Specter::Toolbar& tb) {} + virtual Specter::View* buildContentView(Specter::ViewResources& res)=0; + Specter::Space* buildSpaceView(Specter::ViewResources& res); public: }; class SplitSpace : public Space { friend class ViewManager; + std::unique_ptr m_a; + std::unique_ptr m_b; std::unique_ptr m_splitView; - struct State : SpaceState + struct State : Space::State { DECL_YAML - Value m_split; + Value split; } m_state; - SpaceState* spaceState() {return &m_state;} + Space::State& spaceState() {return m_state;} public: - SplitSpace(ViewManager& vm) - : Space(vm, Class::SplitSpace) {} - Specter::View* buildContent(Specter::ViewResources& res); + SplitSpace(ViewManager& vm) : Space(vm, Class::SplitSpace) {} + SplitSpace(ViewManager& vm, Athena::io::YAMLDocReader& r) + : SplitSpace(vm) + { + m_state.read(r); + m_a.reset(NewSpaceFromYAMLStream(vm, r)); + m_b.reset(NewSpaceFromYAMLStream(vm, r)); + } + + Specter::View* buildContentView(Specter::ViewResources& res); }; class TestSpace : public Space @@ -81,20 +95,20 @@ public: : Space(vm, Class::TestSpace), m_contentStr(content), m_buttonStr(button), m_binding(binding) {} - struct State : SpaceState + struct State : Space::State { DECL_YAML } m_state; - SpaceState* spaceState() {return &m_state;} + Space::State& spaceState() {return m_state;} bool usesToolbar() const {return true;} - void buildToolbar(Specter::ViewResources& res, Specter::Toolbar& tb) + void buildToolbarView(Specter::ViewResources& res, Specter::Toolbar& tb) { m_button.reset(new Specter::Button(res, tb, m_binding, m_buttonStr)); tb.push_back(m_button.get()); } - Specter::View* buildContent(Specter::ViewResources& res) + Specter::View* buildContentView(Specter::ViewResources& res) { m_textView.reset(new Specter::MultiLineTextView(res, *m_space, res.m_heading14)); m_textView->setBackground(res.themeData().viewportBackground()); diff --git a/Editor/SplashScreen.hpp b/Editor/SplashScreen.hpp index ce37239ef..47bdd5b9d 100644 --- a/Editor/SplashScreen.hpp +++ b/Editor/SplashScreen.hpp @@ -43,10 +43,13 @@ class SplashScreen : public Specter::ModalWindow new Specter::FileBrowser(m_splash.rootView().viewRes(), m_splash, m_splash.m_newString, Specter::FileBrowser::Type::SaveDirectory, - [](bool ok, const HECL::SystemString& path) + [&](bool ok, const HECL::SystemString& path) { if (ok) + { Log.report(LogVisor::Info, _S("Making project '%s'"), path.c_str()); + m_splash.m_vm.projectManager().newProject(path); + } })); m_splash.updateSize(); m_splash.m_newButt.mouseLeave(coord); @@ -65,10 +68,13 @@ class SplashScreen : public Specter::ModalWindow new Specter::FileBrowser(m_splash.rootView().viewRes(), m_splash, m_splash.m_openString, Specter::FileBrowser::Type::OpenHECLProject, - [](bool ok, const HECL::SystemString& path) + [&](bool ok, const HECL::SystemString& path) { if (ok) + { Log.report(LogVisor::Info, _S("Opening project '%s'"), path.c_str()); + m_splash.m_vm.projectManager().openProject(path); + } })); m_splash.updateSize(); m_splash.m_openButt.mouseLeave(coord); @@ -87,10 +93,13 @@ class SplashScreen : public Specter::ModalWindow new Specter::FileBrowser(m_splash.rootView().viewRes(), m_splash, m_splash.m_extractString, Specter::FileBrowser::Type::OpenFile, - [](bool ok, const HECL::SystemString& path) + [&](bool ok, const HECL::SystemString& path) { if (ok) + { Log.report(LogVisor::Info, _S("Extracting game '%s'"), path.c_str()); + m_splash.m_vm.projectManager().extractGame(path); + } })); m_splash.updateSize(); m_splash.m_extractButt.mouseLeave(coord); diff --git a/Editor/ViewManager.cpp b/Editor/ViewManager.cpp index d8ffdde85..d10ff7ca2 100644 --- a/Editor/ViewManager.cpp +++ b/Editor/ViewManager.cpp @@ -11,11 +11,11 @@ namespace RUDE Specter::View* ViewManager::BuildSpaceViews(RUDE::Space* space) { - Specter::Space* sspace = space->buildSpace(m_viewResources); - Specter::View* sview = space->buildContent(m_viewResources); + Specter::Space* sspace = space->buildSpaceView(m_viewResources); + Specter::View* sview = space->buildContentView(m_viewResources); sspace->setContentView(sview); if (space->usesToolbar()) - space->buildToolbar(m_viewResources, sspace->toolbar()); + space->buildToolbarView(m_viewResources, sspace->toolbar()); return sspace; } @@ -31,24 +31,28 @@ void ViewManager::SetupSplashView() m_splash.reset(new SplashScreen(*this, m_viewResources)); m_rootView->setContentView(m_splash.get()); m_rootView->updateSize(); + m_showSplash = true; } void ViewManager::SetupEditorView() { - m_rootView->setBackground(Zeus::CColor::skGrey); - m_rootView->setContentView(m_split.buildContent(m_viewResources)); - m_split.m_splitView->setContentView(0, BuildSpaceViews(&m_space1)); - m_split.m_splitView->setContentView(1, BuildSpaceViews(&m_space2)); + m_rootSpace.reset(new SplitSpace(*this)); + m_rootView->setContentView(BuildSpaceViews(m_rootSpace.get())); m_rootView->updateSize(); + m_showSplash = false; +} + +void ViewManager::SetupEditorView(Athena::io::YAMLDocReader& r) +{ + m_rootSpace.reset(Space::NewSpaceFromYAMLStream(*this, r)); + m_rootView->setContentView(BuildSpaceViews(m_rootSpace.get())); + m_rootView->updateSize(); + m_showSplash = false; } ViewManager::ViewManager(HECL::Runtime::FileStoreManager& fileMgr, HECL::CVarManager& cvarMgr) -: m_fileStoreManager(fileMgr), m_cvarManager(cvarMgr), - m_fontCache(fileMgr), m_translator(RUDE::SystemLocaleOrEnglish()), - m_setTo1(*this), m_setTo2(*this), - m_split(*this), - m_space1(*this, "Hello, World!\n\n", "Hello Button", &m_setTo1), - m_space2(*this, "こんにちは世界!\n\n", "こんにちはボタン", &m_setTo2) +: m_fileStoreManager(fileMgr), m_cvarManager(cvarMgr), m_projManager(*this), + m_fontCache(fileMgr), m_translator(RUDE::SystemLocaleOrEnglish()) {} ViewManager::~ViewManager() {} @@ -70,15 +74,12 @@ void ViewManager::init(boo::IApplication* app) m_mainWindow->setWaitCursor(true); float pixelFactor = 1.0; - m_cvPixelFactor = m_cvarManager.newCVar("ed_pixelfactor", "User-selected UI Scale", - pixelFactor, HECL::CVar::EFlags::Editor | HECL::CVar::EFlags::Archive); boo::IGraphicsDataFactory* gf = m_mainWindow->getMainContextDataFactory(); m_viewResources.init(gf, &m_fontCache, Specter::ThemeData(), pixelFactor); m_viewResources.prepFontCacheAsync(m_mainWindow.get()); SetupRootView(); SetupSplashView(); - m_showSplash = true; m_mainWindow->setWaitCursor(false); } @@ -92,16 +93,12 @@ bool ViewManager::proc() { m_viewResources.resetPixelFactor(m_reqPf); SetupRootView(); + if (m_showSplash) + SetupSplashView(); + else + SetupEditorView(); m_updatePf = false; } -#if 0 - if (m_cvPixelFactor->isModified()) - { - float pixelFactor = m_cvPixelFactor->toFloat(); - m_viewResources.resetPixelFactor(pixelFactor); - m_cvPixelFactor->clearModified(); - } -#endif m_rootView->dispatchEvents(); if (m_showSplash) m_splash->think(); diff --git a/Editor/ViewManager.hpp b/Editor/ViewManager.hpp index 2f1d9000f..5a556f41e 100644 --- a/Editor/ViewManager.hpp +++ b/Editor/ViewManager.hpp @@ -11,6 +11,8 @@ class SplashScreen; class ViewManager : public Specter::IViewManager { + friend class ProjectManager; + HECL::Runtime::FileStoreManager& m_fileStoreManager; HECL::CVarManager& m_cvarManager; ProjectManager m_projManager; @@ -18,10 +20,10 @@ class ViewManager : public Specter::IViewManager Specter::ViewResources m_viewResources; Specter::Translator m_translator; std::unique_ptr m_mainWindow; + std::unique_ptr m_rootView; std::unique_ptr m_splash; - - HECL::CVar* m_cvPixelFactor; + std::unique_ptr m_rootSpace; std::vector m_recentProjects; std::vector m_recentFiles; @@ -33,41 +35,11 @@ class ViewManager : public Specter::IViewManager void SetupRootView(); void SetupSplashView(); void SetupEditorView(); + void SetupEditorView(Athena::io::YAMLDocReader& r); bool m_showSplash = false; + public: - struct SetTo1 : Specter::IButtonBinding - { - ViewManager& m_vm; - SetTo1(ViewManager& vm) : m_vm(vm) {} - - const char* name() const {return "SetTo1";} - const char* help() const {return "Sets scale factor to 1.0";} - void activated(const boo::SWindowCoord& coord) - { - m_vm.requestPixelFactor(1.0); - } - }; - SetTo1 m_setTo1; - - struct SetTo2 : Specter::IButtonBinding - { - ViewManager& m_vm; - SetTo2(ViewManager& vm) : m_vm(vm) {} - - const char* name() const {return "SetTo2";} - const char* help() const {return "Sets scale factor to 2.0";} - void activated(const boo::SWindowCoord& coord) - { - m_vm.requestPixelFactor(2.0); - } - }; - SetTo2 m_setTo2; - - SplitSpace m_split; - TestSpace m_space1; - TestSpace m_space2; - ViewManager(HECL::Runtime::FileStoreManager& fileMgr, HECL::CVarManager& cvarMgr); ~ViewManager(); diff --git a/hecl b/hecl index ca39b6420..69bddf2a5 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit ca39b64201938f45b9a8550f057de09d9824d12c +Subproject commit 69bddf2a5fcd05c4c92de4601a1a55409e65ce5c diff --git a/libSpecter b/libSpecter index 7f1ed824a..f7bd80bfe 160000 --- a/libSpecter +++ b/libSpecter @@ -1 +1 @@ -Subproject commit 7f1ed824a6200a6e6478180c8ea729abc758006b +Subproject commit f7bd80bfe01d30456dfbcf2eaa3bf45c80d43a0c