mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Adjust client part for markets
This commit is contained in:
parent
67e6920e23
commit
4e55279a6a
@ -1720,7 +1720,10 @@ void CPlayerInterface::showMarketWindow(const IMarket *market, const CGHeroInsta
|
||||
}
|
||||
else
|
||||
{
|
||||
GH.pushIntT<CMarketplaceWindow>(market, visitor, market->availableModes().front());
|
||||
if(market->allowsTrade(EMarketMode::CREATURE_UNDEAD))
|
||||
GH.pushIntT<CTransformerWindow>(market, visitor);
|
||||
else
|
||||
GH.pushIntT<CMarketplaceWindow>(market, visitor, market->availableModes().front());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -774,7 +774,7 @@ void CCastleBuildings::buildingClicked(BuildingID building, BuildingSubID::EBuil
|
||||
break;
|
||||
|
||||
case BuildingSubID::CREATURE_TRANSFORMER: //Skeleton Transformer
|
||||
GH.pushIntT<CTransformerWindow>(getHero(), town);
|
||||
GH.pushIntT<CTransformerWindow>(town, getHero());
|
||||
break;
|
||||
|
||||
case BuildingSubID::PORTAL_OF_SUMMONING:
|
||||
|
@ -1166,7 +1166,7 @@ void CTransformerWindow::makeDeal()
|
||||
for(auto & elem : items)
|
||||
{
|
||||
if(!elem->left)
|
||||
LOCPLINT->cb->trade(town, EMarketMode::CREATURE_UNDEAD, elem->id, 0, 0, hero);
|
||||
LOCPLINT->cb->trade(market, EMarketMode::CREATURE_UNDEAD, elem->id, 0, 0, hero);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1186,21 +1186,24 @@ void CTransformerWindow::updateGarrisons()
|
||||
item->update();
|
||||
}
|
||||
|
||||
CTransformerWindow::CTransformerWindow(const CGHeroInstance * _hero, const CGTownInstance * _town)
|
||||
CTransformerWindow::CTransformerWindow(const IMarket * _market, const CGHeroInstance * _hero)
|
||||
: CStatusbarWindow(PLAYER_COLORED, "SKTRNBK"),
|
||||
hero(_hero),
|
||||
town(_town)
|
||||
market(_market)
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
if(hero)
|
||||
army = hero;
|
||||
else
|
||||
army = town;
|
||||
|
||||
for(int i=0; i<GameConstants::ARMY_SIZE; i++)
|
||||
army = dynamic_cast<const CArmedInstance *>(market); //for town only
|
||||
|
||||
if(army)
|
||||
{
|
||||
if(army->getCreature(SlotID(i)))
|
||||
items.push_back(std::make_shared<CItem>(this, army->getStackCount(SlotID(i)), i));
|
||||
for(int i = 0; i < GameConstants::ARMY_SIZE; i++)
|
||||
{
|
||||
if(army->getCreature(SlotID(i)))
|
||||
items.push_back(std::make_shared<CItem>(this, army->getStackCount(SlotID(i)), i));
|
||||
}
|
||||
}
|
||||
|
||||
all = std::make_shared<CButton>(Point(146, 416), "ALTARMY.DEF", CGI->generaltexth->zelp[590], [&](){ addAll(); }, SDLK_a);
|
||||
@ -1291,6 +1294,9 @@ CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, const IMarket
|
||||
bars->setCustom("UNIVGOLD", 1, 0);
|
||||
bars->setCustom("UNIVGREN", 2, 0);
|
||||
bars->preload();
|
||||
|
||||
std::string titleStr = CGI->generaltexth->allTexts[602];
|
||||
std::string speechStr = CGI->generaltexth->allTexts[603];
|
||||
|
||||
if(auto town = dynamic_cast<const CGTownInstance *>(_market))
|
||||
{
|
||||
@ -1298,13 +1304,21 @@ CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, const IMarket
|
||||
auto bid = town->town->getSpecialBuilding(BuildingSubID::MAGIC_UNIVERSITY)->bid;
|
||||
titlePic = std::make_shared<CAnimImage>((*CGI->townh)[faction]->town->clientInfo.buildingsIcons, bid);
|
||||
}
|
||||
else if(auto uni = dynamic_cast<const CGUniversity *>(_market); uni->appearance)
|
||||
{
|
||||
titlePic = std::make_shared<CAnimImage>(uni->appearance->animationFile, 0);
|
||||
titleStr = uni->title;
|
||||
speechStr = uni->speech;
|
||||
}
|
||||
else
|
||||
{
|
||||
titlePic = std::make_shared<CPicture>("UNIVBLDG");
|
||||
}
|
||||
|
||||
titlePic->center(Point(232 + pos.x, 76 + pos.y));
|
||||
|
||||
clerkSpeech = std::make_shared<CTextBox>(CGI->generaltexth->allTexts[603], Rect(24, 129, 413, 70), 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
|
||||
title = std::make_shared<CLabel>(231, 26, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[602]);
|
||||
clerkSpeech = std::make_shared<CTextBox>(speechStr, Rect(24, 129, 413, 70), 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
|
||||
title = std::make_shared<CLabel>(231, 26, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, titleStr);
|
||||
|
||||
std::vector<int> goods = market->availableItemsIds(EMarketMode::RESOURCE_SKILL);
|
||||
assert(goods.size() == 4);
|
||||
@ -1318,7 +1332,7 @@ CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, const IMarket
|
||||
|
||||
void CUniversityWindow::makeDeal(int skill)
|
||||
{
|
||||
LOCPLINT->cb->trade(dynamic_cast<const CGObjectInstance *>(market), EMarketMode::RESOURCE_SKILL, 6, skill, 1, hero);
|
||||
LOCPLINT->cb->trade(market, EMarketMode::RESOURCE_SKILL, 6, skill, 1, hero);
|
||||
}
|
||||
|
||||
|
||||
|
@ -382,7 +382,7 @@ class CTransformerWindow : public CStatusbarWindow, public CGarrisonHolder
|
||||
|
||||
const CArmedInstance * army;//object with army for transforming (hero or town)
|
||||
const CGHeroInstance * hero;//only if we have hero in town
|
||||
const CGTownInstance * town;//market, town garrison is used if hero == nullptr
|
||||
const IMarket * market;//market, town garrison is used if hero == nullptr
|
||||
|
||||
std::shared_ptr<CLabel> titleLeft;
|
||||
std::shared_ptr<CLabel> titleRight;
|
||||
@ -399,7 +399,7 @@ public:
|
||||
void makeDeal();
|
||||
void addAll();
|
||||
void updateGarrisons() override;
|
||||
CTransformerWindow(const CGHeroInstance * _hero, const CGTownInstance * _town);
|
||||
CTransformerWindow(const IMarket * _market, const CGHeroInstance * _hero);
|
||||
};
|
||||
|
||||
class CUniversityWindow : public CStatusbarWindow
|
||||
|
Loading…
Reference in New Issue
Block a user