Skip to content

Commit

Permalink
Finish dev tools
Browse files Browse the repository at this point in the history
  • Loading branch information
aMannus committed Feb 1, 2025
1 parent 7e13a16 commit 9e582e1
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 12 deletions.
3 changes: 3 additions & 0 deletions soh/soh/SohGui/MenuTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ typedef enum {
DISABLE_FOR_ADVANCED_RESOLUTION_ON,
DISABLE_FOR_VERTICAL_RES_TOGGLE_ON,
DISABLE_FOR_LOW_RES_MODE_ON,
DISABLE_FOR_NULL_PLAY_STATE,
DISABLE_FOR_DEBUG_MODE_OFF,
DISABLE_FOR_FRAME_ADVANCE_OFF,
} DisableOption;

struct WidgetInfo;
Expand Down
15 changes: 8 additions & 7 deletions soh/soh/SohGui/SohMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@
#include <spdlog/fmt/fmt.h>
#include <tuple>

extern "C" {
#include "z64.h"
#include "functions.h"
#include "variables.h"
extern PlayState* gPlayState;
}
extern std::unordered_map<s16, const char*> warpPointSceneList;
extern void Warp();

namespace SohGui {
extern std::shared_ptr<SohMenu> mSohMenu;
Expand Down Expand Up @@ -142,6 +135,14 @@ void SohMenu::InitElement() {
"Vertical Resolution Toggle Enabled" } },
{ DISABLE_FOR_LOW_RES_MODE_ON,
{ [](disabledInfo& info) -> bool { return CVarGetInteger(CVAR_LOW_RES_MODE, 0); }, "N64 Mode Enabled" } },
{ DISABLE_FOR_NULL_PLAY_STATE,
{ [](disabledInfo& info) -> bool { return gPlayState == NULL; }, "Save Not Loaded" } },
{ DISABLE_FOR_DEBUG_MODE_OFF,
{ [](disabledInfo& info) -> bool { return !CVarGetInteger("gDeveloperTools.DebugEnabled", 0); },
"Debug Mode is Disabled" } },
{ DISABLE_FOR_FRAME_ADVANCE_OFF,
{ [](disabledInfo& info) -> bool { return !(gPlayState != nullptr && gPlayState->frameAdvCtx.enabled); },
"Frame Advance is Disabled" } },
};
}

Expand Down
11 changes: 11 additions & 0 deletions soh/soh/SohGui/SohMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
#include "graphic/Fast3D/gfx_rendering_api.h"
#include "soh/cvar_prefixes.h"

extern "C" {
#include "z64.h"
#include "functions.h"
#include "variables.h"
extern PlayState* gPlayState;
}

