From 3a69f6baaa2aa591a58191fa1a826a5b9fb94add Mon Sep 17 00:00:00 2001 From: korenkonder Date: Wed, 7 Jun 2023 01:18:25 +0300 Subject: [PATCH] Add PV Debug --- src/ReDIVA/config.hpp | 1 + src/ReDIVA/pv_game/pv_game.cpp | 135 ++++++++++++++++++++++++++++++++- src/ReDIVA/pv_game/pv_game.hpp | 15 ++++ src/ReDIVA/render.cpp | 4 + src/ReDIVA/system_startup.cpp | 11 ++- 5 files changed, 160 insertions(+), 6 deletions(-) diff --git a/src/ReDIVA/config.hpp b/src/ReDIVA/config.hpp index 62713099..a78c8906 100644 --- a/src/ReDIVA/config.hpp +++ b/src/ReDIVA/config.hpp @@ -7,6 +7,7 @@ #define BAKE_PNG (0) #define BAKE_VIDEO (0) #define BAKE_PV826 (0) +#define PV_DEBUG (0) #define DATA_EDIT (0) #endif diff --git a/src/ReDIVA/pv_game/pv_game.cpp b/src/ReDIVA/pv_game/pv_game.cpp index 48c3e198..80ac616a 100644 --- a/src/ReDIVA/pv_game/pv_game.cpp +++ b/src/ReDIVA/pv_game/pv_game.cpp @@ -16,6 +16,8 @@ #include "../../CRE/sound.hpp" #include "../../KKdLib/prj/algorithm.hpp" #include "../game_state.hpp" +#include "../imgui_helper.hpp" +#include "../input.hpp" #include "player_data.hpp" #include "pv_game_camera.hpp" #include "pv_game_music.hpp" @@ -5207,7 +5209,11 @@ void TaskPvGame::Data::Reset() { option = 0; } +#if PV_DEBUG +TaskPvGame::TaskPvGame() : pause(), step_frame(), is_paused() { +#else TaskPvGame::TaskPvGame() { +#endif } @@ -5216,6 +5222,12 @@ TaskPvGame::~TaskPvGame() { } bool TaskPvGame::Init() { +#if PV_DEBUG + pause = true; + step_frame = false; + is_paused = false; +#endif + Load(data); //touch_util::touch_reaction_set_enable(false); return true; @@ -5237,6 +5249,120 @@ void TaskPvGame::Disp() { pv_game_parent_disp(); } +#if PV_DEBUG +void TaskPvGame::Window() { + if (pv_game_parent_data.pv_state != 1 || pv_game_parent_data.init_time) + return; + + if (Input::IsKeyTapped(GLFW_KEY_K, GLFW_MOD_CONTROL)) + pv_game_ptr->end_pv = true; + else if (Input::IsKeyTapped(GLFW_KEY_K)) + pause ^= true; + + if (Input::IsKeyTapped(GLFW_KEY_L)) { + pause = true; + step_frame = true; + } + + if (!pause) + return; + + ImGuiIO& io = ImGui::GetIO(); + ImGuiStyle& style = ImGui::GetStyle(); + ImFont* font = ImGui::GetFont(); + + float_t w = 240.0f; + float_t h = 86.0f; + + extern int32_t width; + ImGui::SetNextWindowPos({ (float_t)width - w, 0.0f }, ImGuiCond_Always); + ImGui::SetNextWindowSize({ w, h }, ImGuiCond_Always); + + ImGuiWindowFlags window_flags = 0; + window_flags |= ImGuiWindowFlags_NoResize; + + bool collapsed = !ImGui::Begin("PV GAME", 0, window_flags); + if (collapsed) { + ImGui::End(); + return; + } + + w = ImGui::GetContentRegionAvailWidth(); + if (ImGui::BeginTable("buttons", 2)) { + ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, w * 0.5f); + + ImGui::TableNextColumn(); + w = ImGui::GetContentRegionAvailWidth(); + if (ImGui::ButtonEnterKeyPressed(pause || (!pause && step_frame) ? "Play (K)" : "Pause (K)", { w, 0.0f })) + pause ^= true; + + ImGui::TableNextColumn(); + w = ImGui::GetContentRegionAvailWidth(); + if (ImGui::ButtonEnterKeyPressed("Step Frame (L)", { w, 0.0f })) { + pause = true; + step_frame = true; + } + + ImGui::TableNextColumn(); + w = ImGui::GetContentRegionAvailWidth(); + if (ImGui::ButtonEnterKeyPressed("Stop (Ctrl+K)", { w, 0.0f })) + pv_game_ptr->end_pv = true; + + ImGui::TableNextColumn(); + w = ImGui::GetContentRegionAvailWidth(); + char buf[0x200]; + sprintf_s(buf, sizeof(buf), "%d/%d", + (int32_t)dsc_time_to_frame(pv_game_get()->data.current_time), + (int32_t)(pv_game_get()->data.current_time / 10000)); + ImGui::PushStyleColor(ImGuiCol_Button, { 0.0f, 0.0f, 0.0f, 0.0f }); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, { 0.0f, 0.0f, 0.0f, 0.0f }); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, { 0.0f, 0.0f, 0.0f, 0.0f }); + ImGui::ButtonExEnterKeyPressed(buf, { w, 0.0f }, ImGuiButtonFlags_DontClosePopups + | ImGuiButtonFlags_NoNavFocus | ImGuiButtonFlags_NoHoveredOnFocus); + ImGui::PopStyleColor(3); + ImGui::EndTable(); + } + + extern bool input_locked; + input_locked |= ImGui::IsWindowFocused(); + ImGui::End(); +} + +void TaskPvGame::Basic() { + if (pv_game_parent_data.pv_state != 1 || pv_game_parent_data.init_time) + return; + + if (step_frame) + if (pause) + pause = false; + else { + pause = true; + step_frame = false; + } + + if (pause && !is_paused) { + pv_game_time_pause(); + + extern float_t frame_speed; + frame_speed = 0.0f; + + is_paused = true; + } + + if (!pause && is_paused) { + pv_game_time_start(); + + extern float_t frame_speed; + frame_speed = 1.0f; + + is_paused = false; + } + + pv_game_music_get()->set_pause(pause ? 1 : 0); + Glitter::glt_particle_manager->SetPause(pause); +} +#endif + void TaskPvGame::Load(TaskPvGame::Data& data) { pv_game_init(); @@ -5536,18 +5662,19 @@ void task_pv_game_init_test_pv() { task_rob_manager_add_task(); TaskPvGame::Args args; - args.init_data.pv_id = 999; - args.init_data.difficulty = PV_DIFFICULTY_NORMAL; + args.init_data.pv_id = 705; + args.init_data.difficulty = PV_DIFFICULTY_HARD; args.init_data.edition = 0; args.init_data.score_percentage_clear = 50; args.init_data.life_gauge_safety_time = 40; args.init_data.life_gauge_border = 30; args.field_190 = false; - args.watch = false; + args.watch = true; args.no_fail = false; args.field_193 = true; args.field_194 = true; - args.mute = true; + args.mute = false; + args.success = true; args.test_pv = true; task_pv_game_add_task(args); } diff --git a/src/ReDIVA/pv_game/pv_game.hpp b/src/ReDIVA/pv_game/pv_game.hpp index c55926d0..432a5ab8 100644 --- a/src/ReDIVA/pv_game/pv_game.hpp +++ b/src/ReDIVA/pv_game/pv_game.hpp @@ -8,6 +8,7 @@ #include "../../CRE/auth_3d.hpp" #include "../../CRE/stage.hpp" #include "../../CRE/task.hpp" +#include "../config.hpp" #include "../task_window.hpp" #include "pv_game_pv_data.hpp" #include "pv_game_play_data.hpp" @@ -750,7 +751,11 @@ struct struc_717 { ~struc_717(); }; +#if PV_DEBUG +class TaskPvGame : public app::TaskWindow { +#else class TaskPvGame : public app::Task { +#endif public: struct Args { pv_game_init_data init_data; @@ -805,6 +810,12 @@ public: void Reset(); } data; +#if PV_DEBUG + bool pause; + bool step_frame; + bool is_paused; +#endif + TaskPvGame(); virtual ~TaskPvGame() override; @@ -812,6 +823,10 @@ public: virtual bool Ctrl() override; virtual bool Dest() override; virtual void Disp() override; +#if PV_DEBUG + virtual void Basic() override; + virtual void Window() override; +#endif void Load(TaskPvGame::Data& data); bool Unload(); diff --git a/src/ReDIVA/render.cpp b/src/ReDIVA/render.cpp index 945fd15c..f01e9aaf 100644 --- a/src/ReDIVA/render.cpp +++ b/src/ReDIVA/render.cpp @@ -155,7 +155,11 @@ int32_t height; static const double_t aspect = 16.0 / 9.0; +#if PV_DEBUG +static const int32_t fast_loader_speed = 0; +#else static const int32_t fast_loader_speed = 60; +#endif bool light_chara_ambient; vec4 npr_cloth_spec_color = 1.0f; diff --git a/src/ReDIVA/system_startup.cpp b/src/ReDIVA/system_startup.cpp index e1b5de08..23aeee78 100644 --- a/src/ReDIVA/system_startup.cpp +++ b/src/ReDIVA/system_startup.cpp @@ -8,6 +8,7 @@ #include "../CRE/mdata_manager.hpp" #include "../CRE/sprite.hpp" #include "pv_game/pv_game.hpp" +#include "config.hpp" #include "game_state.hpp" system_startup_detail::TaskSystemStartup* task_system_startup; @@ -59,7 +60,9 @@ namespace system_startup_detail { system_startup.state = 4; break; case 4: - //rctx_ptr->render_manager.set_pass_sw(rndr::RND_PASSID_ALL_3D, false); +#if !PV_DEBUG + rctx_ptr->render_manager.set_pass_sw(rndr::RND_PASSID_ALL_3D, false); +#endif task_pv_game_init_test_pv(); system_startup.state = 5; break; @@ -76,7 +79,9 @@ namespace system_startup_detail { system_startup.state = 8; break; case 8: - //rctx_ptr->render_manager.set_pass_sw(rndr::RND_PASSID_ALL_3D, true); +#if !PV_DEBUG + rctx_ptr->render_manager.set_pass_sw(rndr::RND_PASSID_ALL_3D, true); +#endif system_startup_ready = 1; break; } @@ -93,9 +98,11 @@ namespace system_startup_detail { } void TaskSystemStartup::Disp() { +#if !PV_DEBUG resolution_struct* res_wind = res_window_get(); spr::put_sprite_rect({ 0.0f, 0.0f, (float_t)res_wind->width, (float_t)res_wind->height }, res_wind->resolution_mode, spr::SPR_PRIO_25, color_black, 0); +#else } }