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

@ -17,6 +17,7 @@
#include <Utils/StringHelper.h>
#include <Window.h>
#include <Context.h>
#include <ImGui/imgui_internal.h>
#undef PATH_HACK
#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) {
Ship::Window::GetInstance()->Close();
Ship::Context::GetInstance()->GetWindow()->Close();
return CMD_SUCCESS;
}

View file

@ -10,7 +10,7 @@
#include <bit>
#include <map>
#include <string>
#include <libultraship/bridge.h>
#include <libultraship/libultraship.h>
extern "C" {
#include <z64.h>
@ -64,7 +64,7 @@ void DrawDLViewer(bool& open) {
ImGui::EndCombo();
}
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++) {
std::string id = "##CMD" + std::to_string(i);
Gfx* gfx = (Gfx*)&res->Instructions[i];

View file

@ -6,7 +6,7 @@
#include "rando_main.hpp"
// #include <soh/Enhancements/randomizer.h>
#include <libultraship/bridge.h>
#include <Window.h>
#include <Context.h>
#include <libultraship/libultra/types.h>
#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";
// 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());
CVarSave();

View file

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

View file

@ -681,22 +681,22 @@ void InitTTSBank() {
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) {
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) {
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) {
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) {
fileChooseMap = nlohmann::json::parse(fileChooseFile->Buffer, nullptr, true, true);
}

View file

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

View file

@ -201,19 +201,19 @@ const char* constCameraStrings[] = {
OTRGlobals::OTRGlobals() {
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)) {
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)) {
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)) {
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 (std::filesystem::is_directory(patchesPath)) {
for (const auto& p : std::filesystem::recursive_directory_iterator(patchesPath)) {
@ -240,7 +240,7 @@ OTRGlobals::OTRGlobals() {
OOT_PAL_GC_DBG1,
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_PlayerAnimation, "PlayerAnimation", std::make_shared<Ship::PlayerAnimationFactory>());
@ -329,10 +329,10 @@ uint32_t OTRGlobals::GetInterpolationFPS() {
}
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 {
@ -694,7 +694,7 @@ extern "C" uint32_t GetGIID(uint32_t itemID) {
}
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) {
std::vector<std::string> raw = StringHelper::Split(rPath, ".");
@ -708,8 +708,8 @@ extern "C" void OTRExtScanner() {
extern "C" void InitOTR() {
#if not defined (__SWITCH__) && not defined(__WIIU__)
if (!std::filesystem::exists(Ship::Window::GetPathRelativeToAppDirectory("oot-mq.otr")) &&
!std::filesystem::exists(Ship::Window::GetPathRelativeToAppDirectory("oot.otr"))){
if (!std::filesystem::exists(Ship::Context::GetPathRelativeToAppDirectory("oot-mq.otr")) &&
!std::filesystem::exists(Ship::Context::GetPathRelativeToAppDirectory("oot.otr"))){
if (Extractor::ShowYesNoBox("No OTR Files", "No OTR files found. Generate one now?") == IDYES) {
Extractor extract;
if (!extract.Run()) {
@ -791,9 +791,6 @@ extern "C" void InitOTR() {
extern "C" void DeinitOTR() {
OTRAudio_Exit();
#if defined(_WIN32) || defined(__APPLE__)
SpeechSynthesizerUninitialize();
#endif
#ifdef ENABLE_CROWD_CONTROL
CrowdControl::Instance->Disable();
CrowdControl::Instance->Shutdown();
@ -833,7 +830,7 @@ extern "C" uint64_t GetPerfCounter() {
// C->C++ Bridge
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;
@ -841,8 +838,8 @@ extern bool ShouldClearTextureCacheAtEndOfFrame;
extern "C" void Graph_StartFrame() {
#ifndef __WIIU__
using Ship::KbScancode;
int32_t dwScancode = OTRGlobals::Instance->context->GetLastScancode();
OTRGlobals::Instance->context->SetLastScancode(-1);
int32_t dwScancode = OTRGlobals::Instance->context->GetWindow()->GetLastScancode();
OTRGlobals::Instance->context->GetWindow()->SetLastScancode(-1);
switch (dwScancode) {
case KbScancode::LUS_KB_F5: {
@ -911,7 +908,7 @@ extern "C" void Graph_StartFrame() {
}
}
#endif
OTRGlobals::Instance->context->StartFrame();
OTRGlobals::Instance->context->GetWindow()->StartFrame();
}
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;
OTRGlobals::Instance->context->SetTargetFps(fps);
OTRGlobals::Instance->context->GetWindow()->SetTargetFps(fps);
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);
@ -991,19 +988,19 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) {
float divisor_num = 0.0f;
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) {
return OTRGlobals::Instance->context->GetPixelDepth(x, y);
return OTRGlobals::Instance->context->GetWindow()->GetPixelDepth(x, y);
}
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) {
return OTRGlobals::Instance->context->GetResourceManager()->GetArchive()->GetGameVersions()[index];
return Ship::Context::GetInstance()->GetResourceManager()->GetArchive()->GetGameVersions()[index];
}
uint32_t IsSceneMasterQuest(s16 sceneNum) {
@ -1048,16 +1045,16 @@ extern "C" uint32_t ResourceMgr_IsGameMasterQuest() {
}
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) {
OTRGlobals::Instance->context->GetResourceManager()->DirtyDirectory(resName);
Ship::Context::GetInstance()->GetResourceManager()->DirtyDirectory(resName);
}
// OTRTODO: There is probably a more elegant way to go about this...
// Kenix: This is definitely leaking memory when it's called.
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*));
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) {
OTRGlobals::Instance->context->GetResourceManager()->LoadResource(resName);
Ship::Context::GetInstance()->GetResourceManager()->LoadResource(resName);
}
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/");
}
}
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) {
@ -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.
extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction) {
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
/*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) {
if (originalGfx.contains(path) && originalGfx[path].contains(patchName)) {
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 = originalGfx[path][patchName].instruction;
@ -1292,15 +1289,15 @@ extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(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) {
return (Vtx*)GetResourceDataByName(path, false);
return (Vtx*) GetResourceDataByName(path);
}
extern "C" SequenceData ResourceMgr_LoadSeqByName(const char* path) {
SequenceData* sequence = (SequenceData*)GetResourceDataByName(path, false);
SequenceData* sequence = (SequenceData*) GetResourceDataByName(path);
return *sequence;
}
@ -1314,7 +1311,7 @@ extern "C" SoundFontSample* ReadCustomSample(const char* 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();
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) {
return (SoundFontSample*)GetResourceDataByName(path, false);
return (SoundFontSample*) GetResourceDataByName(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)
@ -1391,7 +1388,7 @@ extern "C" int ResourceMgr_OTRSigCheck(char* imgData)
}
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) {
@ -1408,11 +1405,11 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel
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 (isAlt && skelHeader == NULL) {
skelHeader = (SkeletonHeader*)GetResourceDataByName(path, false);
skelHeader = (SkeletonHeader*) GetResourceDataByName(path);
}
// 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) {
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);
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() {
return OTRGlobals::Instance->context->GetCurrentWidth();
return OTRGlobals::Instance->context->GetWindow()->GetCurrentWidth();
}
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) {
auto controlDeck = Ship::Window::GetInstance()->GetControlDeck();
auto controlDeck = Ship::Context::GetInstance()->GetControlDeck();
for (int i = 0; i < controlDeck->GetNumConnectedPorts(); ++i) {
auto physicalDevice = controlDeck->GetDeviceFromPortIndex(i);
switch (ledColor) {
case 0:
physicalDevice->SetLed(i, 255, 0, 0);
physicalDevice->SetLedColor(i, {255, 0, 0});
break;
case 1:
physicalDevice->SetLed(i, 0x1E, 0x69, 0x1B);
physicalDevice->SetLedColor(i, {0x1E, 0x69, 0x1B});
break;
case 2:
physicalDevice->SetLed(i, 0x64, 0x14, 0x00);
physicalDevice->SetLedColor(i, {0x64, 0x14, 0x00});
break;
case 3:
physicalDevice->SetLed(i, 0x00, 0x3C, 0x64);
physicalDevice->SetLedColor(i, {0x00, 0x3C, 0x64});
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) {
auto controlDeck = Ship::Window::GetInstance()->GetControlDeck();
auto controlDeck = Ship::Context::GetInstance()->GetControlDeck();
if (slot < controlDeck->GetNumConnectedPorts()) {
auto physicalDevice = controlDeck->GetDeviceFromPortIndex(slot);
@ -1656,13 +1653,13 @@ extern "C" int Controller_ShouldRumble(size_t slot) {
}
extern "C" void Controller_BlockGameInput() {
auto controlDeck = Ship::Window::GetInstance()->GetControlDeck();
auto controlDeck = Ship::Context::GetInstance()->GetControlDeck();
controlDeck->BlockGameInput();
}
extern "C" void Controller_UnblockGameInput() {
auto controlDeck = Ship::Window::GetInstance()->GetControlDeck();
auto controlDeck = Ship::Context::GetInstance()->GetControlDeck();
controlDeck->UnblockGameInput();
}

View file

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

View file

@ -7,7 +7,7 @@
#include "macros.h"
#include <variables.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
#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) {
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");
}
@ -342,10 +342,10 @@ void SaveManager::SaveRandomizer(SaveContext* saveContext) {
}
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");
auto sOldSavePath = Ship::Window::GetPathRelativeToAppDirectory("oot_save.sav");
auto sOldBackupSavePath = Ship::Window::GetPathRelativeToAppDirectory("oot_save.bak");
auto sOldSavePath = Ship::Context::GetPathRelativeToAppDirectory("oot_save.sav");
auto sOldBackupSavePath = Ship::Context::GetPathRelativeToAppDirectory("oot_save.bak");
Ship::RegisterHook<Ship::ExitGame>([this]() { ThreadPoolWait(); });
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnExitGame>([this](uint32_t fileNum) { ThreadPoolWait(); });
@ -771,7 +771,7 @@ void SaveManager::SaveGlobal() {
globalBlock["zTargetSetting"] = gSaveContext.zTargetSetting;
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");
std::ofstream output(sGlobalPath);

View file

@ -90,7 +90,7 @@ extern "C" SoundFontSample* ReadCustomSample(const char* 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();
uint8_t* strem2 = (uint8_t*)strem;

View file

@ -18,7 +18,7 @@ std::shared_ptr<Resource> AudioSequenceFactory::ReadResource(std::shared_ptr<Res
if (factory == nullptr)
{
SPDLOG_ERROR("Failed to load AudioSequence with version {}", resource->InitData->ResourceVersion);
return nullptr;
return nullptr;
}
factory->ParseFileBinary(reader, resource);

View file

@ -1,7 +1,7 @@
#include "soh/resource/importer/AudioSoundFontFactory.h"
#include "soh/resource/type/AudioSoundFont.h"
#include "spdlog/spdlog.h"
#include "libultraship/bridge.h"
#include "libultraship/libultraship.h"
namespace Ship {
std::shared_ptr<Resource> AudioSoundFontFactory::ReadResource(std::shared_ptr<ResourceManager> resourceMgr,
@ -19,7 +19,7 @@ std::shared_ptr<Resource> AudioSoundFontFactory::ReadResource(std::shared_ptr<Re
if (factory == nullptr)
{
SPDLOG_ERROR("Failed to load AudioSoundFont with version {}", resource->InitData->ResourceVersion);
return nullptr;
return nullptr;
}
factory->ParseFileBinary(reader, resource);
@ -87,7 +87,8 @@ void Ship::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader
if (sampleFileName.empty()) {
drum.sound.sample = nullptr;
} 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);
@ -130,7 +131,8 @@ void Ship::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader
bool hasSampleRef = reader->ReadInt8();
std::string sampleFileName = reader->ReadString();
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 {
instrument.lowNotesSound.sample = nullptr;
instrument.lowNotesSound.tuning = 0;
@ -141,7 +143,8 @@ void Ship::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader
bool hasSampleRef = reader->ReadInt8();
std::string sampleFileName = reader->ReadString();
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 {
instrument.normalNotesSound.sample = nullptr;
instrument.normalNotesSound.tuning = 0;
@ -152,7 +155,8 @@ void Ship::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader
bool hasSampleRef = reader->ReadInt8();
std::string sampleFileName = reader->ReadString();
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 {
instrument.highNotesSound.sample = nullptr;
instrument.highNotesSound.tuning = 0;
@ -176,7 +180,8 @@ void Ship::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader
bool hasSampleRef = reader->ReadInt8();
std::string sampleFileName = reader->ReadString();
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);

View file

@ -11,13 +11,13 @@ std::shared_ptr<Resource> CollisionHeaderFactory::ReadResource(std::shared_ptr<R
switch (resource->InitData->ResourceVersion) {
case 0:
factory = std::make_shared<CollisionHeaderFactoryV0>();
break;
factory = std::make_shared<CollisionHeaderFactoryV0>();
break;
}
if (factory == nullptr) {
SPDLOG_ERROR("Failed to load Collision Header with version {}", resource->InitData->ResourceVersion);
return nullptr;
return nullptr;
}
factory->ParseFileBinary(reader, resource);

View file

@ -1,7 +1,7 @@
#include "soh/resource/importer/SkeletonFactory.h"
#include "soh/resource/type/Skeleton.h"
#include <spdlog/spdlog.h>
#include <libultraship/bridge.h>
#include <libultraship/libultraship.h>
namespace Ship {
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);
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch ((Version)resource->InitData->ResourceVersion) {
case Version::Deckard:
switch (resource->InitData->ResourceVersion) {
case 0:
factory = std::make_shared<SkeletonFactoryV0>();
break;
}
@ -85,8 +85,8 @@ void SkeletonFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
for (size_t i = 0; i < skeleton->limbTable.size(); i++) {
std::string limbStr = skeleton->limbTable[i];
auto limb = GetResourceDataByName(limbStr.c_str(), true);
skeleton->skeletonHeaderSegments.push_back(limb);
auto limb = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(limbStr.c_str());
skeleton->skeletonHeaderSegments.push_back(limb ? limb->GetPointer() : nullptr);
}
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");
skel->limbTable.push_back(limbName);
auto limb = GetResourceDataByName(limbName.c_str(), true);
skel->skeletonHeaderSegments.push_back(limb);
auto limb = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(limbName.c_str());
skel->skeletonHeaderSegments.push_back(limb ? limb->GetPointer() : nullptr);
}
child = child->NextSiblingElement();

View file

@ -1,7 +1,7 @@
#include "soh/resource/importer/SkeletonLimbFactory.h"
#include "soh/resource/type/SkeletonLimb.h"
#include "spdlog/spdlog.h"
#include "libultraship/bridge.h"
#include "libultraship/libultraship.h"
namespace Ship {
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);
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch ((Version)resource->InitData->ResourceVersion) {
case Version::Deckard:
switch (resource->InitData->ResourceVersion) {
case 0:
factory = std::make_shared<SkeletonLimbFactoryV0>();
break;
}
@ -134,15 +134,15 @@ void Ship::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader>
skeletonLimb->limbData.lodLimb.sibling = skeletonLimb->siblingIndex;
if (skeletonLimb->dListPtr != "") {
auto dList = GetResourceDataByName(skeletonLimb->dListPtr.c_str(), true);
skeletonLimb->limbData.lodLimb.dLists[0] = (Gfx*)dList;
auto dList = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dListPtr.c_str());
skeletonLimb->limbData.lodLimb.dLists[0] = (Gfx*)(dList ? dList->GetPointer() : nullptr);
} else {
skeletonLimb->limbData.lodLimb.dLists[0] = nullptr;
}
if (skeletonLimb->dList2Ptr != "") {
auto dList = GetResourceDataByName(skeletonLimb->dList2Ptr.c_str(), true);
skeletonLimb->limbData.lodLimb.dLists[1] = (Gfx*)dList;
auto dList = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dList2Ptr.c_str());
skeletonLimb->limbData.lodLimb.dLists[1] = (Gfx*)(dList ? dList->GetPointer() : nullptr);
} else {
skeletonLimb->limbData.lodLimb.dLists[1] = nullptr;
}
@ -155,8 +155,8 @@ void Ship::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader>
skeletonLimb->limbData.standardLimb.dList = nullptr;
if (!skeletonLimb->dListPtr.empty()) {
const auto dList = GetResourceDataByName(skeletonLimb->dListPtr.c_str(), true);
skeletonLimb->limbData.standardLimb.dList = (Gfx*)dList;
const auto dList = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dListPtr.c_str());
skeletonLimb->limbData.standardLimb.dList = (Gfx*)(dList ? dList->GetPointer() : nullptr);
}
} else if (skeletonLimb->limbType == Ship::LimbType::Curve) {
skeletonLimb->limbData.skelCurveLimb.firstChildIdx = skeletonLimb->childIndex;
@ -165,13 +165,13 @@ void Ship::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader>
skeletonLimb->limbData.skelCurveLimb.dList[1] = nullptr;
if (!skeletonLimb->dListPtr.empty()) {
const auto dList = GetResourceDataByName(skeletonLimb->dListPtr.c_str(), true);
skeletonLimb->limbData.skelCurveLimb.dList[0] = (Gfx*)dList;
const auto dList = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dListPtr.c_str());
skeletonLimb->limbData.skelCurveLimb.dList[0] = (Gfx*)(dList ? dList->GetPointer() : nullptr);
}
if (!skeletonLimb->dList2Ptr.empty()) {
const auto dList = GetResourceDataByName(skeletonLimb->dList2Ptr.c_str(), true);
skeletonLimb->limbData.skelCurveLimb.dList[1] = (Gfx*)dList;
const auto dList = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(skeletonLimb->dList2Ptr.c_str());
skeletonLimb->limbData.skelCurveLimb.dList[1] = (Gfx*)(dList ? dList->GetPointer() : nullptr);
}
} else if (skeletonLimb->limbType == Ship::LimbType::Skin) {
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) {
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) {
skeletonLimb->skinAnimLimbData.totalVtxCount = skeletonLimb->skinVtxCnt;
skeletonLimb->skinAnimLimbData.limbModifCount = skeletonLimb->skinLimbModifCount;
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++) {
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;
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 {
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);
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch ((Version)resource->InitData->ResourceVersion) {
case Version::Deckard:
switch (resource->InitData->ResourceVersion) {
case 0:
factory = std::make_shared<TextFactoryV0>();
break;
}

View file

@ -1,7 +1,7 @@
#include "soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h"
#include "soh/resource/type/scenecommand/SetAlternateHeaders.h"
#include "spdlog/spdlog.h"
#include "libultraship/bridge.h"
#include "libultraship/libultraship.h"
namespace Ship {
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++) {
auto headerName = reader->ReadString();
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 {
setAlternateHeaders->headers.push_back(nullptr);
}

View file

@ -1,6 +1,6 @@
#include "soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h"
#include "soh/resource/type/scenecommand/SetCollisionHeader.h"
#include "libultraship/bridge.h"
#include "libultraship/libultraship.h"
#include "spdlog/spdlog.h"
namespace Ship {
@ -34,7 +34,7 @@ void Ship::SetCollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptr<BinaryRe
ReadCommandId(setCollisionHeader, reader);
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

View file

@ -1,6 +1,6 @@
#include "soh/resource/importer/scenecommand/SetCutscenesFactory.h"
#include "soh/resource/type/scenecommand/SetCutscenes.h"
#include <libultraship/bridge.h>
#include <libultraship/libultraship.h>
#include "spdlog/spdlog.h"
namespace Ship {
@ -35,7 +35,7 @@ void Ship::SetCutscenesFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader>
ReadCommandId(setCutscenes, reader);
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

View file

@ -1,7 +1,7 @@
#include "soh/resource/importer/scenecommand/SetMeshFactory.h"
#include "soh/resource/type/scenecommand/SetMesh.h"
#include "spdlog/spdlog.h"
#include "libultraship/bridge.h"
#include "libultraship/libultraship.h"
namespace Ship {
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 meshXlu = reader->ReadString();
dlist.opa = meshOpa != "" ? (Gfx*)GetResourceDataByName(meshOpa.c_str(), true) : 0;
dlist.xlu = meshXlu != "" ? (Gfx*)GetResourceDataByName(meshXlu.c_str(), true) : 0;
auto opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str());
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);
} 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 imgXlu = reader->ReadString();
pType.opa = imgOpa != "" ? (Gfx*)GetResourceDataByName(imgOpa.c_str(), true) : 0;
pType.xlu = imgXlu != "" ? (Gfx*)GetResourceDataByName(imgXlu.c_str(), true) : 0;
auto opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgOpa.c_str());
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();
setMesh->images.reserve(bgImageCount);
@ -122,8 +126,10 @@ void Ship::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reade
std::string meshOpa = reader->ReadString();
std::string meshXlu = reader->ReadString();
pType.opa = meshOpa != "" ? (Gfx*)GetResourceDataByName(meshOpa.c_str(), true) : 0;
pType.xlu = meshXlu != "" ? (Gfx*)GetResourceDataByName(meshXlu.c_str(), true) : 0;
opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str());
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);
} 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 meshXlu = reader->ReadString();
dlist.opa = meshOpa != "" ? (Gfx*)GetResourceDataByName(meshOpa.c_str(), true) : 0;
dlist.xlu = meshXlu != "" ? (Gfx*)GetResourceDataByName(meshXlu.c_str(), true) : 0;
auto opaRes = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str());
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);
} else {

View file

@ -1,7 +1,7 @@
#include "soh/resource/importer/scenecommand/SetPathwaysFactory.h"
#include "soh/resource/type/scenecommand/SetPathways.h"
#include "spdlog/spdlog.h"
#include <libultraship/bridge.h>
#include <libultraship/libultraship.h>
namespace Ship {
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);
for (uint32_t i = 0; i < setPathways->numPaths; i++) {
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)
{
Skeleton* newSkel =
(Skeleton*)OTRGlobals::Instance->context->GetResourceManager()
(Skeleton*)Ship::Context::GetInstance()->GetResourceManager()
->LoadResource((isHD ? Ship::Resource::gAltAssetPrefix : "") + skel.vanillaSkeletonPath, true)
.get();

View file

@ -1,5 +1,5 @@
#include "OTRGlobals.h"
#include <ResourceManager.h>
#include <libultraship/libultraship.h>
#include "soh/resource/type/Scene.h"
#include <Utils/StringHelper.h>
#include "global.h"
@ -16,7 +16,7 @@ extern "C" MessageTableEntry* sStaffMessageEntryTablePtr;
//extern "C" MessageTableEntry* _message_0xFFFC_nes;
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)
return nullptr;
@ -92,7 +92,7 @@ extern "C" void OTRMessage_Init()
if (sStaffMessageEntryTablePtr == NULL) {
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"));
// 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());

View file

@ -1,5 +1,5 @@
#include "OTRGlobals.h"
#include <ResourceManager.h>
#include <libultraship/libultraship.h>
#include "soh/resource/type/Scene.h"
#include <Utils/StringHelper.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::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();
}
@ -76,7 +76,7 @@ void OTRPlay_InitScene(PlayState* play, s32 spawn) {
gSaveContext.worldMapArea = 0;
OTRScene_ExecuteCommands(play, (Ship::Scene*)play->sceneSegment);
Play_InitEnvironment(play, play->skyboxId);
/* auto data = static_cast<Ship::Vertex*>(Ship::Window::GetInstance()
/* auto data = static_cast<Ship::Vertex*>(Ship::Context::GetInstance()
->GetResourceManager()
->LoadResource("object_link_child\\object_link_childVtx_01FE08")
.get());

View file

@ -1,5 +1,5 @@
#include "OTRGlobals.h"
#include <ResourceManager.h>
#include <libultraship/libultraship.h>
#include "soh/resource/type/Scene.h"
#include <Utils/StringHelper.h>
#include "global.h"
@ -46,7 +46,7 @@ std::shared_ptr<Ship::File> ResourceMgr_LoadFile(const char* path) {
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

View file

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

View file

@ -413,7 +413,7 @@ void Map_InitData(PlayState* play, s16 room) {
//gMapData->owMinimapTexSize[mapIndex], __FILE__, __LINE__);
if (sEntranceIconMapIndex < 24) {
play->interfaceCtx.mapSegment[0] = GetResourceDataByName(minimapTableOW[sEntranceIconMapIndex], true);
play->interfaceCtx.mapSegment[0] = GetResourceDataByName(minimapTableOW[sEntranceIconMapIndex]);
play->interfaceCtx.mapSegmentName[0] = minimapTableOW[sEntranceIconMapIndex];
}
@ -447,7 +447,8 @@ void Map_InitData(PlayState* play, s16 room) {
//((gMapData->dgnMinimapTexIndexOffset[mapIndex] + room) * 0xFF0),
//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];
R_COMPASS_OFFSET_X = gMapData->roomCompassOffsetX[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
uint8_t Player_IsCustomLinkModel() {
return (LINK_IS_ADULT && GetResourceIsCustomByName(gLinkAdultSkel, true)) ||
(LINK_IS_CHILD && GetResourceIsCustomByName(gLinkChildSkel, true));
return (LINK_IS_ADULT && GetResourceIsCustomByName(gLinkAdultSkel)) ||
(LINK_IS_CHILD && GetResourceIsCustomByName(gLinkChildSkel));
}
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;
if (ResourceMgr_ResourceIsBackground((char*) source)) {
char* blob = (char*) GetResourceDataByName((char*) source, true);
char* blob = (char*) GetResourceDataByName((char *) source);
swapAndConvertJPEG(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) {
arg0 = GetResourceDataByNameHandlingMQ(arg0);
floorTex = GetResourceDataByName(floorTex, false);
floorTex = GetResourceDataByName(floorTex);
u16* temp_s3 = SEGMENTED_TO_VIRTUAL(arg0);
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);
if (Flags_GetClear(play, play->roomCtx.curRoom.num)) { // KD is dead
u16* LavaFloorTex = GetResourceDataByName(gDodongosCavernBossLavaFloorTex, false);
u16* LavaFloorRockTex = GetResourceDataByName(sLavaFloorRockTex, false);
u16* LavaFloorTex = GetResourceDataByName(gDodongosCavernBossLavaFloorTex);
u16* LavaFloorRockTex = GetResourceDataByName(sLavaFloorRockTex);
temp_s1_3 = SEGMENTED_TO_VIRTUAL(LavaFloorTex);
temp_s2 = SEGMENTED_TO_VIRTUAL(LavaFloorRockTex);
Actor_Kill(&this->actor);
@ -1018,8 +1018,8 @@ void BossDodongo_Update(Actor* thisx, PlayState* play2) {
}
if (this->unk_1C6 != 0) {
u16* ptr1 = GetResourceDataByName(sLavaFloorLavaTex, false);
u16* ptr2 = GetResourceDataByName(sLavaFloorRockTex, false);
u16* ptr1 = GetResourceDataByName(sLavaFloorLavaTex);
u16* ptr2 = GetResourceDataByName(sLavaFloorRockTex);
s16 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) {
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++) {
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) {
this->unk_164 = false;
u8* carpTex = GetResourceDataByName(sCarpetTex, false);
u8* carpTex = GetResourceDataByName(sCarpetTex);
u8* shadTex = sShadowTex;
for (i = 0; i < ARRAY_COUNT(sShadowTex); i++) {
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[1] = sDungeonMapTexs[R_MAP_TEX_INDEX + 1];
interfaceCtx->mapSegment[0] = GetResourceDataByName(sDungeonMapTexs[R_MAP_TEX_INDEX], true);
interfaceCtx->mapSegment[1] = GetResourceDataByName(sDungeonMapTexs[R_MAP_TEX_INDEX + 1], true);
interfaceCtx->mapSegment[0] = GetResourceDataByName(sDungeonMapTexs[R_MAP_TEX_INDEX]);
interfaceCtx->mapSegment[1] = GetResourceDataByName(sDungeonMapTexs[R_MAP_TEX_INDEX + 1]);
}
void KaleidoScope_UpdateDungeonMap(PlayState* play) {