2009-05-19 21:23:04 +03:00
|
|
|
/*
|
|
|
|
* GUIClasses.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2017-07-13 10:26:03 +02:00
|
|
|
#pragma once
|
|
|
|
|
2022-09-18 14:47:49 +02:00
|
|
|
#include "CWindowObject.h"
|
2017-07-13 10:26:03 +02:00
|
|
|
#include "../lib/GameConstants.h"
|
|
|
|
#include "../lib/ResourceSet.h"
|
|
|
|
#include "../lib/CConfigHandler.h"
|
2023-01-17 22:01:35 +02:00
|
|
|
#include "../lib/int3.h"
|
2017-07-13 10:26:03 +02:00
|
|
|
#include "../widgets/CArtifactHolder.h"
|
|
|
|
#include "../widgets/CGarrisonInt.h"
|
|
|
|
#include "../widgets/Images.h"
|
2009-05-19 21:23:04 +03:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2009-07-26 13:43:22 +03:00
|
|
|
class CGDwelling;
|
2010-05-18 10:01:54 +03:00
|
|
|
class IMarket;
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
|
|
|
class CreatureCostBox;
|
2014-07-13 18:39:45 +03:00
|
|
|
class CCreaturePic;
|
|
|
|
class MoraleLuckBox;
|
|
|
|
class CHeroArea;
|
|
|
|
class CMinorResDataBar;
|
2014-07-15 10:14:49 +03:00
|
|
|
class CSlider;
|
2014-07-13 18:39:45 +03:00
|
|
|
class CComponentBox;
|
2014-07-15 10:14:49 +03:00
|
|
|
class CTextInput;
|
|
|
|
class CListBox;
|
|
|
|
class CLabelGroup;
|
2014-08-03 14:16:19 +03:00
|
|
|
class CToggleButton;
|
|
|
|
class CToggleGroup;
|
2015-08-22 05:05:08 +02:00
|
|
|
class CVolumeSlider;
|
2014-07-15 10:14:49 +03:00
|
|
|
class CGStatusBar;
|
2018-04-07 13:34:11 +02:00
|
|
|
class CTextBox;
|
|
|
|
class CResDataBar;
|
|
|
|
class CHeroWithMaybePickedArtifact;
|
2009-05-19 21:23:04 +03:00
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// Recruitment window where you can recruit creatures
|
2018-10-29 15:12:07 +02:00
|
|
|
class CRecruitmentWindow : public CStatusbarWindow
|
2009-05-19 21:23:04 +03:00
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
class CCreatureCard : public CIntObject, public std::enable_shared_from_this<CCreatureCard>
|
2009-05-19 21:23:04 +03:00
|
|
|
{
|
2012-06-22 14:40:16 +03:00
|
|
|
CRecruitmentWindow * parent;
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CCreaturePic> animation;
|
2012-06-22 14:40:16 +03:00
|
|
|
bool selected;
|
|
|
|
|
|
|
|
public:
|
|
|
|
const CCreature * creature;
|
|
|
|
si32 amount;
|
|
|
|
|
|
|
|
void select(bool on);
|
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
CCreatureCard(CRecruitmentWindow * window, const CCreature * crea, int totalAmount);
|
|
|
|
|
|
|
|
void clickLeft(tribool down, bool previousState) override;
|
|
|
|
void clickRight(tribool down, bool previousState) override;
|
|
|
|
void showAll(SDL_Surface * to) override;
|
2012-06-22 14:40:16 +03:00
|
|
|
};
|
|
|
|
|
2013-06-26 14:18:27 +03:00
|
|
|
std::function<void(CreatureID,int)> onRecruit; //void (int ID, int amount) <-- call to recruit creatures
|
2012-06-22 14:40:16 +03:00
|
|
|
|
2009-07-26 13:43:22 +03:00
|
|
|
int level;
|
2018-04-07 13:34:11 +02:00
|
|
|
const CArmedInstance * dst;
|
|
|
|
|
|
|
|
std::shared_ptr<CCreatureCard> selected;
|
|
|
|
std::vector<std::shared_ptr<CCreatureCard>> cards;
|
|
|
|
|
|
|
|
std::shared_ptr<CSlider> slider;
|
|
|
|
std::shared_ptr<CButton> maxButton;
|
|
|
|
std::shared_ptr<CButton> buyButton;
|
|
|
|
std::shared_ptr<CButton> cancelButton;
|
|
|
|
std::shared_ptr<CLabel> title;
|
|
|
|
std::shared_ptr<CLabel> availableValue;
|
|
|
|
std::shared_ptr<CLabel> toRecruitValue;
|
|
|
|
std::shared_ptr<CLabel> availableTitle;
|
|
|
|
std::shared_ptr<CLabel> toRecruitTitle;
|
|
|
|
std::shared_ptr<CreatureCostBox> costPerTroopValue;
|
|
|
|
std::shared_ptr<CreatureCostBox> totalCostValue;
|
|
|
|
|
|
|
|
void select(std::shared_ptr<CCreatureCard> card);
|
2012-06-22 14:40:16 +03:00
|
|
|
void buy();
|
2009-05-19 21:23:04 +03:00
|
|
|
void sliderMoved(int to);
|
2012-06-22 14:40:16 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
void showAll(SDL_Surface * to) override;
|
2012-06-22 14:40:16 +03:00
|
|
|
public:
|
|
|
|
const CGDwelling * const dwelling;
|
2018-04-07 13:34:11 +02:00
|
|
|
CRecruitmentWindow(const CGDwelling * Dwelling, int Level, const CArmedInstance * Dst, const std::function<void(CreatureID,int)> & Recruit, int y_offset = 0);
|
2012-06-22 14:40:16 +03:00
|
|
|
void availableCreaturesChanged();
|
2009-05-19 21:23:04 +03:00
|
|
|
};
|
|
|
|
|
2013-02-07 20:34:50 +03:00
|
|
|
/// Split window where creatures can be split up into two single unit stacks
|
2012-06-13 16:04:06 +03:00
|
|
|
class CSplitWindow : public CWindowObject
|
2009-05-19 21:23:04 +03:00
|
|
|
{
|
2013-06-26 14:18:27 +03:00
|
|
|
std::function<void(int, int)> callback;
|
2012-06-13 16:04:06 +03:00
|
|
|
int leftAmount;
|
|
|
|
int rightAmount;
|
|
|
|
|
|
|
|
int leftMin;
|
|
|
|
int rightMin;
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CLabel> title;
|
|
|
|
std::shared_ptr<CSlider> slider;
|
|
|
|
std::shared_ptr<CCreaturePic> animLeft;
|
|
|
|
std::shared_ptr<CCreaturePic> animRight;
|
|
|
|
std::shared_ptr<CButton> ok;
|
|
|
|
std::shared_ptr<CButton> cancel;
|
|
|
|
std::shared_ptr<CTextInput> leftInput;
|
|
|
|
std::shared_ptr<CTextInput> rightInput;
|
2012-06-13 16:04:06 +03:00
|
|
|
|
|
|
|
void setAmountText(std::string text, bool left);
|
|
|
|
void setAmount(int value, bool left);
|
|
|
|
void sliderMoved(int value);
|
|
|
|
void apply();
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* creature - displayed creature
|
|
|
|
* callback(leftAmount, rightAmount) - function to call on close
|
|
|
|
* leftMin, rightMin - minimal amount of creatures in each stack
|
|
|
|
* leftAmount, rightAmount - amount of creatures in each stack
|
|
|
|
*/
|
2018-04-07 13:34:11 +02:00
|
|
|
CSplitWindow(const CCreature * creature, std::function<void(int, int)> callback, int leftMin, int rightMin, int leftAmount, int rightAmount);
|
2009-05-19 21:23:04 +03:00
|
|
|
};
|
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
/// Raised up level window where you can select one out of two skills
|
2012-06-15 20:08:19 +03:00
|
|
|
class CLevelWindow : public CWindowObject
|
2009-05-19 21:23:04 +03:00
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CAnimImage> portrait;
|
|
|
|
std::shared_ptr<CButton> ok;
|
|
|
|
std::shared_ptr<CLabel> mainTitle;
|
|
|
|
std::shared_ptr<CLabel> levelTitle;
|
|
|
|
std::shared_ptr<CAnimImage> skillIcon;
|
|
|
|
std::shared_ptr<CLabel> skillValue;
|
|
|
|
|
|
|
|
std::shared_ptr<CComponentBox> box; //skills to select
|
2013-06-26 14:18:27 +03:00
|
|
|
std::function<void(ui32)> cb;
|
2009-05-19 21:23:04 +03:00
|
|
|
|
2012-07-07 16:32:37 +03:00
|
|
|
void selectionChanged(unsigned to);
|
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
public:
|
2017-07-17 23:04:00 +02:00
|
|
|
CLevelWindow(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, std::function<void(ui32)> callback);
|
|
|
|
~CLevelWindow();
|
2009-05-19 21:23:04 +03:00
|
|
|
};
|
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// Town portal, castle gate window
|
2012-06-15 20:08:19 +03:00
|
|
|
class CObjectListWindow : public CWindowObject
|
2010-06-26 13:01:26 +03:00
|
|
|
{
|
2012-01-12 18:23:00 +03:00
|
|
|
class CItem : public CIntObject
|
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
CObjectListWindow * parent;
|
|
|
|
std::shared_ptr<CLabel> text;
|
|
|
|
std::shared_ptr<CPicture> border;
|
2012-01-12 18:23:00 +03:00
|
|
|
public:
|
|
|
|
const size_t index;
|
2018-04-07 13:34:11 +02:00
|
|
|
CItem(CObjectListWindow * parent, size_t id, std::string text);
|
2012-01-12 18:23:00 +03:00
|
|
|
|
|
|
|
void select(bool on);
|
2015-10-12 15:47:10 +02:00
|
|
|
void clickLeft(tribool down, bool previousState) override;
|
2023-01-23 14:43:55 +02:00
|
|
|
void onDoubleClick() override;
|
2012-01-12 18:23:00 +03:00
|
|
|
};
|
2010-06-26 13:01:26 +03:00
|
|
|
|
2013-06-26 14:18:27 +03:00
|
|
|
std::function<void(int)> onSelect;//called when OK button is pressed, returns id of selected item.
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CIntObject> titleWidget;
|
|
|
|
std::shared_ptr<CLabel> title;
|
|
|
|
std::shared_ptr<CLabel> descr;
|
2010-06-26 13:01:26 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CListBox> list;
|
|
|
|
std::shared_ptr<CButton> ok;
|
|
|
|
std::shared_ptr<CButton> exit;
|
2010-06-26 13:01:26 +03:00
|
|
|
|
2012-01-12 18:23:00 +03:00
|
|
|
std::vector< std::pair<int, std::string> > items;//all items present in list
|
2010-06-26 13:01:26 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
void init(std::shared_ptr<CIntObject> titleWidget_, std::string _title, std::string _descr);
|
2017-06-06 06:53:51 +02:00
|
|
|
void exitPressed();
|
2012-01-12 18:23:00 +03:00
|
|
|
public:
|
|
|
|
size_t selected;//index of currently selected item
|
2017-06-06 06:53:51 +02:00
|
|
|
|
|
|
|
std::function<void()> onExit;//optional exit callback
|
|
|
|
|
2010-06-26 13:01:26 +03:00
|
|
|
/// Callback will be called when OK button is pressed, returns id of selected item. initState = initially selected item
|
2013-06-26 14:18:27 +03:00
|
|
|
/// Image can be nullptr
|
2012-01-12 18:23:00 +03:00
|
|
|
///item names will be taken from map objects
|
2022-10-01 09:33:48 +02:00
|
|
|
CObjectListWindow(const std::vector<int> &_items, std::shared_ptr<CIntObject> titleWidget_, std::string _title, std::string _descr, std::function<void(int)> Callback, size_t initialSelection = 0);
|
|
|
|
CObjectListWindow(const std::vector<std::string> &_items, std::shared_ptr<CIntObject> titleWidget_, std::string _title, std::string _descr, std::function<void(int)> Callback, size_t initialSelection = 0);
|
2010-06-26 13:01:26 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CIntObject> genItem(size_t index);
|
2012-01-12 18:23:00 +03:00
|
|
|
void elementSelected();//call callback and close this window
|
|
|
|
void changeSelection(size_t which);
|
2015-10-12 15:47:10 +02:00
|
|
|
void keyPressed (const SDL_KeyboardEvent & key) override;
|
2010-06-26 13:01:26 +03:00
|
|
|
};
|
|
|
|
|
2012-06-15 20:08:19 +03:00
|
|
|
class CSystemOptionsWindow : public CWindowObject
|
2009-05-19 21:23:04 +03:00
|
|
|
{
|
|
|
|
private:
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CLabel> title;
|
|
|
|
std::shared_ptr<CLabelGroup> leftGroup;
|
|
|
|
std::shared_ptr<CLabelGroup> rightGroup;
|
|
|
|
std::shared_ptr<CButton> load;
|
|
|
|
std::shared_ptr<CButton> save;
|
|
|
|
std::shared_ptr<CButton> restart;
|
|
|
|
std::shared_ptr<CButton> mainMenu;
|
|
|
|
std::shared_ptr<CButton> quitGame;
|
|
|
|
std::shared_ptr<CButton> backToMap; //load and restart are not used yet
|
|
|
|
std::shared_ptr<CToggleGroup> heroMoveSpeed;
|
|
|
|
std::shared_ptr<CToggleGroup> enemyMoveSpeed;
|
|
|
|
std::shared_ptr<CToggleGroup> mapScrollSpeed;
|
|
|
|
std::shared_ptr<CVolumeSlider> musicVolume;
|
|
|
|
std::shared_ptr<CVolumeSlider> effectsVolume;
|
|
|
|
|
|
|
|
std::shared_ptr<CToggleButton> showReminder;
|
|
|
|
std::shared_ptr<CToggleButton> quickCombat;
|
|
|
|
std::shared_ptr<CToggleButton> spellbookAnim;
|
|
|
|
std::shared_ptr<CToggleButton> fullscreen;
|
|
|
|
|
|
|
|
std::shared_ptr<CButton> gameResButton;
|
|
|
|
std::shared_ptr<CLabel> gameResLabel;
|
2012-01-12 18:23:00 +03:00
|
|
|
|
2012-09-30 13:35:17 +03:00
|
|
|
SettingsListener onFullscreenChanged;
|
|
|
|
|
2009-05-19 21:23:04 +03:00
|
|
|
//functions bound to buttons
|
2012-04-09 05:53:50 +03:00
|
|
|
void bloadf(); //load game
|
2009-05-19 21:23:04 +03:00
|
|
|
void bsavef(); //save game
|
|
|
|
void bquitf(); //quit game
|
|
|
|
void breturnf(); //return to game
|
2012-04-09 05:53:50 +03:00
|
|
|
void brestartf(); //restart game
|
2009-11-01 03:15:16 +02:00
|
|
|
void bmainmenuf(); //return to main menu
|
|
|
|
|
2012-05-18 20:35:46 +03:00
|
|
|
void selectGameRes();
|
|
|
|
void setGameRes(int index);
|
2012-09-11 17:25:19 +03:00
|
|
|
void closeAndPushEvent(int eventType, int code = 0);
|
2009-05-19 21:23:04 +03:00
|
|
|
|
2012-01-12 18:23:00 +03:00
|
|
|
public:
|
2017-07-17 23:04:00 +02:00
|
|
|
CSystemOptionsWindow();
|
2009-05-19 21:23:04 +03:00
|
|
|
};
|
|
|
|
|
2018-10-29 15:12:07 +02:00
|
|
|
class CTavernWindow : public CStatusbarWindow
|
2009-05-19 21:23:04 +03:00
|
|
|
{
|
|
|
|
public:
|
2009-08-11 19:05:33 +03:00
|
|
|
class HeroPortrait : public CIntObject
|
2009-05-19 21:23:04 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::string hoverName;
|
2014-02-27 00:20:36 +03:00
|
|
|
std::string description; // "XXX is a level Y ZZZ with N artifacts"
|
2018-04-07 13:34:11 +02:00
|
|
|
const CGHeroInstance * h;
|
2010-07-09 02:03:27 +03:00
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
void clickLeft(tribool down, bool previousState) override;
|
|
|
|
void clickRight(tribool down, bool previousState) override;
|
|
|
|
void hover (bool on) override;
|
2018-04-07 13:34:11 +02:00
|
|
|
HeroPortrait(int & sel, int id, int x, int y, const CGHeroInstance * H);
|
2009-05-19 21:23:04 +03:00
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
private:
|
|
|
|
int *_sel;
|
|
|
|
const int _id;
|
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CAnimImage> portrait;
|
|
|
|
};
|
|
|
|
|
|
|
|
//recruitable heroes
|
|
|
|
std::shared_ptr<HeroPortrait> h1;
|
|
|
|
std::shared_ptr<HeroPortrait> h2; //recruitable heroes
|
2010-07-09 02:03:27 +03:00
|
|
|
|
2009-05-19 21:23:04 +03:00
|
|
|
int selected;//0 (left) or 1 (right)
|
2009-05-30 19:17:44 +03:00
|
|
|
int oldSelected;//0 (left) or 1 (right)
|
2009-05-19 21:23:04 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CButton> thiefGuild;
|
|
|
|
std::shared_ptr<CButton> cancel;
|
|
|
|
std::shared_ptr<CButton> recruit;
|
|
|
|
|
|
|
|
const CGObjectInstance * tavernObj;
|
|
|
|
|
|
|
|
std::shared_ptr<CLabel> title;
|
|
|
|
std::shared_ptr<CLabel> cost;
|
|
|
|
std::shared_ptr<CTextBox> rumor;
|
2009-05-19 21:23:04 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
CTavernWindow(const CGObjectInstance * TavernObj);
|
2017-07-17 23:04:00 +02:00
|
|
|
~CTavernWindow();
|
2009-05-19 21:23:04 +03:00
|
|
|
|
|
|
|
void recruitb();
|
2010-01-31 20:41:22 +02:00
|
|
|
void thievesguildb();
|
2015-10-12 15:47:10 +02:00
|
|
|
void show(SDL_Surface * to) override;
|
2009-05-19 21:23:04 +03:00
|
|
|
};
|
|
|
|
|
2021-02-13 22:30:50 +02:00
|
|
|
class CCallback;
|
|
|
|
class CExchangeWindow;
|
|
|
|
|
2021-02-14 17:11:46 +02:00
|
|
|
struct HeroArtifact
|
|
|
|
{
|
|
|
|
const CGHeroInstance * hero;
|
|
|
|
const CArtifactInstance * artifact;
|
|
|
|
ArtifactPosition artPosition;
|
|
|
|
|
|
|
|
HeroArtifact(const CGHeroInstance * hero, const CArtifactInstance * artifact, ArtifactPosition artPosition)
|
|
|
|
:hero(hero), artifact(artifact), artPosition(artPosition)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-02-11 21:06:47 +02:00
|
|
|
class CExchangeController
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
const CGHeroInstance * left;
|
|
|
|
const CGHeroInstance * right;
|
2021-02-13 22:30:50 +02:00
|
|
|
std::shared_ptr<CCallback> cb;
|
|
|
|
CExchangeWindow * view;
|
2021-02-11 21:06:47 +02:00
|
|
|
|
|
|
|
public:
|
2021-02-13 22:30:50 +02:00
|
|
|
CExchangeController(CExchangeWindow * view, ObjectInstanceID hero1, ObjectInstanceID hero2);
|
2021-02-11 21:06:47 +02:00
|
|
|
std::function<void()> onMoveArmyToRight();
|
|
|
|
std::function<void()> onSwapArmy();
|
|
|
|
std::function<void()> onMoveArmyToLeft();
|
2021-02-13 22:30:50 +02:00
|
|
|
std::function<void()> onSwapArtifacts();
|
|
|
|
std::function<void()> onMoveArtifactsToLeft();
|
|
|
|
std::function<void()> onMoveArtifactsToRight();
|
2021-11-28 21:48:22 +02:00
|
|
|
std::function<void()> onMoveStackToLeft(SlotID slotID);
|
|
|
|
std::function<void()> onMoveStackToRight(SlotID slotID);
|
2021-02-13 22:30:50 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
void moveArmy(bool leftToRight);
|
|
|
|
void moveArtifacts(bool leftToRight);
|
|
|
|
void moveArtifact(const CGHeroInstance * source, const CGHeroInstance * target, ArtifactPosition srcPosition);
|
|
|
|
void moveStack(const CGHeroInstance * source, const CGHeroInstance * target, SlotID sourceSlot);
|
2021-02-11 21:06:47 +02:00
|
|
|
};
|
|
|
|
|
2018-10-29 15:12:07 +02:00
|
|
|
class CExchangeWindow : public CStatusbarWindow, public CGarrisonHolder, public CWindowWithArtifacts
|
2009-06-16 14:18:14 +03:00
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
std::array<std::shared_ptr<CHeroWithMaybePickedArtifact>, 2> herosWArt;
|
2009-06-19 15:10:36 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::array<std::shared_ptr<CLabel>, 2> titles;
|
|
|
|
std::vector<std::shared_ptr<CAnimImage>> primSkillImages;//shared for both heroes
|
|
|
|
std::array<std::vector<std::shared_ptr<CLabel>>, 2> primSkillValues;
|
|
|
|
std::array<std::vector<std::shared_ptr<CAnimImage>>, 2> secSkillIcons;
|
|
|
|
std::array<std::shared_ptr<CAnimImage>, 2> specImages;
|
|
|
|
std::array<std::shared_ptr<CAnimImage>, 2> expImages;
|
|
|
|
std::array<std::shared_ptr<CLabel>, 2> expValues;
|
|
|
|
std::array<std::shared_ptr<CAnimImage>, 2> manaImages;
|
|
|
|
std::array<std::shared_ptr<CLabel>, 2> manaValues;
|
|
|
|
std::array<std::shared_ptr<CAnimImage>, 2> portraits;
|
2009-06-16 14:18:14 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::vector<std::shared_ptr<LRClickableAreaWTextComp>> primSkillAreas;
|
|
|
|
std::array<std::vector<std::shared_ptr<LRClickableAreaWTextComp>>, 2> secSkillAreas;
|
2009-06-19 15:10:36 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::array<std::shared_ptr<CHeroArea>, 2> heroAreas;
|
|
|
|
std::array<std::shared_ptr<LRClickableAreaWText>, 2> specialtyAreas;
|
|
|
|
std::array<std::shared_ptr<LRClickableAreaWText>, 2> experienceAreas;
|
|
|
|
std::array<std::shared_ptr<LRClickableAreaWText>, 2> spellPointsAreas;
|
2010-02-01 01:30:47 +02:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::array<std::shared_ptr<MoraleLuckBox>, 2> morale;
|
|
|
|
std::array<std::shared_ptr<MoraleLuckBox>, 2> luck;
|
|
|
|
|
|
|
|
std::shared_ptr<CButton> quit;
|
|
|
|
std::array<std::shared_ptr<CButton>, 2> questlogButton;
|
|
|
|
|
|
|
|
std::shared_ptr<CGarrisonInt> garr;
|
2020-04-01 00:01:57 +02:00
|
|
|
std::shared_ptr<CButton> moveAllGarrButtonLeft;
|
|
|
|
std::shared_ptr<CButton> echangeGarrButton;
|
|
|
|
std::shared_ptr<CButton> moveAllGarrButtonRight;
|
|
|
|
std::shared_ptr<CButton> moveArtifactsButtonLeft;
|
|
|
|
std::shared_ptr<CButton> echangeArtifactsButton;
|
|
|
|
std::shared_ptr<CButton> moveArtifactsButtonRight;
|
2021-11-28 21:48:22 +02:00
|
|
|
std::vector<std::shared_ptr<CButton>> moveStackLeftButtons;
|
|
|
|
std::vector<std::shared_ptr<CButton>> moveStackRightButtons;
|
2021-02-11 21:06:47 +02:00
|
|
|
CExchangeController controller;
|
2009-06-26 18:41:19 +03:00
|
|
|
|
2009-06-19 15:10:36 +03:00
|
|
|
public:
|
2018-04-07 13:34:11 +02:00
|
|
|
std::array<const CGHeroInstance *, 2> heroInst;
|
|
|
|
std::array<std::shared_ptr<CArtifactsOfHero>, 2> artifs;
|
2009-06-16 14:18:14 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
void updateGarrisons() override;
|
2009-06-28 16:49:39 +03:00
|
|
|
|
2009-06-19 15:10:36 +03:00
|
|
|
void questlog(int whichHero); //questlog button callback; whichHero: 0 - left, 1 - right
|
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
void updateWidgets();
|
2009-06-28 16:49:39 +03:00
|
|
|
|
2021-11-28 21:48:22 +02:00
|
|
|
const CGarrisonSlot * getSelectedSlotID() const;
|
|
|
|
|
2017-07-17 23:04:00 +02:00
|
|
|
CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID queryID);
|
2009-06-16 14:18:14 +03:00
|
|
|
};
|
2009-05-19 21:23:04 +03:00
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// Here you can buy ships
|
2018-10-29 15:12:07 +02:00
|
|
|
class CShipyardWindow : public CStatusbarWindow
|
2009-07-26 06:33:13 +03:00
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CPicture> bgWater;
|
|
|
|
std::shared_ptr<CAnimImage> bgShip;
|
2011-09-23 18:58:18 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CLabel> title;
|
|
|
|
std::shared_ptr<CLabel> costLabel;
|
2011-09-23 18:58:18 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CAnimImage> woodPic;
|
|
|
|
std::shared_ptr<CAnimImage> goldPic;
|
|
|
|
std::shared_ptr<CLabel> woodCost;
|
|
|
|
std::shared_ptr<CLabel> goldCost;
|
2011-09-23 18:58:18 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CButton> build;
|
|
|
|
std::shared_ptr<CButton> quit;
|
2009-07-26 06:33:13 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
public:
|
|
|
|
CShipyardWindow(const std::vector<si32> & cost, int state, int boatType, const std::function<void()> & onBuy);
|
2009-07-26 06:33:13 +03:00
|
|
|
};
|
2009-05-19 21:23:04 +03:00
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// Puzzle screen which gets uncovered when you visit obilisks
|
2012-06-15 20:08:19 +03:00
|
|
|
class CPuzzleWindow : public CWindowObject
|
2009-08-31 18:57:15 +03:00
|
|
|
{
|
|
|
|
private:
|
2012-06-15 20:08:19 +03:00
|
|
|
int3 grailPos;
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CPicture> logo;
|
|
|
|
std::shared_ptr<CLabel> title;
|
|
|
|
std::shared_ptr<CButton> quitb;
|
|
|
|
std::shared_ptr<CResDataBar> resDataBar;
|
2012-06-15 20:08:19 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::vector<std::shared_ptr<CPicture>> piecesToRemove;
|
|
|
|
std::vector<std::shared_ptr<CPicture>> visiblePieces;
|
2012-06-15 20:08:19 +03:00
|
|
|
ui8 currentAlpha;
|
2009-08-31 18:57:15 +03:00
|
|
|
|
|
|
|
public:
|
2015-10-12 15:47:10 +02:00
|
|
|
void showAll(SDL_Surface * to) override;
|
|
|
|
void show(SDL_Surface * to) override;
|
2009-08-31 18:57:15 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
CPuzzleWindow(const int3 & grailPos, double discoveredRatio);
|
2009-08-31 18:57:15 +03:00
|
|
|
};
|
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// Creature transformer window
|
2018-10-29 15:12:07 +02:00
|
|
|
class CTransformerWindow : public CStatusbarWindow, public CGarrisonHolder
|
2010-07-03 15:00:53 +03:00
|
|
|
{
|
|
|
|
class CItem : public CIntObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int id;//position of creature in hero army
|
|
|
|
bool left;//position of the item
|
|
|
|
int size; //size of creature stack
|
|
|
|
CTransformerWindow * parent;
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CAnimImage> icon;
|
|
|
|
std::shared_ptr<CLabel> count;
|
2010-07-03 15:00:53 +03:00
|
|
|
|
|
|
|
void move();
|
2015-10-12 15:47:10 +02:00
|
|
|
void clickLeft(tribool down, bool previousState) override;
|
2012-06-17 01:40:28 +03:00
|
|
|
void update();
|
2012-09-26 16:13:39 +03:00
|
|
|
CItem(CTransformerWindow * parent, int size, int id);
|
2010-07-03 15:00:53 +03:00
|
|
|
};
|
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
const CArmedInstance * army;//object with army for transforming (hero or town)
|
|
|
|
const CGHeroInstance * hero;//only if we have hero in town
|
|
|
|
const CGTownInstance * town;//market, town garrison is used if hero == nullptr
|
|
|
|
|
|
|
|
std::shared_ptr<CLabel> titleLeft;
|
|
|
|
std::shared_ptr<CLabel> titleRight;
|
|
|
|
std::shared_ptr<CTextBox> helpLeft;
|
|
|
|
std::shared_ptr<CTextBox> helpRight;
|
|
|
|
|
|
|
|
std::vector<std::shared_ptr<CItem>> items;
|
|
|
|
|
|
|
|
std::shared_ptr<CButton> all;
|
|
|
|
std::shared_ptr<CButton> convert;
|
|
|
|
std::shared_ptr<CButton> cancel;
|
|
|
|
public:
|
2010-07-03 15:00:53 +03:00
|
|
|
|
|
|
|
void makeDeal();
|
|
|
|
void addAll();
|
2015-10-12 15:47:10 +02:00
|
|
|
void updateGarrisons() override;
|
2017-07-17 23:04:00 +02:00
|
|
|
CTransformerWindow(const CGHeroInstance * _hero, const CGTownInstance * _town);
|
2010-07-03 15:00:53 +03:00
|
|
|
};
|
|
|
|
|
2018-10-29 15:12:07 +02:00
|
|
|
class CUniversityWindow : public CStatusbarWindow
|
2010-07-20 17:08:13 +03:00
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
class CItem : public CIntObject
|
2010-07-20 17:08:13 +03:00
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CAnimImage> icon;
|
|
|
|
std::shared_ptr<CAnimImage> topBar;
|
|
|
|
std::shared_ptr<CAnimImage> bottomBar;
|
|
|
|
std::shared_ptr<CLabel> name;
|
|
|
|
std::shared_ptr<CLabel> level;
|
2010-07-20 17:08:13 +03:00
|
|
|
public:
|
|
|
|
int ID;//id of selected skill
|
|
|
|
CUniversityWindow * parent;
|
2010-11-15 17:15:00 +02:00
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
void showAll(SDL_Surface * to) override;
|
|
|
|
void clickLeft(tribool down, bool previousState) override;
|
|
|
|
void clickRight(tribool down, bool previousState) override;
|
|
|
|
void hover(bool on) override;
|
2010-07-20 17:08:13 +03:00
|
|
|
int state();//0=can't learn, 1=learned, 2=can learn
|
|
|
|
CItem(CUniversityWindow * _parent, int _ID, int X, int Y);
|
|
|
|
};
|
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
const CGHeroInstance * hero;
|
2010-07-20 17:08:13 +03:00
|
|
|
const IMarket * market;
|
2010-11-15 17:15:00 +02:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CAnimation> bars;
|
2010-07-20 17:08:13 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::vector<std::shared_ptr<CItem>> items;
|
2010-11-15 17:15:00 +02:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CButton> cancel;
|
|
|
|
std::shared_ptr<CIntObject> titlePic;
|
|
|
|
std::shared_ptr<CLabel> title;
|
|
|
|
std::shared_ptr<CTextBox> clerkSpeech;
|
|
|
|
|
|
|
|
public:
|
2017-07-17 23:04:00 +02:00
|
|
|
CUniversityWindow(const CGHeroInstance * _hero, const IMarket * _market);
|
2018-04-07 13:34:11 +02:00
|
|
|
|
|
|
|
void makeDeal(int skill);
|
2010-07-20 17:08:13 +03:00
|
|
|
};
|
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// Confirmation window for University
|
2018-10-29 15:12:07 +02:00
|
|
|
class CUnivConfirmWindow : public CStatusbarWindow
|
2010-07-20 17:08:13 +03:00
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CTextBox> clerkSpeech;
|
|
|
|
std::shared_ptr<CLabel> name;
|
|
|
|
std::shared_ptr<CLabel> level;
|
|
|
|
std::shared_ptr<CAnimImage> icon;
|
|
|
|
|
|
|
|
CUniversityWindow * owner;
|
|
|
|
std::shared_ptr<CButton> confirm;
|
|
|
|
std::shared_ptr<CButton> cancel;
|
|
|
|
|
|
|
|
std::shared_ptr<CAnimImage> costIcon;
|
|
|
|
std::shared_ptr<CLabel> cost;
|
2010-07-20 17:08:13 +03:00
|
|
|
|
|
|
|
void makeDeal(int skill);
|
2018-04-07 13:34:11 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
CUnivConfirmWindow(CUniversityWindow * PARENT, int SKILL, bool available);
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Garrison window where you can take creatures out of the hero to place it on the garrison
|
|
|
|
class CGarrisonWindow : public CWindowObject, public CGarrisonHolder
|
|
|
|
{
|
|
|
|
std::shared_ptr<CLabel> title;
|
|
|
|
std::shared_ptr<CAnimImage> banner;
|
|
|
|
std::shared_ptr<CAnimImage> portrait;
|
|
|
|
|
|
|
|
std::shared_ptr<CGarrisonInt> garr;
|
|
|
|
|
|
|
|
public:
|
|
|
|
std::shared_ptr<CButton> quit;
|
|
|
|
|
|
|
|
CGarrisonWindow(const CArmedInstance * up, const CGHeroInstance * down, bool removableUnits);
|
|
|
|
|
|
|
|
void updateGarrisons() override;
|
2010-07-20 17:08:13 +03:00
|
|
|
};
|
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// Hill fort is the building where you can upgrade units
|
2018-10-29 15:12:07 +02:00
|
|
|
class CHillFortWindow : public CStatusbarWindow, public CGarrisonHolder
|
2010-07-22 03:32:45 +03:00
|
|
|
{
|
2016-10-16 06:51:07 +02:00
|
|
|
private:
|
|
|
|
static const int slotsCount = 7;
|
|
|
|
//todo: mithril support
|
|
|
|
static const int resCount = 7;
|
2010-07-22 03:32:45 +03:00
|
|
|
|
|
|
|
const CGObjectInstance * fort;
|
|
|
|
const CGHeroInstance * hero;
|
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CLabel> title;
|
|
|
|
std::shared_ptr<CHeroArea> heroPic;
|
|
|
|
|
|
|
|
std::array<std::shared_ptr<CAnimImage>, resCount> totalIcons;
|
|
|
|
std::array<std::shared_ptr<CLabel>, resCount> totalLabels;
|
2016-10-16 06:51:07 +02:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::array<std::shared_ptr<CButton>, slotsCount> upgrade;//upgrade single creature
|
2016-10-16 06:51:07 +02:00
|
|
|
std::array<int, slotsCount + 1> currState;//current state of slot - to avoid calls to getState or updating buttons
|
|
|
|
|
|
|
|
//there is a place for only 2 resources per slot
|
2018-04-07 13:34:11 +02:00
|
|
|
std::array< std::array<std::shared_ptr<CAnimImage>, 2>, slotsCount> slotIcons;
|
|
|
|
std::array< std::array<std::shared_ptr<CLabel>, 2>, slotsCount> slotLabels;
|
|
|
|
|
|
|
|
std::shared_ptr<CButton> upgradeAll;
|
|
|
|
std::shared_ptr<CButton> quit;
|
|
|
|
|
|
|
|
std::shared_ptr<CGarrisonInt> garr;
|
2016-10-16 06:51:07 +02:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::string getDefForSlot(SlotID slot);
|
|
|
|
std::string getTextForSlot(SlotID slot);
|
2010-11-15 17:15:00 +02:00
|
|
|
|
2013-02-16 17:03:47 +03:00
|
|
|
void makeDeal(SlotID slot);//-1 for upgrading all creatures
|
|
|
|
int getState(SlotID slot); //-1 = no creature 0=can't upgrade, 1=upgraded, 2=can upgrade
|
2016-10-16 06:51:07 +02:00
|
|
|
public:
|
2017-07-17 23:04:00 +02:00
|
|
|
CHillFortWindow(const CGHeroInstance * visitor, const CGObjectInstance * object);
|
2015-10-12 15:47:10 +02:00
|
|
|
void updateGarrisons() override;//update buttons after garrison changes
|
2010-07-22 03:32:45 +03:00
|
|
|
};
|
|
|
|
|
2018-10-29 15:12:07 +02:00
|
|
|
class CThievesGuildWindow : public CStatusbarWindow
|
2010-01-31 20:41:22 +02:00
|
|
|
{
|
2010-02-01 19:51:33 +02:00
|
|
|
const CGObjectInstance * owner;
|
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CButton> exitb;
|
|
|
|
std::shared_ptr<CMinorResDataBar> resdatabar;
|
|
|
|
|
|
|
|
std::vector<std::shared_ptr<CLabel>> rowHeaders;
|
|
|
|
std::vector<std::shared_ptr<CAnimImage>> columnBackgrounds;
|
|
|
|
std::vector<std::shared_ptr<CLabel>> columnHeaders;
|
|
|
|
std::vector<std::shared_ptr<CAnimImage>> cells;
|
|
|
|
|
|
|
|
std::vector<std::shared_ptr<CPicture>> banners;
|
|
|
|
std::vector<std::shared_ptr<CAnimImage>> bestHeroes;
|
|
|
|
std::vector<std::shared_ptr<CTextBox>> primSkillHeaders;
|
|
|
|
std::vector<std::shared_ptr<CLabel>> primSkillValues;
|
|
|
|
std::vector<std::shared_ptr<CAnimImage>> bestCreatures;
|
|
|
|
std::vector<std::shared_ptr<CLabel>> personalities;
|
2010-01-31 20:41:22 +02:00
|
|
|
public:
|
2010-02-01 19:51:33 +02:00
|
|
|
CThievesGuildWindow(const CGObjectInstance * _owner);
|
2010-01-31 20:41:22 +02:00
|
|
|
};
|
2018-04-07 13:34:11 +02:00
|
|
|
|