1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

creature/town biography/description

This commit is contained in:
Laserlicht 2024-04-12 23:35:39 +02:00 committed by GitHub
parent 3e0eb3ac02
commit e4b60baa3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 58 additions and 0 deletions

View File

@ -466,6 +466,9 @@ void CInteractableTownTooltip::init(const CGTownInstance * town)
if(town->id == townId && town->builtBuildings.count(BuildingID::TAVERN))
LOCPLINT->showTavernWindow(town, nullptr, QueryID::NONE);
}
}, [&]{
if(!town->town->faction->getDescriptionTranslated().empty())
CRClickPopup::createAndPush(town->town->faction->getDescriptionTranslated());
});
fastMarket = std::make_shared<LRClickableArea>(Rect(143, 31, 30, 34), []()
{

View File

@ -1349,6 +1349,9 @@ void CCastleInterface::recreateIcons()
{
if(town->builtBuildings.count(BuildingID::TAVERN))
LOCPLINT->showTavernWindow(town, nullptr, QueryID::NONE);
}, [&]{
if(!town->town->faction->getDescriptionTranslated().empty())
CRClickPopup::createAndPush(town->town->faction->getDescriptionTranslated());
});
creainfo.clear();

View File

@ -22,6 +22,7 @@
#include "../widgets/Images.h"
#include "../widgets/TextControls.h"
#include "../widgets/ObjectLists.h"
#include "../windows/InfoWindows.h"
#include "../gui/CGuiHandler.h"
#include "../gui/Shortcut.h"
@ -517,6 +518,10 @@ CStackWindow::MainSection::MainSection(CStackWindow * owner, int yOffset, bool s
};
animation = std::make_shared<CCreaturePic>(5, 41, parent->info->creature);
animationArea = std::make_shared<LRClickableArea>(Rect(5, 41, 100, 130), nullptr, [&]{
if(!parent->info->creature->getBiographyTranslated().empty())
CRClickPopup::createAndPush(parent->info->creature->getBiographyTranslated());
});
if(parent->info->stackNode != nullptr && parent->info->commander == nullptr)
{

View File

@ -29,6 +29,7 @@ class CButton;
class CMultiLineLabel;
class CListBox;
class CCommanderArtPlace;
class LRClickableArea;
class CCommanderSkillIcon : public LRClickableAreaWText //TODO: maybe bring commander skill button initialization logic inside?
{
@ -132,6 +133,7 @@ class CStackWindow : public CWindowObject
};
std::shared_ptr<CCreaturePic> animation;
std::shared_ptr<LRClickableArea> animationArea;
std::shared_ptr<CLabel> name;
std::shared_ptr<CPicture> icons;
std::shared_ptr<MoraleLuckBox> morale;

View File

@ -832,6 +832,9 @@ CTownItem::CTownItem(const CGTownInstance * Town)
{
if(town->builtBuildings.count(BuildingID::TAVERN))
LOCPLINT->showTavernWindow(town, nullptr, QueryID::NONE);
}, [&]{
if(!town->town->faction->getDescriptionTranslated().empty())
CRClickPopup::createAndPush(town->town->faction->getDescriptionTranslated());
});
fastMarket = std::make_shared<LRClickableArea>(Rect(153, 6, 65, 64), []()
{

View File

@ -41,6 +41,10 @@
}
}
},
"biography" : {
"type" : "string",
"description" : "Creature biography"
},
"faction" : {
"type" : "string",
"description" : "Faction this creature belongs to. Examples: castle, rampart"

View File

@ -40,6 +40,10 @@
"type" : "string",
"description" : "Localizable faction name, e.g. Rampart"
},
"description" : {
"type" : "string",
"description" : "Description about the faction"
},
"alignment" : {
"type" : "string",
"enum" : [ "good", "neutral", "evil" ],

View File

@ -31,6 +31,10 @@ In order to make functional creature you also need:
"singular" : "Creature",
"plural" : "Creatures"
},
// Biography and information about creature
"biography" : "",
"level" : 0,
// Marks this object as special and not available by default

View File

@ -59,6 +59,9 @@ Each town requires a set of buildings (Around 30-45 buildings)
// Localizable faction name, e.g. "Rampart"
"name" : "",
// Description of town (e.g. history or story about town)
"description" : "",
// Faction alignment. Can be good, neutral (default) or evil.
"alignment" : "",

View File

@ -199,6 +199,11 @@ std::string CCreature::getNameTextID() const
return getNameSingularTextID();
}
std::string CCreature::getBiographyTranslated() const
{
return VLC->generaltexth->translate(getBiographyTextID());
}
std::string CCreature::getNamePluralTextID() const
{
return TextIdentifier("creatures", modScope, identifier, "name", "plural" ).get();
@ -209,6 +214,11 @@ std::string CCreature::getNameSingularTextID() const
return TextIdentifier("creatures", modScope, identifier, "name", "singular" ).get();
}
std::string CCreature::getBiographyTextID() const
{
return TextIdentifier("creatures", modScope, identifier, "biography").get();
}
CCreature::CreatureQuantityId CCreature::getQuantityID(const int & quantity)
{
if (quantity<5)
@ -600,6 +610,7 @@ CCreature * CCreatureHandler::loadFromJson(const std::string & scope, const Json
VLC->generaltexth->registerString(scope, cre->getNameSingularTextID(), node["name"]["singular"].String());
VLC->generaltexth->registerString(scope, cre->getNamePluralTextID(), node["name"]["plural"].String());
VLC->generaltexth->registerString(scope, cre->getBiographyTextID(), node["biography"].String());
cre->addBonus(node["hitPoints"].Integer(), BonusType::STACK_HEALTH);
cre->addBonus(node["speed"].Integer(), BonusType::STACKS_SPEED);

View File

@ -51,6 +51,9 @@ class DLL_LINKAGE CCreature : public Creature, public CBonusSystemNode
TResources cost; //cost[res_id] - amount of that resource required to buy creature from dwelling
public:
std::string getBiographyTranslated() const;
std::string getBiographyTextID() const;
ui32 ammMin; // initial size of stack of these creatures on adventure map (if not set in editor)
ui32 ammMax;

View File

@ -188,6 +188,16 @@ std::string CFaction::getNameTextID() const
return TextIdentifier("faction", modScope, identifier, "name").get();
}
std::string CFaction::getDescriptionTranslated() const
{
return VLC->generaltexth->translate(getDescriptionTextID());
}
std::string CFaction::getDescriptionTextID() const
{
return TextIdentifier("faction", modScope, identifier, "description").get();
}
FactionID CFaction::getId() const
{
return FactionID(index);
@ -1037,6 +1047,7 @@ CFaction * CTownHandler::loadFromJson(const std::string & scope, const JsonNode
faction->identifier = identifier;
VLC->generaltexth->registerString(scope, faction->getNameTextID(), source["name"].String());
VLC->generaltexth->registerString(scope, faction->getDescriptionTranslated(), source["description"].String());
faction->creatureBg120 = ImagePath::fromJson(source["creatureBackground"]["120px"]);
faction->creatureBg130 = ImagePath::fromJson(source["creatureBackground"]["130px"]);

View File

@ -192,6 +192,8 @@ public:
std::string getNameTranslated() const override;
std::string getNameTextID() const override;
std::string getDescriptionTranslated() const;
std::string getDescriptionTextID() const;
bool hasTown() const override;
TerrainId getNativeTerrain() const override;