Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve line breaks/scrolls #5641

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/battle_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -3340,6 +3340,7 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst, u32 dstSize)
u8 fontId = FONT_NORMAL;
s16 letterSpacing = 0;
u32 lineNum = 1;
u32 displayedLineNums = 1;

if (gBattleTypeFlags & BATTLE_TYPE_RECORDED_LINK)
multiplayerId = gRecordedBattleMultiplayerId;
Expand Down Expand Up @@ -3753,8 +3754,12 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst, u32 dstSize)

if (dstWidth + toCpyWidth > BATTLE_MSG_MAX_WIDTH)
{
dst[lastValidSkip] = lineNum == 1 ? CHAR_NEWLINE : CHAR_PROMPT_SCROLL;
dst[lastValidSkip] = displayedLineNums == 1 ? CHAR_NEWLINE : CHAR_PROMPT_SCROLL;
dstWidth = GetStringLineWidth(fontId, dst, letterSpacing, lineNum, dstSize);
if (displayedLineNums == 1)
displayedLineNums++;
else
displayedLineNums = 1;
lineNum++;
}
while (*toCpy != EOS)
Expand All @@ -3780,15 +3785,20 @@ u32 BattleStringExpandPlaceholders(const u8 *src, u8 *dst, u32 dstSize)
dst[dstID] = *src;
if (dstWidth + toCpyWidth > BATTLE_MSG_MAX_WIDTH)
{
dst[lastValidSkip] = lineNum == 1 ? CHAR_NEWLINE : CHAR_PROMPT_SCROLL;
dst[lastValidSkip] = displayedLineNums == 1 ? CHAR_NEWLINE : CHAR_PROMPT_SCROLL;
if (displayedLineNums == 1)
displayedLineNums++;
else
displayedLineNums = 1;
lineNum++;
dstWidth = 0;
}
switch (*src)
{
case CHAR_NEWLINE:
case CHAR_PROMPT_SCROLL:
case CHAR_PROMPT_CLEAR:
case CHAR_PROMPT_SCROLL:
displayedLineNums = 1;
case CHAR_NEWLINE:
lineNum++;
dstWidth = 0;
//fallthrough
Expand Down
Loading