1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-17 00:07:41 +02:00

allow custom loadbar-backgrounds for campaigns

This commit is contained in:
Laserlicht
2024-08-31 16:03:42 +02:00
parent 0b8f92250d
commit 16cbd6a7d2
9 changed files with 36 additions and 5 deletions

View File

@ -532,6 +532,9 @@ void CServerHandler::sendGuiAction(ui8 action) const
void CServerHandler::sendRestartGame() const void CServerHandler::sendRestartGame() const
{ {
if(si->campState && !si->campState->getLoadingBackground().empty())
GH.windows().createAndPushWindow<CLoadingScreen>(si->campState->getLoadingBackground());
else
GH.windows().createAndPushWindow<CLoadingScreen>(); GH.windows().createAndPushWindow<CLoadingScreen>();
LobbyRestartGame endGame; LobbyRestartGame endGame;
@ -576,7 +579,12 @@ void CServerHandler::sendStartGame(bool allowOnlyAI) const
verifyStateBeforeStart(allowOnlyAI ? true : settings["session"]["onlyai"].Bool()); verifyStateBeforeStart(allowOnlyAI ? true : settings["session"]["onlyai"].Bool());
if(!settings["session"]["headless"].Bool()) if(!settings["session"]["headless"].Bool())
{
if(si->campState && !si->campState->getLoadingBackground().empty())
GH.windows().createAndPushWindow<CLoadingScreen>(si->campState->getLoadingBackground());
else
GH.windows().createAndPushWindow<CLoadingScreen>(); GH.windows().createAndPushWindow<CLoadingScreen>();
}
LobbyPrepareStartGame lpsg; LobbyPrepareStartGame lpsg;
sendLobbyPack(lpsg); sendLobbyPack(lpsg);

View File

@ -629,7 +629,12 @@ void CSimpleJoinScreen::startConnection(const std::string & addr, ui16 port)
} }
CLoadingScreen::CLoadingScreen() CLoadingScreen::CLoadingScreen()
: CWindowObject(BORDERED, getBackground()) : CLoadingScreen(getBackground())
{
}
CLoadingScreen::CLoadingScreen(ImagePath background)
: CWindowObject(BORDERED, background)
{ {
OBJECT_CONSTRUCTION; OBJECT_CONSTRUCTION;

View File

@ -192,6 +192,7 @@ class CLoadingScreen : virtual public CWindowObject, virtual public Load::Progre
public: public:
CLoadingScreen(); CLoadingScreen();
CLoadingScreen(ImagePath background);
~CLoadingScreen(); ~CLoadingScreen();
void tick(uint32_t msPassed) override; void tick(uint32_t msPassed) override;

View File

@ -27,6 +27,7 @@
{ "voiceProlog": "Hc1_G2C" }, { "voiceProlog": "Hc1_G2C" },
{ "voiceProlog": "Hc1_ABvoFL3" }, { "voiceProlog": "Hc1_ABvoFL3" },
{ "voiceProlog": "Hc1_H3x2BBf", "voiceEpilog": "Hc1_N1C_D" } { "voiceProlog": "Hc1_H3x2BBf", "voiceEpilog": "Hc1_N1C_D" }
] ],
"loadingBackground": "Hc1_LoadBar"
} }
} }

View File

@ -52,6 +52,7 @@ In header are parameters describing campaign properties
- `"campaignVersion"` is creator defined version - `"campaignVersion"` is creator defined version
- `"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
## Scenario description ## Scenario description

View File

@ -168,6 +168,7 @@ void CampaignHandler::readHeaderFromJson(CampaignHeader & ret, JsonNode & reader
ret.filename = filename; ret.filename = filename;
ret.modName = modName; ret.modName = modName;
ret.encoding = encoding; ret.encoding = encoding;
ret.loadingBackground = ImagePath::fromJson(reader["loadingBackground"]);
} }
CampaignScenario CampaignHandler::readScenarioFromJson(JsonNode & reader) CampaignScenario CampaignHandler::readScenarioFromJson(JsonNode & reader)

View File

@ -205,6 +205,11 @@ AudioPath CampaignHeader::getMusic() const
return music; return music;
} }
ImagePath CampaignHeader::getLoadingBackground() const
{
return loadingBackground;
}
const CampaignRegions & CampaignHeader::getRegions() const const CampaignRegions & CampaignHeader::getRegions() const
{ {
return campaignRegions; return campaignRegions;
@ -472,6 +477,8 @@ void Campaign::overrideCampaign(bool scenario)
{ {
if(!entry.second["regions"].isNull() && !entry.second["scenarioCount"].isNull()) if(!entry.second["regions"].isNull() && !entry.second["scenarioCount"].isNull())
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())
loadingBackground = ImagePath::builtin(entry.second["loadingBackground"].String());
} }
else else
{ {

View File

@ -97,6 +97,7 @@ class DLL_LINKAGE CampaignHeader : public boost::noncopyable
std::string filename; std::string filename;
std::string modName; std::string modName;
std::string encoding; std::string encoding;
ImagePath loadingBackground;
int numberOfScenarios = 0; int numberOfScenarios = 0;
bool difficultyChosenByPlayer = false; bool difficultyChosenByPlayer = false;
@ -120,6 +121,7 @@ public:
std::string getModName() const; std::string getModName() const;
std::string getEncoding() const; std::string getEncoding() const;
AudioPath getMusic() const; AudioPath getMusic() const;
ImagePath getLoadingBackground() const;
const CampaignRegions & getRegions() const; const CampaignRegions & getRegions() const;
TextContainerRegistrable & getTexts(); TextContainerRegistrable & getTexts();
@ -145,6 +147,10 @@ public:
h & encoding; h & encoding;
if (h.version >= Handler::Version::RELEASE_143) if (h.version >= Handler::Version::RELEASE_143)
h & textContainer; h & textContainer;
if (h.version >= Handler::Version::CHRONICLES_SUPPORT)
{
h & loadingBackground;
}
} }
}; };

View File

@ -67,6 +67,7 @@ enum class ESerializationVersion : int32_t
STATISTICS_SCREEN, // 856 - extent statistic functions STATISTICS_SCREEN, // 856 - extent statistic functions
NEW_MARKETS, // 857 - reworked market classes NEW_MARKETS, // 857 - reworked market classes
PLAYER_STATE_OWNED_OBJECTS, // 858 - player state stores all owned objects in a single list PLAYER_STATE_OWNED_OBJECTS, // 858 - player state stores all owned objects in a single list
CHRONICLES_SUPPORT, // 859 - support for heroes chronicles
CURRENT = PLAYER_STATE_OWNED_OBJECTS CURRENT = CHRONICLES_SUPPORT
}; };