mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
integrate campaign intro
This commit is contained in:
parent
9c2a5f6baa
commit
46872b764b
@ -204,8 +204,8 @@ void ApplyOnLobbyScreenNetPackVisitor::visitLobbyUpdateState(LobbyUpdateState &
|
||||
if(!lobby->bonusSel && handler.si->campState && handler.getState() == EClientState::LOBBY_CAMPAIGN)
|
||||
{
|
||||
lobby->bonusSel = std::make_shared<CBonusSelection>();
|
||||
if(!handler.si->campState->conqueredScenarios().size())
|
||||
GH.windows().createAndPushWindow<CampaignIntroVideo>(VideoPath::builtin("Hc1_Intro"), ImagePath::builtin("INTRORIM"), lobby->bonusSel);
|
||||
if(!handler.si->campState->conqueredScenarios().size() && !handler.si->campState->getIntroVideo().empty())
|
||||
GH.windows().createAndPushWindow<CampaignIntroVideo>(handler.si->campState->getIntroVideo(), handler.si->campState->getIntroVideoRim().empty() ? ImagePath::builtin("INTRORIM") : handler.si->campState->getIntroVideoRim(), lobby->bonusSel);
|
||||
else
|
||||
GH.windows().pushWindow(lobby->bonusSel);
|
||||
}
|
||||
|
@ -63,16 +63,35 @@ CampaignIntroVideo::CampaignIntroVideo(VideoPath video, ImagePath rim, std::shar
|
||||
: CWindowObject(BORDERED), bonusSel(bonusSel)
|
||||
{
|
||||
OBJECT_CONSTRUCTION;
|
||||
videoPlayer = std::make_shared<VideoWidgetOnce>(Point(0, 0), video, true, [this](){ exit(); });
|
||||
|
||||
addUsedEvents(LCLICK | KEYBOARD);
|
||||
|
||||
pos = center(Rect(0, 0, 800, 600));
|
||||
|
||||
videoPlayer = std::make_shared<VideoWidgetOnce>(Point(80, 186), video, true, [this](){ exit(); });
|
||||
setBackground(rim);
|
||||
|
||||
audioVol = CCS->musich->getVolume();
|
||||
CCS->musich->setVolume(0);
|
||||
}
|
||||
|
||||
void CampaignIntroVideo::exit()
|
||||
{
|
||||
close();
|
||||
CCS->musich->setVolume(audioVol);
|
||||
GH.windows().pushWindow(bonusSel);
|
||||
}
|
||||
|
||||
void CampaignIntroVideo::clickPressed(const Point & cursorPosition)
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
void CampaignIntroVideo::keyPressed(EShortcut key)
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
std::shared_ptr<CampaignState> CBonusSelection::getCampaign()
|
||||
{
|
||||
return CSH->si->campState;
|
||||
|
@ -38,9 +38,14 @@ class CampaignIntroVideo : public CWindowObject
|
||||
std::shared_ptr<VideoWidgetOnce> videoPlayer;
|
||||
std::shared_ptr<CBonusSelection> bonusSel;
|
||||
|
||||
ui32 audioVol;
|
||||
|
||||
void exit();
|
||||
public:
|
||||
CampaignIntroVideo(VideoPath video, ImagePath rim, std::shared_ptr<CBonusSelection> bonusSel);
|
||||
|
||||
void clickPressed(const Point & cursorPosition) override;
|
||||
void keyPressed(EShortcut key) override;
|
||||
};
|
||||
|
||||
/// Campaign screen where you can choose one out of three starting bonuses
|
||||
|
@ -28,6 +28,8 @@
|
||||
{ "voiceProlog": "Hc1_ABvoFL3" },
|
||||
{ "voiceProlog": "Hc1_H3x2BBf", "voiceEpilog": "Hc1_N1C_D" }
|
||||
],
|
||||
"loadingBackground": "Hc1_LoadBar"
|
||||
"loadingBackground": "Hc1_LoadBar",
|
||||
"introVideoRim": "Hc1_INTRORIM",
|
||||
"introVideo": "Hc1_Intro"
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,8 @@ In header are parameters describing campaign properties
|
||||
- `"creationDateTime"` unix time of campaign creation
|
||||
- `"allowDifficultySelection"` is a boolean field (`true`/`false`) which allows or disallows to choose difficulty before scenario start
|
||||
- `"loadingBackground"` is for setting a different loading screen background
|
||||
- `"introVideo"` is for defining an optional intro video
|
||||
- `"introVideoRim"` is for the Rim around the optional video (default is INTRORIM)
|
||||
|
||||
## Scenario description
|
||||
|
||||
|
@ -169,6 +169,8 @@ void CampaignHandler::readHeaderFromJson(CampaignHeader & ret, JsonNode & reader
|
||||
ret.modName = modName;
|
||||
ret.encoding = encoding;
|
||||
ret.loadingBackground = ImagePath::fromJson(reader["loadingBackground"]);
|
||||
ret.introVideoRim = ImagePath::fromJson(reader["introVideoRim"]);
|
||||
ret.introVideo = VideoPath::fromJson(reader["introVideo"]);
|
||||
}
|
||||
|
||||
CampaignScenario CampaignHandler::readScenarioFromJson(JsonNode & reader)
|
||||
|
@ -210,6 +210,16 @@ ImagePath CampaignHeader::getLoadingBackground() const
|
||||
return loadingBackground;
|
||||
}
|
||||
|
||||
ImagePath CampaignHeader::getIntroVideoRim() const
|
||||
{
|
||||
return introVideoRim;
|
||||
}
|
||||
|
||||
VideoPath CampaignHeader::getIntroVideo() const
|
||||
{
|
||||
return introVideo;
|
||||
}
|
||||
|
||||
const CampaignRegions & CampaignHeader::getRegions() const
|
||||
{
|
||||
return campaignRegions;
|
||||
@ -479,6 +489,10 @@ void Campaign::overrideCampaign(bool scenario)
|
||||
loadLegacyData(CampaignRegions::fromJson(entry.second["regions"]), entry.second["scenarioCount"].Integer());
|
||||
if(!entry.second["loadingBackground"].isNull())
|
||||
loadingBackground = ImagePath::builtin(entry.second["loadingBackground"].String());
|
||||
if(!entry.second["introVideoRim"].isNull())
|
||||
introVideoRim = ImagePath::builtin(entry.second["introVideoRim"].String());
|
||||
if(!entry.second["introVideo"].isNull())
|
||||
introVideo = VideoPath::builtin(entry.second["introVideo"].String());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -98,6 +98,8 @@ class DLL_LINKAGE CampaignHeader : public boost::noncopyable
|
||||
std::string modName;
|
||||
std::string encoding;
|
||||
ImagePath loadingBackground;
|
||||
ImagePath introVideoRim;
|
||||
VideoPath introVideo;
|
||||
|
||||
int numberOfScenarios = 0;
|
||||
bool difficultyChosenByPlayer = false;
|
||||
@ -122,6 +124,8 @@ public:
|
||||
std::string getEncoding() const;
|
||||
AudioPath getMusic() const;
|
||||
ImagePath getLoadingBackground() const;
|
||||
ImagePath getIntroVideoRim() const;
|
||||
VideoPath getIntroVideo() const;
|
||||
|
||||
const CampaignRegions & getRegions() const;
|
||||
TextContainerRegistrable & getTexts();
|
||||
@ -149,6 +153,8 @@ public:
|
||||
if (h.version >= Handler::Version::CHRONICLES_SUPPORT)
|
||||
{
|
||||
h & loadingBackground;
|
||||
h & introVideoRim;
|
||||
h & introVideo;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user