diff --git a/src/code_800029B0.c b/src/code_800029B0.c index 88453dcaa..18b3c5f63 100644 --- a/src/code_800029B0.c +++ b/src/code_800029B0.c @@ -60,7 +60,8 @@ struct UnkStruct_800DC5EC* D_800DC5EC = &D_8015F480[0]; struct UnkStruct_800DC5EC* D_800DC5F0 = &D_8015F480[1]; struct UnkStruct_800DC5EC* D_800DC5F4 = &D_8015F480[2]; struct UnkStruct_800DC5EC* D_800DC5F8 = &D_8015F480[3]; -u16 gIsGamePaused = 0; // 1 if the game is paused and 0 if the game is not paused +u16 gIsGamePaused = false; // true if the game is paused and false if the game is not paused +bool gIsEditorPaused = false; u8* pAppNmiBuffer = (u8*) &osAppNmiBuffer; s32 gIsMirrorMode = 0; diff --git a/src/code_800029B0.h b/src/code_800029B0.h index 8e605c3ee..a5f590e08 100644 --- a/src/code_800029B0.h +++ b/src/code_800029B0.h @@ -61,6 +61,7 @@ extern struct UnkStruct_800DC5EC* D_800DC5F0; extern struct UnkStruct_800DC5EC* D_800DC5F4; extern struct UnkStruct_800DC5EC* D_800DC5F8; extern u16 gIsGamePaused; +extern bool gIsEditorPaused; extern u8* pAppNmiBuffer; extern s32 gIsMirrorMode; // D_800DC604 extern s16 gCreditsCourseId; diff --git a/src/code_80057C60.c b/src/code_80057C60.c index 1618bf57f..044e15619 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -1243,7 +1243,7 @@ void func_80059A88(s32 playerId) { void func_80059AC8(void) { s32 i; - if (gIsGamePaused == false) { + if ((gIsGamePaused == false) && (gIsEditorPaused == false)) { func_8008C1D8(&D_80165678); gRaceFrameCounter++; for (i = 0; i < gPlayerCount; i++) { @@ -1409,7 +1409,7 @@ void func_8005A070(void) { gMatrixHudCount = 0; D_801655C0 = 0; func_80041D34(); - if (gIsGamePaused == false) { + if (gIsGamePaused == false && (gIsEditorPaused == false)) { func_8005C728(); if (gGamestate == ENDING) { // func_80086604(); diff --git a/src/code_8006E9C0.c b/src/code_8006E9C0.c index e5cc43887..e499f3779 100644 --- a/src/code_8006E9C0.c +++ b/src/code_8006E9C0.c @@ -379,7 +379,7 @@ void func_8006F824(s32 arg0) { D_80165828 = D_801657F8; D_80165832[0] = D_80165800[0]; D_80165832[1] = D_80165800[1]; - if ((arg0 != 0) && (gIsGamePaused == 0)) { + if ((arg0 != 0) && (gIsGamePaused == 0) && (gIsEditorPaused == false)) { play_sound2(SOUND_ACTION_PING); } } diff --git a/src/main.c b/src/main.c index 94e076ca6..e524ab26d 100644 --- a/src/main.c +++ b/src/main.c @@ -748,14 +748,23 @@ void display_debug_info(void) { } void process_game_tick(void) { - if (D_8015011E) { - gCourseTimer += COURSE_TIMER_ITER; + + if (gIsEditorPaused == false) { + if (D_8015011E) { + gCourseTimer += COURSE_TIMER_ITER; + } + func_802909F0(); + evaluate_collision_for_players_and_actors(); + func_800382DC(); } - func_802909F0(); - evaluate_collision_for_players_and_actors(); - func_800382DC(); + + // Editor requires this for camera movement. func_8001EE98(gPlayerOneCopy, camera1, 0); + if (gIsEditorPaused == true) { + return; + } + switch(gActiveScreenMode) { case SCREEN_MODE_1P: func_80028F70(); @@ -818,11 +827,13 @@ void race_logic_loop(void) { network_all_players_loaded(); } - if (gIsGamePaused == 0) { + if (gIsGamePaused == false) { for (size_t i = 0; i < gTickLogic; i++) { process_game_tick(); } - func_80022744(); + if (gIsEditorPaused == false) { + func_80022744(); + } } func_8005A070(); profiler_log_thread5_time(LEVEL_SCRIPT_EXECUTE); diff --git a/src/port/ui/Tools.cpp b/src/port/ui/Tools.cpp index b8af1e5e3..c457d555a 100644 --- a/src/port/ui/Tools.cpp +++ b/src/port/ui/Tools.cpp @@ -11,6 +11,10 @@ #include #include +extern "C" { +#include "code_800029B0.h" +} + namespace EditorNamespace { ToolsWindow::~ToolsWindow() { @@ -24,6 +28,7 @@ namespace EditorNamespace { void ToolsWindow::DrawElement() { static bool toggleState = CVarGetInteger("gEditorSnapToGround", 0); static int selectedTool = 0; // 0: Move, 1: Rotate, 2: Scale + static int selectedPlayTool = 0; // 0: Play, 1: Paused ImVec4 defaultColor = ImGui::GetStyle().Colors[ImGuiCol_Button]; // Function to check and highlight the selected button @@ -64,5 +69,24 @@ namespace EditorNamespace { gPlayerOne->type |= PLAYER_KART_AI; } } + + ImGui::SameLine(); + + auto PlayButton = [&](const char* label, int id) { + bool isSelected = (selectedPlayTool == id); + ImGui::PushStyleColor(ImGuiCol_Button, isSelected ? ImVec4(0.4f, 0.7f, 0.9f, 1.0f) : defaultColor); + + if (ImGui::Button(label, ImVec2(125, 25))) { + selectedPlayTool = id; // Set the selected tool + gIsEditorPaused = (id == 1); + } + + ImGui::PopStyleColor(); + }; + + // Draw buttons + PlayButton("Play", 0); + ImGui::SameLine(); + PlayButton("Pause", 1); } }