mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Merge pull request #1429 from dydzio0614/creature-numeric-quantities
Implement numeric creature descriptions with config toggle on/off
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
#include "../../lib/CGeneralTextHandler.h"
|
#include "../../lib/CGeneralTextHandler.h"
|
||||||
#include "../../lib/CModHandler.h"
|
#include "../../lib/CModHandler.h"
|
||||||
#include "../../lib/CGameState.h"
|
#include "../../lib/CGameState.h"
|
||||||
|
#include "../../lib/CConfigHandler.h"
|
||||||
|
|
||||||
void CHoverableArea::hover (bool on)
|
void CHoverableArea::hover (bool on)
|
||||||
{
|
{
|
||||||
@@ -256,7 +257,16 @@ void CArmyTooltip::init(const InfoAboutArmy &army)
|
|||||||
{
|
{
|
||||||
//if =0 - we have no information about stack size at all
|
//if =0 - we have no information about stack size at all
|
||||||
if(slot.second.count)
|
if(slot.second.count)
|
||||||
subtitle = CGI->generaltexth->arraytxt[171 + 3*(slot.second.count)];
|
{
|
||||||
|
if(settings["gameTweaks"]["numericCreaturesQuantities"].Bool())
|
||||||
|
{
|
||||||
|
subtitle = CCreature::getQuantityRangeStringForId((CCreature::CreatureQuantityId)slot.second.count);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
subtitle = CGI->generaltexth->arraytxt[171 + 3*(slot.second.count)];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
subtitles.push_back(std::make_shared<CLabel>(slotsPos[slot.first.getNum()].x + 17, slotsPos[slot.first.getNum()].y + 41, FONT_TINY, ETextAlignment::CENTER, Colors::WHITE, subtitle));
|
subtitles.push_back(std::make_shared<CLabel>(slotsPos[slot.first.getNum()].x + 17, slotsPos[slot.first.getNum()].y + 41, FONT_TINY, ETextAlignment::CENTER, Colors::WHITE, subtitle));
|
||||||
|
@@ -23,6 +23,19 @@
|
|||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
const std::map<CCreature::CreatureQuantityId, std::string> CCreature::creatureQuantityRanges =
|
||||||
|
{
|
||||||
|
{CCreature::CreatureQuantityId::FEW, "1-4"},
|
||||||
|
{CCreature::CreatureQuantityId::SEVERAL, "5-9"},
|
||||||
|
{CCreature::CreatureQuantityId::PACK, "10-19"},
|
||||||
|
{CCreature::CreatureQuantityId::LOTS, "20-49"},
|
||||||
|
{CCreature::CreatureQuantityId::HORDE, "50-99"},
|
||||||
|
{CCreature::CreatureQuantityId::THRONG, "100-249"},
|
||||||
|
{CCreature::CreatureQuantityId::SWARM, "250-499"},
|
||||||
|
{CCreature::CreatureQuantityId::ZOUNDS, "500-999"},
|
||||||
|
{CCreature::CreatureQuantityId::LEGION, "1000+"}
|
||||||
|
};
|
||||||
|
|
||||||
int32_t CCreature::getIndex() const
|
int32_t CCreature::getIndex() const
|
||||||
{
|
{
|
||||||
return idNumber.toEnum();
|
return idNumber.toEnum();
|
||||||
@@ -185,25 +198,36 @@ std::string CCreature::getNameSingularTextID() const
|
|||||||
return TextIdentifier("creatures", modScope, identifier, "name", "singular" ).get();
|
return TextIdentifier("creatures", modScope, identifier, "name", "singular" ).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CCreature::getQuantityID(const int & quantity)
|
CCreature::CreatureQuantityId CCreature::getQuantityID(const int & quantity)
|
||||||
{
|
{
|
||||||
if (quantity<5)
|
if (quantity<5)
|
||||||
return 1;
|
return CCreature::CreatureQuantityId::FEW;
|
||||||
if (quantity<10)
|
if (quantity<10)
|
||||||
return 2;
|
return CCreature::CreatureQuantityId::SEVERAL;
|
||||||
if (quantity<20)
|
if (quantity<20)
|
||||||
return 3;
|
return CCreature::CreatureQuantityId::PACK;
|
||||||
if (quantity<50)
|
if (quantity<50)
|
||||||
return 4;
|
return CCreature::CreatureQuantityId::LOTS;
|
||||||
if (quantity<100)
|
if (quantity<100)
|
||||||
return 5;
|
return CCreature::CreatureQuantityId::HORDE;
|
||||||
if (quantity<250)
|
if (quantity<250)
|
||||||
return 6;
|
return CCreature::CreatureQuantityId::THRONG;
|
||||||
if (quantity<500)
|
if (quantity<500)
|
||||||
return 7;
|
return CCreature::CreatureQuantityId::SWARM;
|
||||||
if (quantity<1000)
|
if (quantity<1000)
|
||||||
return 8;
|
return CCreature::CreatureQuantityId::ZOUNDS;
|
||||||
return 9;
|
|
||||||
|
return CCreature::CreatureQuantityId::LEGION;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CCreature::getQuantityRangeStringForId(const CCreature::CreatureQuantityId & quantityId)
|
||||||
|
{
|
||||||
|
if(creatureQuantityRanges.find(quantityId) != creatureQuantityRanges.end())
|
||||||
|
return creatureQuantityRanges.at(quantityId);
|
||||||
|
|
||||||
|
logGlobal->error("Wrong quantityId: %d", (int)quantityId);
|
||||||
|
assert(0);
|
||||||
|
return "[ERROR]";
|
||||||
}
|
}
|
||||||
|
|
||||||
int CCreature::estimateCreatureCount(ui32 countID)
|
int CCreature::estimateCreatureCount(ui32 countID)
|
||||||
|
@@ -61,6 +61,19 @@ public:
|
|||||||
std::string smallIconName;
|
std::string smallIconName;
|
||||||
std::string largeIconName;
|
std::string largeIconName;
|
||||||
|
|
||||||
|
enum class CreatureQuantityId
|
||||||
|
{
|
||||||
|
FEW = 1,
|
||||||
|
SEVERAL,
|
||||||
|
PACK,
|
||||||
|
LOTS,
|
||||||
|
HORDE,
|
||||||
|
THRONG,
|
||||||
|
SWARM,
|
||||||
|
ZOUNDS,
|
||||||
|
LEGION
|
||||||
|
};
|
||||||
|
|
||||||
struct CreatureAnimation
|
struct CreatureAnimation
|
||||||
{
|
{
|
||||||
struct RayColor {
|
struct RayColor {
|
||||||
@@ -185,7 +198,8 @@ public:
|
|||||||
bool isGood () const;
|
bool isGood () const;
|
||||||
bool isEvil () const;
|
bool isEvil () const;
|
||||||
si32 maxAmount(const std::vector<si32> &res) const; //how many creatures can be bought
|
si32 maxAmount(const std::vector<si32> &res) const; //how many creatures can be bought
|
||||||
static int getQuantityID(const int & quantity); //1 - a few, 2 - several, 3 - pack, 4 - lots, 5 - horde, 6 - throng, 7 - swarm, 8 - zounds, 9 - legion
|
static CCreature::CreatureQuantityId getQuantityID(const int & quantity);
|
||||||
|
static std::string getQuantityRangeStringForId(const CCreature::CreatureQuantityId & quantityId);
|
||||||
static int estimateCreatureCount(ui32 countID); //reverse version of above function, returns middle of range
|
static int estimateCreatureCount(ui32 countID); //reverse version of above function, returns middle of range
|
||||||
bool isMyUpgrade(const CCreature *anotherCre) const;
|
bool isMyUpgrade(const CCreature *anotherCre) const;
|
||||||
|
|
||||||
@@ -240,6 +254,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void fillWarMachine();
|
void fillWarMachine();
|
||||||
|
static const std::map<CreatureQuantityId, std::string> creatureQuantityRanges;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DLL_LINKAGE CCreatureHandler : public CHandlerBase<CreatureID, Creature, CCreature, CreatureService>
|
class DLL_LINKAGE CCreatureHandler : public CHandlerBase<CreatureID, Creature, CCreature, CreatureService>
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "CCreatureSet.h"
|
#include "CCreatureSet.h"
|
||||||
|
|
||||||
|
#include "CConfigHandler.h"
|
||||||
#include "CCreatureHandler.h"
|
#include "CCreatureHandler.h"
|
||||||
#include "VCMI_Lib.h"
|
#include "VCMI_Lib.h"
|
||||||
#include "CModHandler.h"
|
#include "CModHandler.h"
|
||||||
@@ -372,9 +373,15 @@ std::string CCreatureSet::getRoughAmount(SlotID slot, int mode) const
|
|||||||
{
|
{
|
||||||
/// Mode represent return string format
|
/// Mode represent return string format
|
||||||
/// "Pack" - 0, "A pack of" - 1, "a pack of" - 2
|
/// "Pack" - 0, "A pack of" - 1, "a pack of" - 2
|
||||||
int quantity = CCreature::getQuantityID(getStackCount(slot));
|
CCreature::CreatureQuantityId quantity = CCreature::getQuantityID(getStackCount(slot));
|
||||||
if(quantity)
|
|
||||||
return VLC->generaltexth->arraytxt[(174 + mode) + 3*CCreature::getQuantityID(getStackCount(slot))];
|
if((int)quantity)
|
||||||
|
{
|
||||||
|
if(settings["gameTweaks"]["numericCreaturesQuantities"].Bool())
|
||||||
|
return CCreature::getQuantityRangeStringForId(quantity);
|
||||||
|
|
||||||
|
return VLC->generaltexth->arraytxt[(174 + mode) + 3*(int)quantity];
|
||||||
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -700,7 +707,7 @@ void CStackInstance::init()
|
|||||||
setNodeType(STACK_INSTANCE);
|
setNodeType(STACK_INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CStackInstance::getQuantityID() const
|
CCreature::CreatureQuantityId CStackInstance::getQuantityID() const
|
||||||
{
|
{
|
||||||
return CCreature::getQuantityID(count);
|
return CCreature::getQuantityID(count);
|
||||||
}
|
}
|
||||||
@@ -814,10 +821,15 @@ void CStackInstance::setArmyObj(const CArmedInstance * ArmyObj)
|
|||||||
|
|
||||||
std::string CStackInstance::getQuantityTXT(bool capitalized) const
|
std::string CStackInstance::getQuantityTXT(bool capitalized) const
|
||||||
{
|
{
|
||||||
int quantity = getQuantityID();
|
CCreature::CreatureQuantityId quantity = getQuantityID();
|
||||||
|
|
||||||
if (quantity)
|
if ((int)quantity)
|
||||||
return VLC->generaltexth->arraytxt[174 + quantity*3 - 1 - capitalized];
|
{
|
||||||
|
if(settings["gameTweaks"]["numericCreaturesQuantities"].Bool())
|
||||||
|
return CCreature::getQuantityRangeStringForId(quantity);
|
||||||
|
|
||||||
|
return VLC->generaltexth->arraytxt[174 + (int)quantity*3 - 1 - capitalized];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,7 @@ class DLL_LINKAGE CStackBasicDescriptor
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const CCreature *type;
|
const CCreature *type;
|
||||||
TQuantity count;
|
TQuantity count; //exact quantity or quantity ID from CCreature::getQuantityID when getting info about enemy army
|
||||||
|
|
||||||
CStackBasicDescriptor();
|
CStackBasicDescriptor();
|
||||||
CStackBasicDescriptor(CreatureID id, TQuantity Count);
|
CStackBasicDescriptor(CreatureID id, TQuantity Count);
|
||||||
@@ -93,7 +93,7 @@ public:
|
|||||||
std::string bonusToGraphics(const std::shared_ptr<Bonus>& bonus) const; //file name of graphics from StackSkills , in future possibly others
|
std::string bonusToGraphics(const std::shared_ptr<Bonus>& bonus) const; //file name of graphics from StackSkills , in future possibly others
|
||||||
|
|
||||||
virtual ui64 getPower() const;
|
virtual ui64 getPower() const;
|
||||||
int getQuantityID() const;
|
CCreature::CreatureQuantityId getQuantityID() const;
|
||||||
std::string getQuantityTXT(bool capitalized = true) const;
|
std::string getQuantityTXT(bool capitalized = true) const;
|
||||||
virtual int getExpRank() const;
|
virtual int getExpRank() const;
|
||||||
virtual int getLevel() const; //different for regular stack and commander
|
virtual int getLevel() const; //different for regular stack and commander
|
||||||
|
@@ -3105,7 +3105,7 @@ ArmyDescriptor::ArmyDescriptor(const CArmedInstance *army, bool detailed)
|
|||||||
if(detailed)
|
if(detailed)
|
||||||
(*this)[elem.first] = *elem.second;
|
(*this)[elem.first] = *elem.second;
|
||||||
else
|
else
|
||||||
(*this)[elem.first] = CStackBasicDescriptor(elem.second->type, elem.second->getQuantityID());
|
(*this)[elem.first] = CStackBasicDescriptor(elem.second->type, (int)elem.second->getQuantityID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
#include "../spells/CSpellHandler.h"
|
#include "../spells/CSpellHandler.h"
|
||||||
|
|
||||||
#include "../NetPacks.h"
|
#include "../NetPacks.h"
|
||||||
|
#include "../CConfigHandler.h"
|
||||||
#include "../CGeneralTextHandler.h"
|
#include "../CGeneralTextHandler.h"
|
||||||
#include "../CModHandler.h"
|
#include "../CModHandler.h"
|
||||||
#include "../IGameCallback.h"
|
#include "../IGameCallback.h"
|
||||||
@@ -190,7 +191,10 @@ void CGDwelling::onHeroVisit( const CGHeroInstance * h ) const
|
|||||||
bd.player = h->tempOwner;
|
bd.player = h->tempOwner;
|
||||||
bd.text.addTxt(MetaString::GENERAL_TXT, 421); //Much to your dismay, the %s is guarded by %s %s. Do you wish to fight the guards?
|
bd.text.addTxt(MetaString::GENERAL_TXT, 421); //Much to your dismay, the %s is guarded by %s %s. Do you wish to fight the guards?
|
||||||
bd.text.addReplacement(ID == Obj::CREATURE_GENERATOR1 ? MetaString::CREGENS : MetaString::CREGENS4, subID);
|
bd.text.addReplacement(ID == Obj::CREATURE_GENERATOR1 ? MetaString::CREGENS : MetaString::CREGENS4, subID);
|
||||||
bd.text.addReplacement(MetaString::ARRAY_TXT, 173 + Slots().begin()->second->getQuantityID()*3);
|
if(settings["gameTweaks"]["numericCreaturesQuantities"].Bool())
|
||||||
|
bd.text.addReplacement(CCreature::getQuantityRangeStringForId(Slots().begin()->second->getQuantityID()));
|
||||||
|
else
|
||||||
|
bd.text.addReplacement(MetaString::ARRAY_TXT, 173 + (int)Slots().begin()->second->getQuantityID()*3);
|
||||||
bd.text.addReplacement(*Slots().begin()->second);
|
bd.text.addReplacement(*Slots().begin()->second);
|
||||||
cb->showBlockingDialog(&bd);
|
cb->showBlockingDialog(&bd);
|
||||||
return;
|
return;
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
#include "../NetPacks.h"
|
#include "../NetPacks.h"
|
||||||
#include "../CGeneralTextHandler.h"
|
#include "../CGeneralTextHandler.h"
|
||||||
#include "../CSoundBase.h"
|
#include "../CSoundBase.h"
|
||||||
|
#include "../CConfigHandler.h"
|
||||||
#include "../CModHandler.h"
|
#include "../CModHandler.h"
|
||||||
#include "../CHeroHandler.h"
|
#include "../CHeroHandler.h"
|
||||||
#include "../CSkillHandler.h"
|
#include "../CSkillHandler.h"
|
||||||
@@ -101,9 +102,12 @@ std::string CGCreature::getHoverText(PlayerColor player) const
|
|||||||
|
|
||||||
std::string hoverName;
|
std::string hoverName;
|
||||||
MetaString ms;
|
MetaString ms;
|
||||||
int pom = stacks.begin()->second->getQuantityID();
|
CCreature::CreatureQuantityId monsterQuantityId = stacks.begin()->second->getQuantityID();
|
||||||
pom = 172 + 3*pom;
|
int quantityTextIndex = 172 + 3 * (int)monsterQuantityId;
|
||||||
ms.addTxt(MetaString::ARRAY_TXT,pom);
|
if(settings["gameTweaks"]["numericCreaturesQuantities"].Bool())
|
||||||
|
ms << CCreature::getQuantityRangeStringForId(monsterQuantityId);
|
||||||
|
else
|
||||||
|
ms.addTxt(MetaString::ARRAY_TXT, quantityTextIndex);
|
||||||
ms << " " ;
|
ms << " " ;
|
||||||
ms.addTxt(MetaString::CRE_PL_NAMES,subID);
|
ms.addTxt(MetaString::CRE_PL_NAMES,subID);
|
||||||
ms.toString(hoverName);
|
ms.toString(hoverName);
|
||||||
|
Reference in New Issue
Block a user