metaforce/DataSpec/DNAMP3/DNAMP3.cpp

69 lines
1.6 KiB
C++
Raw Normal View History

2015-07-17 00:01:05 +00:00
#include <set>
#define NOD_ATHENA 1
2015-07-16 01:57:34 +00:00
#include "DNAMP3.hpp"
2015-07-17 00:01:05 +00:00
#include "STRG.hpp"
#include "MLVL.hpp"
2015-07-19 06:19:46 +00:00
#include "../DNACommon/TXTR.hpp"
2015-07-16 01:57:34 +00:00
namespace Retro
{
namespace DNAMP3
{
2015-07-17 00:01:05 +00:00
2015-07-16 01:57:34 +00:00
LogVisor::LogModule Log("Retro::DNAMP3");
2015-07-17 00:01:05 +00:00
PAKBridge::PAKBridge(HECL::Database::Project& project, const NOD::DiscBase::IPartition::Node& node)
: m_project(project), m_node(node)
{
NOD::AthenaPartReadStream rs(node.beginReadStream());
m_pak.read(rs);
}
2015-07-19 06:19:46 +00:00
HECL::SystemString PAKBridge::getLevelString() const
2015-07-17 00:01:05 +00:00
{
2015-07-19 06:19:46 +00:00
std::set<HECL::SystemString, CaseInsensitiveCompare> uniq;
2015-07-17 00:01:05 +00:00
for (const PAK::Entry& entry : m_pak.m_entries)
{
if (entry.type == Retro::MLVL)
{
PAKEntryReadStream rs = entry.beginReadStream(m_node);
MLVL mlvl;
mlvl.read(rs);
const PAK::Entry* nameEnt = m_pak.lookupEntry(mlvl.worldNameId);
if (nameEnt)
{
PAKEntryReadStream rs = nameEnt->beginReadStream(m_node);
STRG mlvlName;
mlvlName.read(rs);
2015-07-19 06:19:46 +00:00
uniq.insert(mlvlName.getSystemString(ENGL, 0));
2015-07-17 00:01:05 +00:00
}
}
}
2015-07-19 06:19:46 +00:00
HECL::SystemString retval;
bool comma = false;
2015-07-19 06:19:46 +00:00
for (const HECL::SystemString& str : uniq)
2015-07-17 00:01:05 +00:00
{
if (comma)
2015-07-17 00:01:05 +00:00
retval += _S(", ");
comma = true;
retval += str;
2015-07-17 00:01:05 +00:00
}
return retval;
}
ResExtractor PAKBridge::LookupExtractor(const PAK::Entry& entry)
{
2015-07-19 06:19:46 +00:00
switch (entry.type.toUint32())
{
case SBIG('STRG'):
return {STRG::Extract, ".as"};
2015-07-19 06:19:46 +00:00
case SBIG('TXTR'):
return {TXTR::Extract, ".png"};
}
2015-07-17 00:01:05 +00:00
return {};
}
2015-07-16 01:57:34 +00:00
}
}