mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
* battle options window works again
* reorganization of GUI code
This commit is contained in:
parent
199be7b06e
commit
35f7281024
@ -1,3 +1,4 @@
|
|||||||
|
#include "AdventureMapButton.h"
|
||||||
#include "CAdvmapInterface.h"
|
#include "CAdvmapInterface.h"
|
||||||
#include "SDL_Extensions.h"
|
#include "SDL_Extensions.h"
|
||||||
#include "hch/CDefHandler.h"
|
#include "hch/CDefHandler.h"
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
#ifndef __ADVENTUREMAPBUTTON_H__
|
#ifndef __ADVENTUREMAPBUTTON_H__
|
||||||
#define __ADVENTUREMAPBUTTON_H__
|
#define __ADVENTUREMAPBUTTON_H__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "CPlayerInterface.h"
|
|
||||||
#include "client/FunctionList.h"
|
#include "client/FunctionList.h"
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
#include "client/GUIClasses.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* AdventureMapButton.h, part of VCMI engine
|
* AdventureMapButton.h, part of VCMI engine
|
||||||
@ -30,8 +28,8 @@ public:
|
|||||||
actOnDown; //runs when mouse is pressed down over it, not when up
|
actOnDown; //runs when mouse is pressed down over it, not when up
|
||||||
ui8 blocked;
|
ui8 blocked;
|
||||||
|
|
||||||
void clickRight (tribool down);
|
void clickRight (boost::logic::tribool down);
|
||||||
virtual void clickLeft (tribool down);
|
virtual void clickLeft (boost::logic::tribool down);
|
||||||
void hover (bool on);
|
void hover (bool on);
|
||||||
void block(ui8 on); //if button is blocked then it'll change it's graphic to inactive (offset==2) and won't react on l-clicks
|
void block(ui8 on); //if button is blocked then it'll change it's graphic to inactive (offset==2) and won't react on l-clicks
|
||||||
void activate(); // makes button active
|
void activate(); // makes button active
|
||||||
@ -55,7 +53,7 @@ public:
|
|||||||
bool selected, onlyOn;
|
bool selected, onlyOn;
|
||||||
CFunctionList<void()> callback2; //when disselecting
|
CFunctionList<void()> callback2; //when disselecting
|
||||||
void select(bool on);
|
void select(bool on);
|
||||||
void clickLeft (tribool down);
|
void clickLeft (boost::logic::tribool down);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CHighlightableButtonsGroup
|
class CHighlightableButtonsGroup
|
||||||
@ -96,7 +94,7 @@ public:
|
|||||||
|
|
||||||
void sliderClicked();
|
void sliderClicked();
|
||||||
void moveLeft();
|
void moveLeft();
|
||||||
void clickLeft (tribool down);
|
void clickLeft (boost::logic::tribool down);
|
||||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent);
|
void mouseMoved (const SDL_MouseMotionEvent & sEvent);
|
||||||
void moveRight();
|
void moveRight();
|
||||||
void moveTo(int to);
|
void moveTo(int to);
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include "CGameInfo.h"
|
#include "CGameInfo.h"
|
||||||
#include "CHeroWindow.h"
|
#include "CHeroWindow.h"
|
||||||
#include "CMessage.h"
|
#include "CMessage.h"
|
||||||
#include "CPlayerInterface.h"
|
|
||||||
#include "SDL_Extensions.h"
|
#include "SDL_Extensions.h"
|
||||||
#include "client/CBitmapHandler.h"
|
#include "client/CBitmapHandler.h"
|
||||||
#include "client/CConfigHandler.h"
|
#include "client/CConfigHandler.h"
|
||||||
@ -17,7 +16,6 @@
|
|||||||
#include "hch/CHeroHandler.h"
|
#include "hch/CHeroHandler.h"
|
||||||
#include "hch/CObjectHandler.h"
|
#include "hch/CObjectHandler.h"
|
||||||
#include "hch/CTownHandler.h"
|
#include "hch/CTownHandler.h"
|
||||||
#include "lib/CondSh.h"
|
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "mapHandler.h"
|
#include "mapHandler.h"
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#include "CPlayerInterface.h"
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "AdventureMapButton.h"
|
#include "AdventureMapButton.h"
|
||||||
class CDefHandler;
|
class CDefHandler;
|
||||||
@ -42,8 +41,8 @@ public:
|
|||||||
void redraw(int level=-1);// (level==-1) => redraw all levels
|
void redraw(int level=-1);// (level==-1) => redraw all levels
|
||||||
void updateRadar();
|
void updateRadar();
|
||||||
|
|
||||||
void clickRight (tribool down);
|
void clickRight (boost::logic::tribool down);
|
||||||
void clickLeft (tribool down);
|
void clickLeft (boost::logic::tribool down);
|
||||||
void hover (bool on);
|
void hover (bool on);
|
||||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent);
|
void mouseMoved (const SDL_MouseMotionEvent & sEvent);
|
||||||
void activate(); // makes button active
|
void activate(); // makes button active
|
||||||
@ -65,8 +64,8 @@ public:
|
|||||||
CPath * currentPath;
|
CPath * currentPath;
|
||||||
void activate();
|
void activate();
|
||||||
void deactivate();
|
void deactivate();
|
||||||
void clickLeft(tribool down);
|
void clickLeft(boost::logic::tribool down);
|
||||||
void clickRight(tribool down);
|
void clickRight(boost::logic::tribool down);
|
||||||
void hover(bool on);
|
void hover(bool on);
|
||||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent);
|
void mouseMoved (const SDL_MouseMotionEvent & sEvent);
|
||||||
void show(SDL_Surface * to);
|
void show(SDL_Surface * to);
|
||||||
@ -82,7 +81,7 @@ public:
|
|||||||
std::vector<std::pair<int,int> > txtpos;
|
std::vector<std::pair<int,int> > txtpos;
|
||||||
std::string datetext;
|
std::string datetext;
|
||||||
|
|
||||||
void clickRight (tribool down);
|
void clickRight (boost::logic::tribool down);
|
||||||
void activate();
|
void activate();
|
||||||
void deactivate();
|
void deactivate();
|
||||||
CResDataBar();
|
CResDataBar();
|
||||||
@ -180,7 +179,7 @@ public:
|
|||||||
void selectionChanged();
|
void selectionChanged();
|
||||||
void centerOn(int3 on);
|
void centerOn(int3 on);
|
||||||
int3 verifyPos(int3 ver);
|
int3 verifyPos(int3 ver);
|
||||||
void handleRightClick(std::string text, tribool down, CIntObject * client);
|
void handleRightClick(std::string text, boost::logic::tribool down, CIntObject * client);
|
||||||
void keyPressed(const SDL_KeyboardEvent & key);
|
void keyPressed(const SDL_KeyboardEvent & key);
|
||||||
|
|
||||||
|
|
||||||
|
@ -985,12 +985,10 @@ void CBattleInterface::handleStartMoving(int number)
|
|||||||
void CBattleInterface::bOptionsf()
|
void CBattleInterface::bOptionsf()
|
||||||
{
|
{
|
||||||
CGI->curh->changeGraphic(0,0);
|
CGI->curh->changeGraphic(0,0);
|
||||||
deactivate();
|
|
||||||
|
|
||||||
SDL_Rect temp_rect = genRect(431, 481, 160, 84);
|
SDL_Rect temp_rect = genRect(431, 481, 160, 84);
|
||||||
CBattleOptionsWindow * optionsWin = new CBattleOptionsWindow(temp_rect, this);
|
CBattleOptionsWindow * optionsWin = new CBattleOptionsWindow(temp_rect, this);
|
||||||
optionsWin->activate();
|
LOCPLINT->pushInt(optionsWin);
|
||||||
LOCPLINT->objsToBlit.push_back(optionsWin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBattleInterface::bSurrenderf()
|
void CBattleInterface::bSurrenderf()
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "CPlayerInterface.h"
|
#include "CPlayerInterface.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include "client/GUIClasses.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CBattleInterface.h, part of VCMI engine
|
* CBattleInterface.h, part of VCMI engine
|
||||||
|
@ -1,18 +1,14 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "CAdvmapInterface.h"
|
|
||||||
#include "CCallback.h"
|
#include "CCallback.h"
|
||||||
#include "CGameInfo.h"
|
#include "CGameInfo.h"
|
||||||
#include "CGameState.h"
|
#include "CGameState.h"
|
||||||
#include "CPlayerInterface.h"
|
#include "CPlayerInterface.h"
|
||||||
#include "CPlayerInterface.h"
|
|
||||||
#include "client/Client.h"
|
#include "client/Client.h"
|
||||||
#include "hch/CAmbarCendamo.h"
|
#include "map.h"
|
||||||
#include "hch/CBuildingHandler.h"
|
#include "hch/CBuildingHandler.h"
|
||||||
#include "hch/CDefObjInfoHandler.h"
|
#include "hch/CDefObjInfoHandler.h"
|
||||||
#include "hch/CGeneralTextHandler.h"
|
|
||||||
#include "hch/CHeroHandler.h"
|
#include "hch/CHeroHandler.h"
|
||||||
#include "hch/CObjectHandler.h"
|
#include "hch/CObjectHandler.h"
|
||||||
#include "hch/CTownHandler.h"
|
|
||||||
#include "lib/Connection.h"
|
#include "lib/Connection.h"
|
||||||
#include "lib/NetPacks.h"
|
#include "lib/NetPacks.h"
|
||||||
#include "mapHandler.h"
|
#include "mapHandler.h"
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include "CPlayerInterface.h"
|
#include "client/GUIClasses.h"
|
||||||
|
#include "hch/CMusicBase.h"
|
||||||
//#include "boost/tuple/tuple.hpp"
|
//#include "boost/tuple/tuple.hpp"
|
||||||
class CGTownInstance;
|
class CGTownInstance;
|
||||||
class CTownHandler;
|
class CTownHandler;
|
||||||
@ -40,8 +41,8 @@ public:
|
|||||||
void deactivate();
|
void deactivate();
|
||||||
bool operator<(const CBuildingRect & p2) const;
|
bool operator<(const CBuildingRect & p2) const;
|
||||||
void hover(bool on);
|
void hover(bool on);
|
||||||
void clickLeft (tribool down);
|
void clickLeft (boost::logic::tribool down);
|
||||||
void clickRight (tribool down);
|
void clickRight (boost::logic::tribool down);
|
||||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent);
|
void mouseMoved (const SDL_MouseMotionEvent & sEvent);
|
||||||
};
|
};
|
||||||
class CHeroGSlot : public ClickableL, public ClickableR, public Hoverable
|
class CHeroGSlot : public ClickableL, public ClickableR, public Hoverable
|
||||||
@ -119,8 +120,8 @@ public:
|
|||||||
int state;// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
|
int state;// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
|
||||||
//(-1) - forbidden in this town, 0 - possible, 1 - lack of res, 2 - requirements/buildings per turn limit, (3) - already exists
|
//(-1) - forbidden in this town, 0 - possible, 1 - lack of res, 2 - requirements/buildings per turn limit, (3) - already exists
|
||||||
void hover(bool on);
|
void hover(bool on);
|
||||||
void clickLeft (tribool down);
|
void clickLeft (boost::logic::tribool down);
|
||||||
void clickRight (tribool down);
|
void clickRight (boost::logic::tribool down);
|
||||||
void show(SDL_Surface * to);
|
void show(SDL_Surface * to);
|
||||||
void activate();
|
void activate();
|
||||||
void deactivate();
|
void deactivate();
|
||||||
@ -140,7 +141,7 @@ public:
|
|||||||
void activate();
|
void activate();
|
||||||
void deactivate();
|
void deactivate();
|
||||||
std::string getTextForState(int state);
|
std::string getTextForState(int state);
|
||||||
void clickRight (tribool down);
|
void clickRight (boost::logic::tribool down);
|
||||||
void show(SDL_Surface * to);
|
void show(SDL_Surface * to);
|
||||||
void Buy();
|
void Buy();
|
||||||
void close();
|
void close();
|
||||||
@ -170,8 +171,8 @@ class CFortScreen : public IShowActivable, public CIntObject
|
|||||||
public:
|
public:
|
||||||
int bid;
|
int bid;
|
||||||
RecArea(int BID):bid(BID){}; //c-tor
|
RecArea(int BID):bid(BID){}; //c-tor
|
||||||
void clickLeft (tribool down);
|
void clickLeft (boost::logic::tribool down);
|
||||||
void clickRight (tribool down);
|
void clickRight (boost::logic::tribool down);
|
||||||
void activate();
|
void activate();
|
||||||
void deactivate();
|
void deactivate();
|
||||||
};
|
};
|
||||||
@ -202,8 +203,8 @@ public:
|
|||||||
CSpell *spell;
|
CSpell *spell;
|
||||||
|
|
||||||
Scroll(CSpell *Spell):spell(Spell){};
|
Scroll(CSpell *Spell):spell(Spell){};
|
||||||
void clickLeft (tribool down);
|
void clickLeft (boost::logic::tribool down);
|
||||||
void clickRight (tribool down);
|
void clickRight (boost::logic::tribool down);
|
||||||
void hover(bool on);
|
void hover(bool on);
|
||||||
void activate();
|
void activate();
|
||||||
void deactivate();
|
void deactivate();
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
#include "hch/CLodHandler.h"
|
#include "hch/CLodHandler.h"
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
#include "CPlayerInterface.h"
|
|
||||||
#include "hch/CDefHandler.h"
|
#include "hch/CDefHandler.h"
|
||||||
#include "CGameInfo.h"
|
#include "CGameInfo.h"
|
||||||
#include "SDL_Extensions.h"
|
#include "SDL_Extensions.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "hch/CGeneralTextHandler.h"
|
#include "hch/CGeneralTextHandler.h"
|
||||||
#include "client/Graphics.h"
|
#include "client/Graphics.h"
|
||||||
#include "CAdvmapInterface.h"
|
#include "client/GUIClasses.h"
|
||||||
|
#include "AdventureMapButton.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CMessage.cpp, part of VCMI engine
|
* CMessage.cpp, part of VCMI engine
|
||||||
|
3290
CPlayerInterface.cpp
3290
CPlayerInterface.cpp
File diff suppressed because it is too large
Load Diff
@ -52,6 +52,18 @@ struct UpgradeInfo;
|
|||||||
template <typename T> struct CondSh;
|
template <typename T> struct CondSh;
|
||||||
class CInGameConsole;
|
class CInGameConsole;
|
||||||
class CGarrisonInt;
|
class CGarrisonInt;
|
||||||
|
class CInGameConsole;
|
||||||
|
union SDL_Event;
|
||||||
|
class IStatusBar;
|
||||||
|
class CInfoWindow;
|
||||||
|
class IShowActivable;
|
||||||
|
class ClickableL;
|
||||||
|
class ClickableR;
|
||||||
|
class Hoverable;
|
||||||
|
class KeyInterested;
|
||||||
|
class MotionInterested;
|
||||||
|
class TimeInterested;
|
||||||
|
class IShowable;
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
@ -59,482 +71,6 @@ namespace boost
|
|||||||
class recursive_mutex;
|
class recursive_mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Point
|
|
||||||
{
|
|
||||||
int x, y;
|
|
||||||
|
|
||||||
//constructors
|
|
||||||
Point(){};
|
|
||||||
Point(int X, int Y)
|
|
||||||
:x(X),y(Y)
|
|
||||||
{};
|
|
||||||
Point(const int3 &a)
|
|
||||||
:x(a.x),y(a.y)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Point operator+(const Point &b) const
|
|
||||||
{
|
|
||||||
return Point(x+b.x,y+b.y);
|
|
||||||
}
|
|
||||||
Point& operator+=(const Point &b)
|
|
||||||
{
|
|
||||||
x += b.x;
|
|
||||||
y += b.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
Point operator-(const Point &b) const
|
|
||||||
{
|
|
||||||
return Point(x+b.x,y+b.y);
|
|
||||||
}
|
|
||||||
Point& operator-=(const Point &b)
|
|
||||||
{
|
|
||||||
x -= b.x;
|
|
||||||
y -= b.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
bool operator<(const Point &b) const //product order
|
|
||||||
{
|
|
||||||
return x < b.x && y < b.y;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Rect : public SDL_Rect
|
|
||||||
{
|
|
||||||
Rect()//default c-tor
|
|
||||||
{
|
|
||||||
x = y = w = h = -1;
|
|
||||||
}
|
|
||||||
Rect(int X, int Y, int W, int H) //c-tor
|
|
||||||
{
|
|
||||||
x = X;
|
|
||||||
y = Y;
|
|
||||||
w = W;
|
|
||||||
h = H;
|
|
||||||
}
|
|
||||||
Rect(const SDL_Rect & r) //c-tor
|
|
||||||
{
|
|
||||||
x = r.x;
|
|
||||||
y = r.y;
|
|
||||||
w = r.w;
|
|
||||||
h = r.h;
|
|
||||||
}
|
|
||||||
bool isIn(int qx, int qy) const //determines if given point lies inside rect
|
|
||||||
{
|
|
||||||
if (qx > x && qx<x+w && qy>y && qy<y+h)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bool isIn(const Point &q) const //determines if given point lies inside rect
|
|
||||||
{
|
|
||||||
return isIn(q.x,q.y);
|
|
||||||
}
|
|
||||||
Point topLeft() const //top left corner of this rect
|
|
||||||
{
|
|
||||||
return Point(x,y);
|
|
||||||
}
|
|
||||||
Point topRight() const //top right corner of this rect
|
|
||||||
{
|
|
||||||
return Point(x+w,y);
|
|
||||||
}
|
|
||||||
Point bottomLeft() const //bottom left corner of this rect
|
|
||||||
{
|
|
||||||
return Point(x,y+h);
|
|
||||||
}
|
|
||||||
Point bottomRight() const //bottom right corner of this rect
|
|
||||||
{
|
|
||||||
return Point(x+w,y+h);
|
|
||||||
}
|
|
||||||
Rect operator+(const Rect &p) const //moves this rect by p's rect position
|
|
||||||
{
|
|
||||||
return Rect(x+p.x,y+p.y,w,h);
|
|
||||||
}
|
|
||||||
Rect operator+(const Point &p) const //moves this rect by p's point position
|
|
||||||
{
|
|
||||||
return Rect(x+p.x,y+p.y,w,h);
|
|
||||||
}
|
|
||||||
Rect& operator=(const Rect &p) //assignment operator
|
|
||||||
{
|
|
||||||
x = p.x;
|
|
||||||
y = p.y;
|
|
||||||
w = p.w;
|
|
||||||
h = p.h;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
Rect& operator+=(const Rect &p) //works as operator+
|
|
||||||
{
|
|
||||||
x += p.x;
|
|
||||||
y += p.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
Rect operator&(const Rect &p) const //rect intersection
|
|
||||||
{
|
|
||||||
bool intersect = true;
|
|
||||||
|
|
||||||
if(p.topLeft().y < y && p.bottomLeft().y < y) //rect p is above *this
|
|
||||||
{
|
|
||||||
intersect = false;
|
|
||||||
}
|
|
||||||
else if(p.topLeft().y > y+h && p.bottomLeft().y > y+h) //rect p is below *this
|
|
||||||
{
|
|
||||||
intersect = false;
|
|
||||||
}
|
|
||||||
else if(p.topLeft().x > x+w && p.topRight().x > x+w) //rect p is on the right hand side of this
|
|
||||||
{
|
|
||||||
intersect = false;
|
|
||||||
}
|
|
||||||
else if(p.topLeft().x < x && p.topRight().x < x) //rect p is on the left hand side of this
|
|
||||||
{
|
|
||||||
intersect = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(intersect)
|
|
||||||
{
|
|
||||||
Rect ret;
|
|
||||||
ret.x = std::max(this->x, p.x);
|
|
||||||
ret.y = std::max(this->y, p.y);
|
|
||||||
Point bR; //bottomRight point of returned rect
|
|
||||||
bR.x = std::min(this->w+this->x, p.w+p.x);
|
|
||||||
bR.y = std::min(this->h+this->y, p.h+p.y);
|
|
||||||
ret.w = bR.x - ret.x;
|
|
||||||
ret.h = bR.y - ret.y;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Rect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class IShowable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void show(SDL_Surface * to)=0;
|
|
||||||
virtual void showAll(SDL_Surface * to)
|
|
||||||
{
|
|
||||||
show(to);
|
|
||||||
}
|
|
||||||
virtual ~IShowable(){}; //d-tor
|
|
||||||
};
|
|
||||||
|
|
||||||
class IStatusBar
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~IStatusBar(){}; //d-tor
|
|
||||||
virtual void print(const std::string & text)=0; //prints text and refreshes statusbar
|
|
||||||
virtual void clear()=0;//clears statusbar and refreshes
|
|
||||||
virtual void show(SDL_Surface * to)=0; //shows statusbar (with current text)
|
|
||||||
virtual std::string getCurrent()=0; //returns currently displayed text
|
|
||||||
};
|
|
||||||
|
|
||||||
class IActivable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void activate()=0;
|
|
||||||
virtual void deactivate()=0;
|
|
||||||
virtual ~IActivable(){}; //d-tor
|
|
||||||
};
|
|
||||||
class IShowActivable : public IShowable, public IActivable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum {WITH_GARRISON = 1};
|
|
||||||
int type; //bin flags using etype
|
|
||||||
IShowActivable();
|
|
||||||
virtual ~IShowActivable(){}; //d-tor
|
|
||||||
};
|
|
||||||
|
|
||||||
class CWindowWithGarrison : public IShowActivable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CGarrisonInt *garr;
|
|
||||||
CWindowWithGarrison();
|
|
||||||
};
|
|
||||||
|
|
||||||
class CMainInterface : public IShowActivable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
IShowActivable *subInt;
|
|
||||||
};
|
|
||||||
class CIntObject //interface object
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Rect pos; //position of object on the screen
|
|
||||||
int ID; //object uniqe ID, rarely (if at all) used
|
|
||||||
|
|
||||||
//virtual bool isIn(int x, int y)
|
|
||||||
//{
|
|
||||||
// return pos.isIn(x,y);
|
|
||||||
//}
|
|
||||||
virtual ~CIntObject(){}; //d-tor
|
|
||||||
};
|
|
||||||
class CSimpleWindow : public IShowActivable, public virtual CIntObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SDL_Surface * bitmap; //background
|
|
||||||
CIntObject * owner; //who made this window
|
|
||||||
virtual void show(SDL_Surface * to);
|
|
||||||
CSimpleWindow():bitmap(NULL),owner(NULL){}; //c-tor
|
|
||||||
virtual ~CSimpleWindow(); //d-tor
|
|
||||||
void activate(){};
|
|
||||||
void deactivate(){};
|
|
||||||
};
|
|
||||||
class CButtonBase : public virtual CIntObject, public IShowable, public IActivable //basic buttton class
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int bitmapOffset; //TODO: comment me
|
|
||||||
int type; //advmapbutton=2 //TODO: comment me
|
|
||||||
bool abs;//TODO: comment me
|
|
||||||
bool active; //if true, this button is active and can be pressed
|
|
||||||
bool notFreeButton; //TODO: comment me
|
|
||||||
CIntObject * ourObj; // "owner"
|
|
||||||
int state; //TODO: comment me
|
|
||||||
std::vector< std::vector<SDL_Surface*> > imgs; //images for this button
|
|
||||||
int curimg; //curently displayed image from imgs
|
|
||||||
virtual void show(SDL_Surface * to);
|
|
||||||
virtual void activate()=0;
|
|
||||||
virtual void deactivate()=0;
|
|
||||||
CButtonBase(); //c-tor
|
|
||||||
virtual ~CButtonBase(); //d-tor
|
|
||||||
};
|
|
||||||
class ClickableL : public virtual CIntObject //for left-clicks
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool pressedL; //for determining if object is L-pressed
|
|
||||||
ClickableL(); //c-tor
|
|
||||||
virtual ~ClickableL();//{};//d-tor
|
|
||||||
virtual void clickLeft (boost::logic::tribool down)=0;
|
|
||||||
virtual void activate();
|
|
||||||
virtual void deactivate();
|
|
||||||
};
|
|
||||||
class ClickableR : public virtual CIntObject //for right-clicks
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool pressedR; //for determining if object is R-pressed
|
|
||||||
ClickableR(); //c-tor
|
|
||||||
virtual ~ClickableR();//{};//d-tor
|
|
||||||
virtual void clickRight (boost::logic::tribool down)=0;
|
|
||||||
virtual void activate()=0;
|
|
||||||
virtual void deactivate()=0;
|
|
||||||
};
|
|
||||||
class Hoverable : public virtual CIntObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Hoverable() : hovered(false){} //c-tor
|
|
||||||
virtual ~Hoverable();//{}; //d-tor
|
|
||||||
bool hovered; //for determining if object is hovered
|
|
||||||
virtual void hover (bool on)=0;
|
|
||||||
virtual void activate()=0;
|
|
||||||
virtual void deactivate()=0;
|
|
||||||
};
|
|
||||||
class KeyInterested : public virtual CIntObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool captureAllKeys; //if true, only this object should get info about pressed keys
|
|
||||||
KeyInterested(): captureAllKeys(false){}
|
|
||||||
virtual ~KeyInterested();//{};//d-tor
|
|
||||||
virtual void keyPressed(const SDL_KeyboardEvent & key)=0;
|
|
||||||
virtual void activate()=0;
|
|
||||||
virtual void deactivate()=0;
|
|
||||||
};
|
|
||||||
|
|
||||||
//class for binding keys to left mouse button clicks
|
|
||||||
//classes wanting use it should have it as one of their base classes
|
|
||||||
class KeyShortcut : public KeyInterested, public ClickableL
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
std::set<int> assignedKeys;
|
|
||||||
KeyShortcut(){}; //c-tor
|
|
||||||
KeyShortcut(int key){assignedKeys.insert(key);}; //c-tor
|
|
||||||
KeyShortcut(std::set<int> Keys):assignedKeys(Keys){}; //c-tor
|
|
||||||
virtual void keyPressed(const SDL_KeyboardEvent & key); //call-in
|
|
||||||
};
|
|
||||||
|
|
||||||
class MotionInterested: public virtual CIntObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool strongInterest; //if true - report all mouse movements, if not - only when hovered
|
|
||||||
MotionInterested(){strongInterest=false;};
|
|
||||||
virtual ~MotionInterested(){};//d-tor
|
|
||||||
virtual void mouseMoved (const SDL_MouseMotionEvent & sEvent)=0;
|
|
||||||
virtual void activate()=0;
|
|
||||||
virtual void deactivate()=0;
|
|
||||||
};
|
|
||||||
class TimeInterested: public virtual CIntObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~TimeInterested(){}; //d-tor
|
|
||||||
int toNextTick;
|
|
||||||
virtual void tick()=0;
|
|
||||||
virtual void activate();
|
|
||||||
virtual void deactivate();
|
|
||||||
};
|
|
||||||
|
|
||||||
class CInfoWindow : public CSimpleWindow //text + comp. + ok button
|
|
||||||
{ //window able to delete its components when closed
|
|
||||||
public:
|
|
||||||
bool delComps; //whether comps will be deleted
|
|
||||||
std::vector<AdventureMapButton *> buttons;
|
|
||||||
std::vector<SComponent*> components;
|
|
||||||
virtual void close();
|
|
||||||
virtual void show(SDL_Surface * to);
|
|
||||||
void activate();
|
|
||||||
void deactivate();
|
|
||||||
CInfoWindow(std::string text, int player, int charperline, const std::vector<SComponent*> &comps, std::vector<std::pair<std::string,CFunctionList<void()> > > &Buttons, bool delComps); //c-tor
|
|
||||||
CInfoWindow(); //c-tor
|
|
||||||
~CInfoWindow(); //d-tor
|
|
||||||
};
|
|
||||||
class CSelWindow : public CInfoWindow //component selection window
|
|
||||||
{ //warning - this window deletes its components by closing!
|
|
||||||
public:
|
|
||||||
void selectionChange(unsigned to);
|
|
||||||
void madeChoice(); //looks for selected component and calls callback
|
|
||||||
CSelWindow(const std::string& text, int player, int charperline ,const std::vector<CSelectableComponent*> &comps, const std::vector<std::pair<std::string,CFunctionList<void()> > > &Buttons, int askID); //c-tor
|
|
||||||
CSelWindow(){}; //c-tor
|
|
||||||
//notification - this class inherits important destructor from CInfoWindow
|
|
||||||
};
|
|
||||||
|
|
||||||
class CRClickPopup : public IShowActivable, public ClickableR //popup displayed on R-click
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void activate();
|
|
||||||
virtual void deactivate();
|
|
||||||
virtual void close();
|
|
||||||
void clickRight (boost::logic::tribool down);
|
|
||||||
virtual ~CRClickPopup(){}; //d-tor
|
|
||||||
};
|
|
||||||
|
|
||||||
class CRClickPopupInt : public CRClickPopup //popup displayed on R-click
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
IShowActivable *inner;
|
|
||||||
bool delInner;
|
|
||||||
|
|
||||||
void show(SDL_Surface * to);
|
|
||||||
CRClickPopupInt(IShowActivable *our, bool deleteInt); //c-tor
|
|
||||||
virtual ~CRClickPopupInt(); //d-tor
|
|
||||||
};
|
|
||||||
|
|
||||||
class CInfoPopup : public CRClickPopup
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool free; //TODO: comment me
|
|
||||||
SDL_Surface * bitmap; //popup background
|
|
||||||
CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free=false); //c-tor
|
|
||||||
void close();
|
|
||||||
void show(SDL_Surface * to);
|
|
||||||
CInfoPopup(){free=false;bitmap=NULL;} //default c-tor
|
|
||||||
~CInfoPopup(){}; //d-tor
|
|
||||||
};
|
|
||||||
|
|
||||||
class SComponent : public ClickableR //common popup window component
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum Etype
|
|
||||||
{
|
|
||||||
primskill, secskill, resource, creature, artifact, experience, secskill44, spell, morale, luck
|
|
||||||
} type; //component type
|
|
||||||
int subtype; //TODO: comment me
|
|
||||||
int val; //TODO: comment me
|
|
||||||
|
|
||||||
std::string description; //r-click
|
|
||||||
std::string subtitle; //TODO: comment me
|
|
||||||
|
|
||||||
void init(Etype Type, int Subtype, int Val);
|
|
||||||
SComponent(Etype Type, int Subtype, int Val); //c-tor
|
|
||||||
SComponent(const Component &c); //c-tor
|
|
||||||
SComponent(){}; //c-tor
|
|
||||||
virtual ~SComponent(){}; //d-tor
|
|
||||||
|
|
||||||
void clickRight (boost::logic::tribool down); //call-in
|
|
||||||
virtual SDL_Surface * getImg();
|
|
||||||
virtual void show(SDL_Surface * to);
|
|
||||||
virtual void activate();
|
|
||||||
virtual void deactivate();
|
|
||||||
};
|
|
||||||
|
|
||||||
class CCustomImgComponent : public SComponent
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SDL_Surface *bmp; //our image
|
|
||||||
bool free; //should surface be freed on delete
|
|
||||||
SDL_Surface * getImg();
|
|
||||||
CCustomImgComponent(Etype Type, int Subtype, int Val, SDL_Surface *sur, bool freeSur); //c-tor
|
|
||||||
~CCustomImgComponent(); //d-tor
|
|
||||||
};
|
|
||||||
|
|
||||||
class CSelectableComponent : public SComponent, public KeyShortcut
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool selected; //if true, this component is selected
|
|
||||||
|
|
||||||
bool customB; //TODO: comment me
|
|
||||||
SDL_Surface * border, *myBitmap;
|
|
||||||
boost::function<void()> onSelect; //function called on selection change
|
|
||||||
|
|
||||||
void clickLeft(boost::logic::tribool down); //call-in
|
|
||||||
void init(SDL_Surface * Border);
|
|
||||||
CSelectableComponent(Etype Type, int Sub, int Val, boost::function<void()> OnSelect = 0, SDL_Surface * Border=NULL); //c-tor
|
|
||||||
CSelectableComponent(const Component &c, boost::function<void()> OnSelect = 0, SDL_Surface * Border=NULL); //c-tor
|
|
||||||
~CSelectableComponent(); //d-tor
|
|
||||||
virtual void show(SDL_Surface * to);
|
|
||||||
void activate();
|
|
||||||
void deactivate();
|
|
||||||
void select(bool on);
|
|
||||||
SDL_Surface * getImg(); //returns myBitmap
|
|
||||||
};
|
|
||||||
class CGarrisonInt;
|
|
||||||
class CGarrisonSlot : public ClickableL, public ClickableR, public Hoverable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CGarrisonInt *owner;
|
|
||||||
const CCreature * creature; //creature in slot
|
|
||||||
int count; //number of creatures
|
|
||||||
int upg; //0 - up garrison, 1 - down garrison
|
|
||||||
bool active; //TODO: comment me
|
|
||||||
|
|
||||||
virtual void hover (bool on); //call-in
|
|
||||||
const CArmedInstance * getObj();
|
|
||||||
void clickRight (boost::logic::tribool down);
|
|
||||||
void clickLeft(boost::logic::tribool down);
|
|
||||||
void activate();
|
|
||||||
void deactivate();
|
|
||||||
void show(SDL_Surface * to);
|
|
||||||
CGarrisonSlot(CGarrisonInt *Owner, int x, int y, int IID, int Upg=0, const CCreature * Creature=NULL, int Count=0);
|
|
||||||
~CGarrisonSlot(); //d-tor
|
|
||||||
};
|
|
||||||
|
|
||||||
class CGarrisonInt :public CIntObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int interx, intery; //intervals between slots
|
|
||||||
CGarrisonSlot *highlighted; //choosen slot
|
|
||||||
|
|
||||||
SDL_Surface *&sur; //TODO: comment me
|
|
||||||
int offx, offy, p2; //TODO: comment me
|
|
||||||
bool ignoreEvent, update, active, splitting, pb;
|
|
||||||
|
|
||||||
const CCreatureSet *set1; //top set of creatures
|
|
||||||
const CCreatureSet *set2; //bottom set of creatures
|
|
||||||
|
|
||||||
std::vector<CGarrisonSlot*> *sup, *sdown; //slots of upper and lower garrison
|
|
||||||
const CArmedInstance *oup, *odown; //upper and lower garrisons (heroes or towns)
|
|
||||||
|
|
||||||
void activate();
|
|
||||||
void deactivate();
|
|
||||||
void show(SDL_Surface * to);
|
|
||||||
void activeteSlots();
|
|
||||||
void deactiveteSlots();
|
|
||||||
void deleteSlots();
|
|
||||||
void createSlots();
|
|
||||||
void recreateSlots();
|
|
||||||
|
|
||||||
void splitClick(); //handles click on split button
|
|
||||||
void splitStacks(int am2); //TODO: comment me
|
|
||||||
|
|
||||||
CGarrisonInt(int x, int y, int inx, int iny, SDL_Surface *&pomsur, int OX, int OY, const CArmedInstance *s1, const CArmedInstance *s2=NULL); //c-tor
|
|
||||||
~CGarrisonInt(); //d-tor
|
|
||||||
};
|
|
||||||
|
|
||||||
class CPlayerInterface : public CGameInterface
|
class CPlayerInterface : public CGameInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -650,346 +186,6 @@ public:
|
|||||||
template <typename Handler> void serializeTempl(Handler &h, const int version);
|
template <typename Handler> void serializeTempl(Handler &h, const int version);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CStatusBar
|
|
||||||
: public CIntObject, public IStatusBar
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SDL_Surface * bg; //background
|
|
||||||
int middlex, middley; //middle of statusbar
|
|
||||||
std::string current; //text currently printed
|
|
||||||
|
|
||||||
CStatusBar(int x, int y, std::string name="ADROLLVR.bmp", int maxw=-1); //c-tor
|
|
||||||
~CStatusBar(); //d-tor
|
|
||||||
void print(const std::string & text); //prints text and refreshes statusbar
|
|
||||||
void clear();//clears statusbar and refreshes
|
|
||||||
void show(SDL_Surface * to); //shows statusbar (with current text)
|
|
||||||
std::string getCurrent(); //getter for current
|
|
||||||
};
|
|
||||||
|
|
||||||
class CList
|
|
||||||
: public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public virtual CIntObject, public MotionInterested
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SDL_Surface * bg; //background bitmap
|
|
||||||
CDefHandler *arrup, *arrdo; //button arrows for scrolling list
|
|
||||||
SDL_Surface *empty, *selection;
|
|
||||||
SDL_Rect arrupp, arrdop; //positions of arrows
|
|
||||||
int posw, posh; //position width/height
|
|
||||||
int selected, //id of selected position, <0 if none
|
|
||||||
from;
|
|
||||||
const int SIZE; //size of list
|
|
||||||
boost::logic::tribool pressed; //true=up; false=down; indeterminate=none
|
|
||||||
|
|
||||||
CList(int Size = 5); //c-tor
|
|
||||||
void clickLeft(boost::logic::tribool down);
|
|
||||||
void activate();
|
|
||||||
void deactivate();
|
|
||||||
virtual void mouseMoved (const SDL_MouseMotionEvent & sEvent)=0; //call-in
|
|
||||||
virtual void genList()=0;
|
|
||||||
virtual void select(int which)=0;
|
|
||||||
virtual void draw(SDL_Surface * to)=0;
|
|
||||||
};
|
|
||||||
class CHeroList
|
|
||||||
: public CList
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CDefHandler *mobile, *mana; //mana and movement indicators
|
|
||||||
std::vector<std::pair<const CGHeroInstance*, CPath *> > items;
|
|
||||||
int posmobx, posporx, posmanx, posmoby, pospory, posmany;
|
|
||||||
|
|
||||||
CHeroList(int Size); //c-tor
|
|
||||||
int getPosOfHero(const CArmedInstance* h); //hero's position on list
|
|
||||||
void genList();
|
|
||||||
void select(int which); //call-in
|
|
||||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent); //call-in
|
|
||||||
void clickLeft(boost::logic::tribool down); //call-in
|
|
||||||
void clickRight(boost::logic::tribool down); //call-in
|
|
||||||
void hover (bool on); //call-in
|
|
||||||
void keyPressed (const SDL_KeyboardEvent & key); //call-in
|
|
||||||
void updateHList(const CGHeroInstance *toRemove=NULL); //removes specific hero from the list or recreates it
|
|
||||||
void updateMove(const CGHeroInstance* which); //draws move points bar
|
|
||||||
void redrawAllOne(int which); //not imeplemented
|
|
||||||
void draw(SDL_Surface * to);
|
|
||||||
void init();
|
|
||||||
};
|
|
||||||
|
|
||||||
class CTownList
|
|
||||||
: public CList
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
boost::function<void()> fun; //function called on selection change
|
|
||||||
std::vector<const CGTownInstance*> items; //towns on list
|
|
||||||
int posporx,pospory;
|
|
||||||
|
|
||||||
CTownList(int Size, int x, int y, std::string arrupg, std::string arrdog); //c-tor
|
|
||||||
~CTownList(); //d-tor
|
|
||||||
void genList();
|
|
||||||
void select(int which); //call-in
|
|
||||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent); //call-in
|
|
||||||
void clickLeft(boost::logic::tribool down); //call-in
|
|
||||||
void clickRight(boost::logic::tribool down); //call-in
|
|
||||||
void hover (bool on); //call-in
|
|
||||||
void keyPressed (const SDL_KeyboardEvent & key); //call-in
|
|
||||||
void draw(SDL_Surface * to);
|
|
||||||
};
|
|
||||||
|
|
||||||
class CCreaturePic //draws picture with creature on background, use nextFrame=true to get animation
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CCreature *c; //which creature's picture
|
|
||||||
bool big; //big => 100x130; !big => 100x120
|
|
||||||
CCreatureAnimation *anim; //displayed animation
|
|
||||||
CCreaturePic(CCreature *cre, bool Big=true); //c-tor
|
|
||||||
~CCreaturePic(); //d-tor
|
|
||||||
int blitPic(SDL_Surface *to, int x, int y, bool nextFrame); //prints creature on screen
|
|
||||||
SDL_Surface * getPic(bool nextFrame); //returns frame of animation
|
|
||||||
};
|
|
||||||
|
|
||||||
class CRecruitmentWindow : public IShowActivable, public ClickableL, public ClickableR
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
struct creinfo
|
|
||||||
{
|
|
||||||
SDL_Rect pos;
|
|
||||||
CCreaturePic *pic; //creature's animation
|
|
||||||
int ID, amount; //creature ID and available amount
|
|
||||||
std::vector<std::pair<int,int> > res; //res_id - cost_per_unit
|
|
||||||
};
|
|
||||||
std::vector<int> amounts; //how many creatures we can afford
|
|
||||||
std::vector<creinfo> creatures; //recruitable creatures
|
|
||||||
boost::function<void(int,int)> recruit; //void (int ID, int amount) <-- call to recruit creatures
|
|
||||||
CSlider *slider; //for selecting amount
|
|
||||||
AdventureMapButton *max, *buy, *cancel;
|
|
||||||
SDL_Surface *bitmap; //background
|
|
||||||
CStatusBar *bar;
|
|
||||||
int which; //which creature is active
|
|
||||||
|
|
||||||
void close();
|
|
||||||
void Max();
|
|
||||||
void Buy();
|
|
||||||
void Cancel();
|
|
||||||
void sliderMoved(int to);
|
|
||||||
void clickLeft(boost::logic::tribool down);
|
|
||||||
void clickRight(boost::logic::tribool down);
|
|
||||||
void activate();
|
|
||||||
void deactivate();
|
|
||||||
void show(SDL_Surface * to);
|
|
||||||
CRecruitmentWindow(const std::vector<std::pair<int,int> > & Creatures, const boost::function<void(int,int)> & Recruit); //creatures - pairs<creature_ID,amount> //c-tor
|
|
||||||
~CRecruitmentWindow(); //d-tor
|
|
||||||
};
|
|
||||||
|
|
||||||
class CSplitWindow : public IShowActivable, public KeyInterested, public ClickableL
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CGarrisonInt *gar;
|
|
||||||
CSlider *slider;
|
|
||||||
CCreaturePic *anim; //creature's animation
|
|
||||||
AdventureMapButton *ok, *cancel;
|
|
||||||
SDL_Surface *bitmap; //background
|
|
||||||
int a1, a2, c; //TODO: comment me
|
|
||||||
bool which; //which creature is selected
|
|
||||||
int last; //0/1/2 - at least one creature must be in the src/dst/both stacks; -1 - no restrictions
|
|
||||||
|
|
||||||
CSplitWindow(int cid, int max, CGarrisonInt *Owner, int Last = -1, int val=0); //c-tor; val - initial amount of second stack
|
|
||||||
~CSplitWindow(); //d-tor
|
|
||||||
void activate();
|
|
||||||
void split();
|
|
||||||
void close();
|
|
||||||
void deactivate();
|
|
||||||
void show(SDL_Surface * to);
|
|
||||||
void clickLeft(boost::logic::tribool down); //call-in
|
|
||||||
void keyPressed (const SDL_KeyboardEvent & key); //call-in
|
|
||||||
void sliderMoved(int to);
|
|
||||||
};
|
|
||||||
|
|
||||||
class CCreInfoWindow : public IShowActivable, public KeyInterested, public ClickableR
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//bool active; //TODO: comment me
|
|
||||||
int type;//0 - rclick popup; 1 - normal window
|
|
||||||
SDL_Surface *bitmap; //background
|
|
||||||
char anf; //animation counter
|
|
||||||
std::string count; //creature count in text format
|
|
||||||
|
|
||||||
boost::function<void()> dsm; //dismiss button callback
|
|
||||||
CCreaturePic *anim; //related creature's animation
|
|
||||||
CCreature *c; //related creature
|
|
||||||
std::vector<SComponent*> upgResCost; //cost of upgrade (if not possible then empty)
|
|
||||||
|
|
||||||
AdventureMapButton *dismiss, *upgrade, *ok;
|
|
||||||
CCreInfoWindow(int Cid, int Type, int creatureCount, StackState *State, boost::function<void()> Upg, boost::function<void()> Dsm, UpgradeInfo *ui); //c-tor
|
|
||||||
~CCreInfoWindow(); //d-tor
|
|
||||||
void activate();
|
|
||||||
void close();
|
|
||||||
void clickRight(boost::logic::tribool down); //call-in
|
|
||||||
void dismissF();
|
|
||||||
void keyPressed (const SDL_KeyboardEvent & key); //call-in
|
|
||||||
void deactivate();
|
|
||||||
void show(SDL_Surface * to);
|
|
||||||
};
|
|
||||||
|
|
||||||
class CLevelWindow : public IShowActivable, public CIntObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int heroType;
|
|
||||||
SDL_Surface *bitmap; //background
|
|
||||||
std::vector<CSelectableComponent *> comps; //skills to select
|
|
||||||
AdventureMapButton *ok;
|
|
||||||
boost::function<void(ui32)> cb;
|
|
||||||
|
|
||||||
void close();
|
|
||||||
CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback); //c-tor
|
|
||||||
~CLevelWindow(); //d-tor
|
|
||||||
void activate();
|
|
||||||
void deactivate();
|
|
||||||
void selectionChanged(unsigned to);
|
|
||||||
void show(SDL_Surface * to);
|
|
||||||
};
|
|
||||||
|
|
||||||
class CMinorResDataBar : public IShowable, public CIntObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SDL_Surface *bg; //background bitmap
|
|
||||||
void show(SDL_Surface * to);
|
|
||||||
CMinorResDataBar(); //c-tor
|
|
||||||
~CMinorResDataBar(); //d-tor
|
|
||||||
};
|
|
||||||
|
|
||||||
class CMarketplaceWindow : public IShowActivable, public CIntObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
class CTradeableItem : public ClickableL
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int type; //0 - res, 1 - artif big, 2 - artif small, 3 - player flag
|
|
||||||
int id;
|
|
||||||
bool left;
|
|
||||||
CFunctionList<void()> callback;
|
|
||||||
|
|
||||||
void activate();
|
|
||||||
void deactivate();
|
|
||||||
void show(SDL_Surface * to);
|
|
||||||
void clickLeft(boost::logic::tribool down);
|
|
||||||
SDL_Surface *getSurface();
|
|
||||||
CTradeableItem(int Type, int ID, bool Left);
|
|
||||||
};
|
|
||||||
|
|
||||||
SDL_Surface *bg; //background
|
|
||||||
std::vector<CTradeableItem*> left, right;
|
|
||||||
std::vector<std::string> rSubs; //offer caption
|
|
||||||
CTradeableItem *hLeft, *hRight; //highlighted items (NULL if no highlight)
|
|
||||||
|
|
||||||
int mode,//0 - res<->res; 1 - res<->plauer; 2 - buy artifact; 3 - sell artifact
|
|
||||||
r1, r2; //suggested amounts of traded resources
|
|
||||||
AdventureMapButton *ok, *max, *deal;
|
|
||||||
CSlider *slider; //for choosing amount to be exchanged
|
|
||||||
|
|
||||||
void activate();
|
|
||||||
void deactivate();
|
|
||||||
void show(SDL_Surface * to);
|
|
||||||
void setMax();
|
|
||||||
void sliderMoved(int to);
|
|
||||||
void makeDeal();
|
|
||||||
void selectionChanged(bool side); //true == left
|
|
||||||
CMarketplaceWindow(int Mode=0); //c-tor
|
|
||||||
~CMarketplaceWindow(); //d-tor
|
|
||||||
void setMode(int mode); //mode setter
|
|
||||||
void clear();
|
|
||||||
};
|
|
||||||
|
|
||||||
class CSystemOptionsWindow : public IShowActivable, public CIntObject
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
SDL_Surface * background; //background of window
|
|
||||||
AdventureMapButton *load, *save, *restart, *mainMenu, * quitGame, * backToMap; //load, restart and main menu are not used yet
|
|
||||||
CHighlightableButtonsGroup * heroMoveSpeed;
|
|
||||||
CHighlightableButtonsGroup * mapScrollSpeed;
|
|
||||||
CHighlightableButtonsGroup * musicVolume, * effectsVolume;
|
|
||||||
public:
|
|
||||||
CSystemOptionsWindow(const SDL_Rect & pos, CPlayerInterface * owner); //c-tor
|
|
||||||
~CSystemOptionsWindow(); //d-tor
|
|
||||||
|
|
||||||
//functions bound to buttons
|
|
||||||
void bsavef(); //save game
|
|
||||||
void bquitf(); //quit game
|
|
||||||
void breturnf(); //return to game
|
|
||||||
|
|
||||||
void activate();
|
|
||||||
void deactivate();
|
|
||||||
void show(SDL_Surface * to);
|
|
||||||
};
|
|
||||||
|
|
||||||
class CTavernWindow : public IShowActivable, public CIntObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
class HeroPortrait : public ClickableL, public ClickableR, public Hoverable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
std::string hoverName;
|
|
||||||
vstd::assigner<int,int> as;
|
|
||||||
const CGHeroInstance *h;
|
|
||||||
void activate();
|
|
||||||
void deactivate();
|
|
||||||
void clickLeft(boost::logic::tribool down);
|
|
||||||
void clickRight(boost::logic::tribool down);
|
|
||||||
void hover (bool on);
|
|
||||||
HeroPortrait(int &sel, int id, int x, int y, const CGHeroInstance *H);
|
|
||||||
void show(SDL_Surface * to);
|
|
||||||
} h1, h2; //recruitable heroes
|
|
||||||
|
|
||||||
SDL_Surface *bg; //background
|
|
||||||
CStatusBar *bar; //tavern's internal status bar
|
|
||||||
int selected;//0 (left) or 1 (right)
|
|
||||||
|
|
||||||
AdventureMapButton *thiefGuild, *cancel, *recruit;
|
|
||||||
|
|
||||||
CTavernWindow(const CGHeroInstance *H1, const CGHeroInstance *H2, const std::string &gossip); //c-tor
|
|
||||||
~CTavernWindow(); //d-tor
|
|
||||||
|
|
||||||
void recruitb();
|
|
||||||
void close();
|
|
||||||
void activate();
|
|
||||||
void deactivate();
|
|
||||||
void show(SDL_Surface * to);
|
|
||||||
};
|
|
||||||
|
|
||||||
class CInGameConsole : public IShowActivable, public KeyInterested
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::list< std::pair< std::string, int > > texts; //<text to show, time of add>
|
|
||||||
std::vector< std::string > previouslyEntered; //previously entered texts, for up/down arrows to work
|
|
||||||
int prevEntDisp; //displayed entry from previouslyEntered - if none it's -1
|
|
||||||
int defaultTimeout; //timeout for new texts (in ms)
|
|
||||||
int maxDisplayedTexts; //hiw many texts can be displayed simultaneously
|
|
||||||
public:
|
|
||||||
std::string enteredText;
|
|
||||||
void activate();
|
|
||||||
void deactivate();
|
|
||||||
void show(SDL_Surface * to);
|
|
||||||
void print(const std::string &txt);
|
|
||||||
void keyPressed (const SDL_KeyboardEvent & key); //call-in
|
|
||||||
|
|
||||||
void startEnteringText();
|
|
||||||
void endEnteringText(bool printEnteredText);
|
|
||||||
void refreshEnteredText();
|
|
||||||
|
|
||||||
CInGameConsole(); //c-tor
|
|
||||||
};
|
|
||||||
|
|
||||||
class CGarrisonWindow : public CWindowWithGarrison, public CIntObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SDL_Surface *bg; //background surface
|
|
||||||
AdventureMapButton *split, *quit;
|
|
||||||
|
|
||||||
void close();
|
|
||||||
void activate();
|
|
||||||
void deactivate();
|
|
||||||
void show(SDL_Surface * to);
|
|
||||||
CGarrisonWindow(const CArmedInstance *up, const CGHeroInstance *down); //c-tor
|
|
||||||
~CGarrisonWindow(); //d-tor
|
|
||||||
};
|
|
||||||
|
|
||||||
extern CPlayerInterface * LOCPLINT;
|
extern CPlayerInterface * LOCPLINT;
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
#define __SDL_EXTENSIONS_H__
|
#define __SDL_EXTENSIONS_H__
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#include "SDL_ttf.h"
|
#include "SDL_ttf.h"
|
||||||
|
#include <string>
|
||||||
|
#include "int3.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SDL_Extensions.h, part of VCMI engine
|
* SDL_Extensions.h, part of VCMI engine
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "../global.h"
|
#include "../global.h"
|
||||||
#include "../CPlayerInterface.h"
|
|
||||||
#include "../hch/CDefHandler.h"
|
#include "../hch/CDefHandler.h"
|
||||||
|
#include "GUIClasses.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CCreatureAnimation.h, part of VCMI engine
|
* CCreatureAnimation.h, part of VCMI engine
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "../global.h"
|
#include "../global.h"
|
||||||
#include "../CPlayerInterface.h"
|
#include "GUIClasses.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CSpellWindow.h, part of VCMI engine
|
* CSpellWindow.h, part of VCMI engine
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define FUNCTIONLIST_H
|
#define FUNCTIONLIST_H
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FunctionList.h, part of VCMI engine
|
* FunctionList.h, part of VCMI engine
|
||||||
|
3348
client/GUIClasses.cpp
Normal file
3348
client/GUIClasses.cpp
Normal file
File diff suppressed because it is too large
Load Diff
876
client/GUIClasses.h
Normal file
876
client/GUIClasses.h
Normal file
@ -0,0 +1,876 @@
|
|||||||
|
#ifndef __GUICLASSES_H__
|
||||||
|
#define __GUICLASSES_H__
|
||||||
|
|
||||||
|
#include "global.h"
|
||||||
|
#include "SDL_framerate.h"
|
||||||
|
#include "FunctionList.h"
|
||||||
|
#include <set>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
#ifdef max
|
||||||
|
#undef max
|
||||||
|
#endif
|
||||||
|
#ifdef min
|
||||||
|
#undef min
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class CDefEssential;
|
||||||
|
class AdventureMapButton;
|
||||||
|
class CHighlightableButtonsGroup;
|
||||||
|
class CDefHandler;
|
||||||
|
struct HeroMoveDetails;
|
||||||
|
class CDefEssential;
|
||||||
|
class CGHeroInstance;
|
||||||
|
class CAdvMapInt;
|
||||||
|
class CCastleInterface;
|
||||||
|
class CBattleInterface;
|
||||||
|
class CStack;
|
||||||
|
class SComponent;
|
||||||
|
class CCreature;
|
||||||
|
struct SDL_Surface;
|
||||||
|
struct CPath;
|
||||||
|
class CCreatureAnimation;
|
||||||
|
class CSelectableComponent;
|
||||||
|
class CCreatureSet;
|
||||||
|
class CGObjectInstance;
|
||||||
|
class CSlider;
|
||||||
|
struct UpgradeInfo;
|
||||||
|
template <typename T> struct CondSh;
|
||||||
|
class CInGameConsole;
|
||||||
|
class CGarrisonInt;
|
||||||
|
class CInGameConsole;
|
||||||
|
class Component;
|
||||||
|
class CArmedInstance;
|
||||||
|
class CGTownInstance;
|
||||||
|
class StackState;
|
||||||
|
class CPlayerInterface;
|
||||||
|
|
||||||
|
struct Point
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
//constructors
|
||||||
|
Point(){};
|
||||||
|
Point(int X, int Y)
|
||||||
|
:x(X),y(Y)
|
||||||
|
{};
|
||||||
|
Point(const int3 &a)
|
||||||
|
:x(a.x),y(a.y)
|
||||||
|
{}
|
||||||
|
|
||||||
|
Point operator+(const Point &b) const
|
||||||
|
{
|
||||||
|
return Point(x+b.x,y+b.y);
|
||||||
|
}
|
||||||
|
Point& operator+=(const Point &b)
|
||||||
|
{
|
||||||
|
x += b.x;
|
||||||
|
y += b.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
Point operator-(const Point &b) const
|
||||||
|
{
|
||||||
|
return Point(x+b.x,y+b.y);
|
||||||
|
}
|
||||||
|
Point& operator-=(const Point &b)
|
||||||
|
{
|
||||||
|
x -= b.x;
|
||||||
|
y -= b.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
bool operator<(const Point &b) const //product order
|
||||||
|
{
|
||||||
|
return x < b.x && y < b.y;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Rect : public SDL_Rect
|
||||||
|
{
|
||||||
|
Rect()//default c-tor
|
||||||
|
{
|
||||||
|
x = y = w = h = -1;
|
||||||
|
}
|
||||||
|
Rect(int X, int Y, int W, int H) //c-tor
|
||||||
|
{
|
||||||
|
x = X;
|
||||||
|
y = Y;
|
||||||
|
w = W;
|
||||||
|
h = H;
|
||||||
|
}
|
||||||
|
Rect(const SDL_Rect & r) //c-tor
|
||||||
|
{
|
||||||
|
x = r.x;
|
||||||
|
y = r.y;
|
||||||
|
w = r.w;
|
||||||
|
h = r.h;
|
||||||
|
}
|
||||||
|
bool isIn(int qx, int qy) const //determines if given point lies inside rect
|
||||||
|
{
|
||||||
|
if (qx > x && qx<x+w && qy>y && qy<y+h)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool isIn(const Point &q) const //determines if given point lies inside rect
|
||||||
|
{
|
||||||
|
return isIn(q.x,q.y);
|
||||||
|
}
|
||||||
|
Point topLeft() const //top left corner of this rect
|
||||||
|
{
|
||||||
|
return Point(x,y);
|
||||||
|
}
|
||||||
|
Point topRight() const //top right corner of this rect
|
||||||
|
{
|
||||||
|
return Point(x+w,y);
|
||||||
|
}
|
||||||
|
Point bottomLeft() const //bottom left corner of this rect
|
||||||
|
{
|
||||||
|
return Point(x,y+h);
|
||||||
|
}
|
||||||
|
Point bottomRight() const //bottom right corner of this rect
|
||||||
|
{
|
||||||
|
return Point(x+w,y+h);
|
||||||
|
}
|
||||||
|
Rect operator+(const Rect &p) const //moves this rect by p's rect position
|
||||||
|
{
|
||||||
|
return Rect(x+p.x,y+p.y,w,h);
|
||||||
|
}
|
||||||
|
Rect operator+(const Point &p) const //moves this rect by p's point position
|
||||||
|
{
|
||||||
|
return Rect(x+p.x,y+p.y,w,h);
|
||||||
|
}
|
||||||
|
Rect& operator=(const Rect &p) //assignment operator
|
||||||
|
{
|
||||||
|
x = p.x;
|
||||||
|
y = p.y;
|
||||||
|
w = p.w;
|
||||||
|
h = p.h;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
Rect& operator+=(const Rect &p) //works as operator+
|
||||||
|
{
|
||||||
|
x += p.x;
|
||||||
|
y += p.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
Rect operator&(const Rect &p) const //rect intersection
|
||||||
|
{
|
||||||
|
bool intersect = true;
|
||||||
|
|
||||||
|
if(p.topLeft().y < y && p.bottomLeft().y < y) //rect p is above *this
|
||||||
|
{
|
||||||
|
intersect = false;
|
||||||
|
}
|
||||||
|
else if(p.topLeft().y > y+h && p.bottomLeft().y > y+h) //rect p is below *this
|
||||||
|
{
|
||||||
|
intersect = false;
|
||||||
|
}
|
||||||
|
else if(p.topLeft().x > x+w && p.topRight().x > x+w) //rect p is on the right hand side of this
|
||||||
|
{
|
||||||
|
intersect = false;
|
||||||
|
}
|
||||||
|
else if(p.topLeft().x < x && p.topRight().x < x) //rect p is on the left hand side of this
|
||||||
|
{
|
||||||
|
intersect = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(intersect)
|
||||||
|
{
|
||||||
|
Rect ret;
|
||||||
|
ret.x = std::max(this->x, p.x);
|
||||||
|
ret.y = std::max(this->y, p.y);
|
||||||
|
Point bR; //bottomRight point of returned rect
|
||||||
|
bR.x = std::min(this->w+this->x, p.w+p.x);
|
||||||
|
bR.y = std::min(this->h+this->y, p.h+p.y);
|
||||||
|
ret.w = bR.x - ret.x;
|
||||||
|
ret.h = bR.y - ret.y;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Rect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class IShowable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void show(SDL_Surface * to)=0;
|
||||||
|
virtual void showAll(SDL_Surface * to)
|
||||||
|
{
|
||||||
|
show(to);
|
||||||
|
}
|
||||||
|
virtual ~IShowable(){}; //d-tor
|
||||||
|
};
|
||||||
|
|
||||||
|
class IStatusBar
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IStatusBar(){}; //d-tor
|
||||||
|
virtual void print(const std::string & text)=0; //prints text and refreshes statusbar
|
||||||
|
virtual void clear()=0;//clears statusbar and refreshes
|
||||||
|
virtual void show(SDL_Surface * to)=0; //shows statusbar (with current text)
|
||||||
|
virtual std::string getCurrent()=0; //returns currently displayed text
|
||||||
|
};
|
||||||
|
|
||||||
|
class IActivable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void activate()=0;
|
||||||
|
virtual void deactivate()=0;
|
||||||
|
virtual ~IActivable(){}; //d-tor
|
||||||
|
};
|
||||||
|
class IShowActivable : public IShowable, public IActivable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum {WITH_GARRISON = 1};
|
||||||
|
int type; //bin flags using etype
|
||||||
|
IShowActivable();
|
||||||
|
virtual ~IShowActivable(){}; //d-tor
|
||||||
|
};
|
||||||
|
|
||||||
|
class CWindowWithGarrison : public IShowActivable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CGarrisonInt *garr;
|
||||||
|
CWindowWithGarrison();
|
||||||
|
};
|
||||||
|
|
||||||
|
class CMainInterface : public IShowActivable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IShowActivable *subInt;
|
||||||
|
};
|
||||||
|
class CIntObject //interface object
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Rect pos; //position of object on the screen
|
||||||
|
int ID; //object uniqe ID, rarely (if at all) used
|
||||||
|
|
||||||
|
//virtual bool isIn(int x, int y)
|
||||||
|
//{
|
||||||
|
// return pos.isIn(x,y);
|
||||||
|
//}
|
||||||
|
virtual ~CIntObject(){}; //d-tor
|
||||||
|
};
|
||||||
|
class CSimpleWindow : public IShowActivable, public virtual CIntObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SDL_Surface * bitmap; //background
|
||||||
|
CIntObject * owner; //who made this window
|
||||||
|
virtual void show(SDL_Surface * to);
|
||||||
|
CSimpleWindow():bitmap(NULL),owner(NULL){}; //c-tor
|
||||||
|
virtual ~CSimpleWindow(); //d-tor
|
||||||
|
void activate(){};
|
||||||
|
void deactivate(){};
|
||||||
|
};
|
||||||
|
class CButtonBase : public virtual CIntObject, public IShowable, public IActivable //basic buttton class
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int bitmapOffset; //TODO: comment me
|
||||||
|
int type; //advmapbutton=2 //TODO: comment me
|
||||||
|
bool abs;//TODO: comment me
|
||||||
|
bool active; //if true, this button is active and can be pressed
|
||||||
|
bool notFreeButton; //TODO: comment me
|
||||||
|
CIntObject * ourObj; // "owner"
|
||||||
|
int state; //TODO: comment me
|
||||||
|
std::vector< std::vector<SDL_Surface*> > imgs; //images for this button
|
||||||
|
int curimg; //curently displayed image from imgs
|
||||||
|
virtual void show(SDL_Surface * to);
|
||||||
|
virtual void activate()=0;
|
||||||
|
virtual void deactivate()=0;
|
||||||
|
CButtonBase(); //c-tor
|
||||||
|
virtual ~CButtonBase(); //d-tor
|
||||||
|
};
|
||||||
|
class ClickableL : public virtual CIntObject //for left-clicks
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool pressedL; //for determining if object is L-pressed
|
||||||
|
ClickableL(); //c-tor
|
||||||
|
virtual ~ClickableL();//{};//d-tor
|
||||||
|
virtual void clickLeft (boost::logic::tribool down)=0;
|
||||||
|
virtual void activate();
|
||||||
|
virtual void deactivate();
|
||||||
|
};
|
||||||
|
class ClickableR : public virtual CIntObject //for right-clicks
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool pressedR; //for determining if object is R-pressed
|
||||||
|
ClickableR(); //c-tor
|
||||||
|
virtual ~ClickableR();//{};//d-tor
|
||||||
|
virtual void clickRight (boost::logic::tribool down)=0;
|
||||||
|
virtual void activate()=0;
|
||||||
|
virtual void deactivate()=0;
|
||||||
|
};
|
||||||
|
class Hoverable : public virtual CIntObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Hoverable() : hovered(false){} //c-tor
|
||||||
|
virtual ~Hoverable();//{}; //d-tor
|
||||||
|
bool hovered; //for determining if object is hovered
|
||||||
|
virtual void hover (bool on)=0;
|
||||||
|
virtual void activate()=0;
|
||||||
|
virtual void deactivate()=0;
|
||||||
|
};
|
||||||
|
class KeyInterested : public virtual CIntObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool captureAllKeys; //if true, only this object should get info about pressed keys
|
||||||
|
KeyInterested(): captureAllKeys(false){}
|
||||||
|
virtual ~KeyInterested();//{};//d-tor
|
||||||
|
virtual void keyPressed(const SDL_KeyboardEvent & key)=0;
|
||||||
|
virtual void activate()=0;
|
||||||
|
virtual void deactivate()=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
//class for binding keys to left mouse button clicks
|
||||||
|
//classes wanting use it should have it as one of their base classes
|
||||||
|
class KeyShortcut : public KeyInterested, public ClickableL
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::set<int> assignedKeys;
|
||||||
|
KeyShortcut(){}; //c-tor
|
||||||
|
KeyShortcut(int key){assignedKeys.insert(key);}; //c-tor
|
||||||
|
KeyShortcut(std::set<int> Keys):assignedKeys(Keys){}; //c-tor
|
||||||
|
virtual void keyPressed(const SDL_KeyboardEvent & key); //call-in
|
||||||
|
};
|
||||||
|
|
||||||
|
class MotionInterested: public virtual CIntObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool strongInterest; //if true - report all mouse movements, if not - only when hovered
|
||||||
|
MotionInterested(){strongInterest=false;};
|
||||||
|
virtual ~MotionInterested(){};//d-tor
|
||||||
|
virtual void mouseMoved (const SDL_MouseMotionEvent & sEvent)=0;
|
||||||
|
virtual void activate()=0;
|
||||||
|
virtual void deactivate()=0;
|
||||||
|
};
|
||||||
|
class TimeInterested: public virtual CIntObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~TimeInterested(){}; //d-tor
|
||||||
|
int toNextTick;
|
||||||
|
virtual void tick()=0;
|
||||||
|
virtual void activate();
|
||||||
|
virtual void deactivate();
|
||||||
|
};
|
||||||
|
|
||||||
|
class CInfoWindow : public CSimpleWindow //text + comp. + ok button
|
||||||
|
{ //window able to delete its components when closed
|
||||||
|
public:
|
||||||
|
bool delComps; //whether comps will be deleted
|
||||||
|
std::vector<AdventureMapButton *> buttons;
|
||||||
|
std::vector<SComponent*> components;
|
||||||
|
virtual void close();
|
||||||
|
virtual void show(SDL_Surface * to);
|
||||||
|
void activate();
|
||||||
|
void deactivate();
|
||||||
|
CInfoWindow(std::string text, int player, int charperline, const std::vector<SComponent*> &comps, std::vector<std::pair<std::string,CFunctionList<void()> > > &Buttons, bool delComps); //c-tor
|
||||||
|
CInfoWindow(); //c-tor
|
||||||
|
~CInfoWindow(); //d-tor
|
||||||
|
};
|
||||||
|
class CSelWindow : public CInfoWindow //component selection window
|
||||||
|
{ //warning - this window deletes its components by closing!
|
||||||
|
public:
|
||||||
|
void selectionChange(unsigned to);
|
||||||
|
void madeChoice(); //looks for selected component and calls callback
|
||||||
|
CSelWindow(const std::string& text, int player, int charperline ,const std::vector<CSelectableComponent*> &comps, const std::vector<std::pair<std::string,CFunctionList<void()> > > &Buttons, int askID); //c-tor
|
||||||
|
CSelWindow(){}; //c-tor
|
||||||
|
//notification - this class inherits important destructor from CInfoWindow
|
||||||
|
};
|
||||||
|
|
||||||
|
class CRClickPopup : public IShowActivable, public ClickableR //popup displayed on R-click
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void activate();
|
||||||
|
virtual void deactivate();
|
||||||
|
virtual void close();
|
||||||
|
void clickRight (boost::logic::tribool down);
|
||||||
|
virtual ~CRClickPopup(){}; //d-tor
|
||||||
|
};
|
||||||
|
|
||||||
|
class CRClickPopupInt : public CRClickPopup //popup displayed on R-click
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IShowActivable *inner;
|
||||||
|
bool delInner;
|
||||||
|
|
||||||
|
void show(SDL_Surface * to);
|
||||||
|
CRClickPopupInt(IShowActivable *our, bool deleteInt); //c-tor
|
||||||
|
virtual ~CRClickPopupInt(); //d-tor
|
||||||
|
};
|
||||||
|
|
||||||
|
class CInfoPopup : public CRClickPopup
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool free; //TODO: comment me
|
||||||
|
SDL_Surface * bitmap; //popup background
|
||||||
|
CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free=false); //c-tor
|
||||||
|
void close();
|
||||||
|
void show(SDL_Surface * to);
|
||||||
|
CInfoPopup(){free=false;bitmap=NULL;} //default c-tor
|
||||||
|
~CInfoPopup(){}; //d-tor
|
||||||
|
};
|
||||||
|
|
||||||
|
class SComponent : public ClickableR //common popup window component
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum Etype
|
||||||
|
{
|
||||||
|
primskill, secskill, resource, creature, artifact, experience, secskill44, spell, morale, luck
|
||||||
|
} type; //component type
|
||||||
|
int subtype; //TODO: comment me
|
||||||
|
int val; //TODO: comment me
|
||||||
|
|
||||||
|
std::string description; //r-click
|
||||||
|
std::string subtitle; //TODO: comment me
|
||||||
|
|
||||||
|
void init(Etype Type, int Subtype, int Val);
|
||||||
|
SComponent(Etype Type, int Subtype, int Val); //c-tor
|
||||||
|
SComponent(const Component &c); //c-tor
|
||||||
|
SComponent(){}; //c-tor
|
||||||
|
virtual ~SComponent(){}; //d-tor
|
||||||
|
|
||||||
|
void clickRight (boost::logic::tribool down); //call-in
|
||||||
|
virtual SDL_Surface * getImg();
|
||||||
|
virtual void show(SDL_Surface * to);
|
||||||
|
virtual void activate();
|
||||||
|
virtual void deactivate();
|
||||||
|
};
|
||||||
|
|
||||||
|
class CCustomImgComponent : public SComponent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SDL_Surface *bmp; //our image
|
||||||
|
bool free; //should surface be freed on delete
|
||||||
|
SDL_Surface * getImg();
|
||||||
|
CCustomImgComponent(Etype Type, int Subtype, int Val, SDL_Surface *sur, bool freeSur); //c-tor
|
||||||
|
~CCustomImgComponent(); //d-tor
|
||||||
|
};
|
||||||
|
|
||||||
|
class CSelectableComponent : public SComponent, public KeyShortcut
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool selected; //if true, this component is selected
|
||||||
|
|
||||||
|
bool customB; //TODO: comment me
|
||||||
|
SDL_Surface * border, *myBitmap;
|
||||||
|
boost::function<void()> onSelect; //function called on selection change
|
||||||
|
|
||||||
|
void clickLeft(boost::logic::tribool down); //call-in
|
||||||
|
void init(SDL_Surface * Border);
|
||||||
|
CSelectableComponent(Etype Type, int Sub, int Val, boost::function<void()> OnSelect = 0, SDL_Surface * Border=NULL); //c-tor
|
||||||
|
CSelectableComponent(const Component &c, boost::function<void()> OnSelect = 0, SDL_Surface * Border=NULL); //c-tor
|
||||||
|
~CSelectableComponent(); //d-tor
|
||||||
|
virtual void show(SDL_Surface * to);
|
||||||
|
void activate();
|
||||||
|
void deactivate();
|
||||||
|
void select(bool on);
|
||||||
|
SDL_Surface * getImg(); //returns myBitmap
|
||||||
|
};
|
||||||
|
class CGarrisonInt;
|
||||||
|
class CGarrisonSlot : public ClickableL, public ClickableR, public Hoverable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CGarrisonInt *owner;
|
||||||
|
const CCreature * creature; //creature in slot
|
||||||
|
int count; //number of creatures
|
||||||
|
int upg; //0 - up garrison, 1 - down garrison
|
||||||
|
bool active; //TODO: comment me
|
||||||
|
|
||||||
|
virtual void hover (bool on); //call-in
|
||||||
|
const CArmedInstance * getObj();
|
||||||
|
void clickRight (boost::logic::tribool down);
|
||||||
|
void clickLeft(boost::logic::tribool down);
|
||||||
|
void activate();
|
||||||
|
void deactivate();
|
||||||
|
void show(SDL_Surface * to);
|
||||||
|
CGarrisonSlot(CGarrisonInt *Owner, int x, int y, int IID, int Upg=0, const CCreature * Creature=NULL, int Count=0);
|
||||||
|
~CGarrisonSlot(); //d-tor
|
||||||
|
};
|
||||||
|
|
||||||
|
class CGarrisonInt :public CIntObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int interx, intery; //intervals between slots
|
||||||
|
CGarrisonSlot *highlighted; //choosen slot
|
||||||
|
|
||||||
|
SDL_Surface *&sur; //TODO: comment me
|
||||||
|
int offx, offy, p2; //TODO: comment me
|
||||||
|
bool ignoreEvent, update, active, splitting, pb;
|
||||||
|
|
||||||
|
const CCreatureSet *set1; //top set of creatures
|
||||||
|
const CCreatureSet *set2; //bottom set of creatures
|
||||||
|
|
||||||
|
std::vector<CGarrisonSlot*> *sup, *sdown; //slots of upper and lower garrison
|
||||||
|
const CArmedInstance *oup, *odown; //upper and lower garrisons (heroes or towns)
|
||||||
|
|
||||||
|
void activate();
|
||||||
|
void deactivate();
|
||||||
|
void show(SDL_Surface * to);
|
||||||
|
void activeteSlots();
|
||||||
|
void deactiveteSlots();
|
||||||
|
void deleteSlots();
|
||||||
|
void createSlots();
|
||||||
|
void recreateSlots();
|
||||||
|
|
||||||
|
void splitClick(); //handles click on split button
|
||||||
|
void splitStacks(int am2); //TODO: comment me
|
||||||
|
|
||||||
|
CGarrisonInt(int x, int y, int inx, int iny, SDL_Surface *&pomsur, int OX, int OY, const CArmedInstance *s1, const CArmedInstance *s2=NULL); //c-tor
|
||||||
|
~CGarrisonInt(); //d-tor
|
||||||
|
};
|
||||||
|
|
||||||
|
class CStatusBar
|
||||||
|
: public CIntObject, public IStatusBar
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SDL_Surface * bg; //background
|
||||||
|
int middlex, middley; //middle of statusbar
|
||||||
|
std::string current; //text currently printed
|
||||||
|
|
||||||
|
CStatusBar(int x, int y, std::string name="ADROLLVR.bmp", int maxw=-1); //c-tor
|
||||||
|
~CStatusBar(); //d-tor
|
||||||
|
void print(const std::string & text); //prints text and refreshes statusbar
|
||||||
|
void clear();//clears statusbar and refreshes
|
||||||
|
void show(SDL_Surface * to); //shows statusbar (with current text)
|
||||||
|
std::string getCurrent(); //getter for current
|
||||||
|
};
|
||||||
|
|
||||||
|
class CList
|
||||||
|
: public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public virtual CIntObject, public MotionInterested
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SDL_Surface * bg; //background bitmap
|
||||||
|
CDefHandler *arrup, *arrdo; //button arrows for scrolling list
|
||||||
|
SDL_Surface *empty, *selection;
|
||||||
|
SDL_Rect arrupp, arrdop; //positions of arrows
|
||||||
|
int posw, posh; //position width/height
|
||||||
|
int selected, //id of selected position, <0 if none
|
||||||
|
from;
|
||||||
|
const int SIZE; //size of list
|
||||||
|
boost::logic::tribool pressed; //true=up; false=down; indeterminate=none
|
||||||
|
|
||||||
|
CList(int Size = 5); //c-tor
|
||||||
|
void clickLeft(boost::logic::tribool down);
|
||||||
|
void activate();
|
||||||
|
void deactivate();
|
||||||
|
virtual void mouseMoved (const SDL_MouseMotionEvent & sEvent)=0; //call-in
|
||||||
|
virtual void genList()=0;
|
||||||
|
virtual void select(int which)=0;
|
||||||
|
virtual void draw(SDL_Surface * to)=0;
|
||||||
|
};
|
||||||
|
class CHeroList
|
||||||
|
: public CList
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CDefHandler *mobile, *mana; //mana and movement indicators
|
||||||
|
std::vector<std::pair<const CGHeroInstance*, CPath *> > items;
|
||||||
|
int posmobx, posporx, posmanx, posmoby, pospory, posmany;
|
||||||
|
|
||||||
|
CHeroList(int Size); //c-tor
|
||||||
|
int getPosOfHero(const CArmedInstance* h); //hero's position on list
|
||||||
|
void genList();
|
||||||
|
void select(int which); //call-in
|
||||||
|
void mouseMoved (const SDL_MouseMotionEvent & sEvent); //call-in
|
||||||
|
void clickLeft(boost::logic::tribool down); //call-in
|
||||||
|
void clickRight(boost::logic::tribool down); //call-in
|
||||||
|
void hover (bool on); //call-in
|
||||||
|
void keyPressed (const SDL_KeyboardEvent & key); //call-in
|
||||||
|
void updateHList(const CGHeroInstance *toRemove=NULL); //removes specific hero from the list or recreates it
|
||||||
|
void updateMove(const CGHeroInstance* which); //draws move points bar
|
||||||
|
void redrawAllOne(int which); //not imeplemented
|
||||||
|
void draw(SDL_Surface * to);
|
||||||
|
void init();
|
||||||
|
};
|
||||||
|
|
||||||
|
class CTownList
|
||||||
|
: public CList
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
boost::function<void()> fun; //function called on selection change
|
||||||
|
std::vector<const CGTownInstance*> items; //towns on list
|
||||||
|
int posporx,pospory;
|
||||||
|
|
||||||
|
CTownList(int Size, int x, int y, std::string arrupg, std::string arrdog); //c-tor
|
||||||
|
~CTownList(); //d-tor
|
||||||
|
void genList();
|
||||||
|
void select(int which); //call-in
|
||||||
|
void mouseMoved (const SDL_MouseMotionEvent & sEvent); //call-in
|
||||||
|
void clickLeft(boost::logic::tribool down); //call-in
|
||||||
|
void clickRight(boost::logic::tribool down); //call-in
|
||||||
|
void hover (bool on); //call-in
|
||||||
|
void keyPressed (const SDL_KeyboardEvent & key); //call-in
|
||||||
|
void draw(SDL_Surface * to);
|
||||||
|
};
|
||||||
|
|
||||||
|
class CCreaturePic //draws picture with creature on background, use nextFrame=true to get animation
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CCreature *c; //which creature's picture
|
||||||
|
bool big; //big => 100x130; !big => 100x120
|
||||||
|
CCreatureAnimation *anim; //displayed animation
|
||||||
|
CCreaturePic(CCreature *cre, bool Big=true); //c-tor
|
||||||
|
~CCreaturePic(); //d-tor
|
||||||
|
int blitPic(SDL_Surface *to, int x, int y, bool nextFrame); //prints creature on screen
|
||||||
|
SDL_Surface * getPic(bool nextFrame); //returns frame of animation
|
||||||
|
};
|
||||||
|
|
||||||
|
class CRecruitmentWindow : public IShowActivable, public ClickableL, public ClickableR
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct creinfo
|
||||||
|
{
|
||||||
|
SDL_Rect pos;
|
||||||
|
CCreaturePic *pic; //creature's animation
|
||||||
|
int ID, amount; //creature ID and available amount
|
||||||
|
std::vector<std::pair<int,int> > res; //res_id - cost_per_unit
|
||||||
|
};
|
||||||
|
std::vector<int> amounts; //how many creatures we can afford
|
||||||
|
std::vector<creinfo> creatures; //recruitable creatures
|
||||||
|
boost::function<void(int,int)> recruit; //void (int ID, int amount) <-- call to recruit creatures
|
||||||
|
CSlider *slider; //for selecting amount
|
||||||
|
AdventureMapButton *max, *buy, *cancel;
|
||||||
|
SDL_Surface *bitmap; //background
|
||||||
|
CStatusBar *bar;
|
||||||
|
int which; //which creature is active
|
||||||
|
|
||||||
|
void close();
|
||||||
|
void Max();
|
||||||
|
void Buy();
|
||||||
|
void Cancel();
|
||||||
|
void sliderMoved(int to);
|
||||||
|
void clickLeft(boost::logic::tribool down);
|
||||||
|
void clickRight(boost::logic::tribool down);
|
||||||
|
void activate();
|
||||||
|
void deactivate();
|
||||||
|
void show(SDL_Surface * to);
|
||||||
|
CRecruitmentWindow(const std::vector<std::pair<int,int> > & Creatures, const boost::function<void(int,int)> & Recruit); //creatures - pairs<creature_ID,amount> //c-tor
|
||||||
|
~CRecruitmentWindow(); //d-tor
|
||||||
|
};
|
||||||
|
|
||||||
|
class CSplitWindow : public IShowActivable, public KeyInterested, public ClickableL
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CGarrisonInt *gar;
|
||||||
|
CSlider *slider;
|
||||||
|
CCreaturePic *anim; //creature's animation
|
||||||
|
AdventureMapButton *ok, *cancel;
|
||||||
|
SDL_Surface *bitmap; //background
|
||||||
|
int a1, a2, c; //TODO: comment me
|
||||||
|
bool which; //which creature is selected
|
||||||
|
int last; //0/1/2 - at least one creature must be in the src/dst/both stacks; -1 - no restrictions
|
||||||
|
|
||||||
|
CSplitWindow(int cid, int max, CGarrisonInt *Owner, int Last = -1, int val=0); //c-tor; val - initial amount of second stack
|
||||||
|
~CSplitWindow(); //d-tor
|
||||||
|
void activate();
|
||||||
|
void split();
|
||||||
|
void close();
|
||||||
|
void deactivate();
|
||||||
|
void show(SDL_Surface * to);
|
||||||
|
void clickLeft(boost::logic::tribool down); //call-in
|
||||||
|
void keyPressed (const SDL_KeyboardEvent & key); //call-in
|
||||||
|
void sliderMoved(int to);
|
||||||
|
};
|
||||||
|
|
||||||
|
class CCreInfoWindow : public IShowActivable, public KeyInterested, public ClickableR
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//bool active; //TODO: comment me
|
||||||
|
int type;//0 - rclick popup; 1 - normal window
|
||||||
|
SDL_Surface *bitmap; //background
|
||||||
|
char anf; //animation counter
|
||||||
|
std::string count; //creature count in text format
|
||||||
|
|
||||||
|
boost::function<void()> dsm; //dismiss button callback
|
||||||
|
CCreaturePic *anim; //related creature's animation
|
||||||
|
CCreature *c; //related creature
|
||||||
|
std::vector<SComponent*> upgResCost; //cost of upgrade (if not possible then empty)
|
||||||
|
|
||||||
|
AdventureMapButton *dismiss, *upgrade, *ok;
|
||||||
|
CCreInfoWindow(int Cid, int Type, int creatureCount, StackState *State, boost::function<void()> Upg, boost::function<void()> Dsm, UpgradeInfo *ui); //c-tor
|
||||||
|
~CCreInfoWindow(); //d-tor
|
||||||
|
void activate();
|
||||||
|
void close();
|
||||||
|
void clickRight(boost::logic::tribool down); //call-in
|
||||||
|
void dismissF();
|
||||||
|
void keyPressed (const SDL_KeyboardEvent & key); //call-in
|
||||||
|
void deactivate();
|
||||||
|
void show(SDL_Surface * to);
|
||||||
|
};
|
||||||
|
|
||||||
|
class CLevelWindow : public IShowActivable, public CIntObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int heroType;
|
||||||
|
SDL_Surface *bitmap; //background
|
||||||
|
std::vector<CSelectableComponent *> comps; //skills to select
|
||||||
|
AdventureMapButton *ok;
|
||||||
|
boost::function<void(ui32)> cb;
|
||||||
|
|
||||||
|
void close();
|
||||||
|
CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback); //c-tor
|
||||||
|
~CLevelWindow(); //d-tor
|
||||||
|
void activate();
|
||||||
|
void deactivate();
|
||||||
|
void selectionChanged(unsigned to);
|
||||||
|
void show(SDL_Surface * to);
|
||||||
|
};
|
||||||
|
|
||||||
|
class CMinorResDataBar : public IShowable, public CIntObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SDL_Surface *bg; //background bitmap
|
||||||
|
void show(SDL_Surface * to);
|
||||||
|
CMinorResDataBar(); //c-tor
|
||||||
|
~CMinorResDataBar(); //d-tor
|
||||||
|
};
|
||||||
|
|
||||||
|
class CMarketplaceWindow : public IShowActivable, public CIntObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
class CTradeableItem : public ClickableL
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int type; //0 - res, 1 - artif big, 2 - artif small, 3 - player flag
|
||||||
|
int id;
|
||||||
|
bool left;
|
||||||
|
CFunctionList<void()> callback;
|
||||||
|
|
||||||
|
void activate();
|
||||||
|
void deactivate();
|
||||||
|
void show(SDL_Surface * to);
|
||||||
|
void clickLeft(boost::logic::tribool down);
|
||||||
|
SDL_Surface *getSurface();
|
||||||
|
CTradeableItem(int Type, int ID, bool Left);
|
||||||
|
};
|
||||||
|
|
||||||
|
SDL_Surface *bg; //background
|
||||||
|
std::vector<CTradeableItem*> left, right;
|
||||||
|
std::vector<std::string> rSubs; //offer caption
|
||||||
|
CTradeableItem *hLeft, *hRight; //highlighted items (NULL if no highlight)
|
||||||
|
|
||||||
|
int mode,//0 - res<->res; 1 - res<->plauer; 2 - buy artifact; 3 - sell artifact
|
||||||
|
r1, r2; //suggested amounts of traded resources
|
||||||
|
AdventureMapButton *ok, *max, *deal;
|
||||||
|
CSlider *slider; //for choosing amount to be exchanged
|
||||||
|
|
||||||
|
void activate();
|
||||||
|
void deactivate();
|
||||||
|
void show(SDL_Surface * to);
|
||||||
|
void setMax();
|
||||||
|
void sliderMoved(int to);
|
||||||
|
void makeDeal();
|
||||||
|
void selectionChanged(bool side); //true == left
|
||||||
|
CMarketplaceWindow(int Mode=0); //c-tor
|
||||||
|
~CMarketplaceWindow(); //d-tor
|
||||||
|
void setMode(int mode); //mode setter
|
||||||
|
void clear();
|
||||||
|
};
|
||||||
|
|
||||||
|
class CSystemOptionsWindow : public IShowActivable, public CIntObject
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
SDL_Surface * background; //background of window
|
||||||
|
AdventureMapButton *load, *save, *restart, *mainMenu, * quitGame, * backToMap; //load, restart and main menu are not used yet
|
||||||
|
CHighlightableButtonsGroup * heroMoveSpeed;
|
||||||
|
CHighlightableButtonsGroup * mapScrollSpeed;
|
||||||
|
CHighlightableButtonsGroup * musicVolume, * effectsVolume;
|
||||||
|
public:
|
||||||
|
CSystemOptionsWindow(const SDL_Rect & pos, CPlayerInterface * owner); //c-tor
|
||||||
|
~CSystemOptionsWindow(); //d-tor
|
||||||
|
|
||||||
|
//functions bound to buttons
|
||||||
|
void bsavef(); //save game
|
||||||
|
void bquitf(); //quit game
|
||||||
|
void breturnf(); //return to game
|
||||||
|
|
||||||
|
void activate();
|
||||||
|
void deactivate();
|
||||||
|
void show(SDL_Surface * to);
|
||||||
|
};
|
||||||
|
|
||||||
|
class CTavernWindow : public IShowActivable, public CIntObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
class HeroPortrait : public ClickableL, public ClickableR, public Hoverable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string hoverName;
|
||||||
|
vstd::assigner<int,int> as;
|
||||||
|
const CGHeroInstance *h;
|
||||||
|
void activate();
|
||||||
|
void deactivate();
|
||||||
|
void clickLeft(boost::logic::tribool down);
|
||||||
|
void clickRight(boost::logic::tribool down);
|
||||||
|
void hover (bool on);
|
||||||
|
HeroPortrait(int &sel, int id, int x, int y, const CGHeroInstance *H);
|
||||||
|
void show(SDL_Surface * to);
|
||||||
|
} h1, h2; //recruitable heroes
|
||||||
|
|
||||||
|
SDL_Surface *bg; //background
|
||||||
|
CStatusBar *bar; //tavern's internal status bar
|
||||||
|
int selected;//0 (left) or 1 (right)
|
||||||
|
|
||||||
|
AdventureMapButton *thiefGuild, *cancel, *recruit;
|
||||||
|
|
||||||
|
CTavernWindow(const CGHeroInstance *H1, const CGHeroInstance *H2, const std::string &gossip); //c-tor
|
||||||
|
~CTavernWindow(); //d-tor
|
||||||
|
|
||||||
|
void recruitb();
|
||||||
|
void close();
|
||||||
|
void activate();
|
||||||
|
void deactivate();
|
||||||
|
void show(SDL_Surface * to);
|
||||||
|
};
|
||||||
|
|
||||||
|
class CInGameConsole : public IShowActivable, public KeyInterested
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::list< std::pair< std::string, int > > texts; //<text to show, time of add>
|
||||||
|
std::vector< std::string > previouslyEntered; //previously entered texts, for up/down arrows to work
|
||||||
|
int prevEntDisp; //displayed entry from previouslyEntered - if none it's -1
|
||||||
|
int defaultTimeout; //timeout for new texts (in ms)
|
||||||
|
int maxDisplayedTexts; //hiw many texts can be displayed simultaneously
|
||||||
|
public:
|
||||||
|
std::string enteredText;
|
||||||
|
void activate();
|
||||||
|
void deactivate();
|
||||||
|
void show(SDL_Surface * to);
|
||||||
|
void print(const std::string &txt);
|
||||||
|
void keyPressed (const SDL_KeyboardEvent & key); //call-in
|
||||||
|
|
||||||
|
void startEnteringText();
|
||||||
|
void endEnteringText(bool printEnteredText);
|
||||||
|
void refreshEnteredText();
|
||||||
|
|
||||||
|
CInGameConsole(); //c-tor
|
||||||
|
};
|
||||||
|
|
||||||
|
class CGarrisonWindow : public CWindowWithGarrison, public CIntObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SDL_Surface *bg; //background surface
|
||||||
|
AdventureMapButton *split, *quit;
|
||||||
|
|
||||||
|
void close();
|
||||||
|
void activate();
|
||||||
|
void deactivate();
|
||||||
|
void show(SDL_Surface * to);
|
||||||
|
CGarrisonWindow(const CArmedInstance *up, const CGHeroInstance *down); //c-tor
|
||||||
|
~CGarrisonWindow(); //d-tor
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //__GUICLASSES_H__
|
@ -13,6 +13,7 @@
|
|||||||
#include "../hch/CSpellHandler.h"
|
#include "../hch/CSpellHandler.h"
|
||||||
#include "../hch/CSoundBase.h"
|
#include "../hch/CSoundBase.h"
|
||||||
#include "../mapHandler.h"
|
#include "../mapHandler.h"
|
||||||
|
#include "GUIClasses.h"
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#ifndef __VCMI_LIB_H__
|
#ifndef __VCMI_LIB_H__
|
||||||
#define __VCMI_LIB_H__
|
#define __VCMI_LIB_H__
|
||||||
#include "../global.h"
|
#include "../global.h"
|
||||||
#ifndef _MSC_VER
|
|
||||||
#include "../hch/CArtHandler.h"
|
#include "../hch/CArtHandler.h"
|
||||||
#include "../hch/CGeneralTextHandler.h"
|
#include "../hch/CGeneralTextHandler.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* VCMI_Lib.h, part of VCMI engine
|
* VCMI_Lib.h, part of VCMI engine
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include "../hch/CArtHandler.h"
|
#include "../hch/CArtHandler.h"
|
||||||
#include "../hch/CBuildingHandler.h"
|
#include "../hch/CBuildingHandler.h"
|
||||||
#include "../hch/CDefObjInfoHandler.h"
|
#include "../hch/CDefObjInfoHandler.h"
|
||||||
#include "../hch/CGeneralTextHandler.h"
|
|
||||||
#include "../hch/CHeroHandler.h"
|
#include "../hch/CHeroHandler.h"
|
||||||
#include "../hch/CObjectHandler.h"
|
#include "../hch/CObjectHandler.h"
|
||||||
#include "../hch/CSpellHandler.h"
|
#include "../hch/CSpellHandler.h"
|
||||||
@ -10,7 +9,6 @@
|
|||||||
#include "../CGameState.h"
|
#include "../CGameState.h"
|
||||||
#include "../lib/CondSh.h"
|
#include "../lib/CondSh.h"
|
||||||
#include "../lib/NetPacks.h"
|
#include "../lib/NetPacks.h"
|
||||||
#include "../lib/Connection.h"
|
|
||||||
#include "../lib/VCMI_Lib.h"
|
#include "../lib/VCMI_Lib.h"
|
||||||
#include "../map.h"
|
#include "../map.h"
|
||||||
#include "CGameHandler.h"
|
#include "CGameHandler.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user