Explorar o código

CWindowWithArtifacts preparations

SoundSSGood hai 1 ano
pai
achega
25d2b468c3

+ 2 - 2
client/CMakeLists.txt

@@ -103,7 +103,7 @@ set(client_SRCS
 	globalLobby/GlobalLobbyWindow.cpp
 	globalLobby/GlobalLobbyWindow.cpp
 
 
 	widgets/Buttons.cpp
 	widgets/Buttons.cpp
-	widgets/CArtifactHolder.cpp
+	widgets/CArtPlace.cpp
 	widgets/CComponent.cpp
 	widgets/CComponent.cpp
 	widgets/CExchangeController.cpp
 	widgets/CExchangeController.cpp
 	widgets/CGarrisonInt.cpp
 	widgets/CGarrisonInt.cpp
@@ -293,7 +293,7 @@ set(client_HEADERS
 	globalLobby/GlobalLobbyWindow.h
 	globalLobby/GlobalLobbyWindow.h
 
 
 	widgets/Buttons.h
 	widgets/Buttons.h
-	widgets/CArtifactHolder.h
+	widgets/CArtPlace.h
 	widgets/CComponent.h
 	widgets/CComponent.h
 	widgets/CExchangeController.h
 	widgets/CExchangeController.h
 	widgets/CGarrisonInt.h
 	widgets/CGarrisonInt.h

+ 4 - 4
client/CPlayerInterface.cpp

@@ -1745,7 +1745,7 @@ void CPlayerInterface::artifactRemoved(const ArtifactLocation &al)
 	EVENT_HANDLER_CALLED_BY_CLIENT;
 	EVENT_HANDLER_CALLED_BY_CLIENT;
 	adventureInt->onHeroChanged(cb->getHero(al.artHolder));
 	adventureInt->onHeroChanged(cb->getHero(al.artHolder));
 
 
-	for(auto artWin : GH.windows().findWindows<CArtifactHolder>())
+	for(auto artWin : GH.windows().findWindows<CWindowWithArtifacts>())
 		artWin->artifactRemoved(al);
 		artWin->artifactRemoved(al);
 
 
 	waitWhileDialog();
 	waitWhileDialog();
@@ -1765,7 +1765,7 @@ void CPlayerInterface::artifactMoved(const ArtifactLocation &src, const Artifact
 			redraw = false;
 			redraw = false;
 	}
 	}
 
 
-	for(auto artWin : GH.windows().findWindows<CArtifactHolder>())
+	for(auto artWin : GH.windows().findWindows<CWindowWithArtifacts>())
 		artWin->artifactMoved(src, dst, redraw);
 		artWin->artifactMoved(src, dst, redraw);
 
 
 	waitWhileDialog();
 	waitWhileDialog();
@@ -1781,7 +1781,7 @@ void CPlayerInterface::artifactAssembled(const ArtifactLocation &al)
 	EVENT_HANDLER_CALLED_BY_CLIENT;
 	EVENT_HANDLER_CALLED_BY_CLIENT;
 	adventureInt->onHeroChanged(cb->getHero(al.artHolder));
 	adventureInt->onHeroChanged(cb->getHero(al.artHolder));
 
 
-	for(auto artWin : GH.windows().findWindows<CArtifactHolder>())
+	for(auto artWin : GH.windows().findWindows<CWindowWithArtifacts>())
 		artWin->artifactAssembled(al);
 		artWin->artifactAssembled(al);
 }
 }
 
 
@@ -1790,7 +1790,7 @@ void CPlayerInterface::artifactDisassembled(const ArtifactLocation &al)
 	EVENT_HANDLER_CALLED_BY_CLIENT;
 	EVENT_HANDLER_CALLED_BY_CLIENT;
 	adventureInt->onHeroChanged(cb->getHero(al.artHolder));
 	adventureInt->onHeroChanged(cb->getHero(al.artHolder));
 
 
-	for(auto artWin : GH.windows().findWindows<CArtifactHolder>())
+	for(auto artWin : GH.windows().findWindows<CWindowWithArtifacts>())
 		artWin->artifactDisassembled(al);
 		artWin->artifactDisassembled(al);
 }
 }
 
 

+ 2 - 2
client/widgets/CArtifactHolder.cpp → client/widgets/CArtPlace.cpp

@@ -1,5 +1,5 @@
 /*
 /*
- * CArtifactHolder.cpp, part of VCMI engine
+ * CArtPlace.cpp, part of VCMI engine
  *
  *
  * Authors: listed in file AUTHORS in main folder
  * Authors: listed in file AUTHORS in main folder
  *
  *
@@ -8,7 +8,7 @@
  *
  *
  */
  */
 #include "StdInc.h"
 #include "StdInc.h"
-#include "CArtifactHolder.h"
+#include "CArtPlace.h"
 
 
 #include "../gui/CGuiHandler.h"
 #include "../gui/CGuiHandler.h"
 #include "../gui/Shortcut.h"
 #include "../gui/Shortcut.h"

