Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource refactory #15

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions OTRExporter/AnimationExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ void OTRExporter_Animation::Save(ZResource* res, const fs::path& outPath, Binary
{
ZAnimation* anim = (ZAnimation*)res;

WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Animation);
WriteHeader(res, outPath, writer, static_cast<uint32_t>(SOH::ResourceType::SOH_Animation));

ZNormalAnimation* normalAnim = dynamic_cast<ZNormalAnimation*>(anim);
ZCurveAnimation* curveAnim = dynamic_cast<ZCurveAnimation*>(anim);
ZLinkAnimation* linkAnim = dynamic_cast<ZLinkAnimation*>(anim);
if (linkAnim != nullptr)
{
writer->Write((uint32_t)LUS::AnimationType::Link);
writer->Write((uint32_t)SOH::AnimationType::Link);
writer->Write((uint16_t)linkAnim->frameCount);
writer->Write((uint32_t)linkAnim->segmentAddress);
}
else if (curveAnim != nullptr)
{
writer->Write((uint32_t)LUS::AnimationType::Curve);
writer->Write((uint32_t)SOH::AnimationType::Curve);
writer->Write((uint16_t)curveAnim->frameCount);

writer->Write((uint32_t)curveAnim->refIndexArr.size());
Expand All @@ -44,7 +44,7 @@ void OTRExporter_Animation::Save(ZResource* res, const fs::path& outPath, Binary
}
else if (normalAnim != nullptr)
{
writer->Write((uint32_t)LUS::AnimationType::Normal);
writer->Write((uint32_t)SOH::AnimationType::Normal);
writer->Write((uint16_t)normalAnim->frameCount);

writer->Write((uint32_t)normalAnim->rotationValues.size());
Expand All @@ -65,6 +65,6 @@ void OTRExporter_Animation::Save(ZResource* res, const fs::path& outPath, Binary
}
else
{
writer->Write((uint32_t)LUS::AnimationType::Legacy);
writer->Write((uint32_t)SOH::AnimationType::Legacy);
}
}
2 changes: 1 addition & 1 deletion OTRExporter/ArrayExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ void OTRExporter_Array::Save(ZResource* res, const fs::path& outPath, BinaryWrit
{
ZArray* arr = (ZArray*)res;

WriteHeader(res, outPath, writer, LUS::ResourceType::Array);
WriteHeader(res, outPath, writer, static_cast<uint32_t>(LUS::ResourceType::Array));

writer->Write((uint32_t)arr->resList[0]->GetResourceType());
writer->Write((uint32_t)arr->arrayCnt);
Expand Down
8 changes: 4 additions & 4 deletions OTRExporter/AudioExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void OTRExporter_Audio::WriteSampleEntryReference(ZAudio* audio, SampleEntry* en

void OTRExporter_Audio::WriteSampleEntry(SampleEntry* entry, BinaryWriter* writer)
{
WriteHeader(nullptr, "", writer, LUS::ResourceType::SOH_AudioSample, 2);
WriteHeader(nullptr, "", writer, static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSample), 2);

writer->Write(entry->codec);
writer->Write(entry->medium);
Expand Down Expand Up @@ -81,7 +81,7 @@ void OTRExporter_Audio::Save(ZResource* res, const fs::path& outPath, BinaryWrit
{
ZAudio* audio = (ZAudio*)res;

WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Audio, 2);
WriteHeader(res, outPath, writer, static_cast<uint32_t>(SOH::ResourceType::SOH_Audio), 2);

// Write Samples as individual files
for (auto pair : audio->samples)
Expand Down Expand Up @@ -114,7 +114,7 @@ void OTRExporter_Audio::Save(ZResource* res, const fs::path& outPath, BinaryWrit
MemoryStream* fntStream = new MemoryStream();
BinaryWriter fntWriter = BinaryWriter(fntStream);

WriteHeader(nullptr, "", &fntWriter, LUS::ResourceType::SOH_AudioSoundFont, 2);
WriteHeader(nullptr, "", &fntWriter, static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSoundFont), 2);

fntWriter.Write((uint32_t)i);
fntWriter.Write(audio->soundFontTable[i].medium);
Expand Down Expand Up @@ -173,7 +173,7 @@ void OTRExporter_Audio::Save(ZResource* res, const fs::path& outPath, BinaryWrit
MemoryStream* seqStream = new MemoryStream();
BinaryWriter seqWriter = BinaryWriter(seqStream);

WriteHeader(nullptr, "", &seqWriter, LUS::ResourceType::SOH_AudioSequence, 2);
WriteHeader(nullptr, "", &seqWriter, static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSequence), 2);

seqWriter.Write((uint32_t)seq.size());
seqWriter.Write(seq.data(), seq.size());
Expand Down
2 changes: 1 addition & 1 deletion OTRExporter/BackgroundExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ void OTRExporter_Background::Save(ZResource* res, const fs::path& outPath, Binar
{
ZBackground* bg = (ZBackground*)res;

WriteHeader(bg, outPath, writer, LUS::ResourceType::SOH_Background);
WriteHeader(bg, outPath, writer, static_cast<uint32_t>(SOH::ResourceType::SOH_Background));

writer->Write((uint32_t)bg->GetRawDataSize());

Expand Down
2 changes: 1 addition & 1 deletion OTRExporter/BlobExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ void OTRExporter_Blob::Save(ZResource* res, const fs::path& outPath, BinaryWrite
{
ZBlob* blob = (ZBlob*)res;

WriteHeader(blob, outPath, writer, LUS::ResourceType::Blob);
WriteHeader(blob, outPath, writer, static_cast<uint32_t>(LUS::ResourceType::Blob));

auto start = std::chrono::steady_clock::now();

Expand Down
2 changes: 1 addition & 1 deletion OTRExporter/CollisionExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ void OTRExporter_Collision::Save(ZResource* res, const fs::path& outPath, Binary
{
ZCollisionHeader* col = (ZCollisionHeader*)res;

WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_CollisionHeader);
WriteHeader(res, outPath, writer, static_cast<uint32_t>(SOH::ResourceType::SOH_CollisionHeader));

writer->Write(col->absMinX);
writer->Write(col->absMinY);
Expand Down
2 changes: 1 addition & 1 deletion OTRExporter/CutsceneExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ void OTRExporter_Cutscene::Save(ZResource* res, const fs::path& outPath, BinaryW
{
ZCutscene* cs = (ZCutscene*)res;

WriteHeader(cs, outPath, writer, LUS::ResourceType::SOH_Cutscene);
WriteHeader(cs, outPath, writer, static_cast<uint32_t>(SOH::ResourceType::SOH_Cutscene));

writer->Write((uint32_t)0);

Expand Down
4 changes: 2 additions & 2 deletions OTRExporter/DisplayListExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina

//printf("Exporting DList %s\n", dList->GetName().c_str());

WriteHeader(res, outPath, writer, LUS::ResourceType::DisplayList);
WriteHeader(res, outPath, writer, static_cast<uint32_t>(LUS::ResourceType::DisplayList));

while (writer->GetBaseAddress() % 8 != 0)
writer->Write((uint8_t)0xFF);
Expand Down Expand Up @@ -787,7 +787,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
}

// OTRTODO: Once we aren't relying on text representations, we should call ArrayExporter...
OTRExporter::WriteHeader(nullptr, "", &vtxWriter, LUS::ResourceType::Array);
OTRExporter::WriteHeader(nullptr, "", &vtxWriter, static_cast<uint32_t>(LUS::ResourceType::Array));

vtxWriter.Write((uint32_t)ZResourceType::Vertex);
vtxWriter.Write((uint32_t)arrCnt);
Expand Down
2 changes: 1 addition & 1 deletion OTRExporter/Exporter.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "Exporter.h"
#include "VersionInfo.h"

void OTRExporter::WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, LUS::ResourceType resType, int32_t resVersion)
void OTRExporter::WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, uint32_t resType, int32_t resVersion)
{
writer->Write((uint8_t)Endianness::Little); // 0x00
writer->Write((uint8_t)0); // 0x01
Expand Down
6 changes: 3 additions & 3 deletions OTRExporter/Exporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#include "ZResource.h"
#include "ZArray.h"
#include "stdint.h"
//#include "OTRExporter.h"
#include <Utils/BinaryWriter.h>
#include <libultraship/bridge.h>
#include "VersionInfo.h"
#include "../../soh/soh/resource/type/SohResourceType.h"

class OTRExporter : public ZResourceExporter
{
protected:
static void WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, LUS::ResourceType resType, int32_t resVersion = 0);
};
static void WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, uint32_t resType, int32_t resVersion = 0);
};
2 changes: 1 addition & 1 deletion OTRExporter/MtxExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ void OTRExporter_MtxExporter::Save(ZResource* res, const fs::path& outPath, Bina
{
ZMtx* mtx = (ZMtx*)res;

WriteHeader(res, outPath, writer, LUS::ResourceType::Matrix);
WriteHeader(res, outPath, writer, static_cast<uint32_t>(LUS::ResourceType::Matrix));

for (size_t i = 0; i < 4; i++)
for (size_t j = 0; j < 4; j++)
Expand Down
2 changes: 1 addition & 1 deletion OTRExporter/PathExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ void OTRExporter_Path::Save(ZResource* res, const fs::path& outPath, BinaryWrite
{
ZPath* path = (ZPath*)res;

WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Path);
WriteHeader(res, outPath, writer, static_cast<uint32_t>(SOH::ResourceType::SOH_Path));

writer->Write((uint32_t)path->pathways.size());

Expand Down
2 changes: 1 addition & 1 deletion OTRExporter/PlayerAnimationExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ void OTRExporter_PlayerAnimationExporter::Save(ZResource* res, const fs::path& o
{
ZPlayerAnimationData* anim = (ZPlayerAnimationData*)res;

WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_PlayerAnimation);
WriteHeader(res, outPath, writer, static_cast<uint32_t>(SOH::ResourceType::SOH_PlayerAnimation));

auto start = std::chrono::steady_clock::now();

Expand Down
2 changes: 1 addition & 1 deletion OTRExporter/RoomExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void OTRExporter_Room::Save(ZResource* res, const fs::path& outPath, BinaryWrite
{
ZRoom* room = (ZRoom*)res;

WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Room);
WriteHeader(res, outPath, writer, static_cast<uint32_t>(SOH::ResourceType::SOH_Room));

writer->Write((uint32_t)room->commands.size());

Expand Down
2 changes: 1 addition & 1 deletion OTRExporter/SkeletonExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void OTRExporter_Skeleton::Save(ZResource* res, const fs::path& outPath, BinaryW
{
ZSkeleton* skel = (ZSkeleton*)res;

WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_Skeleton);
WriteHeader(res, outPath, writer, static_cast<uint32_t>(SOH::ResourceType::SOH_Skeleton));

writer->Write((uint8_t)skel->type);
writer->Write((uint8_t)skel->limbType);
Expand Down
2 changes: 1 addition & 1 deletion OTRExporter/SkeletonLimbExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void OTRExporter_SkeletonLimb::Save(ZResource* res, const fs::path& outPath, Bin
{
ZLimb* limb = (ZLimb*)res;

WriteHeader(res, outPath, writer, LUS::ResourceType::SOH_SkeletonLimb);
WriteHeader(res, outPath, writer, static_cast<uint32_t>(SOH::ResourceType::SOH_SkeletonLimb));

writer->Write((uint8_t)limb->type);
writer->Write((uint8_t)limb->skinSegmentType);
Expand Down
2 changes: 1 addition & 1 deletion OTRExporter/TextExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ void OTRExporter_Text::Save(ZResource* res, const fs::path& outPath, BinaryWrite
{
ZText* txt = (ZText*)res;

WriteHeader(txt, outPath, writer, LUS::ResourceType::SOH_Text);
WriteHeader(txt, outPath, writer, static_cast<uint32_t>(SOH::ResourceType::SOH_Text));

writer->Write((uint32_t)txt->messages.size());

Expand Down
2 changes: 1 addition & 1 deletion OTRExporter/TextureExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ void OTRExporter_Texture::Save(ZResource* res, const fs::path& outPath, BinaryWr
{
ZTexture* tex = (ZTexture*)res;

WriteHeader(tex, outPath, writer, LUS::ResourceType::Texture);
WriteHeader(tex, outPath, writer, static_cast<uint32_t>(LUS::ResourceType::Texture));

auto start = std::chrono::steady_clock::now();

Expand Down
35 changes: 18 additions & 17 deletions OTRExporter/VersionInfo.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
#include "VersionInfo.h"
#include <libultraship/bridge.h>
#include "../../soh/soh/resource/type/SohResourceType.h"

std::map<LUS::ResourceType, uint32_t> resourceVersions;
std::map<uint32_t, uint32_t> resourceVersions;

void InitVersionInfo()
{
resourceVersions = std::map<LUS::ResourceType, uint32_t> {
{ LUS::ResourceType::SOH_Animation, 0 },
{ LUS::ResourceType::Texture, 0 },
{ LUS::ResourceType::SOH_PlayerAnimation, 0 },
{ LUS::ResourceType::DisplayList, 0 },
{ LUS::ResourceType::SOH_Room, 0 },
{ LUS::ResourceType::SOH_CollisionHeader, 0 },
{ LUS::ResourceType::SOH_Skeleton, 0 },
{ LUS::ResourceType::SOH_SkeletonLimb, 0 },
{ LUS::ResourceType::Matrix, 0 },
{ LUS::ResourceType::SOH_Path, 0 },
{ LUS::ResourceType::Vertex, 0 },
{ LUS::ResourceType::SOH_Cutscene, 0 },
{ LUS::ResourceType::Array, 0 },
{ LUS::ResourceType::SOH_Text, 0 },
{ LUS::ResourceType::Blob, 0 },
resourceVersions = std::map<uint32_t, uint32_t> {
{ static_cast<uint32_t>(SOH::ResourceType::SOH_Animation), 0 },
{ static_cast<uint32_t>(LUS::ResourceType::Texture), 0 },
{ static_cast<uint32_t>(SOH::ResourceType::SOH_PlayerAnimation), 0 },
{ static_cast<uint32_t>(LUS::ResourceType::DisplayList), 0 },
{ static_cast<uint32_t>(SOH::ResourceType::SOH_Room), 0 },
{ static_cast<uint32_t>(SOH::ResourceType::SOH_CollisionHeader), 0 },
{ static_cast<uint32_t>(SOH::ResourceType::SOH_Skeleton), 0 },
{ static_cast<uint32_t>(SOH::ResourceType::SOH_SkeletonLimb), 0 },
{ static_cast<uint32_t>(LUS::ResourceType::Matrix), 0 },
{ static_cast<uint32_t>(SOH::ResourceType::SOH_Path), 0 },
{ static_cast<uint32_t>(LUS::ResourceType::Vertex), 0 },
{ static_cast<uint32_t>(SOH::ResourceType::SOH_Cutscene), 0 },
{ static_cast<uint32_t>(LUS::ResourceType::Array), 0 },
{ static_cast<uint32_t>(SOH::ResourceType::SOH_Text), 0 },
{ static_cast<uint32_t>(LUS::ResourceType::Blob), 0 },
};
}
2 changes: 1 addition & 1 deletion OTRExporter/VersionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
#include <vector>
#include "src/resource/Resource.h"

extern std::map<LUS::ResourceType, uint32_t> resourceVersions;
extern std::map<uint32_t, uint32_t> resourceVersions;
4 changes: 2 additions & 2 deletions OTRExporter/VtxExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

void OTRExporter_Vtx::SaveArr(ZResource* res, const fs::path& outPath, const std::vector<ZResource*>& vec, BinaryWriter* writer)
{
WriteHeader(res, outPath, writer, LUS::ResourceType::Vertex);
WriteHeader(res, outPath, writer, static_cast<uint32_t>(LUS::ResourceType::Vertex));

for (auto& res: vec) {
ZVtx* vtx = (ZVtx*)res;
Expand All @@ -27,7 +27,7 @@ void OTRExporter_Vtx::Save(ZResource* res, const fs::path& outPath, BinaryWriter
{
ZVtx* vtx = (ZVtx*)res;

WriteHeader(res, outPath, writer, LUS::ResourceType::Vertex);
WriteHeader(res, outPath, writer, static_cast<uint32_t>(LUS::ResourceType::Vertex));

writer->Write((uint32_t)1); //Yes I'm hard coding it to one, it *should* be fine.

Expand Down