From 63370b065d633cc2ca21293e9b31a4ec1fb1081b Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 25 Aug 2022 17:31:14 +0200 Subject: [PATCH] Party menu supports 4digit hp --- src/party_menu.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/party_menu.c b/src/party_menu.c index 34a95d5e33..ca770f93bd 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -270,7 +270,7 @@ static u8 CanMonLearnTMTutor(struct Pokemon *, u16, u8); static void DisplayPartyPokemonBarDetail(u8, const u8 *, u8, const u8 *); static void DisplayPartyPokemonLevel(u8, struct PartyMenuBox *); static void DisplayPartyPokemonGender(u8, u16, u8 *, struct PartyMenuBox *); -static void DisplayPartyPokemonHP(u16, struct PartyMenuBox *); +static void DisplayPartyPokemonHP(u16 hp, u16 maxHp, struct PartyMenuBox *menuBox); static void DisplayPartyPokemonMaxHP(u16, struct PartyMenuBox *); static void DisplayPartyPokemonHPBar(u16, u16, struct PartyMenuBox *); static void CreatePartyMonIconSpriteParameterized(u16, u32, struct PartyMenuBox *, u8); @@ -1032,7 +1032,7 @@ static void DisplayPartyPokemonDataForMultiBattle(u8 slot) DisplayPartyPokemonBarDetail(menuBox->windowId, gStringVar1, 0, menuBox->infoRects->dimensions); DisplayPartyPokemonLevel(gMultiPartnerParty[actualSlot].level, menuBox); DisplayPartyPokemonGender(gMultiPartnerParty[actualSlot].gender, gMultiPartnerParty[actualSlot].species, gMultiPartnerParty[actualSlot].nickname, menuBox); - DisplayPartyPokemonHP(gMultiPartnerParty[actualSlot].hp, menuBox); + DisplayPartyPokemonHP(gMultiPartnerParty[actualSlot].hp, gMultiPartnerParty[actualSlot].maxhp, menuBox); DisplayPartyPokemonMaxHP(gMultiPartnerParty[actualSlot].maxhp, menuBox); DisplayPartyPokemonHPBar(gMultiPartnerParty[actualSlot].hp, gMultiPartnerParty[actualSlot].maxhp, menuBox); } @@ -2359,18 +2359,31 @@ static void DisplayPartyPokemonHPCheck(struct Pokemon *mon, struct PartyMenuBox if (c != 0) menuBox->infoRects->blitFunc(menuBox->windowId, menuBox->infoRects->dimensions[12] >> 3, (menuBox->infoRects->dimensions[13] >> 3) + 1, menuBox->infoRects->dimensions[14] >> 3, menuBox->infoRects->dimensions[15] >> 3, FALSE); if (c != 2) - DisplayPartyPokemonHP(GetMonData(mon, MON_DATA_HP), menuBox); + DisplayPartyPokemonHP(GetMonData(mon, MON_DATA_HP), GetMonData(mon, MON_DATA_MAX_HP), menuBox); } } -static void DisplayPartyPokemonHP(u16 hp, struct PartyMenuBox *menuBox) +static void DisplayParty4DigitsHP(struct PartyMenuBox *menuBox, const u8 *str, const u8 *origAlings, u32 toSub) { - u8 *strOut = ConvertIntToDecimalStringN(gStringVar1, hp, STR_CONV_MODE_RIGHT_ALIGN, 4); + u8 newAligns[4]; + + memcpy(newAligns, origAlings, sizeof(newAligns)); + newAligns[0] -= toSub; // x, so that the hp fits + DisplayPartyPokemonBarDetail(menuBox->windowId, str, 0, newAligns); +} + +static void DisplayPartyPokemonHP(u16 hp, u16 maxhp, struct PartyMenuBox *menuBox) +{ + bool32 fourDigits = (maxhp >= 1000); + u8 *strOut = ConvertIntToDecimalStringN(gStringVar1, hp, STR_CONV_MODE_RIGHT_ALIGN, fourDigits ? 4 : 3); strOut[0] = CHAR_SLASH; strOut[1] = EOS; - DisplayPartyPokemonBarDetail(menuBox->windowId, gStringVar1, 0, &menuBox->infoRects->dimensions[12]); + if (fourDigits) + DisplayParty4DigitsHP(menuBox, gStringVar1, &menuBox->infoRects->dimensions[12], 10); + else + DisplayPartyPokemonBarDetail(menuBox->windowId, gStringVar1, 0, &menuBox->infoRects->dimensions[12]); } static void DisplayPartyPokemonMaxHPCheck(struct Pokemon *mon, struct PartyMenuBox *menuBox, u8 c) @@ -2386,10 +2399,16 @@ static void DisplayPartyPokemonMaxHPCheck(struct Pokemon *mon, struct PartyMenuB static void DisplayPartyPokemonMaxHP(u16 maxhp, struct PartyMenuBox *menuBox) { - ConvertIntToDecimalStringN(gStringVar2, maxhp, STR_CONV_MODE_RIGHT_ALIGN, 4); + bool32 fourDigits = (maxhp >= 1000); + + ConvertIntToDecimalStringN(gStringVar2, maxhp, STR_CONV_MODE_RIGHT_ALIGN, fourDigits ? 4 : 3); StringCopy(gStringVar1, gText_Slash); StringAppend(gStringVar1, gStringVar2); - DisplayPartyPokemonBarDetail(menuBox->windowId, gStringVar1, 0, &menuBox->infoRects->dimensions[16]); + + if (fourDigits) + DisplayParty4DigitsHP(menuBox, gStringVar1, &menuBox->infoRects->dimensions[16], 5); + else + DisplayPartyPokemonBarDetail(menuBox->windowId, gStringVar1, 0, &menuBox->infoRects->dimensions[16]); } static void DisplayPartyPokemonHPBarCheck(struct Pokemon *mon, struct PartyMenuBox *menuBox)