1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

integrate campaign intro

This commit is contained in:
Laserlicht
2024-08-31 17:57:27 +02:00
parent 9c2a5f6baa
commit 46872b764b
8 changed files with 54 additions and 4 deletions

View File

@@ -204,8 +204,8 @@ void ApplyOnLobbyScreenNetPackVisitor::visitLobbyUpdateState(LobbyUpdateState &
if(!lobby->bonusSel && handler.si->campState && handler.getState() == EClientState::LOBBY_CAMPAIGN) if(!lobby->bonusSel && handler.si->campState && handler.getState() == EClientState::LOBBY_CAMPAIGN)
{ {
lobby->bonusSel = std::make_shared<CBonusSelection>(); lobby->bonusSel = std::make_shared<CBonusSelection>();
if(!handler.si->campState->conqueredScenarios().size()) if(!handler.si->campState->conqueredScenarios().size() && !handler.si->campState->getIntroVideo().empty())
GH.windows().createAndPushWindow<CampaignIntroVideo>(VideoPath::builtin("Hc1_Intro"), ImagePath::builtin("INTRORIM"), lobby->bonusSel); GH.windows().createAndPushWindow<CampaignIntroVideo>(handler.si->campState->getIntroVideo(), handler.si->campState->getIntroVideoRim().empty() ? ImagePath::builtin("INTRORIM") : handler.si->campState->getIntroVideoRim(), lobby->bonusSel);
else else
GH.windows().pushWindow(lobby->bonusSel); GH.windows().pushWindow(lobby->bonusSel);
} }

View File

@@ -63,16 +63,35 @@ CampaignIntroVideo::CampaignIntroVideo(VideoPath video, ImagePath rim, std::shar
: CWindowObject(BORDERED), bonusSel(bonusSel) : CWindowObject(BORDERED), bonusSel(bonusSel)
{ {
OBJECT_CONSTRUCTION; 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); setBackground(rim);
audioVol = CCS->musich->getVolume();
CCS->musich->setVolume(0);
} }
void CampaignIntroVideo::exit() void CampaignIntroVideo::exit()
{ {
close(); close();
CCS->musich->setVolume(audioVol);
GH.windows().pushWindow(bonusSel); GH.windows().pushWindow(bonusSel);
} }
void CampaignIntroVideo::clickPressed(const Point & cursorPosition)
{
exit();
}
void CampaignIntroVideo::keyPressed(EShortcut key)
{
exit();
}
std::shared_ptr<CampaignState> CBonusSelection::getCampaign() std::shared_ptr<CampaignState> CBonusSelection::getCampaign()
{ {
return CSH->si->campState; return CSH->si->campState;

View File

@@ -38,9 +38,14 @@ class CampaignIntroVideo : public CWindowObject
std::shared_ptr<VideoWidgetOnce> videoPlayer; std::shared_ptr<VideoWidgetOnce> videoPlayer;
std::shared_ptr<CBonusSelection> bonusSel; std::shared_ptr<CBonusSelection> bonusSel;
ui32 audioVol;
void exit(); void exit();
public: public:
CampaignIntroVideo(VideoPath video, ImagePath rim, std::shared_ptr<CBonusSelection> bonusSel); 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 /// Campaign screen where you can choose one out of three starting bonuses

View File

@@ -28,6 +28,8 @@
{ "voiceProlog": "Hc1_ABvoFL3" }, { "voiceProlog": "Hc1_ABvoFL3" },
{ "voiceProlog": "Hc1_H3x2BBf", "voiceEpilog": "Hc1_N1C_D" } { "voiceProlog": "Hc1_H3x2BBf", "voiceEpilog": "Hc1_N1C_D" }
], ],
"loadingBackground": "Hc1_LoadBar" "loadingBackground": "Hc1_LoadBar",
"introVideoRim": "Hc1_INTRORIM",
"introVideo": "Hc1_Intro"
} }
} }

View File

@@ -53,6 +53,8 @@ In header are parameters describing campaign properties
- `"creationDateTime"` unix time of campaign creation - `"creationDateTime"` unix time of campaign creation
- `"allowDifficultySelection"` is a boolean field (`true`/`false`) which allows or disallows to choose difficulty before scenario start - `"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 - `"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 ## Scenario description

View File

@@ -169,6 +169,8 @@ void CampaignHandler::readHeaderFromJson(CampaignHeader & ret, JsonNode & reader
ret.modName = modName; ret.modName = modName;
ret.encoding = encoding; ret.encoding = encoding;
ret.loadingBackground = ImagePath::fromJson(reader["loadingBackground"]); ret.loadingBackground = ImagePath::fromJson(reader["loadingBackground"]);
ret.introVideoRim = ImagePath::fromJson(reader["introVideoRim"]);
ret.introVideo = VideoPath::fromJson(reader["introVideo"]);
} }
CampaignScenario CampaignHandler::readScenarioFromJson(JsonNode & reader) CampaignScenario CampaignHandler::readScenarioFromJson(JsonNode & reader)

View File

@@ -210,6 +210,16 @@ ImagePath CampaignHeader::getLoadingBackground() const
return loadingBackground; return loadingBackground;
} }
ImagePath CampaignHeader::getIntroVideoRim() const
{
return introVideoRim;
}
VideoPath CampaignHeader::getIntroVideo() const
{
return introVideo;
}
const CampaignRegions & CampaignHeader::getRegions() const const CampaignRegions & CampaignHeader::getRegions() const
{ {
return campaignRegions; return campaignRegions;
@@ -479,6 +489,10 @@ void Campaign::overrideCampaign(bool scenario)
loadLegacyData(CampaignRegions::fromJson(entry.second["regions"]), entry.second["scenarioCount"].Integer()); loadLegacyData(CampaignRegions::fromJson(entry.second["regions"]), entry.second["scenarioCount"].Integer());
if(!entry.second["loadingBackground"].isNull()) if(!entry.second["loadingBackground"].isNull())
loadingBackground = ImagePath::builtin(entry.second["loadingBackground"].String()); 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 else
{ {

View File

@@ -98,6 +98,8 @@ class DLL_LINKAGE CampaignHeader : public boost::noncopyable
std::string modName; std::string modName;
std::string encoding; std::string encoding;
ImagePath loadingBackground; ImagePath loadingBackground;
ImagePath introVideoRim;
VideoPath introVideo;
int numberOfScenarios = 0; int numberOfScenarios = 0;
bool difficultyChosenByPlayer = false; bool difficultyChosenByPlayer = false;
@@ -122,6 +124,8 @@ public:
std::string getEncoding() const; std::string getEncoding() const;
AudioPath getMusic() const; AudioPath getMusic() const;
ImagePath getLoadingBackground() const; ImagePath getLoadingBackground() const;
ImagePath getIntroVideoRim() const;
VideoPath getIntroVideo() const;
const CampaignRegions & getRegions() const; const CampaignRegions & getRegions() const;
TextContainerRegistrable & getTexts(); TextContainerRegistrable & getTexts();
@@ -149,6 +153,8 @@ public:
if (h.version >= Handler::Version::CHRONICLES_SUPPORT) if (h.version >= Handler::Version::CHRONICLES_SUPPORT)
{ {
h & loadingBackground; h & loadingBackground;
h & introVideoRim;
h & introVideo;
} }
} }
}; };