Bump LUS version (#2849)

* Bump LUS version

* Removes the "now" boolean from the LUS resource bridge functions.

* Bump LUS

* More LUS bump

* Update soh/soh/resource/importer/AudioSampleFactory.cpp

---------

Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
This commit is contained in:
Kenix3 2023-05-07 20:18:54 -04:00 committed by GitHub
commit 91bd693ff6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
59 changed files with 233 additions and 218 deletions

View file

@ -2,7 +2,7 @@
#include "Main.h" #include "Main.h"
#include <Utils/MemoryStream.h> #include <Utils/MemoryStream.h>
#include <Globals.h> #include <Globals.h>
#include <Utils/File.h> #include <Utils/DiskFile.h>
#include "DisplayListExporter.h" #include "DisplayListExporter.h"
void OTRExporter_Audio::WriteSampleEntryReference(ZAudio* audio, SampleEntry* entry, std::map<uint32_t, SampleEntry*> samples, BinaryWriter* writer) void OTRExporter_Audio::WriteSampleEntryReference(ZAudio* audio, SampleEntry* entry, std::map<uint32_t, SampleEntry*> samples, BinaryWriter* writer)
@ -29,7 +29,7 @@ void OTRExporter_Audio::WriteSampleEntryReference(ZAudio* audio, SampleEntry* en
void OTRExporter_Audio::WriteSampleEntry(SampleEntry* entry, BinaryWriter* writer) void OTRExporter_Audio::WriteSampleEntry(SampleEntry* entry, BinaryWriter* writer)
{ {
WriteHeader(nullptr, "", writer, Ship::ResourceType::SOH_AudioSample, Ship::Version::Rachael); WriteHeader(nullptr, "", writer, Ship::ResourceType::SOH_AudioSample, 2);
writer->Write(entry->codec); writer->Write(entry->codec);
writer->Write(entry->medium); writer->Write(entry->medium);
@ -81,7 +81,7 @@ void OTRExporter_Audio::Save(ZResource* res, const fs::path& outPath, BinaryWrit
{ {
ZAudio* audio = (ZAudio*)res; ZAudio* audio = (ZAudio*)res;
WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_Audio, Ship::Version::Rachael); WriteHeader(res, outPath, writer, Ship::ResourceType::SOH_Audio, 2);
// Write Samples as individual files // Write Samples as individual files
for (auto pair : audio->samples) for (auto pair : audio->samples)
@ -114,7 +114,7 @@ void OTRExporter_Audio::Save(ZResource* res, const fs::path& outPath, BinaryWrit
MemoryStream* fntStream = new MemoryStream(); MemoryStream* fntStream = new MemoryStream();
BinaryWriter fntWriter = BinaryWriter(fntStream); BinaryWriter fntWriter = BinaryWriter(fntStream);
WriteHeader(nullptr, "", &fntWriter, Ship::ResourceType::SOH_AudioSoundFont, Ship::Version::Rachael); WriteHeader(nullptr, "", &fntWriter, Ship::ResourceType::SOH_AudioSoundFont, 2);
fntWriter.Write((uint32_t)i); fntWriter.Write((uint32_t)i);
fntWriter.Write(audio->soundFontTable[i].medium); fntWriter.Write(audio->soundFontTable[i].medium);
@ -173,7 +173,7 @@ void OTRExporter_Audio::Save(ZResource* res, const fs::path& outPath, BinaryWrit
MemoryStream* seqStream = new MemoryStream(); MemoryStream* seqStream = new MemoryStream();
BinaryWriter seqWriter = BinaryWriter(seqStream); BinaryWriter seqWriter = BinaryWriter(seqStream);
WriteHeader(nullptr, "", &seqWriter, Ship::ResourceType::SOH_AudioSequence, Ship::Version::Rachael); WriteHeader(nullptr, "", &seqWriter, Ship::ResourceType::SOH_AudioSequence, 2);
seqWriter.Write((uint32_t)seq.size()); seqWriter.Write((uint32_t)seq.size());
seqWriter.Write(seq.data(), seq.size()); seqWriter.Write(seq.data(), seq.size());

View file

@ -10,7 +10,7 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include "MtxExporter.h" #include "MtxExporter.h"
#include <Utils/File.h> #include <Utils/DiskFile.h>
#include "VersionInfo.h" #include "VersionInfo.h"
#define GFX_SIZE 8 #define GFX_SIZE 8
@ -356,7 +356,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
//std::string fName = StringHelper::Sprintf("%s\\%s", GetParentFolderName(res).c_str(), dListDecl2->varName.c_str()); //std::string fName = StringHelper::Sprintf("%s\\%s", GetParentFolderName(res).c_str(), dListDecl2->varName.c_str());
std::string fName = OTRExporter_DisplayList::GetPathToRes(res, dListDecl2->varName.c_str()); std::string fName = OTRExporter_DisplayList::GetPathToRes(res, dListDecl2->varName.c_str());
if (files.find(fName) == files.end() && !File::Exists("Extract/" + fName)) if (files.find(fName) == files.end() && !DiskFile::Exists("Extract/" + fName))
{ {
MemoryStream* dlStream = new MemoryStream(); MemoryStream* dlStream = new MemoryStream();
BinaryWriter dlWriter = BinaryWriter(dlStream); BinaryWriter dlWriter = BinaryWriter(dlStream);
@ -442,7 +442,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
//std::string fName = StringHelper::Sprintf("%s\\%s", GetParentFolderName(res).c_str(), dListDecl2->varName.c_str()); //std::string fName = StringHelper::Sprintf("%s\\%s", GetParentFolderName(res).c_str(), dListDecl2->varName.c_str());
std::string fName = OTRExporter_DisplayList::GetPathToRes(res, dListDecl2->varName.c_str()); std::string fName = OTRExporter_DisplayList::GetPathToRes(res, dListDecl2->varName.c_str());
if (files.find(fName) == files.end() && !File::Exists("Extract/" + fName)) if (files.find(fName) == files.end() && !DiskFile::Exists("Extract/" + fName))
{ {
MemoryStream* dlStream = new MemoryStream(); MemoryStream* dlStream = new MemoryStream();
BinaryWriter dlWriter = BinaryWriter(dlStream); BinaryWriter dlWriter = BinaryWriter(dlStream);
@ -767,7 +767,7 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
word0 = hash >> 32; word0 = hash >> 32;
word1 = hash & 0xFFFFFFFF; word1 = hash & 0xFFFFFFFF;
if (files.find(fName) == files.end() && !File::Exists("Extract/" + fName)) if (files.find(fName) == files.end() && !DiskFile::Exists("Extract/" + fName))
{ {
// Write vertices to file // Write vertices to file
MemoryStream* vtxStream = new MemoryStream(); MemoryStream* vtxStream = new MemoryStream();

View file

@ -1,7 +1,7 @@
#include "Exporter.h" #include "Exporter.h"
#include "VersionInfo.h" #include "VersionInfo.h"
void OTRExporter::WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, Ship::ResourceType resType, Ship::Version resVersion) void OTRExporter::WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, Ship::ResourceType resType, int32_t resVersion)
{ {
writer->Write((uint8_t)Endianness::Little); // 0x00 writer->Write((uint8_t)Endianness::Little); // 0x00
writer->Write((uint8_t)0); // 0x01 writer->Write((uint8_t)0); // 0x01

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "ZResource.h" #include "ZResource.h"
#include "ZArray.h" #include "ZArray.h"
#include "stdint.h"
//#include "OTRExporter.h" //#include "OTRExporter.h"
#include <Utils/BinaryWriter.h> #include <Utils/BinaryWriter.h>
#include <libultraship/bridge.h> #include <libultraship/bridge.h>
@ -9,5 +10,5 @@
class OTRExporter : public ZResourceExporter class OTRExporter : public ZResourceExporter
{ {
protected: protected:
static void WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, Ship::ResourceType resType, Ship::Version resVersion = MAJOR_VERSION); static void WriteHeader(ZResource* res, const fs::path& outPath, BinaryWriter* writer, Ship::ResourceType resType, int32_t resVersion = 0);
}; };

View file

@ -18,7 +18,7 @@
#include "MtxExporter.h" #include "MtxExporter.h"
#include "AudioExporter.h" #include "AudioExporter.h"
#include <Globals.h> #include <Globals.h>
#include <Utils/File.h> #include <Utils/DiskFile.h>
#include <Utils/Directory.h> #include <Utils/Directory.h>
#include <Utils/MemoryStream.h> #include <Utils/MemoryStream.h>
#include <Utils/BinaryWriter.h> #include <Utils/BinaryWriter.h>
@ -47,7 +47,7 @@ static void ExporterParseFileMode(const std::string& buildMode, ZFileMode& fileM
printf("BOTR: Generating OTR Archive...\n"); printf("BOTR: Generating OTR Archive...\n");
if (File::Exists(otrFileName)) if (DiskFile::Exists(otrFileName))
otrArchive = std::shared_ptr<Ship::Archive>(new Ship::Archive(otrFileName, true)); otrArchive = std::shared_ptr<Ship::Archive>(new Ship::Archive(otrFileName, true));
else else
otrArchive = Ship::Archive::CreateArchive(otrFileName, 40000); otrArchive = Ship::Archive::CreateArchive(otrFileName, 40000);
@ -56,7 +56,7 @@ static void ExporterParseFileMode(const std::string& buildMode, ZFileMode& fileM
for (auto item : lst) for (auto item : lst)
{ {
auto fileData = File::ReadAllBytes(item); auto fileData = DiskFile::ReadAllBytes(item);
otrArchive->AddFile(StringHelper::Split(item, "Extract/")[1], (uintptr_t)fileData.data(), fileData.size()); otrArchive->AddFile(StringHelper::Split(item, "Extract/")[1], (uintptr_t)fileData.data(), fileData.size());
} }
} }
@ -70,7 +70,7 @@ static void ExporterProgramEnd()
if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory) if (Globals::Instance->fileMode == ZFileMode::ExtractDirectory)
{ {
std::string romPath = Globals::Instance->baseRomPath.string(); std::string romPath = Globals::Instance->baseRomPath.string();
const std::vector<uint8_t>& romData = File::ReadAllBytes(romPath); const std::vector<uint8_t>& romData = DiskFile::ReadAllBytes(romPath);
crc = BitConverter::ToUInt32BE(romData, 0x10); crc = BitConverter::ToUInt32BE(romData, 0x10);
printf("Creating version file...\n"); printf("Creating version file...\n");
@ -111,7 +111,7 @@ static void ExporterProgramEnd()
files.clear(); files.clear();
// Add any additional files that need to be manually copied... // Add any additional files that need to be manually copied...
if (File::Exists("soh.otr")) { if (DiskFile::Exists("soh.otr")) {
return; return;
} }
const auto& lst = Directory::ListFiles("Extract"); const auto& lst = Directory::ListFiles("Extract");
@ -158,14 +158,14 @@ static void ExporterProgramEnd()
splitPath.pop_back(); splitPath.pop_back();
if (extension == "json") if (extension == "json")
{ {
const auto &fileData = File::ReadAllBytes(item); const auto &fileData = DiskFile::ReadAllBytes(item);
printf("Adding accessibility texts %s\n", StringHelper::Split(item, "texts/")[1].c_str()); printf("Adding accessibility texts %s\n", StringHelper::Split(item, "texts/")[1].c_str());
sohOtr->AddFile(StringHelper::Split(item, "Extract/assets/")[1], (uintptr_t)fileData.data(), fileData.size()); sohOtr->AddFile(StringHelper::Split(item, "Extract/assets/")[1], (uintptr_t)fileData.data(), fileData.size());
} }
continue; continue;
} }
const auto& fileData = File::ReadAllBytes(item); const auto& fileData = DiskFile::ReadAllBytes(item);
printf("sohOtr->AddFile(%s)\n", StringHelper::Split(item, "Extract/")[1].c_str()); printf("sohOtr->AddFile(%s)\n", StringHelper::Split(item, "Extract/")[1].c_str());
sohOtr->AddFile(StringHelper::Split(item, item.find("Extract/assets/") != std::string::npos ? "Extract/assets/" : "Extract/")[1], (uintptr_t)fileData.data(), fileData.size()); sohOtr->AddFile(StringHelper::Split(item, item.find("Extract/assets/") != std::string::npos ? "Extract/assets/" : "Extract/")[1], (uintptr_t)fileData.data(), fileData.size());
} }
@ -249,7 +249,7 @@ static void ExporterResourceEnd(ZResource* res, BinaryWriter& writer)
files[fName] = strem->ToVector(); files[fName] = strem->ToVector();
} }
else else
File::WriteAllBytes("Extract/" + fName, strem->ToVector()); DiskFile::WriteAllBytes("Extract/" + fName, strem->ToVector());
} }
auto end = std::chrono::steady_clock::now(); auto end = std::chrono::steady_clock::now();
@ -275,7 +275,7 @@ static void ExporterXMLEnd()
void AddFile(std::string fName, std::vector<char> data) void AddFile(std::string fName, std::vector<char> data)
{ {
if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory) if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory)
File::WriteAllBytes("Extract/" + fName, data); DiskFile::WriteAllBytes("Extract/" + fName, data);
else else
{ {
std::unique_lock Lock(fileMutex); std::unique_lock Lock(fileMutex);

View file

@ -1,7 +1,7 @@
#include "RoomExporter.h" #include "RoomExporter.h"
#include "Utils/BinaryWriter.h" #include "Utils/BinaryWriter.h"
#include "Utils/MemoryStream.h" #include "Utils/MemoryStream.h"
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include <ZRoom/Commands/SetMesh.h> #include <ZRoom/Commands/SetMesh.h>
#include <ZRoom/Commands/SetWind.h> #include <ZRoom/Commands/SetWind.h>
#include <ZRoom/Commands/SetTimeSettings.h> #include <ZRoom/Commands/SetTimeSettings.h>

View file

@ -4,6 +4,4 @@
#include <vector> #include <vector>
#include "src/resource/Resource.h" #include "src/resource/Resource.h"
#define MAJOR_VERSION Ship::Version::Deckard
extern std::map<Ship::ResourceType, uint32_t> resourceVersions; extern std::map<Ship::ResourceType, uint32_t> resourceVersions;

View file

@ -1,7 +1,7 @@
#include "RoomExporter.h" #include "RoomExporter.h"
#include "CollisionExporter.h" #include "CollisionExporter.h"
#include "Utils/BinaryWriter.h" #include "Utils/BinaryWriter.h"
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include "Utils/MemoryStream.h" #include "Utils/MemoryStream.h"
#include "ZRoom/Commands/SetCameraSettings.h" #include "ZRoom/Commands/SetCameraSettings.h"
#include "ZRoom/Commands/SetCollisionHeader.h" #include "ZRoom/Commands/SetCollisionHeader.h"
@ -367,6 +367,6 @@ void ExporterExample_Room::Save(ZResource* res, const fs::path& outPath, BinaryW
} }
// writer->Close(); // writer->Close();
// File::WriteAllBytes(StringHelper::Sprintf("%s", res->GetName().c_str()), // DiskFile::WriteAllBytes(StringHelper::Sprintf("%s", res->GetName().c_str()),
// memStream->ToVector()); // memStream->ToVector());
} }

View file

@ -5,7 +5,7 @@
#include <unordered_map> #include <unordered_map>
#include "Utils/Directory.h" #include "Utils/Directory.h"
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include "Utils/Path.h" #include "Utils/Path.h"
#include "ZFile.h" #include "ZFile.h"
#include "tinyxml2.h" #include "tinyxml2.h"
@ -57,7 +57,7 @@ void GameConfig::ReadTexturePool(const fs::path& texturePoolXmlPath)
void GameConfig::GenSymbolMap(const fs::path& symbolMapPath) void GameConfig::GenSymbolMap(const fs::path& symbolMapPath)
{ {
auto symbolLines = File::ReadAllLines(symbolMapPath); auto symbolLines = DiskFile::ReadAllLines(symbolMapPath);
for (std::string& symbolLine : symbolLines) for (std::string& symbolLine : symbolLines)
{ {
@ -79,7 +79,7 @@ void GameConfig::ConfigFunc_ActorList(const tinyxml2::XMLElement& element)
{ {
std::string fileName = element.Attribute("File"); std::string fileName = element.Attribute("File");
std::vector<std::string> lines = std::vector<std::string> lines =
File::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName); DiskFile::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName);
for (auto& line : lines) for (auto& line : lines)
actorList.emplace_back(std::move(line)); actorList.emplace_back(std::move(line));
@ -89,7 +89,7 @@ void GameConfig::ConfigFunc_ObjectList(const tinyxml2::XMLElement& element)
{ {
std::string fileName = element.Attribute("File"); std::string fileName = element.Attribute("File");
std::vector<std::string> lines = std::vector<std::string> lines =
File::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName); DiskFile::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName);
for (auto& line : lines) for (auto& line : lines)
objectList.emplace_back(std::move(line)); objectList.emplace_back(std::move(line));

View file

@ -3,7 +3,7 @@
#include <algorithm> #include <algorithm>
#include <string_view> #include <string_view>
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include "Utils/Path.h" #include "Utils/Path.h"
#include "WarningHandler.h" #include "WarningHandler.h"
#include "tinyxml2.h" #include "tinyxml2.h"
@ -134,12 +134,12 @@ void Globals::BuildAssetTexture(const fs::path& pngFilePath, TextureType texType
tex.FromPNG(pngFilePath.string(), texType); tex.FromPNG(pngFilePath.string(), texType);
std::string cfgPath = StringHelper::Split(pngFilePath.string(), ".")[0] + ".cfg"; std::string cfgPath = StringHelper::Split(pngFilePath.string(), ".")[0] + ".cfg";
if (File::Exists(cfgPath)) if (DiskFile::Exists(cfgPath))
name = File::ReadAllText(cfgPath); name = DiskFile::ReadAllText(cfgPath);
std::string src = tex.GetBodySourceCode(); std::string src = tex.GetBodySourceCode();
File::WriteAllBytes(outPath.string(), src.c_str(), src.size()); DiskFile::WriteAllBytes(outPath.string(), src.c_str(), src.size());
} }
std::map<std::string, ExporterSet*>& Globals::GetExporterMap() std::map<std::string, ExporterSet*>& Globals::GetExporterMap()
@ -186,7 +186,7 @@ std::vector<uint8_t> Globals::GetBaseromFile(std::string fileName)
} }
else else
return File::ReadAllBytes(fileName); return DiskFile::ReadAllBytes(fileName);
} }
bool Globals::GetSegmentedPtrName(segptr_t segAddress, ZFile* currentFile, bool Globals::GetSegmentedPtrName(segptr_t segAddress, ZFile* currentFile,

View file

@ -1,6 +1,6 @@
#include "Globals.h" #include "Globals.h"
#include "Utils/Directory.h" #include "Utils/Directory.h"
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include "Utils/Path.h" #include "Utils/Path.h"
#include "WarningHandler.h" #include "WarningHandler.h"
@ -578,7 +578,7 @@ void BuildAssetBackground(const fs::path& imageFilePath, const fs::path& outPath
ZBackground background(nullptr); ZBackground background(nullptr);
background.ParseBinaryFile(imageFilePath.string(), false); background.ParseBinaryFile(imageFilePath.string(), false);
File::WriteAllText(outPath.string(), background.GetBodySourceCode()); DiskFile::WriteAllText(outPath.string(), background.GetBodySourceCode());
} }
void BuildAssetBlob(const fs::path& blobFilePath, const fs::path& outPath) void BuildAssetBlob(const fs::path& blobFilePath, const fs::path& outPath)
@ -588,7 +588,7 @@ void BuildAssetBlob(const fs::path& blobFilePath, const fs::path& outPath)
std::string src = blob->GetBodySourceCode(); std::string src = blob->GetBodySourceCode();
File::WriteAllText(outPath.string(), src); DiskFile::WriteAllText(outPath.string(), src);
delete blob; delete blob;
} }

View file

@ -5,7 +5,7 @@
#include <unordered_set> #include <unordered_set>
#include "Globals.h" #include "Globals.h"
#include "Utils/Directory.h" #include "Utils/Directory.h"
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include "Utils/Path.h" #include "Utils/Path.h"
#include "Utils/StringHelper.h" #include "Utils/StringHelper.h"
#include "WarningHandler.h" #include "WarningHandler.h"
@ -76,7 +76,7 @@ static const std::unordered_set<std::string> sSections = {
ZOverlay* ZOverlay::FromBuild(fs::path buildPath, fs::path cfgFolderPath) ZOverlay* ZOverlay::FromBuild(fs::path buildPath, fs::path cfgFolderPath)
{ {
std::string cfgText = File::ReadAllText(cfgFolderPath / "overlay.cfg"); std::string cfgText = DiskFile::ReadAllText(cfgFolderPath / "overlay.cfg");
std::vector<std::string> cfgLines = StringHelper::Split(cfgText, "\n"); std::vector<std::string> cfgLines = StringHelper::Split(cfgText, "\n");
ZOverlay* ovl = new ZOverlay(StringHelper::Strip(cfgLines[0], "\r")); ZOverlay* ovl = new ZOverlay(StringHelper::Strip(cfgLines[0], "\r"));

View file

@ -4,7 +4,7 @@
#include "Globals.h" #include "Globals.h"
#include "Utils/BitConverter.h" #include "Utils/BitConverter.h"
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include "Utils/StringHelper.h" #include "Utils/StringHelper.h"
#include "WarningHandler.h" #include "WarningHandler.h"
#include "ZFile.h" #include "ZFile.h"

View file

@ -2,7 +2,7 @@
#include "Globals.h" #include "Globals.h"
#include "Utils/BitConverter.h" #include "Utils/BitConverter.h"
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include "Utils/Path.h" #include "Utils/Path.h"
#include "Utils/StringHelper.h" #include "Utils/StringHelper.h"
#include "ZFile.h" #include "ZFile.h"

View file

@ -2,7 +2,7 @@
#include "Globals.h" #include "Globals.h"
#include "Utils/BitConverter.h" #include "Utils/BitConverter.h"
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include "Utils/Path.h" #include "Utils/Path.h"
#include "Utils/StringHelper.h" #include "Utils/StringHelper.h"
#include "WarningHandler.h" #include "WarningHandler.h"
@ -46,7 +46,7 @@ void ZBackground::ParseBinaryFile(const std::string& inFolder, bool appendOutNam
if (appendOutName) if (appendOutName)
filepath = filepath / (outName + "." + GetExternalExtension()); filepath = filepath / (outName + "." + GetExternalExtension());
data = File::ReadAllBytes(filepath.string()); data = DiskFile::ReadAllBytes(filepath.string());
// Add padding. // Add padding.
data.insert(data.end(), GetRawDataSize() - data.size(), 0x00); data.insert(data.end(), GetRawDataSize() - data.size(), 0x00);
@ -153,7 +153,7 @@ void ZBackground::Save(const fs::path& outFolder)
if (!Globals::Instance->otrMode) if (!Globals::Instance->otrMode)
{ {
fs::path filepath = outFolder / (outName + "." + GetExternalExtension()); fs::path filepath = outFolder / (outName + "." + GetExternalExtension());
File::WriteAllBytes(filepath.string(), data); DiskFile::WriteAllBytes(filepath.string(), data);
} }
} }

View file

@ -2,7 +2,7 @@
#include "Globals.h" #include "Globals.h"
#include "Utils/BitConverter.h" #include "Utils/BitConverter.h"
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include "Utils/Path.h" #include "Utils/Path.h"
#include "Utils/StringHelper.h" #include "Utils/StringHelper.h"
#include "ZFile.h" #include "ZFile.h"
@ -19,7 +19,7 @@ ZBlob* ZBlob::FromFile(const std::string& filePath)
{ {
ZBlob* blob = new ZBlob(nullptr); ZBlob* blob = new ZBlob(nullptr);
blob->name = StringHelper::Split(Path::GetFileNameWithoutExtension(filePath), ".")[0]; blob->name = StringHelper::Split(Path::GetFileNameWithoutExtension(filePath), ".")[0];
blob->blobData = File::ReadAllBytes(filePath); blob->blobData = DiskFile::ReadAllBytes(filePath);
return blob; return blob;
} }
@ -87,7 +87,7 @@ std::string ZBlob::GetBodySourceCode() const
void ZBlob::Save(const fs::path& outFolder) void ZBlob::Save(const fs::path& outFolder)
{ {
if (!Globals::Instance->otrMode) if (!Globals::Instance->otrMode)
File::WriteAllBytes((outFolder / (name + ".bin")).string(), blobData); DiskFile::WriteAllBytes((outFolder / (name + ".bin")).string(), blobData);
} }
bool ZBlob::IsExternalResource() const bool ZBlob::IsExternalResource() const

View file

@ -9,7 +9,7 @@
#include "Globals.h" #include "Globals.h"
#include "OutputFormatter.h" #include "OutputFormatter.h"
#include "Utils/BitConverter.h" #include "Utils/BitConverter.h"
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include "Utils/Path.h" #include "Utils/Path.h"
#include "Utils/StringHelper.h" #include "Utils/StringHelper.h"
#include "WarningHandler.h" #include "WarningHandler.h"

View file

@ -10,7 +10,7 @@
#include "Utils/BinaryWriter.h" #include "Utils/BinaryWriter.h"
#include "Utils/BitConverter.h" #include "Utils/BitConverter.h"
#include "Utils/Directory.h" #include "Utils/Directory.h"
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include "Utils/MemoryStream.h" #include "Utils/MemoryStream.h"
#include "Utils/Path.h" #include "Utils/Path.h"
#include "Utils/StringHelper.h" #include "Utils/StringHelper.h"
@ -190,7 +190,7 @@ void ZFile::ParseXML(tinyxml2::XMLElement* reader, const std::string& filename)
{ {
if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory) if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory)
{ {
if (!File::Exists((basePath / name).string())) if (!DiskFile::Exists((basePath / name).string()))
{ {
std::string errorHeader = StringHelper::Sprintf("binary file '%s' does not exist.", std::string errorHeader = StringHelper::Sprintf("binary file '%s' does not exist.",
(basePath / name).c_str()); (basePath / name).c_str());
@ -421,7 +421,7 @@ void ZFile::ExtractResources()
if (memStreamFile->GetLength() > 0) if (memStreamFile->GetLength() > 0)
{ {
File::WriteAllBytes(StringHelper::Sprintf("%s%s.bin", DiskFile::WriteAllBytes(StringHelper::Sprintf("%s%s.bin",
Globals::Instance->outputPath.string().c_str(), Globals::Instance->outputPath.string().c_str(),
GetName().c_str()), GetName().c_str()),
memStreamFile->ToVector()); memStreamFile->ToVector());
@ -802,7 +802,7 @@ void ZFile::GenerateSourceFiles()
OutputFormatter formatter; OutputFormatter formatter;
formatter.Write(sourceOutput); formatter.Write(sourceOutput);
File::WriteAllText(outPath, formatter.GetOutput()); DiskFile::WriteAllText(outPath, formatter.GetOutput());
} }
GenerateSourceHeaderFiles(); GenerateSourceHeaderFiles();
@ -850,7 +850,7 @@ void ZFile::GenerateSourceHeaderFiles()
output.pop_back(); output.pop_back();
if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory) if (Globals::Instance->fileMode != ZFileMode::ExtractDirectory)
File::WriteAllText(headerFilename, output); DiskFile::WriteAllText(headerFilename, output);
else if (Globals::Instance->sourceOutputPath != "") else if (Globals::Instance->sourceOutputPath != "")
{ {
std::string xmlPath = xmlFilePath.string(); std::string xmlPath = xmlFilePath.string();
@ -875,7 +875,7 @@ void ZFile::GenerateSourceHeaderFiles()
outPath += "/"; outPath += "/";
} }
File::WriteAllText(outPath, output); DiskFile::WriteAllText(outPath, output);
} }
} }
@ -1121,7 +1121,7 @@ std::string ZFile::ProcessDeclarations()
extType = "vtx"; extType = "vtx";
auto filepath = outputPath / item.second->varName; auto filepath = outputPath / item.second->varName;
File::WriteAllText( DiskFile::WriteAllText(
StringHelper::Sprintf("%s.%s.inc", filepath.string().c_str(), extType.c_str()), StringHelper::Sprintf("%s.%s.inc", filepath.string().c_str(), extType.c_str()),
item.second->text); item.second->text);
} }

View file

@ -1,6 +1,6 @@
#include "ZRom.h" #include "ZRom.h"
#include "Utils/BitConverter.h" #include "Utils/BitConverter.h"
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include "Utils/Directory.h" #include "Utils/Directory.h"
#include "yaz0/yaz0.h" #include "yaz0/yaz0.h"
@ -95,7 +95,7 @@ bool ZRom::IsMQ() {
ZRom::ZRom(std::string romPath) ZRom::ZRom(std::string romPath)
{ {
RomVersion version; RomVersion version;
romData = File::ReadAllBytes(romPath); romData = DiskFile::ReadAllBytes(romPath);
version.crc = BitConverter::ToInt32BE(romData, 0x10); version.crc = BitConverter::ToInt32BE(romData, 0x10);
@ -189,7 +189,7 @@ ZRom::ZRom(std::string romPath)
} }
auto path = StringHelper::Sprintf("%s/%s", Globals::Instance->fileListPath.string().c_str(), version.listPath.c_str()); auto path = StringHelper::Sprintf("%s/%s", Globals::Instance->fileListPath.string().c_str(), version.listPath.c_str());
auto txt = File::ReadAllText(path); auto txt = DiskFile::ReadAllText(path);
std::vector<std::string> lines = StringHelper::Split(txt, "\n"); std::vector<std::string> lines = StringHelper::Split(txt, "\n");
std::vector<uint8_t> decompressedData(1); std::vector<uint8_t> decompressedData(1);
@ -222,7 +222,7 @@ ZRom::ZRom(std::string romPath)
else else
files[lines[i]] = outData; files[lines[i]] = outData;
//File::WriteAllBytes(StringHelper::Sprintf("baserom/%s", lines[i].c_str()), files[lines[i]]); //DiskFile::WriteAllBytes(StringHelper::Sprintf("baserom/%s", lines[i].c_str()), files[lines[i]]);
} }
} }

