mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-02 00:10:22 +02:00
code review
This commit is contained in:
parent
b80852617a
commit
c7064377da
@ -71,14 +71,16 @@ CampaignIntroVideo::CampaignIntroVideo(VideoPath video, ImagePath rim, std::shar
|
|||||||
videoPlayer = std::make_shared<VideoWidgetOnce>(Point(80, 186), video, true, [this](){ exit(); });
|
videoPlayer = std::make_shared<VideoWidgetOnce>(Point(80, 186), video, true, [this](){ exit(); });
|
||||||
setBackground(rim);
|
setBackground(rim);
|
||||||
|
|
||||||
audioVol = CCS->musich->getVolume();
|
CCS->musich->stopMusic();
|
||||||
CCS->musich->setVolume(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CampaignIntroVideo::exit()
|
void CampaignIntroVideo::exit()
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
CCS->musich->setVolume(audioVol);
|
|
||||||
|
if (!CSH->si->campState->getMusic().empty())
|
||||||
|
CCS->musich->playMusic(CSH->si->campState->getMusic(), true, false);
|
||||||
|
|
||||||
GH.windows().pushWindow(bonusSel);
|
GH.windows().pushWindow(bonusSel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +129,9 @@ CBonusSelection::CBonusSelection()
|
|||||||
labelCampaignDescription = std::make_shared<CLabel>(481, 63, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[38]);
|
labelCampaignDescription = std::make_shared<CLabel>(481, 63, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[38]);
|
||||||
campaignDescription = std::make_shared<CTextBox>(getCampaign()->getDescriptionTranslated(), Rect(480, 86, 286, 117), 1);
|
campaignDescription = std::make_shared<CTextBox>(getCampaign()->getDescriptionTranslated(), Rect(480, 86, 286, 117), 1);
|
||||||
|
|
||||||
mapName = std::make_shared<CLabel>(481, 219, FONT_BIG, ETextAlignment::TOPLEFT, Colors::YELLOW, CSH->mi->getNameTranslated(), CSH->getState() == EClientState::GAMEPLAY ? 225 : 285); //if video button active theres fewer space
|
bool videoButtonActive = CSH->getState() == EClientState::GAMEPLAY;
|
||||||
|
int availableSpace = videoButtonActive ? 225 : 285;
|
||||||
|
mapName = std::make_shared<CLabel>(481, 219, FONT_BIG, ETextAlignment::TOPLEFT, Colors::YELLOW, CSH->mi->getNameTranslated(), availableSpace );
|
||||||
labelMapDescription = std::make_shared<CLabel>(481, 253, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[496]);
|
labelMapDescription = std::make_shared<CLabel>(481, 253, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[496]);
|
||||||
mapDescription = std::make_shared<CTextBox>("", Rect(480, 278, 292, 108), 1);
|
mapDescription = std::make_shared<CTextBox>("", Rect(480, 278, 292, 108), 1);
|
||||||
|
|
||||||
|
@ -38,8 +38,6 @@ 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);
|
||||||
|
@ -206,7 +206,7 @@
|
|||||||
"portraitTarnumBarbarian" :
|
"portraitTarnumBarbarian" :
|
||||||
{
|
{
|
||||||
"class" : "barbarian",
|
"class" : "barbarian",
|
||||||
"special" : false,
|
"special" : true,
|
||||||
"images": {
|
"images": {
|
||||||
"large" : "Hc_HPL137",
|
"large" : "Hc_HPL137",
|
||||||
"small" : "Hc_HPS137",
|
"small" : "Hc_HPS137",
|
||||||
@ -235,7 +235,7 @@
|
|||||||
"portraitTarnumKnight" :
|
"portraitTarnumKnight" :
|
||||||
{
|
{
|
||||||
"class" : "knight",
|
"class" : "knight",
|
||||||
"special" : false,
|
"special" : true,
|
||||||
"images": {
|
"images": {
|
||||||
"large" : "Hc_HPL138",
|
"large" : "Hc_HPL138",
|
||||||
"small" : "Hc_HPS138",
|
"small" : "Hc_HPS138",
|
||||||
@ -264,7 +264,7 @@
|
|||||||
"portraitTarnumWizard" :
|
"portraitTarnumWizard" :
|
||||||
{
|
{
|
||||||
"class" : "wizard",
|
"class" : "wizard",
|
||||||
"special" : false,
|
"special" : true,
|
||||||
"images": {
|
"images": {
|
||||||
"large" : "Hc_HPL139",
|
"large" : "Hc_HPL139",
|
||||||
"small" : "Hc_HPS139",
|
"small" : "Hc_HPS139",
|
||||||
@ -293,7 +293,7 @@
|
|||||||
"portraitTarnumRanger" :
|
"portraitTarnumRanger" :
|
||||||
{
|
{
|
||||||
"class" : "ranger",
|
"class" : "ranger",
|
||||||
"special" : false,
|
"special" : true,
|
||||||
"images": {
|
"images": {
|
||||||
"large" : "Hc_HPL140",
|
"large" : "Hc_HPL140",
|
||||||
"small" : "Hc_HPS140",
|
"small" : "Hc_HPS140",
|
||||||
@ -322,7 +322,7 @@
|
|||||||
"portraitTarnumOverlord" :
|
"portraitTarnumOverlord" :
|
||||||
{
|
{
|
||||||
"class" : "overlord",
|
"class" : "overlord",
|
||||||
"special" : false,
|
"special" : true,
|
||||||
"images": {
|
"images": {
|
||||||
"large" : "Hc_HPL141",
|
"large" : "Hc_HPL141",
|
||||||
"small" : "Hc_HPS141",
|
"small" : "Hc_HPS141",
|
||||||
@ -351,7 +351,7 @@
|
|||||||
"portraitTarnumBeastmaster" :
|
"portraitTarnumBeastmaster" :
|
||||||
{
|
{
|
||||||
"class" : "beastmaster",
|
"class" : "beastmaster",
|
||||||
"special" : false,
|
"special" : true,
|
||||||
"images": {
|
"images": {
|
||||||
"large" : "Hc_HPL142",
|
"large" : "Hc_HPL142",
|
||||||
"small" : "Hc_HPS142",
|
"small" : "Hc_HPS142",
|
||||||
|
@ -38,14 +38,14 @@ void CampaignHandler::readCampaign(Campaign * ret, const std::vector<ui8> & inpu
|
|||||||
CBinaryReader reader(&stream);
|
CBinaryReader reader(&stream);
|
||||||
|
|
||||||
readHeaderFromMemory(*ret, reader, filename, modName, encoding);
|
readHeaderFromMemory(*ret, reader, filename, modName, encoding);
|
||||||
ret->overrideCampaign(false);
|
ret->overrideCampaign();
|
||||||
|
|
||||||
for(int g = 0; g < ret->numberOfScenarios; ++g)
|
for(int g = 0; g < ret->numberOfScenarios; ++g)
|
||||||
{
|
{
|
||||||
auto scenarioID = static_cast<CampaignScenarioID>(ret->scenarios.size());
|
auto scenarioID = static_cast<CampaignScenarioID>(ret->scenarios.size());
|
||||||
ret->scenarios[scenarioID] = readScenarioFromMemory(reader, *ret);
|
ret->scenarios[scenarioID] = readScenarioFromMemory(reader, *ret);
|
||||||
}
|
}
|
||||||
ret->overrideCampaign(true);
|
ret->overrideCampaignScenarios();
|
||||||
}
|
}
|
||||||
else // text format (json)
|
else // text format (json)
|
||||||
{
|
{
|
||||||
@ -397,7 +397,7 @@ void CampaignHandler::readHeaderFromMemory( CampaignHeader & ret, CBinaryReader
|
|||||||
{
|
{
|
||||||
ret.version = static_cast<CampaignVersion>(reader.readUInt32());
|
ret.version = static_cast<CampaignVersion>(reader.readUInt32());
|
||||||
ui8 campId = reader.readUInt8() - 1;//change range of it from [1, 20] to [0, 19]
|
ui8 campId = reader.readUInt8() - 1;//change range of it from [1, 20] to [0, 19]
|
||||||
if(ret.version != CampaignVersion::Chr)
|
if(ret.version != CampaignVersion::Chr) // For chronicles: Will be overridden later; Chronicles uses own logic (reusing OH3 ID's)
|
||||||
ret.loadLegacyData(campId);
|
ret.loadLegacyData(campId);
|
||||||
ret.name.appendTextID(readLocalizedString(ret, reader, filename, modName, encoding, "name"));
|
ret.name.appendTextID(readLocalizedString(ret, reader, filename, modName, encoding, "name"));
|
||||||
ret.description.appendTextID(readLocalizedString(ret, reader, filename, modName, encoding, "description"));
|
ret.description.appendTextID(readLocalizedString(ret, reader, filename, modName, encoding, "description"));
|
||||||
|
@ -477,37 +477,40 @@ std::set<CampaignScenarioID> Campaign::allScenarios() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Campaign::overrideCampaign(bool scenario)
|
void Campaign::overrideCampaign()
|
||||||
{
|
{
|
||||||
JsonNode node = JsonUtils::assembleFromFiles("config/campaignOverrides.json");
|
const JsonNode node = JsonUtils::assembleFromFiles("config/campaignOverrides.json");
|
||||||
for (auto & entry : node.Struct())
|
for (auto & entry : node.Struct())
|
||||||
if(filename == entry.first)
|
if(filename == entry.first)
|
||||||
{
|
{
|
||||||
if(!scenario)
|
if(!entry.second["regions"].isNull() && !entry.second["scenarioCount"].isNull())
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Campaign::overrideCampaignScenarios()
|
||||||
|
{
|
||||||
|
const JsonNode node = JsonUtils::assembleFromFiles("config/campaignOverrides.json");
|
||||||
|
for (auto & entry : node.Struct())
|
||||||
|
if(filename == entry.first)
|
||||||
|
{
|
||||||
|
if(!entry.second["scenarios"].isNull())
|
||||||
{
|
{
|
||||||
if(!entry.second["regions"].isNull() && !entry.second["scenarioCount"].isNull())
|
auto sc = entry.second["scenarios"].Vector();
|
||||||
loadLegacyData(CampaignRegions::fromJson(entry.second["regions"]), entry.second["scenarioCount"].Integer());
|
for(int i = 0; i < sc.size(); i++)
|
||||||
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
|
|
||||||
{
|
|
||||||
if(!entry.second["scenarios"].isNull())
|
|
||||||
{
|
{
|
||||||
auto sc = entry.second["scenarios"].Vector();
|
auto it = scenarios.begin();
|
||||||
for(int i = 0; i < sc.size(); i++)
|
std::advance(it, i);
|
||||||
{
|
if(!sc.at(i)["voiceProlog"].isNull())
|
||||||
auto it = scenarios.begin();
|
it->second.prolog.prologVoice = AudioPath::builtin(sc.at(i)["voiceProlog"].String());
|
||||||
std::advance(it, i);
|
if(!sc.at(i)["voiceEpilog"].isNull())
|
||||||
if(!sc.at(i)["voiceProlog"].isNull())
|
it->second.epilog.prologVoice = AudioPath::builtin(sc.at(i)["voiceEpilog"].String());
|
||||||
it->second.prolog.prologVoice = AudioPath::builtin(sc.at(i)["voiceProlog"].String());
|
|
||||||
if(!sc.at(i)["voiceEpilog"].isNull())
|
|
||||||
it->second.epilog.prologVoice = AudioPath::builtin(sc.at(i)["voiceEpilog"].String());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,8 @@ public:
|
|||||||
std::set<CampaignScenarioID> allScenarios() const;
|
std::set<CampaignScenarioID> allScenarios() const;
|
||||||
int scenariosCount() const;
|
int scenariosCount() const;
|
||||||
|
|
||||||
void overrideCampaign(bool scenario);
|
void overrideCampaign();
|
||||||
|
void overrideCampaignScenarios();
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h)
|
template <typename Handler> void serialize(Handler &h)
|
||||||
{
|
{
|
||||||
|
@ -197,7 +197,7 @@ std::string CArchiveLoader::getMountPoint() const
|
|||||||
return mountPoint;
|
return mountPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<ResourcePath, ArchiveEntry> CArchiveLoader::getEntries() const
|
const std::unordered_map<ResourcePath, ArchiveEntry> & CArchiveLoader::getEntries() const
|
||||||
{
|
{
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public:
|
|||||||
std::unique_ptr<CInputStream> load(const ResourcePath & resourceName) const override;
|
std::unique_ptr<CInputStream> load(const ResourcePath & resourceName) const override;
|
||||||
bool existsResource(const ResourcePath & resourceName) const override;
|
bool existsResource(const ResourcePath & resourceName) const override;
|
||||||
std::string getMountPoint() const override;
|
std::string getMountPoint() const override;
|
||||||
std::unordered_map<ResourcePath, ArchiveEntry> getEntries() const;
|
const std::unordered_map<ResourcePath, ArchiveEntry> & getEntries() const;
|
||||||
void updateFilteredFiles(std::function<bool(const std::string &)> filter) const override {}
|
void updateFilteredFiles(std::function<bool(const std::string &)> filter) const override {}
|
||||||
std::unordered_set<ResourcePath> getFilteredFiles(std::function<bool(const ResourcePath &)> filter) const override;
|
std::unordered_set<ResourcePath> getFilteredFiles(std::function<bool(const ResourcePath &)> filter) const override;
|
||||||
/** Extracts one archive entry to the specified subfolder. Used for Video and Sound */
|
/** Extracts one archive entry to the specified subfolder. Used for Video and Sound */
|
||||||
|
Loading…
Reference in New Issue
Block a user