mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
Added possibility to define per-town tower icon for battle queue in siege
This commit is contained in:
parent
3d1f6df0e2
commit
861a6849f9
@ -429,11 +429,13 @@ void Graphics::loadErmuToPicture()
|
||||
assert (etp_idx == 44);
|
||||
}
|
||||
|
||||
void Graphics::addImageListEntry(size_t index, const std::string & listName, const std::string & imageName)
|
||||
void Graphics::addImageListEntry(size_t index, size_t group, const std::string & listName, const std::string & imageName)
|
||||
{
|
||||
if (!imageName.empty())
|
||||
{
|
||||
JsonNode entry;
|
||||
if (group != 0)
|
||||
entry["group"].Integer() = group;
|
||||
entry["frame"].Integer() = index;
|
||||
entry["file"].String() = imageName;
|
||||
|
||||
@ -443,7 +445,7 @@ void Graphics::addImageListEntry(size_t index, const std::string & listName, con
|
||||
|
||||
void Graphics::addImageListEntries(const EntityService * service)
|
||||
{
|
||||
auto cb = std::bind(&Graphics::addImageListEntry, this, _1, _2, _3);
|
||||
auto cb = std::bind(&Graphics::addImageListEntry, this, _1, _2, _3, _4);
|
||||
|
||||
auto loopCb = [&](const Entity * entity, bool & stop)
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ enum EFonts
|
||||
/// Handles fonts, hero images, town images, various graphics
|
||||
class Graphics
|
||||
{
|
||||
void addImageListEntry(size_t index, const std::string & listName, const std::string & imageName);
|
||||
void addImageListEntry(size_t index, size_t group, const std::string & listName, const std::string & imageName);
|
||||
|
||||
void addImageListEntries(const EntityService * service);
|
||||
|
||||
|
@ -17,7 +17,7 @@ class IBonusBearer;
|
||||
class DLL_LINKAGE Entity
|
||||
{
|
||||
public:
|
||||
using IconRegistar = std::function<void(int32_t index, const std::string & listName, const std::string & imageName)>;
|
||||
using IconRegistar = std::function<void(int32_t index, int32_t group, const std::string & listName, const std::string & imageName)>;
|
||||
|
||||
virtual ~Entity() = default;
|
||||
|
||||
|
@ -72,8 +72,8 @@ const std::string & CArtifact::getJsonKey() const
|
||||
|
||||
void CArtifact::registerIcons(const IconRegistar & cb) const
|
||||
{
|
||||
cb(getIconIndex(), "ARTIFACT", image);
|
||||
cb(getIconIndex(), "ARTIFACTLARGE", large);
|
||||
cb(getIconIndex(), 0, "ARTIFACT", image);
|
||||
cb(getIconIndex(), 0, "ARTIFACTLARGE", large);
|
||||
}
|
||||
|
||||
ArtifactID CArtifact::getId() const
|
||||
|
@ -46,8 +46,8 @@ const std::string & CCreature::getJsonKey() const
|
||||
|
||||
void CCreature::registerIcons(const IconRegistar & cb) const
|
||||
{
|
||||
cb(getIconIndex(), "CPRSMALL", smallIconName);
|
||||
cb(getIconIndex(), "TWCRPORT", largeIconName);
|
||||
cb(getIconIndex(), 0, "CPRSMALL", smallIconName);
|
||||
cb(getIconIndex(), 0, "TWCRPORT", largeIconName);
|
||||
}
|
||||
|
||||
CreatureID CCreature::getId() const
|
||||
|
@ -59,10 +59,10 @@ HeroTypeID CHero::getId() const
|
||||
|
||||
void CHero::registerIcons(const IconRegistar & cb) const
|
||||
{
|
||||
cb(getIconIndex(), "UN32", iconSpecSmall);
|
||||
cb(getIconIndex(), "UN44", iconSpecLarge);
|
||||
cb(getIconIndex(), "PORTRAITSLARGE", portraitLarge);
|
||||
cb(getIconIndex(), "PORTRAITSSMALL", portraitSmall);
|
||||
cb(getIconIndex(), 0, "UN32", iconSpecSmall);
|
||||
cb(getIconIndex(), 0, "UN44", iconSpecLarge);
|
||||
cb(getIconIndex(), 0, "PORTRAITSLARGE", portraitLarge);
|
||||
cb(getIconIndex(), 0, "PORTRAITSSMALL", portraitSmall);
|
||||
}
|
||||
|
||||
void CHero::updateFrom(const JsonNode & data)
|
||||
|
@ -70,9 +70,9 @@ void CSkill::registerIcons(const IconRegistar & cb) const
|
||||
{
|
||||
int frame = 2 + level + 3 * id;
|
||||
const LevelInfo & skillAtLevel = at(level);
|
||||
cb(frame, "SECSK32", skillAtLevel.iconSmall);
|
||||
cb(frame, "SECSKILL", skillAtLevel.iconMedium);
|
||||
cb(frame, "SECSK82", skillAtLevel.iconLarge);
|
||||
cb(frame, 0, "SECSK32", skillAtLevel.iconSmall);
|
||||
cb(frame, 0, "SECSKILL", skillAtLevel.iconMedium);
|
||||
cb(frame, 0, "SECSK82", skillAtLevel.iconLarge);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,15 +126,19 @@ void CFaction::registerIcons(const IconRegistar & cb) const
|
||||
if(town)
|
||||
{
|
||||
auto & info = town->clientInfo;
|
||||
cb(info.icons[0][0], "ITPT", info.iconLarge[0][0]);
|
||||
cb(info.icons[0][1], "ITPT", info.iconLarge[0][1]);
|
||||
cb(info.icons[1][0], "ITPT", info.iconLarge[1][0]);
|
||||
cb(info.icons[1][1], "ITPT", info.iconLarge[1][1]);
|
||||
cb(info.icons[0][0], 0, "ITPT", info.iconLarge[0][0]);
|
||||
cb(info.icons[0][1], 0, "ITPT", info.iconLarge[0][1]);
|
||||
cb(info.icons[1][0], 0, "ITPT", info.iconLarge[1][0]);
|
||||
cb(info.icons[1][1], 0, "ITPT", info.iconLarge[1][1]);
|
||||
|
||||
cb(info.icons[0][0] + 2, 0, "ITPA", info.iconSmall[0][0]);
|
||||
cb(info.icons[0][1] + 2, 0, "ITPA", info.iconSmall[0][1]);
|
||||
cb(info.icons[1][0] + 2, 0, "ITPA", info.iconSmall[1][0]);
|
||||
cb(info.icons[1][1] + 2, 0, "ITPA", info.iconSmall[1][1]);
|
||||
|
||||
cb(index, 1, "CPRSMALL", info.towerIconSmall);
|
||||
cb(index, 1, "TWCRPORT", info.towerIconLarge);
|
||||
|
||||
cb(info.icons[0][0] + 2, "ITPA", info.iconSmall[0][0]);
|
||||
cb(info.icons[0][1] + 2, "ITPA", info.iconSmall[0][1]);
|
||||
cb(info.icons[1][0] + 2, "ITPA", info.iconSmall[1][0]);
|
||||
cb(info.icons[1][1] + 2, "ITPA", info.iconSmall[1][1]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -755,6 +759,9 @@ CTown::ClientInfo::Point JsonToPoint(const JsonNode & node)
|
||||
void CTownHandler::loadSiegeScreen(CTown &town, const JsonNode & source)
|
||||
{
|
||||
town.clientInfo.siegePrefix = source["imagePrefix"].String();
|
||||
town.clientInfo.towerIconSmall = source["towerIconSmall"].String();
|
||||
town.clientInfo.towerIconLarge = source["towerIconLarge"].String();
|
||||
|
||||
VLC->modh->identifiers.requestIdentifier("creature", source["shooter"], [&town](si32 creature)
|
||||
{
|
||||
auto crId = CreatureID(creature);
|
||||
|
@ -303,6 +303,8 @@ public:
|
||||
std::string siegePrefix;
|
||||
std::vector<Point> siegePositions;
|
||||
CreatureID siegeShooter; // shooter creature ID
|
||||
std::string towerIconSmall;
|
||||
std::string towerIconLarge;
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
@ -321,6 +323,8 @@ public:
|
||||
h & siegePrefix;
|
||||
h & siegePositions;
|
||||
h & siegeShooter;
|
||||
h & towerIconSmall;
|
||||
h & towerIconLarge;
|
||||
}
|
||||
} clientInfo;
|
||||
|
||||
|
@ -505,10 +505,10 @@ std::unique_ptr<spells::Mechanics> CSpell::battleMechanics(const spells::IBattle
|
||||
|
||||
void CSpell::registerIcons(const IconRegistar & cb) const
|
||||
{
|
||||
cb(getIndex(), "SPELLS", iconBook);
|
||||
cb(getIndex()+1, "SPELLINT", iconEffect);
|
||||
cb(getIndex(), "SPELLBON", iconScenarioBonus);
|
||||
cb(getIndex(), "SPELLSCR", iconScroll);
|
||||
cb(getIndex(), 0, "SPELLS", iconBook);
|
||||
cb(getIndex()+1, 0, "SPELLINT", iconEffect);
|
||||
cb(getIndex(), 0, "SPELLBON", iconScenarioBonus);
|
||||
cb(getIndex(), 0, "SPELLSCR", iconScroll);
|
||||
}
|
||||
|
||||
void CSpell::updateFrom(const JsonNode & data)
|
||||
|
@ -310,11 +310,13 @@ std::shared_ptr<Animation> Graphics::getAnimation(const std::shared_ptr<const Ob
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Graphics::addImageListEntry(size_t index, const std::string & listName, const std::string & imageName)
|
||||
void Graphics::addImageListEntry(size_t index, size_t group, const std::string & listName, const std::string & imageName)
|
||||
{
|
||||
if (!imageName.empty())
|
||||
{
|
||||
JsonNode entry;
|
||||
if ( group != 0)
|
||||
entry["group"].Integer() = group;
|
||||
entry["frame"].Integer() = index;
|
||||
entry["file"].String() = imageName;
|
||||
|
||||
@ -324,7 +326,7 @@ void Graphics::addImageListEntry(size_t index, const std::string & listName, con
|
||||
|
||||
void Graphics::addImageListEntries(const EntityService * service)
|
||||
{
|
||||
auto cb = std::bind(&Graphics::addImageListEntry, this, _1, _2, _3);
|
||||
auto cb = std::bind(&Graphics::addImageListEntry, this, _1, _2, _3, _4);
|
||||
|
||||
auto loopCb = [&](const Entity * entity, bool & stop)
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ class JsonNode;
|
||||
/// Handles fonts, hero images, town images, various graphics
|
||||
class Graphics
|
||||
{
|
||||
void addImageListEntry(size_t index, const std::string & listName, const std::string & imageName);
|
||||
void addImageListEntry(size_t index, size_t group, const std::string & listName, const std::string & imageName);
|
||||
|
||||
void addImageListEntries(const EntityService * service);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user