merging from old version of branch

This commit is contained in:
LT_Schmiddy (Alex Schmid) 2024-11-23 22:59:27 -05:00
commit b1a6d32123
7 changed files with 64 additions and 0 deletions

View File

@ -73,6 +73,13 @@
</panel>
</tabset>
<div class="config__icon-buttons">
<button
class="icon-button"
onclick="open_reset_game_prompt"
id="config__reset_game-button"
>
<svg src="icons/Reset.svg" />
</button>
<button
class="icon-button"
onclick="open_quit_game_prompt"

View File

@ -88,6 +88,9 @@ namespace zelda64 {
void set_analog_cam_mode(AnalogCamMode mode);
void open_quit_game_prompt();
void open_reset_game_prompt();
extern bool should_game_reset;
};
#endif

View File

@ -1,6 +1,10 @@
#include "play_patches.h"
#include "z64debug_display.h"
#include "input.h"
#include "input.h"
#include "z64game.h"
#include "overlays/gamestates/ovl_title/z_title.h"
#include "prevent_bss_reordering.h"
#include "z64.h"
#include "regs.h"
@ -36,11 +40,20 @@ void controls_play_update(PlayState* play) {
gSaveContext.options.zTargetSetting = recomp_get_targeting_mode();
}
void do_reset_game(PlayState* this) {
STOP_GAMESTATE(&this->state);
SET_NEXT_GAMESTATE(&this->state, ConsoleLogo_Init, sizeof(ConsoleLogoState));
}
// @recomp Patched to add hooks for various added functionality.
RECOMP_PATCH void Play_Main(GameState* thisx) {
static Input* prevInput = NULL;
PlayState* this = (PlayState*)thisx;
if (recomp_should_reset_game()) {
do_reset_game(this);
}
// @recomp_event recomp_on_play_main(PlayState* play): Allow mods to execute code every frame.
recomp_on_play_main(this);

View File

@ -2,6 +2,9 @@
#define __PLAY_PATCHES_H__
#include "patches.h"
#include "patch_helpers.h"
DECLARE_FUNC(bool, recomp_should_reset_game);
void debug_play_update(PlayState* play);
void camera_pre_play_update(PlayState* play);
@ -11,4 +14,6 @@ void analog_cam_post_play_update(PlayState* play);
void matrix_play_update(PlayState* play);
void autosave_post_play_update(PlayState* play);
#endif

View File

@ -44,3 +44,4 @@ 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;

View File

@ -166,3 +166,11 @@ extern "C" void recomp_set_right_analog_suppressed(uint8_t* rdram, recomp_contex
recomp::set_right_analog_suppressed(suppressed);
}
extern "C" void recomp_should_reset_game(uint8_t* rdram, recomp_context* ctx) {
bool retVal = zelda64::should_game_reset;
zelda64::should_game_reset = false;
_return(ctx, retVal);
}

View File

@ -161,6 +161,11 @@ static bool sample_positions_supported = false;
static bool cont_active = true;
namespace zelda64 {
bool should_game_reset;
}
static recomp::InputDevice cur_device = recomp::InputDevice::Controller;
int recomp::get_scanned_input_index() {
@ -279,6 +284,23 @@ void zelda64::open_quit_game_prompt() {
);
}
void zelda64::open_reset_game_prompt() {
prompt_context.open_prompt(
"Return to the main menu?",
"Any progress since your last save will be lost.",
"Quit",
"Cancel",
[]() {
should_game_reset = true;
},
[]() {},
recompui::ButtonVariant::Error,
recompui::ButtonVariant::Tertiary,
true,
"config__quit-game-button"
);
}
// These defaults values don't matter, as the config file handling overrides them.
struct ControlOptionsContext {
int rumble_strength; // 0 to 100
@ -559,6 +581,11 @@ public:
zelda64::open_quit_game_prompt();
});
recompui::register_event(listener, "open_reset_game_prompt",
[](const std::string& param, Rml::Event& event) {
zelda64::open_reset_game_prompt();
});
recompui::register_event(listener, "toggle_input_device",
[](const std::string& param, Rml::Event& event) {
cur_device = cur_device == recomp::InputDevice::Controller