Skip to content

Commit

Permalink
Merge pull request #4 from purrfectdoodle/feature/partyswitchingqol
Browse files Browse the repository at this point in the history
Party Switching: R to switch, SELECT to switch to front of party
  • Loading branch information
purrfectdoodle authored Jun 20, 2024
2 parents 610b2bd + ae8347a commit 18eb31f
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/party_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,15 @@ void Task_HandleChooseMonInput(u8 taskId)
MoveCursorToConfirm();
}
break;
case R_BUTTON:
DestroyTask(taskId);
break;
case SELECT_BUTTON:
gPartyMenu.slotId = *slotPtr;
gPartyMenu.slotId2 = 0;
gPartyMenu.action = PARTY_ACTION_SWITCH;
HandleChooseMonSelection(taskId, slotPtr);
break;
}
}
}
Expand Down Expand Up @@ -1618,6 +1627,22 @@ static void Task_HandleCancelChooseMonYesNoInput(u8 taskId)
}
}

static bool8 IsInvalidPartyMenuActionType(u8 partyMenuType)
{
return (partyMenuType == PARTY_ACTION_SEND_OUT
|| partyMenuType == PARTY_ACTION_CANT_SWITCH
|| partyMenuType == PARTY_ACTION_USE_ITEM
|| partyMenuType == PARTY_ACTION_ABILITY_PREVENTS
|| partyMenuType == PARTY_ACTION_GIVE_ITEM
|| partyMenuType == PARTY_ACTION_GIVE_PC_ITEM
|| partyMenuType == PARTY_ACTION_GIVE_MAILBOX_MAIL
|| partyMenuType == PARTY_ACTION_SOFTBOILED
|| partyMenuType == PARTY_ACTION_CHOOSE_AND_CLOSE
|| partyMenuType == PARTY_ACTION_MOVE_TUTOR
|| partyMenuType == PARTY_ACTION_MINIGAME
|| partyMenuType == PARTY_ACTION_REUSABLE_ITEM);
}

static u16 PartyMenuButtonHandler(s8 *slotPtr)
{
s8 movementDir;
Expand Down Expand Up @@ -1655,6 +1680,29 @@ static u16 PartyMenuButtonHandler(s8 *slotPtr)
if (JOY_NEW(START_BUTTON))
return START_BUTTON;

if (JOY_NEW(R_BUTTON) && CalculatePlayerPartyCount() >= 2 && !IsInvalidPartyMenuActionType(gPartyMenu.action))
{
if (gPartyMenu.menuType != PARTY_MENU_TYPE_FIELD)
return 0;
if (*slotPtr == PARTY_SIZE + 1)
return 0;
if (gPartyMenu.action != PARTY_ACTION_SWITCH)
{
CreateTask(CursorCb_Switch, 1);
return R_BUTTON;
}
return A_BUTTON; // R is allowed to act as the A Button while CursorCb_Switch is active.
}

if (JOY_NEW(SELECT_BUTTON) && CalculatePlayerPartyCount() >= 2 && gPartyMenu.action == PARTY_ACTION_CHOOSE_MON)
{
if (gPartyMenu.menuType != PARTY_MENU_TYPE_FIELD)
return 0;
if (*slotPtr == PARTY_SIZE + 1 || *slotPtr == 0)
return 0;
return SELECT_BUTTON;
}

if (movementDir)
{
UpdateCurrentPartySelection(slotPtr, movementDir);
Expand Down

0 comments on commit 18eb31f

Please sign in to comment.