Skip to content

Add Description Submenu

voloved edited this page Apr 7, 2023 · 11 revisions

By devolov

Goal: When pushing START in battle, show the move's stats and description in a sub-menu.
Most of the credit goes to TheXaman's tx_ui_battle_typing system. I just pulled the small parts that I needed to make it easy to see what the move's description and effects are.

pokeemerald_modern-0

-------------------------- include/constants/battle.h --------------------------
index 4dfa31cec8..b1ac50303e 100644
@@ -361,8 +361,12 @@
 #define B_WIN_VS_MULTI_PLAYER_4  20
 #define B_WIN_VS_OUTCOME_DRAW    21
 #define B_WIN_VS_OUTCOME_LEFT    22
 #define B_WIN_VS_OUTCOME_RIGHT   23
+#define B_WIN_MOVE_DESCRIPTION   24

 // The following are duplicate id values for windows that Battle Arena uses differently.
 #define ARENA_WIN_PLAYER_NAME      15
 #define ARENA_WIN_VS               16
-------------------------------- include/menu.h --------------------------------
index 0b0a42423d..cc956e5334 100644
@@ -95,8 +95,9 @@ u8 GetStartMenuWindowId(void);
 void ListMenuLoadStdPalAt(u8 palOffset, u8 palId);
 u8 Menu_MoveCursor(s8 cursorDelta);
 u8 Menu_MoveCursorNoWrapAround(s8 cursorDelta);
 void DrawStdWindowFrame(u8 windowId, bool8 CopyToVram);
+void DrawStdWindowFrameBattleInfoSystem(u8 windowId);
 u8 AddStartMenuWindow(u8 numActions);
 u8 InitMenuNormal(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 initialCursorPos);
 void LoadMessageBoxAndFrameGfx(u8 windowId, bool8 copyToVram);
 void AddTextPrinterForMessage_2(bool8 allowSkippingDelayWithButtonPress);
------------------------------- src/battle_bg.c -------------------------------
index f24bb5d28a..9f76f1e0ff 100644
@@ -376,35 +376,44 @@ static const struct WindowTemplate sStandardBattleWindowTemplates[] =
     [B_WIN_VS_OUTCOME_RIGHT] = {
         .bg = 0,
         .tilemapLeft = 19,
         .tilemapTop = 2,
         .width = 7,
         .height = 2,
         .paletteNum = 0,
         .baseBlock = 0x00b0,
     },
+    [B_WIN_MOVE_DESCRIPTION] = {
+        .bg = 0,
+        .tilemapLeft = 1,
+        .tilemapTop = 47,
+        .width = 18,
+        .height = 6,
+        .paletteNum = 5,
+        .baseBlock = 0x0350,
+    },
     DUMMY_WIN_TEMPLATE
 };
 static const struct WindowTemplate sBattleArenaWindowTemplates[] =

------------------------ src/battle_controller_player.c ------------------------
index 6bf2b9d0cb..1d0317c010 100644
@@ -36,8 +36,10 @@
 #include "constants/party_menu.h"
 #include "constants/songs.h"
 #include "constants/trainers.h"
 #include "constants/rgb.h"
+#include "menu.h"
+#include "pokemon_summary_screen.h"
 
 static void PlayerHandleGetMonData(void);
 static void PlayerHandleSetMonData(void);
 static void PlayerHandleSetRawMonData(void);
@@ -104,8 +106,9 @@ static void MoveSelectionDestroyCursorAt(u8);
 static void MoveSelectionDisplayPpNumber(void);
 static void MoveSelectionDisplayPpString(void);
 static void MoveSelectionDisplayMoveTypeDoubles(u8 targetId, u8 targetIdPrev);
 static void MoveSelectionDisplayMoveType(void);
+static void MoveSelectionDisplayMoveDescription(void);
 static void MoveSelectionDisplayMoveNames(void);
 static void HandleMoveSwitching(void);
 static void SwitchIn_HandleSoundAndEnd(void);
 static void WaitForMonSelection(void);
@@ -185,8 +188,12 @@ static void (*const sPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
     [CONTROLLER_ENDLINKBATTLE]            = PlayerHandleEndLinkBattle,
     [CONTROLLER_TERMINATOR_NOP]           = PlayerCmdEnd
 };
 
+EWRAM_DATA bool8 gAdditionalBattleInfoSubmenu = 0;
+
+
+
 static const u8 sTargetIdentities[MAX_BATTLERS_COUNT] = {B_POSITION_PLAYER_LEFT, B_POSITION_PLAYER_RIGHT, B_POSITION_OPPONENT_RIGHT, B_POSITION_OPPONENT_LEFT};
 
 // unknown unused data
 static const u8 sUnused[] = {0x48, 0x48, 0x20, 0x5a, 0x50, 0x50, 0x50, 0x58};
@@ -497,9 +504,23 @@ static void HandleInputChooseMove(void)
         gPlayerDpadHoldFrames++;
     else
         gPlayerDpadHoldFrames = 0;
 
-    if (JOY_NEW(A_BUTTON))
+    if (gAdditionalBattleInfoSubmenu)
+    {
+        if (JOY_NEW(START_BUTTON) || JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON))
+        {
+            gAdditionalBattleInfoSubmenu = FALSE;
+            FillWindowPixelBuffer(B_WIN_MOVE_DESCRIPTION, PIXEL_FILL(0));
+            ClearStdWindowAndFrame(B_WIN_MOVE_DESCRIPTION, FALSE);
+            CopyWindowToVram(B_WIN_MOVE_DESCRIPTION, COPYWIN_GFX);
+            PlaySE(SE_SELECT);
+            MoveSelectionDisplayPpNumber();
+            MoveSelectionDisplayMoveType();
+        }
+    }
+    else if (JOY_NEW(A_BUTTON))
     {
         u8 moveTarget;
 
         PlaySE(SE_SELECT);
@@ -633,8 +654,13 @@ static void HandleInputChooseMove(void)
             BattlePutTextOnWindow(gText_BattleSwitchWhich, B_WIN_SWITCH_PROMPT);
             gBattlerControllerFuncs[gActiveBattler] = HandleMoveSwitching;
         }
     }
