mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
virtual CWindowObject
This commit is contained in:
@@ -122,7 +122,6 @@ set(client_SRCS
|
|||||||
widgets/CArtifactsOfHeroAltar.cpp
|
widgets/CArtifactsOfHeroAltar.cpp
|
||||||
widgets/CArtifactsOfHeroMarket.cpp
|
widgets/CArtifactsOfHeroMarket.cpp
|
||||||
widgets/CArtifactsOfHeroBackpack.cpp
|
widgets/CArtifactsOfHeroBackpack.cpp
|
||||||
widgets/CWindowWithArtifacts.cpp
|
|
||||||
widgets/RadialMenu.cpp
|
widgets/RadialMenu.cpp
|
||||||
widgets/markets/CAltarArtifacts.cpp
|
widgets/markets/CAltarArtifacts.cpp
|
||||||
widgets/markets/CAltarCreatures.cpp
|
widgets/markets/CAltarCreatures.cpp
|
||||||
@@ -152,6 +151,7 @@ set(client_SRCS
|
|||||||
windows/InfoWindows.cpp
|
windows/InfoWindows.cpp
|
||||||
windows/QuickRecruitmentWindow.cpp
|
windows/QuickRecruitmentWindow.cpp
|
||||||
windows/CHeroBackpackWindow.cpp
|
windows/CHeroBackpackWindow.cpp
|
||||||
|
windows/CWindowWithArtifacts.cpp
|
||||||
windows/settings/GeneralOptionsTab.cpp
|
windows/settings/GeneralOptionsTab.cpp
|
||||||
windows/settings/OtherOptionsTab.cpp
|
windows/settings/OtherOptionsTab.cpp
|
||||||
windows/settings/SettingsMainWindow.cpp
|
windows/settings/SettingsMainWindow.cpp
|
||||||
@@ -312,7 +312,6 @@ set(client_HEADERS
|
|||||||
widgets/CArtifactsOfHeroAltar.h
|
widgets/CArtifactsOfHeroAltar.h
|
||||||
widgets/CArtifactsOfHeroMarket.h
|
widgets/CArtifactsOfHeroMarket.h
|
||||||
widgets/CArtifactsOfHeroBackpack.h
|
widgets/CArtifactsOfHeroBackpack.h
|
||||||
widgets/CWindowWithArtifacts.h
|
|
||||||
widgets/RadialMenu.h
|
widgets/RadialMenu.h
|
||||||
widgets/markets/CAltarArtifacts.h
|
widgets/markets/CAltarArtifacts.h
|
||||||
widgets/markets/CAltarCreatures.h
|
widgets/markets/CAltarCreatures.h
|
||||||
@@ -342,6 +341,7 @@ set(client_HEADERS
|
|||||||
windows/InfoWindows.h
|
windows/InfoWindows.h
|
||||||
windows/QuickRecruitmentWindow.h
|
windows/QuickRecruitmentWindow.h
|
||||||
windows/CHeroBackpackWindow.h
|
windows/CHeroBackpackWindow.h
|
||||||
|
windows/CWindowWithArtifacts.h
|
||||||
windows/settings/GeneralOptionsTab.h
|
windows/settings/GeneralOptionsTab.h
|
||||||
windows/settings/OtherOptionsTab.h
|
windows/settings/OtherOptionsTab.h
|
||||||
windows/settings/SettingsMainWindow.h
|
windows/settings/SettingsMainWindow.h
|
||||||
|
|||||||
@@ -1183,7 +1183,7 @@ void CTownInfo::showPopupWindow(const Point & cursorPosition)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInstance * from):
|
CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInstance * from):
|
||||||
CStatusbarWindow(PLAYER_COLORED | BORDERED),
|
CWindowObject(PLAYER_COLORED | BORDERED),
|
||||||
town(Town)
|
town(Town)
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
@@ -1459,7 +1459,7 @@ void CHallInterface::CBuildingBox::showPopupWindow(const Point & cursorPosition)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CHallInterface::CHallInterface(const CGTownInstance * Town):
|
CHallInterface::CHallInterface(const CGTownInstance * Town):
|
||||||
CStatusbarWindow(PLAYER_COLORED | BORDERED, Town->town->clientInfo.hallBackground),
|
CWindowObject(PLAYER_COLORED | BORDERED, Town->town->clientInfo.hallBackground),
|
||||||
town(Town)
|
town(Town)
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
@@ -1507,7 +1507,7 @@ CHallInterface::CHallInterface(const CGTownInstance * Town):
|
|||||||
}
|
}
|
||||||
|
|
||||||
CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Building, EBuildingState state, bool rightClick):
|
CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Building, EBuildingState state, bool rightClick):
|
||||||
CStatusbarWindow(PLAYER_COLORED | (rightClick ? RCLICK_POPUP : 0), ImagePath::builtin("TPUBUILD")),
|
CWindowObject(PLAYER_COLORED | (rightClick ? RCLICK_POPUP : 0), ImagePath::builtin("TPUBUILD")),
|
||||||
town(Town),
|
town(Town),
|
||||||
building(Building)
|
building(Building)
|
||||||
{
|
{
|
||||||
@@ -1660,7 +1660,7 @@ void LabeledValue::hover(bool on)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CFortScreen::CFortScreen(const CGTownInstance * town):
|
CFortScreen::CFortScreen(const CGTownInstance * town):
|
||||||
CStatusbarWindow(PLAYER_COLORED | BORDERED, getBgName(town))
|
CWindowObject(PLAYER_COLORED | BORDERED, getBgName(town))
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
ui32 fortSize = static_cast<ui32>(town->creatures.size());
|
ui32 fortSize = static_cast<ui32>(town->creatures.size());
|
||||||
@@ -1849,7 +1849,7 @@ void CFortScreen::RecruitArea::showPopupWindow(const Point & cursorPosition)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CMageGuildScreen::CMageGuildScreen(CCastleInterface * owner, const ImagePath & imagename)
|
CMageGuildScreen::CMageGuildScreen(CCastleInterface * owner, const ImagePath & imagename)
|
||||||
: CStatusbarWindow(BORDERED, imagename)
|
: CWindowObject(BORDERED, imagename)
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
|
|
||||||
@@ -1918,7 +1918,7 @@ void CMageGuildScreen::Scroll::hover(bool on)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CBlacksmithDialog::CBlacksmithDialog(bool possible, CreatureID creMachineID, ArtifactID aid, ObjectInstanceID hid):
|
CBlacksmithDialog::CBlacksmithDialog(bool possible, CreatureID creMachineID, ArtifactID aid, ObjectInstanceID hid):
|
||||||
CStatusbarWindow(PLAYER_COLORED, ImagePath::builtin("TPSMITH"))
|
CWindowObject(PLAYER_COLORED, ImagePath::builtin("TPSMITH"))
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,7 @@
|
|||||||
#include "CPlayerInterface.h"
|
#include "CPlayerInterface.h"
|
||||||
|
|
||||||
CHeroBackpackWindow::CHeroBackpackWindow(const CGHeroInstance * hero, const std::vector<CArtifactsOfHeroPtr> & artsSets)
|
CHeroBackpackWindow::CHeroBackpackWindow(const CGHeroInstance * hero, const std::vector<CArtifactsOfHeroPtr> & artsSets)
|
||||||
: CStatusbarWindow(0)
|
: CWindowWithArtifacts(&artsSets)
|
||||||
, CWindowWithArtifacts(&artsSets)
|
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE);
|
||||||
|
|
||||||
@@ -49,15 +48,7 @@ void CHeroBackpackWindow::showAll(Canvas & to)
|
|||||||
CMessage::drawBorder(PlayerColor(LOCPLINT->playerID), to, pos.w+28, pos.h+29, pos.x-14, pos.y-15);
|
CMessage::drawBorder(PlayerColor(LOCPLINT->playerID), to, pos.w+28, pos.h+29, pos.x-14, pos.y-15);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHeroBackpackWindow::activate()
|
|
||||||
{
|
|
||||||
if(const auto art = getPickedArtifact())
|
|
||||||
setCursorAnimation(*art);
|
|
||||||
CIntObject::activate();
|
|
||||||
}
|
|
||||||
|
|
||||||
CHeroQuickBackpackWindow::CHeroQuickBackpackWindow(const CGHeroInstance * hero, ArtifactPosition targetSlot)
|
CHeroQuickBackpackWindow::CHeroQuickBackpackWindow(const CGHeroInstance * hero, ArtifactPosition targetSlot)
|
||||||
: CWindowObject(0)
|
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE);
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../widgets/CWindowWithArtifacts.h"
|
#include "CWindowWithArtifacts.h"
|
||||||
#include "CWindowObject.h"
|
|
||||||
|
|
||||||
class CFilledTexture;
|
class CFilledTexture;
|
||||||
|
|
||||||
@@ -26,10 +25,9 @@ protected:
|
|||||||
const int windowMargin = 5;
|
const int windowMargin = 5;
|
||||||
|
|
||||||
void showAll(Canvas & to) override;
|
void showAll(Canvas & to) override;
|
||||||
void activate() override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CHeroQuickBackpackWindow : public CWindowObject, public CWindowWithArtifacts
|
class CHeroQuickBackpackWindow : public CWindowWithArtifacts
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CHeroQuickBackpackWindow(const CGHeroInstance * hero, ArtifactPosition targetSlot);
|
CHeroQuickBackpackWindow(const CGHeroInstance * hero, ArtifactPosition targetSlot);
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
#include "../CPlayerInterface.h"
|
#include "../CPlayerInterface.h"
|
||||||
|
|
||||||
#include "../gui/CGuiHandler.h"
|
#include "../gui/CGuiHandler.h"
|
||||||
#include "../gui/CursorHandler.h"
|
|
||||||
#include "../gui/TextAlignment.h"
|
#include "../gui/TextAlignment.h"
|
||||||
#include "../gui/Shortcut.h"
|
#include "../gui/Shortcut.h"
|
||||||
#include "../gui/WindowHandler.h"
|
#include "../gui/WindowHandler.h"
|
||||||
@@ -71,7 +70,7 @@ CHeroSwitcher::CHeroSwitcher(CHeroWindow * owner_, Point pos_, const CGHeroInsta
|
|||||||
}
|
}
|
||||||
|
|
||||||
CHeroWindow::CHeroWindow(const CGHeroInstance * hero)
|
CHeroWindow::CHeroWindow(const CGHeroInstance * hero)
|
||||||
: CStatusbarWindow(PLAYER_COLORED, ImagePath::builtin("HeroScr4"))
|
: CWindowObject(PLAYER_COLORED, ImagePath::builtin("HeroScr4"))
|
||||||
{
|
{
|
||||||
auto & heroscrn = CGI->generaltexth->heroscrn;
|
auto & heroscrn = CGI->generaltexth->heroscrn;
|
||||||
|
|
||||||
@@ -360,9 +359,3 @@ bool CHeroWindow::holdsGarrison(const CArmedInstance * army)
|
|||||||
{
|
{
|
||||||
return army == curHero;
|
return army == curHero;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHeroWindow::deactivate()
|
|
||||||
{
|
|
||||||
CCS->curh->dragAndDropCursor(nullptr);
|
|
||||||
CIntObject::deactivate();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -9,8 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../widgets/CWindowWithArtifacts.h"
|
#include "CWindowWithArtifacts.h"
|
||||||
#include "CWindowObject.h"
|
|
||||||
|
|
||||||
#include "../../lib/bonuses/IBonusBearer.h"
|
#include "../../lib/bonuses/IBonusBearer.h"
|
||||||
|
|
||||||
@@ -108,7 +107,6 @@ public:
|
|||||||
void switchHero(); //changes displayed hero
|
void switchHero(); //changes displayed hero
|
||||||
void updateGarrisons() override;
|
void updateGarrisons() override;
|
||||||
bool holdsGarrison(const CArmedInstance * army) override;
|
bool holdsGarrison(const CArmedInstance * army) override;
|
||||||
void deactivate() override;
|
|
||||||
void createBackpackWindow();
|
void createBackpackWindow();
|
||||||
|
|
||||||
//friends
|
//friends
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
#include "../PlayerLocalState.h"
|
#include "../PlayerLocalState.h"
|
||||||
#include "../adventureMap/CResDataBar.h"
|
#include "../adventureMap/CResDataBar.h"
|
||||||
#include "../gui/CGuiHandler.h"
|
#include "../gui/CGuiHandler.h"
|
||||||
#include "../gui/CursorHandler.h"
|
|
||||||
#include "../gui/Shortcut.h"
|
#include "../gui/Shortcut.h"
|
||||||
#include "../gui/WindowHandler.h"
|
#include "../gui/WindowHandler.h"
|
||||||
#include "../widgets/CComponent.h"
|
#include "../widgets/CComponent.h"
|
||||||
@@ -549,7 +548,10 @@ std::shared_ptr<CIntObject> CKingdomInterface::createMainTab(size_t index)
|
|||||||
switch(index)
|
switch(index)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return std::make_shared<CKingdHeroList>(size);
|
return std::make_shared<CKingdHeroList>(size, [this](const CWindowWithArtifacts::CArtifactsOfHeroPtr & newHeroSet)
|
||||||
|
{
|
||||||
|
addSetAndCallbacks(newHeroSet);
|
||||||
|
});
|
||||||
case 1:
|
case 1:
|
||||||
return std::make_shared<CKingdTownList>(size);
|
return std::make_shared<CKingdTownList>(size);
|
||||||
default:
|
default:
|
||||||
@@ -674,31 +676,7 @@ bool CKingdomInterface::holdsGarrison(const CArmedInstance * army)
|
|||||||
return army->getOwner() == LOCPLINT->playerID;
|
return army->getOwner() == LOCPLINT->playerID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKingdomInterface::artifactAssembled(const ArtifactLocation& artLoc)
|
CKingdHeroList::CKingdHeroList(size_t maxSize, const CreateHeroItemFunctor & onCreateHeroItemCallback)
|
||||||
{
|
|
||||||
if(auto arts = std::dynamic_pointer_cast<CWindowWithArtifacts>(tabArea->getItem()))
|
|
||||||
arts->artifactAssembled(artLoc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CKingdomInterface::artifactDisassembled(const ArtifactLocation& artLoc)
|
|
||||||
{
|
|
||||||
if(auto arts = std::dynamic_pointer_cast<CWindowWithArtifacts>(tabArea->getItem()))
|
|
||||||
arts->artifactDisassembled(artLoc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CKingdomInterface::artifactMoved(const ArtifactLocation& artLoc, const ArtifactLocation& destLoc, bool withRedraw)
|
|
||||||
{
|
|
||||||
if(auto arts = std::dynamic_pointer_cast<CWindowWithArtifacts>(tabArea->getItem()))
|
|
||||||
arts->artifactMoved(artLoc, destLoc, withRedraw);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CKingdomInterface::artifactRemoved(const ArtifactLocation& artLoc)
|
|
||||||
{
|
|
||||||
if(auto arts = std::dynamic_pointer_cast<CWindowWithArtifacts>(tabArea->getItem()))
|
|
||||||
arts->artifactRemoved(artLoc);
|
|
||||||
}
|
|
||||||
|
|
||||||
CKingdHeroList::CKingdHeroList(size_t maxSize)
|
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
title = std::make_shared<CPicture>(ImagePath::builtin("OVTITLE"),16,0);
|
title = std::make_shared<CPicture>(ImagePath::builtin("OVTITLE"),16,0);
|
||||||
@@ -708,8 +686,20 @@ CKingdHeroList::CKingdHeroList(size_t maxSize)
|
|||||||
|
|
||||||
ui32 townCount = LOCPLINT->cb->howManyHeroes(false);
|
ui32 townCount = LOCPLINT->cb->howManyHeroes(false);
|
||||||
ui32 size = OVERVIEW_SIZE*116 + 19;
|
ui32 size = OVERVIEW_SIZE*116 + 19;
|
||||||
heroes = std::make_shared<CListBox>(std::bind(&CKingdHeroList::createHeroItem, this, _1),
|
heroes = std::make_shared<CListBox>([onCreateHeroItemCallback](size_t idx) -> std::shared_ptr<CIntObject>
|
||||||
Point(19,21), Point(0,116), maxSize, townCount, 0, 1, Rect(-19, -21, size, size));
|
{
|
||||||
|
auto heroesList = LOCPLINT->localState->getWanderingHeroes();
|
||||||
|
if(idx < heroesList.size())
|
||||||
|
{
|
||||||
|
auto hero = std::make_shared<CHeroItem>(heroesList[idx]);
|
||||||
|
onCreateHeroItemCallback(hero->heroArts);
|
||||||
|
return hero;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return std::make_shared<CAnimImage>(AnimationPath::builtin("OVSLOT"), (idx - 2) % GameConstants::KINGDOM_WINDOW_HEROES_SLOTS);
|
||||||
|
}
|
||||||
|
}, Point(19,21), Point(0,116), maxSize, townCount, 0, 1, Rect(-19, -21, size, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKingdHeroList::updateGarrisons()
|
void CKingdHeroList::updateGarrisons()
|
||||||
@@ -730,30 +720,6 @@ bool CKingdHeroList::holdsGarrison(const CArmedInstance * army)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKingdHeroList::deactivate()
|
|
||||||
{
|
|
||||||
CCS->curh->dragAndDropCursor(nullptr);
|
|
||||||
CIntObject::deactivate();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<CIntObject> CKingdHeroList::createHeroItem(size_t index)
|
|
||||||
{
|
|
||||||
ui32 picCount = 4; // OVSLOT contains 4 images
|
|
||||||
|
|
||||||
auto heroesList = LOCPLINT->localState->getWanderingHeroes();
|
|
||||||
|
|
||||||
if(index < heroesList.size())
|
|
||||||
{
|
|
||||||
auto hero = std::make_shared<CHeroItem>(heroesList[index]);
|
|
||||||
//addSetAndCallbacks(hero->heroArts);
|
|
||||||
return hero;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return std::make_shared<CAnimImage>(AnimationPath::builtin("OVSLOT"), (index-2) % picCount );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CKingdTownList::CKingdTownList(size_t maxSize)
|
CKingdTownList::CKingdTownList(size_t maxSize)
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
|
|||||||
@@ -9,8 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../widgets/CWindowWithArtifacts.h"
|
#include "CWindowWithArtifacts.h"
|
||||||
#include "CWindowObject.h"
|
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
class CGObjectInstance;
|
class CGObjectInstance;
|
||||||
@@ -200,7 +199,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 CWindowWithArtifacts, public ITownHolder
|
class CKingdomInterface : public IGarrisonHolder, public CWindowWithArtifacts, public ITownHolder
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
struct OwnedObjectInfo
|
struct OwnedObjectInfo
|
||||||
@@ -254,10 +253,6 @@ public:
|
|||||||
void heroRemoved();
|
void heroRemoved();
|
||||||
void updateGarrisons() override;
|
void updateGarrisons() override;
|
||||||
bool holdsGarrison(const CArmedInstance * army) override;
|
bool holdsGarrison(const CArmedInstance * army) override;
|
||||||
void artifactRemoved(const ArtifactLocation &artLoc) override;
|
|
||||||
void artifactMoved(const ArtifactLocation &artLoc, const ArtifactLocation &destLoc, bool withRedraw) override;
|
|
||||||
void artifactDisassembled(const ArtifactLocation &artLoc) override;
|
|
||||||
void artifactAssembled(const ArtifactLocation &artLoc) override;
|
|
||||||
void buildChanged() override;
|
void buildChanged() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -338,13 +333,12 @@ private:
|
|||||||
std::shared_ptr<CLabel> heroLabel;
|
std::shared_ptr<CLabel> heroLabel;
|
||||||
std::shared_ptr<CLabel> skillsLabel;
|
std::shared_ptr<CLabel> skillsLabel;
|
||||||
|
|
||||||
std::shared_ptr<CIntObject> createHeroItem(size_t index);
|
|
||||||
public:
|
public:
|
||||||
CKingdHeroList(size_t maxSize);
|
using CreateHeroItemFunctor = std::function<void(const CWindowWithArtifacts::CArtifactsOfHeroPtr)>;
|
||||||
|
|
||||||
|
CKingdHeroList(size_t maxSize, const CreateHeroItemFunctor & onCreateHeroItemCallback);
|
||||||
void updateGarrisons() override;
|
void updateGarrisons() override;
|
||||||
bool holdsGarrison(const CArmedInstance * army) override;
|
bool holdsGarrison(const CArmedInstance * army) override;
|
||||||
void deactivate() override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Tab with all town-specific data
|
/// Tab with all town-specific data
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
#include "CMarketWindow.h"
|
#include "CMarketWindow.h"
|
||||||
|
|
||||||
#include "../gui/CGuiHandler.h"
|
#include "../gui/CGuiHandler.h"
|
||||||
#include "../gui/CursorHandler.h"
|
|
||||||
#include "../gui/Shortcut.h"
|
#include "../gui/Shortcut.h"
|
||||||
|
|
||||||
#include "../widgets/Buttons.h"
|
#include "../widgets/Buttons.h"
|
||||||
@@ -34,7 +33,7 @@
|
|||||||
#include "../../lib/mapObjects/CGHeroInstance.h"
|
#include "../../lib/mapObjects/CGHeroInstance.h"
|
||||||
|
|
||||||
CMarketWindow::CMarketWindow(const IMarket * market, const CGHeroInstance * hero, const std::function<void()> & onWindowClosed, EMarketMode mode)
|
CMarketWindow::CMarketWindow(const IMarket * market, const CGHeroInstance * hero, const std::function<void()> & onWindowClosed, EMarketMode mode)
|
||||||
: CStatusbarWindow(PLAYER_COLORED)
|
: CWindowObject(PLAYER_COLORED)
|
||||||
, windowClosedCallback(onWindowClosed)
|
, windowClosedCallback(onWindowClosed)
|
||||||
{
|
{
|
||||||
assert(mode == EMarketMode::RESOURCE_RESOURCE || mode == EMarketMode::RESOURCE_PLAYER || mode == EMarketMode::CREATURE_RESOURCE ||
|
assert(mode == EMarketMode::RESOURCE_RESOURCE || mode == EMarketMode::RESOURCE_PLAYER || mode == EMarketMode::CREATURE_RESOURCE ||
|
||||||
@@ -262,9 +261,3 @@ void CMarketWindow::createAltarCreatures(const IMarket * market, const CGHeroIns
|
|||||||
initWidgetInternals(EMarketMode::CREATURE_EXP, CGI->generaltexth->zelp[568]);
|
initWidgetInternals(EMarketMode::CREATURE_EXP, CGI->generaltexth->zelp[568]);
|
||||||
updateHero();
|
updateHero();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMarketWindow::deactivate()
|
|
||||||
{
|
|
||||||
CCS->curh->dragAndDropCursor(nullptr);
|
|
||||||
CIntObject::deactivate();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -10,8 +10,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../widgets/markets/CMarketBase.h"
|
#include "../widgets/markets/CMarketBase.h"
|
||||||
#include "../widgets/CWindowWithArtifacts.h"
|
#include "CWindowWithArtifacts.h"
|
||||||
#include "CWindowObject.h"
|
|
||||||
|
|
||||||
class CMarketWindow : public CStatusbarWindow, public CWindowWithArtifacts, public IGarrisonHolder
|
class CMarketWindow : public CStatusbarWindow, public CWindowWithArtifacts, public IGarrisonHolder
|
||||||
{
|
{
|
||||||
@@ -25,7 +24,6 @@ public:
|
|||||||
bool holdsGarrison(const CArmedInstance * army) override;
|
bool holdsGarrison(const CArmedInstance * army) override;
|
||||||
void artifactRemoved(const ArtifactLocation & artLoc) override;
|
void artifactRemoved(const ArtifactLocation & artLoc) override;
|
||||||
void artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw) override;
|
void artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw) override;
|
||||||
void deactivate() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createChangeModeButtons(EMarketMode currentMode, const IMarket * market, const CGHeroInstance * hero);
|
void createChangeModeButtons(EMarketMode currentMode, const IMarket * market, const CGHeroInstance * hero);
|
||||||
|
|||||||
@@ -239,11 +239,3 @@ bool CWindowObject::isPopupWindow() const
|
|||||||
{
|
{
|
||||||
return options & RCLICK_POPUP;
|
return options & RCLICK_POPUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
CStatusbarWindow::CStatusbarWindow(int options, const ImagePath & imageName, Point centerAt) : CWindowObject(options, imageName, centerAt)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
CStatusbarWindow::CStatusbarWindow(int options, const ImagePath & imageName) : CWindowObject(options, imageName)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -47,17 +47,14 @@ public:
|
|||||||
* centerAt - position of window center. Default - center of the screen
|
* centerAt - position of window center. Default - center of the screen
|
||||||
*/
|
*/
|
||||||
CWindowObject(int options, const ImagePath & imageName, Point centerAt);
|
CWindowObject(int options, const ImagePath & imageName, Point centerAt);
|
||||||
CWindowObject(int options, const ImagePath & imageName = {});
|
CWindowObject(int options = 0, const ImagePath & imageName = {});
|
||||||
~CWindowObject();
|
~CWindowObject();
|
||||||
|
|
||||||
void showAll(Canvas & to) override;
|
void showAll(Canvas & to) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CStatusbarWindow : public CWindowObject
|
class CStatusbarWindow : virtual public CWindowObject
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
CStatusbarWindow(int options, const ImagePath & imageName, Point centerAt);
|
|
||||||
CStatusbarWindow(int options, const ImagePath & imageName = {});
|
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<CGStatusBar> statusbar;
|
std::shared_ptr<CGStatusBar> statusbar;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
#include "../render/CAnimation.h"
|
#include "../render/CAnimation.h"
|
||||||
#include "../render/IImage.h"
|
#include "../render/IImage.h"
|
||||||
|
|
||||||
#include "CComponent.h"
|
#include "../widgets/CComponent.h"
|
||||||
|
|
||||||
#include "../windows/CHeroWindow.h"
|
#include "../windows/CHeroWindow.h"
|
||||||
#include "../windows/CSpellWindow.h"
|
#include "../windows/CSpellWindow.h"
|
||||||
@@ -333,6 +333,19 @@ void CWindowWithArtifacts::gestureArtPlaceHero(CArtifactsOfHeroBase & artsInst,
|
|||||||
}, artSetWeak.value());
|
}, artSetWeak.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CWindowWithArtifacts::activate()
|
||||||
|
{
|
||||||
|
if(const auto art = getPickedArtifact())
|
||||||
|
setCursorAnimation(*art);
|
||||||
|
CWindowObject::activate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CWindowWithArtifacts::deactivate()
|
||||||
|
{
|
||||||
|
CCS->curh->dragAndDropCursor(nullptr);
|
||||||
|
CWindowObject::deactivate();
|
||||||
|
}
|
||||||
|
|
||||||
void CWindowWithArtifacts::artifactRemoved(const ArtifactLocation & artLoc)
|
void CWindowWithArtifacts::artifactRemoved(const ArtifactLocation & artLoc)
|
||||||
{
|
{
|
||||||
updateSlots();
|
updateSlots();
|
||||||
@@ -9,13 +9,14 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CArtifactsOfHeroMain.h"
|
#include "../widgets/CArtifactsOfHeroMain.h"
|
||||||
#include "CArtifactsOfHeroKingdom.h"
|
#include "../widgets/CArtifactsOfHeroKingdom.h"
|
||||||
#include "CArtifactsOfHeroAltar.h"
|
#include "../widgets/CArtifactsOfHeroAltar.h"
|
||||||
#include "CArtifactsOfHeroMarket.h"
|
#include "../widgets/CArtifactsOfHeroMarket.h"
|
||||||
#include "CArtifactsOfHeroBackpack.h"
|
#include "../widgets/CArtifactsOfHeroBackpack.h"
|
||||||
|
#include "CWindowObject.h"
|
||||||
|
|
||||||
class CWindowWithArtifacts
|
class CWindowWithArtifacts : virtual public CWindowObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using CArtifactsOfHeroPtr = std::variant<
|
using CArtifactsOfHeroPtr = std::variant<
|
||||||
@@ -36,6 +37,8 @@ public:
|
|||||||
void clickPressedArtPlaceHero(CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition);
|
void clickPressedArtPlaceHero(CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition);
|
||||||
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 activate() override;
|
||||||
|
void deactivate() override;
|
||||||
|
|
||||||
virtual void artifactRemoved(const ArtifactLocation & artLoc);
|
virtual void artifactRemoved(const ArtifactLocation & artLoc);
|
||||||
virtual void artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw);
|
virtual void artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw);
|
||||||
@@ -204,7 +204,7 @@ void CRecruitmentWindow::showAll(Canvas & to)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CRecruitmentWindow::CRecruitmentWindow(const CGDwelling * Dwelling, int Level, const CArmedInstance * Dst, const std::function<void(CreatureID,int)> & Recruit, const std::function<void()> & onClose, int y_offset):
|
CRecruitmentWindow::CRecruitmentWindow(const CGDwelling * Dwelling, int Level, const CArmedInstance * Dst, const std::function<void(CreatureID,int)> & Recruit, const std::function<void()> & onClose, int y_offset):
|
||||||
CStatusbarWindow(PLAYER_COLORED, ImagePath::builtin("TPRCRT")),
|
CWindowObject(PLAYER_COLORED, ImagePath::builtin("TPRCRT")),
|
||||||
onRecruit(Recruit),
|
onRecruit(Recruit),
|
||||||
onClose(onClose),
|
onClose(onClose),
|
||||||
level(Level),
|
level(Level),
|
||||||
@@ -445,7 +445,7 @@ CLevelWindow::~CLevelWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CTavernWindow::CTavernWindow(const CGObjectInstance * TavernObj, const std::function<void()> & onWindowClosed)
|
CTavernWindow::CTavernWindow(const CGObjectInstance * TavernObj, const std::function<void()> & onWindowClosed)
|
||||||
: CStatusbarWindow(PLAYER_COLORED, ImagePath::builtin("TPTAVERN")),
|
: CWindowObject(PLAYER_COLORED, ImagePath::builtin("TPTAVERN")),
|
||||||
onWindowClosed(onWindowClosed),
|
onWindowClosed(onWindowClosed),
|
||||||
tavernObj(TavernObj),
|
tavernObj(TavernObj),
|
||||||
heroToInvite(nullptr)
|
heroToInvite(nullptr)
|
||||||
@@ -692,7 +692,7 @@ static bool isQuickExchangeLayoutAvailable()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID queryID)
|
CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID queryID)
|
||||||
: CStatusbarWindow(PLAYER_COLORED | BORDERED, ImagePath::builtin(isQuickExchangeLayoutAvailable() ? QUICK_EXCHANGE_BG : "TRADE2")),
|
: CWindowObject(PLAYER_COLORED | BORDERED, ImagePath::builtin(isQuickExchangeLayoutAvailable() ? QUICK_EXCHANGE_BG : "TRADE2")),
|
||||||
controller(hero1, hero2),
|
controller(hero1, hero2),
|
||||||
moveStackLeftButtons(),
|
moveStackLeftButtons(),
|
||||||
moveStackRightButtons()
|
moveStackRightButtons()
|
||||||
@@ -934,12 +934,6 @@ bool CExchangeWindow::holdsGarrison(const CArmedInstance * army)
|
|||||||
return garr->upperArmy() == army || garr->lowerArmy() == army;
|
return garr->upperArmy() == army || garr->lowerArmy() == army;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CExchangeWindow::deactivate()
|
|
||||||
{
|
|
||||||
CCS->curh->dragAndDropCursor(nullptr);
|
|
||||||
CIntObject::deactivate();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CExchangeWindow::questlog(int whichHero)
|
void CExchangeWindow::questlog(int whichHero)
|
||||||
{
|
{
|
||||||
CCS->curh->dragAndDropCursor(nullptr);
|
CCS->curh->dragAndDropCursor(nullptr);
|
||||||
@@ -975,7 +969,7 @@ void CExchangeWindow::updateWidgets()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CShipyardWindow::CShipyardWindow(const TResources & cost, int state, BoatId boatType, const std::function<void()> & onBuy)
|
CShipyardWindow::CShipyardWindow(const TResources & cost, int state, BoatId boatType, const std::function<void()> & onBuy)
|
||||||
: CStatusbarWindow(PLAYER_COLORED, ImagePath::builtin("TPSHIP"))
|
: CWindowObject(PLAYER_COLORED, ImagePath::builtin("TPSHIP"))
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
|
|
||||||
@@ -1093,7 +1087,7 @@ bool CTransformerWindow::holdsGarrison(const CArmedInstance * army)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CTransformerWindow::CTransformerWindow(const IMarket * _market, const CGHeroInstance * _hero, const std::function<void()> & onWindowClosed)
|
CTransformerWindow::CTransformerWindow(const IMarket * _market, const CGHeroInstance * _hero, const std::function<void()> & onWindowClosed)
|
||||||
: CStatusbarWindow(PLAYER_COLORED, ImagePath::builtin("SKTRNBK")),
|
: CWindowObject(PLAYER_COLORED, ImagePath::builtin("SKTRNBK")),
|
||||||
hero(_hero),
|
hero(_hero),
|
||||||
onWindowClosed(onWindowClosed),
|
onWindowClosed(onWindowClosed),
|
||||||
market(_market)
|
market(_market)
|
||||||
@@ -1192,7 +1186,7 @@ void CUniversityWindow::CItem::showAll(Canvas & to)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, const IMarket * _market, const std::function<void()> & onWindowClosed)
|
CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, const IMarket * _market, const std::function<void()> & onWindowClosed)
|
||||||
: CStatusbarWindow(PLAYER_COLORED, ImagePath::builtin("UNIVERS1")),
|
: CWindowObject(PLAYER_COLORED, ImagePath::builtin("UNIVERS1")),
|
||||||
hero(_hero),
|
hero(_hero),
|
||||||
onWindowClosed(onWindowClosed),
|
onWindowClosed(onWindowClosed),
|
||||||
market(_market)
|
market(_market)
|
||||||
@@ -1254,7 +1248,7 @@ void CUniversityWindow::makeDeal(SecondarySkill skill)
|
|||||||
|
|
||||||
|
|
||||||
CUnivConfirmWindow::CUnivConfirmWindow(CUniversityWindow * owner_, SecondarySkill SKILL, bool available)
|
CUnivConfirmWindow::CUnivConfirmWindow(CUniversityWindow * owner_, SecondarySkill SKILL, bool available)
|
||||||
: CStatusbarWindow(PLAYER_COLORED, ImagePath::builtin("UNIVERS2.PCX")),
|
: CWindowObject(PLAYER_COLORED, ImagePath::builtin("UNIVERS2.PCX")),
|
||||||
owner(owner_)
|
owner(owner_)
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
@@ -1341,7 +1335,7 @@ bool CGarrisonWindow::holdsGarrison(const CArmedInstance * army)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CHillFortWindow::CHillFortWindow(const CGHeroInstance * visitor, const CGObjectInstance * object)
|
CHillFortWindow::CHillFortWindow(const CGHeroInstance * visitor, const CGObjectInstance * object)
|
||||||
: CStatusbarWindow(PLAYER_COLORED, ImagePath::builtin("APHLFTBK")),
|
: CWindowObject(PLAYER_COLORED, ImagePath::builtin("APHLFTBK")),
|
||||||
fort(object),
|
fort(object),
|
||||||
hero(visitor)
|
hero(visitor)
|
||||||
{
|
{
|
||||||
@@ -1545,7 +1539,7 @@ int CHillFortWindow::getState(SlotID slot)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
|
CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
|
||||||
CStatusbarWindow(PLAYER_COLORED | BORDERED, ImagePath::builtin("TpRank")),
|
CWindowObject(PLAYER_COLORED | BORDERED, ImagePath::builtin("TpRank")),
|
||||||
owner(_owner)
|
owner(_owner)
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
|
|||||||
@@ -11,9 +11,8 @@
|
|||||||
|
|
||||||
#include "../lib/ResourceSet.h"
|
#include "../lib/ResourceSet.h"
|
||||||
#include "../widgets/CExchangeController.h"
|
#include "../widgets/CExchangeController.h"
|
||||||
#include "../widgets/CWindowWithArtifacts.h"
|
|
||||||
#include "../widgets/Images.h"
|
#include "../widgets/Images.h"
|
||||||
#include "../windows/CWindowObject.h"
|
#include "CWindowWithArtifacts.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
@@ -326,7 +325,6 @@ public:
|
|||||||
|
|
||||||
void updateGarrisons() override;
|
void updateGarrisons() override;
|
||||||
bool holdsGarrison(const CArmedInstance * army) override;
|
bool holdsGarrison(const CArmedInstance * army) override;
|
||||||
void deactivate() override;
|
|
||||||
|
|
||||||
void questlog(int whichHero); //questlog button callback; whichHero: 0 - left, 1 - right
|
void questlog(int whichHero); //questlog button callback; whichHero: 0 - left, 1 - right
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ namespace GameConstants
|
|||||||
constexpr int64_t PLAYER_RESOURCES_CAP = 1000 * 1000 * 1000;
|
constexpr int64_t PLAYER_RESOURCES_CAP = 1000 * 1000 * 1000;
|
||||||
constexpr int ALTAR_ARTIFACTS_SLOTS = 22;
|
constexpr int ALTAR_ARTIFACTS_SLOTS = 22;
|
||||||
constexpr int TOURNAMENT_RULES_DD_MAP_TILES_THRESHOLD = 144*144*2; //map tiles count threshold for 2 dimension door casts with tournament rules
|
constexpr int TOURNAMENT_RULES_DD_MAP_TILES_THRESHOLD = 144*144*2; //map tiles count threshold for 2 dimension door casts with tournament rules
|
||||||
|
constexpr int KINGDOM_WINDOW_HEROES_SLOTS = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_END
|
VCMI_LIB_NAMESPACE_END
|
||||||
|
|||||||
Reference in New Issue
Block a user