metaforce/DataSpec/DNAMP1/SCAN.cpp

78 lines
2.5 KiB
C++
Raw Normal View History

2018-02-22 07:24:51 +00:00
#include "SCAN.hpp"
#include <algorithm>
#include <array>
2018-12-08 05:30:43 +00:00
namespace DataSpec::DNAMP1 {
2018-02-22 07:24:51 +00:00
constexpr std::array PaneNames{
"imagepane_pane0"sv, "imagepane_pane1"sv, "imagepane_pane2"sv, "imagepane_pane3"sv, "imagepane_pane01"sv,
"imagepane_pane12"sv, "imagepane_pane23"sv, "imagepane_pane012"sv, "imagepane_pane123"sv, "imagepane_pane0123"sv,
"imagepane_pane4"sv, "imagepane_pane5"sv, "imagepane_pane6"sv, "imagepane_pane7"sv, "imagepane_pane45"sv,
"imagepane_pane56"sv, "imagepane_pane67"sv, "imagepane_pane456"sv, "imagepane_pane567"sv, "imagepane_pane4567"sv,
};
2018-02-22 07:24:51 +00:00
template <>
2018-12-08 05:30:43 +00:00
void SCAN::Texture::Enumerate<BigDNA::Read>(typename Read::StreamT& r) {
texture.read(r);
appearanceRange = r.readFloatBig();
position = Position(r.readUint32Big());
width = r.readUint32Big();
height = r.readUint32Big();
interval = r.readFloatBig();
fadeDuration = r.readFloatBig();
2018-02-22 07:24:51 +00:00
}
template <>
2018-12-08 05:30:43 +00:00
void SCAN::Texture::Enumerate<BigDNA::Write>(typename Write::StreamT& w) {
texture.write(w);
w.writeFloatBig(appearanceRange);
w.writeUint32Big(atUint32(position));
w.writeUint32Big(width);
w.writeUint32Big(height);
w.writeFloatBig(interval);
w.writeFloatBig(fadeDuration);
2018-02-22 07:24:51 +00:00
}
template <>
2018-12-08 05:30:43 +00:00
void SCAN::Texture::Enumerate<BigDNA::ReadYaml>(typename ReadYaml::StreamT& r) {
r.enumerate("texture", texture);
appearanceRange = r.readFloat("appearanceRange");
std::string tmp = r.readString("position");
2018-02-22 07:24:51 +00:00
2018-12-08 05:30:43 +00:00
auto idx = std::find(PaneNames.begin(), PaneNames.end(), tmp);
if (idx != PaneNames.end())
position = Position(idx - PaneNames.begin());
else
position = Position::Invalid;
2018-02-22 07:24:51 +00:00
2018-12-08 05:30:43 +00:00
width = r.readUint32("width");
height = r.readUint32("height");
interval = r.readFloat("interval");
fadeDuration = r.readFloat("fadeDuration");
2018-02-22 07:24:51 +00:00
}
template <>
2018-12-08 05:30:43 +00:00
void SCAN::Texture::Enumerate<BigDNA::WriteYaml>(typename WriteYaml::StreamT& w) {
w.enumerate("texture", texture);
w.writeFloat("appearanceRange", appearanceRange);
if (position != Position::Invalid)
w.writeString("position", PaneNames.at(atUint32(position)));
else
w.writeString("position", "undefined");
w.writeUint32("width", width);
w.writeUint32("height", height);
w.writeFloat("interval", interval);
w.writeFloat("fadeDuration", fadeDuration);
2018-02-22 07:24:51 +00:00
}
2021-04-10 08:42:06 +00:00
std::string_view SCAN::Texture::DNAType() { return "DNAMP1::SCAN::Texture"sv; }
2018-02-22 07:24:51 +00:00
template <>
2018-12-08 05:30:43 +00:00
void SCAN::Texture::Enumerate<BigDNA::BinarySize>(typename BinarySize::StreamT& s) {
texture.binarySize(s);
s += 24;
2018-02-22 07:24:51 +00:00
}
2018-12-08 05:30:43 +00:00
} // namespace DataSpec::DNAMP1