namespace SohGui {

static const std::unordered_map<int32_t, const char*> menuThemeOptions = {
Expand Down Expand Up @@ -42,6 +49,10 @@ static const std::unordered_map<int32_t, const char*> notificationPosition = {
{ 0, "Top Left" }, { 1, "Top Right" }, { 2, "Bottom Left" }, { 3, "Bottom Right" }, { 4, "Hidden" },
};

static const std::unordered_map<int32_t, const char*> debugSaveFileModes = {
{ 0, "Off" }, { 1, "Vanilla" }, { 2, "Maxed" },
};

class SohMenu : public Ship::Menu {
public:
SohMenu(const std::string& consoleVariable, const std::string& name);
Expand Down
70 changes: 69 additions & 1 deletion soh/soh/SohGui/SohMenuDevTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,75 @@ void SohMenu::AddMenuDevTools() {
AddWidget(path, "Popout Menu", WIDGET_CVAR_CHECKBOX)
.CVar("gSettings.Menu.Popout")
.Options(CheckboxOptions().Tooltip("Changes the menu display from overlay to windowed."));
AddWidget(path, "Debug Mode", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_DEVELOPER_TOOLS("DebugEnabled"))
.Options(CheckboxOptions().Tooltip("Enables Debug Mode, allowing you to select maps with L + R + Z, noclip "
"with L + D-pad Right, and open the debug menu with L on the pause screen."));
AddWidget(path, "OoT Registry Editor", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_DEVELOPER_TOOLS("RegEditEnabled"))
.PreFunc([](WidgetInfo& info) { info.isHidden = !CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0); })
.Options(CheckboxOptions().Tooltip("Enables the registry editor."));
AddWidget(path, "Debug Save File Mode", WIDGET_CVAR_COMBOBOX)
.CVar(CVAR_DEVELOPER_TOOLS("DebugSaveFileMode"))
.PreFunc([](WidgetInfo& info) { info.isHidden = !CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0); })
.Options(ComboboxOptions()
.Tooltip("Changes the behaviour of debug file select creation (creating a save file on slot 1 "
"with debug mode on)\n"
"- Off: The debug save file will be a normal savefile\n"
"- Vanilla: The debug save file will be the debug save file from the original game\n"
"- Maxed: The debug save file will be a save file with all of the items & upgrades")
.ComboMap(debugSaveFileModes));
AddWidget(path, "OoT Skulltula Debug", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_DEVELOPER_TOOLS("SkulltulaDebugEnabled"))
.Options(CheckboxOptions().Tooltip("Enables Skulltula Debug, when moving the cursor in the menu above various "
"map icons (boss key, compass, map screen locations, etc) will set the GS "
"bits in that area.\nUSE WITH CAUTION AS IT DOES NOT UPDATE THE GS COUNT."));
AddWidget(path, "Better Debug Warp Screen", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_DEVELOPER_TOOLS("BetterDebugWarpScreen"))
.Options(CheckboxOptions().Tooltip(
"Optimized debug warp screen, with the added ability to chose entrances and time of day"));
AddWidget(path, "Debug Warp Screen Translation", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_DEVELOPER_TOOLS("DebugWarpScreenTranslation"))
.Options(CheckboxOptions()
.Tooltip("Translate the Debug Warp Screen based on the game language.")
.DefaultValue(true));
AddWidget(path, "Resource logging", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_DEVELOPER_TOOLS("ResourceLogging"))
.Options(CheckboxOptions().Tooltip("Logs some resources as XML when they're loaded in binary format"));

AddWidget(path, "Frame Advance", WIDGET_CHECKBOX)
.Options(CheckboxOptions().Tooltip(
"This allows you to advance through the game one frame at a time on command. "
"To advance a frame, hold Z and tap R on the second controller. Holding Z "
"and R will advance a frame every half second. You can also use the buttons below."))
.PreFunc([](WidgetInfo& info) {
info.isHidden = mSohMenu->disabledMap.at(DISABLE_FOR_NULL_PLAY_STATE).active ||
mSohMenu->disabledMap.at(DISABLE_FOR_DEBUG_MODE_OFF).active;
if (gPlayState != nullptr) {
info.valuePointer = (bool*)&gPlayState->frameAdvCtx.enabled;
} else {
info.valuePointer = (bool*)nullptr;
}
});
AddWidget(path, "Advance 1", WIDGET_BUTTON)
.Options(ButtonOptions().Tooltip("Advance 1 frame.").Size(Sizes::Inline))
.Callback([](WidgetInfo& info) { CVarSetInteger(CVAR_DEVELOPER_TOOLS("FrameAdvanceTick"), 1); })
.PreFunc([](WidgetInfo& info) {
info.isHidden = mSohMenu->disabledMap.at(DISABLE_FOR_FRAME_ADVANCE_OFF).active ||
mSohMenu->disabledMap.at(DISABLE_FOR_DEBUG_MODE_OFF).active;
});
AddWidget(path, "Advance (Hold)", WIDGET_BUTTON)
.Options(ButtonOptions().Tooltip("Advance frames while the button is held.").Size(Sizes::Inline))
.PreFunc([](WidgetInfo& info) {
info.isHidden = mSohMenu->disabledMap.at(DISABLE_FOR_FRAME_ADVANCE_OFF).active ||
mSohMenu->disabledMap.at(DISABLE_FOR_DEBUG_MODE_OFF).active;
})
.PostFunc([](WidgetInfo& info) {
if (ImGui::IsItemActive()) {
CVarSetInteger(CVAR_DEVELOPER_TOOLS("FrameAdvanceTick"), 1);
}
})
.SameLine(true);

// Stats
path.sidebarName = "Stats";
Expand Down Expand Up @@ -96,7 +165,6 @@ void SohMenu::AddMenuDevTools() {
.CVar(CVAR_WINDOW("GfxDebugger"))
.WindowName("Gfx Debugger")
.Options(ButtonOptions().Tooltip("Enables the separate Gfx Debugger Window.").Size(Sizes::Inline));

}

} // namespace SohGui
2 changes: 1 addition & 1 deletion soh/soh/SohGui/SohMenuSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void SohMenu::AddMenuSettings() {
.Options(IntSliderOptions()
.Min(0)
.Max(100)
.DefaultValue(50)
.DefaultValue(30)
.ShowButtons(true)
.Format(""));
AddWidget(path, "Main Music Volume: %d %%", WIDGET_CVAR_SLIDER_INT)
Expand Down
2 changes: 1 addition & 1 deletion soh/soh/config/ConfigMigrators.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace SOH {

std::vector<Migration> version3Migrations = {
{ MigrationAction::Rename, "gSwitchAge", "gGeneral.SwitchAge" },
{ MigrationAction::Rename, "gFrameAdvance", "gGeneral.FrameAdvance" },
{ MigrationAction::Rename, "gFrameAdvance", "gDeveloperTools.FrameAdvanceTick" },
{ MigrationAction::Rename, "gRandoGenerating", "gGeneral.RandoGenerating" },
{ MigrationAction::Rename, "gNewSeedGenerated", "gGeneral.NewSeedGenerated" },
{ MigrationAction::Rename, "gOnFileSelectNameEntry", "gGeneral.OnFileSelectNameEntry" },
Expand Down
5 changes: 3 additions & 2 deletions soh/src/code/z_frame_advance.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, Input* input) {
frameAdvCtx->enabled = !frameAdvCtx->enabled;
}

if (!frameAdvCtx->enabled || CVarGetInteger(CVAR_GENERAL("FrameAdvance"), 0) || (CHECK_BTN_ALL(input->cur.button, BTN_Z) &&
if (!frameAdvCtx->enabled || CVarGetInteger(CVAR_DEVELOPER_TOOLS("FrameAdvanceTick"), 0) ||
(CHECK_BTN_ALL(input->cur.button, BTN_Z) &&
(CHECK_BTN_ALL(input->press.button, BTN_R) ||
(CHECK_BTN_ALL(input->cur.button, BTN_R) && (++frameAdvCtx->timer >= 9))))) {
CVarClear(CVAR_GENERAL("FrameAdvance"));
CVarClear(CVAR_DEVELOPER_TOOLS("FrameAdvanceTick"));
frameAdvCtx->timer = 0;
return true;
}
Expand Down

0 comments on commit 9e582e1

Please sign in to comment.