Browse Source

refactor backgrounds (allow resolution change)

Laserlicht 8 months ago
parent
commit
de06de06b5

+ 12 - 3
client/mainmenu/CHighScoreScreen.cpp

@@ -45,8 +45,6 @@ CHighScoreScreen::CHighScoreScreen(HighScorePage highscorepage, int highlighted)
 	OBJECT_CONSTRUCTION;
 	pos = center(Rect(0, 0, 800, 600));
 
-	backgroundAroundMenu = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), Rect(-pos.x, -pos.y, GH.screenDimensions().x, GH.screenDimensions().y));
-
 	addHighScores();
 	addButtons();
 }
@@ -174,6 +172,12 @@ void CHighScoreScreen::buttonExitClick()
 	CMM->playMusic();
 }
 
+void CHighScoreScreen::showAll(Canvas & to)
+{
+	to.fillTexture(GH.renderHandler().loadImage(ImagePath::builtin("DiBoxBck"), EImageBlitMode::OPAQUE));
+	CWindowObject::showAll(to);
+}
+
 CHighScoreInputScreen::CHighScoreInputScreen(bool won, HighScoreCalculation calc, const StatisticDataSet & statistic)
 	: CWindowObject(BORDERED), won(won), calc(calc), stat(statistic)
 {
@@ -182,7 +186,6 @@ CHighScoreInputScreen::CHighScoreInputScreen(bool won, HighScoreCalculation calc
 	OBJECT_CONSTRUCTION;
 	pos = center(Rect(0, 0, 800, 600));
 
-	backgroundAroundMenu = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), Rect(-pos.x, -pos.y, GH.screenDimensions().x, GH.screenDimensions().y));
 	background = std::make_shared<TransparentFilledRectangle>(Rect(0, 0, pos.w, pos.h), Colors::BLACK);
 
 	if(won)
@@ -272,6 +275,12 @@ void CHighScoreInputScreen::show(Canvas & to)
 	CWindowObject::showAll(to);
 }
 
+void CHighScoreInputScreen::showAll(Canvas & to)
+{
+	to.fillTexture(GH.renderHandler().loadImage(ImagePath::builtin("DiBoxBck"), EImageBlitMode::OPAQUE));
+	CWindowObject::showAll(to);
+}
+
 void CHighScoreInputScreen::clickPressed(const Point & cursorPosition)
 {
 	if(statisticButton && statisticButton->pos.isInside(cursorPosition))

+ 2 - 2
client/mainmenu/CHighScoreScreen.h

@@ -39,11 +39,11 @@ private:
 	void buttonExitClick();
 
 	void showPopupWindow(const Point & cursorPosition) override;
+	void showAll(Canvas & to) override;
 
 	HighScorePage highscorepage;
 
 	std::shared_ptr<CPicture> background;
-	std::shared_ptr<CFilledTexture> backgroundAroundMenu;
 	std::vector<std::shared_ptr<CButton>> buttons;
 	std::vector<std::shared_ptr<CLabel>> texts;
 	std::vector<std::shared_ptr<CAnimImage>> images;
@@ -77,7 +77,6 @@ class CHighScoreInputScreen : public CWindowObject, public IVideoHolder
 	std::shared_ptr<CHighScoreInput> input;
 	std::shared_ptr<TransparentFilledRectangle> background;
 	std::shared_ptr<VideoWidgetBase> videoPlayer;
-	std::shared_ptr<CFilledTexture> backgroundAroundMenu;
 
 	std::shared_ptr<CButton> statisticButton;
 
@@ -95,4 +94,5 @@ public:
 	void clickPressed(const Point & cursorPosition) override;
 	void keyPressed(EShortcut key) override;
 	void show(Canvas & to) override;
+	void showAll(Canvas & to) override;
 };

+ 7 - 7
client/windows/GUIClasses.cpp

@@ -1685,15 +1685,12 @@ void CObjectListWindow::keyPressed(EShortcut key)
 }
 
 VideoWindow::VideoWindow(const VideoPath & video, const ImagePath & rim, bool showBackground, float scaleFactor, const std::function<void(bool skipped)> & closeCb)
-	: CWindowObject(BORDERED | SHADOW_DISABLED | NEEDS_ANIMATED_BACKGROUND), closeCb(closeCb)
+	: CWindowObject(BORDERED | SHADOW_DISABLED | NEEDS_ANIMATED_BACKGROUND), closeCb(closeCb), showBackground(showBackground)
 {
 	OBJECT_CONSTRUCTION;
 
 	addUsedEvents(LCLICK | KEYBOARD);
 
-	if(showBackground)
-		backgroundAroundWindow = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), Rect(0, 0, GH.screenDimensions().x, GH.screenDimensions().y));
-	
 	if(!rim.empty())
 	{
 		setBackground(rim);
@@ -1707,9 +1704,13 @@ VideoWindow::VideoWindow(const VideoPath & video, const ImagePath & rim, bool sh
 		pos = center(Rect(0, 0, videoPlayer->pos.w, videoPlayer->pos.h));
 		blackBackground->addBox(Point(0, 0), Point(videoPlayer->pos.w, videoPlayer->pos.h), Colors::BLACK);
 	}
+}
 
-	if(backgroundAroundWindow)
-		backgroundAroundWindow->pos.moveTo(Point(0, 0));
+void VideoWindow::showAll(Canvas & to)
+{
+	if(showBackground)
+		to.fillTexture(GH.renderHandler().loadImage(ImagePath::builtin("DiBoxBck"), EImageBlitMode::OPAQUE));
+	CWindowObject::showAll(to);
 }
 
 void VideoWindow::onVideoPlaybackFinished()
@@ -1717,7 +1718,6 @@ void VideoWindow::onVideoPlaybackFinished()
 	exit(false);
 }
 
-
 void VideoWindow::exit(bool skipped)
 {
 	close();

+ 2 - 0
client/windows/GUIClasses.h

@@ -517,6 +517,7 @@ class VideoWindow : public CWindowObject, public IVideoHolder
 	std::shared_ptr<VideoWidgetOnce> videoPlayer;
 	std::shared_ptr<CFilledTexture> backgroundAroundWindow;
 	std::shared_ptr<GraphicalPrimitiveCanvas> blackBackground;
+	bool showBackground;
 
 	std::function<void(bool)> closeCb;
 
@@ -528,4 +529,5 @@ public:
 	void clickPressed(const Point & cursorPosition) override;
 	void keyPressed(EShortcut key) override;
 	void notFocusedClick() override;
+	void showAll(Canvas & to) override;
 };