Skip to content

Commit

Permalink
Implemented DirectMenuPatch
Browse files Browse the repository at this point in the history
  • Loading branch information
florianessl committed May 24, 2024
1 parent 49bb208 commit eb8f075
Show file tree
Hide file tree
Showing 12 changed files with 221 additions and 33 deletions.
9 changes: 7 additions & 2 deletions resources/unix/easyrpg-player.6.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,21 @@ NOTE: For games that only use ASCII (English games) use '1252'.
Disable support for the Runtime Package (RTP). Will lead to checkerboard
graphics and silent music/sound effects in games depending on the RTP.

*--patch-anti-lag-switch*:: _SWITCH_
*--patch-antilag-switch*:: _SWITCH_
Disables event page refreshing when the switch 'SWITCH' is set to 'ON'.

*--patch-common-this*::
Enable usage of __This Event__ in common events in any version of the engine.
By default, this behaviour is only enabled for RPG Maker 2003 v1.12.

*--patch-direct-menu*:: _VAR_
Directly access subscreens of the default menu by setting VAR.
See also: https://dev.makerpendium.de/docs/patch_db/main-en.htm?page=direct_menu

*--patch-dynrpg*::
Enable limited support for the DynRPG patch from Cherry. The patches are not
loaded from DLL files, but re-implemented by the engine.
loaded from DLL files, but re-implemented by the engine. See also:
https://rpg-maker.cherrytree.at/dynrpg/getting_started.html

