2
0
Эх сурвалжийг харах

rename and move window class

Laserlicht 1 жил өмнө
parent
commit
21c3cf0960

+ 2 - 1
client/CServerHandler.cpp

@@ -23,6 +23,7 @@
 #include "lobby/CLobbyScreen.h"
 #include "lobby/CBonusSelection.h"
 #include "windows/InfoWindows.h"
+#include "windows/GUIClasses.h"
 #include "media/CMusicHandler.h"
 #include "media/IVideoPlayer.h"
 
@@ -711,7 +712,7 @@ void CServerHandler::startCampaignScenario(HighScoreParameter param, std::shared
 			if(!ourCampaign->getOutroVideo().empty() && CCS->videoh->open(ourCampaign->getOutroVideo(), 1))
 			{
 				CCS->musich->stopMusic();
-				GH.windows().createAndPushWindow<CampaignRimVideo>(ourCampaign->getOutroVideo(), ourCampaign->getVideoRim().empty() ? ImagePath::builtin("INTRORIM") : ourCampaign->getVideoRim(), false, 1, [campaignScoreCalculator, statistic](bool skipped){
+				GH.windows().createAndPushWindow<VideoWindow>(ourCampaign->getOutroVideo(), ourCampaign->getVideoRim().empty() ? ImagePath::builtin("INTRORIM") : ourCampaign->getVideoRim(), false, 1, [campaignScoreCalculator, statistic](bool skipped){
 					GH.windows().createAndPushWindow<CHighScoreInputScreen>(true, *campaignScoreCalculator, statistic);
 				});
 			}

+ 2 - 1
client/NetPacksLobbyClient.cpp

@@ -33,6 +33,7 @@
 #include "widgets/TextControls.h"
 #include "media/CMusicHandler.h"
 #include "media/IVideoPlayer.h"
+#include "windows/GUIClasses.h"
 
 #include "../lib/CConfigHandler.h"
 #include "../lib/texts/CGeneralTextHandler.h"
@@ -210,7 +211,7 @@ void ApplyOnLobbyScreenNetPackVisitor::visitLobbyUpdateState(LobbyUpdateState &
 		if(!handler.si->campState->conqueredScenarios().size() && !handler.si->campState->getIntroVideo().empty() && CCS->videoh->open(handler.si->campState->getIntroVideo(), 1))
 		{
 			CCS->musich->stopMusic();
-			GH.windows().createAndPushWindow<CampaignRimVideo>(handler.si->campState->getIntroVideo(), handler.si->campState->getVideoRim().empty() ? ImagePath::builtin("INTRORIM") : handler.si->campState->getVideoRim(), false, 1, [bonusSel](bool skipped){
+			GH.windows().createAndPushWindow<VideoWindow>(handler.si->campState->getIntroVideo(), handler.si->campState->getVideoRim().empty() ? ImagePath::builtin("INTRORIM") : handler.si->campState->getVideoRim(), false, 1, [bonusSel](bool skipped){
 				if(!CSH->si->campState->getMusic().empty())
 					CCS->musich->playMusic(CSH->si->campState->getMusic(), true, false);
 				GH.windows().pushWindow(bonusSel);

+ 0 - 48
client/lobby/CBonusSelection.cpp

@@ -58,54 +58,6 @@
 
 #include "../../lib/mapObjects/CGHeroInstance.h"
 
-
-CampaignRimVideo::CampaignRimVideo(VideoPath video, ImagePath rim, bool showBackground, float scaleFactor, std::function<void(bool skipped)> closeCb)
-	: CWindowObject(BORDERED | NEEDS_ANIMATED_BACKGROUND), closeCb(closeCb)
-{
-	OBJECT_CONSTRUCTION;
-
-	addUsedEvents(LCLICK | KEYBOARD);
-
-	if(!rim.empty())
-	{
-		videoPlayer = std::make_shared<VideoWidgetOnce>(Point(80, 186), video, true, [this](){ exit(false); });
-		pos = center(Rect(0, 0, 800, 600));
-	}
-	else
-	{
-		videoPlayer = std::make_shared<VideoWidgetOnce>(Point(0, 0), video, true, scaleFactor, [this](){ exit(false); });
-		pos = center(Rect(0, 0, videoPlayer->pos.w, videoPlayer->pos.h));
-	}
-
-	if(showBackground)
-		backgroundAroundWindow = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), Rect(-pos.x, -pos.y, GH.screenDimensions().x, GH.screenDimensions().y));
-
-	if(!rim.empty())
-		setBackground(rim);
-}
-
-void CampaignRimVideo::exit(bool skipped)
-{
-	close();
-	if(closeCb)
-		closeCb(skipped);
-}
-
-void CampaignRimVideo::clickPressed(const Point & cursorPosition)
-{
-	exit(true);
-}
-
-void CampaignRimVideo::keyPressed(EShortcut key)
-{
-	exit(true);
-}
-
-bool CampaignRimVideo::receiveEvent(const Point & position, int eventType) const
-{
-	return true;  // capture click also outside of window
-}
-
 std::shared_ptr<CampaignState> CBonusSelection::getCampaign()
 {
 	return CSH->si->campState;

+ 0 - 16
client/lobby/CBonusSelection.h

@@ -34,22 +34,6 @@ class CBonusSelection;
 class CFilledTexture;
 
 
-class CampaignRimVideo : public CWindowObject
-{
-	std::shared_ptr<VideoWidgetOnce> videoPlayer;
-	std::shared_ptr<CFilledTexture> backgroundAroundWindow;
-
-	std::function<void(bool)> closeCb;
-
-	void exit(bool skipped);
-public:
-	CampaignRimVideo(VideoPath video, ImagePath rim, bool showBackground, float scaleFactor, std::function<void(bool)> closeCb);
-
-	void clickPressed(const Point & cursorPosition) override;
-	void keyPressed(EShortcut key) override;
-	bool receiveEvent(const Point & position, int eventType) const override;
-};
-
 /// Campaign screen where you can choose one out of three starting bonuses
 class CBonusSelection : public CWindowObject
 {

+ 2 - 2
client/mainmenu/CMainMenu.cpp

@@ -309,11 +309,11 @@ void CMainMenu::playIntroVideos(bool playVideoIntro)
 	{
 		auto playVideo = [](std::string video, bool rim, float scaleFactor, std::function<void(bool)> cb){
 			if(CCS->videoh->open(VideoPath::builtin(video), scaleFactor))
-				GH.windows().createAndPushWindow<CampaignRimVideo>(VideoPath::builtin(video), rim ? ImagePath::builtin("INTRORIM") : ImagePath::builtin(""), true, scaleFactor, [cb](bool skipped){ cb(skipped); });
+				GH.windows().createAndPushWindow<VideoWindow>(VideoPath::builtin(video), rim ? ImagePath::builtin("INTRORIM") : ImagePath::builtin(""), true, scaleFactor, [cb](bool skipped){ cb(skipped); });
 			else
 				cb(true);
 		};
-		playVideo("3DOLOGO.SMK", false, 1, [playVideo, playMusic](bool skipped){
+		playVideo("3DOLOGO.SMK", false, 1.25, [playVideo, playMusic](bool skipped){
 			if(!skipped)
 				playVideo("NWCLOGO.SMK", false, 2, [playVideo, playMusic](bool skipped){
 					if(!skipped)

+ 47 - 0
client/windows/GUIClasses.cpp

@@ -1607,3 +1607,50 @@ void CObjectListWindow::keyPressed(EShortcut key)
 	list->scrollTo(sel);
 	changeSelection(sel);
 }
+
+VideoWindow::VideoWindow(VideoPath video, ImagePath rim, bool showBackground, float scaleFactor, std::function<void(bool skipped)> closeCb)
+	: CWindowObject(BORDERED | NEEDS_ANIMATED_BACKGROUND), closeCb(closeCb)
+{
+	OBJECT_CONSTRUCTION;
+
+	addUsedEvents(LCLICK | KEYBOARD);
+
+	if(!rim.empty())
+	{
+		videoPlayer = std::make_shared<VideoWidgetOnce>(Point(80, 186), video, true, [this](){ exit(false); });
+		pos = center(Rect(0, 0, 800, 600));
+	}
+	else
+	{
+		videoPlayer = std::make_shared<VideoWidgetOnce>(Point(0, 0), video, true, scaleFactor, [this](){ exit(false); });
+		pos = center(Rect(0, 0, videoPlayer->pos.w, videoPlayer->pos.h));
+	}
+
+	if(showBackground)
+		backgroundAroundWindow = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), Rect(-pos.x, -pos.y, GH.screenDimensions().x, GH.screenDimensions().y));
+
+	if(!rim.empty())
+		setBackground(rim);
+}
+
+void VideoWindow::exit(bool skipped)
+{
+	close();
+	if(closeCb)
+		closeCb(skipped);
+}
+
+void VideoWindow::clickPressed(const Point & cursorPosition)
+{
+	exit(true);
+}
+
+void VideoWindow::keyPressed(EShortcut key)
+{
+	exit(true);
+}
+
+bool VideoWindow::receiveEvent(const Point & position, int eventType) const
+{
+	return true;  // capture click also outside of window
+}

+ 16 - 0
client/windows/GUIClasses.h

@@ -43,6 +43,7 @@ class CAnimImage;
 class CFilledTexture;
 class IImage;
 class VideoWidget;
+class VideoWidgetOnce;
 
 enum class EUserEvent;
 
@@ -501,3 +502,18 @@ public:
 	CThievesGuildWindow(const CGObjectInstance * _owner);
 };
 
+class VideoWindow : public CWindowObject
+{
+	std::shared_ptr<VideoWidgetOnce> videoPlayer;
+	std::shared_ptr<CFilledTexture> backgroundAroundWindow;
+
+	std::function<void(bool)> closeCb;
+
+	void exit(bool skipped);
+public:
+	VideoWindow(VideoPath video, ImagePath rim, bool showBackground, float scaleFactor, std::function<void(bool)> closeCb);
+
+	void clickPressed(const Point & cursorPosition) override;
+	void keyPressed(EShortcut key) override;
+	bool receiveEvent(const Point & position, int eventType) const override;
+};