Easy Chat always shows words in uppercase

This commit is contained in:
Eduardo Quezada 2023-06-06 10:55:42 -04:00
parent a1a49cef8f
commit 49ffd4a2e9
5 changed files with 24 additions and 4 deletions

View File

@ -2,6 +2,7 @@
#include "string_util.h"
#include "text.h"
#include "strings.h"
#include "union_room_chat.h"
EWRAM_DATA u8 gStringVar1[0x100] = {0};
EWRAM_DATA u8 gStringVar2[0x100] = {0};
@ -779,3 +780,19 @@ void StripExtCtrlCodes(u8 *str)
}
str[destIndex] = EOS;
}
u8 *StringCopyUppercase(u8 *dest, const u8 *src)
{
while (*src != EOS)
{
if (*src >= CHAR_a && *src <= CHAR_z)
*dest = gCaseToggleTable[*src];
else
*dest = *src;
dest++;
src++;
}
*dest = EOS;
return dest;
}

View File

@ -42,5 +42,6 @@ u8 GetExtCtrlCodeLength(u8 code);
s32 StringCompareWithoutExtCtrlCodes(const u8 *str1, const u8 *str2);
void ConvertInternationalString(u8 *s, u8 language);
void StripExtCtrlCodes(u8 *str);
u8 *StringCopyUppercase(u8 *dest, const u8 *src);
#endif // GUARD_STRING_UTIL_H

View File

@ -4,4 +4,6 @@
void EnterUnionRoomChat(void);
void InitUnionRoomChatRegisteredTexts(void);
extern const u8 gCaseToggleTable[256];
#endif // GUARD_UNION_ROOM_CHAT_H

View File

@ -5224,7 +5224,7 @@ u8 *CopyEasyChatWord(u8 *dest, u16 easyChatWord)
{
u16 index = EC_INDEX(easyChatWord);
u8 groupId = EC_GROUP(easyChatWord);
resultStr = StringCopy(dest, GetEasyChatWord(groupId, index));
resultStr = StringCopyUppercase(dest, GetEasyChatWord(groupId, index));
}
else
{

View File

@ -335,7 +335,7 @@ static const u8 sKeyboardPageMaxRow[UNION_ROOM_KB_PAGE_COUNT] =
[UNION_ROOM_KB_PAGE_REGISTER] = 9
};
static const u8 sCaseToggleTable[256] = {
const u8 gCaseToggleTable[256] = {
[CHAR_A] = CHAR_a,
[CHAR_B] = CHAR_b,
[CHAR_C] = CHAR_c,
@ -1734,7 +1734,7 @@ static void SwitchCaseOfLastMessageCharacter(void)
str = GetLastCharOfMessagePtr();
if (*str != CHAR_EXTRA_SYMBOL)
{
character = sCaseToggleTable[*str];
character = gCaseToggleTable[*str];
if (character)
*str = character;
}
@ -1997,7 +1997,7 @@ static int GetShouldShowCaseToggleIcon(void)
{
u8 *str = GetLastCharOfMessagePtr();
u32 character = *str;
if (character > EOS || sCaseToggleTable[character] == character || sCaseToggleTable[character] == CHAR_SPACE)
if (character > EOS || gCaseToggleTable[character] == character || gCaseToggleTable[character] == CHAR_SPACE)
return 3; // Don't show
else
return 0; // Show