diff --git a/src/brogue/Buttons.c b/src/brogue/Buttons.c index 436da0b9..022aeddf 100644 --- a/src/brogue/Buttons.c +++ b/src/brogue/Buttons.c @@ -299,8 +299,8 @@ short processButtonInput(buttonState *state, boolean *canceled, rogueEvent *even drawButton(&(state->buttons[i]), BUTTON_PRESSED, &state->dbuf); // Update the display. - overlayDisplayBuffer(&state->rbuf, NULL); - overlayDisplayBuffer(&state->dbuf, NULL); + overlayDisplayBuffer(&state->rbuf); + overlayDisplayBuffer(&state->dbuf); if (!rogue.playbackMode || rogue.playbackPaused) { // Wait for a little; then we're done. @@ -359,7 +359,7 @@ short buttonInputLoop(brogueButton *buttons, do { // Update the display. - overlayDisplayBuffer(&state.dbuf, NULL); + overlayDisplayBuffer(&state.dbuf); // Get input. nextBrogueEvent(&theEvent, true, false, false); @@ -368,7 +368,7 @@ short buttonInputLoop(brogueButton *buttons, button = processButtonInput(&state, &canceled, &theEvent); // Revert the display. - overlayDisplayBuffer(&state.rbuf, NULL); + overlayDisplayBuffer(&state.rbuf); } while (button == -1 && !canceled); @@ -376,7 +376,7 @@ short buttonInputLoop(brogueButton *buttons, *returnEvent = theEvent; } - //overlayDisplayBuffer(dbuf, NULL); // hangs around + //overlayDisplayBuffer(dbuf); // hangs around restoreRNG; diff --git a/src/brogue/IO.c b/src/brogue/IO.c index 81d50375..47162412 100644 --- a/src/brogue/IO.c +++ b/src/brogue/IO.c @@ -174,7 +174,7 @@ static short actionMenu(short x, boolean playingBack) { brogueButton buttons[ROWS] = {{{0}}}; char yellowColorEscape[5] = "", whiteColorEscape[5] = "", darkGrayColorEscape[5] = ""; short i, j, longestName = 0, buttonChosen; - screenDisplayBuffer dbuf, rbuf; + screenDisplayBuffer dbuf; encodeMessageColor(yellowColorEscape, 0, &itemMessageColor); encodeMessageColor(whiteColorEscape, 0, &white); @@ -408,9 +408,12 @@ static short actionMenu(short x, boolean playingBack) { clearDisplayBuffer(&dbuf); rectangularShading(x - 1, y, longestName + 2, buttonCount, &black, INTERFACE_OPACITY / 2, &dbuf); - overlayDisplayBuffer(&dbuf, &rbuf); + ScreenLayerHandle layer = pushNewScreenLayer((ScreenLayerOptions) { + .name = "action menu", + }); + overlayDisplayBuffer(&dbuf); buttonChosen = buttonInputLoop(buttons, buttonCount, x - 1, y, longestName + 2, buttonCount, NULL); - overlayDisplayBuffer(&rbuf, NULL); + popScreenLayer(layer); if (buttonChosen == -1) { return -1; } else if (takeActionOurselves[buttonChosen]) { @@ -545,10 +548,9 @@ void mainInputLoop() { pos path[1000]; creature *monst; item *theItem; - screenDisplayBuffer rbuf; boolean canceled, targetConfirmed, tabKey, focusedOnMonster, focusedOnItem, focusedOnTerrain, - playingBack, doEvent, textDisplayed; + playingBack, doEvent; rogueEvent theEvent; short **costMap, **playerPathingMap, **cursorSnapMap; @@ -609,7 +611,10 @@ void mainInputLoop() { processSnapMap(cursorSnapMap); do { - textDisplayed = false; + // If text gets displayed, the layer will be stored in the handle provided, + // which must be popped from the screen before exiting this loop. + boolean textDisplayed = false; + ScreenLayerHandle textDisplayLayer = {0}; // Draw the cursor and path if (isPosInMap(oldTargetLoc)) { @@ -673,7 +678,11 @@ void mainInputLoop() { focusedOnMonster = true; if (monst != &player && (!player.status[STATUS_HALLUCINATING] || rogue.playbackOmniscience || player.status[STATUS_TELEPATHIC])) { - printMonsterDetails(monst, &rbuf); + + textDisplayLayer = pushNewScreenLayer((ScreenLayerOptions) { + .name = "monster text", + }); + printMonsterDetails(monst); textDisplayed = true; } } else if (theItem != NULL && playerCanSeeOrSense(rogue.cursorLoc.x, rogue.cursorLoc.y)) { @@ -683,7 +692,10 @@ void mainInputLoop() { focusedOnItem = true; if (!player.status[STATUS_HALLUCINATING] || rogue.playbackOmniscience) { - printFloorItemDetails(theItem, &rbuf); + textDisplayLayer = pushNewScreenLayer((ScreenLayerOptions) { + .name = "item text", + }); + printFloorItemDetails(theItem); textDisplayed = true; } } else if (cellHasTMFlag(rogue.cursorLoc.x, rogue.cursorLoc.y, TM_LIST_IN_SIDEBAR) && playerCanSeeOrSense(rogue.cursorLoc.x, rogue.cursorLoc.y)) { @@ -738,7 +750,7 @@ void mainInputLoop() { focusedOnItem = false; focusedOnTerrain = false; if (textDisplayed) { - overlayDisplayBuffer(&rbuf, NULL); // Erase the monster info window. + popScreenLayer(textDisplayLayer); } rogue.playbackMode = playingBack; refreshSideBar(-1, -1, false); @@ -1710,7 +1722,7 @@ void irisFadeBetweenBuffers(screenDisplayBuffer* fromBuf, fastForward = pauseAnimation(16); frame++; } while (frame <= frameCount && !fastForward); - overlayDisplayBuffer(toBuf, NULL); + overlayDisplayBuffer(toBuf); } // takes dungeon coordinates @@ -1972,15 +1984,11 @@ color colorFromComponents(char rgb[3]) { // draws overBuf over the current display with per-cell pseudotransparency as specified in overBuf. // If previousBuf is not null, it gets filled with the preexisting display for reversion purposes. -void overlayDisplayBuffer(screenDisplayBuffer *overBuf, screenDisplayBuffer *previousBuf) { +void overlayDisplayBuffer(screenDisplayBuffer *overBuf) { short i, j; color foreColor, backColor, tempColor; enum displayGlyph character; - if (previousBuf) { - copyDisplayBuffer(previousBuf, &displayBuffer); - } - for (i=0; i 0) { return buttonInputLoop(buttons, buttonCount, x2, y2, width, by - y2 + 1 + padLines, NULL); @@ -4995,20 +5058,22 @@ short printTextBox(char *textBuf, short x, short y, short width, } } -void printMonsterDetails(creature *monst, screenDisplayBuffer *rbuf) { +void printMonsterDetails(creature *monst) { char textBuf[COLS * 100]; monsterDetails(textBuf, monst); - printTextBox(textBuf, monst->loc.x, 0, 0, &white, &black, rbuf, NULL, 0); + printTextBox(textBuf, monst->loc.x, 0, 0, &white, &black, NULL, 0); } // Displays the item info box with the dark blue background. // If includeButtons is true, we include buttons for item actions. // Returns the key of an action to take, if any; otherwise -1. -unsigned long printCarriedItemDetails(item *theItem, - short x, short y, short width, - boolean includeButtons, - screenDisplayBuffer *rbuf) { +unsigned long printCarriedItemDetails( + item *theItem, + short x, short y, + short width, + boolean includeButtons +) { char textBuf[COLS * 100], goldColorEscape[5] = "", whiteColorEscape[5] = ""; brogueButton buttons[20] = {{{0}}}; short b; @@ -5075,7 +5140,7 @@ unsigned long printCarriedItemDetails(item *theItem, buttons[b].hotkey[2] = DOWN_ARROW; b++; } - b = printTextBox(textBuf, x, y, width, &white, &interfaceBoxColor, rbuf, buttons, b); + b = printTextBox(textBuf, x, y, width, &white, &interfaceBoxColor, buttons, b); if (!includeButtons) { waitForKeystrokeOrMouseClick(); @@ -5090,9 +5155,9 @@ unsigned long printCarriedItemDetails(item *theItem, } // Returns true if an action was taken. -void printFloorItemDetails(item *theItem, screenDisplayBuffer *rbuf) { +void printFloorItemDetails(item *theItem) { char textBuf[COLS * 100]; itemDetails(textBuf, theItem); - printTextBox(textBuf, theItem->loc.x, 0, 0, &white, &black, rbuf, NULL, 0); + printTextBox(textBuf, theItem->loc.x, 0, 0, &white, &black, NULL, 0); } diff --git a/src/brogue/Items.c b/src/brogue/Items.c index 0b2b64fa..0370d3b0 100644 --- a/src/brogue/Items.c +++ b/src/brogue/Items.c @@ -2703,7 +2703,6 @@ char displayInventory(unsigned short categoryMask, boolean magicDetected, repeatDisplay; short highlightItemLine, itemSpaceRemaining; screenDisplayBuffer dbuf; - screenDisplayBuffer rbuf; brogueButton buttons[50] = {{{0}}}; short actionKey = -1; color darkItemColor; @@ -2930,15 +2929,23 @@ char displayInventory(unsigned short categoryMask, buttons[itemNumber + extraLineCount + 1].hotkey[0] = NUMPAD_2; buttons[itemNumber + extraLineCount + 1].hotkey[1] = DOWN_ARROW; - overlayDisplayBuffer(&dbuf, &rbuf); + ScreenLayerHandle inventoryLayer = pushNewScreenLayer((ScreenLayerOptions) { + .name = "inventory", + }); + overlayDisplayBuffer(&dbuf); do { repeatDisplay = false; // Do the button loop. highlightItemLine = -1; - overlayDisplayBuffer(&rbuf, NULL); // Remove the inventory display while the buttons are active, - // since they look the same and we don't want their opacities to stack. + + // Remove the inventory display while the buttons are active, + // since they look the same and we don't want their opacities to stack. + popScreenLayer(inventoryLayer); + inventoryLayer = pushNewScreenLayer((ScreenLayerOptions) { + .name = "inventory", + }); highlightItemLine = buttonInputLoop(buttons, itemCount + extraLineCount + 2, // the 2 is for up/down hotkeys @@ -2970,7 +2977,7 @@ char displayInventory(unsigned short categoryMask, do { // Yes. Highlight the selected item. Do this by changing the button color and re-displaying it. - overlayDisplayBuffer(&dbuf, NULL); + overlayDisplayBuffer(&dbuf); //buttons[highlightItemLine].buttonColor = interfaceBoxColor; drawButton(&(buttons[highlightItemLine]), BUTTON_PRESSED, NULL); @@ -2978,17 +2985,24 @@ char displayInventory(unsigned short categoryMask, if (theEvent.shiftKey || theEvent.controlKey || waitForAcknowledge) { // Display an information window about the item. - actionKey = printCarriedItemDetails(theItem, max(2, mapToWindowX(DCOLS - maxLength - 42)), mapToWindowY(2), 40, includeButtons, NULL); + actionKey = printCarriedItemDetails(theItem, max(2, mapToWindowX(DCOLS - maxLength - 42)), mapToWindowY(2), 40, includeButtons); - overlayDisplayBuffer(&rbuf, NULL); // remove the item info window + // remove the item info window + popScreenLayer(inventoryLayer); + inventoryLayer = pushNewScreenLayer((ScreenLayerOptions) { + .name = "inventory", + }); if (actionKey == -1) { repeatDisplay = true; - overlayDisplayBuffer(&dbuf, NULL); // redisplay the inventory + overlayDisplayBuffer(&dbuf); // redisplay the inventory } else { restoreRNG; repeatDisplay = false; - overlayDisplayBuffer(&rbuf, NULL); // restore the original screen + popScreenLayer(inventoryLayer); + inventoryLayer = pushNewScreenLayer((ScreenLayerOptions) { + .name = "inventory", + }); // restore the original screen } switch (actionKey) { @@ -3035,6 +3049,7 @@ char displayInventory(unsigned short categoryMask, } else if (actionKey > -1) { // Player took an action directly from the item screen; we're done here. restoreRNG; + popScreenLayer(inventoryLayer); return 0; } } @@ -3042,7 +3057,8 @@ char displayInventory(unsigned short categoryMask, } } while (repeatDisplay); // so you can get info on multiple items sequentially - overlayDisplayBuffer(&rbuf, NULL); // restore the original screen + // restore the original screen + popScreenLayer(inventoryLayer); restoreRNG; return theKey; @@ -5260,7 +5276,7 @@ boolean moveCursor(boolean *targetConfirmed, if (state) { // Also running a button loop. // Update the display. - overlayDisplayBuffer(&state->dbuf, NULL); + overlayDisplayBuffer(&state->dbuf); // Get input. nextBrogueEvent(&theEvent, false, colorsDance, true); @@ -5274,7 +5290,7 @@ boolean moveCursor(boolean *targetConfirmed, } // Revert the display. - overlayDisplayBuffer(&state->rbuf, NULL); + overlayDisplayBuffer(&state->rbuf); } else { // No buttons to worry about. nextBrogueEvent(&theEvent, false, colorsDance, true); diff --git a/src/brogue/MainMenu.c b/src/brogue/MainMenu.c index 4cf2f5c3..bd22ca3e 100644 --- a/src/brogue/MainMenu.c +++ b/src/brogue/MainMenu.c @@ -402,12 +402,13 @@ static void chooseGameVariant() { append(textBuf, "Die faster and more often in this quarter-length version of the classic game!\n\n", TEXT_MAX_LENGTH); brogueButton buttons[2]; - screenDisplayBuffer rbuf; - copyDisplayBuffer(&rbuf, &displayBuffer); + ScreenLayerHandle menuButtonLayer = pushNewScreenLayer((ScreenLayerOptions) { + .name = "game variant", + }); initializeMainMenuButton(&(buttons[0]), " %sR%sapid Brogue ", 'r', 'R', NG_NOTHING); initializeMainMenuButton(&(buttons[1]), " %sB%srogue ", 'b', 'B', NG_NOTHING); - gameVariantChoice = printTextBox(textBuf, 20, 7, 45, &white, &black, &rbuf, buttons, 2); - overlayDisplayBuffer(&rbuf, NULL); + gameVariantChoice = printTextBox(textBuf, 20, 7, 45, &white, &black, buttons, 2); + popScreenLayer(menuButtonLayer); if (gameVariantChoice == 1) { gameVariant = VARIANT_BROGUE; @@ -442,13 +443,14 @@ static void chooseGameMode() { "(Your score is not saved.)", TEXT_MAX_LENGTH); brogueButton buttons[3]; - screenDisplayBuffer rbuf; - copyDisplayBuffer(&rbuf, &displayBuffer); + ScreenLayerHandle difficultyLayer = pushNewScreenLayer((ScreenLayerOptions) { + .name = "game difficulty", + }); initializeMainMenuButton(&(buttons[0]), " %sW%sizard ", 'w', 'W', NG_NOTHING); initializeMainMenuButton(&(buttons[1]), " %sE%sasy ", 'e', 'E', NG_NOTHING); initializeMainMenuButton(&(buttons[2]), " %sN%sormal ", 'n', 'N', NG_NOTHING); - gameMode = printTextBox(textBuf, 10, 5, 66, &white, &black, &rbuf, buttons, 3); - overlayDisplayBuffer(&rbuf, NULL); + gameMode = printTextBox(textBuf, 10, 5, 66, &white, &black, buttons, 3); + popScreenLayer(difficultyLayer); if (gameMode == 0) { rogue.wizard = true; rogue.easyMode = false; @@ -554,18 +556,18 @@ static void titleMenu() { do { if (isApplicationActive()) { // Revert the display. - overlayDisplayBuffer(&mainMenu.rbuf, NULL); + overlayDisplayBuffer(&mainMenu.rbuf); // Update the display. updateMenuFlames(colors, colorSources, flames); drawMenuFlames(flames, mask); - overlayDisplayBuffer(&mainShadowBuf, NULL); - overlayDisplayBuffer(&mainMenu.dbuf, NULL); + overlayDisplayBuffer(&mainShadowBuf); + overlayDisplayBuffer(&mainMenu.dbuf); //Show flyout if selected if (isFlyoutActive()) { - overlayDisplayBuffer(&flyoutShadowBuf, NULL); - overlayDisplayBuffer(&flyoutMenu.dbuf, NULL); + overlayDisplayBuffer(&flyoutShadowBuf); + overlayDisplayBuffer(&flyoutMenu.dbuf); } // Pause briefly. if (pauseBrogue(MENU_FLAME_UPDATE_DELAY)) { @@ -629,15 +631,17 @@ int quitImmediately() { } void dialogAlert(char *message) { - screenDisplayBuffer rbuf; brogueButton OKButton; initializeButton(&OKButton); strcpy(OKButton.text, " OK "); OKButton.hotkey[0] = RETURN_KEY; OKButton.hotkey[1] = ACKNOWLEDGE_KEY; - printTextBox(message, COLS/3, ROWS/3, COLS/3, &white, &interfaceBoxColor, &rbuf, &OKButton, 1); - overlayDisplayBuffer(&rbuf, NULL); + ScreenLayerHandle dialogLayer = pushNewScreenLayer((ScreenLayerOptions) { + .name = "alert", + }); + printTextBox(message, COLS/3, ROWS/3, COLS/3, &white, &interfaceBoxColor, &OKButton, 1); + popScreenLayer(dialogLayer); } static boolean stringsExactlyMatch(const char *string1, const char *string2) { @@ -801,7 +805,7 @@ boolean dialogChooseFile(char *path, const char *suffix, const char *prompt) { clearDisplayBuffer(&dbuf); printString(prompt, x, y - 1, &itemMessageColor, dialogColor, &dbuf); rectangularShading(x - 1, y - 1, width + 1, height + 1, dialogColor, INTERFACE_OPACITY, &dbuf); - overlayDisplayBuffer(&dbuf, NULL); + overlayDisplayBuffer(&dbuf); // for (j=0; j= 0) { diff --git a/src/brogue/Recordings.c b/src/brogue/Recordings.c index 0102cc9f..0ed56080 100644 --- a/src/brogue/Recordings.c +++ b/src/brogue/Recordings.c @@ -302,8 +302,6 @@ If this is a different computer from the one on which the recording was saved, t might succeed on the original computer." static void playbackPanic() { - screenDisplayBuffer rbuf; - if (!rogue.playbackOOS) { rogue.playbackFastForward = false; rogue.playbackPaused = true; @@ -316,13 +314,25 @@ static void playbackPanic() { confirmMessages(); message("Playback is out of sync.", 0); - printTextBox(OOS_APOLOGY, 0, 0, 0, &white, &black, &rbuf, NULL, 0); + // If the platform shows the output directly in the console, + // then a simple 'printf' will paint over the screen. + // Therefore, we push an additional layer in order to fix the screen + // after the printf statement: + + ScreenLayerHandle panicLayer1 = pushNewScreenLayer((ScreenLayerOptions) { + .name = "panic1", + }); + ScreenLayerHandle panicLayer2 = pushNewScreenLayer((ScreenLayerOptions) { + .name = "panic2", + }); + + printTextBox(OOS_APOLOGY, 0, 0, 0, &white, &black, NULL, 0); rogue.playbackMode = false; displayMoreSign(); rogue.playbackMode = true; - overlayDisplayBuffer(&rbuf, NULL); + popScreenLayer(panicLayer2); if (nonInteractivePlayback) { rogue.gameHasEnded = true; @@ -330,7 +340,8 @@ static void playbackPanic() { rogue.gameExitStatusCode = EXIT_STATUS_FAILURE_RECORDING_OOS; printf("Playback panic at location %li! Turn number %li.\n", recordingLocation - 1, rogue.playerTurnNumber); - overlayDisplayBuffer(&rbuf, NULL); + + popScreenLayer(panicLayer1); mainInputLoop(); } @@ -432,7 +443,6 @@ static void loadNextAnnotation() { } void displayAnnotation() { - screenDisplayBuffer rbuf; if (rogue.playbackMode && rogue.playerTurnNumber == rogue.nextAnnotationTurn) { @@ -440,13 +450,16 @@ void displayAnnotation() { if (!rogue.playbackFastForward) { refreshSideBar(-1, -1, false); - printTextBox(rogue.nextAnnotation, player.loc.x, 0, 0, &black, &white, &rbuf, NULL, 0); + ScreenLayerHandle annotationLayer = pushNewScreenLayer((ScreenLayerOptions) { + .name = "annotation", + }); + printTextBox(rogue.nextAnnotation, player.loc.x, 0, 0, &black, &white, NULL, 0); rogue.playbackMode = false; displayMoreSign(); rogue.playbackMode = true; - overlayDisplayBuffer(&rbuf, NULL); + popScreenLayer(annotationLayer); } loadNextAnnotation(); @@ -639,7 +652,6 @@ static boolean unpause() { static void printPlaybackHelpScreen() { short i, j; screenDisplayBuffer dbuf; - screenDisplayBuffer rbuf; char helpText[PLAYBACK_HELP_LINE_COUNT][80] = { "Commands:", "", @@ -683,12 +695,16 @@ static void printPlaybackHelpScreen() { dbuf.cells[i][j].opacity = (i < STAT_BAR_WIDTH ? 0 : INTERFACE_OPACITY); } } - overlayDisplayBuffer(&dbuf, &rbuf); + + ScreenLayerHandle ackLayer = pushNewScreenLayer((ScreenLayerOptions) { + .name = "playback help acknowledge", + }); + overlayDisplayBuffer(&dbuf); rogue.playbackMode = false; waitForAcknowledgment(); rogue.playbackMode = true; - overlayDisplayBuffer(&rbuf, NULL); + popScreenLayer(ackLayer); } static void resetPlayback() { @@ -765,7 +781,7 @@ static void seek(unsigned long seekTarget, enum recordingSeekModes seekMode) { if (useProgressBar) { clearDisplayBuffer(&dbuf); rectangularShading((COLS - 20) / 2, ROWS / 2, 20, 1, &black, INTERFACE_OPACITY, &dbuf); - overlayDisplayBuffer(&dbuf, NULL); + overlayDisplayBuffer(&dbuf); commitDraws(); } rogue.playbackFastForward = true; @@ -1356,7 +1372,7 @@ boolean loadSavedGame() { clearDisplayBuffer(&dbuf); rectangularShading((COLS - 20) / 2, ROWS / 2, 20, 1, &black, INTERFACE_OPACITY, &dbuf); rogue.playbackFastForward = false; - overlayDisplayBuffer(&dbuf, NULL); + overlayDisplayBuffer(&dbuf); rogue.playbackFastForward = true; while (recordingLocation < lengthOfPlaybackFile diff --git a/src/brogue/Rogue.h b/src/brogue/Rogue.h index 4445edfc..ad1c32e0 100644 --- a/src/brogue/Rogue.h +++ b/src/brogue/Rogue.h @@ -1298,6 +1298,16 @@ typedef struct screenDisplayBuffer { cellDisplayBuffer cells[COLS][ROWS]; } screenDisplayBuffer; +typedef struct ScreenLayerHandle { + int index; + uint64_t uniqueId; +} ScreenLayerHandle; + +typedef struct ScreenLayerOptions { + // The name of a layer is just intended to be used for debugging. + char name[32]; +} ScreenLayerOptions; + typedef struct pcell { // permanent cell; have to remember this stuff to save levels enum tileType layers[NUMBER_TERRAIN_LAYERS]; // terrain unsigned long flags; // non-terrain cell flags @@ -2921,15 +2931,13 @@ extern "C" { const color *backColor, short opacity, screenDisplayBuffer *dbuf); short printTextBox(char *textBuf, short x, short y, short width, const color *foreColor, const color *backColor, - screenDisplayBuffer *rbuf, brogueButton *buttons, short buttonCount); void setButtonText(brogueButton *button, const char *textWithHotkey, const char *textWithoutHotkey); - void printMonsterDetails(creature *monst, screenDisplayBuffer* rbuf); - void printFloorItemDetails(item *theItem, screenDisplayBuffer* rbuf); + void printMonsterDetails(creature *monst); + void printFloorItemDetails(item *theItem); unsigned long printCarriedItemDetails(item *theItem, short x, short y, short width, - boolean includeButtons, - screenDisplayBuffer* rbuf); + boolean includeButtons); void funkyFade(screenDisplayBuffer *displayBuf, const color *colorStart, const color *colorEnd, short stepCount, short x, short y, boolean invert); void displayCenteredAlert(char *message); void flashMessage(char *message, short x, short y, int time, const color *fColor, const color *bColor); @@ -2966,7 +2974,10 @@ extern "C" { void copyDisplayBuffer(screenDisplayBuffer *toBuf, screenDisplayBuffer *fromBuf); void clearDisplayBuffer(screenDisplayBuffer *dbuf); color colorFromComponents(char rgb[3]); - void overlayDisplayBuffer(screenDisplayBuffer *overBuf, screenDisplayBuffer *previousBuf); + + ScreenLayerHandle pushNewScreenLayer(ScreenLayerOptions options); + void popScreenLayer(ScreenLayerHandle layer); + void overlayDisplayBuffer(screenDisplayBuffer *overBuf); void flashForeground(short *x, short *y, const color **flashColor, short *flashStrength, short count, short frames); void flashCell(const color *theColor, short frames, short x, short y); void colorFlash(const color *theColor, unsigned long reqTerrainFlags, unsigned long reqTileFlags, short frames, short maxRadius, short x, short y); diff --git a/src/brogue/Wizard.c b/src/brogue/Wizard.c index 42596675..08adb50b 100644 --- a/src/brogue/Wizard.c +++ b/src/brogue/Wizard.c @@ -44,7 +44,6 @@ static short dialogSelectEntryFromList( short x=0, y=0, width=0, height=0; screenDisplayBuffer dbuf; - screenDisplayBuffer rbuf; short i, selectedButton, len, maxLen; char buttonText[COLS]; @@ -78,11 +77,14 @@ static short dialogSelectEntryFromList( //Dialog background rectangularShading(x - 1, y - 1, width + 1, height + 1, &interfaceBoxColor, INTERFACE_OPACITY, &dbuf); //Display the title/background and save the prior display state - overlayDisplayBuffer(&dbuf, &rbuf); + ScreenLayerHandle buttonLayer = pushNewScreenLayer((ScreenLayerOptions) { + .name = "dialog select", + }); + overlayDisplayBuffer(&dbuf); //Display the buttons and wait for user selection selectedButton = buttonInputLoop(buttons, buttonCount, x, y, width, height, NULL); //Revert the display state - overlayDisplayBuffer(&rbuf, NULL); + popScreenLayer(buttonLayer); return selectedButton; }