View file

@ -39,7 +39,7 @@
#include "Commands/Unused1D.h" #include "Commands/Unused1D.h"
#include "Commands/ZRoomCommandUnk.h" #include "Commands/ZRoomCommandUnk.h"
#include "Globals.h" #include "Globals.h"
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include "Utils/Path.h" #include "Utils/Path.h"
#include "Utils/StringHelper.h" #include "Utils/StringHelper.h"
#include "WarningHandler.h" #include "WarningHandler.h"

View file

@ -2,7 +2,7 @@
#include "Globals.h" #include "Globals.h"
#include "Utils/BitConverter.h" #include "Utils/BitConverter.h"
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include "Utils/StringHelper.h" #include "Utils/StringHelper.h"
#include "WarningHandler.h" #include "WarningHandler.h"
#include "ZFile.h" #include "ZFile.h"

View file

@ -1,6 +1,6 @@
#include "ZString.h" #include "ZString.h"
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include "Utils/StringHelper.h" #include "Utils/StringHelper.h"
#include "ZFile.h" #include "ZFile.h"

View file

@ -2,7 +2,7 @@
#include "Globals.h" #include "Globals.h"
#include "Utils/BitConverter.h" #include "Utils/BitConverter.h"
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include "Utils/Path.h" #include "Utils/Path.h"
#include "Utils/StringHelper.h" #include "Utils/StringHelper.h"
#include "ZFile.h" #include "ZFile.h"

