From 25d2b468c37c3c4269c0e88e6b21bf74cdb203cd Mon Sep 17 00:00:00 2001 From: SoundSSGood <87084363+SoundSSGood@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:49:35 +0300 Subject: [PATCH] CWindowWithArtifacts preparations --- client/CMakeLists.txt | 4 ++-- client/CPlayerInterface.cpp | 8 ++++---- .../{CArtifactHolder.cpp => CArtPlace.cpp} | 4 ++-- .../widgets/{CArtifactHolder.h => CArtPlace.h} | 18 +----------------- client/widgets/CArtifactsOfHeroBase.h | 2 +- client/widgets/CComponent.cpp | 1 - client/widgets/CExchangeController.h | 3 +-- client/widgets/CWindowWithArtifacts.h | 11 +++++------ client/windows/CCreatureWindow.cpp | 2 +- client/windows/CKingdomInterface.cpp | 10 +++++----- client/windows/CKingdomInterface.h | 4 ++-- client/windows/GUIClasses.h | 1 + 12 files changed, 25 insertions(+), 43 deletions(-) rename client/widgets/{CArtifactHolder.cpp => CArtPlace.cpp} (99%) rename client/widgets/{CArtifactHolder.h => CArtPlace.h} (80%) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 35d23822b..632601cc2 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -103,7 +103,7 @@ set(client_SRCS globalLobby/GlobalLobbyWindow.cpp widgets/Buttons.cpp - widgets/CArtifactHolder.cpp + widgets/CArtPlace.cpp widgets/CComponent.cpp widgets/CExchangeController.cpp widgets/CGarrisonInt.cpp @@ -293,7 +293,7 @@ set(client_HEADERS globalLobby/GlobalLobbyWindow.h widgets/Buttons.h - widgets/CArtifactHolder.h + widgets/CArtPlace.h widgets/CComponent.h widgets/CExchangeController.h widgets/CGarrisonInt.h diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index ded74dfc2..551072e2a 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -1745,7 +1745,7 @@ void CPlayerInterface::artifactRemoved(const ArtifactLocation &al) EVENT_HANDLER_CALLED_BY_CLIENT; adventureInt->onHeroChanged(cb->getHero(al.artHolder)); - for(auto artWin : GH.windows().findWindows()) + for(auto artWin : GH.windows().findWindows()) artWin->artifactRemoved(al); waitWhileDialog(); @@ -1765,7 +1765,7 @@ void CPlayerInterface::artifactMoved(const ArtifactLocation &src, const Artifact redraw = false; } - for(auto artWin : GH.windows().findWindows()) + for(auto artWin : GH.windows().findWindows()) artWin->artifactMoved(src, dst, redraw); waitWhileDialog(); @@ -1781,7 +1781,7 @@ void CPlayerInterface::artifactAssembled(const ArtifactLocation &al) EVENT_HANDLER_CALLED_BY_CLIENT; adventureInt->onHeroChanged(cb->getHero(al.artHolder)); - for(auto artWin : GH.windows().findWindows()) + for(auto artWin : GH.windows().findWindows()) artWin->artifactAssembled(al); } @@ -1790,7 +1790,7 @@ void CPlayerInterface::artifactDisassembled(const ArtifactLocation &al) EVENT_HANDLER_CALLED_BY_CLIENT; adventureInt->onHeroChanged(cb->getHero(al.artHolder)); - for(auto artWin : GH.windows().findWindows()) + for(auto artWin : GH.windows().findWindows()) artWin->artifactDisassembled(al); } diff --git a/client/widgets/CArtifactHolder.cpp b/client/widgets/CArtPlace.cpp similarity index 99% rename from client/widgets/CArtifactHolder.cpp rename to client/widgets/CArtPlace.cpp index 14a90796d..3e709599b 100644 --- a/client/widgets/CArtifactHolder.cpp +++ b/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 * @@ -8,7 +8,7 @@ * */ #include "StdInc.h" -#include "CArtifactHolder.h" +#include "CArtPlace.h" #include "../gui/CGuiHandler.h" #include "../gui/Shortcut.h" diff --git a/client/widgets/CArtifactHolder.h b/client/widgets/CArtPlace.h similarity index 80% rename from client/widgets/CArtifactHolder.h rename to client/widgets/CArtPlace.h index c39cbdca7..eb0752af5 100644 --- a/client/widgets/CArtifactHolder.h +++ b/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 * @@ -11,24 +11,8 @@ #include "MiscWidgets.h" -VCMI_LIB_NAMESPACE_BEGIN - -struct ArtifactLocation; -class CArtifactSet; - -VCMI_LIB_NAMESPACE_END - 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 { public: diff --git a/client/widgets/CArtifactsOfHeroBase.h b/client/widgets/CArtifactsOfHeroBase.h index 61a16580f..db5eef332 100644 --- a/client/widgets/CArtifactsOfHeroBase.h +++ b/client/widgets/CArtifactsOfHeroBase.h @@ -9,7 +9,7 @@ */ #pragma once -#include "CArtifactHolder.h" +#include "CArtPlace.h" class CButton; diff --git a/client/widgets/CComponent.cpp b/client/widgets/CComponent.cpp index d8e7a7d97..2d31f76eb 100644 --- a/client/widgets/CComponent.cpp +++ b/client/widgets/CComponent.cpp @@ -10,7 +10,6 @@ #include "StdInc.h" #include "CComponent.h" -#include "CArtifactHolder.h" #include "Images.h" #include diff --git a/client/widgets/CExchangeController.h b/client/widgets/CExchangeController.h index e5aa53b8c..1348002a4 100644 --- a/client/widgets/CExchangeController.h +++ b/client/widgets/CExchangeController.h @@ -9,8 +9,7 @@ */ #pragma once -#include "../windows/CWindowObject.h" -#include "CWindowWithArtifacts.h" +#include "../lib/mapObjects/CGHeroInstance.h" class CCallback; diff --git a/client/widgets/CWindowWithArtifacts.h b/client/widgets/CWindowWithArtifacts.h index 6ba216ba8..23b287465 100644 --- a/client/widgets/CWindowWithArtifacts.h +++ b/client/widgets/CWindowWithArtifacts.h @@ -9,14 +9,13 @@ */ #pragma once -#include "CArtifactHolder.h" #include "CArtifactsOfHeroMain.h" #include "CArtifactsOfHeroKingdom.h" #include "CArtifactsOfHeroAltar.h" #include "CArtifactsOfHeroMarket.h" #include "CArtifactsOfHeroBackpack.h" -class CWindowWithArtifacts : public CArtifactHolder +class CWindowWithArtifacts { public: using CArtifactsOfHeroPtr = std::variant< @@ -38,10 +37,10 @@ public: void showPopupArtPlaceHero(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: std::vector artSets; diff --git a/client/windows/CCreatureWindow.cpp b/client/windows/CCreatureWindow.cpp index 65b457733..ee2c75471 100644 --- a/client/windows/CCreatureWindow.cpp +++ b/client/windows/CCreatureWindow.cpp @@ -17,7 +17,7 @@ #include "../CPlayerInterface.h" #include "../render/Canvas.h" #include "../widgets/Buttons.h" -#include "../widgets/CArtifactHolder.h" +#include "../widgets/CArtPlace.h" #include "../widgets/CComponent.h" #include "../widgets/Images.h" #include "../widgets/TextControls.h" diff --git a/client/windows/CKingdomInterface.cpp b/client/windows/CKingdomInterface.cpp index b1466c40d..eb09b6209 100644 --- a/client/windows/CKingdomInterface.cpp +++ b/client/windows/CKingdomInterface.cpp @@ -676,25 +676,25 @@ bool CKingdomInterface::holdsGarrison(const CArmedInstance * army) void CKingdomInterface::artifactAssembled(const ArtifactLocation& artLoc) { - if(auto arts = std::dynamic_pointer_cast(tabArea->getItem())) + if(auto arts = std::dynamic_pointer_cast(tabArea->getItem())) arts->artifactAssembled(artLoc); } void CKingdomInterface::artifactDisassembled(const ArtifactLocation& artLoc) { - if(auto arts = std::dynamic_pointer_cast(tabArea->getItem())) + if(auto arts = std::dynamic_pointer_cast(tabArea->getItem())) arts->artifactDisassembled(artLoc); } void CKingdomInterface::artifactMoved(const ArtifactLocation& artLoc, const ArtifactLocation& destLoc, bool withRedraw) { - if(auto arts = std::dynamic_pointer_cast(tabArea->getItem())) + if(auto arts = std::dynamic_pointer_cast(tabArea->getItem())) arts->artifactMoved(artLoc, destLoc, withRedraw); } void CKingdomInterface::artifactRemoved(const ArtifactLocation& artLoc) { - if(auto arts = std::dynamic_pointer_cast(tabArea->getItem())) + if(auto arts = std::dynamic_pointer_cast(tabArea->getItem())) arts->artifactRemoved(artLoc); } @@ -745,7 +745,7 @@ std::shared_ptr CKingdHeroList::createHeroItem(size_t index) if(index < heroesList.size()) { auto hero = std::make_shared(heroesList[index]); - addSetAndCallbacks(hero->heroArts); + //addSetAndCallbacks(hero->heroArts); return hero; } else diff --git a/client/windows/CKingdomInterface.h b/client/windows/CKingdomInterface.h index ba2291379..5823e2298 100644 --- a/client/windows/CKingdomInterface.h +++ b/client/windows/CKingdomInterface.h @@ -200,7 +200,7 @@ public: }; /// 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: struct OwnedObjectInfo @@ -330,7 +330,7 @@ public: }; /// Tab with all hero-specific data -class CKingdHeroList : public CIntObject, public IGarrisonHolder, public CWindowWithArtifacts +class CKingdHeroList : public CIntObject, public IGarrisonHolder { private: std::shared_ptr heroes; diff --git a/client/windows/GUIClasses.h b/client/windows/GUIClasses.h index 6048ef3ca..85ebd3c69 100644 --- a/client/windows/GUIClasses.h +++ b/client/windows/GUIClasses.h @@ -13,6 +13,7 @@ #include "../widgets/CExchangeController.h" #include "../widgets/CWindowWithArtifacts.h" #include "../widgets/Images.h" +#include "../windows/CWindowObject.h" VCMI_LIB_NAMESPACE_BEGIN