Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libultraship
Submodule libultraship updated 302 files
2 changes: 1 addition & 1 deletion soh/soh/Enhancements/Difficulty/PermanentLosses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static void DeleteFileOnDeath() {
SaveManager::Instance->DeleteZeldaFile(gSaveContext.fileNum);
hasAffectedHealth = false;
std::reinterpret_pointer_cast<Ship::ConsoleWindow>(
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))
->Dispatch("reset");
}
}
Expand Down
2 changes: 1 addition & 1 deletion soh/soh/Enhancements/FileSelectEnhancements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void SohFileSelect_ShowPresetModal() {
return;
}
std::shared_ptr<SohModalWindow> modal = static_pointer_cast<SohModalWindow>(
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Modal Window"));
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Modal Window"));
if (modal->IsPopupOpen("Take a look at our presets!")) {
modal->DismissPopup();
} else {
Expand Down
4 changes: 2 additions & 2 deletions soh/soh/Enhancements/Lang/Lang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ void Lang::LoadLangs() {
initData->Type = static_cast<uint32_t>(Ship::ResourceType::Json);
initData->ResourceVersion = 0;
const static std::string folder = "lang/*";
auto langFiles = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(folder);
auto langFiles = Ship::Context::GetRawInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(folder);
size_t start = std::string(folder).size() - 1;
for (size_t i = 0; i < langFiles->size(); i++) {
std::string filePath = langFiles->at(i);
auto json = std::static_pointer_cast<Ship::Json>(
Ship::Context::GetInstance()->GetResourceManager()->LoadResource(filePath, true, initData));
Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(filePath, true, initData));

std::string fileName = filePath.substr(start, filePath.size() - start - 5); // 5 for length of ".json"
langs.insert_or_assign(fileName, json->Data);
Expand Down
20 changes: 10 additions & 10 deletions soh/soh/Enhancements/Presets/Presets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,17 @@ void applyPreset(std::string presetName, std::vector<PresetSection> includeSecti
} else {
auto block = item.value();
if (sectionStrategy == "merge") {
auto currentJson = Ship::Context::GetInstance()->GetConfig()->GetNestedJson();
auto currentJson = Ship::Context::GetRawInstance()->GetConfig()->GetNestedJson();
if (currentJson.contains("CVars") && currentJson["CVars"].contains(item.key())) {
block = currentJson["CVars"][item.key()];
// Recursively merge the two json objects
block.update(item.value(), true);
}
}

Ship::Context::GetInstance()->GetConfig()->SetBlock(fmt::format("{}.{}", "CVars", item.key()),
block);
Ship::Context::GetInstance()->GetConsoleVariables()->Load();
Ship::Context::GetRawInstance()->GetConfig()->SetBlock(fmt::format("{}.{}", "CVars", item.key()),
block);
Ship::Context::GetRawInstance()->GetConsoleVariables()->Load();
}
}
if (i == PRESET_SECTION_RANDOMIZER) {
Expand Down Expand Up @@ -159,7 +159,7 @@ void DrawPresetSelector(std::vector<PresetSection> includeSections, std::string
if (ImGui::Selectable(iter->c_str(), *iter == currentIndex)) {
CVarSetString(selectorCvar.c_str(), iter->c_str());
currentIndex = *iter;
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
}
}

Expand Down Expand Up @@ -234,12 +234,12 @@ void LoadPresets() {
initData->Type = static_cast<uint32_t>(Ship::ResourceType::Json);
initData->ResourceVersion = 0;
std::string folder = "presets/*";
auto builtIns = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(folder);
auto builtIns = Ship::Context::GetRawInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(folder);
size_t start = std::string(folder).size() - 1;
for (size_t i = 0; i < builtIns->size(); i++) {
std::string filePath = builtIns->at(i);
auto json = std::static_pointer_cast<Ship::Json>(
Ship::Context::GetInstance()->GetResourceManager()->LoadResource(filePath, true, initData));
Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(filePath, true, initData));

std::string fileName = filePath.substr(start, filePath.size() - start - 5); // 5 for length of ".json"
ParsePreset(json->Data, fileName);
Expand All @@ -253,7 +253,7 @@ void SavePreset(std::string& presetName) {
presets[presetName].presetValues["presetName"] = presetName;
presets[presetName].presetValues["fileType"] = FILE_TYPE_PRESET;
std::ofstream file(
fmt::format("{}/{}.json", Ship::Context::GetInstance()->LocateFileAcrossAppDirs("presets"), presetName));
fmt::format("{}/{}.json", Ship::Context::GetRawInstance()->LocateFileAcrossAppDirs("presets"), presetName));
file << presets[presetName].presetValues.dump(4);
file.close();
LoadPresets();
Expand Down Expand Up @@ -293,7 +293,7 @@ void DrawNewPresetPopup() {
.Padding({ 6.0f, 6.0f })
.Color(THEME_COLOR))) {
presets[newPresetName] = {};
auto config = Ship::Context::GetInstance()->GetConfig()->GetNestedJson();
auto config = Ship::Context::GetRawInstance()->GetConfig()->GetNestedJson();
for (int i = PRESET_SECTION_SETTINGS; i < PRESET_SECTION_MAX; i++) {
if (saveSection[i]) {
for (size_t j = 0; j < blockInfo[i].sections.size(); j++) {
Expand Down Expand Up @@ -459,7 +459,7 @@ void RegisterPresetsWidgets() {
SohGui::mSohMenu->AddWidget(path, "PresetsWidget", WIDGET_CUSTOM)
.CustomFunction(PresetsCustomWidget)
.HideInSearch(true);
presetFolder = Ship::Context::GetInstance()->GetPathRelativeToAppDirectory("presets");
presetFolder = Ship::Context::GetRawInstance()->GetPathRelativeToAppDirectory("presets");
std::fill_n(saveSection, PRESET_SECTION_MAX, true);
LoadPresets();
}
Expand Down
2 changes: 1 addition & 1 deletion soh/soh/Enhancements/ResetHotKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static void OnGameStateMainStartResetHotkey() {
CHECK_BTN_ALL(gGameState->input[0].cur.button, mask)) {

auto consoleWin = std::reinterpret_pointer_cast<Ship::ConsoleWindow>(
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"));
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"));

if (consoleWin) {
consoleWin->Dispatch("reset");
Expand Down
6 changes: 4 additions & 2 deletions soh/soh/Enhancements/Restorations/GraveHoleJumps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ CollisionHeader* getGraveyardCollisionHeader() {
* dspot02_sceneCollisionHeader_003C54. We have to scroll through the scene cmds to get the header the same way the
* game does.
*/
SOH::Scene* scene =
(SOH::Scene*)Ship::Context::GetInstance()->GetResourceManager()->LoadResource(GRAVEYARD_SCENE_FILEPATH).get();
SOH::Scene* scene = (SOH::Scene*)Ship::Context::GetRawInstance()
->GetResourceManager()
->LoadResource(GRAVEYARD_SCENE_FILEPATH)
.get();
SOH::SetCollisionHeader* sceneCmd = nullptr;
for (size_t i = 0; i < scene->commands.size(); i++) {
auto cmd = scene->commands[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void WeirdAnimation::Build() {
auto& animation = animationData.emplace();

for (const auto& neighborName : neighborAnimations) {
const auto neighbor = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(neighborName);
const auto neighbor = Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(neighborName);

const auto prevSize = animation.size();
animation.resize(prevSize + neighbor->GetPointerSize());
Expand Down
58 changes: 31 additions & 27 deletions soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "assets/soh_assets.h"
#include "soh/SohGui/ImGuiUtils.h"

#include <fast/Fast3dGui.h>

extern "C" {
#include "macros.h"
#include "functions.h"
Expand Down Expand Up @@ -83,18 +85,19 @@ static void TimeDisplayGetTimer(uint32_t timeID) {
Player* player = GET_PLAYER(gPlayState);
uint32_t timer1 = gSaveContext.timerSeconds;

auto gui = std::dynamic_pointer_cast<Fast::Fast3dGui>(
std::dynamic_pointer_cast<Fast::Fast3dGui>(Ship::Context::GetRawInstance()->GetWindow()->GetGui()));

switch (timeID) {
case DISPLAY_IN_GAME_TIMER:
textureDisplay = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("GAMEPLAY_TIMER");
textureDisplay = gui->GetTextureByName("GAMEPLAY_TIMER");
timeDisplayTime = formatTimeDisplay(GAMEPLAYSTAT_TOTAL_TIME).c_str();
break;
case DISPLAY_TIME_OF_DAY:
if (gSaveContext.dayTime >= DAY_BEGINS && gSaveContext.dayTime < NIGHT_BEGINS) {
textureDisplay =
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("DAY_TIME_TIMER");
textureDisplay = gui->GetTextureByName("DAY_TIME_TIMER");
} else {
textureDisplay =
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("NIGHT_TIME_TIMER");
textureDisplay = gui->GetTextureByName("NIGHT_TIME_TIMER");
}
timeDisplayTime = convertDayTime(gSaveContext.dayTime).c_str();
break;
Expand All @@ -107,18 +110,16 @@ static void TimeDisplayGetTimer(uint32_t timeID) {
: COLOR_LIGHT_BLUE)
: COLOR_WHITE;
if (gSaveContext.timerState <= TIMER_STATE_ENV_HAZARD_TICK) {
textureDisplay = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(
gPlayState->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3
? itemMapping[ITEM_TUNIC_GORON].name
: itemMapping[ITEM_TUNIC_ZORA].name);
textureDisplay =
gui->GetTextureByName(gPlayState->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3
? itemMapping[ITEM_TUNIC_GORON].name
: itemMapping[ITEM_TUNIC_ZORA].name);
}
if (gSaveContext.timerState >= TIMER_STATE_DOWN_PREVIEW) {
textureDisplay = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(
itemMapping[ITEM_SWORD_MASTER].name);
textureDisplay = gui->GetTextureByName(itemMapping[ITEM_SWORD_MASTER].name);
}
} else {
textureDisplay = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(
itemMapping[ITEM_TUNIC_KOKIRI].name);
textureDisplay = gui->GetTextureByName(itemMapping[ITEM_TUNIC_KOKIRI].name);
timeDisplayTime = "-:--";
}
break;
Expand All @@ -132,7 +133,7 @@ static void TimeDisplayGetTimer(uint32_t timeID) {
timeDisplayTime = convertNaviTime(NAVI_COOLDOWN - gSaveContext.naviTimer).c_str();
textColor = COLOR_GREY;
}
textureDisplay = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("NAVI_TIMER");
textureDisplay = gui->GetTextureByName("NAVI_TIMER");
break;
default:
break;
Expand Down Expand Up @@ -203,13 +204,15 @@ void TimeDisplayWindow::Draw() {
}
if (textToDecode[i] == '.') {
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (8.0f * fontScale));
ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(
digitList[textureIndex].first),
ImGui::Image(std::dynamic_pointer_cast<Fast::Fast3dGui>(
Ship::Context::GetRawInstance()->GetWindow()->GetGui())
->GetTextureByName(digitList[textureIndex].first),
ImVec2(8.0f * fontScale, 8.0f * fontScale), ImVec2(0, 0.5f), ImVec2(1, 1),
textColor, ImVec4(0, 0, 0, 0));
} else {
ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(
digitList[textureIndex].first),
ImGui::Image(std::dynamic_pointer_cast<Fast::Fast3dGui>(
Ship::Context::GetRawInstance()->GetWindow()->GetGui())
->GetTextureByName(digitList[textureIndex].first),
ImVec2(8.0f * fontScale, 16.0f * fontScale), ImVec2(0, 0), ImVec2(1, 1), textColor,
ImVec4(0, 0, 0, 0));
}
Expand Down Expand Up @@ -247,17 +250,18 @@ static void TimeDisplayInitTimers() {
}

void TimeDisplayWindow::InitElement() {
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("GAMEPLAY_TIMER", gClockIconTex,
ImVec4(1, 1, 1, 1));
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("DAY_TIME_TIMER", gSunIconTex,
ImVec4(1, 1, 1, 1));
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("NIGHT_TIME_TIMER", gMoonIconTex,
ImVec4(1, 1, 1, 1));
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("NAVI_TIMER", gNaviIconTex, ImVec4(1, 1, 1, 1));
std::dynamic_pointer_cast<Fast::Fast3dGui>(Ship::Context::GetRawInstance()->GetWindow()->GetGui())
->LoadGuiTexture("GAMEPLAY_TIMER", gClockIconTex, ImVec4(1, 1, 1, 1));
std::dynamic_pointer_cast<Fast::Fast3dGui>(Ship::Context::GetRawInstance()->GetWindow()->GetGui())
->LoadGuiTexture("DAY_TIME_TIMER", gSunIconTex, ImVec4(1, 1, 1, 1));
std::dynamic_pointer_cast<Fast::Fast3dGui>(Ship::Context::GetRawInstance()->GetWindow()->GetGui())
->LoadGuiTexture("NIGHT_TIME_TIMER", gMoonIconTex, ImVec4(1, 1, 1, 1));
std::dynamic_pointer_cast<Fast::Fast3dGui>(Ship::Context::GetRawInstance()->GetWindow()->GetGui())
->LoadGuiTexture("NAVI_TIMER", gNaviIconTex, ImVec4(1, 1, 1, 1));

for (auto& load : digitList) {
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(load.first.c_str(), load.second,
ImVec4(1, 1, 1, 1));
std::dynamic_pointer_cast<Fast::Fast3dGui>(Ship::Context::GetRawInstance()->GetWindow()->GetGui())
->LoadGuiTexture(load.first.c_str(), load.second, ImVec4(1, 1, 1, 1));
}

TimeDisplayInitSettings();
Expand Down
8 changes: 4 additions & 4 deletions soh/soh/Enhancements/Warping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(WarpPoint, entranceId, roomNum, pos, rotY, bo
std::map<std::string, WarpPoint> warpPoints;

void LoadConfig() {
auto allConfig = Ship::Context::GetInstance()->GetConfig()->GetNestedJson();
auto allConfig = Ship::Context::GetRawInstance()->GetConfig()->GetNestedJson();
if (allConfig.find("WarpPoints") == allConfig.end() || !allConfig["WarpPoints"].is_object()) {
allConfig["WarpPoints"] = nlohmann::json::object();
}
warpPoints = allConfig["WarpPoints"];
}

void SaveConfig() {
auto allConfig = Ship::Context::GetInstance()->GetConfig()->GetNestedJson();
auto allConfig = Ship::Context::GetRawInstance()->GetConfig()->GetNestedJson();
allConfig["WarpPoints"] = warpPoints;
Ship::Context::GetInstance()->GetConfig()->SetBlock("WarpPoints", warpPoints);
Ship::Context::GetInstance()->GetConfig()->Save();
Ship::Context::GetRawInstance()->GetConfig()->SetBlock("WarpPoints", warpPoints);
Ship::Context::GetRawInstance()->GetConfig()->Save();
}

void Warp(WarpPoint& warpPoint) {
Expand Down
4 changes: 2 additions & 2 deletions soh/soh/Enhancements/audio/AudioCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,15 +399,15 @@ void AudioCollection::RemoveFromShufflePool(SequenceInfo* seqInfo) {
excludedSequences.insert(seqInfo);
includedSequences.erase(seqInfo);
CVarSetInteger(cvarKey.c_str(), 1);
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
}

void AudioCollection::AddToShufflePool(SequenceInfo* seqInfo) {
const std::string cvarKey = std::string(CVAR_AUDIO("Excluded.")) + seqInfo->sfxKey;
includedSequences.insert(seqInfo);
excludedSequences.erase(seqInfo);
CVarClear(cvarKey.c_str());
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
}

void AudioCollection::InitializeShufflePool() {
Expand Down
Loading
Loading