+ 1 - 17
client/widgets/CArtifactHolder.h → client/widgets/CArtPlace.h

@@ -1,5 +1,5 @@
 /*
 /*
- * CArtifactHolder.h, part of VCMI engine
+ * CArtPlace.h, part of VCMI engine
  *
  *
  * Authors: listed in file AUTHORS in main folder
  * Authors: listed in file AUTHORS in main folder
  *
  *
@@ -11,24 +11,8 @@
 
 
 #include "MiscWidgets.h"
 #include "MiscWidgets.h"
 
 
-VCMI_LIB_NAMESPACE_BEGIN
-
-struct ArtifactLocation;
-class CArtifactSet;
-
-VCMI_LIB_NAMESPACE_END
-
 class CAnimImage;
 class CAnimImage;
 
 
-class CArtifactHolder
-{
-public:
-	virtual void artifactRemoved(const ArtifactLocation & artLoc)=0;
-	virtual void artifactMoved(const ArtifactLocation & artLoc, const ArtifactLocation & destLoc, bool withRedraw)=0;
-	virtual void artifactDisassembled(const ArtifactLocation & artLoc)=0;
-	virtual void artifactAssembled(const ArtifactLocation & artLoc)=0;
-};
-
 class CArtPlace : public SelectableSlot
 class CArtPlace : public SelectableSlot
 {
 {
 public:
 public:

+ 1 - 1
client/widgets/CArtifactsOfHeroBase.h

@@ -9,7 +9,7 @@
  */
  */
 #pragma once
 #pragma once
 
 
-#include "CArtifactHolder.h"
+#include "CArtPlace.h"
 
 
 class CButton;
 class CButton;
 
 

+ 0 - 1
client/widgets/CComponent.cpp

@@ -10,7 +10,6 @@
 #include "StdInc.h"
 #include "StdInc.h"
 #include "CComponent.h"
 #include "CComponent.h"
 
 
-#include "CArtifactHolder.h"
 #include "Images.h"
 #include "Images.h"
 
 
 #include <vcmi/spells/Service.h>
 #include <vcmi/spells/Service.h>

+ 1 - 2
client/widgets/CExchangeController.h

@@ -9,8 +9,7 @@
  */
  */
 #pragma once
 #pragma once
  
  
-#include "../windows/CWindowObject.h"
-#include "CWindowWithArtifacts.h"
+#include "../lib/mapObjects/CGHeroInstance.h"
  
  
 class CCallback;
 class CCallback;
 
 

+ 5 - 6
client/widgets/CWindowWithArtifacts.h

@@ -9,14 +9,13 @@
  */
  */
 #pragma once
 #pragma once
 
 
-#include "CArtifactHolder.h"
 #include "CArtifactsOfHeroMain.h"
 #include "CArtifactsOfHeroMain.h"
 #include "CArtifactsOfHeroKingdom.h"
 #include "CArtifactsOfHeroKingdom.h"
 #include "CArtifactsOfHeroAltar.h"
 #include "CArtifactsOfHeroAltar.h"
 #include "CArtifactsOfHeroMarket.h"
 #include "CArtifactsOfHeroMarket.h"
 #include "CArtifactsOfHeroBackpack.h"
 #include "CArtifactsOfHeroBackpack.h"
 
 
-class CWindowWithArtifacts : public CArtifactHolder
+class CWindowWithArtifacts
 {
 {
 public:
 public:
 	using CArtifactsOfHeroPtr = std::variant<
 	using CArtifactsOfHeroPtr = std::variant<
@@ -38,10 +37,10 @@ public:
 	void showPopupArtPlaceHero(CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition);
 	void showPopupArtPlaceHero(CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition);
 	void gestureArtPlaceHero(CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition);
 	void gestureArtPlaceHero(CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition);
 
 
-	void artifactRemoved(const ArtifactLocation & artLoc) override;
-	void artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw) override;
-	void artifactDisassembled(const ArtifactLocation & artLoc) override;
-	void artifactAssembled(const ArtifactLocation & artLoc) override;
+	virtual void artifactRemoved(const ArtifactLocation & artLoc);
+	virtual void artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw);
+	virtual void artifactDisassembled(const ArtifactLocation & artLoc);
+	virtual void artifactAssembled(const ArtifactLocation & artLoc);
 
 
 protected:
 protected:
 	std::vector<CArtifactsOfHeroPtr> artSets;
 	std::vector<CArtifactsOfHeroPtr> artSets;

+ 1 - 1
client/windows/CCreatureWindow.cpp

@@ -17,7 +17,7 @@
 #include "../CPlayerInterface.h"
 #include "../CPlayerInterface.h"
 #include "../render/Canvas.h"
 #include "../render/Canvas.h"
 #include "../widgets/Buttons.h"
 #include "../widgets/Buttons.h"
