mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
Merge pull request #2586 from Jaizu/ability_popup_fixes
Ability popup updates
This commit is contained in:
commit
1202f0366c
Binary file not shown.
Before Width: | Height: | Size: 275 B After Width: | Height: | Size: 284 B |
@ -2801,66 +2801,25 @@ static const struct SpritePalette sSpritePalette_AbilityPopUp =
|
||||
|
||||
static const struct OamData sOamData_AbilityPopUp =
|
||||
{
|
||||
.y = 0,
|
||||
.affineMode = 0,
|
||||
.objMode = 0,
|
||||
.mosaic = 0,
|
||||
.bpp = 0,
|
||||
.shape = ST_OAM_H_RECTANGLE,
|
||||
.x = 0,
|
||||
.matrixNum = 0,
|
||||
.size = 3,
|
||||
.tileNum = 0,
|
||||
.affineMode = ST_OAM_AFFINE_OFF,
|
||||
.objMode = ST_OAM_OBJ_NORMAL,
|
||||
.shape = SPRITE_SHAPE(64x32),
|
||||
.size = SPRITE_SIZE(64x32),
|
||||
.priority = 0,
|
||||
.paletteNum = 0,
|
||||
.affineParam = 0,
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_AbilityPopUp1[] =
|
||||
{
|
||||
ANIMCMD_FRAME(0, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd *const sSpriteAnimTable_AbilityPopUp1[] =
|
||||
{
|
||||
sSpriteAnim_AbilityPopUp1
|
||||
};
|
||||
|
||||
static const struct SpriteTemplate sSpriteTemplate_AbilityPopUp1 =
|
||||
static const struct SpriteTemplate sSpriteTemplate_AbilityPopUp =
|
||||
{
|
||||
.tileTag = ABILITY_POP_UP_TAG,
|
||||
.paletteTag = ABILITY_POP_UP_TAG,
|
||||
.oam = &sOamData_AbilityPopUp,
|
||||
.anims = sSpriteAnimTable_AbilityPopUp1,
|
||||
.anims = gDummySpriteAnimTable,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = SpriteCb_AbilityPopUp
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_AbilityPopUp2[] =
|
||||
{
|
||||
ANIMCMD_FRAME(32, 0),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd *const sSpriteAnimTable_AbilityPopUp2[] =
|
||||
{
|
||||
sSpriteAnim_AbilityPopUp2
|
||||
};
|
||||
|
||||
static const struct SpriteTemplate sSpriteTemplate_AbilityPopUp2 =
|
||||
{
|
||||
.tileTag = ABILITY_POP_UP_TAG,
|
||||
.paletteTag = ABILITY_POP_UP_TAG,
|
||||
.oam = &sOamData_AbilityPopUp,
|
||||
.anims = sSpriteAnimTable_AbilityPopUp2,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = SpriteCb_AbilityPopUp
|
||||
};
|
||||
|
||||
#define ABILITY_POP_UP_POS_X_DIFF 64
|
||||
#define ABILITY_POP_UP_POS_X_DIFF (64 - 7) // Hide second sprite underneath to gain proper letter spacing
|
||||
#define ABILITY_POP_UP_POS_X_SLIDE 68
|
||||
|
||||
static const s16 sAbilityPopUpCoordsDoubles[MAX_BATTLERS_COUNT][2] =
|
||||
@ -2877,24 +2836,27 @@ static const s16 sAbilityPopUpCoordsSingles[MAX_BATTLERS_COUNT][2] =
|
||||
{186, 57}, // opponent
|
||||
};
|
||||
|
||||
#define POPUP_WINDOW_WIDTH 8
|
||||
#define MAX_POPUP_STRING_WIDTH (POPUP_WINDOW_WIDTH * 8)
|
||||
|
||||
static u8* AddTextPrinterAndCreateWindowOnAbilityPopUp(const u8 *str, u32 x, u32 y, u32 color1, u32 color2, u32 color3, u32 *windowId)
|
||||
{
|
||||
u8 color[3] = {color1, color2, color3};
|
||||
struct WindowTemplate winTemplate = {0};
|
||||
winTemplate.width = 8;
|
||||
winTemplate.width = POPUP_WINDOW_WIDTH;
|
||||
winTemplate.height = 2;
|
||||
|
||||
*windowId = AddWindow(&winTemplate);
|
||||
FillWindowPixelBuffer(*windowId, PIXEL_FILL(color1));
|
||||
|
||||
AddTextPrinterParameterized4(*windowId, 0, x, y, 0, 0, color, -1, str);
|
||||
AddTextPrinterParameterized4(*windowId, FONT_SMALL, x, y, 0, 0, color, TEXT_SKIP_DRAW, str);
|
||||
return (u8 *)(GetWindowAttribute(*windowId, WINDOW_TILE_DATA));
|
||||
}
|
||||
|
||||
static void TextIntoAbilityPopUp(void *dest, u8 *windowTileData, s32 arg2, bool32 arg3)
|
||||
static void TextIntoAbilityPopUp(void *dest, u8 *windowTileData, s32 xTileAmount, bool32 arg3)
|
||||
{
|
||||
CpuCopy32(windowTileData + 256, dest + 256, arg2 * 32);
|
||||
if (arg2 > 0)
|
||||
CpuCopy32(windowTileData + 256, dest + 256, xTileAmount * 32);
|
||||
if (xTileAmount > 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
@ -2903,52 +2865,26 @@ static void TextIntoAbilityPopUp(void *dest, u8 *windowTileData, s32 arg2, bool3
|
||||
else
|
||||
CpuCopy32(windowTileData + 20, dest + 20, 12);
|
||||
dest += 32, windowTileData += 32;
|
||||
arg2--;
|
||||
} while (arg2 != 0);
|
||||
xTileAmount--;
|
||||
} while (xTileAmount != 0);
|
||||
}
|
||||
}
|
||||
|
||||
#define MAX_CHARS_PRINTED 12
|
||||
|
||||
static void PrintOnAbilityPopUp(const u8 *str, u8 *spriteTileData1, u8 *spriteTileData2, u32 x1, u32 x2, u32 y, u32 color1, u32 color2, u32 color3, bool32 alignAbilityChars)
|
||||
static void PrintOnAbilityPopUp(const u8 *str, u8 *spriteTileData1, u8 *spriteTileData2, u32 x1, u32 x2, u32 y, u32 color1, u32 color2, u32 color3)
|
||||
{
|
||||
u32 windowId, i;
|
||||
u32 windowId;
|
||||
u8 *windowTileData;
|
||||
u8 text1[MAX_CHARS_PRINTED];
|
||||
u8 text2[MAX_CHARS_PRINTED];
|
||||
u16 width;
|
||||
|
||||
for (i = 0; i < MAX_CHARS_PRINTED; i++)
|
||||
{
|
||||
text1[i] = str[i];
|
||||
if (text1[i] == EOS)
|
||||
break;
|
||||
}
|
||||
text1[i] = EOS;
|
||||
|
||||
// Because there are two Windows, we need to align the strings, so that the first char in the second window starts right after the last char in the first window.
|
||||
// Windows are 64 pixels in width.
|
||||
if (alignAbilityChars && i == MAX_CHARS_PRINTED)
|
||||
{
|
||||
u32 width = GetStringWidth(FONT_SMALL, text1, 0);
|
||||
if (x1 + width < 64)
|
||||
x1 += 64 - (x1 + width);
|
||||
}
|
||||
|
||||
windowTileData = AddTextPrinterAndCreateWindowOnAbilityPopUp(text1, x1, y, color1, color2, color3, &windowId);
|
||||
windowTileData = AddTextPrinterAndCreateWindowOnAbilityPopUp(str, x1, y, color1, color2, color3, &windowId);
|
||||
TextIntoAbilityPopUp(spriteTileData1, windowTileData, 8, (y == 0));
|
||||
RemoveWindow(windowId);
|
||||
|
||||
if (i == MAX_CHARS_PRINTED)
|
||||
{
|
||||
for (i = 0; i < MAX_CHARS_PRINTED; i++)
|
||||
{
|
||||
text2[i] = str[MAX_CHARS_PRINTED + i];
|
||||
if (text2[i] == EOS)
|
||||
break;
|
||||
}
|
||||
text2[i] = EOS;
|
||||
width = GetStringWidth(FONT_SMALL, str, 0);
|
||||
|
||||
windowTileData = AddTextPrinterAndCreateWindowOnAbilityPopUp(text2, x2, y, color1, color2, color3, &windowId);
|
||||
if (width > MAX_POPUP_STRING_WIDTH - 5)
|
||||
{
|
||||
windowTileData = AddTextPrinterAndCreateWindowOnAbilityPopUp(str, x2 - MAX_POPUP_STRING_WIDTH, y, color1, color2, color3, &windowId);
|
||||
TextIntoAbilityPopUp(spriteTileData2, windowTileData, 3, (y == 0));
|
||||
RemoveWindow(windowId);
|
||||
}
|
||||
@ -2960,48 +2896,51 @@ static void ClearAbilityName(u8 spriteId1, u8 spriteId2)
|
||||
PrintOnAbilityPopUp(sText_Space16,
|
||||
(void*)(OBJ_VRAM0) + (gSprites[spriteId1].oam.tileNum * 32) + 256,
|
||||
(void*)(OBJ_VRAM0) + (gSprites[spriteId2].oam.tileNum * 32) + 256,
|
||||
6, 1,
|
||||
5, 12,
|
||||
4,
|
||||
7, 9, 1,
|
||||
FALSE);
|
||||
7, 9, 1);
|
||||
}
|
||||
|
||||
static void PrintBattlerOnAbilityPopUp(u8 battlerId, u8 spriteId1, u8 spriteId2)
|
||||
{
|
||||
int i;
|
||||
u8 lastChar;
|
||||
u8* name;
|
||||
u8* textPtr;
|
||||
u8 monName[POKEMON_NAME_LENGTH + 3] = {0};
|
||||
u8* nick = gBattleMons[battlerId].nickname;
|
||||
u8* nick = gBattleMons[battlerId].nickname; // This needs to be updated for Illusion support
|
||||
|
||||
for (i = 0; i < POKEMON_NAME_LENGTH; ++i)
|
||||
{
|
||||
monName[i] = nick[i];
|
||||
if (nick[i] == EOS || i + 1 == POKEMON_NAME_LENGTH)
|
||||
|
||||
if (nick[i] == EOS || i + 1 == POKEMON_NAME_LENGTH) // End of string
|
||||
break;
|
||||
}
|
||||
|
||||
name = monName + i + 1;
|
||||
if (*(name - 1) == EOS)
|
||||
name--;
|
||||
textPtr = monName + i + 1;
|
||||
|
||||
lastChar = *(name - 1);
|
||||
name[0] = CHAR_SGL_QUOTE_RIGHT; // apostraphe
|
||||
name++;
|
||||
if (*(textPtr - 1) == EOS)
|
||||
textPtr--;
|
||||
|
||||
lastChar = *(textPtr - 1);
|
||||
|
||||
// Make the string say "[NAME]'s" instead of "[NAME]"
|
||||
textPtr[0] = CHAR_SGL_QUOTE_RIGHT; // apostraphe
|
||||
textPtr++;
|
||||
if (lastChar != CHAR_S && lastChar != CHAR_s)
|
||||
{
|
||||
name[0] = CHAR_s;
|
||||
name++;
|
||||
textPtr[0] = CHAR_s;
|
||||
textPtr++;
|
||||
}
|
||||
|
||||
name[0] = EOS;
|
||||
textPtr[0] = EOS;
|
||||
|
||||
PrintOnAbilityPopUp((const u8 *)monName,
|
||||
(void*)(OBJ_VRAM0) + (gSprites[spriteId1].oam.tileNum * 32),
|
||||
(void*)(OBJ_VRAM0) + (gSprites[spriteId2].oam.tileNum * 32),
|
||||
7, 0,
|
||||
5, 12,
|
||||
0,
|
||||
2, 7, 1,
|
||||
FALSE);
|
||||
2, 7, 1);
|
||||
}
|
||||
|
||||
static void PrintAbilityOnAbilityPopUp(u32 ability, u8 spriteId1, u8 spriteId2)
|
||||
@ -3009,10 +2948,9 @@ static void PrintAbilityOnAbilityPopUp(u32 ability, u8 spriteId1, u8 spriteId2)
|
||||
PrintOnAbilityPopUp(gAbilityNames[ability],
|
||||
(void*)(OBJ_VRAM0) + (gSprites[spriteId1].oam.tileNum * 32) + 256,
|
||||
(void*)(OBJ_VRAM0) + (gSprites[spriteId2].oam.tileNum * 32) + 256,
|
||||
6, 0,
|
||||
5, 12,
|
||||
4,
|
||||
7, 9, 1,
|
||||
TRUE);
|
||||
7, 9, 1);
|
||||
}
|
||||
|
||||
#define PIXEL_COORDS_TO_OFFSET(x, y)( \
|
||||
@ -3076,15 +3014,12 @@ static const u16 sOverwrittenPixelsTable[][2] =
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 45), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 46), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 47), 8},
|
||||
//{PIXEL_COORDS_TO_OFFSET(0, 48), 8}, // cuts off the top of the 'G' in Neutralizing Gas
|
||||
{PIXEL_COORDS_TO_OFFSET(8, 45), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(8, 46), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(8, 47), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(8, 48), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(16, 45), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(16, 46), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(16, 47), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(16, 48), 8},
|
||||
};
|
||||
|
||||
static inline void CopyPixels(u8 *dest, const u8 *src, u32 pixelCount)
|
||||
@ -3155,35 +3090,33 @@ void CreateAbilityPopUp(u8 battlerId, u32 ability, bool32 isDoubleBattle)
|
||||
|
||||
if ((battlerPosition & BIT_SIDE) == B_SIDE_PLAYER)
|
||||
{
|
||||
spriteId1 = CreateSprite(&sSpriteTemplate_AbilityPopUp1,
|
||||
spriteId1 = CreateSprite(&sSpriteTemplate_AbilityPopUp,
|
||||
coords[battlerPosition][0] - ABILITY_POP_UP_POS_X_SLIDE,
|
||||
coords[battlerPosition][1], 0);
|
||||
spriteId2 = CreateSprite(&sSpriteTemplate_AbilityPopUp2,
|
||||
spriteId2 = CreateSprite(&sSpriteTemplate_AbilityPopUp,
|
||||
coords[battlerPosition][0] - ABILITY_POP_UP_POS_X_SLIDE + ABILITY_POP_UP_POS_X_DIFF,
|
||||
coords[battlerPosition][1], 0);
|
||||
|
||||
gSprites[spriteId1].tOriginalX = coords[battlerPosition][0];
|
||||
gSprites[spriteId2].tOriginalX = coords[battlerPosition][0] + ABILITY_POP_UP_POS_X_DIFF;
|
||||
coords[battlerPosition][1], 1); //Appears below
|
||||
|
||||
gSprites[spriteId1].tRightToLeft = TRUE;
|
||||
gSprites[spriteId2].tRightToLeft = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
spriteId1 = CreateSprite(&sSpriteTemplate_AbilityPopUp1,
|
||||
spriteId1 = CreateSprite(&sSpriteTemplate_AbilityPopUp,
|
||||
coords[battlerPosition][0] + ABILITY_POP_UP_POS_X_SLIDE,
|
||||
coords[battlerPosition][1], 0);
|
||||
spriteId2 = CreateSprite(&sSpriteTemplate_AbilityPopUp2,
|
||||
spriteId2 = CreateSprite(&sSpriteTemplate_AbilityPopUp,
|
||||
coords[battlerPosition][0] + ABILITY_POP_UP_POS_X_SLIDE + ABILITY_POP_UP_POS_X_DIFF,
|
||||
coords[battlerPosition][1], 0);
|
||||
|
||||
gSprites[spriteId1].tOriginalX = coords[battlerPosition][0];
|
||||
gSprites[spriteId2].tOriginalX = coords[battlerPosition][0] + ABILITY_POP_UP_POS_X_DIFF;
|
||||
coords[battlerPosition][1], 1); //Appears below
|
||||
|
||||
gSprites[spriteId1].tRightToLeft = FALSE;
|
||||
gSprites[spriteId2].tRightToLeft = FALSE;
|
||||
}
|
||||
|
||||
gSprites[spriteId1].tOriginalX = coords[battlerPosition][0];
|
||||
gSprites[spriteId2].tOriginalX = coords[battlerPosition][0] + ABILITY_POP_UP_POS_X_DIFF;
|
||||
gSprites[spriteId2].oam.tileNum += (8 * 4); //Second half of pop up
|
||||
|
||||
gBattleStruct->abilityPopUpSpriteIds[battlerId][0] = spriteId1;
|
||||
gBattleStruct->abilityPopUpSpriteIds[battlerId][1] = spriteId2;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user