2015-09-24 07:47:30 +00:00
|
|
|
#ifndef _DNAMP1_SCAN_HPP_
|
|
|
|
#define _DNAMP1_SCAN_HPP_
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
#include <athena/FileWriter.hpp>
|
2015-09-24 07:47:30 +00:00
|
|
|
#include "../DNACommon/DNACommon.hpp"
|
|
|
|
#include "DNAMP1.hpp"
|
|
|
|
|
2016-02-13 09:02:47 +00:00
|
|
|
namespace DataSpec
|
2015-09-24 07:47:30 +00:00
|
|
|
{
|
|
|
|
namespace DNAMP1
|
|
|
|
{
|
2015-11-19 13:16:15 +00:00
|
|
|
static const std::vector<std::string> PaneNames =
|
|
|
|
{
|
2016-01-10 22:27:59 +00:00
|
|
|
"imagepane_pane0", "imagepane_pane1", "imagepane_pane2", "imagepane_pane3", "imagepane_pane01",
|
|
|
|
"imagepane_pane12", "imagepane_pane23", "imagepane_pane012", "imagepane_pane123", "imagepane_pane0123",
|
|
|
|
"imagepane_pane4", "imagepane_pane5", "imagepane_pane6", "imagepane_pane7", "imagepane_pane45",
|
|
|
|
"imagepane_pane56", "imagepane_pane67", "imagepane_pane456", "imagepane_pane567", "imagepane_pane4567"
|
2015-11-19 13:16:15 +00:00
|
|
|
};
|
|
|
|
|
2015-09-24 07:47:30 +00:00
|
|
|
struct SCAN : BigYAML
|
|
|
|
{
|
|
|
|
DECL_YAML
|
|
|
|
Value<atUint32> version;
|
|
|
|
Value<atUint32> magic;
|
|
|
|
UniqueID32 frame;
|
|
|
|
UniqueID32 string;
|
|
|
|
|
2015-11-21 01:16:07 +00:00
|
|
|
enum class ScanSpeed : atUint32
|
2015-09-24 07:47:30 +00:00
|
|
|
{ Normal, Slow };
|
|
|
|
Value<ScanSpeed> scanSpeed;
|
|
|
|
|
2015-11-21 01:16:07 +00:00
|
|
|
enum class Category : atUint32
|
2015-09-24 07:47:30 +00:00
|
|
|
{
|
|
|
|
None,
|
|
|
|
SpacePirateData,
|
|
|
|
ChozoLore,
|
|
|
|
Creatures,
|
|
|
|
Research
|
|
|
|
};
|
|
|
|
|
|
|
|
Value<Category> category;
|
|
|
|
|
|
|
|
Value<bool> isImportant;
|
|
|
|
|
|
|
|
struct Texture : BigYAML
|
|
|
|
{
|
2015-11-19 13:16:15 +00:00
|
|
|
Delete __delete;
|
2015-09-24 07:47:30 +00:00
|
|
|
UniqueID32 texture;
|
|
|
|
Value<float> appearanceRange;
|
2015-11-21 01:16:07 +00:00
|
|
|
enum class Position : atInt32
|
2015-09-24 07:47:30 +00:00
|
|
|
{
|
2016-01-10 22:27:59 +00:00
|
|
|
Pane0, Pane1, Pane2, Pane3, Pane01, Pane12, Pane23, Pane012,
|
|
|
|
Pane123, Pane0123, Pane4, Pane5, Pane6, Pane7, Pane45, Pane56,
|
|
|
|
Pane67, Pane456, Pane567, Pane4567, Invalid = -1
|
2015-09-24 07:47:30 +00:00
|
|
|
};
|
|
|
|
Value<Position> position;
|
2015-10-15 23:42:39 +00:00
|
|
|
Value<atUint32> width; // width of animation cell
|
|
|
|
Value<atUint32> height; // height of animation cell
|
|
|
|
Value<float> interval; // 0.0 - 1.0
|
|
|
|
Value<float> fadeDuration; // 0.0 - 1.0
|
2015-11-19 13:16:15 +00:00
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void read(athena::io::IStreamReader& __dna_reader)
|
2015-11-19 13:16:15 +00:00
|
|
|
{
|
|
|
|
/* texture */
|
|
|
|
texture.read(__dna_reader);
|
|
|
|
/* appearanceRange */
|
|
|
|
appearanceRange = __dna_reader.readFloatBig();
|
|
|
|
/* position */
|
2015-11-21 01:23:55 +00:00
|
|
|
position = Position(__dna_reader.readUint32Big());
|
2015-11-19 13:16:15 +00:00
|
|
|
/* width */
|
|
|
|
width = __dna_reader.readUint32Big();
|
|
|
|
/* height */
|
|
|
|
height = __dna_reader.readUint32Big();
|
|
|
|
/* interval */
|
|
|
|
interval = __dna_reader.readFloatBig();
|
|
|
|
/* fadeDuration */
|
|
|
|
fadeDuration = __dna_reader.readFloatBig();
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void write(athena::io::IStreamWriter& __dna_writer) const
|
2015-11-19 13:16:15 +00:00
|
|
|
{
|
|
|
|
/* texture */
|
|
|
|
texture.write(__dna_writer);
|
|
|
|
/* appearanceRange */
|
|
|
|
__dna_writer.writeFloatBig(appearanceRange);
|
|
|
|
/* position */
|
2015-11-21 01:23:55 +00:00
|
|
|
__dna_writer.writeUint32Big(atUint32(position));
|
2015-11-19 13:16:15 +00:00
|
|
|
/* width */
|
|
|
|
__dna_writer.writeUint32Big(width);
|
|
|
|
/* height */
|
|
|
|
__dna_writer.writeUint32Big(height);
|
|
|
|
/* interval */
|
|
|
|
__dna_writer.writeFloatBig(interval);
|
|
|
|
/* fadeDuration */
|
|
|
|
__dna_writer.writeFloatBig(fadeDuration);
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void read(athena::io::YAMLDocReader& __dna_docin)
|
2015-11-19 13:16:15 +00:00
|
|
|
{
|
|
|
|
/* texture */
|
|
|
|
__dna_docin.enumerate("texture", texture);
|
|
|
|
/* appearanceRange */
|
|
|
|
appearanceRange = __dna_docin.readFloat("appearanceRange");
|
|
|
|
/* position */
|
|
|
|
std::string tmp = __dna_docin.readString("position");
|
|
|
|
|
|
|
|
auto idx = std::find(PaneNames.begin(), PaneNames.end(), tmp);
|
|
|
|
if (idx != PaneNames.end())
|
2015-11-21 01:23:55 +00:00
|
|
|
position = Position(idx - PaneNames.begin());
|
2015-11-19 13:16:15 +00:00
|
|
|
else
|
2015-11-21 01:23:55 +00:00
|
|
|
position = Position::Invalid;
|
2015-11-19 13:16:15 +00:00
|
|
|
|
|
|
|
/* width */
|
|
|
|
width = __dna_docin.readUint32("width");
|
|
|
|
/* height */
|
|
|
|
height = __dna_docin.readUint32("height");
|
|
|
|
/* interval */
|
|
|
|
interval = __dna_docin.readFloat("interval");
|
|
|
|
/* fadeDuration */
|
|
|
|
fadeDuration = __dna_docin.readFloat("fadeDuration");
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void write(athena::io::YAMLDocWriter& __dna_docout) const
|
2015-11-19 13:16:15 +00:00
|
|
|
{
|
|
|
|
/* texture */
|
|
|
|
__dna_docout.enumerate("texture", texture);
|
|
|
|
/* appearanceRange */
|
|
|
|
__dna_docout.writeFloat("appearanceRange", appearanceRange);
|
|
|
|
/* position */
|
2015-11-21 01:23:55 +00:00
|
|
|
if (position != Position::Invalid)
|
|
|
|
__dna_docout.writeString("position", PaneNames.at(atUint32(position)));
|
2015-11-19 13:16:15 +00:00
|
|
|
else
|
|
|
|
__dna_docout.writeString("position", "undefined");
|
|
|
|
/* width */
|
|
|
|
__dna_docout.writeUint32("width", width);
|
|
|
|
/* height */
|
|
|
|
__dna_docout.writeUint32("height", height);
|
|
|
|
/* interval */
|
|
|
|
__dna_docout.writeFloat("interval", interval);
|
|
|
|
/* fadeDuration */
|
|
|
|
__dna_docout.writeFloat("fadeDuration", fadeDuration);
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
const char* DNAType() { return "urde::DNAMP1::SCAN::Texture"; }
|
2015-11-19 13:16:15 +00:00
|
|
|
size_t binarySize(size_t __isz) const
|
|
|
|
{
|
|
|
|
__isz = texture.binarySize(__isz);
|
|
|
|
return __isz + 24;
|
|
|
|
}
|
|
|
|
|
2015-09-24 07:47:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Texture textures[4];
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
static bool Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
|
2015-09-24 07:47:30 +00:00
|
|
|
{
|
|
|
|
SCAN scan;
|
|
|
|
scan.read(rs);
|
2016-03-04 23:04:53 +00:00
|
|
|
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("wb"));
|
2015-09-24 07:47:30 +00:00
|
|
|
scan.toYAMLFile(fp);
|
|
|
|
fclose(fp);
|
|
|
|
return true;
|
|
|
|
}
|
2015-10-27 00:19:03 +00:00
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
static bool Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath)
|
2016-01-05 00:48:10 +00:00
|
|
|
{
|
|
|
|
SCAN scan;
|
2016-03-04 23:04:53 +00:00
|
|
|
FILE* fp = hecl::Fopen(inPath.getAbsolutePath().c_str(), _S("rb"));
|
2016-01-05 00:48:10 +00:00
|
|
|
scan.fromYAMLFile(fp);
|
|
|
|
fclose(fp);
|
2016-03-04 23:04:53 +00:00
|
|
|
athena::io::FileWriter ws(outPath.getAbsolutePath());
|
2016-01-05 00:48:10 +00:00
|
|
|
scan.write(ws);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-10-27 00:19:03 +00:00
|
|
|
static void Name(const SpecBase& dataSpec,
|
|
|
|
PAKEntryReadStream& rs,
|
|
|
|
PAKRouter<PAKBridge>& pakRouter,
|
|
|
|
PAK::Entry& entry)
|
|
|
|
{
|
|
|
|
SCAN scan;
|
|
|
|
scan.read(rs);
|
|
|
|
if (scan.string)
|
|
|
|
{
|
|
|
|
PAK::Entry* ent = (PAK::Entry*)pakRouter.lookupEntry(scan.string);
|
2016-03-04 23:04:53 +00:00
|
|
|
ent->name = hecl::Format("SCAN_%s_strg", entry.id.toString().c_str());
|
2015-10-27 00:19:03 +00:00
|
|
|
}
|
|
|
|
for (int i=0 ; i<4 ; ++i)
|
|
|
|
{
|
|
|
|
const Texture& tex = scan.textures[i];
|
|
|
|
if (tex.texture)
|
|
|
|
{
|
|
|
|
PAK::Entry* ent = (PAK::Entry*)pakRouter.lookupEntry(tex.texture);
|
2016-03-04 23:04:53 +00:00
|
|
|
ent->name = hecl::Format("SCAN_%s_tex%d", entry.id.toString().c_str(), i+1);
|
2015-10-27 00:19:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-09-24 07:47:30 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|