From 3c06b3a6b465b76d8d783249e6adaabb7d7c1603 Mon Sep 17 00:00:00 2001 From: briaguya Date: Thu, 2 Jun 2022 23:24:57 -0400 Subject: [PATCH] start moving stuff out of sohimguiimpl --- libultraship/libultraship/SohImGuiImpl.cpp | 17 +------ soh/soh/Enhancements/randomizer.cpp | 52 ++++++++++++++++++++++ soh/soh/Enhancements/randomizer.h | 11 +++++ soh/soh/OTRGlobals.cpp | 2 + 4 files changed, 66 insertions(+), 16 deletions(-) diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index 9e1f3a7bf..8d09f504e 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -63,8 +63,6 @@ OSContPad* pads; std::map DefaultAssets; -std::thread randoThread; - // SpoilerData gSpoilerData; namespace SohImGui { @@ -438,7 +436,7 @@ namespace SohImGui { if (generated) { generated = 0; - randoThread.join(); + // randoThread.join(); } ImGuiProcessEvent(event); @@ -1046,19 +1044,6 @@ namespace SohImGui { ImGui::EndMenu(); } - if (ImGui::BeginMenu("Randomizer")) - { - EnhancementCheckbox("Enable Randomizer", "gRandomizer"); - - if (ImGui::Button("Generate Seed")) { - if (CVar_GetS32("gRandoGenerating", 0) == 0) { - randoThread = std::thread(&SohImGui::GenerateRandomizerImgui); - } - } - - ImGui::EndMenu(); - } - if (ImGui::BeginMenu("Developer Tools")) { EnhancementCheckbox("OoT Debug Mode", "gDebugEnabled"); diff --git a/soh/soh/Enhancements/randomizer.cpp b/soh/soh/Enhancements/randomizer.cpp index d3fe5fbfb..a67810131 100644 --- a/soh/soh/Enhancements/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer.cpp @@ -9,6 +9,8 @@ #include #include #include +#include "../libultraship/SohImGuiImpl.h" +#include using json = nlohmann::json; @@ -2048,3 +2050,53 @@ RandomizerCheck Randomizer::GetCheckFromActor(s16 sceneNum, s16 actorId, s16 act return RC_UNKNOWN_CHECK; } + +std::thread randoThread; + +void DrawRandoEditor(bool& open) { + if (!open) { + return; + } + + ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); + if (!ImGui::Begin("Rando Editor", &open, ImGuiWindowFlags_NoFocusOnAppearing)) { + ImGui::End(); + return; + } + + ImGui::End(); +} + +// void EnhancementCheckbox(const char* text, const char* cvarName) +// { +// bool val = (bool)CVar_GetS32(cvarName, 0); +// if (ImGui::Checkbox(text, &val)) { +// CVar_SetS32(cvarName, val); +// needs_save = true; +// } +// } + +void InitRando() { + SohImGui::AddWindow("Developer Tools", "Rando Editor", DrawRandoEditor); + + // if (ImGui::BeginMenu("Randomizer")) + // { + // // EnhancementCheckbox("Enable Randomizer", "gRandomizer"); + + // if (ImGui::Button("Generate Seed")) { + // if (CVar_GetS32("gRandoGenerating", 0) == 0) { + // randoThread = std::thread(&SohImGui::GenerateRandomizerImgui); + // } + // } + + // ImGui::EndMenu(); + // } +} + +extern "C" { + +void Rando_Init(void) { + InitRando(); +} + +} \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer.h b/soh/soh/Enhancements/randomizer.h index c32b89a9f..3f02f1930 100644 --- a/soh/soh/Enhancements/randomizer.h +++ b/soh/soh/Enhancements/randomizer.h @@ -27,4 +27,15 @@ class Randomizer { GetItemID GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum); }; +#ifdef __cplusplus +extern "C" { +#endif + +void Rando_Init(void); + +#ifdef __cplusplus +} +#endif + + #endif diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 00da4f2f5..f08b6ffb8 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -29,6 +29,7 @@ #include "AudioPlayer.h" #include "Enhancements/debugconsole.h" #include "Enhancements/debugger/debugger.h" +#include "Enhancements/randomizer.h" #include "soh/frame_interpolation.h" #include "Utils/BitConverter.h" #include "variables.h" @@ -76,6 +77,7 @@ extern "C" void InitOTR() { OTRMessage_Init(); DebugConsole_Init(); Debug_Init(); + Rando_Init(); } #ifdef _WIN32