Skip to content

Commit

Permalink
add horizontal ally/enemy selection feature for 2k3 battle system
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghabry committed Sep 20, 2023
1 parent ac9cddf commit 16217f0
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
3 changes: 0 additions & 3 deletions src/feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,3 @@ bool Feature::HasFixedEnemyFacingDirection() {
return HasRpg2k3BattleSystem() && lcf::Data::battlecommands.easyrpg_fixed_enemy_facing_direction > 0;
}

bool Feature::HasHorizontalAllyEnemySelecting() {
return HasRpg2k3BattleSystem() && lcf::Data::battlecommands.easyrpg_horizontal_ally_enemy_selection;
}
5 changes: 0 additions & 5 deletions src/feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ namespace Feature {
* @return true if fixed enemy facing direction is used
*/
bool HasFixedEnemyFacingDirection();

/**
* @return true if horizontal ally/enemy selecting during battle is used
*/
bool HasHorizontalAllyEnemySelecting();
}

#endif
2 changes: 2 additions & 0 deletions src/scene_battle_rpg2k3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ void Scene_Battle_Rpg2k3::CreateBattleTargetWindow() {
int transp = IsTransparent() ? 160 : 255;
target_window->SetBackOpacity(transp);
}

target_window->SetSingleColumnWrapping(true);
}

void Scene_Battle_Rpg2k3::RefreshTargetWindow() {
Expand Down
4 changes: 2 additions & 2 deletions src/window_battlestatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ void Window_BattleStatus::Update() {
}

if (active && index >= 0) {
if (Input::IsRepeated(Input::DOWN) || Input::IsTriggered(Input::SCROLL_DOWN)) {
if (Input::IsRepeated(Input::DOWN) || Input::IsRepeated(Input::RIGHT) || Input::IsTriggered(Input::SCROLL_DOWN)) {
Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Cursor));
for (int i = 1; i < item_max; i++) {
int new_index = (index + i) % item_max;
Expand All @@ -293,7 +293,7 @@ void Window_BattleStatus::Update() {
}
}
}
if (Input::IsRepeated(Input::UP) || Input::IsTriggered(Input::SCROLL_UP)) {
if (Input::IsRepeated(Input::UP) || Input::IsRepeated(Input::LEFT) || Input::IsTriggered(Input::SCROLL_UP)) {
Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Cursor));
for (int i = item_max - 1; i > 0; i--) {
int new_index = (index + i) % item_max;
Expand Down
8 changes: 6 additions & 2 deletions src/window_selectable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@ void Window_Selectable::Update() {
}
}
if (Input::IsRepeated(Input::RIGHT)) {
if (column_max >= 2 && index < item_max - 1) {
if (column_max >= wrap_limit && index < item_max - 1) {
Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Cursor));
index += 1;
}
}
if (Input::IsRepeated(Input::LEFT)) {
if (column_max >= 2 && index > 0) {
if (column_max >= wrap_limit && index > 0) {
Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Cursor));
index -= 1;
}
Expand Down Expand Up @@ -234,3 +234,7 @@ void Window_Selectable::SetEndlessScrolling(bool state) {
void Window_Selectable::SetMenuItemHeight(int height) {
menu_item_height = height;
}

void Window_Selectable::SetSingleColumnWrapping(bool wrap) {
wrap_limit = wrap ? 1 : 2;
}
10 changes: 10 additions & 0 deletions src/window_selectable.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ class Window_Selectable: public Window_Base {
*/
void SetMenuItemHeight(int height);

/**
* Allow left/right input to move cursor up/down when the selectable has only one column.
* By default this behaviour is only enabled for two and more columns.
*
* @param wrap enable/disable single column wrap
*/
void SetSingleColumnWrapping(bool wrap);

protected:
void UpdateArrows();

Expand All @@ -107,6 +115,8 @@ class Window_Selectable: public Window_Base {

int scroll_dir = 0;
int scroll_progress = 0;

int wrap_limit = 2;
};

inline void Window_Selectable::SetItemMax(int value) {
Expand Down

0 comments on commit 16217f0

Please sign in to comment.