mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-07 09:25:52 +00:00
Code cleanup and add NamedResourceCatalog
This commit is contained in:
parent
5229f95fb7
commit
8af98fb2f3
@ -21,6 +21,7 @@ add_library(DNACommon
|
|||||||
ParticleCommon.cpp
|
ParticleCommon.cpp
|
||||||
DeafBabe.hpp
|
DeafBabe.hpp
|
||||||
BabeDead.hpp
|
BabeDead.hpp
|
||||||
|
NamedResourceCatalog.hpp
|
||||||
Tweaks/ITweakGame.hpp
|
Tweaks/ITweakGame.hpp
|
||||||
Tweaks/ITweakParticle.hpp
|
Tweaks/ITweakParticle.hpp
|
||||||
Tweaks/ITweakPlayer.hpp
|
Tweaks/ITweakPlayer.hpp
|
||||||
|
132
DataSpec/DNACommon/NamedResourceCatalog.hpp
Normal file
132
DataSpec/DNACommon/NamedResourceCatalog.hpp
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
#ifndef __DNACOMMON_NAMEDRESOURCECATALOG_HPP__
|
||||||
|
#define __DNACOMMON_NAMEDRESOURCECATALOG_HPP__
|
||||||
|
|
||||||
|
#include "DNACommon.hpp"
|
||||||
|
namespace DataSpec
|
||||||
|
{
|
||||||
|
template <class IDType>
|
||||||
|
struct NamedResourceCatalog : BigYAML
|
||||||
|
{
|
||||||
|
Delete _d;
|
||||||
|
Value<atUint32> namedResCount;
|
||||||
|
struct NamedResource : BigYAML
|
||||||
|
{
|
||||||
|
Delete _d;
|
||||||
|
DNAFourCC type;
|
||||||
|
String<-1> name;
|
||||||
|
IDType uid;
|
||||||
|
|
||||||
|
void read(Athena::io::IStreamReader& __dna_reader)
|
||||||
|
{
|
||||||
|
/* type */
|
||||||
|
type.read(__dna_reader);
|
||||||
|
/* name */
|
||||||
|
name = __dna_reader.readString(-1);
|
||||||
|
/* uid */
|
||||||
|
uid.read(__dna_reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
void write(Athena::io::IStreamWriter& __dna_writer) const
|
||||||
|
{
|
||||||
|
/* type */
|
||||||
|
type.write(__dna_writer);
|
||||||
|
/* name */
|
||||||
|
__dna_writer.writeString(name, -1);
|
||||||
|
/* uid */
|
||||||
|
uid.write(__dna_writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void read(Athena::io::YAMLDocReader& __dna_docin)
|
||||||
|
{
|
||||||
|
/* type */
|
||||||
|
__dna_docin.enumerate("type", type);
|
||||||
|
/* name */
|
||||||
|
name = __dna_docin.readString("name");
|
||||||
|
/* uid */
|
||||||
|
__dna_docin.enumerate("uid", uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void write(Athena::io::YAMLDocWriter& __dna_docout) const
|
||||||
|
{
|
||||||
|
/* type */
|
||||||
|
__dna_docout.enumerate("type", type);
|
||||||
|
/* name */
|
||||||
|
__dna_docout.writeString("name", name);
|
||||||
|
/* uid */
|
||||||
|
__dna_docout.enumerate("uid", uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* DNAType() { return "DataSpec::DNACommon::NameResourceCatalog::NamedResource"; }
|
||||||
|
|
||||||
|
size_t binarySize(size_t __isz) const
|
||||||
|
{
|
||||||
|
__isz = type.binarySize(__isz);
|
||||||
|
__isz += name.size() + 1;
|
||||||
|
__isz = uid.binarySize(__isz);
|
||||||
|
return __isz;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Vector<NamedResource, DNA_COUNT(namedResCount)> namedResources;
|
||||||
|
|
||||||
|
void read(Athena::io::IStreamReader& __dna_reader)
|
||||||
|
{
|
||||||
|
/* namedResCount */
|
||||||
|
namedResCount = __dna_reader.readUint32Big();
|
||||||
|
/* namedResources */
|
||||||
|
__dna_reader.enumerate(namedResources, namedResCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
void write(Athena::io::IStreamWriter& __dna_writer) const
|
||||||
|
{
|
||||||
|
/* namedResCount */
|
||||||
|
__dna_writer.writeUint32Big(namedResCount);
|
||||||
|
/* namedResources */
|
||||||
|
__dna_writer.enumerate(namedResources);
|
||||||
|
}
|
||||||
|
|
||||||
|
void read(Athena::io::YAMLDocReader& __dna_docin)
|
||||||
|
{
|
||||||
|
/* namedResCount */
|
||||||
|
namedResCount = __dna_docin.readUint32("namedResCount");
|
||||||
|
/* namedResources */
|
||||||
|
__dna_docin.enumerate("namedResources", namedResources, namedResCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
void write(Athena::io::YAMLDocWriter& __dna_docout) const
|
||||||
|
{
|
||||||
|
/* namedResCount */
|
||||||
|
__dna_docout.writeUint32("namedResCount", namedResCount);
|
||||||
|
/* namedResources */
|
||||||
|
__dna_docout.enumerate("namedResources", namedResources);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* DNAType()
|
||||||
|
{
|
||||||
|
return "DataSpec::DNACommon::NameResourceCatalog";
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t binarySize(size_t __isz) const
|
||||||
|
{
|
||||||
|
__isz = __EnumerateSize(__isz, namedResources);
|
||||||
|
return __isz + 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addNamedResource(const std::string& name, const IDType& id, const DNAFourCC& type)
|
||||||
|
{
|
||||||
|
NamedResource res;
|
||||||
|
res.type = type;
|
||||||
|
res.name = name;
|
||||||
|
res.uid = id;
|
||||||
|
auto it = std::find_if(namedResources.begin(), namedResources.end(), [res](const NamedResource& a)->bool
|
||||||
|
{ return (a.name == res.name && a.type == res.type && a.uid == res.uid); });
|
||||||
|
|
||||||
|
if (it != namedResources.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
namedResources.push_back(std::move(res));
|
||||||
|
namedResCount++;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // NAMEDRESOURCECATALOG_HPP
|
@ -2,6 +2,7 @@
|
|||||||
#define __DNACOMMON_PAK_HPP__
|
#define __DNACOMMON_PAK_HPP__
|
||||||
|
|
||||||
#include "DNACommon.hpp"
|
#include "DNACommon.hpp"
|
||||||
|
#include "NamedResourceCatalog.hpp"
|
||||||
|
|
||||||
namespace DataSpec
|
namespace DataSpec
|
||||||
{
|
{
|
||||||
@ -240,6 +241,7 @@ public:
|
|||||||
using EntryType = typename PAKType::Entry;
|
using EntryType = typename PAKType::Entry;
|
||||||
using RigPair = std::pair<IDType, IDType>;
|
using RigPair = std::pair<IDType, IDType>;
|
||||||
private:
|
private:
|
||||||
|
NamedResourceCatalog<IDType> m_catalog;
|
||||||
const SpecBase& m_dataSpec;
|
const SpecBase& m_dataSpec;
|
||||||
const std::vector<BRIDGETYPE>* m_bridges = nullptr;
|
const std::vector<BRIDGETYPE>* m_bridges = nullptr;
|
||||||
std::vector<std::pair<HECL::ProjectPath,HECL::ProjectPath>> m_bridgePaths;
|
std::vector<std::pair<HECL::ProjectPath,HECL::ProjectPath>> m_bridgePaths;
|
||||||
@ -309,9 +311,21 @@ public:
|
|||||||
/* Add RigPairs to global map */
|
/* Add RigPairs to global map */
|
||||||
bridge.addCMDLRigPairs(*this, m_cmdlRigs);
|
bridge.addCMDLRigPairs(*this, m_cmdlRigs);
|
||||||
|
|
||||||
|
/* Add named resources to catalog */
|
||||||
|
for (const auto& namedEntry : pak.m_nameEntries)
|
||||||
|
m_catalog.addNamedResource(namedEntry.name, namedEntry.id, namedEntry.type);
|
||||||
|
|
||||||
progress(++count / bridgesSz);
|
progress(++count / bridgesSz);
|
||||||
++bridgeIdx;
|
++bridgeIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HECL::SystemString catalogPath = m_gameCooked.getAbsolutePath() + _S("/catalog.yaml");
|
||||||
|
FILE* catalog = HECL::Fopen(catalogPath.c_str(), _S("wb"));
|
||||||
|
if (catalog)
|
||||||
|
{
|
||||||
|
m_catalog.toYAMLFile(catalog);
|
||||||
|
fclose(catalog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void enterPAKBridge(const BRIDGETYPE& pakBridge)
|
void enterPAKBridge(const BRIDGETYPE& pakBridge)
|
||||||
|
@ -25,6 +25,13 @@ class CInputGenerator : public boo::DeviceFinder
|
|||||||
float m_leftDiv;
|
float m_leftDiv;
|
||||||
float m_rightDiv;
|
float m_rightDiv;
|
||||||
CKeyboardMouseControllerData m_data;
|
CKeyboardMouseControllerData m_data;
|
||||||
|
|
||||||
|
CFinalInput m_lastUpdate;
|
||||||
|
const CFinalInput& getFinalInput(unsigned idx, float dt)
|
||||||
|
{
|
||||||
|
m_lastUpdate = CFinalInput(idx, dt, m_data, m_lastUpdate);
|
||||||
|
return m_lastUpdate;
|
||||||
|
}
|
||||||
public:
|
public:
|
||||||
CInputGenerator(float leftDiv, float rightDiv)
|
CInputGenerator(float leftDiv, float rightDiv)
|
||||||
: boo::DeviceFinder({typeid(boo::DolphinSmashAdapter)}),
|
: boo::DeviceFinder({typeid(boo::DolphinSmashAdapter)}),
|
||||||
@ -90,13 +97,6 @@ public:
|
|||||||
m_data.m_accumScroll.zeroOut();
|
m_data.m_accumScroll.zeroOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
CFinalInput m_lastUpdate;
|
|
||||||
const CFinalInput& getFinalInput(unsigned idx, float dt)
|
|
||||||
{
|
|
||||||
m_lastUpdate = CFinalInput(idx, dt, m_data, m_lastUpdate);
|
|
||||||
return m_lastUpdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Input via the smash adapter is received asynchronously on a USB
|
/* Input via the smash adapter is received asynchronously on a USB
|
||||||
* report thread. This class atomically exchanges that data to the
|
* report thread. This class atomically exchanges that data to the
|
||||||
* game thread as needed */
|
* game thread as needed */
|
||||||
|
@ -225,10 +225,6 @@ int CMain::appMain(boo::IApplication* app)
|
|||||||
float rgba[4] = { 0.2f, 0.2f, 0.2f, 1.0f};
|
float rgba[4] = { 0.2f, 0.2f, 0.2f, 1.0f};
|
||||||
gfxQ->setClearColor(rgba);
|
gfxQ->setClearColor(rgba);
|
||||||
|
|
||||||
float time = 0.0f;
|
|
||||||
int frame = 0;
|
|
||||||
CTimeProvider test(time);
|
|
||||||
|
|
||||||
while (!xe8_b24_finished)
|
while (!xe8_b24_finished)
|
||||||
{
|
{
|
||||||
mainWindow->waitForRetrace();
|
mainWindow->waitForRetrace();
|
||||||
@ -237,9 +233,6 @@ int CMain::appMain(boo::IApplication* app)
|
|||||||
|
|
||||||
gfxQ->resolveDisplay(nullptr);
|
gfxQ->resolveDisplay(nullptr);
|
||||||
gfxQ->execute();
|
gfxQ->execute();
|
||||||
|
|
||||||
time = (frame++) / 60.f;
|
|
||||||
//fprintf(stderr, "%f\n", test.x0_currentTime);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user