1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-15 20:03:15 +02:00

Move trading window title to config

This commit is contained in:
nordsoft
2023-04-29 16:10:30 +04:00
committed by Nordsoft91
parent 11840b9f6d
commit a4fd6c1c92
4 changed files with 18 additions and 35 deletions

View File

@@ -673,7 +673,7 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket * Market, const CGHeroInsta
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
madeTransaction = false;
bool sliderNeeded = true;
bool sliderNeeded = (mode != EMarketMode::RESOURCE_ARTIFACT && mode != EMarketMode::ARTIFACT_RESOURCE);
statusBar = CGStatusBar::create(std::make_shared<CPicture>(background->getSurface(), Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
@@ -688,7 +688,6 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket * Market, const CGHeroInsta
break;
case EMarketMode::RESOURCE_ARTIFACT:
title = (*CGI->townh)[o->subID]->town->buildings[BuildingID::ARTIFACT_MERCHANT]->getNameTranslated();
sliderNeeded = false;
break;
case EMarketMode::ARTIFACT_RESOURCE:
title = (*CGI->townh)[o->subID]->town->buildings[BuildingID::ARTIFACT_MERCHANT]->getNameTranslated();
@@ -696,34 +695,15 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket * Market, const CGHeroInsta
// create image that copies part of background containing slot MISC_1 into position of slot MISC_5
// this is workaround for bug in H3 files where this slot for ragdoll on this screen is missing
images.push_back(std::make_shared<CPicture>(background->getSurface(), Rect(20, 187, 47, 47), 18, 339 ));
sliderNeeded = false;
break;
default:
title = CGI->generaltexth->allTexts[158];
break;
}
}
else
else if(auto * o = dynamic_cast<const CGMarket *>(market))
{
if(auto * o = dynamic_cast<const CGObjectInstance *>(market))
{
switch(o->ID)
{
case Obj::BLACK_MARKET:
title = CGI->generaltexth->allTexts[349];
sliderNeeded = false;
break;
case Obj::TRADING_POST:
title = CGI->generaltexth->allTexts[159];
break;
case Obj::TRADING_POST_SNOW:
title = CGI->generaltexth->allTexts[159];
break;
default:
title = o->getObjectName();
break;
}
}
title = o->title.empty() ? o->getObjectName() : o->title;
}
titleLabel = std::make_shared<CLabel>(300, 27, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, title);

View File

@@ -54,7 +54,8 @@
"rarity" : 100
},
"modes" : ["resource-resource", "resource-player"],
"efficacy" : 5
"efficacy" : 5,
"title" : "core.genrltxt.159"
}
}
},
@@ -77,7 +78,8 @@
"rarity" : 100
},
"modes" : ["resource-resource", "resource-player"],
"efficacy" : 5
"efficacy" : 5,
"title" : "core.genrltxt.159"
}
}
},
@@ -115,7 +117,8 @@
"value" : 8000,
"rarity" : 20
},
"modes" : ["resource-artifact"]
"modes" : ["resource-artifact"],
"title" : "core.genrltxt.349"
}
}
},

View File

@@ -37,6 +37,10 @@ public:
std::set<EMarketMode::EMarketMode> marketModes;
int marketEfficacy = 5;
//window variables
std::string title;
std::string speech; //currently shown only in university
CGMarket();
///IObjectInterface
void onHeroVisit(const CGHeroInstance * h) const override; //open trading window
@@ -53,6 +57,8 @@ public:
h & static_cast<CGObjectInstance&>(*this);
h & marketModes;
h & marketEfficacy;
h & title;
h & speech;
}
};
@@ -76,10 +82,6 @@ class DLL_LINKAGE CGUniversity : public CGMarket
public:
int skillsTotal = 4;
std::vector<int> skills; //available skills
//window variables
std::string title;
std::string speech;
std::vector<int> availableItemsIds(EMarketMode::EMarketMode mode) const override;
void initObj(CRandomGenerator & rand) override;//set skills for trade
@@ -89,8 +91,6 @@ public:
{
h & static_cast<CGMarket&>(*this);
h & skills;
h & title;
h & speech;
}
};

View File

@@ -335,6 +335,9 @@ CGObjectInstance * MarketInstanceConstructor::create(std::shared_ptr<const Objec
if(marketEfficacy >= 0)
market->marketEfficacy = marketEfficacy;
market->title = VLC->generaltexth->translate(title);
market->speech = VLC->generaltexth->translate(speech);
return market;
}
@@ -344,9 +347,6 @@ void MarketInstanceConstructor::configureObject(CGObjectInstance * object, CRand
{
for(auto skill : JsonRandom::loadSecondary(predefinedOffer, rng))
university->skills.push_back(skill.first.getNum());
university->title = VLC->generaltexth->translate(title);
university->speech = VLC->generaltexth->translate(speech);
}
}