From deb9b6c146744a37b2963ac183f41ce3e6fcf44f Mon Sep 17 00:00:00 2001 From: MackValentine Date: Sat, 9 Nov 2024 11:26:06 +0100 Subject: [PATCH] Updates --- src/game_actor.cpp | 2 +- src/game_battlealgorithm.cpp | 7 ++- src/game_commonevent.cpp | 40 +++++++++----- src/game_commonevent.h | 9 +--- src/game_interpreter.cpp | 86 ++++++++++++++++++++++++++++++- src/game_interpreter.h | 3 +- src/game_interpreter_battle.cpp | 26 ---------- src/game_interpreter_battle.h | 1 - src/scene_battle.cpp | 20 ++++++- src/scene_battle_rpg2k3.cpp | 20 +++---- src/scene_item_custom.cpp | 12 ++--- src/scene_map.cpp | 4 +- src/scene_menu_custom.cpp | 12 ++--- src/window_base.cpp | 2 + src/window_battlestatusCustom.cpp | 4 +- src/window_battlestatusCustom.h | 2 +- src/window_command_custom.cpp | 4 +- src/window_command_custom.h | 2 +- src/window_custom.cpp | 4 +- src/window_custom.h | 2 +- src/window_item_custom.cpp | 4 +- src/window_item_custom.h | 2 +- src/window_menustatus_custom.cpp | 4 +- src/window_menustatus_custom.h | 2 +- src/window_skill.cpp | 2 +- 25 files changed, 182 insertions(+), 94 deletions(-) diff --git a/src/game_actor.cpp b/src/game_actor.cpp index 3c7a7cb9cc..30f207e0ba 100644 --- a/src/game_actor.cpp +++ b/src/game_actor.cpp @@ -255,7 +255,7 @@ bool Game_Actor::IsSkillUsable(int skill_id) const { else Game_Map::GetInterpreter().Push(common_event); - common_event->ForceCreate(eventID); + common_event->ForceCreateNoCheck(eventID); common_event->ForceUpdate(false); } diff --git a/src/game_battlealgorithm.cpp b/src/game_battlealgorithm.cpp index e7de867dd9..d6e3d56a9e 100644 --- a/src/game_battlealgorithm.cpp +++ b/src/game_battlealgorithm.cpp @@ -395,7 +395,7 @@ void Game_BattleAlgorithm::AlgorithmBase::Start() { } // Target Var - int size = std::distance(targets.begin(), targets.end()); + int size = 1; if (GetType() == Type::Normal) { size = 1; @@ -415,6 +415,11 @@ void Game_BattleAlgorithm::AlgorithmBase::Start() { } } + else if (GetType() == Type::Skill) { + // Fix for multiple targets + auto* skill = static_cast(this); + size = std::distance(skill->GetOriginalTargets().begin(), skill->GetOriginalTargets().end()); + } if (size > 1) { if (current_target[0]->GetType() != source->GetType()) { diff --git a/src/game_commonevent.cpp b/src/game_commonevent.cpp index 79f262a9c9..d60337ad36 100644 --- a/src/game_commonevent.cpp +++ b/src/game_commonevent.cpp @@ -40,18 +40,6 @@ Game_CommonEvent::Game_CommonEvent(int common_event_id) : } -void Game_CommonEvent::ForceCreate(int ce_ID) { - auto* ce = lcf::ReaderUtil::GetElement(lcf::Data::commonevents, ce_ID); - - if ((ce->trigger == lcf::rpg::EventPage::Trigger_parallel || ce->ID == ManiacsBattle::Get_ATBCE() || ce->ID == ManiacsBattle::Get_TargetCE() || - ce->ID == ManiacsBattle::Get_DamageCE() || ce->ID == ManiacsBattle::Get_StateCE() || ce->ID == ManiacsBattle::Get_StatsCE()) - && !ce->event_commands.empty()) - { - interpreter.reset(new Game_Interpreter_Map()); - interpreter->Push(this); - } -} - void Game_CommonEvent::SetSaveData(const lcf::rpg::SaveEventExecState& data) { // RPG_RT Savegames have empty stacks for parallel events. // We are LSD compatible but don't load these into interpreter. @@ -80,12 +68,36 @@ AsyncOp Game_CommonEvent::Update(bool resume_async) { void Game_CommonEvent::ForceCreate(int ce_ID) { auto* ce = lcf::ReaderUtil::GetElement(lcf::Data::commonevents, ce_ID); + if ((ce->trigger == lcf::rpg::EventPage::Trigger_parallel || ce->ID == ManiacsBattle::Get_ATBCE() || ce->ID == ManiacsBattle::Get_TargetCE() || + ce->ID == ManiacsBattle::Get_DamageCE() || ce->ID == ManiacsBattle::Get_StateCE() || ce->ID == ManiacsBattle::Get_StatsCE()) + && !ce->event_commands.empty()) { - if (!interpreter) - interpreter.reset(new Game_Interpreter_Map()); + interpreter.reset(new Game_Interpreter_Map()); + interpreter->Push(this); + } +} +void Game_CommonEvent::ForceCreateNoCheck(int ce_ID) { + auto* ce = lcf::ReaderUtil::GetElement(lcf::Data::commonevents, ce_ID); + + + { + interpreter.reset(new Game_Interpreter_Map()); interpreter->Push(this); } } +AsyncOp Game_CommonEvent::ForceUpdate(bool resume_async) { + if (interpreter) { + assert(interpreter->IsRunning()); + interpreter->Update(!resume_async); + + // Suspend due to async op ... + if (interpreter->IsAsyncPending()) { + return interpreter->GetAsyncOp(); + } + } + + return {}; +} AsyncOp Game_CommonEvent::UpdateBattle(bool resume_async, int ce_ID) { if (interpreter) { diff --git a/src/game_commonevent.h b/src/game_commonevent.h index 526672b163..100ecf7c09 100644 --- a/src/game_commonevent.h +++ b/src/game_commonevent.h @@ -64,6 +64,8 @@ class Game_CommonEvent { */ AsyncOp ForceUpdate(bool resume_async); void ForceCreate(int ce_ID); + + void ForceCreateNoCheck(int ce_ID); /** * Gets common event index. * @@ -117,13 +119,6 @@ class Game_CommonEvent { */ bool IsWaitingBackgroundExecution(bool force_run) const; - /** - * Force creation of Common Event - * - * @param ce_ID Common Event ID - */ - void ForceCreate(int ce_ID); - private: int common_event_id; diff --git a/src/game_interpreter.cpp b/src/game_interpreter.cpp index 4c515b3392..d21e1bb57a 100644 --- a/src/game_interpreter.cpp +++ b/src/game_interpreter.cpp @@ -840,6 +840,8 @@ bool Game_Interpreter::ExecuteCommand(lcf::rpg::EventCommand const& com) { return CommandShowStringPicSelectable(com); case 3029: return CommandManiacControlMessage(com); + case Cmd::EnableCombo: + return CommandEnableCombo(com); default: return true; } @@ -4158,6 +4160,10 @@ bool Game_Interpreter::CommandChangeClass(lcf::rpg::EventCommand const& com) { / } int class_id = com.parameters[2]; // 0: No class, 1+: Specific class + + int mode = 1; + class_id = ValueOrVariable(mode, com.parameters[2]); + bool level1 = com.parameters[3] > 0; int skill_mode = com.parameters[4]; // no change, replace, add int param_mode = com.parameters[5]; // no change, halve, level 1, current level @@ -5595,6 +5601,30 @@ bool Game_Interpreter::CommandShowStringPicSelectable(lcf::rpg::EventCommand con if (Main_Data::game_windows->GetWindow(picIndex).window->GetActive()) { Main_Data::game_windows->GetWindow(picIndex).window->Update(); + // *** Mouse controls + + Point mouse_pos = Input::GetMousePosition(); + int x = Main_Data::game_pictures->GetPicture(picIndex).sprite->GetX() - Main_Data::game_windows->GetWindow(picIndex).window->GetWidth() / 2; + int y = Main_Data::game_pictures->GetPicture(picIndex).sprite->GetY() - Main_Data::game_windows->GetWindow(picIndex).window->GetHeight() / 2; + + int index = Main_Data::game_windows->GetWindow(picIndex).window->CursorHitTest({ mouse_pos.x - x, mouse_pos.y - y }); + + if (index >= 0) + DisplayUi->ChangeCursor(1); + if (index >= 0 && index != Main_Data::game_windows->GetWindow(picIndex).window->GetIndex() && Input::MouseMoved()) { + // FIXME: Index changed callback? + Main_Data::game_windows->GetWindow(picIndex).window->SetIndex(index); + + Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Cursor)); + } + + if (index == -1 && Input::MouseMoved() && Main_Data::game_windows->GetWindow(picIndex).window->GetIndex() != -999) { + Main_Data::game_windows->GetWindow(picIndex).window->SetMouseOldIndex(Main_Data::game_windows->GetWindow(picIndex).window->GetIndex()); + Main_Data::game_windows->GetWindow(picIndex).window->SetIndex(-999); + } + + // *** + if (Input::IsTriggered(Input::CANCEL)) { Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Cancel)); int choice_result = Main_Data::game_windows->GetWindow(picIndex).window->GetPageItemMax(); @@ -5635,10 +5665,13 @@ bool Game_Interpreter::CommandShowStringPicSelectable(lcf::rpg::EventCommand con return true; } if (Input::IsTriggered(Input::DECISION)) { - Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Decision)); int choice_result = Main_Data::game_windows->GetWindow(picIndex).window->GetIndex(); //Output::Debug("CONFIRM {}", choice_result); + if (choice_result == -999) { + return false; + } + Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Decision)); int label_id = com.parameters[0]; @@ -5678,6 +5711,7 @@ bool Game_Interpreter::CommandShowStringPicSelectable(lcf::rpg::EventCommand con //Output::Debug("!Active"); Main_Data::game_windows->GetWindow(picIndex).window->SetIndex(0); Main_Data::game_windows->GetWindow(picIndex).window->SetActive(true); + auto text = Main_Data::game_windows->GetWindow(picIndex).data.texts; int maxItem = 0; for (const auto& text : text) { @@ -5696,6 +5730,29 @@ bool Game_Interpreter::CommandShowStringPicSelectable(lcf::rpg::EventCommand con else if (type == 2) { Main_Data::game_windows->GetWindow(picIndex).window->Update(); + // *** Mouse controls + + Point mouse_pos = Input::GetMousePosition(); + int x = Main_Data::game_pictures->GetPicture(picIndex).sprite->GetX() - Main_Data::game_windows->GetWindow(picIndex).window->GetWidth() / 2; + int y = Main_Data::game_pictures->GetPicture(picIndex).sprite->GetY() - Main_Data::game_windows->GetWindow(picIndex).window->GetHeight() / 2; + + int index = Main_Data::game_windows->GetWindow(picIndex).window->CursorHitTest({ mouse_pos.x - x, mouse_pos.y - y }); + if (index >= 0) + DisplayUi->ChangeCursor(1); + if (index >= 0 && index != Main_Data::game_windows->GetWindow(picIndex).window->GetIndex() && Input::MouseMoved()) { + // FIXME: Index changed callback? + Main_Data::game_windows->GetWindow(picIndex).window->SetIndex(index); + + Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Cursor)); + } + + if (index == -1 && Input::MouseMoved() && Main_Data::game_windows->GetWindow(picIndex).window->GetIndex() != -999) { + Main_Data::game_windows->GetWindow(picIndex).window->SetMouseOldIndex(Main_Data::game_windows->GetWindow(picIndex).window->GetIndex()); + Main_Data::game_windows->GetWindow(picIndex).window->SetIndex(-999); + } + + // *** + int variableID = ValueOrVariable(com.parameters[3], com.parameters[4]); int value = Main_Data::game_windows->GetWindow(picIndex).window->GetIndex(); Main_Data::game_variables->Set(variableID, value); @@ -5706,3 +5763,30 @@ bool Game_Interpreter::CommandShowStringPicSelectable(lcf::rpg::EventCommand con } return true; } + +bool Game_Interpreter::CommandEnableCombo(lcf::rpg::EventCommand const& com) { + if (!Player::IsRPG2k3Commands()) { + return true; + } + + + int actor_id = com.parameters[0]; + + if (!Main_Data::game_party->IsActorInParty(actor_id)) { + return true; + } + + int command_id = com.parameters[1]; + int multiple = com.parameters[2]; + + Game_Actor* actor = Main_Data::game_actors->GetActor(actor_id); + + if (!actor) { + Output::Warning("EnableCombo: Invalid actor ID {}", actor_id); + return true; + } + + actor->SetBattleCombo(command_id, multiple); + + return true; +} diff --git a/src/game_interpreter.h b/src/game_interpreter.h index 88ba60312d..7724ada31b 100644 --- a/src/game_interpreter.h +++ b/src/game_interpreter.h @@ -295,7 +295,8 @@ class Game_Interpreter bool CommandForceSelectingActor(lcf::rpg::EventCommand const& com); bool CommandShowStringPicSelectable(lcf::rpg::EventCommand const& com); bool CommandManiacControlMessage(lcf::rpg::EventCommand const& com); - + bool CommandEnableCombo(lcf::rpg::EventCommand const& com); + void tokenize(std::string const& str, const char delim, std::vector& out); void tokenizeRegex(std::string const& str, const char delim, std::vector& out); diff --git a/src/game_interpreter_battle.cpp b/src/game_interpreter_battle.cpp index 58a843ad3c..189189aa22 100644 --- a/src/game_interpreter_battle.cpp +++ b/src/game_interpreter_battle.cpp @@ -189,8 +189,6 @@ bool Game_Interpreter_Battle::ExecuteCommand(lcf::rpg::EventCommand const& com) return CommandCallCommonEvent(com); case Cmd::ForceFlee: return CommandForceFlee(com); - case Cmd::EnableCombo: - return CommandEnableCombo(com); case Cmd::ChangeMonsterHP: return CommandChangeMonsterHP(com); case Cmd::ChangeMonsterMP: @@ -297,31 +295,7 @@ bool Game_Interpreter_Battle::CommandForceFlee(lcf::rpg::EventCommand const& com return true; } -bool Game_Interpreter_Battle::CommandEnableCombo(lcf::rpg::EventCommand const& com) { - if (!Player::IsRPG2k3Commands()) { - return true; - } - - int actor_id = com.parameters[0]; - - if (!Main_Data::game_party->IsActorInParty(actor_id)) { - return true; - } - - int command_id = com.parameters[1]; - int multiple = com.parameters[2]; - Game_Actor* actor = Main_Data::game_actors->GetActor(actor_id); - - if (!actor) { - Output::Warning("EnableCombo: Invalid actor ID {}", actor_id); - return true; - } - - actor->SetBattleCombo(command_id, multiple); - - return true; -} bool Game_Interpreter_Battle::CommandChangeMonsterHP(lcf::rpg::EventCommand const& com) { auto* enemy = Main_Data::game_enemyparty->GetEnemy(com.parameters[0]); diff --git a/src/game_interpreter_battle.h b/src/game_interpreter_battle.h index 4b27a7ca20..8864ac0a19 100644 --- a/src/game_interpreter_battle.h +++ b/src/game_interpreter_battle.h @@ -66,7 +66,6 @@ class Game_Interpreter_Battle : public Game_Interpreter private: bool CommandCallCommonEvent(lcf::rpg::EventCommand const& com); bool CommandForceFlee(lcf::rpg::EventCommand const& com); - bool CommandEnableCombo(lcf::rpg::EventCommand const& com); bool CommandChangeMonsterHP(lcf::rpg::EventCommand const& com); bool CommandChangeMonsterMP(lcf::rpg::EventCommand const& com); bool CommandChangeMonsterCondition(lcf::rpg::EventCommand const& com); diff --git a/src/scene_battle.cpp b/src/scene_battle.cpp index 24f6c20a06..623fcfa5b2 100644 --- a/src/scene_battle.cpp +++ b/src/scene_battle.cpp @@ -291,13 +291,29 @@ void Scene_Battle::CreateUi() { } + win_name = "Help"; + it2 = CustomBattle::customWindows.find(win_name); + + if (it2 != CustomBattle::customWindows.end()) { + + help_window->SetX(CustomBattle::customWindows[win_name].x); + help_window->SetY(CustomBattle::customWindows[win_name].y); + help_window->SetWidth(CustomBattle::customWindows[win_name].w); + help_window->SetHeight(CustomBattle::customWindows[win_name].h); + help_window->SetOpacity(CustomBattle::customWindows[win_name].opacity); + help_window->SetBackOpacity(CustomBattle::customWindows[win_name].opacity); + + help_window->SetVisible(!CustomBattle::customWindows[win_name].hide); + + } + win_name = "Skills"; it2 = CustomBattle::customWindows.find(win_name); if (it2 != CustomBattle::customWindows.end()) { - skill_window.reset(new Window_BattleSkillCustom(Player::menu_offset_x, (Player::menu_offset_y + MENU_HEIGHT - 80), MENU_WIDTH, 80)); + skill_window.reset(new Window_BattleSkillCustom(this, Player::menu_offset_x, (Player::menu_offset_y + MENU_HEIGHT - 80), MENU_WIDTH, 80)); skill_window->SetX(CustomBattle::customWindows[win_name].x); skill_window->SetY(CustomBattle::customWindows[win_name].y); @@ -315,7 +331,7 @@ void Scene_Battle::CreateUi() { } else { - skill_window.reset(new Window_BattleSkill(Player::menu_offset_x, (Player::menu_offset_y + MENU_HEIGHT - 80), MENU_WIDTH, 80)); + skill_window.reset(new Window_BattleSkill(this, Player::menu_offset_x, (Player::menu_offset_y + MENU_HEIGHT - 80), MENU_WIDTH, 80)); skill_window->SetHelpWindow(help_window.get()); } diff --git a/src/scene_battle_rpg2k3.cpp b/src/scene_battle_rpg2k3.cpp index 1630f9ef81..a4c3ea9cba 100644 --- a/src/scene_battle_rpg2k3.cpp +++ b/src/scene_battle_rpg2k3.cpp @@ -651,9 +651,9 @@ void Scene_Battle_Rpg2k3::CreateBattleStatusWindow() { Window_BattleStatus* win; if (CustomBattle::customWindows["Status"].stats.size() > 0) - win = new Window_BattleStatusCustom(x, y, w, h); + win = new Window_BattleStatusCustom(this, x, y, w, h); else - win = new Window_BattleStatus(x, y, w, h); + win = new Window_BattleStatus(this, x, y, w, h); win->SetOpacity(CustomBattle::customWindows[win_name].opacity); win->SetBackOpacity(CustomBattle::customWindows[win_name].opacity); @@ -667,7 +667,7 @@ void Scene_Battle_Rpg2k3::CreateBattleStatusWindow() { status_window.reset(win); } else { - status_window.reset(new Window_BattleStatus(x, y, w, h)); + status_window.reset(new Window_BattleStatus(this, x, y, w, h)); } status_window->SetZ(Priority_Window + 1); } @@ -710,14 +710,14 @@ void Scene_Battle_Rpg2k3::CreateBattleCommandWindow() { auto it2 = CustomBattle::customWindows.find(win_name); if (it2 != CustomBattle::customWindows.end()) { - command_window.reset(new Window_Command_Custom(std::move(commands), option_command_mov, CustomBattle::customWindows[win_name].column)); + command_window.reset(new Window_Command_Custom(this, std::move(commands), option_command_mov, CustomBattle::customWindows[win_name].column)); } else { - command_window.reset(new Window_Command(std::move(commands), option_command_mov)); + command_window.reset(new Window_Command(this, std::move(commands), option_command_mov)); } } else { - command_window.reset(new Window_Command(std::move(commands), option_command_mov)); + command_window.reset(new Window_Command(this, std::move(commands), option_command_mov)); } SetBattleCommandsDisable(*command_window, actor); @@ -1378,7 +1378,7 @@ Scene_Battle_Rpg2k3::SceneActionReturn Scene_Battle_Rpg2k3::ProcessSceneActionAc status_window->SetVisible(true); command_window->SetIndex(-1); - if (lcf::Data::battlecommands.battle_type == lcf::rpg::BattleCommands::BattleType_traditional) { + if (lcf::Data::battlecommands.battle_type == lcf::rpg::BattleCommands::BattleType_traditional || ManiacsBattle::GetForceSelectingActor()) { status_window->SetChoiceMode(Window_BattleStatus::ChoiceMode_None); target_window->SetVisible(true); @@ -1448,7 +1448,7 @@ Scene_Battle_Rpg2k3::SceneActionReturn Scene_Battle_Rpg2k3::ProcessSceneActionAc } if (scene_action_substate == eWaitActor) { - if (lcf::Data::battlecommands.battle_type == lcf::rpg::BattleCommands::BattleType_traditional) { + if (lcf::Data::battlecommands.battle_type == lcf::rpg::BattleCommands::BattleType_traditional || ManiacsBattle::GetForceSelectingActor()) { UpdateReadyActors(); SetActiveActor(GetNextReadyActor()); } @@ -1906,8 +1906,8 @@ Scene_Battle_Rpg2k3::SceneActionReturn Scene_Battle_Rpg2k3::ProcessSceneActionAl if (Input::GetUseMouseButton()) { - bool actorHover = status_window->UpdateMouse(false); - + //bool actorHover = status_window->UpdateMouse(false); + bool actorHover = false; if (!actorHover) { Point mouseP = Input::GetMousePosition(); if (!(mouseP.x >= status_window->GetX() + status_window->GetBorderX() && mouseP.x < status_window->GetX() + status_window->GetBorderX() + status_window->GetWidth() && diff --git a/src/scene_item_custom.cpp b/src/scene_item_custom.cpp index 3a6f39b68d..040f41564b 100644 --- a/src/scene_item_custom.cpp +++ b/src/scene_item_custom.cpp @@ -73,10 +73,10 @@ void Scene_Item_Custom::Start() { y = CustomItem::customWindows[win_name].y; w = CustomItem::customWindows[win_name].w; - help_window.reset(new Window_Help(x, y, w, menu_help_height)); + help_window.reset(new Window_Help(this, x, y, w, menu_help_height)); } else { - help_window.reset(new Window_Help(Player::menu_offset_x, Player::menu_offset_y, MENU_WIDTH, menu_help_height)); + help_window.reset(new Window_Help(this, Player::menu_offset_x, Player::menu_offset_y, MENU_WIDTH, menu_help_height)); } win_name = "Items"; @@ -93,14 +93,14 @@ void Scene_Item_Custom::Start() { w = CustomItem::customWindows[win_name].w; h = CustomItem::customWindows[win_name].h; - item_window.reset(new Window_Item_Custom(x,y,w,h)); + item_window.reset(new Window_Item_Custom(this, x,y,w,h)); item_window->SetHelpWindow(help_window.get()); item_window->SetColumnMax(CustomItem::customWindows[win_name].column); item_window->Refresh(); item_window->SetIndex(item_index); } else { - item_window.reset(new Window_Item(Player::menu_offset_x, Player::menu_offset_y + menu_help_height, MENU_WIDTH, MENU_HEIGHT - menu_help_height)); + item_window.reset(new Window_Item(this, Player::menu_offset_x, Player::menu_offset_y + menu_help_height, MENU_WIDTH, MENU_HEIGHT - menu_help_height)); item_window->SetHelpWindow(help_window.get()); item_window->Refresh(); item_window->SetIndex(item_index); @@ -178,7 +178,7 @@ void Scene_Item_Custom::Start() { if (options.size() == 0) options.push_back("All"); - pocket_window.reset(new Window_Command_Custom(options, w, CustomItem::customWindows[win_name].column)); + pocket_window.reset(new Window_Command_Custom(this, options, w, CustomItem::customWindows[win_name].column)); pocket_window->SetX(x); pocket_window->SetY(y); pocket_window->SetHeight(h); @@ -233,7 +233,7 @@ void Scene_Item_Custom::vUpdate() { Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Cancel)); Scene::Pop(); } - else if (Input::IsTriggered(Input::DECISION)) { + else if (Input::IsTriggered(Input::DECISION) && pocket_window->GetIndex() >= 0) { Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Decision)); pocket_window->SetActive(false); item_window->SetActive(true); diff --git a/src/scene_map.cpp b/src/scene_map.cpp index beca3afe59..370669dac4 100644 --- a/src/scene_map.cpp +++ b/src/scene_map.cpp @@ -80,7 +80,7 @@ void Scene_Map::Start() { int y = Player::screen_height - h; - message_window.reset(new Window_Message(Player::message_box_offset_x, y, w, h)); + message_window.reset(new Window_Message(this, Player::message_box_offset_x, y, w, h)); Game_Message::SetWindow(message_window.get()); @@ -537,7 +537,7 @@ int* Scene_Map::GetWindowMessage(){ } void Scene_Map::Reset_MessageWindow(int x, int y, int w, int h) { - message_window.reset(new Window_Message(x, y, w, h)); + message_window.reset(new Window_Message(this, x, y, w, h)); Game_Message::SetWindow(message_window.get()); } diff --git a/src/scene_menu_custom.cpp b/src/scene_menu_custom.cpp index 1fb532c017..c3d300053a 100644 --- a/src/scene_menu_custom.cpp +++ b/src/scene_menu_custom.cpp @@ -86,7 +86,7 @@ void Scene_Menu_Custom::Start() { // Gold Window - gold_window.reset(new Window_Gold(Player::menu_offset_x, (Player::screen_height - gold_window_height - Player::menu_offset_y), gold_window_width, gold_window_height)); + gold_window.reset(new Window_Gold(this, Player::menu_offset_x, (Player::screen_height - gold_window_height - Player::menu_offset_y), gold_window_width, gold_window_height)); std::string win_name = "Gold"; auto it2 = CustomMenu::customWindows.find(win_name); @@ -110,7 +110,7 @@ void Scene_Menu_Custom::Start() { // Status Window int h = CustomMenu::customWindows[win_name].itemHeight * (Main_Data::game_party->GetBattlerCount() + 1) / CustomMenu::customWindows[win_name].column; - menustatus_window.reset(new Window_MenuStatus_Custom(Player::menu_offset_x + menu_command_width, Player::menu_offset_y, CustomMenu::customWindows[win_name].w, h)); + menustatus_window.reset(new Window_MenuStatus_Custom(this, Player::menu_offset_x + menu_command_width, Player::menu_offset_y, CustomMenu::customWindows[win_name].w, h)); menustatus_window->SetActive(false); menustatus_window->SetX(CustomMenu::customWindows[win_name].x); @@ -131,7 +131,7 @@ void Scene_Menu_Custom::Start() { } else { // Status Window - menustatus_window.reset(new Window_MenuStatus_Custom(Player::menu_offset_x + menu_command_width, Player::menu_offset_y, (MENU_WIDTH - menu_command_width), MENU_HEIGHT)); + menustatus_window.reset(new Window_MenuStatus_Custom(this, Player::menu_offset_x + menu_command_width, Player::menu_offset_y, (MENU_WIDTH - menu_command_width), MENU_HEIGHT)); menustatus_window->SetMenuItemHeight(58); menustatus_window->SetActive(false); menustatus_window->Refresh(); @@ -197,7 +197,7 @@ void Scene_Menu_Custom::CreateCustomWindows() { for (auto p : CustomMenu::customWindows) { if (!in_array(p.first, basic)) { auto w = p.second; - Window_Custom* win = new Window_Custom(w.x, w.y, w.w, w.h, w.name); + Window_Custom* win = new Window_Custom(this, w.x, w.y, w.w, w.h, w.name); win->SetVisible(!w.hide); win->SetOpacity(w.opacity); win->SetBackOpacity(w.opacity); @@ -353,7 +353,7 @@ void Scene_Menu_Custom::CreateCommandWindow() { auto it2 = CustomMenu::customWindows.find(win_name); if (it2 != CustomMenu::customWindows.end()) { - command_window.reset(new Window_Command_Custom(options, CustomMenu::customWindows[win_name].w, CustomMenu::customWindows[win_name].column)); + command_window.reset(new Window_Command_Custom(this, options, CustomMenu::customWindows[win_name].w, CustomMenu::customWindows[win_name].column)); command_window->SetIndex(menu_index); command_window->SetX(CustomMenu::customWindows[win_name].x); @@ -363,7 +363,7 @@ void Scene_Menu_Custom::CreateCommandWindow() { command_window->SetVisible(!CustomMenu::customWindows[win_name].hide); } else { - command_window.reset(new Window_Command(options, menu_command_width)); + command_window.reset(new Window_Command(this, options, menu_command_width)); command_window->SetX(Player::menu_offset_x); command_window->SetY(Player::menu_offset_y); command_window->SetIndex(menu_index); diff --git a/src/window_base.cpp b/src/window_base.cpp index 5f7a1526c0..89139d5cbf 100644 --- a/src/window_base.cpp +++ b/src/window_base.cpp @@ -351,6 +351,8 @@ void Window_Base::DrawCustomGauge(const Game_Battler& actor, int type, int act, } bool full = act == max; + if (max == 0) + max = 1; // Which gauge (0 - 2) int gauge_y = 32 + type * 16; diff --git a/src/window_battlestatusCustom.cpp b/src/window_battlestatusCustom.cpp index d5f7c2bdbb..752c9d2023 100644 --- a/src/window_battlestatusCustom.cpp +++ b/src/window_battlestatusCustom.cpp @@ -34,8 +34,8 @@ #include "scene_battle.h" #include "game_strings.h" -Window_BattleStatusCustom::Window_BattleStatusCustom(int ix, int iy, int iwidth, int iheight, bool enemy) : - Window_BattleStatus(ix, iy, iwidth, iheight, enemy) { +Window_BattleStatusCustom::Window_BattleStatusCustom(Scene* parent, int ix, int iy, int iwidth, int iheight, bool enemy) : + Window_BattleStatus(parent, ix, iy, iwidth, iheight, enemy) { SetBorderX(4); diff --git a/src/window_battlestatusCustom.h b/src/window_battlestatusCustom.h index cc9f8542be..20cff84c4e 100644 --- a/src/window_battlestatusCustom.h +++ b/src/window_battlestatusCustom.h @@ -31,7 +31,7 @@ class Window_BattleStatusCustom : public Window_BattleStatus { /** * Constructor. */ - Window_BattleStatusCustom(int ix, int iy, int iwidth, int iheight, bool enemy = false); + Window_BattleStatusCustom(Scene* parent, int ix, int iy, int iwidth, int iheight, bool enemy = false); /** * Renders the current status on the window. diff --git a/src/window_command_custom.cpp b/src/window_command_custom.cpp index 46dbf4852b..e12d312fd8 100644 --- a/src/window_command_custom.cpp +++ b/src/window_command_custom.cpp @@ -32,8 +32,8 @@ static int CalculateWidth(const std::vector& commands, int width) { return width; } -Window_Command_Custom::Window_Command_Custom(std::vector in_commands, int width, int c) : - Window_Command(in_commands, -1) +Window_Command_Custom::Window_Command_Custom(Scene* parent, std::vector in_commands, int width, int c) : + Window_Command(parent, in_commands, -1) { col_max = c; SetWidth(CalculateWidth(in_commands, width)); diff --git a/src/window_command_custom.h b/src/window_command_custom.h index c101d492c8..6f8bff0991 100644 --- a/src/window_command_custom.h +++ b/src/window_command_custom.h @@ -35,7 +35,7 @@ class Window_Command_Custom : public Window_Command { * @param width window width, if no width is passed * the width is autocalculated. */ - Window_Command_Custom(std::vector commands, int width = -1, int c = 1); + Window_Command_Custom(Scene* parent, std::vector commands, int width = -1, int c = 1); /** * Replace all commands with a new command set. diff --git a/src/window_custom.cpp b/src/window_custom.cpp index 33e8f8091e..73bee29ce9 100644 --- a/src/window_custom.cpp +++ b/src/window_custom.cpp @@ -26,8 +26,8 @@ #include -Window_Custom::Window_Custom(int ix, int iy, int iwidth, int iheight, std::string t) : - Window_Base(ix, iy, iwidth, iheight) { +Window_Custom::Window_Custom(Scene* parent, int ix, int iy, int iwidth, int iheight, std::string t) : + Window_Base(parent, ix, iy, iwidth, iheight) { name = t; SetContents(Bitmap::Create(width - 16, height - 16)); diff --git a/src/window_custom.h b/src/window_custom.h index 9f85cabf27..3d2474dcb8 100644 --- a/src/window_custom.h +++ b/src/window_custom.h @@ -30,7 +30,7 @@ class Window_Custom : public Window_Base { /** * Constructor. */ - Window_Custom(int ix, int iy, int iwidth, int iheight, std::string t); + Window_Custom(Scene* parent, int ix, int iy, int iwidth, int iheight, std::string t); std::string name; diff --git a/src/window_item_custom.cpp b/src/window_item_custom.cpp index d18f9d7633..27ce8dcd90 100644 --- a/src/window_item_custom.cpp +++ b/src/window_item_custom.cpp @@ -26,8 +26,8 @@ #include "game_battle.h" #include "output.h" -Window_Item_Custom::Window_Item_Custom(int ix, int iy, int iwidth, int iheight) : - Window_Item(ix, iy, iwidth, iheight) { +Window_Item_Custom::Window_Item_Custom(Scene* parent, int ix, int iy, int iwidth, int iheight) : + Window_Item(parent, ix, iy, iwidth, iheight) { column_max = 2; } diff --git a/src/window_item_custom.h b/src/window_item_custom.h index b728064c58..4f3ed6379b 100644 --- a/src/window_item_custom.h +++ b/src/window_item_custom.h @@ -32,7 +32,7 @@ class Window_Item_Custom : public Window_Item { /** * Constructor. */ - Window_Item_Custom(int ix, int iy, int iwidth, int iheight); + Window_Item_Custom(Scene* parent, int ix, int iy, int iwidth, int iheight); void Refresh() override; diff --git a/src/window_menustatus_custom.cpp b/src/window_menustatus_custom.cpp index 989a220a6e..31b1c9ef6c 100644 --- a/src/window_menustatus_custom.cpp +++ b/src/window_menustatus_custom.cpp @@ -25,8 +25,8 @@ #include "scene_menu_custom.h" #include "game_strings.h" -Window_MenuStatus_Custom::Window_MenuStatus_Custom(int ix, int iy, int iwidth, int iheight) : - Window_MenuStatus(ix, iy, iwidth, iheight) { +Window_MenuStatus_Custom::Window_MenuStatus_Custom(Scene* parent, int ix, int iy, int iwidth, int iheight) : + Window_MenuStatus(parent, ix, iy, iwidth, iheight) { if (Player::IsRPG2k3()) { SetContents(Bitmap::Create(width - 12, height - 16)); diff --git a/src/window_menustatus_custom.h b/src/window_menustatus_custom.h index 73bb2a189d..49e6d8af0f 100644 --- a/src/window_menustatus_custom.h +++ b/src/window_menustatus_custom.h @@ -28,7 +28,7 @@ */ class Window_MenuStatus_Custom : public Window_MenuStatus { public: - Window_MenuStatus_Custom(int ix, int iy, int iwidth, int iheight); + Window_MenuStatus_Custom(Scene* parent, int ix, int iy, int iwidth, int iheight); void Refresh(); void UpdateCursorRect() override; diff --git a/src/window_skill.cpp b/src/window_skill.cpp index 1845f0fcac..01ac8eeffd 100644 --- a/src/window_skill.cpp +++ b/src/window_skill.cpp @@ -172,7 +172,7 @@ void Window_BattleSkillCustom::DrawItem(int index) { Game_Battle::GetInterpreter().Push(common_event); - common_event->ForceCreate(eventID); + common_event->ForceCreateNoCheck(eventID); common_event->ForceUpdate(false); std::string str_VarId = std::to_string(stringVarID);