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:
parent
2fbdeb3a5d
commit
21c3cf0960
@ -23,6 +23,7 @@
|
|||||||
#include "lobby/CLobbyScreen.h"
|
#include "lobby/CLobbyScreen.h"
|
||||||
#include "lobby/CBonusSelection.h"
|
#include "lobby/CBonusSelection.h"
|
||||||
#include "windows/InfoWindows.h"
|
#include "windows/InfoWindows.h"
|
||||||
|
#include "windows/GUIClasses.h"
|
||||||
#include "media/CMusicHandler.h"
|
#include "media/CMusicHandler.h"
|
||||||
#include "media/IVideoPlayer.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))
|
if(!ourCampaign->getOutroVideo().empty() && CCS->videoh->open(ourCampaign->getOutroVideo(), 1))
|
||||||
{
|
{
|
||||||
CCS->musich->stopMusic();
|
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);
|
GH.windows().createAndPushWindow<CHighScoreInputScreen>(true, *campaignScoreCalculator, statistic);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "widgets/TextControls.h"
|
#include "widgets/TextControls.h"
|
||||||
#include "media/CMusicHandler.h"
|
#include "media/CMusicHandler.h"
|
||||||
#include "media/IVideoPlayer.h"
|
#include "media/IVideoPlayer.h"
|
||||||
|
#include "windows/GUIClasses.h"
|
||||||
|
|
||||||
#include "../lib/CConfigHandler.h"
|
#include "../lib/CConfigHandler.h"
|
||||||
#include "../lib/texts/CGeneralTextHandler.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))
|
if(!handler.si->campState->conqueredScenarios().size() && !handler.si->campState->getIntroVideo().empty() && CCS->videoh->open(handler.si->campState->getIntroVideo(), 1))
|
||||||
{
|
{
|
||||||
CCS->musich->stopMusic();
|
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())
|
if(!CSH->si->campState->getMusic().empty())
|
||||||
CCS->musich->playMusic(CSH->si->campState->getMusic(), true, false);
|
CCS->musich->playMusic(CSH->si->campState->getMusic(), true, false);
|
||||||
GH.windows().pushWindow(bonusSel);
|
GH.windows().pushWindow(bonusSel);
|
||||||
|
@ -58,54 +58,6 @@
|
|||||||
|
|
||||||
#include "../../lib/mapObjects/CGHeroInstance.h"
|
#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()
|
std::shared_ptr<CampaignState> CBonusSelection::getCampaign()
|
||||||
{
|
{
|
||||||
return CSH->si->campState;
|
return CSH->si->campState;
|
||||||
|
@ -34,22 +34,6 @@ class CBonusSelection;
|
|||||||
class CFilledTexture;
|
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
|
/// Campaign screen where you can choose one out of three starting bonuses
|
||||||
class CBonusSelection : public CWindowObject
|
class CBonusSelection : public CWindowObject
|
||||||
{
|
{
|
||||||
|
@ -309,11 +309,11 @@ void CMainMenu::playIntroVideos(bool playVideoIntro)
|
|||||||
{
|
{
|
||||||
auto playVideo = [](std::string video, bool rim, float scaleFactor, std::function<void(bool)> cb){
|
auto playVideo = [](std::string video, bool rim, float scaleFactor, std::function<void(bool)> cb){
|
||||||
if(CCS->videoh->open(VideoPath::builtin(video), scaleFactor))
|
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
|
else
|
||||||
cb(true);
|
cb(true);
|
||||||
};
|
};
|
||||||
playVideo("3DOLOGO.SMK", false, 1, [playVideo, playMusic](bool skipped){
|
playVideo("3DOLOGO.SMK", false, 1.25, [playVideo, playMusic](bool skipped){
|
||||||
if(!skipped)
|
if(!skipped)
|
||||||
playVideo("NWCLOGO.SMK", false, 2, [playVideo, playMusic](bool skipped){
|
playVideo("NWCLOGO.SMK", false, 2, [playVideo, playMusic](bool skipped){
|
||||||
if(!skipped)
|
if(!skipped)
|
||||||
|
@ -1607,3 +1607,50 @@ void CObjectListWindow::keyPressed(EShortcut key)
|
|||||||
list->scrollTo(sel);
|
list->scrollTo(sel);
|
||||||
changeSelection(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
|
||||||
|
}
|
||||||
|
@ -43,6 +43,7 @@ class CAnimImage;
|
|||||||
class CFilledTexture;
|
class CFilledTexture;
|
||||||
class IImage;
|
class IImage;
|
||||||
class VideoWidget;
|
class VideoWidget;
|
||||||
|
class VideoWidgetOnce;
|
||||||
|
|
||||||
enum class EUserEvent;
|
enum class EUserEvent;
|
||||||
|
|
||||||
@ -501,3 +502,18 @@ public:
|
|||||||
CThievesGuildWindow(const CGObjectInstance * _owner);
|
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;
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user