From fc50482b43c3f6070f34fa4e1c9b5d2ec546a59a Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Sat, 18 May 2024 19:58:51 +0200 Subject: [PATCH] background for multiple windows --- client/mainmenu/CHighScoreScreen.cpp | 18 +++++++++++++++--- client/mainmenu/CHighScoreScreen.h | 3 +++ client/mainmenu/CPrologEpilogVideo.cpp | 4 +++- client/mainmenu/CPrologEpilogVideo.h | 2 ++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/client/mainmenu/CHighScoreScreen.cpp b/client/mainmenu/CHighScoreScreen.cpp index c099b5335..f26c3fd78 100644 --- a/client/mainmenu/CHighScoreScreen.cpp +++ b/client/mainmenu/CHighScoreScreen.cpp @@ -21,6 +21,7 @@ #include "../windows/InfoWindows.h" #include "../widgets/TextControls.h" #include "../render/Canvas.h" +#include "../render/IRenderHandler.h" #include "../CGameInfo.h" #include "../CVideoHandler.h" @@ -81,7 +82,8 @@ CHighScoreScreen::CHighScoreScreen(HighScorePage highscorepage, int highlighted) OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; pos = center(Rect(0, 0, 800, 600)); - updateShadow(); + + backgroundAroundMenu = std::make_shared(ImagePath::builtin("DIBOXBCK"), Rect(-pos.x, -pos.y, GH.screenDimensions().x, GH.screenDimensions().y)); addHighScores(); addButtons(); @@ -222,8 +224,8 @@ CHighScoreInputScreen::CHighScoreInputScreen(bool won, HighScoreCalculation calc OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; pos = center(Rect(0, 0, 800, 600)); - updateShadow(); + backgroundAroundMenu = std::make_shared(ImagePath::builtin("DIBOXBCK"), Rect(-pos.x, -pos.y, GH.screenDimensions().x, GH.screenDimensions().y)); background = std::make_shared(Rect(0, 0, pos.w, pos.h), Colors::BLACK); if(won) @@ -289,6 +291,9 @@ int CHighScoreInputScreen::addEntry(std::string text) { void CHighScoreInputScreen::show(Canvas & to) { + if(background) + background->redraw(); + CCS->videoh->update(pos.x, pos.y, to.getInternalSurface(), true, false, [&]() { @@ -303,7 +308,14 @@ void CHighScoreInputScreen::show(Canvas & to) else close(); }); - redraw(); + + if(input) + input->redraw(); + for(auto & text : texts) + { + text->setRedrawParent(false); + text->redraw(); + } CIntObject::show(to); } diff --git a/client/mainmenu/CHighScoreScreen.h b/client/mainmenu/CHighScoreScreen.h index 2261dbe60..50e8b290f 100644 --- a/client/mainmenu/CHighScoreScreen.h +++ b/client/mainmenu/CHighScoreScreen.h @@ -15,6 +15,7 @@ class CLabel; class CMultiLineLabel; class CAnimImage; class CTextInput; +class CFilledTexture; class TransparentFilledRectangle; @@ -61,6 +62,7 @@ private: HighScorePage highscorepage; std::shared_ptr background; + std::shared_ptr backgroundAroundMenu; std::vector> buttons; std::vector> texts; std::vector> images; @@ -93,6 +95,7 @@ class CHighScoreInputScreen : public CWindowObject std::vector> texts; std::shared_ptr input; std::shared_ptr background; + std::shared_ptr backgroundAroundMenu; std::string video; int videoSoundHandle; diff --git a/client/mainmenu/CPrologEpilogVideo.cpp b/client/mainmenu/CPrologEpilogVideo.cpp index af1d77a72..b1a7e1dad 100644 --- a/client/mainmenu/CPrologEpilogVideo.cpp +++ b/client/mainmenu/CPrologEpilogVideo.cpp @@ -18,6 +18,7 @@ #include "../gui/CGuiHandler.h" #include "../gui/FramerateManager.h" #include "../widgets/TextControls.h" +#include "../widgets/Images.h" #include "../render/Canvas.h" @@ -27,7 +28,8 @@ CPrologEpilogVideo::CPrologEpilogVideo(CampaignScenarioPrologEpilog _spe, std::f OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; addUsedEvents(LCLICK | TIME); pos = center(Rect(0, 0, 800, 600)); - updateShadow(); + + backgroundAroundMenu = std::make_shared(ImagePath::builtin("DIBOXBCK"), Rect(-pos.x, -pos.y, GH.screenDimensions().x, GH.screenDimensions().y)); auto audioData = CCS->videoh->getAudio(spe.prologVideo); videoSoundHandle = CCS->soundh->playSound(audioData, -1); diff --git a/client/mainmenu/CPrologEpilogVideo.h b/client/mainmenu/CPrologEpilogVideo.h index 5923791d5..69dad8597 100644 --- a/client/mainmenu/CPrologEpilogVideo.h +++ b/client/mainmenu/CPrologEpilogVideo.h @@ -13,6 +13,7 @@ #include "../../lib/campaign/CampaignScenarioPrologEpilog.h" class CMultiLineLabel; +class CFilledTexture; class CPrologEpilogVideo : public CWindowObject { @@ -25,6 +26,7 @@ class CPrologEpilogVideo : public CWindowObject std::function exitCb; std::shared_ptr text; + std::shared_ptr backgroundAroundMenu; bool voiceStopped = false;