1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00

rename and move window class

This commit is contained in:
Laserlicht 2024-09-12 23:35:21 +02:00
parent 2fbdeb3a5d
commit 21c3cf0960
7 changed files with 69 additions and 68 deletions

View File

@ -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);
});
}

View File

@ -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);

View File

@ -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;

View File

@ -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
{

View File

@ -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)

View File

@ -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
}

View File

@ -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;
};