Clear out text printer when closing dialogue windows (#8848)

Co-authored-by: Hedara <hedara90@gmail.com>
This commit is contained in:
hedara90 2026-01-09 19:46:40 +01:00 committed by GitHub
parent f32883f38a
commit 9a09de66dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -282,6 +282,7 @@ void DrawStdWindowFrame(u8 windowId, bool8 copyToVram)
void ClearDialogWindowAndFrame(u8 windowId, bool8 copyToVram)
{
DeactivateSingleTextPrinter(windowId, WINDOW_TEXT_PRINTER);
CallWindowFunction(windowId, WindowFunc_ClearDialogWindowAndFrame);
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
ClearWindowTilemap(windowId);

View File

@ -2747,6 +2747,8 @@ static void FreeFinishedTextPrinters(void)
void DeactivateSingleTextPrinter(u32 id, enum TextPrinterType type)
{
struct TextPrinter *currentPrinter = sFirstTextPrinter;
bool32 foundPrinter = FALSE;
// This loop cannot exit early because a single window/sprite group can have multiple printers attached to it
while (currentPrinter != NULL)
{
switch (type)
@ -2756,6 +2758,7 @@ void DeactivateSingleTextPrinter(u32 id, enum TextPrinterType type)
{
currentPrinter->isInUse = FALSE;
currentPrinter = NULL;
foundPrinter = TRUE;
}
else
{
@ -2763,10 +2766,11 @@ void DeactivateSingleTextPrinter(u32 id, enum TextPrinterType type)
}
break;
case SPRITE_TEXT_PRINTER:
if (currentPrinter->printerTemplate.type == SPRITE_TEXT_PRINTER && currentPrinter->printerTemplate.spriteId == id)
if (currentPrinter->printerTemplate.type == SPRITE_TEXT_PRINTER && currentPrinter->printerTemplate.firstSprite == id)
{
currentPrinter->isInUse = FALSE;
currentPrinter = NULL;
foundPrinter = TRUE;
}
else
{
@ -2776,5 +2780,6 @@ void DeactivateSingleTextPrinter(u32 id, enum TextPrinterType type)
}
}
FreeFinishedTextPrinters();
if (foundPrinter)
FreeFinishedTextPrinters();
}