Hides the reset button in the launcher and in the main menu.

This commit is contained in:
LT-Schmiddy 2024-11-25 18:32:59 -05:00
parent f3ba1ce5d6
commit 5b0578dd87
9 changed files with 123 additions and 4 deletions

View File

@ -72,12 +72,13 @@
<template src="config-menu__debug" />
</panel>
</tabset>
<div class="config__icon-buttons">
<div data-model="game_reset_model" class="config__icon-buttons">
<button
class="icon-button"
onclick="open_reset_game_prompt"
id="config__reset_game-button"
>
data-if="reset_button_visibility"
>
<svg src="icons/Reset.svg" />
</button>
<button

View File

@ -89,6 +89,8 @@ namespace zelda64 {
void open_quit_game_prompt();
void open_reset_game_prompt();
void set_reset_button_visibility(bool enabled);
};
#endif

View File

@ -1,5 +1,7 @@
#ifndef __ZELDA_GAME_H__
#define __ZELDA_GAME_H__
#include <stdint.h>
#include <atomic>
namespace zelda64 {
// Quicksaving is disabled for now:

View File

@ -26,6 +26,7 @@
#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h"
#include "debug.h"
extern Input D_801F6C18;
RECOMP_DECLARE_EVENT(recomp_on_play_main(PlayState* play));
@ -174,6 +175,7 @@ RECOMP_PATCH void Play_Init(GameState* thisx) {
// @recomp_event recomp_on_play_init(PlayState* this): A new PlayState is being initialized.
recomp_on_play_init(this);
recomp_set_reset_button_visibility(1);
if ((gSaveContext.respawnFlag == -4) || (gSaveContext.respawnFlag == -0x63)) {
if (CHECK_EVENTINF(EVENTINF_TRIGGER_DAYTELOP)) {
@ -441,3 +443,74 @@ RECOMP_PATCH void Play_Init(GameState* thisx) {
// @recomp_event recomp_after_play_init(PlayState* this): The new PlayState has finished initializing.
recomp_after_play_init(this);
}
void Play_ClearTransition(PlayState* this);
void Play_DestroyMotionBlur(void);
void ZeldaArena_Cleanup();
RECOMP_PATCH void Play_Destroy(GameState* thisx) {
PlayState* this = (PlayState*)thisx;
GraphicsContext* gfxCtx = this->state.gfxCtx;
recomp_set_reset_button_visibility(0);
if (sBombersNotebookOpen) {
MsgEvent_SendNullTask();
SysCfb_SetLoResMode();
gfxCtx->curFrameBuffer = SysCfb_GetFramebuffer(gfxCtx->framebufferIndex % 2);
gfxCtx->zbuffer = SysCfb_GetZBuffer();
gfxCtx->viMode = gActiveViMode;
gfxCtx->viConfigFeatures = gViConfigFeatures;
gfxCtx->xScale = gViConfigXScale;
gfxCtx->yScale = gViConfigYScale;
gfxCtx->updateViMode = true;
sBombersNotebookOpen = false;
}
BombersNotebook_Destroy(&sBombersNotebook);
this->state.gfxCtx->callback = NULL;
this->state.gfxCtx->callbackArg = NULL;
Play_DestroyMotionBlur();
if (R_PAUSE_BG_PRERENDER_STATE != PAUSE_BG_PRERENDER_OFF) {
PreRender_ApplyFiltersSlowlyDestroy(&this->pauseBgPreRender);
R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_OFF;
}
R_PICTO_PHOTO_STATE = PICTO_PHOTO_STATE_OFF;
PreRender_Destroy(&this->pauseBgPreRender);
this->unk_18E58 = NULL;
this->pictoPhotoI8 = NULL;
this->unk_18E60 = NULL;
this->unk_18E64 = NULL;
this->unk_18E68 = NULL;
Effect_DestroyAll(this);
EffectSS_Clear(this);
CollisionCheck_DestroyContext(this, &this->colChkCtx);
if (gTransitionTileState == TRANS_TILE_READY) {
TransitionTile_Destroy(&sTransitionTile);
gTransitionTileState = TRANS_TILE_OFF;
}
if ((this->transitionMode == TRANS_MODE_INSTANCE_RUNNING) || D_801D0D54) {
this->transitionCtx.destroy(&this->transitionCtx.instanceData);
Play_ClearTransition(this);
this->transitionMode = TRANS_MODE_OFF;
}
ShrinkWindow_Destroy();
TransitionFade_Destroy(&this->unk_18E48);
VisMono_Destroy(&sPlayVisMono);
VisFbuf_Destroy(sPlayVisFbufInstance);
sPlayVisFbufInstance = NULL;
if (CHECK_WEEKEVENTREG(WEEKEVENTREG_92_80)) {
Actor_CleanupContext(&this->actorCtx, this);
}
CLEAR_WEEKEVENTREG(WEEKEVENTREG_92_80);
Interface_Destroy(this);
KaleidoScopeCall_Destroy(this);
KaleidoManager_Destroy();
ZeldaArena_Cleanup();
}

View File

@ -2,6 +2,7 @@
#define __PLAY_PATCHES_H__
#include "patches.h"
#include "patch_helpers.h"
void debug_play_update(PlayState* play);
void camera_pre_play_update(PlayState* play);
@ -11,4 +12,6 @@ void analog_cam_post_play_update(PlayState* play);
void matrix_play_update(PlayState* play);
void autosave_post_play_update(PlayState* play);
DECLARE_FUNC(void, recomp_set_reset_button_visibility, u8 visibility);
#endif

View File

@ -44,4 +44,5 @@ recomp_get_inverted_axes = 0x8F0000A4;
recomp_high_precision_fb_enabled = 0x8F0000A8;
recomp_get_resolution_scale = 0x8F0000AC;
recomp_get_analog_inverted_axes = 0x8F0000B0;
recomp_should_reset_game = 0x8F0000B4;
recomp_should_reset_game = 0x8F0000B4;
recomp_set_reset_button_visibility = 0x8F0000B8;

View File

@ -1,4 +1,5 @@
#include <cmath>
#include <iostream>
#include "librecomp/recomp.h"
#include "librecomp/overlays.hpp"
@ -177,4 +178,11 @@ extern "C" void recomp_set_right_analog_suppressed(uint8_t* rdram, recomp_contex
extern "C" void recomp_should_reset_game(uint8_t* rdram, recomp_context* ctx) {
_return(ctx, should_game_reset.exchange(0x00));
}
extern "C" void recomp_set_reset_button_visibility(uint8_t* rdram, recomp_context* ctx) {
uint8_t storeVal = _arg<0, uint8_t>(rdram, ctx);
std::cout << "Reset Button Visibility: " << std::to_string(storeVal) << "\n";
zelda64::set_reset_button_visibility((bool)storeVal);
}

View File

@ -16,6 +16,7 @@ Rml::DataModelHandle general_model_handle;
Rml::DataModelHandle controls_model_handle;
Rml::DataModelHandle graphics_model_handle;
Rml::DataModelHandle sound_options_model_handle;
Rml::DataModelHandle reset_game_model_handle;
recompui::PromptContext prompt_context;
@ -529,6 +530,18 @@ void recompui::update_rml_display_refresh_rate() {
DebugContext debug_context;
struct ResetGameContext {
std::atomic<bool> reset_button_visibility;
};
ResetGameContext reset_game_context;
void zelda64::set_reset_button_visibility(bool enabled) {
reset_game_context.reset_button_visibility.store(enabled);
if (reset_game_model_handle) {
reset_game_model_handle.DirtyVariable("reset_button_visibility");
}
}
class ConfigMenu : public recompui::MenuController {
public:
ConfigMenu() {
@ -1030,6 +1043,19 @@ public:
prompt_context.model_handle = constructor.GetModelHandle();
}
void make_game_reset_bindings(Rml::Context* context) {
Rml::DataModelConstructor constructor = context->CreateDataModel("game_reset_model");
if (!constructor) {
throw std::runtime_error("Failed to make RmlUi data model for the game reset button");
}
// Bind the debug mode enabled flag.
reset_game_model_handle = constructor.GetModelHandle();
bind_atomic(constructor, reset_game_model_handle, "reset_button_visibility", &reset_game_context.reset_button_visibility);
}
void make_bindings(Rml::Context* context) override {
// initially set cont state for ui help
recomp::config_menu_set_cont_or_kb(recompui::get_cont_active());
@ -1040,6 +1066,7 @@ public:
make_sound_options_bindings(context);
make_debug_bindings(context);
make_prompt_bindings(context);
make_game_reset_bindings(context);
}
};

View File

@ -2,6 +2,7 @@
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <iostream>
#include <fstream>
#include <filesystem>
#ifdef _WIN32
@ -15,6 +16,7 @@
#include "recomp_input.h"
#include "librecomp/game.hpp"
#include "zelda_config.h"
#include "zelda_game.h"
#include "ui_rml_hacks.hpp"
#include "concurrentqueue.h"
@ -1020,7 +1022,7 @@ struct UIContext {
current_document->GetElementsByTagName(tabs, "tab");
for (const auto& tab : tabs) {
tab->SetProperty("nav-down", "#" + id);
}
}
}
void update_prompt_loop(void) {