mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Added text container with map translations to campaign state
Fixes missing translations for heroes names customized on maps after their transfer to next scenario
This commit is contained in:
parent
5c5fb523a4
commit
290cc1510b
@ -227,7 +227,7 @@ public:
|
|||||||
TextContainerRegistrable(const TextContainerRegistrable & other);
|
TextContainerRegistrable(const TextContainerRegistrable & other);
|
||||||
TextContainerRegistrable(TextContainerRegistrable && other) noexcept;
|
TextContainerRegistrable(TextContainerRegistrable && other) noexcept;
|
||||||
|
|
||||||
TextContainerRegistrable& operator=(TextContainerRegistrable b) = delete;
|
TextContainerRegistrable& operator=(const TextContainerRegistrable & b) = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Handles all text-related data in game
|
/// Handles all text-related data in game
|
||||||
|
@ -317,7 +317,7 @@ std::optional<ui8> CampaignState::getBonusID(CampaignScenarioID which) const
|
|||||||
return chosenCampaignBonuses.at(which);
|
return chosenCampaignBonuses.at(which);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CMap> CampaignState::getMap(CampaignScenarioID scenarioId, IGameCallback * cb) const
|
std::unique_ptr<CMap> CampaignState::getMap(CampaignScenarioID scenarioId, IGameCallback * cb)
|
||||||
{
|
{
|
||||||
// FIXME: there is certainly better way to handle maps inside campaigns
|
// FIXME: there is certainly better way to handle maps inside campaigns
|
||||||
if(scenarioId == CampaignScenarioID::NONE)
|
if(scenarioId == CampaignScenarioID::NONE)
|
||||||
@ -328,7 +328,10 @@ std::unique_ptr<CMap> CampaignState::getMap(CampaignScenarioID scenarioId, IGame
|
|||||||
boost::to_lower(scenarioName);
|
boost::to_lower(scenarioName);
|
||||||
scenarioName += ':' + std::to_string(scenarioId.getNum());
|
scenarioName += ':' + std::to_string(scenarioId.getNum());
|
||||||
const auto & mapContent = mapPieces.find(scenarioId)->second;
|
const auto & mapContent = mapPieces.find(scenarioId)->second;
|
||||||
return mapService.loadMap(mapContent.data(), mapContent.size(), scenarioName, getModName(), getEncoding(), cb);
|
auto result = mapService.loadMap(mapContent.data(), mapContent.size(), scenarioName, getModName(), getEncoding(), cb);
|
||||||
|
|
||||||
|
mapTranslations[scenarioId] = result->texts;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CMapHeader> CampaignState::getMapHeader(CampaignScenarioID scenarioId) const
|
std::unique_ptr<CMapHeader> CampaignState::getMapHeader(CampaignScenarioID scenarioId) const
|
||||||
|
@ -244,6 +244,9 @@ class DLL_LINKAGE CampaignState : public Campaign
|
|||||||
/// List of all maps completed by player, in order of their completion
|
/// List of all maps completed by player, in order of their completion
|
||||||
std::vector<CampaignScenarioID> mapsConquered;
|
std::vector<CampaignScenarioID> mapsConquered;
|
||||||
|
|
||||||
|
/// List of previously loaded campaign maps, to prevent translation of transferred hero names getting lost after their original map has been completed
|
||||||
|
std::map<CampaignScenarioID, TextContainerRegistrable> mapTranslations;
|
||||||
|
|
||||||
std::map<CampaignScenarioID, std::vector<uint8_t> > mapPieces; //binary h3ms, scenario number -> map data
|
std::map<CampaignScenarioID, std::vector<uint8_t> > mapPieces; //binary h3ms, scenario number -> map data
|
||||||
std::map<CampaignScenarioID, ui8> chosenCampaignBonuses;
|
std::map<CampaignScenarioID, ui8> chosenCampaignBonuses;
|
||||||
std::optional<CampaignScenarioID> currentMap;
|
std::optional<CampaignScenarioID> currentMap;
|
||||||
@ -278,7 +281,7 @@ public:
|
|||||||
/// Returns true if all available scenarios have been completed and campaign is finished
|
/// Returns true if all available scenarios have been completed and campaign is finished
|
||||||
bool isCampaignFinished() const;
|
bool isCampaignFinished() const;
|
||||||
|
|
||||||
std::unique_ptr<CMap> getMap(CampaignScenarioID scenarioId, IGameCallback * cb) const;
|
std::unique_ptr<CMap> getMap(CampaignScenarioID scenarioId, IGameCallback * cb);
|
||||||
std::unique_ptr<CMapHeader> getMapHeader(CampaignScenarioID scenarioId) const;
|
std::unique_ptr<CMapHeader> getMapHeader(CampaignScenarioID scenarioId) const;
|
||||||
std::shared_ptr<CMapInfo> getMapInfo(CampaignScenarioID scenarioId) const;
|
std::shared_ptr<CMapInfo> getMapInfo(CampaignScenarioID scenarioId) const;
|
||||||
|
|
||||||
@ -314,6 +317,8 @@ public:
|
|||||||
h & currentMap;
|
h & currentMap;
|
||||||
h & chosenCampaignBonuses;
|
h & chosenCampaignBonuses;
|
||||||
h & campaignSet;
|
h & campaignSet;
|
||||||
|
if (h.version >= Handler::Version::CAMPAIGN_MAP_TRANSLATIONS)
|
||||||
|
h & mapTranslations;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -664,7 +664,7 @@ bool CGameStateCampaign::playerHasStartingHero(PlayerColor playerColor) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CMap> CGameStateCampaign::getCurrentMap() const
|
std::unique_ptr<CMap> CGameStateCampaign::getCurrentMap()
|
||||||
{
|
{
|
||||||
return gameState->scenarioOps->campState->getMap(CampaignScenarioID::NONE, gameState->callback);
|
return gameState->scenarioOps->campState->getMap(CampaignScenarioID::NONE, gameState->callback);
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public:
|
|||||||
void initTowns();
|
void initTowns();
|
||||||
|
|
||||||
bool playerHasStartingHero(PlayerColor player) const;
|
bool playerHasStartingHero(PlayerColor player) const;
|
||||||
std::unique_ptr<CMap> getCurrentMap() const;
|
std::unique_ptr<CMap> getCurrentMap();
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h)
|
template <typename Handler> void serialize(Handler &h)
|
||||||
{
|
{
|
||||||
|
@ -35,6 +35,7 @@ enum class ESerializationVersion : int32_t
|
|||||||
RELEASE_143, // 832 +text container in campaigns, +starting hero in RMG options
|
RELEASE_143, // 832 +text container in campaigns, +starting hero in RMG options
|
||||||
HAS_EXTRA_OPTIONS, // 833 +extra options struct as part of startinfo
|
HAS_EXTRA_OPTIONS, // 833 +extra options struct as part of startinfo
|
||||||
DESTROYED_OBJECTS, // 834 +list of objects destroyed by player
|
DESTROYED_OBJECTS, // 834 +list of objects destroyed by player
|
||||||
|
CAMPAIGN_MAP_TRANSLATIONS,
|
||||||
|
|
||||||
CURRENT = DESTROYED_OBJECTS
|
CURRENT = CAMPAIGN_MAP_TRANSLATIONS
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user