From e34419b38edf41b1ea03a99c0b586030dbf20bf4 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Sun, 24 Nov 2024 23:40:00 -0600 Subject: [PATCH] Add checkpoint developer tool (doesn't work perfectly) --- src/engine/fox_play.c | 7 +++++++ src/port/ui/ImguiUI.cpp | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/engine/fox_play.c b/src/engine/fox_play.c index 38407a59..3e90db13 100644 --- a/src/engine/fox_play.c +++ b/src/engine/fox_play.c @@ -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; diff --git a/src/port/ui/ImguiUI.cpp b/src/port/ui/ImguiUI.cpp index 640c7f4f..a9fc6fef 100644 --- a/src/port/ui/ImguiUI.cpp +++ b/src/port/ui/ImguiUI.cpp @@ -15,6 +15,7 @@ extern "C" { #include "sys.h" #include +#include } 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, {