View file

@ -6,7 +6,7 @@
#include "Globals.h" #include "Globals.h"
#include "Utils/BitConverter.h" #include "Utils/BitConverter.h"
#include "Utils/Directory.h" #include "Utils/Directory.h"
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include "Utils/Path.h" #include "Utils/Path.h"
#include "WarningHandler.h" #include "WarningHandler.h"
@ -727,7 +727,7 @@ void ZTexture::Save(const fs::path& outFolder)
// process for generating the Texture Pool XML. // process for generating the Texture Pool XML.
if (Globals::Instance->outputCrc) if (Globals::Instance->outputCrc)
{ {
File::WriteAllText((Globals::Instance->outputPath / (outName + ".txt")).string(), DiskFile::WriteAllText((Globals::Instance->outputPath / (outName + ".txt")).string(),
StringHelper::Sprintf("%08lX", hash)); StringHelper::Sprintf("%08lX", hash));
} }

View file

@ -4,7 +4,7 @@
#include "Globals.h" #include "Globals.h"
#include "Utils/BitConverter.h" #include "Utils/BitConverter.h"
#include "Utils/File.h" #include <Utils/DiskFile.h>
#include "Utils/StringHelper.h" #include "Utils/StringHelper.h"
#include "WarningHandler.h" #include "WarningHandler.h"
#include "ZFile.h" #include "ZFile.h"

@ -1 +1 @@
Subproject commit f9e554dc214c2f23cfc74a26348ef9fd3055451b Subproject commit 19958ec56fc9966e5a55e4701606f37f2cd8c903

View file

@ -17,6 +17,7 @@
#include <Utils/StringHelper.h> #include <Utils/StringHelper.h>
#include <Window.h> #include <Window.h>
#include <Context.h>
#include <ImGui/imgui_internal.h> #include <ImGui/imgui_internal.h>
#undef PATH_HACK #undef PATH_HACK
#undef Path #undef Path
@ -483,7 +484,7 @@ static bool FileSelectHandler(std::shared_ptr<Ship::Console> Console, const std:
} }
static bool QuitHandler(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>& args) { static bool QuitHandler(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>& args) {
Ship::Window::GetInstance()->Close(); Ship::Context::GetInstance()->GetWindow()->Close();
return CMD_SUCCESS; return CMD_SUCCESS;
} }

View file

