From b36ac50425a13615471ef8b3bbae6b7a0a2da5a5 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Tue, 13 Dec 2022 10:37:52 +0300 Subject: [PATCH] Review windowShow --- src/game.cc | 2 +- src/game_dialog.cc | 6 +++--- src/interface.cc | 6 +++--- src/main.cc | 2 +- src/map.cc | 2 +- src/scripts.cc | 2 +- src/window_manager.cc | 47 ++++++++++++++++++++++--------------------- src/window_manager.h | 2 +- 8 files changed, 35 insertions(+), 34 deletions(-) diff --git a/src/game.cc b/src/game.cc index e23f76c..1e25c96 100644 --- a/src/game.cc +++ b/src/game.cc @@ -1172,7 +1172,7 @@ static void showHelp() if (backgroundFrmImage.lock(backgroundFid)) { paletteSetEntries(gPaletteBlack); blitBufferToBuffer(backgroundFrmImage.getData(), HELP_SCREEN_WIDTH, HELP_SCREEN_HEIGHT, HELP_SCREEN_WIDTH, windowBuffer, HELP_SCREEN_WIDTH); - windowUnhide(win); + windowShow(win); colorPaletteLoad("art\\intrface\\helpscrn.pal"); paletteSetEntries(_cmap); diff --git a/src/game_dialog.cc b/src/game_dialog.cc index 929281b..7e73867 100644 --- a/src/game_dialog.cc +++ b/src/game_dialog.cc @@ -1058,7 +1058,7 @@ void gameDialogRenderSupplementaryMessage(char* msg) 379, _colorTable[992] | 0x2000000); - windowUnhide(_gd_replyWin); + windowShow(_gd_replyWin); windowRefresh(gGameDialogReplyWindow); } @@ -1236,11 +1236,11 @@ static int gdHide() static int gdUnhide() { if (_gd_replyWin != -1) { - windowUnhide(_gd_replyWin); + windowShow(_gd_replyWin); } if (_gd_optionsWin != -1) { - windowUnhide(_gd_optionsWin); + windowShow(_gd_optionsWin); } return 0; diff --git a/src/interface.cc b/src/interface.cc index 82ac47f..2f7e104 100644 --- a/src/interface.cc +++ b/src/interface.cc @@ -797,7 +797,7 @@ void _intface_show() interfaceUpdateItems(false, INTERFACE_ITEM_ACTION_DEFAULT, INTERFACE_ITEM_ACTION_DEFAULT); interfaceRenderHitPoints(false); interfaceRenderArmorClass(false); - windowUnhide(gInterfaceBarWindow); + windowShow(gInterfaceBarWindow); sidePanelsShow(); _intfaceHidden = false; } @@ -2577,11 +2577,11 @@ static void sidePanelsHide() static void sidePanelsShow() { if (gInterfaceSidePanelsLeadingWindow != -1) { - windowUnhide(gInterfaceSidePanelsLeadingWindow); + windowShow(gInterfaceSidePanelsLeadingWindow); } if (gInterfaceSidePanelsTrailingWindow != -1) { - windowUnhide(gInterfaceSidePanelsTrailingWindow); + windowShow(gInterfaceSidePanelsTrailingWindow); } } diff --git a/src/main.cc b/src/main.cc index 9ddb0c5..03cf886 100644 --- a/src/main.cc +++ b/src/main.cc @@ -995,7 +995,7 @@ static void mainMenuWindowUnhide(bool animate) return; } - windowUnhide(gMainMenuWindow); + windowShow(gMainMenuWindow); if (animate) { colorPaletteLoad("color.pal"); diff --git a/src/map.cc b/src/map.cc index 90c2639..0c3ad1b 100644 --- a/src/map.cc +++ b/src/map.cc @@ -300,7 +300,7 @@ void _map_init() mapNewMap(); tickersAdd(gameMouseRefresh); _gmouse_disable(0); - windowUnhide(gIsoWindow); + windowShow(gIsoWindow); messageListRepositorySetStandardMessageList(STANDARD_MESSAGE_LIST_MAP, &gMapMessageList); } diff --git a/src/scripts.cc b/src/scripts.cc index 96fc6c8..80c1de1 100644 --- a/src/scripts.cc +++ b/src/scripts.cc @@ -470,7 +470,7 @@ int _scriptsCheckGameEvents(int* moviePtr, int window) gameMoviePlay(movie, movieFlags); if (window != -1) { - windowUnhide(window); + windowShow(window); } if (adjustRep) { diff --git a/src/window_manager.cc b/src/window_manager.cc index 3a72804..101186a 100644 --- a/src/window_manager.cc +++ b/src/window_manager.cc @@ -657,40 +657,41 @@ void windowFill(int win, int x, int y, int width, int height, int a6) } // 0x4D6DAC -void windowUnhide(int win) +void windowShow(int win) { - Window* window; - int v3; - int v5; - int v7; - Window* v6; - - window = windowGetWindow(win); - v3 = gWindowIndexes[window->id]; + Window* window = windowGetWindow(win); + int index = gWindowIndexes[window->id]; if (!gWindowSystemInitialized) { return; } - if (window->flags & WINDOW_HIDDEN) { + if ((window->flags & WINDOW_HIDDEN) != 0) { window->flags &= ~WINDOW_HIDDEN; - if (v3 == gWindowsLength - 1) { + if (index == gWindowsLength - 1) { _GNW_win_refresh(window, &(window->rect), NULL); } } - v5 = gWindowsLength - 1; - if (v3 < v5 && !(window->flags & WINDOW_DONT_MOVE_TOP)) { - v7 = v3; - while (v3 < v5 && ((window->flags & WINDOW_MOVE_ON_TOP) || !(gWindows[v7 + 1]->flags & WINDOW_MOVE_ON_TOP))) { - v6 = gWindows[v7 + 1]; - gWindows[v7] = v6; - v7++; - gWindowIndexes[v6->id] = v3++; + if (index < gWindowsLength - 1 && (window->flags & WINDOW_DONT_MOVE_TOP) == 0) { + while (index < gWindowsLength - 1) { + Window* nextWindow = gWindows[index + 1]; + if ((window->flags & WINDOW_MOVE_ON_TOP) == 0 && (nextWindow->flags & WINDOW_MOVE_ON_TOP) != 0) { + break; + } + + gWindows[index] = nextWindow; + gWindowIndexes[nextWindow->id] = index; + index++; } - gWindows[v3] = window; - gWindowIndexes[window->id] = v3; + gWindows[index] = window; + gWindowIndexes[window->id] = index; + _GNW_win_refresh(window, &(window->rect), NULL); + } else { + // SFALL: Fix for the window with the "DontMoveTop" flag not being + // redrawn after the show function call if it is not the topmost + // one. _GNW_win_refresh(window, &(window->rect), NULL); } } @@ -1016,7 +1017,7 @@ void _win_drag(int win) return; } - windowUnhide(win); + windowShow(win); Rect rect; rectCopy(&rect, &(window->rect)); @@ -1741,7 +1742,7 @@ int _GNW_check_buttons(Window* window, int* keyCodePtr) window->clickedButton = NULL; } } else { - windowUnhide(window->id); + windowShow(window->id); } if (prevHoveredButton != NULL) { diff --git a/src/window_manager.h b/src/window_manager.h index ea19315..2275b4d 100644 --- a/src/window_manager.h +++ b/src/window_manager.h @@ -158,7 +158,7 @@ void _win_text(int win, char** fileNameList, int fileNameListLength, int maxWidt void windowDrawLine(int win, int left, int top, int right, int bottom, int color); void windowDrawRect(int win, int left, int top, int right, int bottom, int color); void windowFill(int win, int x, int y, int width, int height, int a6); -void windowUnhide(int win); +void windowShow(int win); void windowHide(int win); void windowRefresh(int win); void windowRefreshRect(int win, const Rect* rect);