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

Merge pull request #502 from vcmi/StatusbarFix

Fix not responding statusbar, issue 3009
This commit is contained in:
Alexander Shishkin 2018-10-30 04:56:34 +03:00 committed by GitHub
commit a3a38a6120
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 65 additions and 56 deletions

View File

@ -1096,7 +1096,7 @@ void CTownInfo::clickRight(tribool down, bool previousState)
} }
CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInstance * from): CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInstance * from):
CWindowObject(PLAYER_COLORED | BORDERED), CStatusbarWindow(PLAYER_COLORED | BORDERED),
town(Town) town(Town)
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
@ -1316,7 +1316,7 @@ void CHallInterface::CBuildingBox::clickRight(tribool down, bool previousState)
} }
CHallInterface::CHallInterface(const CGTownInstance * Town): CHallInterface::CHallInterface(const CGTownInstance * Town):
CWindowObject(PLAYER_COLORED | BORDERED, Town->town->clientInfo.hallBackground), CStatusbarWindow(PLAYER_COLORED | BORDERED, Town->town->clientInfo.hallBackground),
town(Town) town(Town)
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
@ -1365,7 +1365,7 @@ CHallInterface::CHallInterface(const CGTownInstance * Town):
} }
CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Building, int state, bool rightClick): CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Building, int state, bool rightClick):
CWindowObject(PLAYER_COLORED | (rightClick ? RCLICK_POPUP : 0), "TPUBUILD"), CStatusbarWindow(PLAYER_COLORED | (rightClick ? RCLICK_POPUP : 0), "TPUBUILD"),
town(Town), town(Town),
building(Building) building(Building)
{ {
@ -1494,7 +1494,7 @@ void LabeledValue::hover(bool on)
} }
CFortScreen::CFortScreen(const CGTownInstance * town): CFortScreen::CFortScreen(const CGTownInstance * town):
CWindowObject(PLAYER_COLORED | BORDERED, getBgName(town)) CStatusbarWindow(PLAYER_COLORED | BORDERED, getBgName(town))
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
ui32 fortSize = town->creatures.size(); ui32 fortSize = town->creatures.size();
@ -1678,7 +1678,7 @@ void CFortScreen::RecruitArea::clickRight(tribool down, bool previousState)
} }
CMageGuildScreen::CMageGuildScreen(CCastleInterface * owner,std::string imagem) CMageGuildScreen::CMageGuildScreen(CCastleInterface * owner,std::string imagem)
: CWindowObject(BORDERED, imagem) : CStatusbarWindow(BORDERED, imagem)
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
@ -1750,7 +1750,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):
CWindowObject(PLAYER_COLORED, "TPSMITH") CStatusbarWindow(PLAYER_COLORED, "TPSMITH")
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);

View File

