Add checkpoint developer tool (doesn't work perfectly)

This commit is contained in:
Garrett Cox 2024-11-24 23:40:00 -06:00 committed by Alejandro Asenjo Nitti
parent 0e39eed609
commit e34419b38e
2 changed files with 23 additions and 0 deletions

View File

@ -4647,6 +4647,13 @@ void Player_Setup(Player* playerx) {
gDisplayedHitCount = gHitCount;
D_hud_80161730 = 0;
if (CVarGetInteger("gCheckpoint.Set", 0)) {
gSavedGroundSurface = CVarGetInteger("gCheckpoint.gSavedGroundSurface", gSavedGroundSurface);
gSavedPathProgress = CVarGetFloat("gCheckpoint.gSavedPathProgress", gSavedPathProgress);
gSavedObjectLoadIndex = CVarGetInteger("gCheckpoint.gSavedObjectLoadIndex", gSavedObjectLoadIndex);
}
gMissedZoSearchlight = gSavedZoSearchlightStatus;
gObjectLoadIndex = gSavedObjectLoadIndex;
gGroundSurface = gSavedGroundSurface;

View File

@ -15,6 +15,7 @@
extern "C" {
#include "sys.h"
#include <sf64audio_provisional.h>
#include <sf64context.h>
}
namespace GameUI {
@ -558,6 +559,21 @@ void DrawDebugMenu() {
.tooltip = "Control the Arwing speed"
});
if (CVarGetInteger("gCheckpoint.Set", 0)) {
if (UIWidgets::Button("Clear Checkpoint")) {
CVarClear("gCheckpoint.Set");
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
}
} else if (gPlayer != NULL) {
if (UIWidgets::Button("Set Checkpoint")) {
CVarSetInteger("gCheckpoint.Set", 1);
CVarSetInteger("gCheckpoint.gSavedPathProgress", gGroundSurface);
CVarSetFloat("gCheckpoint.gSavedPathProgress", (-gPlayer->pos.z) - 250.0f);
CVarSetInteger("gCheckpoint.gSavedObjectLoadIndex", gObjectLoadIndex);
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
}
}
UIWidgets::Spacer(0);
UIWidgets::WindowButton("Stats", "gStatsEnabled", GameUI::mStatsWindow, {