mirror of
https://github.com/isledecomp/SIEdit.git
synced 2025-04-22 01:23:32 -04:00
lib: add classes for deweaving
This commit is contained in:
parent
b8ee5349bc
commit
09384dbe46
7 changed files with 224 additions and 0 deletions
|
@ -6,8 +6,14 @@ set(LIBWEAVER_SOURCES
|
|||
common.h
|
||||
core.cpp
|
||||
core.h
|
||||
interleaf.cpp
|
||||
interleaf.h
|
||||
object.cpp
|
||||
object.h
|
||||
sitypes.cpp
|
||||
sitypes.h
|
||||
stream.cpp
|
||||
stream.h
|
||||
types.h
|
||||
)
|
||||
|
||||
|
|
49
lib/interleaf.cpp
Normal file
49
lib/interleaf.cpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
#include "interleaf.h"
|
||||
|
||||
namespace si {
|
||||
|
||||
Interleaf::Interleaf()
|
||||
{
|
||||
}
|
||||
|
||||
bool Interleaf::Parse(Chunk *riff)
|
||||
{
|
||||
if (riff->id() != Chunk::TYPE_RIFF) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Chunk *hd = riff->FindChildWithType(Chunk::TYPE_MxHd);
|
||||
if (!hd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
version_ = hd->data("Version");
|
||||
if (version_ == 0) {
|
||||
// Unknown version
|
||||
return false;
|
||||
}
|
||||
|
||||
buffer_size_ = hd->data("BufferSize");
|
||||
buffer_count_ = hd->data("BufferCount");
|
||||
|
||||
Chunk *of = riff->FindChildWithType(Chunk::TYPE_MxOf);
|
||||
if (!of) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const Data &offset_table = of->data("Offsets");
|
||||
size_t offset_count = offset_table.size() / sizeof(uint32_t);
|
||||
DeleteChildren();
|
||||
for (size_t i=0; i<offset_count; i++) {
|
||||
Stream *o = new Stream();
|
||||
Chunk *st = riff->FindChildWithOffset(offset_table[i]);
|
||||
if (!o->Parse(st)) {
|
||||
return false;
|
||||
}
|
||||
AppendChild(o);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
26
lib/interleaf.h
Normal file
26
lib/interleaf.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef INTERLEAF_H
|
||||
#define INTERLEAF_H
|
||||
|
||||
#include "chunk.h"
|
||||
#include "core.h"
|
||||
#include "stream.h"
|
||||
|
||||
namespace si {
|
||||
|
||||
class Interleaf : public Core
|
||||
{
|
||||
public:
|
||||
LIBWEAVER_EXPORT Interleaf();
|
||||
|
||||
LIBWEAVER_EXPORT bool Parse(Chunk *riff);
|
||||
|
||||
private:
|
||||
uint32_t version_;
|
||||
uint32_t buffer_size_;
|
||||
uint32_t buffer_count_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // INTERLEAF_H
|
37
lib/object.cpp
Normal file
37
lib/object.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
#include "object.h"
|
||||
|
||||
namespace si {
|
||||
|
||||
Object::Object()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool Object::Parse(Chunk *chunk)
|
||||
{
|
||||
type_ = static_cast<MxOb::Type>(chunk->data("Type").toU16());
|
||||
presenter_ = chunk->data("Presenter").toString();
|
||||
unknown1_ = chunk->data("Unknown1");
|
||||
name_ = chunk->data("Name").toString();
|
||||
id_ = chunk->data("ID");
|
||||
flags_ = chunk->data("Flags");
|
||||
unknown4_ = chunk->data("Unknown4");
|
||||
duration_ = chunk->data("Duration");
|
||||
loops_ = chunk->data("Loops");
|
||||
position_ = chunk->data("Position");
|
||||
direction_ = chunk->data("Direction");
|
||||
up_ = chunk->data("Up");
|
||||
extra_ = chunk->data("ExtraData");
|
||||
filename_ = chunk->data("FileName").toString();
|
||||
unknown26_ = chunk->data("Unknown26");
|
||||
unknown27_ = chunk->data("Unknown27");
|
||||
unknown28_ = chunk->data("Unknown28");
|
||||
filetype_ = chunk->data("FileType");
|
||||
unknown29_ = chunk->data("Unknown29");
|
||||
unknown30_ = chunk->data("Unknown30");
|
||||
unknown31_ = chunk->data("Unknown31");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
51
lib/object.h
Normal file
51
lib/object.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
#ifndef OBJECT_H
|
||||
#define OBJECT_H
|
||||
|
||||
#include "chunk.h"
|
||||
#include "core.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace si {
|
||||
|
||||
class Object : public Core
|
||||
{
|
||||
public:
|
||||
Object();
|
||||
|
||||
bool Parse(Chunk *chunk);
|
||||
|
||||
bytearray &data()
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
private:
|
||||
MxOb::Type type_;
|
||||
std::string presenter_;
|
||||
uint32_t unknown1_;
|
||||
std::string name_;
|
||||
uint32_t id_;
|
||||
uint32_t flags_;
|
||||
uint32_t unknown4_;
|
||||
uint32_t duration_;
|
||||
uint32_t loops_;
|
||||
Vector3 position_;
|
||||
Vector3 direction_;
|
||||
Vector3 up_;
|
||||
bytearray extra_;
|
||||
std::string filename_;
|
||||
uint32_t unknown26_;
|
||||
uint32_t unknown27_;
|
||||
uint32_t unknown28_;
|
||||
uint32_t filetype_;
|
||||
uint32_t unknown29_;
|
||||
uint32_t unknown30_;
|
||||
uint32_t unknown31_;
|
||||
|
||||
bytearray data_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OBJECT_H
|
33
lib/stream.cpp
Normal file
33
lib/stream.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include "stream.h"
|
||||
|
||||
#include "object.h"
|
||||
|
||||
namespace si {
|
||||
|
||||
Stream::Stream()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool Stream::Parse(Chunk *chunk)
|
||||
{
|
||||
if (chunk->type() != Chunk::TYPE_MxSt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Chunk *obj_chunk = chunk->FindChildWithType(Chunk::TYPE_MxOb);
|
||||
if (!obj_chunk) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Object *obj = new Object();
|
||||
if (!obj->Parse(obj_chunk)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIXME: Read MxCh into Objects
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
22
lib/stream.h
Normal file
22
lib/stream.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef STREAM_H
|
||||
#define STREAM_H
|
||||
|
||||
#include "chunk.h"
|
||||
#include "core.h"
|
||||
|
||||
namespace si {
|
||||
|
||||
class Stream : public Core
|
||||
{
|
||||
public:
|
||||
Stream();
|
||||
|
||||
bool Parse(Chunk *chunk);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // STREAM_H
|
Loading…
Add table
Add a link
Reference in a new issue