@ -195,7 +195,7 @@ public:
}; };
/// Class which manages the castle window /// Class which manages the castle window
class CCastleInterface : public CWindowObject, public CGarrisonHolder class CCastleInterface : public CStatusbarWindow, public CGarrisonHolder
{ {
std::shared_ptr<CLabel> title; std::shared_ptr<CLabel> title;
std::shared_ptr<CLabel> income; std::shared_ptr<CLabel> income;
@ -203,7 +203,6 @@ class CCastleInterface : public CWindowObject, public CGarrisonHolder
std::shared_ptr<CPicture> panel; std::shared_ptr<CPicture> panel;
std::shared_ptr<CResDataBar> resdatabar; std::shared_ptr<CResDataBar> resdatabar;
std::shared_ptr<CGStatusBar> statusbar;
std::shared_ptr<CTownInfo> hall; std::shared_ptr<CTownInfo> hall;
std::shared_ptr<CTownInfo> fort; std::shared_ptr<CTownInfo> fort;
@ -240,7 +239,7 @@ public:
}; };
/// Hall window where you can build things /// Hall window where you can build things
class CHallInterface : public CWindowObject class CHallInterface : public CStatusbarWindow
{ {
class CBuildingBox : public CIntObject class CBuildingBox : public CIntObject
{ {
@ -264,7 +263,6 @@ class CHallInterface : public CWindowObject
std::vector<std::vector<std::shared_ptr<CBuildingBox>>> boxes; std::vector<std::vector<std::shared_ptr<CBuildingBox>>> boxes;
std::shared_ptr<CLabel> title; std::shared_ptr<CLabel> title;
std::shared_ptr<CMinorResDataBar> resdatabar; std::shared_ptr<CMinorResDataBar> resdatabar;
std::shared_ptr<CGStatusBar> statusbar;
std::shared_ptr<CButton> exit; std::shared_ptr<CButton> exit;
public: public:
@ -272,13 +270,12 @@ public:
}; };
/// Window where you can decide to buy a building or not /// Window where you can decide to buy a building or not
class CBuildWindow: public CWindowObject class CBuildWindow: public CStatusbarWindow
{ {
const CGTownInstance * town; const CGTownInstance * town;
const CBuilding * building; const CBuilding * building;
std::shared_ptr<CAnimImage> icon; std::shared_ptr<CAnimImage> icon;
std::shared_ptr<CGStatusBar> statusbar;
std::shared_ptr<CLabel> name; std::shared_ptr<CLabel> name;
std::shared_ptr<CTextBox> description; std::shared_ptr<CTextBox> description;
std::shared_ptr<CTextBox> stateText; std::shared_ptr<CTextBox> stateText;
@ -308,7 +305,7 @@ public:
}; };
/// The fort screen where you can afford units /// The fort screen where you can afford units
class CFortScreen : public CWindowObject class CFortScreen : public CStatusbarWindow
{ {
class RecruitArea : public CIntObject class RecruitArea : public CIntObject
{ {
@ -336,7 +333,6 @@ class CFortScreen : public CWindowObject
std::shared_ptr<CLabel> title; std::shared_ptr<CLabel> title;
std::vector<std::shared_ptr<RecruitArea>> recAreas; std::vector<std::shared_ptr<RecruitArea>> recAreas;
std::shared_ptr<CMinorResDataBar> resdatabar; std::shared_ptr<CMinorResDataBar> resdatabar;
std::shared_ptr<CGStatusBar> statusbar;
std::shared_ptr<CButton> exit; std::shared_ptr<CButton> exit;
std::string getBgName(const CGTownInstance * town); std::string getBgName(const CGTownInstance * town);
@ -348,7 +344,7 @@ public:
}; };
/// The mage guild screen where you can see which spells you have /// The mage guild screen where you can see which spells you have
class CMageGuildScreen : public CWindowObject class CMageGuildScreen : public CStatusbarWindow
{ {
class Scroll : public CIntObject class Scroll : public CIntObject
{ {
@ -367,14 +363,13 @@ class CMageGuildScreen : public CWindowObject
std::vector<std::shared_ptr<CAnimImage>> emptyScrolls; std::vector<std::shared_ptr<CAnimImage>> emptyScrolls;
std::shared_ptr<CMinorResDataBar> resdatabar; std::shared_ptr<CMinorResDataBar> resdatabar;
std::shared_ptr<CGStatusBar> statusbar;
public: public:
CMageGuildScreen(CCastleInterface * owner,std::string image); CMageGuildScreen(CCastleInterface * owner,std::string image);
}; };
/// The blacksmith window where you can buy available in town war machine /// The blacksmith window where you can buy available in town war machine
class CBlacksmithDialog : public CWindowObject class CBlacksmithDialog : public CStatusbarWindow
{ {
std::shared_ptr<CButton> buy; std::shared_ptr<CButton> buy;
std::shared_ptr<CButton> cancel; std::shared_ptr<CButton> cancel;
@ -384,7 +379,6 @@ class CBlacksmithDialog : public CWindowObject
std::shared_ptr<CAnimImage> costIcon; std::shared_ptr<CAnimImage> costIcon;
std::shared_ptr<CLabel> costText; std::shared_ptr<CLabel> costText;
std::shared_ptr<CLabel> costValue; std::shared_ptr<CLabel> costValue;
std::shared_ptr<CGStatusBar> statusbar;
public: public:
CBlacksmithDialog(bool possible, CreatureID creMachineID, ArtifactID aid, ObjectInstanceID hid); CBlacksmithDialog(bool possible, CreatureID creMachineID, ArtifactID aid, ObjectInstanceID hid);

View File

@ -238,3 +238,17 @@ void CWindowObject::clickRight(tribool down, bool previousState)
close(); close();
CCS->curh->show(); CCS->curh->show();
} }
CStatusbarWindow::CStatusbarWindow(int options, std::string imageName, Point centerAt) : CWindowObject(options, imageName, centerAt)
{
}
CStatusbarWindow::CStatusbarWindow(int options, std::string imageName) : CWindowObject(options, imageName)
{
}
void CStatusbarWindow::activate()
{
CIntObject::activate();
GH.statusbar = statusbar;
}

View File

@ -11,6 +11,8 @@
#include "../gui/CIntObject.h" #include "../gui/CIntObject.h"
class CGStatusBar;
class CWindowObject : public WindowBase class CWindowObject : public WindowBase
{ {
std::shared_ptr<CPicture> createBg(std::string imageName, bool playerColored); std::shared_ptr<CPicture> createBg(std::string imageName, bool playerColored);
@ -50,3 +52,13 @@ public:
void showAll(SDL_Surface * to) override; void showAll(SDL_Surface * to) override;
}; };
class CStatusbarWindow : public CWindowObject
{
public:
CStatusbarWindow(int options, std::string imageName, Point centerAt);
CStatusbarWindow(int options, std::string imageName = "");
void activate() override;
protected:
std::shared_ptr<CGStatusBar> statusbar;
};

View File

@ -194,7 +194,7 @@ void CRecruitmentWindow::showAll(SDL_Surface * to)
} }
CRecruitmentWindow::CRecruitmentWindow(const CGDwelling * Dwelling, int Level, const CArmedInstance * Dst, const std::function<void(CreatureID,int)> & Recruit, int y_offset): CRecruitmentWindow::CRecruitmentWindow(const CGDwelling * Dwelling, int Level, const CArmedInstance * Dst, const std::function<void(CreatureID,int)> & Recruit, int y_offset):
CWindowObject(PLAYER_COLORED, "TPRCRT"), CStatusbarWindow(PLAYER_COLORED, "TPRCRT"),
onRecruit(Recruit), onRecruit(Recruit),
level(Level), level(Level),
dst(Dst), dst(Dst),
@ -205,7 +205,7 @@ CRecruitmentWindow::CRecruitmentWindow(const CGDwelling * Dwelling, int Level, c
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
statusBar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26)); statusbar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
slider = std::make_shared<CSlider>(Point(176,279),135,std::bind(&CRecruitmentWindow::sliderMoved,this, _1),0,0,0,true); slider = std::make_shared<CSlider>(Point(176,279),135,std::bind(&CRecruitmentWindow::sliderMoved,this, _1),0,0,0,true);
@ -630,7 +630,7 @@ void CSystemOptionsWindow::closeAndPushEvent(int eventType, int code)
} }
CTavernWindow::CTavernWindow(const CGObjectInstance * TavernObj) CTavernWindow::CTavernWindow(const CGObjectInstance * TavernObj)
: CWindowObject(PLAYER_COLORED, "TPTAVERN"), : CStatusbarWindow(PLAYER_COLORED, "TPTAVERN"),
tavernObj(TavernObj) tavernObj(TavernObj)
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
@ -656,7 +656,7 @@ CTavernWindow::CTavernWindow(const CGObjectInstance * TavernObj)
auto rumorText = boost::str(boost::format(CGI->generaltexth->allTexts[216]) % LOCPLINT->cb->getTavernRumor(tavernObj)); auto rumorText = boost::str(boost::format(CGI->generaltexth->allTexts[216]) % LOCPLINT->cb->getTavernRumor(tavernObj));
rumor = std::make_shared<CTextBox>(rumorText, Rect(32, 190, 330, 68), 0, FONT_SMALL, CENTER, Colors::WHITE); rumor = std::make_shared<CTextBox>(rumorText, Rect(32, 190, 330, 68), 0, FONT_SMALL, CENTER, Colors::WHITE);
statusBar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26)); statusbar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
cancel = std::make_shared<CButton>(Point(310, 428), "ICANCEL.DEF", CButton::tooltip(CGI->generaltexth->tavernInfo[7]), std::bind(&CTavernWindow::close, this), SDLK_ESCAPE); cancel = std::make_shared<CButton>(Point(310, 428), "ICANCEL.DEF", CButton::tooltip(CGI->generaltexth->tavernInfo[7]), std::bind(&CTavernWindow::close, this), SDLK_ESCAPE);
recruit = std::make_shared<CButton>(Point(272, 355), "TPTAV01.DEF", CButton::tooltip(), std::bind(&CTavernWindow::recruitb, this), SDLK_RETURN); recruit = std::make_shared<CButton>(Point(272, 355), "TPTAV01.DEF", CButton::tooltip(), std::bind(&CTavernWindow::recruitb, this), SDLK_RETURN);
thiefGuild = std::make_shared<CButton>(Point(22, 428), "TPTAV02.DEF", CButton::tooltip(CGI->generaltexth->tavernInfo[5]), std::bind(&CTavernWindow::thievesguildb, this), SDLK_t); thiefGuild = std::make_shared<CButton>(Point(22, 428), "TPTAV02.DEF", CButton::tooltip(CGI->generaltexth->tavernInfo[5]), std::bind(&CTavernWindow::thievesguildb, this), SDLK_t);
@ -788,7 +788,7 @@ void CTavernWindow::HeroPortrait::hover(bool on)
} }
CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID queryID) CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID queryID)
: CWindowObject(PLAYER_COLORED | BORDERED, "TRADE2") : CStatusbarWindow(PLAYER_COLORED | BORDERED, "TRADE2")
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
@ -920,7 +920,7 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
questlogButton[1] = std::make_shared<CButton>(Point(740, 44), "hsbtns4.def", CButton::tooltip(CGI->generaltexth->heroscrn[0]), std::bind(&CExchangeWindow::questlog, this, 1)); questlogButton[1] = std::make_shared<CButton>(Point(740, 44), "hsbtns4.def", CButton::tooltip(CGI->generaltexth->heroscrn[0]), std::bind(&CExchangeWindow::questlog, this, 1));
Rect barRect(5, 578, 725, 18); Rect barRect(5, 578, 725, 18);
statusBar = CGStatusBar::create(std::make_shared<CPicture>(*background, barRect, 5, 578, false)); statusbar = CGStatusBar::create(std::make_shared<CPicture>(*background, barRect, 5, 578, false));
//garrison interface //garrison interface
garr = std::make_shared<CGarrisonInt>(69, 131, 4, Point(418,0), heroInst[0], heroInst[1], true, true); garr = std::make_shared<CGarrisonInt>(69, 131, 4, Point(418,0), heroInst[0], heroInst[1], true, true);
@ -978,7 +978,7 @@ void CExchangeWindow::updateWidgets()
} }
CShipyardWindow::CShipyardWindow(const std::vector<si32> & cost, int state, int boatType, const std::function<void()> & onBuy) CShipyardWindow::CShipyardWindow(const std::vector<si32> & cost, int state, int boatType, const std::function<void()> & onBuy)
: CWindowObject(PLAYER_COLORED, "TPSHIP") : CStatusbarWindow(PLAYER_COLORED, "TPSHIP")
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
@ -1013,7 +1013,7 @@ CShipyardWindow::CShipyardWindow(const std::vector<si32> & cost, int state, int
} }
} }
statusBar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26)); statusbar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
title = std::make_shared<CLabel>(164, 27, FONT_BIG, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[13]); title = std::make_shared<CLabel>(164, 27, FONT_BIG, CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[13]);
costLabel = std::make_shared<CLabel>(164, 220, FONT_MEDIUM, CENTER, Colors::WHITE, CGI->generaltexth->jktexts[14]); costLabel = std::make_shared<CLabel>(164, 220, FONT_MEDIUM, CENTER, Colors::WHITE, CGI->generaltexth->jktexts[14]);
@ -1159,7 +1159,7 @@ void CTransformerWindow::updateGarrisons()
} }
CTransformerWindow::CTransformerWindow(const CGHeroInstance * _hero, const CGTownInstance * _town) CTransformerWindow::CTransformerWindow(const CGHeroInstance * _hero, const CGTownInstance * _town)
: CWindowObject(PLAYER_COLORED, "SKTRNBK"), : CStatusbarWindow(PLAYER_COLORED, "SKTRNBK"),
hero(_hero), hero(_hero),
town(_town) town(_town)
{ {
@ -1178,7 +1178,7 @@ CTransformerWindow::CTransformerWindow(const CGHeroInstance * _hero, const CGTow
all = std::make_shared<CButton>(Point(146, 416), "ALTARMY.DEF", CGI->generaltexth->zelp[590], [&](){ addAll(); }, SDLK_a); all = std::make_shared<CButton>(Point(146, 416), "ALTARMY.DEF", CGI->generaltexth->zelp[590], [&](){ addAll(); }, SDLK_a);
convert = std::make_shared<CButton>(Point(269, 416), "ALTSACR.DEF", CGI->generaltexth->zelp[591], [&](){ makeDeal(); }, SDLK_RETURN); convert = std::make_shared<CButton>(Point(269, 416), "ALTSACR.DEF", CGI->generaltexth->zelp[591], [&](){ makeDeal(); }, SDLK_RETURN);
cancel = std::make_shared<CButton>(Point(392, 416), "ICANCEL.DEF", CGI->generaltexth->zelp[592], [&](){ close(); },SDLK_ESCAPE); cancel = std::make_shared<CButton>(Point(392, 416), "ICANCEL.DEF", CGI->generaltexth->zelp[592], [&](){ close(); },SDLK_ESCAPE);
statusBar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26)); statusbar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
titleLeft = std::make_shared<CLabel>(153, 29,FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[485]);//holding area titleLeft = std::make_shared<CLabel>(153, 29,FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[485]);//holding area
titleRight = std::make_shared<CLabel>(153+295, 29, FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[486]);//transformer titleRight = std::make_shared<CLabel>(153+295, 29, FONT_SMALL, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[486]);//transformer
@ -1254,7 +1254,7 @@ void CUniversityWindow::CItem::showAll(SDL_Surface * to)
} }
CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, const IMarket * _market) CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, const IMarket * _market)
: CWindowObject(PLAYER_COLORED, "UNIVERS1"), : CStatusbarWindow(PLAYER_COLORED, "UNIVERS1"),
hero(_hero), hero(_hero),
market(_market) market(_market)
{ {
@ -1283,7 +1283,7 @@ CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, const IMarket
items.push_back(std::make_shared<CItem>(this, goods[i], 54+i*104, 234)); items.push_back(std::make_shared<CItem>(this, goods[i], 54+i*104, 234));
cancel = std::make_shared<CButton>(Point(200, 313), "IOKAY.DEF", CGI->generaltexth->zelp[632], [&](){ close(); }, SDLK_RETURN); cancel = std::make_shared<CButton>(Point(200, 313), "IOKAY.DEF", CGI->generaltexth->zelp[632], [&](){ close(); }, SDLK_RETURN);
statusBar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26)); statusbar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
} }
void CUniversityWindow::makeDeal(int skill) void CUniversityWindow::makeDeal(int skill)
@ -1293,7 +1293,7 @@ void CUniversityWindow::makeDeal(int skill)
CUnivConfirmWindow::CUnivConfirmWindow(CUniversityWindow * owner_, int SKILL, bool available) CUnivConfirmWindow::CUnivConfirmWindow(CUniversityWindow * owner_, int SKILL, bool available)
: CWindowObject(PLAYER_COLORED, "UNIVERS2.PCX"), : CStatusbarWindow(PLAYER_COLORED, "UNIVERS2.PCX"),
owner(owner_) owner(owner_)
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
@ -1324,7 +1324,7 @@ CUnivConfirmWindow::CUnivConfirmWindow(CUniversityWindow * owner_, int SKILL, bo
confirm->block(!available); confirm->block(!available);
cancel = std::make_shared<CButton>(Point(252,299), "ICANCEL.DEF", CGI->generaltexth->zelp[631], [&](){ close(); }, SDLK_ESCAPE); cancel = std::make_shared<CButton>(Point(252,299), "ICANCEL.DEF", CGI->generaltexth->zelp[631], [&](){ close(); }, SDLK_ESCAPE);
statusBar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26)); statusbar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
} }
void CUnivConfirmWindow::makeDeal(int skill) void CUnivConfirmWindow::makeDeal(int skill)
@ -1375,7 +1375,7 @@ void CGarrisonWindow::updateGarrisons()
} }
CHillFortWindow::CHillFortWindow(const CGHeroInstance * visitor, const CGObjectInstance * object) CHillFortWindow::CHillFortWindow(const CGHeroInstance * visitor, const CGObjectInstance * object)
: CWindowObject(PLAYER_COLORED, "APHLFTBK"), : CStatusbarWindow(PLAYER_COLORED, "APHLFTBK"),
fort(object), fort(object),
hero(visitor) hero(visitor)
{ {
@ -1409,7 +1409,7 @@ CHillFortWindow::CHillFortWindow(const CGHeroInstance * visitor, const CGObjectI
upgradeAll->addImage(image); upgradeAll->addImage(image);
quit = std::make_shared<CButton>(Point(294, 275), "IOKAY.DEF", CButton::tooltip(), std::bind(&CHillFortWindow::close, this), SDLK_RETURN); quit = std::make_shared<CButton>(Point(294, 275), "IOKAY.DEF", CButton::tooltip(), std::bind(&CHillFortWindow::close, this), SDLK_RETURN);
statusBar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26)); statusbar = CGStatusBar::create(std::make_shared<CPicture>(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
garr = std::make_shared<CGarrisonInt>(108, 60, 18, Point(), hero, nullptr); garr = std::make_shared<CGarrisonInt>(108, 60, 18, Point(), hero, nullptr);
updateGarrisons(); updateGarrisons();
@ -1579,7 +1579,7 @@ int CHillFortWindow::getState(SlotID slot)
} }
CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner): CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
CWindowObject(PLAYER_COLORED | BORDERED, "TpRank"), CStatusbarWindow(PLAYER_COLORED | BORDERED, "TpRank"),
owner(_owner) owner(_owner)
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
@ -1590,7 +1590,7 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
exitb = std::make_shared<CButton>(Point(748, 556), "TPMAGE1", CButton::tooltip(CGI->generaltexth->allTexts[600]), [&](){ close();}, SDLK_RETURN); exitb = std::make_shared<CButton>(Point(748, 556), "TPMAGE1", CButton::tooltip(CGI->generaltexth->allTexts[600]), [&](){ close();}, SDLK_RETURN);
exitb->assignedKeys.insert(SDLK_ESCAPE); exitb->assignedKeys.insert(SDLK_ESCAPE);
statusBar = CGStatusBar::create(3, 555, "TStatBar.bmp", 742); statusbar = CGStatusBar::create(3, 555, "TStatBar.bmp", 742);
resdatabar = std::make_shared<CMinorResDataBar>(); resdatabar = std::make_shared<CMinorResDataBar>();
resdatabar->moveBy(pos.topLeft(), true); resdatabar->moveBy(pos.topLeft(), true);