@ -10,7 +10,7 @@
#include <bit> #include <bit>
#include <map> #include <map>
#include <string> #include <string>
#include <libultraship/bridge.h> #include <libultraship/libultraship.h>
extern "C" { extern "C" {
#include <z64.h> #include <z64.h>
@ -64,7 +64,7 @@ void DrawDLViewer(bool& open) {
ImGui::EndCombo(); ImGui::EndCombo();
} }
if (activeDisplayList != nullptr) { if (activeDisplayList != nullptr) {
auto res = std::static_pointer_cast<Ship::DisplayList>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(activeDisplayList)); auto res = std::static_pointer_cast<Ship::DisplayList>(Ship::Context::GetInstance()->GetResourceManager()->LoadResource(activeDisplayList));
for (int i = 0; i < res->Instructions.size(); i++) { for (int i = 0; i < res->Instructions.size(); i++) {
std::string id = "##CMD" + std::to_string(i); std::string id = "##CMD" + std::to_string(i);
Gfx* gfx = (Gfx*)&res->Instructions[i]; Gfx* gfx = (Gfx*)&res->Instructions[i];

View file

@ -6,7 +6,7 @@
#include "rando_main.hpp" #include "rando_main.hpp"
// #include <soh/Enhancements/randomizer.h> // #include <soh/Enhancements/randomizer.h>
#include <libultraship/bridge.h> #include <libultraship/bridge.h>
#include <Window.h> #include <Context.h>
#include <libultraship/libultra/types.h> #include <libultraship/libultra/types.h>
#define TICKS_PER_SEC 268123480.0 #define TICKS_PER_SEC 268123480.0
@ -20,7 +20,7 @@ void RandoMain::GenerateRando(std::unordered_map<RandomizerSettingKey, u8> cvarS
// std::string settingsFileName = "./randomizer/latest_settings.json"; // std::string settingsFileName = "./randomizer/latest_settings.json";
// CVarSetString("gLoadedPreset", settingsFileName.c_str()); // CVarSetString("gLoadedPreset", settingsFileName.c_str());
std::string fileName = Ship::Window::GetPathRelativeToAppDirectory(GenerateRandomizer(cvarSettings, excludedLocations, seedString).c_str()); std::string fileName = Ship::Context::GetPathRelativeToAppDirectory(GenerateRandomizer(cvarSettings, excludedLocations, seedString).c_str());
CVarSetString("gSpoilerLog", fileName.c_str()); CVarSetString("gSpoilerLog", fileName.c_str());
CVarSave(); CVarSave();

View file

@ -27,7 +27,7 @@
#include <filesystem> #include <filesystem>
#include <variables.h> #include <variables.h>
#include <Window.h> #include <libultraship/libultraship.h>
using json = nlohmann::json; using json = nlohmann::json;
@ -807,8 +807,8 @@ const char* SpoilerLog_Write(int language) {
WriteShuffledEntrances(); WriteShuffledEntrances();
WriteAllLocations(language); WriteAllLocations(language);
if (!std::filesystem::exists(Ship::Window::GetPathRelativeToAppDirectory("Randomizer"))) { if (!std::filesystem::exists(Ship::Context::GetPathRelativeToAppDirectory("Randomizer"))) {
std::filesystem::create_directory(Ship::Window::GetPathRelativeToAppDirectory("Randomizer")); std::filesystem::create_directory(Ship::Context::GetPathRelativeToAppDirectory("Randomizer"));
} }
std::string jsonString = jsonData.dump(4); std::string jsonString = jsonData.dump(4);
@ -823,7 +823,7 @@ const char* SpoilerLog_Write(int language) {
fileNameStream << std::to_string(Settings::hashIconIndexes[i]); fileNameStream << std::to_string(Settings::hashIconIndexes[i]);
} }
std::string fileName = fileNameStream.str(); std::string fileName = fileNameStream.str();
std::ofstream jsonFile(Ship::Window::GetPathRelativeToAppDirectory( std::ofstream jsonFile(Ship::Context::GetPathRelativeToAppDirectory(
(std::string("Randomizer/") + fileName + std::string(".json")).c_str())); (std::string("Randomizer/") + fileName + std::string(".json")).c_str()));
jsonFile << std::setw(4) << jsonString << std::endl; jsonFile << std::setw(4) << jsonString << std::endl;
jsonFile.close(); jsonFile.close();

View file

@ -681,22 +681,22 @@ void InitTTSBank() {
break; break;
} }
auto sceneFile = OTRGlobals::Instance->context->GetResourceManager()->LoadFile("accessibility/texts/scenes" + languageSuffix); auto sceneFile = Ship::Context::GetInstance()->GetResourceManager()->LoadFile("accessibility/texts/scenes" + languageSuffix);
if (sceneFile != nullptr) { if (sceneFile != nullptr) {
sceneMap = nlohmann::json::parse(sceneFile->Buffer, nullptr, true, true); sceneMap = nlohmann::json::parse(sceneFile->Buffer, nullptr, true, true);
} }
auto miscFile = OTRGlobals::Instance->context->GetResourceManager()->LoadFile("accessibility/texts/misc" + languageSuffix); auto miscFile = Ship::Context::GetInstance()->GetResourceManager()->LoadFile("accessibility/texts/misc" + languageSuffix);
if (miscFile != nullptr) { if (miscFile != nullptr) {
miscMap = nlohmann::json::parse(miscFile->Buffer, nullptr, true, true); miscMap = nlohmann::json::parse(miscFile->Buffer, nullptr, true, true);
} }
auto kaleidoFile = OTRGlobals::Instance->context->GetResourceManager()->LoadFile("accessibility/texts/kaleidoscope" + languageSuffix); auto kaleidoFile = Ship::Context::GetInstance()->GetResourceManager()->LoadFile("accessibility/texts/kaleidoscope" + languageSuffix);
if (kaleidoFile != nullptr) { if (kaleidoFile != nullptr) {
kaleidoMap = nlohmann::json::parse(kaleidoFile->Buffer, nullptr, true, true); kaleidoMap = nlohmann::json::parse(kaleidoFile->Buffer, nullptr, true, true);
} }
auto fileChooseFile = OTRGlobals::Instance->context->GetResourceManager()->LoadFile("accessibility/texts/filechoose" + languageSuffix); auto fileChooseFile = Ship::Context::GetInstance()->GetResourceManager()->LoadFile("accessibility/texts/filechoose" + languageSuffix);
if (fileChooseFile != nullptr) { if (fileChooseFile != nullptr) {
fileChooseMap = nlohmann::json::parse(fileChooseFile->Buffer, nullptr, true, true); fileChooseMap = nlohmann::json::parse(fileChooseFile->Buffer, nullptr, true, true);
} }

View file

@ -12,7 +12,7 @@
#define IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS
#include <ImGui/imgui_internal.h> #include <ImGui/imgui_internal.h>
#include <ImGuiImpl.h> #include <ImGuiImpl.h>
#include <libultraship/bridge.h> #include <libultraship/libultraship.h>
#include <Hooks.h> #include <Hooks.h>
#include <libultraship/libultra/types.h> #include <libultraship/libultra/types.h>
#include <libultraship/libultra/pi.h> #include <libultraship/libultra/pi.h>
@ -204,7 +204,7 @@ namespace GameMenuBar {
if (Ship::WindowBackend() == Ship::Backend::DX11) { if (Ship::WindowBackend() == Ship::Backend::DX11) {
maxFps = 360; maxFps = 360;
} else { } else {
maxFps = Ship::Window::GetInstance()->GetCurrentRefreshRate(); maxFps = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
} }
int currentFps = fmax(fmin(OTRGlobals::Instance->GetInterpolationFPS(), maxFps), minFps); int currentFps = fmax(fmin(OTRGlobals::Instance->GetInterpolationFPS(), maxFps), minFps);
#ifdef __WIIU__ #ifdef __WIIU__
@ -289,7 +289,7 @@ namespace GameMenuBar {
if (Ship::WindowBackend() == Ship::Backend::DX11) { if (Ship::WindowBackend() == Ship::Backend::DX11) {
UIWidgets::Spacer(0); UIWidgets::Spacer(0);
if (ImGui::Button("Match Refresh Rate")) { if (ImGui::Button("Match Refresh Rate")) {
int hz = Ship::Window::GetInstance()->GetCurrentRefreshRate(); int hz = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
if (hz >= 20 && hz <= 360) { if (hz >= 20 && hz <= 360) {
CVarSetInteger("gInterpolationFPS", hz); CVarSetInteger("gInterpolationFPS", hz);
Ship::RequestCvarSaveOnNextTick(); Ship::RequestCvarSaveOnNextTick();
@ -328,7 +328,7 @@ namespace GameMenuBar {
UIWidgets::ReEnableComponent(""); UIWidgets::ReEnableComponent("");
} }
if (Ship::Window::GetInstance()->CanDisableVerticalSync()) { if (Ship::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) {
UIWidgets::PaddedEnhancementCheckbox("Enable Vsync", "gVsyncEnabled", true, false); UIWidgets::PaddedEnhancementCheckbox("Enable Vsync", "gVsyncEnabled", true, false);
} }

View file

@ -201,19 +201,19 @@ const char* constCameraStrings[] = {
OTRGlobals::OTRGlobals() { OTRGlobals::OTRGlobals() {
std::vector<std::string> OTRFiles; std::vector<std::string> OTRFiles;
std::string mqPath = Ship::Window::GetPathRelativeToAppDirectory("oot-mq.otr"); std::string mqPath = Ship::Context::GetPathRelativeToAppDirectory("oot-mq.otr");
if (std::filesystem::exists(mqPath)) { if (std::filesystem::exists(mqPath)) {
OTRFiles.push_back(mqPath); OTRFiles.push_back(mqPath);
} }
std::string ootPath = Ship::Window::GetPathRelativeToAppDirectory("oot.otr"); std::string ootPath = Ship::Context::GetPathRelativeToAppDirectory("oot.otr");
if (std::filesystem::exists(ootPath)) { if (std::filesystem::exists(ootPath)) {
OTRFiles.push_back(ootPath); OTRFiles.push_back(ootPath);
} }
std::string sohOtrPath = Ship::Window::GetPathRelativeToAppBundle("soh.otr"); std::string sohOtrPath = Ship::Context::GetPathRelativeToAppBundle("soh.otr");
if (std::filesystem::exists(sohOtrPath)) { if (std::filesystem::exists(sohOtrPath)) {
OTRFiles.push_back(sohOtrPath); OTRFiles.push_back(sohOtrPath);
} }
std::string patchesPath = Ship::Window::GetPathRelativeToAppDirectory("mods"); std::string patchesPath = Ship::Context::GetPathRelativeToAppDirectory("mods");
if (patchesPath.length() > 0 && std::filesystem::exists(patchesPath)) { if (patchesPath.length() > 0 && std::filesystem::exists(patchesPath)) {
if (std::filesystem::is_directory(patchesPath)) { if (std::filesystem::is_directory(patchesPath)) {
for (const auto& p : std::filesystem::recursive_directory_iterator(patchesPath)) { for (const auto& p : std::filesystem::recursive_directory_iterator(patchesPath)) {
@ -240,7 +240,7 @@ OTRGlobals::OTRGlobals() {
OOT_PAL_GC_DBG1, OOT_PAL_GC_DBG1,
OOT_PAL_GC_DBG2 OOT_PAL_GC_DBG2
}; };
context = Ship::Window::CreateInstance("Ship of Harkinian", "soh", OTRFiles); context = Ship::Context::CreateInstance("Ship of Harkinian", "soh", OTRFiles);
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(Ship::ResourceType::SOH_Animation, "Animation", std::make_shared<Ship::AnimationFactory>()); context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(Ship::ResourceType::SOH_Animation, "Animation", std::make_shared<Ship::AnimationFactory>());
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(Ship::ResourceType::SOH_PlayerAnimation, "PlayerAnimation", std::make_shared<Ship::PlayerAnimationFactory>()); context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(Ship::ResourceType::SOH_PlayerAnimation, "PlayerAnimation", std::make_shared<Ship::PlayerAnimationFactory>());
@ -329,10 +329,10 @@ uint32_t OTRGlobals::GetInterpolationFPS() {
} }
if (CVarGetInteger("gMatchRefreshRate", 0)) { if (CVarGetInteger("gMatchRefreshRate", 0)) {
return Ship::Window::GetInstance()->GetCurrentRefreshRate(); return Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
} }
return std::min<uint32_t>(Ship::Window::GetInstance()->GetCurrentRefreshRate(), CVarGetInteger("gInterpolationFPS", 20)); return std::min<uint32_t>(Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), CVarGetInteger("gInterpolationFPS", 20));
} }
struct ExtensionEntry { struct ExtensionEntry {
@ -694,7 +694,7 @@ extern "C" uint32_t GetGIID(uint32_t itemID) {
} }
extern "C" void OTRExtScanner() { extern "C" void OTRExtScanner() {
auto lst = *OTRGlobals::Instance->context->GetResourceManager()->GetArchive()->ListFiles("*").get(); auto lst = *Ship::Context::GetInstance()->GetResourceManager()->GetArchive()->ListFiles("*").get();
for (auto& rPath : lst) { for (auto& rPath : lst) {
std::vector<std::string> raw = StringHelper::Split(rPath, "."); std::vector<std::string> raw = StringHelper::Split(rPath, ".");
@ -708,8 +708,8 @@ extern "C" void OTRExtScanner() {
extern "C" void InitOTR() { extern "C" void InitOTR() {
#if not defined (__SWITCH__) && not defined(__WIIU__) #if not defined (__SWITCH__) && not defined(__WIIU__)
if (!std::filesystem::exists(Ship::Window::GetPathRelativeToAppDirectory("oot-mq.otr")) && if (!std::filesystem::exists(Ship::Context::GetPathRelativeToAppDirectory("oot-mq.otr")) &&
!std::filesystem::exists(Ship::Window::GetPathRelativeToAppDirectory("oot.otr"))){ !std::filesystem::exists(Ship::Context::GetPathRelativeToAppDirectory("oot.otr"))){
if (Extractor::ShowYesNoBox("No OTR Files", "No OTR files found. Generate one now?") == IDYES) { if (Extractor::ShowYesNoBox("No OTR Files", "No OTR files found. Generate one now?") == IDYES) {
Extractor extract; Extractor extract;
if (!extract.Run()) { if (!extract.Run()) {
@ -791,9 +791,6 @@ extern "C" void InitOTR() {
extern "C" void DeinitOTR() { extern "C" void DeinitOTR() {
OTRAudio_Exit(); OTRAudio_Exit();
#if defined(_WIN32) || defined(__APPLE__)
SpeechSynthesizerUninitialize();
#endif
#ifdef ENABLE_CROWD_CONTROL #ifdef ENABLE_CROWD_CONTROL
CrowdControl::Instance->Disable(); CrowdControl::Instance->Disable();
CrowdControl::Instance->Shutdown(); CrowdControl::Instance->Shutdown();
@ -833,7 +830,7 @@ extern "C" uint64_t GetPerfCounter() {
// C->C++ Bridge // C->C++ Bridge
extern "C" void Graph_ProcessFrame(void (*run_one_game_iter)(void)) { extern "C" void Graph_ProcessFrame(void (*run_one_game_iter)(void)) {
OTRGlobals::Instance->context->MainLoop(run_one_game_iter); OTRGlobals::Instance->context->GetWindow()->MainLoop(run_one_game_iter);
} }
extern bool ShouldClearTextureCacheAtEndOfFrame; extern bool ShouldClearTextureCacheAtEndOfFrame;
@ -841,8 +838,8 @@ extern bool ShouldClearTextureCacheAtEndOfFrame;
extern "C" void Graph_StartFrame() { extern "C" void Graph_StartFrame() {
#ifndef __WIIU__ #ifndef __WIIU__
using Ship::KbScancode; using Ship::KbScancode;
int32_t dwScancode = OTRGlobals::Instance->context->GetLastScancode(); int32_t dwScancode = OTRGlobals::Instance->context->GetWindow()->GetLastScancode();
OTRGlobals::Instance->context->SetLastScancode(-1); OTRGlobals::Instance->context->GetWindow()->SetLastScancode(-1);
switch (dwScancode) { switch (dwScancode) {
case KbScancode::LUS_KB_F5: { case KbScancode::LUS_KB_F5: {
@ -911,7 +908,7 @@ extern "C" void Graph_StartFrame() {
} }
} }
#endif #endif
OTRGlobals::Instance->context->StartFrame(); OTRGlobals::Instance->context->GetWindow()->StartFrame();
} }
void RunCommands(Gfx* Commands, const std::vector<std::unordered_map<Mtx*, MtxF>>& mtx_replacements) { void RunCommands(Gfx* Commands, const std::vector<std::unordered_map<Mtx*, MtxF>>& mtx_replacements) {
@ -959,10 +956,10 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) {
time -= fps; time -= fps;
OTRGlobals::Instance->context->SetTargetFps(fps); OTRGlobals::Instance->context->GetWindow()->SetTargetFps(fps);
int threshold = CVarGetInteger("gExtraLatencyThreshold", 80); int threshold = CVarGetInteger("gExtraLatencyThreshold", 80);
OTRGlobals::Instance->context->SetMaximumFrameLatency(threshold > 0 && target_fps >= threshold ? 2 : 1); OTRGlobals::Instance->context->GetWindow()->SetMaximumFrameLatency(threshold > 0 && target_fps >= threshold ? 2 : 1);
RunCommands(commands, mtx_replacements); RunCommands(commands, mtx_replacements);
@ -991,19 +988,19 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) {
float divisor_num = 0.0f; float divisor_num = 0.0f;
extern "C" void OTRGetPixelDepthPrepare(float x, float y) { extern "C" void OTRGetPixelDepthPrepare(float x, float y) {
OTRGlobals::Instance->context->GetPixelDepthPrepare(x, y); OTRGlobals::Instance->context->GetWindow()->GetPixelDepthPrepare(x, y);
} }
extern "C" uint16_t OTRGetPixelDepth(float x, float y) { extern "C" uint16_t OTRGetPixelDepth(float x, float y) {
return OTRGlobals::Instance->context->GetPixelDepth(x, y); return OTRGlobals::Instance->context->GetWindow()->GetPixelDepth(x, y);
} }
extern "C" uint32_t ResourceMgr_GetNumGameVersions() { extern "C" uint32_t ResourceMgr_GetNumGameVersions() {
return OTRGlobals::Instance->context->GetResourceManager()->GetArchive()->GetGameVersions().size(); return Ship::Context::GetInstance()->GetResourceManager()->GetArchive()->GetGameVersions().size();
} }
extern "C" uint32_t ResourceMgr_GetGameVersion(int index) { extern "C" uint32_t ResourceMgr_GetGameVersion(int index) {
return OTRGlobals::Instance->context->GetResourceManager()->GetArchive()->GetGameVersions()[index]; return Ship::Context::GetInstance()->GetResourceManager()->GetArchive()->GetGameVersions()[index];
} }
uint32_t IsSceneMasterQuest(s16 sceneNum) { uint32_t IsSceneMasterQuest(s16 sceneNum) {
@ -1048,16 +1045,16 @@ extern "C" uint32_t ResourceMgr_IsGameMasterQuest() {
} }
extern "C" void ResourceMgr_LoadDirectory(const char* resName) { extern "C" void ResourceMgr_LoadDirectory(const char* resName) {
OTRGlobals::Instance->context->GetResourceManager()->LoadDirectory(resName); Ship::Context::GetInstance()->GetResourceManager()->LoadDirectory(resName);
} }
extern "C" void ResourceMgr_DirtyDirectory(const char* resName) { extern "C" void ResourceMgr_DirtyDirectory(const char* resName) {
OTRGlobals::Instance->context->GetResourceManager()->DirtyDirectory(resName); Ship::Context::GetInstance()->GetResourceManager()->DirtyDirectory(resName);
} }
// OTRTODO: There is probably a more elegant way to go about this... // OTRTODO: There is probably a more elegant way to go about this...
// Kenix: This is definitely leaking memory when it's called. // Kenix: This is definitely leaking memory when it's called.
extern "C" char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize) { extern "C" char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize) {
auto lst = OTRGlobals::Instance->context->GetResourceManager()->GetArchive()->ListFiles(searchMask); auto lst = Ship::Context::GetInstance()->GetResourceManager()->GetArchive()->ListFiles(searchMask);
char** result = (char**)malloc(lst->size() * sizeof(char*)); char** result = (char**)malloc(lst->size() * sizeof(char*));
for (size_t i = 0; i < lst->size(); i++) { for (size_t i = 0; i < lst->size(); i++) {
@ -1081,7 +1078,7 @@ extern "C" uint8_t ResourceMgr_FileExists(const char* filePath) {
} }
extern "C" void ResourceMgr_LoadFile(const char* resName) { extern "C" void ResourceMgr_LoadFile(const char* resName) {
OTRGlobals::Instance->context->GetResourceManager()->LoadResource(resName); Ship::Context::GetInstance()->GetResourceManager()->LoadResource(resName);
} }
std::shared_ptr<Ship::Resource> GetResourceByNameHandlingMQ(const char* path) { std::shared_ptr<Ship::Resource> GetResourceByNameHandlingMQ(const char* path) {
@ -1092,7 +1089,7 @@ std::shared_ptr<Ship::Resource> GetResourceByNameHandlingMQ(const char* path) {
Path.replace(pos, 7, "/mq/"); Path.replace(pos, 7, "/mq/");
} }
} }
return OTRGlobals::Instance->context->GetResourceManager()->LoadResource(Path.c_str()); return Ship::Context::GetInstance()->GetResourceManager()->LoadResource(Path.c_str());
} }
extern "C" char* GetResourceDataByNameHandlingMQ(const char* path) { extern "C" char* GetResourceDataByNameHandlingMQ(const char* path) {
@ -1219,7 +1216,7 @@ std::unordered_map<std::string, std::unordered_map<std::string, GfxPatch>> origi
// instead (When that is available). Index can be found using the commented out section below. // instead (When that is available). Index can be found using the commented out section below.
extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction) { extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction) {
auto res = std::static_pointer_cast<Ship::DisplayList>( auto res = std::static_pointer_cast<Ship::DisplayList>(
OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path));
// Leaving this here for people attempting to find the correct Dlist index to patch // Leaving this here for people attempting to find the correct Dlist index to patch
/*if (strcmp("__OTR__objects/object_gi_longsword/gGiBiggoronSwordDL", path) == 0) { /*if (strcmp("__OTR__objects/object_gi_longsword/gGiBiggoronSwordDL", path) == 0) {
@ -1254,7 +1251,7 @@ extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchNa
extern "C" void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName) { extern "C" void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName) {
if (originalGfx.contains(path) && originalGfx[path].contains(patchName)) { if (originalGfx.contains(path) && originalGfx[path].contains(patchName)) {
auto res = std::static_pointer_cast<Ship::DisplayList>( auto res = std::static_pointer_cast<Ship::DisplayList>(
OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path));
Gfx* gfx = (Gfx*)&res->Instructions[originalGfx[path][patchName].index]; Gfx* gfx = (Gfx*)&res->Instructions[originalGfx[path][patchName].index];
*gfx = originalGfx[path][patchName].instruction; *gfx = originalGfx[path][patchName].instruction;
@ -1292,15 +1289,15 @@ extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path) {
} }
extern "C" CollisionHeader* ResourceMgr_LoadColByName(const char* path) { extern "C" CollisionHeader* ResourceMgr_LoadColByName(const char* path) {
return (CollisionHeader*)GetResourceDataByName(path, false); return (CollisionHeader*) GetResourceDataByName(path);
} }
extern "C" Vtx* ResourceMgr_LoadVtxByName(char* path) { extern "C" Vtx* ResourceMgr_LoadVtxByName(char* path) {
return (Vtx*)GetResourceDataByName(path, false); return (Vtx*) GetResourceDataByName(path);
} }
extern "C" SequenceData ResourceMgr_LoadSeqByName(const char* path) { extern "C" SequenceData ResourceMgr_LoadSeqByName(const char* path) {
SequenceData* sequence = (SequenceData*)GetResourceDataByName(path, false); SequenceData* sequence = (SequenceData*) GetResourceDataByName(path);
return *sequence; return *sequence;
} }
@ -1314,7 +1311,7 @@ extern "C" SoundFontSample* ReadCustomSample(const char* path) {
ExtensionEntry entry = ExtensionCache[path]; ExtensionEntry entry = ExtensionCache[path];
auto sampleRaw = OTRGlobals::Instance->context->GetResourceManager()->LoadFile(entry.path); auto sampleRaw = Ship::Context::GetInstance()->GetResourceManager()->LoadFile(entry.path);
uint32_t* strem = (uint32_t*)sampleRaw->Buffer.get(); uint32_t* strem = (uint32_t*)sampleRaw->Buffer.get();
uint8_t* strem2 = (uint8_t*)strem; uint8_t* strem2 = (uint8_t*)strem;
@ -1365,11 +1362,11 @@ extern "C" SoundFontSample* ReadCustomSample(const char* path) {
} }
extern "C" SoundFontSample* ResourceMgr_LoadAudioSample(const char* path) { extern "C" SoundFontSample* ResourceMgr_LoadAudioSample(const char* path) {
return (SoundFontSample*)GetResourceDataByName(path, false); return (SoundFontSample*) GetResourceDataByName(path);
} }
extern "C" SoundFont* ResourceMgr_LoadAudioSoundFont(const char* path) { extern "C" SoundFont* ResourceMgr_LoadAudioSoundFont(const char* path) {
return (SoundFont*)GetResourceDataByName(path, false); return (SoundFont*) GetResourceDataByName(path);
} }
extern "C" int ResourceMgr_OTRSigCheck(char* imgData) extern "C" int ResourceMgr_OTRSigCheck(char* imgData)
@ -1391,7 +1388,7 @@ extern "C" int ResourceMgr_OTRSigCheck(char* imgData)
} }
extern "C" AnimationHeaderCommon* ResourceMgr_LoadAnimByName(const char* path) { extern "C" AnimationHeaderCommon* ResourceMgr_LoadAnimByName(const char* path) {
return (AnimationHeaderCommon*)GetResourceDataByName(path, false); return (AnimationHeaderCommon*) GetResourceDataByName(path);
} }
extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, SkelAnime* skelAnime) { extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, SkelAnime* skelAnime) {
@ -1408,11 +1405,11 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel
pathStr = Ship::Resource::gAltAssetPrefix + pathStr; pathStr = Ship::Resource::gAltAssetPrefix + pathStr;
} }
SkeletonHeader* skelHeader = (SkeletonHeader*)GetResourceDataByName(pathStr.c_str(), false); SkeletonHeader* skelHeader = (SkeletonHeader*) GetResourceDataByName(pathStr.c_str());
// If there isn't an alternate model, load the regular one // If there isn't an alternate model, load the regular one
if (isAlt && skelHeader == NULL) { if (isAlt && skelHeader == NULL) {
skelHeader = (SkeletonHeader*)GetResourceDataByName(path, false); skelHeader = (SkeletonHeader*) GetResourceDataByName(path);
} }
// This function is only called when a skeleton is initialized. // This function is only called when a skeleton is initialized.
@ -1440,7 +1437,7 @@ extern "C" s32* ResourceMgr_LoadCSByName(const char* path) {
} }
std::filesystem::path GetSaveFile(std::shared_ptr<Mercury> Conf) { std::filesystem::path GetSaveFile(std::shared_ptr<Mercury> Conf) {
const std::string fileName = Conf->getString("Game.SaveName", Ship::Window::GetPathRelativeToAppDirectory("oot_save.sav")); const std::string fileName = Conf->getString("Game.SaveName", Ship::Context::GetPathRelativeToAppDirectory("oot_save.sav"));
std::filesystem::path saveFile = std::filesystem::absolute(fileName); std::filesystem::path saveFile = std::filesystem::absolute(fileName);
if (!exists(saveFile.parent_path())) { if (!exists(saveFile.parent_path())) {
@ -1571,30 +1568,30 @@ extern "C" void OTRGfxPrint(const char* str, void* printer, void (*printImpl)(vo
} }
extern "C" uint32_t OTRGetCurrentWidth() { extern "C" uint32_t OTRGetCurrentWidth() {
return OTRGlobals::Instance->context->GetCurrentWidth(); return OTRGlobals::Instance->context->GetWindow()->GetCurrentWidth();
} }
extern "C" uint32_t OTRGetCurrentHeight() { extern "C" uint32_t OTRGetCurrentHeight() {
return OTRGlobals::Instance->context->GetCurrentHeight(); return OTRGlobals::Instance->context->GetWindow()->GetCurrentHeight();
} }
extern "C" void OTRControllerCallback(uint8_t rumble, uint8_t ledColor) { extern "C" void OTRControllerCallback(uint8_t rumble, uint8_t ledColor) {
auto controlDeck = Ship::Window::GetInstance()->GetControlDeck(); auto controlDeck = Ship::Context::GetInstance()->GetControlDeck();
for (int i = 0; i < controlDeck->GetNumConnectedPorts(); ++i) { for (int i = 0; i < controlDeck->GetNumConnectedPorts(); ++i) {
auto physicalDevice = controlDeck->GetDeviceFromPortIndex(i); auto physicalDevice = controlDeck->GetDeviceFromPortIndex(i);
switch (ledColor) { switch (ledColor) {
case 0: case 0:
physicalDevice->SetLed(i, 255, 0, 0); physicalDevice->SetLedColor(i, {255, 0, 0});
break; break;
case 1: case 1:
physicalDevice->SetLed(i, 0x1E, 0x69, 0x1B); physicalDevice->SetLedColor(i, {0x1E, 0x69, 0x1B});
break; break;
case 2: case 2:
physicalDevice->SetLed(i, 0x64, 0x14, 0x00); physicalDevice->SetLedColor(i, {0x64, 0x14, 0x00});
break; break;
case 3: case 3:
physicalDevice->SetLed(i, 0x00, 0x3C, 0x64); physicalDevice->SetLedColor(i, {0x00, 0x3C, 0x64});
break; break;
} }
@ -1642,7 +1639,7 @@ extern "C" void AudioPlayer_Play(const uint8_t* buf, uint32_t len) {
} }
extern "C" int Controller_ShouldRumble(size_t slot) { extern "C" int Controller_ShouldRumble(size_t slot) {
auto controlDeck = Ship::Window::GetInstance()->GetControlDeck(); auto controlDeck = Ship::Context::GetInstance()->GetControlDeck();
if (slot < controlDeck->GetNumConnectedPorts()) { if (slot < controlDeck->GetNumConnectedPorts()) {
auto physicalDevice = controlDeck->GetDeviceFromPortIndex(slot); auto physicalDevice = controlDeck->GetDeviceFromPortIndex(slot);
@ -1656,13 +1653,13 @@ extern "C" int Controller_ShouldRumble(size_t slot) {
} }
extern "C" void Controller_BlockGameInput() { extern "C" void Controller_BlockGameInput() {
auto controlDeck = Ship::Window::GetInstance()->GetControlDeck(); auto controlDeck = Ship::Context::GetInstance()->GetControlDeck();
controlDeck->BlockGameInput(); controlDeck->BlockGameInput();
} }
extern "C" void Controller_UnblockGameInput() { extern "C" void Controller_UnblockGameInput() {
auto controlDeck = Ship::Window::GetInstance()->GetControlDeck(); auto controlDeck = Ship::Context::GetInstance()->GetControlDeck();
controlDeck->UnblockGameInput(); controlDeck->UnblockGameInput();
} }

View file

@ -19,7 +19,7 @@ class OTRGlobals
public: public:
static OTRGlobals* Instance; static OTRGlobals* Instance;
std::shared_ptr<Ship::Window> context; std::shared_ptr<Ship::Context> context;
std::shared_ptr<SaveStateMgr> gSaveStateMgr; std::shared_ptr<SaveStateMgr> gSaveStateMgr;
std::shared_ptr<Randomizer> gRandomizer; std::shared_ptr<Randomizer> gRandomizer;

View file

@ -7,7 +7,7 @@
#include "macros.h" #include "macros.h"
#include <variables.h> #include <variables.h>
#include <Hooks.h> #include <Hooks.h>
#include <libultraship/bridge.h> #include <libultraship/libultraship.h>
#define NOGDI // avoid various windows defines that conflict with things in z64.h #define NOGDI // avoid various windows defines that conflict with things in z64.h
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
@ -41,7 +41,7 @@ void SaveManager::ReadSaveFile(std::filesystem::path savePath, uintptr_t addr, v
} }
std::filesystem::path SaveManager::GetFileName(int fileNum) { std::filesystem::path SaveManager::GetFileName(int fileNum) {
const std::filesystem::path sSavePath(Ship::Window::GetPathRelativeToAppDirectory("Save")); const std::filesystem::path sSavePath(Ship::Context::GetPathRelativeToAppDirectory("Save"));
return sSavePath / ("file" + std::to_string(fileNum + 1) + ".sav"); return sSavePath / ("file" + std::to_string(fileNum + 1) + ".sav");
} }
@ -342,10 +342,10 @@ void SaveManager::SaveRandomizer(SaveContext* saveContext) {
} }
void SaveManager::Init() { void SaveManager::Init() {
const std::filesystem::path sSavePath(Ship::Window::GetPathRelativeToAppDirectory("Save")); const std::filesystem::path sSavePath(Ship::Context::GetPathRelativeToAppDirectory("Save"));
const std::filesystem::path sGlobalPath = sSavePath / std::string("global.sav"); const std::filesystem::path sGlobalPath = sSavePath / std::string("global.sav");
auto sOldSavePath = Ship::Window::GetPathRelativeToAppDirectory("oot_save.sav"); auto sOldSavePath = Ship::Context::GetPathRelativeToAppDirectory("oot_save.sav");
auto sOldBackupSavePath = Ship::Window::GetPathRelativeToAppDirectory("oot_save.bak"); auto sOldBackupSavePath = Ship::Context::GetPathRelativeToAppDirectory("oot_save.bak");
Ship::RegisterHook<Ship::ExitGame>([this]() { ThreadPoolWait(); }); Ship::RegisterHook<Ship::ExitGame>([this]() { ThreadPoolWait(); });
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnExitGame>([this](uint32_t fileNum) { ThreadPoolWait(); }); GameInteractor::Instance->RegisterGameHook<GameInteractor::OnExitGame>([this](uint32_t fileNum) { ThreadPoolWait(); });
@ -771,7 +771,7 @@ void SaveManager::SaveGlobal() {
globalBlock["zTargetSetting"] = gSaveContext.zTargetSetting; globalBlock["zTargetSetting"] = gSaveContext.zTargetSetting;
globalBlock["language"] = gSaveContext.language; globalBlock["language"] = gSaveContext.language;
const std::filesystem::path sSavePath(Ship::Window::GetPathRelativeToAppDirectory("Save")); const std::filesystem::path sSavePath(Ship::Context::GetPathRelativeToAppDirectory("Save"));
const std::filesystem::path sGlobalPath = sSavePath / std::string("global.sav"); const std::filesystem::path sGlobalPath = sSavePath / std::string("global.sav");
std::ofstream output(sGlobalPath); std::ofstream output(sGlobalPath);

View file

@ -90,7 +90,7 @@ extern "C" SoundFontSample* ReadCustomSample(const char* path) {
ExtensionEntry entry = ExtensionCache[path]; ExtensionEntry entry = ExtensionCache[path];
auto sampleRaw = OTRGlobals::Instance->context->GetResourceManager()->LoadFile(entry.path); auto sampleRaw = Ship::Context::GetInstance()->GetResourceManager()->LoadFile(entry.path);
uint32_t* strem = (uint32_t*)sampleRaw->Buffer.get(); uint32_t* strem = (uint32_t*)sampleRaw->Buffer.get();
uint8_t* strem2 = (uint8_t*)strem; uint8_t* strem2 = (uint8_t*)strem;

View file

@ -1,7 +1,7 @@
#include "soh/resource/importer/AudioSoundFontFactory.h" #include "soh/resource/importer/AudioSoundFontFactory.h"
#include "soh/resource/type/AudioSoundFont.h" #include "soh/resource/type/AudioSoundFont.h"
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
#include "libultraship/bridge.h" #include "libultraship/libultraship.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> AudioSoundFontFactory::ReadResource(std::shared_ptr<ResourceManager> resourceMgr, std::shared_ptr<Resource> AudioSoundFontFactory::ReadResource(std::shared_ptr<ResourceManager> resourceMgr,
@ -87,7 +87,8 @@ void Ship::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader
if (sampleFileName.empty()) { if (sampleFileName.empty()) {
drum.sound.sample = nullptr; drum.sound.sample = nullptr;
} else { } else {
drum.sound.sample = static_cast<Sample*>(GetResourceDataByName(sampleFileName.c_str(), true)); auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str());
drum.sound.sample = static_cast<Sample*>(res ? res->GetPointer() : nullptr);
} }
audioSoundFont->drums.push_back(drum); audioSoundFont->drums.push_back(drum);
@ -130,7 +131,8 @@ void Ship::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader
bool hasSampleRef = reader->ReadInt8(); bool hasSampleRef = reader->ReadInt8();
std::string sampleFileName = reader->ReadString(); std::string sampleFileName = reader->ReadString();
instrument.lowNotesSound.tuning = reader->ReadFloat(); instrument.lowNotesSound.tuning = reader->ReadFloat();
instrument.lowNotesSound.sample = static_cast<Sample*>(GetResourceDataByName(sampleFileName.c_str(), true)); auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str());
instrument.lowNotesSound.sample = static_cast<Sample*>(res ? res->GetPointer() : nullptr);
} else { } else {
instrument.lowNotesSound.sample = nullptr; instrument.lowNotesSound.sample = nullptr;
instrument.lowNotesSound.tuning = 0; instrument.lowNotesSound.tuning = 0;
@ -141,7 +143,8 @@ void Ship::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader
bool hasSampleRef = reader->ReadInt8(); bool hasSampleRef = reader->ReadInt8();
std::string sampleFileName = reader->ReadString(); std::string sampleFileName = reader->ReadString();
instrument.normalNotesSound.tuning = reader->ReadFloat(); instrument.normalNotesSound.tuning = reader->ReadFloat();
instrument.normalNotesSound.sample = static_cast<Sample*>(GetResourceDataByName(sampleFileName.c_str(), true)); auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str());
instrument.normalNotesSound.sample = static_cast<Sample*>(res ? res->GetPointer() : nullptr);
} else { } else {
instrument.normalNotesSound.sample = nullptr; instrument.normalNotesSound.sample = nullptr;
instrument.normalNotesSound.tuning = 0; instrument.normalNotesSound.tuning = 0;
@ -152,7 +155,8 @@ void Ship::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader
bool hasSampleRef = reader->ReadInt8(); bool hasSampleRef = reader->ReadInt8();
std::string sampleFileName = reader->ReadString(); std::string sampleFileName = reader->ReadString();
instrument.highNotesSound.tuning = reader->ReadFloat(); instrument.highNotesSound.tuning = reader->ReadFloat();
instrument.highNotesSound.sample = static_cast<Sample*>(GetResourceDataByName(sampleFileName.c_str(), true)); auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str());
instrument.highNotesSound.sample = static_cast<Sample*>(res ? res->GetPointer() : nullptr);
} else { } else {
instrument.highNotesSound.sample = nullptr; instrument.highNotesSound.sample = nullptr;
instrument.highNotesSound.tuning = 0; instrument.highNotesSound.tuning = 0;
@ -176,7 +180,8 @@ void Ship::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader
bool hasSampleRef = reader->ReadInt8(); bool hasSampleRef = reader->ReadInt8();
std::string sampleFileName = reader->ReadString(); std::string sampleFileName = reader->ReadString();
soundEffect.tuning = reader->ReadFloat(); soundEffect.tuning = reader->ReadFloat();
soundEffect.sample = static_cast<Sample*>(GetResourceDataByName(sampleFileName.c_str(), true)); auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str());
soundEffect.sample = static_cast<Sample*>(res ? res->GetPointer() : nullptr);
} }
audioSoundFont->soundEffects.push_back(soundEffect); audioSoundFont->soundEffects.push_back(soundEffect);

View file

@ -1,7 +1,7 @@
#include "soh/resource/importer/SkeletonFactory.h" #include "soh/resource/importer/SkeletonFactory.h"
#include "soh/resource/type/Skeleton.h" #include "soh/resource/type/Skeleton.h"
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <libultraship/bridge.h> #include <libultraship/libultraship.h>
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SkeletonFactory::ReadResource(std::shared_ptr<ResourceManager> resourceMgr, std::shared_ptr<Resource> SkeletonFactory::ReadResource(std::shared_ptr<ResourceManager> resourceMgr,
@ -32,8 +32,8 @@ std::shared_ptr<Resource> SkeletonFactory::ReadResourceXML(std::shared_ptr<Resou
auto resource = std::make_shared<Skeleton>(resourceMgr, initData); auto resource = std::make_shared<Skeleton>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch ((Version)resource->InitData->ResourceVersion) { switch (resource->InitData->ResourceVersion) {
case Version::Deckard: case 0:
factory = std::make_shared<SkeletonFactoryV0>(); factory = std::make_shared<SkeletonFactoryV0>();
break; break;
} }
@ -85,8 +85,8 @@ void SkeletonFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
for (size_t i = 0; i < skeleton->limbTable.size(); i++) { for (size_t i = 0; i < skeleton->limbTable.size(); i++) {
std::string limbStr = skeleton->limbTable[i]; std::string limbStr = skeleton->limbTable[i];
auto limb = GetResourceDataByName(limbStr.c_str(), true); auto limb = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(limbStr.c_str());
skeleton->skeletonHeaderSegments.push_back(limb); skeleton->skeletonHeaderSegments.push_back(limb ? limb->GetPointer() : nullptr);
} }
if (skeleton->type == Ship::SkeletonType::Normal) { if (skeleton->type == Ship::SkeletonType::Normal) {
@ -142,8 +142,8 @@ void SkeletonFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_p
std::string limbName = child->Attribute("Path"); std::string limbName = child->Attribute("Path");
skel->limbTable.push_back(limbName); skel->limbTable.push_back(limbName);
auto limb = GetResourceDataByName(limbName.c_str(), true); auto limb = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(limbName.c_str());
skel->skeletonHeaderSegments.push_back(limb); skel->skeletonHeaderSegments.push_back(limb ? limb->GetPointer() : nullptr);
} }
child = child->NextSiblingElement(); child = child->NextSiblingElement();

View file

@ -1,7 +1,7 @@
#include "soh/resource/importer/SkeletonLimbFactory.h" #include "soh/resource/importer/SkeletonLimbFactory.h"
#include "soh/resource/type/SkeletonLimb.h" #include "soh/resource/type/SkeletonLimb.h"
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
#include "libultraship/bridge.h" #include "libultraship/libultraship.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SkeletonLimbFactory::ReadResource(std::shared_ptr<ResourceManager> resourceMgr, std::shared_ptr<Resource> SkeletonLimbFactory::ReadResource(std::shared_ptr<ResourceManager> resourceMgr,
@ -32,8 +32,8 @@ std::shared_ptr<Resource> SkeletonLimbFactory::ReadResourceXML(std::shared_ptr<R
auto resource = std::make_shared<SkeletonLimb>(resourceMgr, initData); auto resource = std::make_shared<SkeletonLimb>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch ((Version)resource->InitData->ResourceVersion) { switch (resource->InitData->ResourceVersion) {
case Version::Deckard: case 0:
factory = std::make_shared<SkeletonLimbFactoryV0>(); factory = std::make_shared<SkeletonLimbFactoryV0>();
break; break;
} }
@ -134,15 +134,15 @@ void Ship::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader>
skeletonLimb->limbData.lodLimb.sibling = skeletonLimb->siblingIndex; skeletonLimb->limbData.lodLimb.sibling = skeletonLimb->siblingIndex;
if (skeletonLimb->dListPtr != "") { if (skeletonLimb->dListPtr != "") {
auto dList = GetResourceDataByName(skeletonLimb->dListPtr.c_str(), true); auto dList = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dListPtr.c_str());
skeletonLimb->limbData.lodLimb.dLists[0] = (Gfx*)dList; skeletonLimb->limbData.lodLimb.dLists[0] = (Gfx*)(dList ? dList->GetPointer() : nullptr);
} else { } else {
skeletonLimb->limbData.lodLimb.dLists[0] = nullptr; skeletonLimb->limbData.lodLimb.dLists[0] = nullptr;
} }
if (skeletonLimb->dList2Ptr != "") { if (skeletonLimb->dList2Ptr != "") {
auto dList = GetResourceDataByName(skeletonLimb->dList2Ptr.c_str(), true); auto dList = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dList2Ptr.c_str());
skeletonLimb->limbData.lodLimb.dLists[1] = (Gfx*)dList; skeletonLimb->limbData.lodLimb.dLists[1] = (Gfx*)(dList ? dList->GetPointer() : nullptr);
} else { } else {
skeletonLimb->limbData.lodLimb.dLists[1] = nullptr; skeletonLimb->limbData.lodLimb.dLists[1] = nullptr;
} }
@ -155,8 +155,8 @@ void Ship::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader>
skeletonLimb->limbData.standardLimb.dList = nullptr; skeletonLimb->limbData.standardLimb.dList = nullptr;
if (!skeletonLimb->dListPtr.empty()) { if (!skeletonLimb->dListPtr.empty()) {
const auto dList = GetResourceDataByName(skeletonLimb->dListPtr.c_str(), true); const auto dList = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dListPtr.c_str());
skeletonLimb->limbData.standardLimb.dList = (Gfx*)dList; skeletonLimb->limbData.standardLimb.dList = (Gfx*)(dList ? dList->GetPointer() : nullptr);
} }
} else if (skeletonLimb->limbType == Ship::LimbType::Curve) { } else if (skeletonLimb->limbType == Ship::LimbType::Curve) {
skeletonLimb->limbData.skelCurveLimb.firstChildIdx = skeletonLimb->childIndex; skeletonLimb->limbData.skelCurveLimb.firstChildIdx = skeletonLimb->childIndex;
@ -165,13 +165,13 @@ void Ship::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader>
skeletonLimb->limbData.skelCurveLimb.dList[1] = nullptr; skeletonLimb->limbData.skelCurveLimb.dList[1] = nullptr;
if (!skeletonLimb->dListPtr.empty()) { if (!skeletonLimb->dListPtr.empty()) {
const auto dList = GetResourceDataByName(skeletonLimb->dListPtr.c_str(), true); const auto dList = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dListPtr.c_str());
skeletonLimb->limbData.skelCurveLimb.dList[0] = (Gfx*)dList; skeletonLimb->limbData.skelCurveLimb.dList[0] = (Gfx*)(dList ? dList->GetPointer() : nullptr);
} }
if (!skeletonLimb->dList2Ptr.empty()) { if (!skeletonLimb->dList2Ptr.empty()) {
const auto dList = GetResourceDataByName(skeletonLimb->dList2Ptr.c_str(), true); const auto dList = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dList2Ptr.c_str());
skeletonLimb->limbData.skelCurveLimb.dList[1] = (Gfx*)dList; skeletonLimb->limbData.skelCurveLimb.dList[1] = (Gfx*)(dList ? dList->GetPointer() : nullptr);
} }
} else if (skeletonLimb->limbType == Ship::LimbType::Skin) { } else if (skeletonLimb->limbType == Ship::LimbType::Skin) {
skeletonLimb->limbData.skinLimb.jointPos.x = skeletonLimb->transX; skeletonLimb->limbData.skinLimb.jointPos.x = skeletonLimb->transX;
@ -191,12 +191,14 @@ void Ship::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader>
} }
if (skeletonLimb->skinSegmentType == Ship::ZLimbSkinType::SkinType_DList) { if (skeletonLimb->skinSegmentType == Ship::ZLimbSkinType::SkinType_DList) {
skeletonLimb->limbData.skinLimb.segment = GetResourceDataByName(skeletonLimb->skinDList.c_str(), true); auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->skinDList.c_str());
skeletonLimb->limbData.skinLimb.segment = res ? res->GetPointer() : nullptr;
} else if (skeletonLimb->skinSegmentType == Ship::ZLimbSkinType::SkinType_4) { } else if (skeletonLimb->skinSegmentType == Ship::ZLimbSkinType::SkinType_4) {
skeletonLimb->skinAnimLimbData.totalVtxCount = skeletonLimb->skinVtxCnt; skeletonLimb->skinAnimLimbData.totalVtxCount = skeletonLimb->skinVtxCnt;
skeletonLimb->skinAnimLimbData.limbModifCount = skeletonLimb->skinLimbModifCount; skeletonLimb->skinAnimLimbData.limbModifCount = skeletonLimb->skinLimbModifCount;
skeletonLimb->skinAnimLimbData.limbModifications = skeletonLimb->skinLimbModifArray.data(); skeletonLimb->skinAnimLimbData.limbModifications = skeletonLimb->skinLimbModifArray.data();
skeletonLimb->skinAnimLimbData.dlist = (Gfx*)GetResourceDataByName(skeletonLimb->skinDList2.c_str(), true); auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->skinDList2.c_str());
skeletonLimb->skinAnimLimbData.dlist = (Gfx*)(res ? res->GetPointer() : nullptr);
for (size_t i = 0; i < skeletonLimb->skinLimbModifArray.size(); i++) { for (size_t i = 0; i < skeletonLimb->skinLimbModifArray.size(); i++) {
skeletonLimb->skinAnimLimbData.limbModifications[i].vtxCount = skeletonLimb->skinLimbModifVertexArrays[i].size(); skeletonLimb->skinAnimLimbData.limbModifications[i].vtxCount = skeletonLimb->skinLimbModifVertexArrays[i].size();
@ -254,7 +256,8 @@ void SkeletonLimbFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shar
limbData.lodLimb.jointPos.z = skelLimb->transZ; limbData.lodLimb.jointPos.z = skelLimb->transZ;
if (skelLimb->dListPtr != "") { if (skelLimb->dListPtr != "") {
limbData.lodLimb.dLists[0] = (Gfx*)GetResourceDataByName((const char*)skelLimb->dListPtr.c_str(), true); auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess((const char*)skelLimb->dListPtr.c_str());
limbData.lodLimb.dLists[0] = (Gfx*)(res ? res->GetPointer() : nullptr);
} else { } else {
limbData.lodLimb.dLists[0] = nullptr; limbData.lodLimb.dLists[0] = nullptr;
} }

View file

@ -34,8 +34,8 @@ std::shared_ptr<Resource> TextFactory::ReadResourceXML(std::shared_ptr<ResourceM
auto resource = std::make_shared<Text>(resourceMgr, initData); auto resource = std::make_shared<Text>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr; std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch ((Version)resource->InitData->ResourceVersion) { switch (resource->InitData->ResourceVersion) {
case Version::Deckard: case 0:
factory = std::make_shared<TextFactoryV0>(); factory = std::make_shared<TextFactoryV0>();
break; break;
} }

View file

@ -1,7 +1,7 @@
#include "soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h" #include "soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h"
#include "soh/resource/type/scenecommand/SetAlternateHeaders.h" #include "soh/resource/type/scenecommand/SetAlternateHeaders.h"
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
#include "libultraship/bridge.h" #include "libultraship/libultraship.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetAlternateHeadersFactory::ReadResource(std::shared_ptr<ResourceManager> resourceMgr, std::shared_ptr<Resource> SetAlternateHeadersFactory::ReadResource(std::shared_ptr<ResourceManager> resourceMgr,
@ -40,7 +40,7 @@ void Ship::SetAlternateHeadersFactoryV0::ParseFileBinary(std::shared_ptr<BinaryR
for (uint32_t i = 0; i < setAlternateHeaders->numHeaders; i++) { for (uint32_t i = 0; i < setAlternateHeaders->numHeaders; i++) {
auto headerName = reader->ReadString(); auto headerName = reader->ReadString();
if (!headerName.empty()) { if (!headerName.empty()) {
setAlternateHeaders->headers.push_back(std::static_pointer_cast<Ship::Scene>(LoadResource(headerName.c_str(), true))); setAlternateHeaders->headers.push_back(std::static_pointer_cast<Ship::Scene>(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str())));
} else { } else {
setAlternateHeaders->headers.push_back(nullptr); setAlternateHeaders->headers.push_back(nullptr);
} }

View file

@ -1,6 +1,6 @@
#include "soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h" #include "soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h"
#include "soh/resource/type/scenecommand/SetCollisionHeader.h" #include "soh/resource/type/scenecommand/SetCollisionHeader.h"
#include "libultraship/bridge.h" #include "libultraship/libultraship.h"
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
@ -34,7 +34,7 @@ void Ship::SetCollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptr<BinaryRe
ReadCommandId(setCollisionHeader, reader); ReadCommandId(setCollisionHeader, reader);
setCollisionHeader->fileName = reader->ReadString(); setCollisionHeader->fileName = reader->ReadString();
setCollisionHeader->collisionHeader = std::static_pointer_cast<CollisionHeader>(LoadResource(setCollisionHeader->fileName.c_str(), true)); setCollisionHeader->collisionHeader = std::static_pointer_cast<CollisionHeader>(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCollisionHeader->fileName.c_str()));
} }
} // namespace Ship } // namespace Ship

View file

@ -1,6 +1,6 @@
#include "soh/resource/importer/scenecommand/SetCutscenesFactory.h" #include "soh/resource/importer/scenecommand/SetCutscenesFactory.h"
#include "soh/resource/type/scenecommand/SetCutscenes.h" #include "soh/resource/type/scenecommand/SetCutscenes.h"
#include <libultraship/bridge.h> #include <libultraship/libultraship.h>
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace Ship { namespace Ship {
@ -35,7 +35,7 @@ void Ship::SetCutscenesFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader>
ReadCommandId(setCutscenes, reader); ReadCommandId(setCutscenes, reader);
setCutscenes->fileName = reader->ReadString(); setCutscenes->fileName = reader->ReadString();
setCutscenes->cutscene = std::static_pointer_cast<Cutscene>(LoadResource(setCutscenes->fileName.c_str(), true)); setCutscenes->cutscene = std::static_pointer_cast<Cutscene>(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCutscenes->fileName.c_str()));
} }
} // namespace Ship } // namespace Ship

View file

@ -1,7 +1,7 @@
#include "soh/resource/importer/scenecommand/SetMeshFactory.h" #include "soh/resource/importer/scenecommand/SetMeshFactory.h"
#include "soh/resource/type/scenecommand/SetMesh.h" #include "soh/resource/type/scenecommand/SetMesh.h"
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
#include "libultraship/bridge.h" #include "libultraship/libultraship.h"
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetMeshFactory::ReadResource(std::shared_ptr<ResourceManager> resourceMgr, std::shared_ptr<Resource> SetMeshFactory::ReadResource(std::shared_ptr<ResourceManager> resourceMgr,
@ -65,8 +65,10 @@ void Ship::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reade
std::string meshOpa = reader->ReadString(); std::string meshOpa = reader->ReadString();
std::string meshXlu = reader->ReadString(); std::string meshXlu = reader->ReadString();
dlist.opa = meshOpa != "" ? (Gfx*)GetResourceDataByName(meshOpa.c_str(), true) : 0; auto opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str());
dlist.xlu = meshXlu != "" ? (Gfx*)GetResourceDataByName(meshXlu.c_str(), true) : 0; auto xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str());
dlist.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetPointer() : nullptr) : 0;
dlist.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetPointer() : nullptr) : 0;
setMesh->dlists.push_back(dlist); setMesh->dlists.push_back(dlist);
} else if (setMesh->meshHeader.base.type == 1) { } else if (setMesh->meshHeader.base.type == 1) {
@ -76,8 +78,10 @@ void Ship::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reade
std::string imgOpa = reader->ReadString(); std::string imgOpa = reader->ReadString();
std::string imgXlu = reader->ReadString(); std::string imgXlu = reader->ReadString();
pType.opa = imgOpa != "" ? (Gfx*)GetResourceDataByName(imgOpa.c_str(), true) : 0; auto opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgOpa.c_str());
pType.xlu = imgXlu != "" ? (Gfx*)GetResourceDataByName(imgXlu.c_str(), true) : 0; auto xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgXlu.c_str());
pType.opa = imgOpa != "" ? (Gfx*)(opaRes ? opaRes->GetPointer() : nullptr) : 0;
pType.xlu = imgXlu != "" ? (Gfx*)(xluRes ? xluRes->GetPointer() : nullptr) : 0;
int32_t bgImageCount = reader->ReadUInt32(); int32_t bgImageCount = reader->ReadUInt32();
setMesh->images.reserve(bgImageCount); setMesh->images.reserve(bgImageCount);
@ -122,8 +126,10 @@ void Ship::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reade
std::string meshOpa = reader->ReadString(); std::string meshOpa = reader->ReadString();
std::string meshXlu = reader->ReadString(); std::string meshXlu = reader->ReadString();
pType.opa = meshOpa != "" ? (Gfx*)GetResourceDataByName(meshOpa.c_str(), true) : 0; opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str());
pType.xlu = meshXlu != "" ? (Gfx*)GetResourceDataByName(meshXlu.c_str(), true) : 0; xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str());
pType.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetPointer() : nullptr) : 0;
pType.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetPointer() : nullptr) : 0;
setMesh->dlists.push_back(pType); setMesh->dlists.push_back(pType);
} else if (setMesh->meshHeader.base.type == 2) { } else if (setMesh->meshHeader.base.type == 2) {
@ -138,8 +144,10 @@ void Ship::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reade
std::string meshOpa = reader->ReadString(); std::string meshOpa = reader->ReadString();
std::string meshXlu = reader->ReadString(); std::string meshXlu = reader->ReadString();
dlist.opa = meshOpa != "" ? (Gfx*)GetResourceDataByName(meshOpa.c_str(), true) : 0; auto opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str());
dlist.xlu = meshXlu != "" ? (Gfx*)GetResourceDataByName(meshXlu.c_str(), true) : 0; auto xluRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str());
dlist.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetPointer() : nullptr) : 0;
dlist.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetPointer() : nullptr) : 0;
setMesh->dlists2.push_back(dlist); setMesh->dlists2.push_back(dlist);
} else { } else {

View file

@ -1,7 +1,7 @@
#include "soh/resource/importer/scenecommand/SetPathwaysFactory.h" #include "soh/resource/importer/scenecommand/SetPathwaysFactory.h"
#include "soh/resource/type/scenecommand/SetPathways.h" #include "soh/resource/type/scenecommand/SetPathways.h"
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
#include <libultraship/bridge.h> #include <libultraship/libultraship.h>
namespace Ship { namespace Ship {
std::shared_ptr<Resource> SetPathwaysFactory::ReadResource(std::shared_ptr<ResourceManager> resourceMgr, std::shared_ptr<Resource> SetPathwaysFactory::ReadResource(std::shared_ptr<ResourceManager> resourceMgr,
@ -37,7 +37,7 @@ void Ship::SetPathwaysFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> r
setPathways->paths.reserve(setPathways->numPaths); setPathways->paths.reserve(setPathways->numPaths);
for (uint32_t i = 0; i < setPathways->numPaths; i++) { for (uint32_t i = 0; i < setPathways->numPaths; i++) {
std::string pathFileName = reader->ReadString(); std::string pathFileName = reader->ReadString();
setPathways->paths.push_back(std::static_pointer_cast<Path>(LoadResource(pathFileName.c_str(), true))); setPathways->paths.push_back(std::static_pointer_cast<Path>(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(pathFileName.c_str())));
} }
} }

View file

@ -69,7 +69,7 @@ void SkeletonPatcher::UpdateSkeletons() {
for (auto skel : skeletons) for (auto skel : skeletons)
{ {
Skeleton* newSkel = Skeleton* newSkel =
(Skeleton*)OTRGlobals::Instance->context->GetResourceManager() (Skeleton*)Ship::Context::GetInstance()->GetResourceManager()
->LoadResource((isHD ? Ship::Resource::gAltAssetPrefix : "") + skel.vanillaSkeletonPath, true) ->LoadResource((isHD ? Ship::Resource::gAltAssetPrefix : "") + skel.vanillaSkeletonPath, true)
.get(); .get();

View file

@ -1,5 +1,5 @@
#include "OTRGlobals.h" #include "OTRGlobals.h"
#include <ResourceManager.h> #include <libultraship/libultraship.h>
#include "soh/resource/type/Scene.h" #include "soh/resource/type/Scene.h"
#include <Utils/StringHelper.h> #include <Utils/StringHelper.h>
#include "global.h" #include "global.h"
@ -16,7 +16,7 @@ extern "C" MessageTableEntry* sStaffMessageEntryTablePtr;
//extern "C" MessageTableEntry* _message_0xFFFC_nes; //extern "C" MessageTableEntry* _message_0xFFFC_nes;
MessageTableEntry* OTRMessage_LoadTable(const char* filePath, bool isNES) { MessageTableEntry* OTRMessage_LoadTable(const char* filePath, bool isNES) {
auto file = std::static_pointer_cast<Ship::Text>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(filePath)); auto file = std::static_pointer_cast<Ship::Text>(Ship::Context::GetInstance()->GetResourceManager()->LoadResource(filePath));
if (file == nullptr) if (file == nullptr)
return nullptr; return nullptr;
@ -92,7 +92,7 @@ extern "C" void OTRMessage_Init()
if (sStaffMessageEntryTablePtr == NULL) { if (sStaffMessageEntryTablePtr == NULL) {
auto file2 = auto file2 =
std::static_pointer_cast<Ship::Text>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource( std::static_pointer_cast<Ship::Text>(Ship::Context::GetInstance()->GetResourceManager()->LoadResource(
"text/staff_message_data_static/staff_message_data_static")); "text/staff_message_data_static/staff_message_data_static"));
// OTRTODO: Should not be malloc'ing here. It's fine for now since we check that the message table is already null. // OTRTODO: Should not be malloc'ing here. It's fine for now since we check that the message table is already null.
sStaffMessageEntryTablePtr = (MessageTableEntry*)malloc(sizeof(MessageTableEntry) * file2->messages.size()); sStaffMessageEntryTablePtr = (MessageTableEntry*)malloc(sizeof(MessageTableEntry) * file2->messages.size());

View file

@ -1,5 +1,5 @@
#include "OTRGlobals.h" #include "OTRGlobals.h"
#include <ResourceManager.h> #include <libultraship/libultraship.h>
#include "soh/resource/type/Scene.h" #include "soh/resource/type/Scene.h"
#include <Utils/StringHelper.h> #include <Utils/StringHelper.h>
#include "soh/Enhancements/game-interactor/GameInteractor.h" #include "soh/Enhancements/game-interactor/GameInteractor.h"
@ -15,7 +15,7 @@ s32 OTRScene_ExecuteCommands(PlayState* play, Ship::Scene* scene);
//Ship::OTRResource* OTRPlay_LoadFile(PlayState* play, RomFile* file) { //Ship::OTRResource* OTRPlay_LoadFile(PlayState* play, RomFile* file) {
Ship::Resource* OTRPlay_LoadFile(PlayState* play, const char* fileName) Ship::Resource* OTRPlay_LoadFile(PlayState* play, const char* fileName)
{ {
auto res = OTRGlobals::Instance->context->GetResourceManager()->LoadResource(fileName); auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(fileName);
return res.get(); return res.get();
} }
@ -76,7 +76,7 @@ void OTRPlay_InitScene(PlayState* play, s32 spawn) {
gSaveContext.worldMapArea = 0; gSaveContext.worldMapArea = 0;
OTRScene_ExecuteCommands(play, (Ship::Scene*)play->sceneSegment); OTRScene_ExecuteCommands(play, (Ship::Scene*)play->sceneSegment);
Play_InitEnvironment(play, play->skyboxId); Play_InitEnvironment(play, play->skyboxId);
/* auto data = static_cast<Ship::Vertex*>(Ship::Window::GetInstance() /* auto data = static_cast<Ship::Vertex*>(Ship::Context::GetInstance()
->GetResourceManager() ->GetResourceManager()
->LoadResource("object_link_child\\object_link_childVtx_01FE08") ->LoadResource("object_link_child\\object_link_childVtx_01FE08")
.get()); .get());

View file

@ -1,5 +1,5 @@
#include "OTRGlobals.h" #include "OTRGlobals.h"
#include <ResourceManager.h> #include <libultraship/libultraship.h>
#include "soh/resource/type/Scene.h" #include "soh/resource/type/Scene.h"
#include <Utils/StringHelper.h> #include <Utils/StringHelper.h>
#include "global.h" #include "global.h"
@ -46,7 +46,7 @@ std::shared_ptr<Ship::File> ResourceMgr_LoadFile(const char* path) {
Path.replace(pos, 7, "/mq/"); Path.replace(pos, 7, "/mq/");
} }
} }
return OTRGlobals::Instance->context->GetResourceManager()->LoadFile(Path.c_str()); return Ship::Context::GetInstance()->GetResourceManager()->LoadFile(Path.c_str());
} }
// Forward Declaration of function declared in OTRGlobals.cpp // Forward Declaration of function declared in OTRGlobals.cpp

View file

@ -4,6 +4,7 @@
#include "global.h" #include "global.h"
#include "vt.h" #include "vt.h"
#include "stdio.h"
#include <soh/Enhancements/bootcommands.h> #include <soh/Enhancements/bootcommands.h>
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"

View file

@ -413,7 +413,7 @@ void Map_InitData(PlayState* play, s16 room) {
//gMapData->owMinimapTexSize[mapIndex], __FILE__, __LINE__); //gMapData->owMinimapTexSize[mapIndex], __FILE__, __LINE__);
if (sEntranceIconMapIndex < 24) { if (sEntranceIconMapIndex < 24) {
play->interfaceCtx.mapSegment[0] = GetResourceDataByName(minimapTableOW[sEntranceIconMapIndex], true); play->interfaceCtx.mapSegment[0] = GetResourceDataByName(minimapTableOW[sEntranceIconMapIndex]);
play->interfaceCtx.mapSegmentName[0] = minimapTableOW[sEntranceIconMapIndex]; play->interfaceCtx.mapSegmentName[0] = minimapTableOW[sEntranceIconMapIndex];
} }
@ -447,7 +447,8 @@ void Map_InitData(PlayState* play, s16 room) {
//((gMapData->dgnMinimapTexIndexOffset[mapIndex] + room) * 0xFF0), //((gMapData->dgnMinimapTexIndexOffset[mapIndex] + room) * 0xFF0),
//0xFF0, __FILE__, __LINE__); //0xFF0, __FILE__, __LINE__);
play->interfaceCtx.mapSegment[0] = GetResourceDataByName(minimapTableDangeon[gMapData->dgnMinimapTexIndexOffset[mapIndex] + room], true); play->interfaceCtx.mapSegment[0] = GetResourceDataByName(
minimapTableDangeon[gMapData->dgnMinimapTexIndexOffset[mapIndex] + room]);
play->interfaceCtx.mapSegmentName[0] = minimapTableDangeon[gMapData->dgnMinimapTexIndexOffset[mapIndex] + room]; play->interfaceCtx.mapSegmentName[0] = minimapTableDangeon[gMapData->dgnMinimapTexIndexOffset[mapIndex] + room];
R_COMPASS_OFFSET_X = gMapData->roomCompassOffsetX[mapIndex][room]; R_COMPASS_OFFSET_X = gMapData->roomCompassOffsetX[mapIndex][room];
R_COMPASS_OFFSET_Y = gMapData->roomCompassOffsetY[mapIndex][room]; R_COMPASS_OFFSET_Y = gMapData->roomCompassOffsetY[mapIndex][room];

View file

@ -332,8 +332,8 @@ void Player_SetBootData(PlayState* play, Player* this) {
// Custom method used to determine if we're using a custom model for link // Custom method used to determine if we're using a custom model for link
uint8_t Player_IsCustomLinkModel() { uint8_t Player_IsCustomLinkModel() {
return (LINK_IS_ADULT && GetResourceIsCustomByName(gLinkAdultSkel, true)) || return (LINK_IS_ADULT && GetResourceIsCustomByName(gLinkAdultSkel)) ||
(LINK_IS_CHILD && GetResourceIsCustomByName(gLinkChildSkel, true)); (LINK_IS_CHILD && GetResourceIsCustomByName(gLinkChildSkel));
} }
s32 Player_InBlockingCsMode(PlayState* play, Player* this) { s32 Player_InBlockingCsMode(PlayState* play, Player* this) {

View file

@ -273,7 +273,7 @@ void func_8009638C(Gfx** displayList, void* source, void* tlut, u16 width, u16 h
bg->b.imageFlip = 0; bg->b.imageFlip = 0;
if (ResourceMgr_ResourceIsBackground((char*) source)) { if (ResourceMgr_ResourceIsBackground((char*) source)) {
char* blob = (char*) GetResourceDataByName((char*) source, true); char* blob = (char*) GetResourceDataByName((char *) source);
swapAndConvertJPEG(blob); swapAndConvertJPEG(blob);
bg->b.imagePtr = (uintptr_t) blob; bg->b.imagePtr = (uintptr_t) blob;
} }

View file

@ -87,7 +87,7 @@ void func_808C12C4(u8* arg1, s16 arg2) {
void func_808C1554(void* arg0, void* floorTex, s32 arg2, f32 arg3) { void func_808C1554(void* arg0, void* floorTex, s32 arg2, f32 arg3) {
arg0 = GetResourceDataByNameHandlingMQ(arg0); arg0 = GetResourceDataByNameHandlingMQ(arg0);
floorTex = GetResourceDataByName(floorTex, false); floorTex = GetResourceDataByName(floorTex);
u16* temp_s3 = SEGMENTED_TO_VIRTUAL(arg0); u16* temp_s3 = SEGMENTED_TO_VIRTUAL(arg0);
u16* temp_s1 = SEGMENTED_TO_VIRTUAL(floorTex); u16* temp_s1 = SEGMENTED_TO_VIRTUAL(floorTex);
@ -186,8 +186,8 @@ void BossDodongo_Init(Actor* thisx, PlayState* play) {
Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->items); Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->items);
if (Flags_GetClear(play, play->roomCtx.curRoom.num)) { // KD is dead if (Flags_GetClear(play, play->roomCtx.curRoom.num)) { // KD is dead
u16* LavaFloorTex = GetResourceDataByName(gDodongosCavernBossLavaFloorTex, false); u16* LavaFloorTex = GetResourceDataByName(gDodongosCavernBossLavaFloorTex);
u16* LavaFloorRockTex = GetResourceDataByName(sLavaFloorRockTex, false); u16* LavaFloorRockTex = GetResourceDataByName(sLavaFloorRockTex);
temp_s1_3 = SEGMENTED_TO_VIRTUAL(LavaFloorTex); temp_s1_3 = SEGMENTED_TO_VIRTUAL(LavaFloorTex);
temp_s2 = SEGMENTED_TO_VIRTUAL(LavaFloorRockTex); temp_s2 = SEGMENTED_TO_VIRTUAL(LavaFloorRockTex);
Actor_Kill(&this->actor); Actor_Kill(&this->actor);
@ -1018,8 +1018,8 @@ void BossDodongo_Update(Actor* thisx, PlayState* play2) {
} }
if (this->unk_1C6 != 0) { if (this->unk_1C6 != 0) {
u16* ptr1 = GetResourceDataByName(sLavaFloorLavaTex, false); u16* ptr1 = GetResourceDataByName(sLavaFloorLavaTex);
u16* ptr2 = GetResourceDataByName(sLavaFloorRockTex, false); u16* ptr2 = GetResourceDataByName(sLavaFloorRockTex);
s16 i2; s16 i2;
for (i2 = 0; i2 < 20; i2++) { for (i2 = 0; i2 < 20; i2++) {

View file

@ -1220,7 +1220,7 @@ void BossGanon_SetupTowerCutscene(BossGanon* this, PlayState* play) {
void BossGanon_ShatterWindows(u8 windowShatterState) { void BossGanon_ShatterWindows(u8 windowShatterState) {
s16 i; s16 i;
u8* templateTex = GetResourceDataByName(SEGMENTED_TO_VIRTUAL(gGanondorfWindowShatterTemplateTex), false); u8* templateTex = GetResourceDataByName(SEGMENTED_TO_VIRTUAL(gGanondorfWindowShatterTemplateTex));
for (i = 0; i < ARRAY_COUNT(sWindowShatterTex); i++) { for (i = 0; i < ARRAY_COUNT(sWindowShatterTex); i++) {
if ((sWindowShatterTex[i] != 1) && (Rand_ZeroOne() < 0.03f)) { if ((sWindowShatterTex[i] != 1) && (Rand_ZeroOne() < 0.03f)) {

View file

@ -397,7 +397,7 @@ void EnJsjutan_Draw(Actor* thisx, PlayState* play2) {
if (this->unk_164) { if (this->unk_164) {
this->unk_164 = false; this->unk_164 = false;
u8* carpTex = GetResourceDataByName(sCarpetTex, false); u8* carpTex = GetResourceDataByName(sCarpetTex);
u8* shadTex = sShadowTex; u8* shadTex = sShadowTex;
for (i = 0; i < ARRAY_COUNT(sShadowTex); i++) { for (i = 0; i < ARRAY_COUNT(sShadowTex); i++) {
if (((u16*)carpTex)[i] != 0) { // Hack to bypass ZAPD exporting textures as u64. if (((u16*)carpTex)[i] != 0) { // Hack to bypass ZAPD exporting textures as u64.

View file

@ -3173,8 +3173,8 @@ void KaleidoScope_LoadDungeonMap(PlayState* play) {
interfaceCtx->mapSegmentName[0] = sDungeonMapTexs[R_MAP_TEX_INDEX]; interfaceCtx->mapSegmentName[0] = sDungeonMapTexs[R_MAP_TEX_INDEX];
interfaceCtx->mapSegmentName[1] = sDungeonMapTexs[R_MAP_TEX_INDEX + 1]; interfaceCtx->mapSegmentName[1] = sDungeonMapTexs[R_MAP_TEX_INDEX + 1];
interfaceCtx->mapSegment[0] = GetResourceDataByName(sDungeonMapTexs[R_MAP_TEX_INDEX], true); interfaceCtx->mapSegment[0] = GetResourceDataByName(sDungeonMapTexs[R_MAP_TEX_INDEX]);
interfaceCtx->mapSegment[1] = GetResourceDataByName(sDungeonMapTexs[R_MAP_TEX_INDEX + 1], true); interfaceCtx->mapSegment[1] = GetResourceDataByName(sDungeonMapTexs[R_MAP_TEX_INDEX + 1]);
} }
void KaleidoScope_UpdateDungeonMap(PlayState* play) { void KaleidoScope_UpdateDungeonMap(PlayState* play) {