mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
market window
This commit is contained in:
@@ -135,6 +135,7 @@ set(client_SRCS
|
|||||||
windows/CHeroWindow.cpp
|
windows/CHeroWindow.cpp
|
||||||
windows/CKingdomInterface.cpp
|
windows/CKingdomInterface.cpp
|
||||||
windows/CMapOverview.cpp
|
windows/CMapOverview.cpp
|
||||||
|
windows/CMarketWindow.cpp
|
||||||
windows/CMessage.cpp
|
windows/CMessage.cpp
|
||||||
windows/CPuzzleWindow.cpp
|
windows/CPuzzleWindow.cpp
|
||||||
windows/CQuestLog.cpp
|
windows/CQuestLog.cpp
|
||||||
@@ -320,6 +321,7 @@ set(client_HEADERS
|
|||||||
windows/CKingdomInterface.h
|
windows/CKingdomInterface.h
|
||||||
windows/CMessage.h
|
windows/CMessage.h
|
||||||
windows/CMapOverview.h
|
windows/CMapOverview.h
|
||||||
|
windows/CMarketWindow.h
|
||||||
windows/CPuzzleWindow.h
|
windows/CPuzzleWindow.h
|
||||||
windows/CQuestLog.h
|
windows/CQuestLog.h
|
||||||
windows/CSpellWindow.h
|
windows/CSpellWindow.h
|
||||||
|
|||||||
@@ -49,15 +49,14 @@
|
|||||||
#include "widgets/CComponent.h"
|
#include "widgets/CComponent.h"
|
||||||
#include "widgets/CGarrisonInt.h"
|
#include "widgets/CGarrisonInt.h"
|
||||||
|
|
||||||
#include "windows/CAltarWindow.h"
|
|
||||||
#include "windows/CCastleInterface.h"
|
#include "windows/CCastleInterface.h"
|
||||||
#include "windows/CCreatureWindow.h"
|
#include "windows/CCreatureWindow.h"
|
||||||
#include "windows/CHeroWindow.h"
|
#include "windows/CHeroWindow.h"
|
||||||
#include "windows/CKingdomInterface.h"
|
#include "windows/CKingdomInterface.h"
|
||||||
|
#include "windows/CMarketWindow.h"
|
||||||
#include "windows/CPuzzleWindow.h"
|
#include "windows/CPuzzleWindow.h"
|
||||||
#include "windows/CQuestLog.h"
|
#include "windows/CQuestLog.h"
|
||||||
#include "windows/CSpellWindow.h"
|
#include "windows/CSpellWindow.h"
|
||||||
#include "windows/CTradeWindow.h"
|
|
||||||
#include "windows/CTutorialWindow.h"
|
#include "windows/CTutorialWindow.h"
|
||||||
#include "windows/GUIClasses.h"
|
#include "windows/GUIClasses.h"
|
||||||
#include "windows/InfoWindows.h"
|
#include "windows/InfoWindows.h"
|
||||||
@@ -450,7 +449,7 @@ void CPlayerInterface::heroMovePointsChanged(const CGHeroInstance * hero)
|
|||||||
void CPlayerInterface::receivedResource()
|
void CPlayerInterface::receivedResource()
|
||||||
{
|
{
|
||||||
EVENT_HANDLER_CALLED_BY_CLIENT;
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
||||||
for (auto mw : GH.windows().findWindows<CMarketplaceWindow>())
|
for (auto mw : GH.windows().findWindows<CMarketWindow>())
|
||||||
mw->resourceChanged();
|
mw->resourceChanged();
|
||||||
|
|
||||||
GH.windows().totalRedraw();
|
GH.windows().totalRedraw();
|
||||||
@@ -1669,13 +1668,13 @@ void CPlayerInterface::showMarketWindow(const IMarket *market, const CGHeroInsta
|
|||||||
};
|
};
|
||||||
|
|
||||||
if(market->allowsTrade(EMarketMode::ARTIFACT_EXP) && visitor->getAlignment() != EAlignment::EVIL)
|
if(market->allowsTrade(EMarketMode::ARTIFACT_EXP) && visitor->getAlignment() != EAlignment::EVIL)
|
||||||
GH.windows().createAndPushWindow<CAltarWindow>(market, visitor, onWindowClosed, EMarketMode::ARTIFACT_EXP);
|
GH.windows().createAndPushWindow<CMarketWindow>(market, visitor, onWindowClosed, EMarketMode::ARTIFACT_EXP);
|
||||||
else if(market->allowsTrade(EMarketMode::CREATURE_EXP) && visitor->getAlignment() != EAlignment::GOOD)
|
else if(market->allowsTrade(EMarketMode::CREATURE_EXP) && visitor->getAlignment() != EAlignment::GOOD)
|
||||||
GH.windows().createAndPushWindow<CAltarWindow>(market, visitor, onWindowClosed, EMarketMode::CREATURE_EXP);
|
GH.windows().createAndPushWindow<CMarketWindow>(market, visitor, onWindowClosed, EMarketMode::CREATURE_EXP);
|
||||||
else if(market->allowsTrade(EMarketMode::CREATURE_UNDEAD))
|
else if(market->allowsTrade(EMarketMode::CREATURE_UNDEAD))
|
||||||
GH.windows().createAndPushWindow<CTransformerWindow>(market, visitor, onWindowClosed);
|
GH.windows().createAndPushWindow<CTransformerWindow>(market, visitor, onWindowClosed);
|
||||||
else if(!market->availableModes().empty())
|
else if(!market->availableModes().empty())
|
||||||
GH.windows().createAndPushWindow<CMarketplaceWindow>(market, visitor, onWindowClosed, market->availableModes().front());
|
GH.windows().createAndPushWindow<CMarketWindow>(market, visitor, onWindowClosed, market->availableModes().front());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayerInterface::showUniversityWindow(const IMarket *market, const CGHeroInstance *visitor, QueryID queryID)
|
void CPlayerInterface::showUniversityWindow(const IMarket *market, const CGHeroInstance *visitor, QueryID queryID)
|
||||||
@@ -1696,8 +1695,8 @@ void CPlayerInterface::showHillFortWindow(const CGObjectInstance *object, const
|
|||||||
void CPlayerInterface::availableArtifactsChanged(const CGBlackMarket * bm)
|
void CPlayerInterface::availableArtifactsChanged(const CGBlackMarket * bm)
|
||||||
{
|
{
|
||||||
EVENT_HANDLER_CALLED_BY_CLIENT;
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
||||||
for (auto cmw : GH.windows().findWindows<CMarketplaceWindow>())
|
for (auto cmw : GH.windows().findWindows<CMarketWindow>())
|
||||||
cmw->artifactsChanged(false);
|
cmw->artifactsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayerInterface::showTavernWindow(const CGObjectInstance * object, const CGHeroInstance * visitor, QueryID queryID)
|
void CPlayerInterface::showTavernWindow(const CGObjectInstance * object, const CGHeroInstance * visitor, QueryID queryID)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#include "../mapView/mapHandler.h"
|
#include "../mapView/mapHandler.h"
|
||||||
#include "../windows/CKingdomInterface.h"
|
#include "../windows/CKingdomInterface.h"
|
||||||
#include "../windows/CSpellWindow.h"
|
#include "../windows/CSpellWindow.h"
|
||||||
#include "../windows/CTradeWindow.h"
|
#include "../windows/CMarketWindow.h"
|
||||||
#include "../windows/settings/SettingsMainWindow.h"
|
#include "../windows/settings/SettingsMainWindow.h"
|
||||||
#include "AdventureMapInterface.h"
|
#include "AdventureMapInterface.h"
|
||||||
#include "AdventureOptions.h"
|
#include "AdventureOptions.h"
|
||||||
@@ -342,7 +342,7 @@ void AdventureMapShortcuts::showMarketplace()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(townWithMarket) //if any town has marketplace, open window
|
if(townWithMarket) //if any town has marketplace, open window
|
||||||
GH.windows().createAndPushWindow<CMarketplaceWindow>(townWithMarket, nullptr, nullptr, EMarketMode::RESOURCE_RESOURCE);
|
GH.windows().createAndPushWindow<CMarketWindow>(townWithMarket, nullptr, nullptr, EMarketMode::RESOURCE_RESOURCE);
|
||||||
else //if not - complain
|
else //if not - complain
|
||||||
LOCPLINT->showInfoDialog(CGI->generaltexth->translate("vcmi.adventureMap.noTownWithMarket"));
|
LOCPLINT->showInfoDialog(CGI->generaltexth->translate("vcmi.adventureMap.noTownWithMarket"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include "../PlayerLocalState.h"
|
#include "../PlayerLocalState.h"
|
||||||
#include "../gui/WindowHandler.h"
|
#include "../gui/WindowHandler.h"
|
||||||
#include "../eventsSDL/InputHandler.h"
|
#include "../eventsSDL/InputHandler.h"
|
||||||
#include "../windows/CTradeWindow.h"
|
#include "../windows/CMarketWindow.h"
|
||||||
#include "../widgets/CGarrisonInt.h"
|
#include "../widgets/CGarrisonInt.h"
|
||||||
#include "../widgets/GraphicalPrimitiveCanvas.h"
|
#include "../widgets/GraphicalPrimitiveCanvas.h"
|
||||||
#include "../widgets/TextControls.h"
|
#include "../widgets/TextControls.h"
|
||||||
@@ -474,7 +474,7 @@ void CInteractableTownTooltip::init(const CGTownInstance * town)
|
|||||||
{
|
{
|
||||||
if(town->builtBuildings.count(BuildingID::MARKETPLACE))
|
if(town->builtBuildings.count(BuildingID::MARKETPLACE))
|
||||||
{
|
{
|
||||||
GH.windows().createAndPushWindow<CMarketplaceWindow>(town, nullptr, nullptr, EMarketMode::RESOURCE_RESOURCE);
|
GH.windows().createAndPushWindow<CMarketWindow>(town, nullptr, nullptr, EMarketMode::RESOURCE_RESOURCE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,38 +11,18 @@
|
|||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "CAltarWindow.h"
|
#include "CAltarWindow.h"
|
||||||
|
|
||||||
#include "../gui/CGuiHandler.h"
|
|
||||||
#include "../render/Canvas.h"
|
#include "../render/Canvas.h"
|
||||||
#include "../gui/Shortcut.h"
|
|
||||||
#include "../widgets/Buttons.h"
|
|
||||||
#include "../widgets/TextControls.h"
|
#include "../widgets/TextControls.h"
|
||||||
|
|
||||||
#include "../CGameInfo.h"
|
#include "../CGameInfo.h"
|
||||||
|
|
||||||
#include "../lib/networkPacks/ArtifactLocation.h"
|
#include "../lib/networkPacks/ArtifactLocation.h"
|
||||||
#include "../../lib/CGeneralTextHandler.h"
|
|
||||||
#include "../../lib/CHeroHandler.h"
|
#include "../../lib/CHeroHandler.h"
|
||||||
#include "../../lib/mapObjects/CGHeroInstance.h"
|
#include "../../lib/mapObjects/CGHeroInstance.h"
|
||||||
|
|
||||||
CAltarWindow::CAltarWindow(const IMarket * market, const CGHeroInstance * hero, const std::function<void()> & onWindowClosed, EMarketMode mode)
|
|
||||||
: CWindowObject(PLAYER_COLORED, ImagePath::builtin(mode == EMarketMode::CREATURE_EXP ? "ALTARMON.bmp" : "ALTRART2.bmp"))
|
|
||||||
, hero(hero)
|
|
||||||
, windowClosedCallback(onWindowClosed)
|
|
||||||
{
|
|
||||||
OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255 - DISPOSE);
|
|
||||||
|
|
||||||
assert(mode == EMarketMode::ARTIFACT_EXP || mode == EMarketMode::CREATURE_EXP);
|
|
||||||
if(mode == EMarketMode::ARTIFACT_EXP)
|
|
||||||
createAltarArtifacts(market, hero);
|
|
||||||
else if(mode == EMarketMode::CREATURE_EXP)
|
|
||||||
createAltarCreatures(market, hero);
|
|
||||||
|
|
||||||
updateExpToLevel();
|
|
||||||
statusBar = CGStatusBar::create(std::make_shared<CPicture>(background->getSurface(), Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CAltarWindow::updateExpToLevel()
|
void CAltarWindow::updateExpToLevel()
|
||||||
{
|
{
|
||||||
|
assert(altar);
|
||||||
altar->expToLevel->setText(std::to_string(CGI->heroh->reqExp(CGI->heroh->level(altar->hero->exp) + 1) - altar->hero->exp));
|
altar->expToLevel->setText(std::to_string(CGI->heroh->reqExp(CGI->heroh->level(altar->hero->exp) + 1) - altar->hero->exp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,63 +34,7 @@ void CAltarWindow::updateGarrisons()
|
|||||||
|
|
||||||
bool CAltarWindow::holdsGarrison(const CArmedInstance * army)
|
bool CAltarWindow::holdsGarrison(const CArmedInstance * army)
|
||||||
{
|
{
|
||||||
return hero == army;
|
return getHero() == army;
|
||||||
}
|
|
||||||
|
|
||||||
const CGHeroInstance * CAltarWindow::getHero() const
|
|
||||||
{
|
|
||||||
return hero;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CAltarWindow::close()
|
|
||||||
{
|
|
||||||
if(windowClosedCallback)
|
|
||||||
windowClosedCallback();
|
|
||||||
|
|
||||||
CWindowObject::close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CAltarWindow::createAltarArtifacts(const IMarket * market, const CGHeroInstance * hero)
|
|
||||||
{
|
|
||||||
OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255 - DISPOSE);
|
|
||||||
|
|
||||||
background = createBg(ImagePath::builtin("ALTRART2.bmp"), PLAYER_COLORED);
|
|
||||||
|
|
||||||
auto altarArtifacts = std::make_shared<CAltarArtifacts>(market, hero);
|
|
||||||
altar = altarArtifacts;
|
|
||||||
artSets.clear();
|
|
||||||
addSetAndCallbacks(altarArtifacts->getAOHset()); altarArtifacts->putBackArtifacts();
|
|
||||||
|
|
||||||
changeModeButton = std::make_shared<CButton>(Point(516, 421), AnimationPath::builtin("ALTSACC.DEF"),
|
|
||||||
CGI->generaltexth->zelp[572], std::bind(&CAltarWindow::createAltarCreatures, this, market, hero));
|
|
||||||
if(altar->hero->getAlignment() == EAlignment::GOOD)
|
|
||||||
changeModeButton->block(true);
|
|
||||||
quitButton = std::make_shared<CButton>(Point(516, 520), AnimationPath::builtin("IOK6432.DEF"),
|
|
||||||
CGI->generaltexth->zelp[568], [this, altarArtifacts]()
|
|
||||||
{
|
|
||||||
altarArtifacts->putBackArtifacts();
|
|
||||||
CAltarWindow::close();
|
|
||||||
}, EShortcut::GLOBAL_RETURN);
|
|
||||||
altar->setRedrawParent(true);
|
|
||||||
redraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CAltarWindow::createAltarCreatures(const IMarket * market, const CGHeroInstance * hero)
|
|
||||||
{
|
|
||||||
OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255 - DISPOSE);
|
|
||||||
|
|
||||||
background = createBg(ImagePath::builtin("ALTARMON.bmp"), PLAYER_COLORED);
|
|
||||||
|
|
||||||
altar = std::make_shared<CAltarCreatures>(market, hero);
|
|
||||||
|
|
||||||
changeModeButton = std::make_shared<CButton>(Point(516, 421), AnimationPath::builtin("ALTART.DEF"),
|
|
||||||
CGI->generaltexth->zelp[580], std::bind(&CAltarWindow::createAltarArtifacts, this, market, hero));
|
|
||||||
if(altar->hero->getAlignment() == EAlignment::EVIL)
|
|
||||||
changeModeButton->block(true);
|
|
||||||
quitButton = std::make_shared<CButton>(Point(516, 520), AnimationPath::builtin("IOK6432.DEF"),
|
|
||||||
CGI->generaltexth->zelp[568], std::bind(&CAltarWindow::close, this), EShortcut::GLOBAL_RETURN);
|
|
||||||
altar->setRedrawParent(true);
|
|
||||||
redraw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAltarWindow::artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw)
|
void CAltarWindow::artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw)
|
||||||
@@ -131,7 +55,7 @@ void CAltarWindow::artifactMoved(const ArtifactLocation & srcLoc, const Artifact
|
|||||||
CWindowWithArtifacts::artifactMoved(srcLoc, destLoc, withRedraw);
|
CWindowWithArtifacts::artifactMoved(srcLoc, destLoc, withRedraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAltarWindow::showAll(Canvas & to)
|
/*void CAltarWindow::showAll(Canvas& to)
|
||||||
{
|
{
|
||||||
// This func is temporary workaround for compliance with CTradeWindow
|
// This func is temporary workaround for compliance with CTradeWindow
|
||||||
CWindowObject::showAll(to);
|
CWindowObject::showAll(to);
|
||||||
@@ -144,4 +68,4 @@ void CAltarWindow::showAll(Canvas & to)
|
|||||||
{
|
{
|
||||||
altar->hLeft->showAllAt(altar->pos.topLeft() + Point(150, 423), "", to);
|
altar->hLeft->showAllAt(altar->pos.topLeft() + Point(150, 423), "", to);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|||||||
@@ -9,32 +9,22 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "../widgets/CWindowWithArtifacts.h"
|
||||||
#include "../widgets/markets/CAltarArtifacts.h"
|
#include "../widgets/markets/CAltarArtifacts.h"
|
||||||
#include "../widgets/markets/CAltarCreatures.h"
|
#include "../widgets/markets/CAltarCreatures.h"
|
||||||
#include "../widgets/CWindowWithArtifacts.h"
|
|
||||||
#include "CWindowObject.h"
|
|
||||||
|
|
||||||
class CAltarWindow : public CWindowObject, public CWindowWithArtifacts, public IGarrisonHolder
|
class CExperienceAltar;
|
||||||
|
|
||||||
|
class CAltarWindow : public CWindowWithArtifacts, public IGarrisonHolder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CAltarWindow(const IMarket * market, const CGHeroInstance * hero, const std::function<void()> & onWindowClosed, EMarketMode mode);
|
|
||||||
void updateExpToLevel();
|
void updateExpToLevel();
|
||||||
void updateGarrisons() override;
|
void updateGarrisons() override;
|
||||||
bool holdsGarrison(const CArmedInstance * army) override;
|
bool holdsGarrison(const CArmedInstance * army) override;
|
||||||
const CGHeroInstance * getHero() const;
|
virtual const CGHeroInstance * getHero() const = 0;
|
||||||
void close() override;
|
|
||||||
|
|
||||||
void artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw) override;
|
void artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw) override;
|
||||||
void showAll(Canvas & to) override;
|
//void showAll(Canvas & to) override;
|
||||||
|
|
||||||
private:
|
|
||||||
const CGHeroInstance * hero;
|
|
||||||
std::shared_ptr<CExperienceAltar> altar;
|
std::shared_ptr<CExperienceAltar> altar;
|
||||||
std::shared_ptr<CButton> changeModeButton;
|
|
||||||
std::shared_ptr<CButton> quitButton;
|
|
||||||
std::function<void()> windowClosedCallback;
|
|
||||||
std::shared_ptr<CGStatusBar> statusBar;
|
|
||||||
|
|
||||||
void createAltarArtifacts(const IMarket * market, const CGHeroInstance * hero);
|
|
||||||
void createAltarCreatures(const IMarket * market, const CGHeroInstance * hero);
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include "CCastleInterface.h"
|
#include "CCastleInterface.h"
|
||||||
|
|
||||||
#include "CHeroWindow.h"
|
#include "CHeroWindow.h"
|
||||||
#include "CTradeWindow.h"
|
#include "CMarketWindow.h"
|
||||||
#include "InfoWindows.h"
|
#include "InfoWindows.h"
|
||||||
#include "GUIClasses.h"
|
#include "GUIClasses.h"
|
||||||
#include "QuickRecruitmentWindow.h"
|
#include "QuickRecruitmentWindow.h"
|
||||||
@@ -728,7 +728,7 @@ void CCastleBuildings::buildingClicked(BuildingID building, BuildingSubID::EBuil
|
|||||||
case BuildingID::MARKETPLACE:
|
case BuildingID::MARKETPLACE:
|
||||||
// can't use allied marketplace
|
// can't use allied marketplace
|
||||||
if (town->getOwner() == LOCPLINT->playerID)
|
if (town->getOwner() == LOCPLINT->playerID)
|
||||||
GH.windows().createAndPushWindow<CMarketplaceWindow>(town, town->visitingHero, nullptr, EMarketMode::RESOURCE_RESOURCE);
|
GH.windows().createAndPushWindow<CMarketWindow>(town, town->visitingHero, nullptr, EMarketMode::RESOURCE_RESOURCE);
|
||||||
else
|
else
|
||||||
enterBuilding(building);
|
enterBuilding(building);
|
||||||
break;
|
break;
|
||||||
@@ -756,7 +756,7 @@ void CCastleBuildings::buildingClicked(BuildingID building, BuildingSubID::EBuil
|
|||||||
|
|
||||||
case BuildingSubID::ARTIFACT_MERCHANT:
|
case BuildingSubID::ARTIFACT_MERCHANT:
|
||||||
if(town->visitingHero)
|
if(town->visitingHero)
|
||||||
GH.windows().createAndPushWindow<CMarketplaceWindow>(town, town->visitingHero, nullptr, EMarketMode::RESOURCE_ARTIFACT);
|
GH.windows().createAndPushWindow<CMarketWindow>(town, town->visitingHero, nullptr, EMarketMode::RESOURCE_ARTIFACT);
|
||||||
else
|
else
|
||||||
LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[273]) % b->getNameTranslated())); //Only visiting heroes may use the %s.
|
LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[273]) % b->getNameTranslated())); //Only visiting heroes may use the %s.
|
||||||
break;
|
break;
|
||||||
@@ -767,7 +767,7 @@ void CCastleBuildings::buildingClicked(BuildingID building, BuildingSubID::EBuil
|
|||||||
|
|
||||||
case BuildingSubID::FREELANCERS_GUILD:
|
case BuildingSubID::FREELANCERS_GUILD:
|
||||||
if(getHero())
|
if(getHero())
|
||||||
GH.windows().createAndPushWindow<CMarketplaceWindow>(town, getHero(), nullptr, EMarketMode::CREATURE_RESOURCE);
|
GH.windows().createAndPushWindow<CMarketWindow>(town, getHero(), nullptr, EMarketMode::CREATURE_RESOURCE);
|
||||||
else
|
else
|
||||||
LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[273]) % b->getNameTranslated())); //Only visiting heroes may use the %s.
|
LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[273]) % b->getNameTranslated())); //Only visiting heroes may use the %s.
|
||||||
break;
|
break;
|
||||||
@@ -1338,7 +1338,7 @@ void CCastleInterface::recreateIcons()
|
|||||||
{
|
{
|
||||||
if(town->builtBuildings.count(BuildingID::MARKETPLACE))
|
if(town->builtBuildings.count(BuildingID::MARKETPLACE))
|
||||||
{
|
{
|
||||||
GH.windows().createAndPushWindow<CMarketplaceWindow>(town, nullptr, nullptr, EMarketMode::RESOURCE_RESOURCE);
|
GH.windows().createAndPushWindow<CMarketWindow>(town, nullptr, nullptr, EMarketMode::RESOURCE_RESOURCE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#include "../widgets/MiscWidgets.h"
|
#include "../widgets/MiscWidgets.h"
|
||||||
#include "../widgets/Buttons.h"
|
#include "../widgets/Buttons.h"
|
||||||
#include "../widgets/ObjectLists.h"
|
#include "../widgets/ObjectLists.h"
|
||||||
#include "../windows/CTradeWindow.h"
|
#include "../windows/CMarketWindow.h"
|
||||||
|
|
||||||
#include "../../CCallback.h"
|
#include "../../CCallback.h"
|
||||||
|
|
||||||
@@ -840,7 +840,7 @@ CTownItem::CTownItem(const CGTownInstance * Town)
|
|||||||
{
|
{
|
||||||
if(town->builtBuildings.count(BuildingID::MARKETPLACE))
|
if(town->builtBuildings.count(BuildingID::MARKETPLACE))
|
||||||
{
|
{
|
||||||
GH.windows().createAndPushWindow<CMarketplaceWindow>(town, nullptr, nullptr, EMarketMode::RESOURCE_RESOURCE);
|
GH.windows().createAndPushWindow<CMarketWindow>(town, nullptr, nullptr, EMarketMode::RESOURCE_RESOURCE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
242
client/windows/CMarketWindow.cpp
Normal file
242
client/windows/CMarketWindow.cpp
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
/*
|
||||||
|
* CMarketWindow.cpp, part of VCMI engine
|
||||||
|
*
|
||||||
|
* Authors: listed in file AUTHORS in main folder
|
||||||
|
*
|
||||||
|
* License: GNU General Public License v2.0 or later
|
||||||
|
* Full text of license available in license.txt file, in main folder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "StdInc.h"
|
||||||
|
#include "CMarketWindow.h"
|
||||||
|
|
||||||
|
#include "../gui/CGuiHandler.h"
|
||||||
|
#include "../gui/Shortcut.h"
|
||||||
|
|
||||||
|
#include "../widgets/Buttons.h"
|
||||||
|
#include "../widgets/TextControls.h"
|
||||||
|
|
||||||
|
#include "../CGameInfo.h"
|
||||||
|
#include "../CPlayerInterface.h"
|
||||||
|
|
||||||
|
#include "../../lib/CGeneralTextHandler.h"
|
||||||
|
#include "../../lib/mapObjects/CGTownInstance.h"
|
||||||
|
#include "../../lib/mapObjects/CGMarket.h"
|
||||||
|
#include "../../lib/mapObjects/CGHeroInstance.h"
|
||||||
|
|
||||||
|
CMarketWindow::CMarketWindow(const IMarket * market, const CGHeroInstance * hero, const std::function<void()> & onWindowClosed, EMarketMode mode)
|
||||||
|
: CStatusbarWindow(PLAYER_COLORED)
|
||||||
|
, hero(hero)
|
||||||
|
, windowClosedCallback(onWindowClosed)
|
||||||
|
{
|
||||||
|
assert(mode == EMarketMode::RESOURCE_RESOURCE || mode == EMarketMode::RESOURCE_PLAYER || mode == EMarketMode::CREATURE_RESOURCE ||
|
||||||
|
mode == EMarketMode::RESOURCE_ARTIFACT || mode == EMarketMode::ARTIFACT_RESOURCE || mode == EMarketMode::ARTIFACT_EXP ||
|
||||||
|
mode == EMarketMode::CREATURE_EXP);
|
||||||
|
|
||||||
|
if(mode == EMarketMode::RESOURCE_RESOURCE)
|
||||||
|
createMarketResources(market, hero);
|
||||||
|
else if(mode == EMarketMode::RESOURCE_PLAYER)
|
||||||
|
createTransferResources(market, hero);
|
||||||
|
else if(mode == EMarketMode::CREATURE_RESOURCE)
|
||||||
|
createFreelancersGuild(market, hero);
|
||||||
|
else if(mode == EMarketMode::RESOURCE_ARTIFACT)
|
||||||
|
createArtifactsBuying(market, hero);
|
||||||
|
else if(mode == EMarketMode::ARTIFACT_RESOURCE)
|
||||||
|
createArtifactsSelling(market, hero);
|
||||||
|
else if(mode == EMarketMode::ARTIFACT_EXP)
|
||||||
|
createAltarArtifacts(market, hero);
|
||||||
|
else if(mode == EMarketMode::CREATURE_EXP)
|
||||||
|
createAltarCreatures(market, hero);
|
||||||
|
|
||||||
|
OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255 - DISPOSE);
|
||||||
|
statusbar = CGStatusBar::create(std::make_shared<CPicture>(background->getSurface(), Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMarketWindow::artifactsChanged()
|
||||||
|
{
|
||||||
|
market->artifactsChanged(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMarketWindow::resourceChanged()
|
||||||
|
{
|
||||||
|
market->initSubs(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMarketWindow::close()
|
||||||
|
{
|
||||||
|
if(windowClosedCallback)
|
||||||
|
windowClosedCallback();
|
||||||
|
|
||||||
|
CWindowObject::close();
|
||||||
|
}
|
||||||
|
|
||||||
|
const CGHeroInstance * CMarketWindow::getHero() const
|
||||||
|
{
|
||||||
|
return hero;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMarketWindow::createChangeModeButtons(EMarketMode mode, const IMarket * market, const CGHeroInstance * hero)
|
||||||
|
{
|
||||||
|
auto isButton = [this](EMarketMode mode) -> bool
|
||||||
|
{
|
||||||
|
if(this->market->mode == mode)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(!this->market->market->allowsTrade(mode))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(mode == EMarketMode::RESOURCE_RESOURCE || mode == EMarketMode::RESOURCE_PLAYER)
|
||||||
|
{
|
||||||
|
if(const auto town = dynamic_cast<const CGTownInstance*>(this->market->market))
|
||||||
|
return town->getOwner() == LOCPLINT->playerID;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this->market->hero != nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
auto buttonPosY = 520;
|
||||||
|
changeModeButtons.clear();
|
||||||
|
|
||||||
|
if(isButton(EMarketMode::RESOURCE_PLAYER))
|
||||||
|
changeModeButtons.emplace_back(std::make_shared<CButton>(Point(18, buttonPosY), AnimationPath::builtin("TPMRKBU1.DEF"),
|
||||||
|
CGI->generaltexth->zelp[612], std::bind(&CMarketWindow::createTransferResources, this, market, hero)));
|
||||||
|
|
||||||
|
buttonPosY -= buttonHeightWithMargin;
|
||||||
|
if(isButton(EMarketMode::ARTIFACT_RESOURCE))
|
||||||
|
{
|
||||||
|
changeModeButtons.emplace_back(std::make_shared<CButton>(Point(18, buttonPosY), AnimationPath::builtin("TPMRKBU3.DEF"),
|
||||||
|
CGI->generaltexth->zelp[613], std::bind(&CMarketWindow::createArtifactsSelling, this, market, hero)));
|
||||||
|
buttonPosY -= buttonHeightWithMargin;
|
||||||
|
}
|
||||||
|
if(isButton(EMarketMode::CREATURE_RESOURCE))
|
||||||
|
changeModeButtons.emplace_back(std::make_shared<CButton>(Point(516, buttonPosY), AnimationPath::builtin("TPMRKBU4.DEF"),
|
||||||
|
CGI->generaltexth->zelp[599], std::bind(&CMarketWindow::createFreelancersGuild, this, market, hero)));
|
||||||
|
if(isButton(EMarketMode::RESOURCE_RESOURCE))
|
||||||
|
changeModeButtons.emplace_back(std::make_shared<CButton>(Point(516, buttonPosY), AnimationPath::builtin("TPMRKBU5.DEF"),
|
||||||
|
CGI->generaltexth->zelp[605], std::bind(&CMarketWindow::createMarketResources, this, market, hero)));
|
||||||
|
if(isButton(EMarketMode::RESOURCE_ARTIFACT))
|
||||||
|
changeModeButtons.emplace_back(std::make_shared<CButton>(Point(18, buttonPosY), AnimationPath::builtin("TPMRKBU2.DEF"),
|
||||||
|
CGI->generaltexth->zelp[598], std::bind(&CMarketWindow::createArtifactsBuying, this, market, hero)));
|
||||||
|
if(isButton(EMarketMode::ARTIFACT_EXP))
|
||||||
|
{
|
||||||
|
changeModeButtons.emplace_back(std::make_shared<CButton>(Point(516, 421), AnimationPath::builtin("ALTSACC.DEF"),
|
||||||
|
CGI->generaltexth->zelp[572], std::bind(&CMarketWindow::createAltarCreatures, this, market, hero)));
|
||||||
|
if(altar->hero->getAlignment() == EAlignment::GOOD)
|
||||||
|
changeModeButtons.back()->block(true);
|
||||||
|
}
|
||||||
|
if(isButton(EMarketMode::CREATURE_EXP))
|
||||||
|
{
|
||||||
|
changeModeButtons.emplace_back(std::make_shared<CButton>(Point(516, 421), AnimationPath::builtin("ALTART.DEF"),
|
||||||
|
CGI->generaltexth->zelp[580], std::bind(&CMarketWindow::createAltarArtifacts, this, market, hero)));
|
||||||
|
if(altar->hero->getAlignment() == EAlignment::EVIL)
|
||||||
|
changeModeButtons.back()->block(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMarketWindow::createInternals(EMarketMode mode, const IMarket * market, const CGHeroInstance * hero)
|
||||||
|
{
|
||||||
|
background->center();
|
||||||
|
pos = background->pos;
|
||||||
|
this->market->setRedrawParent(true);
|
||||||
|
createChangeModeButtons(mode, market, hero);
|
||||||
|
quitButton = std::make_shared<CButton>(quitButtonPos, AnimationPath::builtin("IOK6432.DEF"),
|
||||||
|
CGI->generaltexth->zelp[600], [this]() {close(); }, EShortcut::GLOBAL_RETURN);
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMarketWindow::createArtifactsBuying(const IMarket * market, const CGHeroInstance * hero)
|
||||||
|
{
|
||||||
|
OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255 - DISPOSE);
|
||||||
|
|
||||||
|
background = createBg(ImagePath::builtin("TPMRKABS.bmp"), PLAYER_COLORED);
|
||||||
|
this->market = std::make_shared<CMarketplaceWindow>(market, hero, []() {}, EMarketMode::RESOURCE_ARTIFACT);
|
||||||
|
createInternals(EMarketMode::RESOURCE_ARTIFACT, market, hero);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMarketWindow::createArtifactsSelling(const IMarket * market, const CGHeroInstance * hero)
|
||||||
|
{
|
||||||
|
OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255 - DISPOSE);
|
||||||
|
|
||||||
|
background = createBg(ImagePath::builtin("TPMRKASS.bmp"), PLAYER_COLORED);
|
||||||
|
this->market = std::make_shared<CMarketplaceWindow>(market, hero, []() {}, EMarketMode::ARTIFACT_RESOURCE);
|
||||||
|
createInternals(EMarketMode::ARTIFACT_RESOURCE, market, hero);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMarketWindow::createMarketResources(const IMarket * market, const CGHeroInstance * hero)
|
||||||
|
{
|
||||||
|
OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255 - DISPOSE);
|
||||||
|
|
||||||
|
background = createBg(ImagePath::builtin("TPMRKRES.bmp"), PLAYER_COLORED);
|
||||||
|
this->market = std::make_shared<CMarketplaceWindow>(market, hero, []() {}, EMarketMode::RESOURCE_RESOURCE);
|
||||||
|
createInternals(EMarketMode::RESOURCE_RESOURCE, market, hero);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMarketWindow::createFreelancersGuild(const IMarket * market, const CGHeroInstance * hero)
|
||||||
|
{
|
||||||
|
OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255 - DISPOSE);
|
||||||
|
|
||||||
|
background = createBg(ImagePath::builtin("TPMRKCRS.bmp"), PLAYER_COLORED);
|
||||||
|
this->market = std::make_shared<CMarketplaceWindow>(market, hero, []() {}, EMarketMode::CREATURE_RESOURCE);
|
||||||
|
createInternals(EMarketMode::CREATURE_RESOURCE, market, hero);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMarketWindow::createTransferResources(const IMarket * market, const CGHeroInstance * hero)
|
||||||
|
{
|
||||||
|
OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255 - DISPOSE);
|
||||||
|
|
||||||
|
background = createBg(ImagePath::builtin("TPMRKPTS.bmp"), PLAYER_COLORED);
|
||||||
|
this->market = std::make_shared<CMarketplaceWindow>(market, hero, []() {}, EMarketMode::RESOURCE_PLAYER);
|
||||||
|
createInternals(EMarketMode::RESOURCE_PLAYER, market, hero);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMarketWindow::createAltarArtifacts(const IMarket * market, const CGHeroInstance * hero)
|
||||||
|
{
|
||||||
|
OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255 - DISPOSE);
|
||||||
|
|
||||||
|
background = createBg(ImagePath::builtin("ALTRART2.bmp"), PLAYER_COLORED);
|
||||||
|
auto altarArtifacts = std::make_shared<CAltarArtifacts>(market, hero);
|
||||||
|
altar = altarArtifacts;
|
||||||
|
artSets.clear();
|
||||||
|
addSetAndCallbacks(altarArtifacts->getAOHset()); altarArtifacts->putBackArtifacts();
|
||||||
|
|
||||||
|
background->center();
|
||||||
|
pos = background->pos;
|
||||||
|
altar->setRedrawParent(true);
|
||||||
|
//createChangeModeButtons(EMarketMode::ARTIFACT_EXP, market, hero);
|
||||||
|
altar->moveTo(pos.topLeft());
|
||||||
|
|
||||||
|
quitButton = std::make_shared<CButton>(quitButtonPos, AnimationPath::builtin("IOK6432.DEF"),
|
||||||
|
CGI->generaltexth->zelp[568], [this, altarArtifacts]()
|
||||||
|
{
|
||||||
|
altarArtifacts->putBackArtifacts();
|
||||||
|
CMarketWindow::close();
|
||||||
|
}, EShortcut::GLOBAL_RETURN);
|
||||||
|
|
||||||
|
updateExpToLevel();
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMarketWindow::createAltarCreatures(const IMarket * market, const CGHeroInstance * hero)
|
||||||
|
{
|
||||||
|
OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255 - DISPOSE);
|
||||||
|
|
||||||
|
background = createBg(ImagePath::builtin("ALTARMON.bmp"), PLAYER_COLORED);
|
||||||
|
altar = std::make_shared<CAltarCreatures>(market, hero);
|
||||||
|
|
||||||
|
background->center();
|
||||||
|
pos = background->pos;
|
||||||
|
altar->setRedrawParent(true);
|
||||||
|
//createChangeModeButtons(EMarketMode::CREATURE_EXP, market, hero);
|
||||||
|
altar->moveTo(pos.topLeft());
|
||||||
|
|
||||||
|
quitButton = std::make_shared<CButton>(quitButtonPos, AnimationPath::builtin("IOK6432.DEF"),
|
||||||
|
CGI->generaltexth->zelp[568], std::bind(&CMarketWindow::close, this), EShortcut::GLOBAL_RETURN);
|
||||||
|
|
||||||
|
updateExpToLevel();
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
44
client/windows/CMarketWindow.h
Normal file
44
client/windows/CMarketWindow.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* CMarketWindow.h, part of VCMI engine
|
||||||
|
*
|
||||||
|
* Authors: listed in file AUTHORS in main folder
|
||||||
|
*
|
||||||
|
* License: GNU General Public License v2.0 or later
|
||||||
|
* Full text of license available in license.txt file, in main folder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CTradeWindow.h"
|
||||||
|
#include "CAltarWindow.h"
|
||||||
|
|
||||||
|
class CMarketWindow : public CStatusbarWindow, public CAltarWindow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CMarketWindow(const IMarket * market, const CGHeroInstance * hero, const std::function<void()> & onWindowClosed, EMarketMode mode);
|
||||||
|
void resourceChanged();
|
||||||
|
void artifactsChanged();
|
||||||
|
void close() override;
|
||||||
|
const CGHeroInstance * getHero() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void createChangeModeButtons(EMarketMode mode, const IMarket * market, const CGHeroInstance * hero);
|
||||||
|
void createInternals(EMarketMode mode, const IMarket * market, const CGHeroInstance * hero);
|
||||||
|
|
||||||
|
void createArtifactsBuying(const IMarket * market, const CGHeroInstance * hero);
|
||||||
|
void createArtifactsSelling(const IMarket * market, const CGHeroInstance * hero);
|
||||||
|
void createMarketResources(const IMarket * market, const CGHeroInstance * hero);
|
||||||
|
void createFreelancersGuild(const IMarket * market, const CGHeroInstance * hero);
|
||||||
|
void createTransferResources(const IMarket * market, const CGHeroInstance * hero);
|
||||||
|
void createAltarArtifacts(const IMarket * market, const CGHeroInstance * hero);
|
||||||
|
void createAltarCreatures(const IMarket * market, const CGHeroInstance * hero);
|
||||||
|
|
||||||
|
const int buttonHeightWithMargin = 32 + 3;
|
||||||
|
const CGHeroInstance * hero;
|
||||||
|
std::vector<std::shared_ptr<CButton>> changeModeButtons;
|
||||||
|
std::shared_ptr<CButton> quitButton;
|
||||||
|
std::function<void()> windowClosedCallback;
|
||||||
|
const Point quitButtonPos = Point(516, 520);
|
||||||
|
|
||||||
|
std::shared_ptr<CMarketplaceWindow> market;
|
||||||
|
};
|
||||||
@@ -214,16 +214,6 @@ void CTradeWindow::setMode(EMarketMode Mode)
|
|||||||
|
|
||||||
onWindowClosed = nullptr; // don't call on closing of this window - pass it to next window
|
onWindowClosed = nullptr; // don't call on closing of this window - pass it to next window
|
||||||
close();
|
close();
|
||||||
|
|
||||||
switch(Mode)
|
|
||||||
{
|
|
||||||
case EMarketMode::CREATURE_EXP:
|
|
||||||
case EMarketMode::ARTIFACT_EXP:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
GH.windows().createAndPushWindow<CMarketplaceWindow>(m, h, functor, Mode);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTradeWindow::artifactSelected(CArtPlace * slot)
|
void CTradeWindow::artifactSelected(CArtPlace * slot)
|
||||||
@@ -265,8 +255,6 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket * Market, const CGHeroInsta
|
|||||||
madeTransaction = false;
|
madeTransaction = false;
|
||||||
bool sliderNeeded = (mode != EMarketMode::RESOURCE_ARTIFACT && mode != EMarketMode::ARTIFACT_RESOURCE);
|
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));
|
|
||||||
|
|
||||||
std::string title;
|
std::string title;
|
||||||
|
|
||||||
if(auto * o = dynamic_cast<const CGTownInstance *>(market))
|
if(auto * o = dynamic_cast<const CGTownInstance *>(market))
|
||||||
@@ -307,7 +295,6 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket * Market, const CGHeroInsta
|
|||||||
initItems(false);
|
initItems(false);
|
||||||
initItems(true);
|
initItems(true);
|
||||||
|
|
||||||
ok = std::make_shared<CButton>(Point(516, 520), AnimationPath::builtin("IOK6432.DEF"), CGI->generaltexth->zelp[600], [&](){ close(); }, EShortcut::GLOBAL_RETURN);
|
|
||||||
deal = std::make_shared<CButton>(Point(307, 520), AnimationPath::builtin("TPMRKB.DEF"), CGI->generaltexth->zelp[595], [&](){ makeDeal(); } );
|
deal = std::make_shared<CButton>(Point(307, 520), AnimationPath::builtin("TPMRKB.DEF"), CGI->generaltexth->zelp[595], [&](){ makeDeal(); } );
|
||||||
deal->block(true);
|
deal->block(true);
|
||||||
|
|
||||||
@@ -361,17 +348,6 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket * Market, const CGHeroInsta
|
|||||||
traderText = std::make_shared<CTextBox>("", traderTextRect, 0, FONT_SMALL, ETextAlignment::CENTER);
|
traderText = std::make_shared<CTextBox>("", traderTextRect, 0, FONT_SMALL, ETextAlignment::CENTER);
|
||||||
int specialOffset = mode == EMarketMode::ARTIFACT_RESOURCE ? 35 : 0; //in selling artifacts mode we need to move res-res and art-res buttons down
|
int specialOffset = mode == EMarketMode::ARTIFACT_RESOURCE ? 35 : 0; //in selling artifacts mode we need to move res-res and art-res buttons down
|
||||||
|
|
||||||
if(printButtonFor(EMarketMode::RESOURCE_PLAYER))
|
|
||||||
buttons.push_back(std::make_shared<CButton>(Point(18, 520),AnimationPath::builtin("TPMRKBU1.DEF"), CGI->generaltexth->zelp[612], [&](){ setMode(EMarketMode::RESOURCE_PLAYER);}));
|
|
||||||
if(printButtonFor(EMarketMode::RESOURCE_RESOURCE))
|
|
||||||
buttons.push_back(std::make_shared<CButton>(Point(516, 450 + specialOffset),AnimationPath::builtin("TPMRKBU5.DEF"), CGI->generaltexth->zelp[605], [&](){ setMode(EMarketMode::RESOURCE_RESOURCE);}));
|
|
||||||
if(printButtonFor(EMarketMode::CREATURE_RESOURCE))
|
|
||||||
buttons.push_back(std::make_shared<CButton>(Point(516, 485),AnimationPath::builtin("TPMRKBU4.DEF"), CGI->generaltexth->zelp[599], [&](){ setMode(EMarketMode::CREATURE_RESOURCE);}));
|
|
||||||
if(printButtonFor(EMarketMode::RESOURCE_ARTIFACT))
|
|
||||||
buttons.push_back(std::make_shared<CButton>(Point(18, 450 + specialOffset),AnimationPath::builtin("TPMRKBU2.DEF"), CGI->generaltexth->zelp[598], [&](){ setMode(EMarketMode::RESOURCE_ARTIFACT);}));
|
|
||||||
if(printButtonFor(EMarketMode::ARTIFACT_RESOURCE))
|
|
||||||
buttons.push_back(std::make_shared<CButton>(Point(18, 485),AnimationPath::builtin("TPMRKBU3.DEF"), CGI->generaltexth->zelp[613], [&](){ setMode(EMarketMode::ARTIFACT_RESOURCE);}));
|
|
||||||
|
|
||||||
updateTraderText();
|
updateTraderText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,29 +485,6 @@ void CMarketplaceWindow::selectionChanged(bool side)
|
|||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMarketplaceWindow::printButtonFor(EMarketMode M) const
|
|
||||||
{
|
|
||||||
if (!market->allowsTrade(M))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (M == mode)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if ( M == EMarketMode::RESOURCE_RESOURCE || M == EMarketMode::RESOURCE_PLAYER)
|
|
||||||
{
|
|
||||||
auto * town = dynamic_cast<const CGTownInstance *>(market);
|
|
||||||
|
|
||||||
if (town)
|
|
||||||
return town->getOwner() == LOCPLINT->playerID;
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return hero != nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMarketplaceWindow::updateGarrison()
|
void CMarketplaceWindow::updateGarrison()
|
||||||
{
|
{
|
||||||
if(mode != EMarketMode::CREATURE_RESOURCE)
|
if(mode != EMarketMode::CREATURE_RESOURCE)
|
||||||
@@ -623,11 +576,6 @@ Point CMarketplaceWindow::selectionOffset(bool Left) const
|
|||||||
return Point(0,0);
|
return Point(0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMarketplaceWindow::resourceChanged()
|
|
||||||
{
|
|
||||||
initSubs(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMarketplaceWindow::updateTraderText()
|
void CMarketplaceWindow::updateTraderText()
|
||||||
{
|
{
|
||||||
if(readyToTrade)
|
if(readyToTrade)
|
||||||
|
|||||||
@@ -55,8 +55,6 @@ class CMarketplaceWindow : public CTradeWindow
|
|||||||
std::shared_ptr<CLabel> titleLabel;
|
std::shared_ptr<CLabel> titleLabel;
|
||||||
std::shared_ptr<CArtifactsOfHeroMarket> arts;
|
std::shared_ptr<CArtifactsOfHeroMarket> arts;
|
||||||
|
|
||||||
bool printButtonFor(EMarketMode M) const;
|
|
||||||
|
|
||||||
ImagePath getBackgroundForMode(EMarketMode mode);
|
ImagePath getBackgroundForMode(EMarketMode mode);
|
||||||
public:
|
public:
|
||||||
int r1, r2; //suggested amounts of traded resources
|
int r1, r2; //suggested amounts of traded resources
|
||||||
@@ -75,6 +73,5 @@ public:
|
|||||||
|
|
||||||
void updateGarrison() override; //removes creatures with count 0 from the list (apparently whole stack has been sold)
|
void updateGarrison() override; //removes creatures with count 0 from the list (apparently whole stack has been sold)
|
||||||
void artifactsChanged(bool left) override;
|
void artifactsChanged(bool left) override;
|
||||||
void resourceChanged();
|
|
||||||
void updateTraderText();
|
void updateTraderText();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user