-#include "../widgets/CArtifactHolder.h"
+#include "../widgets/CArtPlace.h"
 #include "../widgets/CComponent.h"
 #include "../widgets/CComponent.h"
 #include "../widgets/Images.h"
 #include "../widgets/Images.h"
 #include "../widgets/TextControls.h"
 #include "../widgets/TextControls.h"

+ 5 - 5
client/windows/CKingdomInterface.cpp

@@ -676,25 +676,25 @@ bool CKingdomInterface::holdsGarrison(const CArmedInstance * army)
 
 
 void CKingdomInterface::artifactAssembled(const ArtifactLocation& artLoc)
 void CKingdomInterface::artifactAssembled(const ArtifactLocation& artLoc)
 {
 {
-	if(auto arts = std::dynamic_pointer_cast<CArtifactHolder>(tabArea->getItem()))
+	if(auto arts = std::dynamic_pointer_cast<CWindowWithArtifacts>(tabArea->getItem()))
 		arts->artifactAssembled(artLoc);
 		arts->artifactAssembled(artLoc);
 }
 }
 
 
 void CKingdomInterface::artifactDisassembled(const ArtifactLocation& artLoc)
 void CKingdomInterface::artifactDisassembled(const ArtifactLocation& artLoc)
 {
 {
-	if(auto arts = std::dynamic_pointer_cast<CArtifactHolder>(tabArea->getItem()))
+	if(auto arts = std::dynamic_pointer_cast<CWindowWithArtifacts>(tabArea->getItem()))
 		arts->artifactDisassembled(artLoc);
 		arts->artifactDisassembled(artLoc);
 }
 }
 
 
 void CKingdomInterface::artifactMoved(const ArtifactLocation& artLoc, const ArtifactLocation& destLoc, bool withRedraw)
 void CKingdomInterface::artifactMoved(const ArtifactLocation& artLoc, const ArtifactLocation& destLoc, bool withRedraw)
 {
 {
-	if(auto arts = std::dynamic_pointer_cast<CArtifactHolder>(tabArea->getItem()))
+	if(auto arts = std::dynamic_pointer_cast<CWindowWithArtifacts>(tabArea->getItem()))
 		arts->artifactMoved(artLoc, destLoc, withRedraw);
 		arts->artifactMoved(artLoc, destLoc, withRedraw);
 }
 }
 
 
 void CKingdomInterface::artifactRemoved(const ArtifactLocation& artLoc)
 void CKingdomInterface::artifactRemoved(const ArtifactLocation& artLoc)
 {
 {
-	if(auto arts = std::dynamic_pointer_cast<CArtifactHolder>(tabArea->getItem()))
+	if(auto arts = std::dynamic_pointer_cast<CWindowWithArtifacts>(tabArea->getItem()))
 		arts->artifactRemoved(artLoc);
 		arts->artifactRemoved(artLoc);
 }
 }
 
 
@@ -745,7 +745,7 @@ std::shared_ptr<CIntObject> CKingdHeroList::createHeroItem(size_t index)
 	if(index < heroesList.size())
 	if(index < heroesList.size())
 	{
 	{
 		auto hero = std::make_shared<CHeroItem>(heroesList[index]);
 		auto hero = std::make_shared<CHeroItem>(heroesList[index]);
-		addSetAndCallbacks(hero->heroArts);
+		//addSetAndCallbacks(hero->heroArts);
 		return hero;
 		return hero;
 	}
 	}
 	else
 	else

+ 2 - 2
client/windows/CKingdomInterface.h

@@ -200,7 +200,7 @@ public:
 };
 };
 
 
 /// Class which holds all parts of kingdom overview window
 /// Class which holds all parts of kingdom overview window
-class CKingdomInterface : public CWindowObject, public IGarrisonHolder, public CArtifactHolder, public ITownHolder
+class CKingdomInterface : public CWindowObject, public IGarrisonHolder, public CWindowWithArtifacts, public ITownHolder
 {
 {
 private:
 private:
 	struct OwnedObjectInfo
 	struct OwnedObjectInfo
@@ -330,7 +330,7 @@ public:
 };
 };
 
 
 /// Tab with all hero-specific data
 /// Tab with all hero-specific data
-class CKingdHeroList : public CIntObject, public IGarrisonHolder, public CWindowWithArtifacts
+class CKingdHeroList : public CIntObject, public IGarrisonHolder
 {
 {
 private:
 private:
 	std::shared_ptr<CListBox> heroes;
 	std::shared_ptr<CListBox> heroes;

+ 1 - 0
client/windows/GUIClasses.h

@@ -13,6 +13,7 @@
 #include "../widgets/CExchangeController.h"
 #include "../widgets/CExchangeController.h"
 #include "../widgets/CWindowWithArtifacts.h"
 #include "../widgets/CWindowWithArtifacts.h"
 #include "../widgets/Images.h"
 #include "../widgets/Images.h"
+#include "../windows/CWindowObject.h"
 
 
 VCMI_LIB_NAMESPACE_BEGIN
 VCMI_LIB_NAMESPACE_BEGIN