mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 19:54:21 +01:00
Ability popup fixes
This commit is contained in:
parent
4855b370a9
commit
c6811fb692
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 =
|
static const struct OamData sOamData_AbilityPopUp =
|
||||||
{
|
{
|
||||||
.y = 0,
|
.affineMode = ST_OAM_AFFINE_OFF,
|
||||||
.affineMode = 0,
|
.objMode = ST_OAM_OBJ_NORMAL,
|
||||||
.objMode = 0,
|
.shape = SPRITE_SHAPE(64x32),
|
||||||
.mosaic = 0,
|
.size = SPRITE_SIZE(64x32),
|
||||||
.bpp = 0,
|
|
||||||
.shape = ST_OAM_H_RECTANGLE,
|
|
||||||
.x = 0,
|
|
||||||
.matrixNum = 0,
|
|
||||||
.size = 3,
|
|
||||||
.tileNum = 0,
|
|
||||||
.priority = 0,
|
.priority = 0,
|
||||||
.paletteNum = 0,
|
|
||||||
.affineParam = 0,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const union AnimCmd sSpriteAnim_AbilityPopUp1[] =
|
static const struct SpriteTemplate sSpriteTemplate_AbilityPopUp =
|
||||||
{
|
|
||||||
ANIMCMD_FRAME(0, 0),
|
|
||||||
ANIMCMD_END
|
|
||||||
};
|
|
||||||
|
|
||||||
static const union AnimCmd *const sSpriteAnimTable_AbilityPopUp1[] =
|
|
||||||
{
|
|
||||||
sSpriteAnim_AbilityPopUp1
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct SpriteTemplate sSpriteTemplate_AbilityPopUp1 =
|
|
||||||
{
|
{
|
||||||
.tileTag = ABILITY_POP_UP_TAG,
|
.tileTag = ABILITY_POP_UP_TAG,
|
||||||
.paletteTag = ABILITY_POP_UP_TAG,
|
.paletteTag = ABILITY_POP_UP_TAG,
|
||||||
.oam = &sOamData_AbilityPopUp,
|
.oam = &sOamData_AbilityPopUp,
|
||||||
.anims = sSpriteAnimTable_AbilityPopUp1,
|
.anims = gDummySpriteAnimTable,
|
||||||
.images = NULL,
|
.images = NULL,
|
||||||
.affineAnims = gDummySpriteAffineAnimTable,
|
.affineAnims = gDummySpriteAffineAnimTable,
|
||||||
.callback = SpriteCb_AbilityPopUp
|
.callback = SpriteCb_AbilityPopUp
|
||||||
};
|
};
|
||||||
|
|
||||||
static const union AnimCmd sSpriteAnim_AbilityPopUp2[] =
|
#define ABILITY_POP_UP_POS_X_DIFF (64 - 7) //Hide second sprite underneath to gain proper letter spacing
|
||||||
{
|
|
||||||
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_SLIDE 68
|
#define ABILITY_POP_UP_POS_X_SLIDE 68
|
||||||
|
|
||||||
static const s16 sAbilityPopUpCoordsDoubles[MAX_BATTLERS_COUNT][2] =
|
static const s16 sAbilityPopUpCoordsDoubles[MAX_BATTLERS_COUNT][2] =
|
||||||
@ -2877,24 +2836,27 @@ static const s16 sAbilityPopUpCoordsSingles[MAX_BATTLERS_COUNT][2] =
|
|||||||
{186, 57}, // opponent
|
{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)
|
static u8* AddTextPrinterAndCreateWindowOnAbilityPopUp(const u8 *str, u32 x, u32 y, u32 color1, u32 color2, u32 color3, u32 *windowId)
|
||||||
{
|
{
|
||||||
u8 color[3] = {color1, color2, color3};
|
u8 color[3] = {color1, color2, color3};
|
||||||
struct WindowTemplate winTemplate = {0};
|
struct WindowTemplate winTemplate = {0};
|
||||||
winTemplate.width = 8;
|
winTemplate.width = POPUP_WINDOW_WIDTH;
|
||||||
winTemplate.height = 2;
|
winTemplate.height = 2;
|
||||||
|
|
||||||
*windowId = AddWindow(&winTemplate);
|
*windowId = AddWindow(&winTemplate);
|
||||||
FillWindowPixelBuffer(*windowId, PIXEL_FILL(color1));
|
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));
|
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);
|
CpuCopy32(windowTileData + 256, dest + 256, xTileAmount * 32);
|
||||||
if (arg2 > 0)
|
if (xTileAmount > 0)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -2903,52 +2865,26 @@ static void TextIntoAbilityPopUp(void *dest, u8 *windowTileData, s32 arg2, bool3
|
|||||||
else
|
else
|
||||||
CpuCopy32(windowTileData + 20, dest + 20, 12);
|
CpuCopy32(windowTileData + 20, dest + 20, 12);
|
||||||
dest += 32, windowTileData += 32;
|
dest += 32, windowTileData += 32;
|
||||||
arg2--;
|
xTileAmount--;
|
||||||
} while (arg2 != 0);
|
} 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)
|
||||||
|
|
||||||
static void PrintOnAbilityPopUp(const u8 *str, u8 *spriteTileData1, u8 *spriteTileData2, u32 x1, u32 x2, u32 y, u32 color1, u32 color2, u32 color3, bool32 alignAbilityChars)
|
|
||||||
{
|
{
|
||||||
u32 windowId, i;
|
u32 windowId;
|
||||||
u8 *windowTileData;
|
u8 *windowTileData;
|
||||||
u8 text1[MAX_CHARS_PRINTED];
|
u16 width;
|
||||||
u8 text2[MAX_CHARS_PRINTED];
|
|
||||||
|
|
||||||
for (i = 0; i < MAX_CHARS_PRINTED; i++)
|
windowTileData = AddTextPrinterAndCreateWindowOnAbilityPopUp(str, x1, y, color1, color2, color3, &windowId);
|
||||||
{
|
|
||||||
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);
|
|
||||||
TextIntoAbilityPopUp(spriteTileData1, windowTileData, 8, (y == 0));
|
TextIntoAbilityPopUp(spriteTileData1, windowTileData, 8, (y == 0));
|
||||||
RemoveWindow(windowId);
|
RemoveWindow(windowId);
|
||||||
|
|
||||||
if (i == MAX_CHARS_PRINTED)
|
width = GetStringWidth(FONT_SMALL, str, 0);
|
||||||
{
|
|
||||||
for (i = 0; i < MAX_CHARS_PRINTED; i++)
|
|
||||||
{
|
|
||||||
text2[i] = str[MAX_CHARS_PRINTED + i];
|
|
||||||
if (text2[i] == EOS)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
text2[i] = EOS;
|
|
||||||
|
|
||||||
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));
|
TextIntoAbilityPopUp(spriteTileData2, windowTileData, 3, (y == 0));
|
||||||
RemoveWindow(windowId);
|
RemoveWindow(windowId);
|
||||||
}
|
}
|
||||||
@ -2960,48 +2896,51 @@ static void ClearAbilityName(u8 spriteId1, u8 spriteId2)
|
|||||||
PrintOnAbilityPopUp(sText_Space16,
|
PrintOnAbilityPopUp(sText_Space16,
|
||||||
(void*)(OBJ_VRAM0) + (gSprites[spriteId1].oam.tileNum * 32) + 256,
|
(void*)(OBJ_VRAM0) + (gSprites[spriteId1].oam.tileNum * 32) + 256,
|
||||||
(void*)(OBJ_VRAM0) + (gSprites[spriteId2].oam.tileNum * 32) + 256,
|
(void*)(OBJ_VRAM0) + (gSprites[spriteId2].oam.tileNum * 32) + 256,
|
||||||
6, 1,
|
5, 12,
|
||||||
4,
|
4,
|
||||||
7, 9, 1,
|
7, 9, 1);
|
||||||
FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrintBattlerOnAbilityPopUp(u8 battlerId, u8 spriteId1, u8 spriteId2)
|
static void PrintBattlerOnAbilityPopUp(u8 battlerId, u8 spriteId1, u8 spriteId2)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
u8 lastChar;
|
u8 lastChar;
|
||||||
u8* name;
|
u8* textPtr;
|
||||||
u8 monName[POKEMON_NAME_LENGTH + 3] = {0};
|
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)
|
for (i = 0; i < POKEMON_NAME_LENGTH; ++i)
|
||||||
{
|
{
|
||||||
monName[i] = nick[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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
name = monName + i + 1;
|
textPtr = monName + i + 1;
|
||||||
if (*(name - 1) == EOS)
|
|
||||||
name--;
|
|
||||||
|
|
||||||
lastChar = *(name - 1);
|
if (*(textPtr - 1) == EOS)
|
||||||
name[0] = CHAR_SGL_QUOTE_RIGHT; // apostraphe
|
textPtr--;
|
||||||
name++;
|
|
||||||
|
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)
|
if (lastChar != CHAR_S && lastChar != CHAR_s)
|
||||||
{
|
{
|
||||||
name[0] = CHAR_s;
|
textPtr[0] = CHAR_s;
|
||||||
name++;
|
textPtr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
name[0] = EOS;
|
textPtr[0] = EOS;
|
||||||
|
|
||||||
PrintOnAbilityPopUp((const u8 *)monName,
|
PrintOnAbilityPopUp((const u8 *)monName,
|
||||||
(void*)(OBJ_VRAM0) + (gSprites[spriteId1].oam.tileNum * 32),
|
(void*)(OBJ_VRAM0) + (gSprites[spriteId1].oam.tileNum * 32),
|
||||||
(void*)(OBJ_VRAM0) + (gSprites[spriteId2].oam.tileNum * 32),
|
(void*)(OBJ_VRAM0) + (gSprites[spriteId2].oam.tileNum * 32),
|
||||||
7, 0,
|
5, 12,
|
||||||
0,
|
0,
|
||||||
2, 7, 1,
|
2, 7, 1);
|
||||||
FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrintAbilityOnAbilityPopUp(u32 ability, u8 spriteId1, u8 spriteId2)
|
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],
|
PrintOnAbilityPopUp(gAbilityNames[ability],
|
||||||
(void*)(OBJ_VRAM0) + (gSprites[spriteId1].oam.tileNum * 32) + 256,
|
(void*)(OBJ_VRAM0) + (gSprites[spriteId1].oam.tileNum * 32) + 256,
|
||||||
(void*)(OBJ_VRAM0) + (gSprites[spriteId2].oam.tileNum * 32) + 256,
|
(void*)(OBJ_VRAM0) + (gSprites[spriteId2].oam.tileNum * 32) + 256,
|
||||||
6, 0,
|
5, 12,
|
||||||
4,
|
4,
|
||||||
7, 9, 1,
|
7, 9, 1);
|
||||||
TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PIXEL_COORDS_TO_OFFSET(x, y)( \
|
#define PIXEL_COORDS_TO_OFFSET(x, y)( \
|
||||||
@ -3080,11 +3018,11 @@ static const u16 sOverwrittenPixelsTable[][2] =
|
|||||||
{PIXEL_COORDS_TO_OFFSET(8, 45), 8},
|
{PIXEL_COORDS_TO_OFFSET(8, 45), 8},
|
||||||
{PIXEL_COORDS_TO_OFFSET(8, 46), 8},
|
{PIXEL_COORDS_TO_OFFSET(8, 46), 8},
|
||||||
{PIXEL_COORDS_TO_OFFSET(8, 47), 8},
|
{PIXEL_COORDS_TO_OFFSET(8, 47), 8},
|
||||||
{PIXEL_COORDS_TO_OFFSET(8, 48), 8},
|
//{PIXEL_COORDS_TO_OFFSET(8, 48), 8},
|
||||||
{PIXEL_COORDS_TO_OFFSET(16, 45), 8},
|
{PIXEL_COORDS_TO_OFFSET(16, 45), 8},
|
||||||
{PIXEL_COORDS_TO_OFFSET(16, 46), 8},
|
{PIXEL_COORDS_TO_OFFSET(16, 46), 8},
|
||||||
{PIXEL_COORDS_TO_OFFSET(16, 47), 8},
|
{PIXEL_COORDS_TO_OFFSET(16, 47), 8},
|
||||||
{PIXEL_COORDS_TO_OFFSET(16, 48), 8},
|
//{PIXEL_COORDS_TO_OFFSET(16, 48), 8},
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline void CopyPixels(u8 *dest, const u8 *src, u32 pixelCount)
|
static inline void CopyPixels(u8 *dest, const u8 *src, u32 pixelCount)
|
||||||
@ -3155,35 +3093,33 @@ void CreateAbilityPopUp(u8 battlerId, u32 ability, bool32 isDoubleBattle)
|
|||||||
|
|
||||||
if ((battlerPosition & BIT_SIDE) == B_SIDE_PLAYER)
|
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][0] - ABILITY_POP_UP_POS_X_SLIDE,
|
||||||
coords[battlerPosition][1], 0);
|
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][0] - ABILITY_POP_UP_POS_X_SLIDE + ABILITY_POP_UP_POS_X_DIFF,
|
||||||
coords[battlerPosition][1], 0);
|
coords[battlerPosition][1], 1); //Appears below
|
||||||
|
|
||||||
gSprites[spriteId1].tOriginalX = coords[battlerPosition][0];
|
|
||||||
gSprites[spriteId2].tOriginalX = coords[battlerPosition][0] + ABILITY_POP_UP_POS_X_DIFF;
|
|
||||||
|
|
||||||
gSprites[spriteId1].tRightToLeft = TRUE;
|
gSprites[spriteId1].tRightToLeft = TRUE;
|
||||||
gSprites[spriteId2].tRightToLeft = TRUE;
|
gSprites[spriteId2].tRightToLeft = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
spriteId1 = CreateSprite(&sSpriteTemplate_AbilityPopUp1,
|
spriteId1 = CreateSprite(&sSpriteTemplate_AbilityPopUp,
|
||||||
coords[battlerPosition][0] + ABILITY_POP_UP_POS_X_SLIDE,
|
coords[battlerPosition][0] + ABILITY_POP_UP_POS_X_SLIDE,
|
||||||
coords[battlerPosition][1], 0);
|
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][0] + ABILITY_POP_UP_POS_X_SLIDE + ABILITY_POP_UP_POS_X_DIFF,
|
||||||
coords[battlerPosition][1], 0);
|
coords[battlerPosition][1], 1); //Appears below
|
||||||
|
|
||||||
gSprites[spriteId1].tOriginalX = coords[battlerPosition][0];
|
|
||||||
gSprites[spriteId2].tOriginalX = coords[battlerPosition][0] + ABILITY_POP_UP_POS_X_DIFF;
|
|
||||||
|
|
||||||
gSprites[spriteId1].tRightToLeft = FALSE;
|
gSprites[spriteId1].tRightToLeft = FALSE;
|
||||||
gSprites[spriteId2].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][0] = spriteId1;
|
||||||
gBattleStruct->abilityPopUpSpriteIds[battlerId][1] = spriteId2;
|
gBattleStruct->abilityPopUpSpriteIds[battlerId][1] = spriteId2;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user