浏览代码

Adjust client part for markets

nordsoft 2 年之前
父节点
当前提交
07f7c318dc
共有 4 个文件被更改,包括 32 次插入15 次删除
  1. 4 1
      client/CPlayerInterface.cpp
  2. 1 1
      client/windows/CCastleInterface.cpp
  3. 25 11
      client/windows/GUIClasses.cpp
  4. 2 2
      client/windows/GUIClasses.h

+ 4 - 1
client/CPlayerInterface.cpp

@@ -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());
 	}
 }
 

+ 1 - 1
client/windows/CCastleInterface.cpp

@@ -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:

+ 25 - 11
client/windows/GUIClasses.cpp

@@ -1162,7 +1162,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);
 	}
 }
 
@@ -1182,21 +1182,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);
@@ -1287,6 +1290,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))
 	{
@@ -1294,13 +1300,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);
@@ -1314,7 +1328,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);
 }
 
 

+ 2 - 2
client/windows/GUIClasses.h

@@ -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