From 2c05b8683de553df325d56cf0758691aea1b6dc3 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Tue, 7 Jun 2022 23:41:24 +0300 Subject: [PATCH] Fix dialog display centering --- src/game_dialog.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/game_dialog.cc b/src/game_dialog.cc index 476b6a2..8d74ad4 100644 --- a/src/game_dialog.cc +++ b/src/game_dialog.cc @@ -4402,11 +4402,19 @@ void gameDialogRenderTalkingHead(Art* headFrm, int frame) } unsigned char* src = windowGetBuffer(gIsoWindow); + + // Usually rendering functions use `screenGetWidth`/`screenGetHeight` to + // determine rendering position. However in this case `windowGetHeight` + // is a must because isometric window's height can either include + // interface bar or not. Offset is updated accordingly (332 -> 232, the + // missing 100 is interface bar height, which is already accounted for + // when we're using `windowGetHeight`). `windowGetWidth` is used for + // consistency. blitBufferToBuffer( - src + ((GAME_DIALOG_WINDOW_WIDTH - 332) / 2) * (GAME_DIALOG_WINDOW_WIDTH) + (GAME_DIALOG_WINDOW_WIDTH - 388) / 2, + src + ((windowGetHeight(gIsoWindow) - 232) / 2) * windowGetWidth(gIsoWindow) + (windowGetWidth(gIsoWindow) - 388) / 2, 388, 200, - screenGetWidth(), + windowGetWidth(gIsoWindow), gGameDialogDisplayBuffer, GAME_DIALOG_WINDOW_WIDTH); }