View File

@ -38,7 +38,7 @@ class CResDataBar;
class CHeroWithMaybePickedArtifact; class CHeroWithMaybePickedArtifact;
/// Recruitment window where you can recruit creatures /// Recruitment window where you can recruit creatures
class CRecruitmentWindow : public CWindowObject class CRecruitmentWindow : public CStatusbarWindow
{ {
class CCreatureCard : public CIntObject, public std::enable_shared_from_this<CCreatureCard> class CCreatureCard : public CIntObject, public std::enable_shared_from_this<CCreatureCard>
{ {
@ -64,8 +64,6 @@ class CRecruitmentWindow : public CWindowObject
int level; int level;
const CArmedInstance * dst; const CArmedInstance * dst;
std::shared_ptr<CGStatusBar> statusBar;
std::shared_ptr<CCreatureCard> selected; std::shared_ptr<CCreatureCard> selected;
std::vector<std::shared_ptr<CCreatureCard>> cards; std::vector<std::shared_ptr<CCreatureCard>> cards;
@ -235,7 +233,7 @@ public:
CSystemOptionsWindow(); CSystemOptionsWindow();
}; };
class CTavernWindow : public CWindowObject class CTavernWindow : public CStatusbarWindow
{ {
public: public:
class HeroPortrait : public CIntObject class HeroPortrait : public CIntObject
@ -273,7 +271,6 @@ public:
std::shared_ptr<CLabel> title; std::shared_ptr<CLabel> title;
std::shared_ptr<CLabel> cost; std::shared_ptr<CLabel> cost;
std::shared_ptr<CTextBox> rumor; std::shared_ptr<CTextBox> rumor;
std::shared_ptr<CGStatusBar> statusBar;
CTavernWindow(const CGObjectInstance * TavernObj); CTavernWindow(const CGObjectInstance * TavernObj);
~CTavernWindow(); ~CTavernWindow();
@ -283,7 +280,7 @@ public:
void show(SDL_Surface * to) override; void show(SDL_Surface * to) override;
}; };
class CExchangeWindow : public CWindowObject, public CGarrisonHolder, public CWindowWithArtifacts class CExchangeWindow : public CStatusbarWindow, public CGarrisonHolder, public CWindowWithArtifacts
{ {
std::array<std::shared_ptr<CHeroWithMaybePickedArtifact>, 2> herosWArt; std::array<std::shared_ptr<CHeroWithMaybePickedArtifact>, 2> herosWArt;
@ -312,7 +309,6 @@ class CExchangeWindow : public CWindowObject, public CGarrisonHolder, public CWi
std::shared_ptr<CButton> quit; std::shared_ptr<CButton> quit;
std::array<std::shared_ptr<CButton>, 2> questlogButton; std::array<std::shared_ptr<CButton>, 2> questlogButton;
std::shared_ptr<CGStatusBar> statusBar;
std::shared_ptr<CGarrisonInt> garr; std::shared_ptr<CGarrisonInt> garr;
public: public:
@ -330,7 +326,7 @@ public:
}; };
/// Here you can buy ships /// Here you can buy ships
class CShipyardWindow : public CWindowObject class CShipyardWindow : public CStatusbarWindow
{ {
std::shared_ptr<CPicture> bgWater; std::shared_ptr<CPicture> bgWater;
std::shared_ptr<CAnimImage> bgShip; std::shared_ptr<CAnimImage> bgShip;
@ -346,7 +342,6 @@ class CShipyardWindow : public CWindowObject
std::shared_ptr<CButton> build; std::shared_ptr<CButton> build;
std::shared_ptr<CButton> quit; std::shared_ptr<CButton> quit;
std::shared_ptr<CGStatusBar> statusBar;
public: public:
CShipyardWindow(const std::vector<si32> & cost, int state, int boatType, const std::function<void()> & onBuy); CShipyardWindow(const std::vector<si32> & cost, int state, int boatType, const std::function<void()> & onBuy);
}; };
@ -373,7 +368,7 @@ public:
}; };
/// Creature transformer window /// Creature transformer window
class CTransformerWindow : public CWindowObject, public CGarrisonHolder class CTransformerWindow : public CStatusbarWindow, public CGarrisonHolder
{ {
class CItem : public CIntObject class CItem : public CIntObject
{ {
@ -405,7 +400,6 @@ class CTransformerWindow : public CWindowObject, public CGarrisonHolder
std::shared_ptr<CButton> all; std::shared_ptr<CButton> all;
std::shared_ptr<CButton> convert; std::shared_ptr<CButton> convert;
std::shared_ptr<CButton> cancel; std::shared_ptr<CButton> cancel;
std::shared_ptr<CGStatusBar> statusBar;
public: public:
void makeDeal(); void makeDeal();
@ -414,7 +408,7 @@ public:
CTransformerWindow(const CGHeroInstance * _hero, const CGTownInstance * _town); CTransformerWindow(const CGHeroInstance * _hero, const CGTownInstance * _town);
}; };
class CUniversityWindow : public CWindowObject class CUniversityWindow : public CStatusbarWindow
{ {
class CItem : public CIntObject class CItem : public CIntObject
{ {
@ -443,7 +437,6 @@ class CUniversityWindow : public CWindowObject
std::vector<std::shared_ptr<CItem>> items; std::vector<std::shared_ptr<CItem>> items;
std::shared_ptr<CButton> cancel; std::shared_ptr<CButton> cancel;
std::shared_ptr<CGStatusBar> statusBar;
std::shared_ptr<CIntObject> titlePic; std::shared_ptr<CIntObject> titlePic;
std::shared_ptr<CLabel> title; std::shared_ptr<CLabel> title;
std::shared_ptr<CTextBox> clerkSpeech; std::shared_ptr<CTextBox> clerkSpeech;
@ -455,7 +448,7 @@ public:
}; };
/// Confirmation window for University /// Confirmation window for University
class CUnivConfirmWindow : public CWindowObject class CUnivConfirmWindow : public CStatusbarWindow
{ {
std::shared_ptr<CTextBox> clerkSpeech; std::shared_ptr<CTextBox> clerkSpeech;
std::shared_ptr<CLabel> name; std::shared_ptr<CLabel> name;
@ -463,7 +456,6 @@ class CUnivConfirmWindow : public CWindowObject
std::shared_ptr<CAnimImage> icon; std::shared_ptr<CAnimImage> icon;
CUniversityWindow * owner; CUniversityWindow * owner;
std::shared_ptr<CGStatusBar> statusBar;
std::shared_ptr<CButton> confirm; std::shared_ptr<CButton> confirm;
std::shared_ptr<CButton> cancel; std::shared_ptr<CButton> cancel;
@ -494,7 +486,7 @@ public:
}; };
/// Hill fort is the building where you can upgrade units /// Hill fort is the building where you can upgrade units
class CHillFortWindow : public CWindowObject, public CGarrisonHolder class CHillFortWindow : public CStatusbarWindow, public CGarrisonHolder
{ {
private: private:
static const int slotsCount = 7; static const int slotsCount = 7;
@ -522,8 +514,6 @@ private:
std::shared_ptr<CGarrisonInt> garr; std::shared_ptr<CGarrisonInt> garr;
std::shared_ptr<CGStatusBar> statusBar;
std::string getDefForSlot(SlotID slot); std::string getDefForSlot(SlotID slot);
std::string getTextForSlot(SlotID slot); std::string getTextForSlot(SlotID slot);
@ -534,11 +524,10 @@ public:
void updateGarrisons() override;//update buttons after garrison changes void updateGarrisons() override;//update buttons after garrison changes
}; };
class CThievesGuildWindow : public CWindowObject class CThievesGuildWindow : public CStatusbarWindow
{ {
const CGObjectInstance * owner; const CGObjectInstance * owner;
std::shared_ptr<CGStatusBar> statusBar;
std::shared_ptr<CButton> exitb; std::shared_ptr<CButton> exitb;
std::shared_ptr<CMinorResDataBar> resdatabar; std::shared_ptr<CMinorResDataBar> resdatabar;