1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-17 01:32:21 +02:00

Fixes for configurable markets support

- string "speech" can now be translated
- removed "title" string, VCMI will now use object name instead
- moved configuration of all "markets" into a separate json file
- added schema for validation of market objects
- removed serialization of translated strings from University
This commit is contained in:
Ivan Savenko
2024-11-19 14:38:27 +00:00
parent f0a71c9e21
commit f59834afe1
10 changed files with 252 additions and 179 deletions

View File

@ -57,7 +57,7 @@ std::string CGMarket::getPopupText(const CGHeroInstance * hero) const
int CGMarket::getMarketEfficiency() const
{
return marketEfficiency;
return getMarketHandler()->getMarketEfficiency();
}
int CGMarket::availableUnits(EMarketMode mode, int marketItemSerial) const
@ -125,6 +125,11 @@ std::vector<TradeItemBuy> CGUniversity::availableItemsIds(EMarketMode mode) cons
}
}
std::string CGUniversity::getSpeechTranslated() const
{
return getMarketHandler()->getSpeechTranslated();
}
void CGUniversity::onHeroVisit(const CGHeroInstance * h) const
{
cb->showObjectWindow(this, EOpenWindowMode::UNIVERSITY_WINDOW, h, true);

View File

@ -19,11 +19,10 @@ class MarketInstanceConstructor;
class DLL_LINKAGE CGMarket : public CGObjectInstance, public IMarket
{
protected:
std::shared_ptr<MarketInstanceConstructor> getMarketHandler() const;
public:
int marketEfficiency;
CGMarket(IGameCallback *cb);
///IObjectInterface
void onHeroVisit(const CGHeroInstance * h) const override; //open trading window
@ -48,7 +47,12 @@ public:
h & marketModes;
}
h & marketEfficiency;
if (h.version < Handler::Version::MARKET_TRANSLATION_FIX)
{
int unused = 0;
h & unused;
}
if (h.version < Handler::Version::NEW_MARKETS)
{
std::string speech;
@ -103,8 +107,8 @@ class DLL_LINKAGE CGUniversity : public CGMarket
{
public:
using CGMarket::CGMarket;
std::string speech; //currently shown only in university
std::string title;
std::string getSpeechTranslated() const;
std::vector<TradeItemBuy> skills; //available skills
@ -115,10 +119,11 @@ public:
{
h & static_cast<CGMarket&>(*this);
h & skills;
if (h.version >= Handler::Version::NEW_MARKETS)
if (h.version >= Handler::Version::NEW_MARKETS && h.version < Handler::Version::MARKET_TRANSLATION_FIX)
{
h & speech;
h & title;
std::string temp;
h & temp;
h & temp;
}
}
};