YAML read/write refactor

This commit is contained in:
Jack Andersen 2016-01-03 19:31:02 -10:00
parent 6e242bcf12
commit 5de9028a51
25 changed files with 265 additions and 168 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -80,7 +80,7 @@ void SCLY::ScriptLayer::nameIDs(PAKRouter<PAKBridge>& 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<IScriptObject> 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();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,11 +5,20 @@
namespace RUDE
{
class ViewManager;
class ProjectManager
{
HECL::Database::Project* m_proj = nullptr;
ViewManager& m_vm;
std::unique_ptr<HECL::Database::Project> 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);
};

View File

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

View File

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

View File

@ -15,8 +15,6 @@ namespace RUDE
{
class ViewManager;
struct SpaceState : Athena::io::DNAYaml<Athena::BigEndian> {Delete _d;};
class Space
{
public:
@ -27,42 +25,58 @@ public:
TestSpace,
ResourceOutliner,
};
struct StateHead : Athena::io::DNAYaml<Athena::BigEndian>
{
DECL_YAML
Value<Class> cls;
};
struct State : Athena::io::DNAYaml<Athena::BigEndian> {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<Specter::Space> 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<Space> m_a;
std::unique_ptr<Space> m_b;
std::unique_ptr<Specter::SplitView> m_splitView;
struct State : SpaceState
struct State : Space::State
{
DECL_YAML
Value<float> m_split;
Value<float> 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());

View File

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

View File

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

View File

@ -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<boo::IWindow> m_mainWindow;
std::unique_ptr<Specter::RootView> m_rootView;
std::unique_ptr<SplashScreen> m_splash;
HECL::CVar* m_cvPixelFactor;
std::unique_ptr<Space> m_rootSpace;
std::vector<HECL::SystemString> m_recentProjects;
std::vector<HECL::SystemString> 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();

2
hecl

@ -1 +1 @@
Subproject commit ca39b64201938f45b9a8550f057de09d9824d12c
Subproject commit 69bddf2a5fcd05c4c92de4601a1a55409e65ce5c

@ -1 +1 @@
Subproject commit 7f1ed824a6200a6e6478180c8ea729abc758006b
Subproject commit f7bd80bfe01d30456dfbcf2eaa3bf45c80d43a0c