mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 19:47:35 +01:00
Clean up international_string_util
This commit is contained in:
parent
f2e0c9ec9d
commit
a950f9c771
@ -10,15 +10,15 @@ int GetStringCenterAlignXOffset(int fontId, const u8 *str, int totalWidth);
|
|||||||
int GetStringRightAlignXOffset(int fontId, const u8 *str, int totalWidth);
|
int GetStringRightAlignXOffset(int fontId, const u8 *str, int totalWidth);
|
||||||
int GetStringCenterAlignXOffsetWithLetterSpacing(int fontId, const u8 *str, int totalWidth, int letterSpacing);
|
int GetStringCenterAlignXOffsetWithLetterSpacing(int fontId, const u8 *str, int totalWidth, int letterSpacing);
|
||||||
int GetStringWidthDifference(int fontId, const u8 *str, int totalWidth, int letterSpacing);
|
int GetStringWidthDifference(int fontId, const u8 *str, int totalWidth, int letterSpacing);
|
||||||
int GetMaxWidthInMenuTable(const struct MenuAction *str, int arg1);
|
int GetMaxWidthInMenuTable(const struct MenuAction *actions, int numActions);
|
||||||
int sub_81DB3D8(const struct MenuAction *str, const u8* arg1, int arg2);
|
int GetMaxWidthInSubsetOfMenuTable(const struct MenuAction *actions, const u8* actionIds, int numActions);
|
||||||
int Intl_GetListMenuWidth(const struct ListMenuTemplate *listMenu);
|
int Intl_GetListMenuWidth(const struct ListMenuTemplate *listMenu);
|
||||||
void CopyMonCategoryText(int dexNum, u8 *dest);
|
void CopyMonCategoryText(int dexNum, u8 *dest);
|
||||||
u8 *sub_81DB494(u8 *str, int fontId, const u8 *str2, int totalStringWidth);
|
u8 *GetStringClearToWidth(u8 *dest, int fontId, const u8 *str, int totalStringWidth);
|
||||||
void PadNameString(u8 *dest, u8 padChar);
|
void PadNameString(u8 *dest, u8 padChar);
|
||||||
void ConvertInternationalPlayerNameStripChar(u8 *, u8);
|
void ConvertInternationalPlayerNameStripChar(u8 *, u8);
|
||||||
void ConvertInternationalContestantName(u8 *);
|
void ConvertInternationalContestantName(u8 *);
|
||||||
int sub_81DB604(u8 *);
|
int GetNicknameLanguage(u8 *);
|
||||||
void sub_81DB620(int windowId, int columnStart, int rowStart, int numFillTiles, int numRows);
|
void sub_81DB620(int windowId, int columnStart, int rowStart, int numFillTiles, int numRows);
|
||||||
|
|
||||||
#endif // GUARD_INTERNATIONAL_STRING_UTIL_H
|
#endif // GUARD_INTERNATIONAL_STRING_UTIL_H
|
||||||
|
@ -34,32 +34,32 @@ int GetStringWidthDifference(int fontId, const u8 *str, int totalWidth, int lett
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetMaxWidthInMenuTable(const struct MenuAction *str, int numActions)
|
int GetMaxWidthInMenuTable(const struct MenuAction *actions, int numActions)
|
||||||
{
|
{
|
||||||
int i, var;
|
int i, maxWidth;
|
||||||
|
|
||||||
for (var = 0, i = 0; i < numActions; i++)
|
for (maxWidth = 0, i = 0; i < numActions; i++)
|
||||||
{
|
{
|
||||||
int stringWidth = GetStringWidth(1, str[i].text, 0);
|
int stringWidth = GetStringWidth(1, actions[i].text, 0);
|
||||||
if (stringWidth > var)
|
if (stringWidth > maxWidth)
|
||||||
var = stringWidth;
|
maxWidth = stringWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ConvertPixelWidthToTileWidth(var);
|
return ConvertPixelWidthToTileWidth(maxWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sub_81DB3D8(const struct MenuAction *str, const u8* arg1, int arg2)
|
int GetMaxWidthInSubsetOfMenuTable(const struct MenuAction *actions, const u8* actionIds, int numActions)
|
||||||
{
|
{
|
||||||
int i, var;
|
int i, maxWidth;
|
||||||
|
|
||||||
for (var = 0, i = 0; i < arg2; i++)
|
for (maxWidth = 0, i = 0; i < numActions; i++)
|
||||||
{
|
{
|
||||||
int stringWidth = GetStringWidth(1, str[arg1[i]].text, 0);
|
int stringWidth = GetStringWidth(1, actions[actionIds[i]].text, 0);
|
||||||
if (stringWidth > var)
|
if (stringWidth > maxWidth)
|
||||||
var = stringWidth;
|
maxWidth = stringWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ConvertPixelWidthToTileWidth(var);
|
return ConvertPixelWidthToTileWidth(maxWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Intl_GetListMenuWidth(const struct ListMenuTemplate *listMenu)
|
int Intl_GetListMenuWidth(const struct ListMenuTemplate *listMenu)
|
||||||
@ -93,32 +93,29 @@ void CopyMonCategoryText(int dexNum, u8 *dest)
|
|||||||
StringCopy(str + 1, gText_Pokemon);
|
StringCopy(str + 1, gText_Pokemon);
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 *sub_81DB494(u8 *str, int fontId, const u8 *str2, int totalStringWidth)
|
u8 *GetStringClearToWidth(u8 *dest, int fontId, const u8 *str, int totalStringWidth)
|
||||||
{
|
{
|
||||||
u8 *buffer;
|
u8 *buffer;
|
||||||
int width;
|
int width;
|
||||||
int clearWidth;
|
int clearWidth;
|
||||||
|
|
||||||
if (str2)
|
if (str)
|
||||||
{
|
{
|
||||||
buffer = StringCopy(str, str2);
|
buffer = StringCopy(dest, str);
|
||||||
width = GetStringWidth(fontId, str2, 0);
|
width = GetStringWidth(fontId, str, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buffer = str;
|
buffer = dest;
|
||||||
width = 0;
|
width = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearWidth = totalStringWidth - width;
|
clearWidth = totalStringWidth - width;
|
||||||
if (clearWidth > 0)
|
if (clearWidth > 0)
|
||||||
{
|
{
|
||||||
*buffer = EXT_CTRL_CODE_BEGIN;
|
*(buffer++) = EXT_CTRL_CODE_BEGIN;
|
||||||
buffer++;
|
*(buffer++) = EXT_CTRL_CODE_CLEAR;
|
||||||
*buffer = EXT_CTRL_CODE_CLEAR;
|
*(buffer++) = clearWidth;
|
||||||
buffer++;
|
|
||||||
*buffer = clearWidth;
|
|
||||||
buffer++;
|
|
||||||
*buffer = EOS;
|
*buffer = EOS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +206,7 @@ void TVShowConvertInternationalString(u8 *dest, const u8 *src, int language)
|
|||||||
ConvertInternationalString(dest, language);
|
ConvertInternationalString(dest, language);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sub_81DB604(u8 *str)
|
int GetNicknameLanguage(u8 *str)
|
||||||
{
|
{
|
||||||
if (str[0] == EXT_CTRL_CODE_BEGIN && str[1] == EXT_CTRL_CODE_JPN)
|
if (str[0] == EXT_CTRL_CODE_BEGIN && str[1] == EXT_CTRL_CODE_JPN)
|
||||||
return LANGUAGE_JAPANESE;
|
return LANGUAGE_JAPANESE;
|
||||||
|
@ -396,7 +396,7 @@ static void InitPlayerPCMenu(u8 taskId)
|
|||||||
else // Bedroom PC
|
else // Bedroom PC
|
||||||
windowTemplate = sWindowTemplates_MainMenus[WIN_MAIN_MENU_BEDROOM];
|
windowTemplate = sWindowTemplates_MainMenus[WIN_MAIN_MENU_BEDROOM];
|
||||||
|
|
||||||
windowTemplate.width = sub_81DB3D8(sPlayerPCMenuActions, sTopMenuOptionOrder, sTopMenuNumOptions);
|
windowTemplate.width = GetMaxWidthInSubsetOfMenuTable(sPlayerPCMenuActions, sTopMenuOptionOrder, sTopMenuNumOptions);
|
||||||
tWindowId = AddWindow(&windowTemplate);
|
tWindowId = AddWindow(&windowTemplate);
|
||||||
SetStandardWindowBorderStyle(tWindowId, 0);
|
SetStandardWindowBorderStyle(tWindowId, 0);
|
||||||
sub_81995E4(tWindowId, sTopMenuNumOptions, sPlayerPCMenuActions, sTopMenuOptionOrder);
|
sub_81995E4(tWindowId, sTopMenuNumOptions, sPlayerPCMenuActions, sTopMenuOptionOrder);
|
||||||
|
@ -705,7 +705,7 @@ static void PrintSearchMonListItem(struct PokenavMonList * item, u8 * dest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
StringGetEnd10(gStringVar3);
|
StringGetEnd10(gStringVar3);
|
||||||
dest = sub_81DB494(dest, 1, gStringVar3, 60);
|
dest = GetStringClearToWidth(dest, 1, gStringVar3, 60);
|
||||||
switch (gender)
|
switch (gender)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
@ -723,5 +723,5 @@ static void PrintSearchMonListItem(struct PokenavMonList * item, u8 * dest)
|
|||||||
*s++ = CHAR_EXTRA_SYMBOL;
|
*s++ = CHAR_EXTRA_SYMBOL;
|
||||||
*s++ = CHAR_LV_2;
|
*s++ = CHAR_LV_2;
|
||||||
ConvertIntToDecimalStringN(s, level, STR_CONV_MODE_LEFT_ALIGN, 3);
|
ConvertIntToDecimalStringN(s, level, STR_CONV_MODE_LEFT_ALIGN, 3);
|
||||||
sub_81DB494(dest, 1, gStringVar1, 40);
|
GetStringClearToWidth(dest, 1, gStringVar1, 40);
|
||||||
}
|
}
|
||||||
|
@ -413,12 +413,12 @@ void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntries *matchCallEntry,
|
|||||||
|
|
||||||
if (className && trainerName)
|
if (className && trainerName)
|
||||||
{
|
{
|
||||||
u8 *str2 = sub_81DB494(str, 7, className, 69);
|
u8 *str2 = GetStringClearToWidth(str, 7, className, 69);
|
||||||
sub_81DB494(str2, 7, trainerName, 51);
|
GetStringClearToWidth(str2, 7, trainerName, 51);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sub_81DB494(str, 7, NULL, 120);
|
GetStringClearToWidth(str, 7, NULL, 120);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -722,7 +722,7 @@ static void BufferRibbonMonInfoText(struct PokenavMonList * item0, u8 * dest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
StringGetEnd10(gStringVar3);
|
StringGetEnd10(gStringVar3);
|
||||||
dest = sub_81DB494(dest, 1, gStringVar3, 60);
|
dest = GetStringClearToWidth(dest, 1, gStringVar3, 60);
|
||||||
switch (gender)
|
switch (gender)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
@ -741,6 +741,6 @@ static void BufferRibbonMonInfoText(struct PokenavMonList * item0, u8 * dest)
|
|||||||
*s++ = CHAR_EXTRA_SYMBOL;
|
*s++ = CHAR_EXTRA_SYMBOL;
|
||||||
*s++ = CHAR_LV_2;
|
*s++ = CHAR_LV_2;
|
||||||
ConvertIntToDecimalStringN(s, level, STR_CONV_MODE_LEFT_ALIGN, 3);
|
ConvertIntToDecimalStringN(s, level, STR_CONV_MODE_LEFT_ALIGN, 3);
|
||||||
dest = sub_81DB494(dest, 1, gStringVar1, 54);
|
dest = GetStringClearToWidth(dest, 1, gStringVar1, 54);
|
||||||
ConvertIntToDecimalStringN(dest, item->data, STR_CONV_MODE_RIGHT_ALIGN, 2);
|
ConvertIntToDecimalStringN(dest, item->data, STR_CONV_MODE_RIGHT_ALIGN, 2);
|
||||||
}
|
}
|
||||||
|
2
src/tv.c
2
src/tv.c
@ -1155,7 +1155,7 @@ void TryPutPokemonTodayOnAir(void)
|
|||||||
show->pokemonToday.ball = itemLastUsed;
|
show->pokemonToday.ball = itemLastUsed;
|
||||||
StringCopy(show->pokemonToday.playerName, gSaveBlock2Ptr->playerName);
|
StringCopy(show->pokemonToday.playerName, gSaveBlock2Ptr->playerName);
|
||||||
StringCopy(show->pokemonToday.nickname, gBattleResults.caughtMonNick);
|
StringCopy(show->pokemonToday.nickname, gBattleResults.caughtMonNick);
|
||||||
language2 = sub_81DB604(show->pokemonToday.nickname);
|
language2 = GetNicknameLanguage(show->pokemonToday.nickname);
|
||||||
StripExtCtrlCodes(show->pokemonToday.nickname);
|
StripExtCtrlCodes(show->pokemonToday.nickname);
|
||||||
show->pokemonToday.species = gBattleResults.caughtMonSpecies;
|
show->pokemonToday.species = gBattleResults.caughtMonSpecies;
|
||||||
StorePlayerIdInRecordMixShow(show);
|
StorePlayerIdInRecordMixShow(show);
|
||||||
|
Loading…
Reference in New Issue
Block a user