+    else if (JOY_NEW(START_BUTTON)) //AdditionalBattleInfo
+    {
+        gAdditionalBattleInfoSubmenu = TRUE;
+        MoveSelectionDisplayMoveDescription();
+    }
 }
 
 static u32 HandleMoveInputUnused(void)
 {
@@ -1574,8 +1600,54 @@ static void MoveSelectionDisplayPpNumber(void)

    BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_PP_REMAINING);
}
 
+static void MoveSelectionDisplayMoveDescription(void)
+{
+    struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]);
+    u16 move = moveInfo->moves[gMoveSelectionCursor[gActiveBattler]];
+    u16 pwr = gBattleMoves[move].power;
+    u16 acc = gBattleMoves[move].accuracy;
+    u16 priority = gBattleMoves[move].priority;
+    u8 pwr_num[3], acc_num[3], pri_num[3], i;
+    u8 pwr_num_len, acc_num_len, pri_num_len;
+    u8 pwr_desc[7] = _(" PWR: ");
+    u8 acc_desc[10] = _("    ACC: ");
+    u8 pri_desc[10] = _("    PRI: ");
+    LoadMessageBoxAndBorderGfx();
+    DrawStdWindowFrameBattleInfoSystem(B_WIN_MOVE_DESCRIPTION);
+    if (pwr < 2)
+        StringCopy(pwr_num, gText_BattleSwitchWhich5);
+    else
+        ConvertIntToDecimalStringN(pwr_num, pwr, STR_CONV_MODE_LEFT_ALIGN, 3);
+     if (acc < 2)
+        StringCopy(acc_num, gText_BattleSwitchWhich5);
+    else
+        ConvertIntToDecimalStringN(acc_num, acc, STR_CONV_MODE_LEFT_ALIGN, 3);
+    ConvertIntToDecimalStringN(pri_num, priority, STR_CONV_MODE_LEFT_ALIGN, 3);
+    pwr_num_len = StringLength(pwr_num);
+    acc_num_len = StringLength(acc_num);
+    pri_num_len = StringLength(pri_num);
+    StringCopy(gDisplayedStringBattle, pwr_desc);
+    StringAppend(gDisplayedStringBattle, pwr_num);
+    for (i = pwr_num_len; i < 3; i++){
+        StringAppend(gDisplayedStringBattle, gText_Space2);
+        StringAppend(gDisplayedStringBattle, gText_Space2);
+    }
+    StringAppend(gDisplayedStringBattle, acc_desc);
+    StringAppend(gDisplayedStringBattle, acc_num);
+    for (i = acc_num_len; i < 3; i++){
+        StringAppend(gDisplayedStringBattle, gText_Space2);
+        StringAppend(gDisplayedStringBattle, gText_Space2);
+    }
+    StringAppend(gDisplayedStringBattle, pri_desc);
+    StringAppend(gDisplayedStringBattle, pri_num);
+    StringAppend(gDisplayedStringBattle, gText_NewLine);
+    StringAppend(gDisplayedStringBattle, gMoveDescriptionPointers[move -1]);
+    BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MOVE_DESCRIPTION);
+    CopyWindowToVram(B_WIN_MOVE_DESCRIPTION, COPYWIN_FULL);
+}
+
 static void MoveSelectionCreateCursorAt(u8 cursorPosition, u8 baseTileNum)
 {
     u16 src[2];
     src[0] = baseTileNum + 1;
----------------------------- src/battle_message.c -----------------------------
index 0835dda70c..4949575d00 100644
@@ -1784,9 +1784,9 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
         .fgColor = TEXT_COLOR_WHITE,
         .bgColor = TEXT_COLOR_TRANSPARENT,
         .shadowColor = TEXT_COLOR_GREEN,
     },
+    [B_WIN_MOVE_DESCRIPTION] = {
+        .fillValue = PIXEL_FILL(0xE),
+        .fontId = FONT_NARROW,
+        .x = 0,
+        .y = 1,
+        .letterSpacing = 0,
+        .lineSpacing = 0,
+        .speed = 0,
+        .fgColor = TEXT_DYNAMIC_COLOR_4,
+        .bgColor = TEXT_DYNAMIC_COLOR_5,
+        .shadowColor = TEXT_DYNAMIC_COLOR_6,
+    },
 };
 
 static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
 {
---------------------------------- src/menu.c ----------------------------------
index e14a2af595..a6e0f468d9 100644
@@ -230,8 +230,13 @@ void DrawStdWindowFrame(u8 windowId, bool8 copyToVram)
     if (copyToVram == TRUE)
         CopyWindowToVram(windowId, COPYWIN_FULL);
 }
 
+void DrawStdWindowFrameBattleInfoSystem(u8 windowId)
+{
+    CallWindowFunction(windowId, WindowFunc_DrawStandardFrame);
+}
+
 void ClearDialogWindowAndFrame(u8 windowId, bool8 copyToVram)
 {
     CallWindowFunction(windowId, WindowFunc_ClearDialogWindowAndFrame);
     FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
Clone this wiki locally