1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

CWindowWithArtifacts preparations

This commit is contained in:
SoundSSGood 2024-04-23 13:49:35 +03:00
parent 62d15ed23c
commit 25d2b468c3
12 changed files with 25 additions and 43 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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; virtual void artifactRemoved(const ArtifactLocation & artLoc);
void artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw) override; virtual void artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw);
void artifactDisassembled(const ArtifactLocation & artLoc) override; virtual void artifactDisassembled(const ArtifactLocation & artLoc);
void artifactAssembled(const ArtifactLocation & artLoc) override; virtual void artifactAssembled(const ArtifactLocation & artLoc);
protected: protected:
std::vector<CArtifactsOfHeroPtr> artSets; std::vector<CArtifactsOfHeroPtr> artSets;

View File

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

View File

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

View File

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

View File

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