*--patch-easyrpg*::
Enable EasyRPG extensions such as support for 32 bit images and large charsets.
Expand Down
68 changes: 62 additions & 6 deletions src/game_config_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "game_config_game.h"
#include "cmdline_parser.h"
#include "directory_tree.h"
#include "filefinder.h"
#include "options.h"
#include "output.h"
Expand Down Expand Up @@ -85,7 +86,8 @@ void Game_ConfigGame::LoadFromArgs(CmdlineParser& cp) {
patch_common_this_event.Lock(false);
patch_key_patch.Lock(false);
patch_rpg2k3_commands.Lock(false);
patch_anti_lag_switch.Lock(false);
patch_anti_lag_switch.Lock(0);
patch_direct_menu.Lock(0);
patch_override = true;
continue;
}
Expand Down Expand Up @@ -129,16 +131,28 @@ void Game_ConfigGame::LoadFromArgs(CmdlineParser& cp) {
patch_override = true;
continue;
}
if (cp.ParseNext(arg, 1, "--patch-antilag-switch")) {
if (arg.ParseValue(0, li_value)) {
if (cp.ParseNext(arg, 1, {"--patch-antilag-switch", "--no-patch-antilag-switch"})) {
if (arg.ArgIsOn() && arg.ParseValue(0, li_value)) {
patch_anti_lag_switch.Set(li_value);
patch_override = true;
}

if (arg.ArgIsOff()) {
patch_anti_lag_switch.Set(0);
patch_override = true;
}
continue;
}
if (cp.ParseNext(arg, 0, "--no-patch-antilag-switch")) {
patch_anti_lag_switch.Set(0);
patch_override = true;
if (cp.ParseNext(arg, 1, {"--patch-direct-menu", "--no-patch-direct-menu"})) {
if (arg.ArgIsOn() && arg.ParseValue(0, li_value)) {
patch_direct_menu.Set(li_value);
patch_override = true;
}

if (arg.ArgIsOff()) {
patch_direct_menu.Set(0);
patch_override = true;
}
continue;
}
if (cp.ParseNext(arg, 6, "--patch")) {
Expand Down Expand Up @@ -211,4 +225,46 @@ void Game_ConfigGame::LoadFromStream(Filesystem_Stream::InputStream& is) {
if (patch_anti_lag_switch.FromIni(ini)) {
patch_override = true;
}

if (patch_direct_menu.FromIni(ini)) {
patch_override = true;
}
}

void Game_ConfigGame::PrintActivePatches() {
std::vector<std::string> patches;

auto add_bool = [&](auto& patch) {
if (patch.Get()) {
patches.push_back(ToString(patch.GetName()));
}
};

add_bool(patch_easyrpg);
add_bool(patch_dynrpg);
add_bool(patch_maniac);
add_bool(patch_common_this_event);
add_bool(patch_unlock_pics);
add_bool(patch_key_patch);
add_bool(patch_rpg2k3_commands);

auto add_int = [&](auto& patch) {
if (patch.Get() > 0) {
patches.push_back(fmt::format("{} ({})", patch.GetName(), patch.Get()));
}
};

add_int(patch_anti_lag_switch);
add_int(patch_direct_menu);

if (patches.empty()) {
Output::Debug("Patch configuration: None");
} else {
std::string out = "Patch configuration: ";
for (const auto& s: patches) {
out += s + " ";
}
out.pop_back();
Output::DebugStr(out);
}
}
4 changes: 4 additions & 0 deletions src/game_config_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct Game_ConfigGame {
BoolConfigParam patch_key_patch{ "Ineluki Key Patch", "Support \"Ineluki Key Patch\"", "Patch", "KeyPatch", false };
BoolConfigParam patch_rpg2k3_commands{ "RPG2k3 Event Commands", "Enable support for RPG2k3 event commands", "Patch", "RPG2k3Commands", false };
ConfigParam<int> patch_anti_lag_switch{ "Anti-Lag Switch", "Disable event page refreshes when switch is set", "Patch", "AntiLagSwitch", 0 };
ConfigParam<int> patch_direct_menu{ "Direct Menu", " Allows direct access to subscreens of the default menu", "Patch", "DirectMenu", 0 };

// Command line only
BoolConfigParam patch_support{ "Support patches", "When OFF all patch support is disabled", "", "", true };
Expand Down Expand Up @@ -75,6 +76,9 @@ struct Game_ConfigGame {
* @post values of this are updated with values found in command line args.
*/
void LoadFromArgs(CmdlineParser& cp);

/** Outputs a list of active patches */
void PrintActivePatches();
};

#endif
95 changes: 91 additions & 4 deletions src/game_interpreter_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <sstream>
#include <cassert>
#include "audio.h"
#include "feature.h"
#include "game_map.h"
#include "game_battle.h"
#include "game_event.h"
Expand All @@ -38,8 +39,13 @@
#include "sprite_character.h"
#include "scene_map.h"
#include "scene_battle.h"
#include "scene_equip.h"
#include "scene_item.h"
#include "scene_menu.h"
#include "scene_order.h"
#include "scene_save.h"
#include "scene_status.h"
#include "scene_skill.h"
#include "scene_load.h"
#include "scene_name.h"
#include "scene_shop.h"
Expand Down Expand Up @@ -83,6 +89,82 @@ void Game_Interpreter_Map::OnMapChange() {
}
}

bool Game_Interpreter_Map::RequestMainMenuScene(int subscreen_id, int actor_index, bool is_db_actor) {

if (Player::game_config.patch_direct_menu.Get() && subscreen_id == -1) {
subscreen_id = Main_Data::game_variables->Get(Player::game_config.patch_direct_menu.Get());
actor_index = Main_Data::game_variables->Get(Player::game_config.patch_direct_menu.Get() + 1);
is_db_actor = (actor_index < 0);
actor_index = std::abs(actor_index);
}

switch (subscreen_id)
{
case 1: // Inventory
Scene::instance->SetRequestedScene(std::make_shared<Scene_Item>());
return true;
case 2: // Skills
case 3: // Equipment
case 4: // Status
if (!is_db_actor) {
if (actor_index == 0 || actor_index > 4) {
actor_index = 1;
}
actor_index--;
}

if (is_db_actor && !Main_Data::game_actors->GetActor(actor_index)) {
Output::Warning("Invalid actor ID {}", actor_index);
return false;
}

if (subscreen_id == 2) {
Scene::instance->SetRequestedScene(std::make_shared<Scene_Skill>(actor_index, 0, is_db_actor));
}
else if (subscreen_id == 3) {
Game_Actor* actor;
if (!is_db_actor) {
actor = Main_Data::game_party->GetActors()[actor_index];
}
else {
actor = Main_Data::game_actors->GetActor(actor_index);
}
Scene::instance->SetRequestedScene(std::make_shared<Scene_Equip>(*actor));
}
else if (subscreen_id == 4) {
Scene::instance->SetRequestedScene(std::make_shared<Scene_Status>(actor_index, is_db_actor));
}
return true;
case 5: // Order
if (!Feature::HasRow()) {
break;
}

if (Main_Data::game_party->GetActors().size() <= 1) {
Output::Warning("Party size must exceed '1' for 'Order' subscreen to be opened");
return false;
}
else {
Scene::instance->SetRequestedScene(std::make_shared<Scene_Order>());
return true;
}
/*
case 6: // Settings
Scene::instance->SetRequestedScene(std::make_shared<Scene_Settings>());
return true;
case 7: // Language
Scene::instance->SetRequestedScene(std::make_shared<Scene_Language>());
return true;
case 8: // Debug
Scene::instance->SetRequestedScene(std::make_shared<Scene_Debug>());
return true;
*/
}

Scene::instance->SetRequestedScene(std::make_shared<Scene_Menu>());
return true;
}

/**
* Execute Command.
*/
Expand Down Expand Up @@ -638,17 +720,22 @@ bool Game_Interpreter_Map::CommandOpenSaveMenu(lcf::rpg::EventCommand const& /*
return false;
}

bool Game_Interpreter_Map::CommandOpenMainMenu(lcf::rpg::EventCommand const& /* com */) { // code 11950
bool Game_Interpreter_Map::CommandOpenMainMenu(lcf::rpg::EventCommand const& com) { // code 11950
auto& frame = GetFrame();
auto& index = frame.current_command;

if (Game_Message::IsMessageActive()) {
return false;
}

Scene::instance->SetRequestedScene(std::make_shared<Scene_Menu>());
++index;
return false;
int subscreen_id = -1, actor_index = 0;
bool is_db_actor = false;

if (RequestMainMenuScene(subscreen_id, actor_index, is_db_actor)) {
++index;
return false;
}
return true;
}

bool Game_Interpreter_Map::CommandOpenLoadMenu(lcf::rpg::EventCommand const& /* com */) {
Expand Down
2 changes: 2 additions & 0 deletions src/game_interpreter_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class Game_Interpreter_Map : public Game_Interpreter
*/
void OnMapChange();

bool RequestMainMenuScene(int subscreen_id = -1, int actor_index = 0, bool is_db_actor = false);

bool ExecuteCommand(lcf::rpg::EventCommand const& com) override;

private:
Expand Down
2 changes: 1 addition & 1 deletion src/game_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void Game_Player::UpdateNextMovementAction() {

ResetAnimation();
Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Decision));
Scene::instance->SetRequestedScene(std::make_shared<Scene_Menu>());
Game_Map::GetInterpreter().RequestMainMenuScene();
return;
}

Expand Down
9 changes: 5 additions & 4 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,9 +825,7 @@ void Player::CreateGameObjects() {
}
}

Output::Debug("Patch configuration: easyrpg={} dynrpg={} maniac={} key-patch={} common-this={} pic-unlock={} 2k3-commands={} anti-lag-switch={}",
Player::HasEasyRpgExtensions(), Player::IsPatchDynRpg(), Player::IsPatchManiac(), Player::IsPatchKeyPatch(), game_config.patch_common_this_event.Get(),
game_config.patch_unlock_pics.Get(), game_config.patch_rpg2k3_commands.Get(), game_config.patch_anti_lag_switch.Get());
game_config.PrintActivePatches();

ResetGameObjects();

Expand Down Expand Up @@ -1394,11 +1392,14 @@ Engine options:
--new-game Skip the title scene and start a new game directly.
--no-log-color Disable colors in terminal log.
--no-rtp Disable support for the Runtime Package (RTP).
--patch-anti-lag-switch SWITCH
--patch-antilag-switch SWITCH
Disables event page refreshing when the switch SWITCH is
enabled.
--patch-common-this Enable usage of "This Event" in common events in any
version of the engine.
--patch-direct-menu VAR
Directly access subscreens of the default menu by setting
VAR.
--patch-dynrpg Enable support of DynRPG patch by Cherry (very limited).
--patch-easyrpg Enable EasyRPG extensions.
--patch-key-patch Enable Key Patch by Ineluki.
Expand Down
12 changes: 8 additions & 4 deletions src/scene_equip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,17 @@ void Scene_Equip::UpdateEquipSelection() {
} else if (Main_Data::game_party->GetActors().size() > 1 && Input::IsTriggered(Input::RIGHT)) {
Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Cursor));
int actor_index = Main_Data::game_party->GetActorPositionInParty(actor.GetId());
actor_index = (actor_index + 1) % Main_Data::game_party->GetActors().size();
Scene::Push(std::make_shared<Scene_Equip>((*Main_Data::game_party)[actor_index], equip_window->GetIndex()), true);
if (actor_index != -1) {
actor_index = (actor_index + 1) % Main_Data::game_party->GetActors().size();
Scene::Push(std::make_shared<Scene_Equip>((*Main_Data::game_party)[actor_index], equip_window->GetIndex()), true);
}
} else if (Main_Data::game_party->GetActors().size() > 1 && Input::IsTriggered(Input::LEFT)) {
Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Cursor));
int actor_index = Main_Data::game_party->GetActorPositionInParty(actor.GetId());
actor_index = (actor_index + Main_Data::game_party->GetActors().size() - 1) % Main_Data::game_party->GetActors().size();
Scene::Push(std::make_shared<Scene_Equip>((*Main_Data::game_party)[actor_index], equip_window->GetIndex()), true);
if (actor_index != -1) {
actor_index = (actor_index + Main_Data::game_party->GetActors().size() - 1) % Main_Data::game_party->GetActors().size();
Scene::Push(std::make_shared<Scene_Equip>((*Main_Data::game_party)[actor_index], equip_window->GetIndex()), true);
}
}
}

Expand Down

0 comments on commit eb8f075

Please sign in to comment.