From 87f20508cab5fb66b46b258b8f9b6a76ea6eaf63 Mon Sep 17 00:00:00 2001 From: Mauro Junior <45118493+jetrotal@users.noreply.github.com> Date: Thu, 25 Jul 2024 07:49:59 -0300 Subject: [PATCH 1/3] Maniacs Patch - Call System Functions In Maniacs, CommandOpenSaveMenu is renamed to "Call System Function". I implemented what is closer to our code. Also expanded the code to cover our custom submenus (Cases 8 to 12). Update game_interpreter_map.cpp --- src/game_interpreter_map.cpp | 53 +++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/src/game_interpreter_map.cpp b/src/game_interpreter_map.cpp index 8cdaa8cdc0..bb889e7f92 100644 --- a/src/game_interpreter_map.cpp +++ b/src/game_interpreter_map.cpp @@ -49,6 +49,7 @@ #include "scene_load.h" #include "scene_name.h" #include "scene_shop.h" +#include "scene_debug.h" #include "scene_gameover.h" #include "scene.h" #include "graphics.h" @@ -716,7 +717,7 @@ bool Game_Interpreter_Map::CommandPlayMovie(lcf::rpg::EventCommand const& com) { return true; } -bool Game_Interpreter_Map::CommandOpenSaveMenu(lcf::rpg::EventCommand const& /* com */) { // code 11910 +bool Game_Interpreter_Map::CommandOpenSaveMenu(lcf::rpg::EventCommand const& com) { // code 11910 if (Game_Message::IsMessageActive()) { return false; } @@ -725,6 +726,56 @@ bool Game_Interpreter_Map::CommandOpenSaveMenu(lcf::rpg::EventCommand const& /* auto& index = frame.current_command; Scene::instance->SetRequestedScene(std::make_shared()); + + const int current_system_function = com.parameters[0]; + + // Handle save menu (default behavior) + if (!Player::IsPatchManiac() || current_system_function <= 0) { + Scene::instance->SetRequestedScene(std::make_shared()); + ++index; + return false; + } + + // Parse common parameters + const int fullscreen_mode = com.parameters[1]; // Broken in Maniac. + const int pause_while_debugging = com.parameters[1]; // unused in our ingame debug screen. + + const int actor_index = ValueOrVariable(com.parameters[1], com.parameters[2]); + const bool is_db_actor = ValueOrVariable(com.parameters[3], com.parameters[4]); + + switch (current_system_function) { + case 1: // Load menu + return CommandOpenLoadMenu(com); + case 2: // Game menu + Scene::instance->SetRequestedScene(std::make_shared()); + break; + case 3: // Toggle fullscreen + // TODO? Implement fullscreen mode once maniacs supports it + return CommandToggleFullscreen(com); + case 4: // Settings menu + return CommandOpenVideoOptions(com); + case 5: // Debug menu + Scene::instance->SetRequestedScene(std::make_shared()); + break; + case 6: // License information menu + // TODO? Implement license information menu + return true; + case 7: // Reset game + return CommandReturnToTitleScreen(com); + case 8: // EASYRPG Inventory menu + return RequestMainMenuScene(1); + case 9: // EASYRPG Skills menu + return RequestMainMenuScene(2, actor_index, is_db_actor); + case 10: // EASYRPG Equip menu + return RequestMainMenuScene(3, actor_index, is_db_actor); + case 11: // EASYRPG Status menu + return RequestMainMenuScene(4, actor_index, is_db_actor); + case 12: // EASYRPG Reorder Party menu + return RequestMainMenuScene(5); + default: + return true; + } + ++index; return false; } From fc4568ace275532d45ad89965e7f0ce109d5387d Mon Sep 17 00:00:00 2001 From: Ghabry Date: Thu, 1 Aug 2024 19:39:16 +0200 Subject: [PATCH 2/3] Call System Functions: Move EasyRPG Extensions to a higher ID to prevent conflicts Minor enhancements --- src/game_interpreter.cpp | 2 +- src/game_interpreter_map.cpp | 45 ++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/game_interpreter.cpp b/src/game_interpreter.cpp index 1779e5c7d6..5166370616 100644 --- a/src/game_interpreter.cpp +++ b/src/game_interpreter.cpp @@ -785,7 +785,7 @@ bool Game_Interpreter::ExecuteCommand(lcf::rpg::EventCommand const& com) { return CommandManiacControlStrings(com); case Cmd::Maniac_CallCommand: return CommandManiacCallCommand(com); - case Cmd::EasyRpg_SetInterpreterFlag: //Cmd::EasyRpg_SetInterpreterFlag + case Cmd::EasyRpg_SetInterpreterFlag: return CommandEasyRpgSetInterpreterFlag(com); default: return true; diff --git a/src/game_interpreter_map.cpp b/src/game_interpreter_map.cpp index bb889e7f92..37269f0b66 100644 --- a/src/game_interpreter_map.cpp +++ b/src/game_interpreter_map.cpp @@ -736,48 +736,43 @@ bool Game_Interpreter_Map::CommandOpenSaveMenu(lcf::rpg::EventCommand const& com return false; } - // Parse common parameters - const int fullscreen_mode = com.parameters[1]; // Broken in Maniac. - const int pause_while_debugging = com.parameters[1]; // unused in our ingame debug screen. - - const int actor_index = ValueOrVariable(com.parameters[1], com.parameters[2]); - const bool is_db_actor = ValueOrVariable(com.parameters[3], com.parameters[4]); - + // Command "Call System Functions" switch (current_system_function) { case 1: // Load menu return CommandOpenLoadMenu(com); case 2: // Game menu - Scene::instance->SetRequestedScene(std::make_shared()); - break; + return CommandOpenMainMenu(com); case 3: // Toggle fullscreen - // TODO? Implement fullscreen mode once maniacs supports it + // TODO Implement fullscreen mode once maniacs supports it + // const int fullscreen_mode = com.parameters[1]; // Broken in Maniac. return CommandToggleFullscreen(com); case 4: // Settings menu return CommandOpenVideoOptions(com); case 5: // Debug menu + // const int pause_while_debugging = com.parameters[1]; // unused in our ingame debug screen. Scene::instance->SetRequestedScene(std::make_shared()); - break; + ++index; + return false; case 6: // License information menu - // TODO? Implement license information menu + // TODO Implement license information menu return true; case 7: // Reset game return CommandReturnToTitleScreen(com); - case 8: // EASYRPG Inventory menu - return RequestMainMenuScene(1); - case 9: // EASYRPG Skills menu - return RequestMainMenuScene(2, actor_index, is_db_actor); - case 10: // EASYRPG Equip menu - return RequestMainMenuScene(3, actor_index, is_db_actor); - case 11: // EASYRPG Status menu - return RequestMainMenuScene(4, actor_index, is_db_actor); - case 12: // EASYRPG Reorder Party menu - return RequestMainMenuScene(5); default: - return true; + if (Player::HasEasyRpgExtensions() && current_system_function >= 200 && current_system_function < 210) { + const int actor_index = ValueOrVariable(com.parameters[1], com.parameters[2]); + const bool is_db_actor = ValueOrVariable(com.parameters[3], com.parameters[4]); + + if (RequestMainMenuScene(current_system_function - 200, actor_index, is_db_actor)) { + ++index; + return false; + } + } else { + Output::Warning("CommandOpenSaveMenu: Unsupported scene {}", current_system_function); + } } - ++index; - return false; + return true; } bool Game_Interpreter_Map::CommandOpenMainMenu(lcf::rpg::EventCommand const&) { // code 11950 From a2080c76babaeda95b9dda5f02f2b81e3f452015 Mon Sep 17 00:00:00 2001 From: Ghabry Date: Mon, 2 Sep 2024 20:50:48 +0200 Subject: [PATCH 3/3] Switch: Fix build (Add missing return value) --- src/platform/switch/ui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/switch/ui.cpp b/src/platform/switch/ui.cpp index 1ef3f28bd0..957dba60d8 100644 --- a/src/platform/switch/ui.cpp +++ b/src/platform/switch/ui.cpp @@ -439,7 +439,7 @@ bool NxUi::ProcessEvents() { // do not handle touch when not displaying buttons or no touch happened if (is_docked || vcfg.touch_ui.IsLocked() || !vcfg.touch_ui.Get() || !hidGetTouchScreenStates(&touch, 1)) - return; + return true; for (int32_t i = 0; i < touch.count; ++i) { if (touch.touches[i].x < 160) {