Skip to content

Commit

Permalink
Battle 2k: Fit the windows better in widescreen mode
Browse files Browse the repository at this point in the history
Not implemented for Battle 2k3 yet because the Ui is much more complicated.
  • Loading branch information
Ghabry committed Jul 25, 2023
1 parent e6ef466 commit 4d3b2d2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/scene_battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ struct BattleArgs {

constexpr int option_command_mov = 76;
constexpr int option_command_time = 8;
// size of options_window, command window and status window
constexpr int battle_menu_offset_x = MENU_WIDTH + option_command_mov;

/**
* Scene_Battle class.
Expand Down
19 changes: 14 additions & 5 deletions src/scene_battle_rpg2k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void Scene_Battle_Rpg2k::CreateUi() {
}
}

SetCommandWindows(Player::menu_offset_x);
SetCommandWindowsX();

ResetWindows(true);
battle_message_window->SetVisible(true);
Expand Down Expand Up @@ -136,9 +136,8 @@ void Scene_Battle_Rpg2k::CreateBattleCommandWindow() {
ToString(lcf::Data::terms.command_item)
};

command_window.reset(new Window_Command(std::move(commands), 76));
command_window.reset(new Window_Command(std::move(commands), option_command_mov));
command_window->SetHeight(80);
command_window->SetX(Player::screen_width - Player::menu_offset_x - option_command_mov);
command_window->SetY(Player::screen_height - Player::menu_offset_y - 80);
}

Expand Down Expand Up @@ -395,7 +394,12 @@ void Scene_Battle_Rpg2k::ResetWindows(bool make_invisible) {
help_window->SetVisible(false);
}

void Scene_Battle_Rpg2k::SetCommandWindows(int x) {
void Scene_Battle_Rpg2k::SetCommandWindowsX() {
int x = Player::menu_offset_x;
if (Player::screen_width >= battle_menu_offset_x) {
x = std::max<int>((Player::screen_width - battle_menu_offset_x) / 2, 0);
}

options_window->SetX(x);
x += options_window->GetWidth();
status_window->SetX(x);
Expand All @@ -404,6 +408,11 @@ void Scene_Battle_Rpg2k::SetCommandWindows(int x) {
}

void Scene_Battle_Rpg2k::MoveCommandWindows(int x, int frames) {
if (Player::screen_width >= battle_menu_offset_x) {
// Do not animate as they fit on the screen in widescreen mode
return;
}

options_window->InitMovement(options_window->GetX(), options_window->GetY(),
x, options_window->GetY(), frames);

Expand Down Expand Up @@ -457,7 +466,7 @@ Scene_Battle_Rpg2k::SceneActionReturn Scene_Battle_Rpg2k::ProcessSceneActionFigh
if (previous_state == State_SelectCommand) {
MoveCommandWindows(Player::menu_offset_x, 8);
} else {
SetCommandWindows(Player::menu_offset_x);
SetCommandWindowsX();
}
SetSceneActionSubState(eWaitForInput);
// Prevent that DECISION from a closed message triggers a battle option in eWaitForInput
Expand Down
3 changes: 1 addition & 2 deletions src/scene_battle_rpg2k.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,9 @@ class Scene_Battle_Rpg2k : public Scene_Battle {
void RefreshTargetWindow();

bool CheckBattleEndConditions();
bool RefreshEventsAndCheckBattleEnd();

void ResetWindows(bool make_invisible);
void SetCommandWindows(int x);
void SetCommandWindowsX();
void MoveCommandWindows(int x, int frames);
void RefreshCommandWindow();

Expand Down

0 comments on commit 4d3b2d2

Please sign in to comment.