mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
second part of spellbook
This commit is contained in:
parent
df03f4ef78
commit
e4d8d66de1
@ -2,6 +2,9 @@
|
|||||||
#include "client/Graphics.h"
|
#include "client/Graphics.h"
|
||||||
#include "hch/CDefHandler.h"
|
#include "hch/CDefHandler.h"
|
||||||
#include "hch/CObjectHandler.h"
|
#include "hch/CObjectHandler.h"
|
||||||
|
#include "hch/CPreGameTextHandler.h"
|
||||||
|
#include "CAdvmapInterface.h"
|
||||||
|
#include "CGameInfo.h"
|
||||||
#include "SDL_Extensions.h"
|
#include "SDL_Extensions.h"
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -10,27 +13,52 @@ extern SDL_Surface * screen;
|
|||||||
extern SDL_Color tytulowy, zwykly ;
|
extern SDL_Color tytulowy, zwykly ;
|
||||||
extern TTF_Font *GEOR16;
|
extern TTF_Font *GEOR16;
|
||||||
|
|
||||||
ClickableArea::ClickableArea(SDL_Rect &myRect, boost::function<void()> func)
|
SpellbookInteractiveArea::SpellbookInteractiveArea(SDL_Rect & myRect, boost::function<void()> funcL, std::string textR, boost::function<void()> funcHon, boost::function<void()> funcHoff)
|
||||||
{
|
{
|
||||||
pos = myRect;
|
pos = myRect;
|
||||||
myFunc = func;
|
onLeft = funcL;
|
||||||
|
textOnRclick = textR;
|
||||||
|
onHoverOn = funcHon;
|
||||||
|
onHoverOff = funcHoff;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClickableArea::clickLeft(boost::logic::tribool down)
|
void SpellbookInteractiveArea::clickLeft(boost::logic::tribool down)
|
||||||
{
|
{
|
||||||
if(!down)
|
if(!down)
|
||||||
{
|
{
|
||||||
myFunc();
|
onLeft();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClickableArea::activate()
|
void SpellbookInteractiveArea::clickRight(boost::logic::tribool down)
|
||||||
|
{
|
||||||
|
LOCPLINT->adventureInt->handleRightClick(textOnRclick, down, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpellbookInteractiveArea::hover(bool on)
|
||||||
|
{
|
||||||
|
Hoverable::hover(on);
|
||||||
|
if(on)
|
||||||
|
{
|
||||||
|
onHoverOn();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
onHoverOff();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpellbookInteractiveArea::activate()
|
||||||
{
|
{
|
||||||
ClickableL::activate();
|
ClickableL::activate();
|
||||||
|
ClickableR::activate();
|
||||||
|
Hoverable::activate();
|
||||||
}
|
}
|
||||||
void ClickableArea::deactivate()
|
void SpellbookInteractiveArea::deactivate()
|
||||||
{
|
{
|
||||||
ClickableL::deactivate();
|
ClickableL::deactivate();
|
||||||
|
ClickableR::deactivate();
|
||||||
|
Hoverable::deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSpellWindow::CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHero): selectedTab(4)
|
CSpellWindow::CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHero): selectedTab(4)
|
||||||
@ -53,9 +81,19 @@ CSpellWindow::CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHer
|
|||||||
schoolF = CDefHandler::giveDef("SplevF.def");
|
schoolF = CDefHandler::giveDef("SplevF.def");
|
||||||
schoolA = CDefHandler::giveDef("SplevA.def");
|
schoolA = CDefHandler::giveDef("SplevA.def");
|
||||||
|
|
||||||
SDL_Rect temp_rect = genRect(45, 35, 569, 407);
|
|
||||||
exitBtn = new ClickableArea(temp_rect, boost::bind(&CSpellWindow::fexitb, this));
|
|
||||||
statusBar = new CStatusBar(97, 571, "Spelroll.bmp");
|
statusBar = new CStatusBar(97, 571, "Spelroll.bmp");
|
||||||
|
exitBtn = new SpellbookInteractiveArea(genRect(45, 35, 569, 407), boost::bind(&CSpellWindow::fexitb, this), CGI->preth->zelp[460].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[460].first)), boost::bind(&CStatusBar::clear, statusBar));
|
||||||
|
battleSpells = new SpellbookInteractiveArea(genRect(45, 35, 311, 407), boost::bind(&CSpellWindow::fbattleSpellsb, this), CGI->preth->zelp[453].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[453].first)), boost::bind(&CStatusBar::clear, statusBar));
|
||||||
|
adventureSpells = new SpellbookInteractiveArea(genRect(45, 35, 445, 407), boost::bind(&CSpellWindow::fadvSpellsb, this), CGI->preth->zelp[452].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[452].first)), boost::bind(&CStatusBar::clear, statusBar));
|
||||||
|
manaPoints = new SpellbookInteractiveArea(genRect(45, 35, 508, 407), boost::bind(&CSpellWindow::fmanaPtsb, this), CGI->preth->zelp[459].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[459].first)), boost::bind(&CStatusBar::clear, statusBar));
|
||||||
|
|
||||||
|
selectSpellsA = new SpellbookInteractiveArea(genRect(36, 56, 639, 96), boost::bind(&CSpellWindow::fspellsAb, this), CGI->preth->zelp[454].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[454].first)), boost::bind(&CStatusBar::clear, statusBar));
|
||||||
|
selectSpellsE = new SpellbookInteractiveArea(genRect(36, 56, 639, 153), boost::bind(&CSpellWindow::fspellsEb, this), CGI->preth->zelp[457].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[457].first)), boost::bind(&CStatusBar::clear, statusBar));
|
||||||
|
selectSpellsF = new SpellbookInteractiveArea(genRect(36, 56, 639, 212), boost::bind(&CSpellWindow::fspellsFb, this), CGI->preth->zelp[455].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[455].first)), boost::bind(&CStatusBar::clear, statusBar));
|
||||||
|
selectSpellsW = new SpellbookInteractiveArea(genRect(36, 56, 639, 272), boost::bind(&CSpellWindow::fspellsWb, this), CGI->preth->zelp[456].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[456].first)), boost::bind(&CStatusBar::clear, statusBar));
|
||||||
|
selectSpellsAll = new SpellbookInteractiveArea(genRect(36, 56, 639, 332), boost::bind(&CSpellWindow::fspellsAllb, this), CGI->preth->zelp[458].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[458].first)), boost::bind(&CStatusBar::clear, statusBar));
|
||||||
}
|
}
|
||||||
|
|
||||||
CSpellWindow::~CSpellWindow()
|
CSpellWindow::~CSpellWindow()
|
||||||
@ -72,7 +110,16 @@ CSpellWindow::~CSpellWindow()
|
|||||||
delete schoolA;
|
delete schoolA;
|
||||||
|
|
||||||
delete exitBtn;
|
delete exitBtn;
|
||||||
|
delete battleSpells;
|
||||||
|
delete adventureSpells;
|
||||||
|
delete manaPoints;
|
||||||
delete statusBar;
|
delete statusBar;
|
||||||
|
|
||||||
|
delete selectSpellsA;
|
||||||
|
delete selectSpellsE;
|
||||||
|
delete selectSpellsF;
|
||||||
|
delete selectSpellsW;
|
||||||
|
delete selectSpellsAll;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSpellWindow::fexitb()
|
void CSpellWindow::fexitb()
|
||||||
@ -92,6 +139,43 @@ void CSpellWindow::fexitb()
|
|||||||
LOCPLINT->curint->activate();
|
LOCPLINT->curint->activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSpellWindow::fadvSpellsb()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSpellWindow::fbattleSpellsb()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSpellWindow::fmanaPtsb()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSpellWindow::fspellsAb()
|
||||||
|
{
|
||||||
|
selectedTab = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSpellWindow::fspellsEb()
|
||||||
|
{
|
||||||
|
selectedTab = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSpellWindow::fspellsFb()
|
||||||
|
{
|
||||||
|
selectedTab = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSpellWindow::fspellsWb()
|
||||||
|
{
|
||||||
|
selectedTab = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSpellWindow::fspellsAllb()
|
||||||
|
{
|
||||||
|
selectedTab = 4;
|
||||||
|
}
|
||||||
|
|
||||||
void CSpellWindow::show(SDL_Surface *to)
|
void CSpellWindow::show(SDL_Surface *to)
|
||||||
{
|
{
|
||||||
if(to == NULL) //evaluating to
|
if(to == NULL) //evaluating to
|
||||||
@ -106,9 +190,27 @@ void CSpellWindow::show(SDL_Surface *to)
|
|||||||
void CSpellWindow::activate()
|
void CSpellWindow::activate()
|
||||||
{
|
{
|
||||||
exitBtn->activate();
|
exitBtn->activate();
|
||||||
|
battleSpells->activate();
|
||||||
|
adventureSpells->activate();
|
||||||
|
manaPoints->activate();
|
||||||
|
|
||||||
|
selectSpellsA->activate();
|
||||||
|
selectSpellsE->activate();
|
||||||
|
selectSpellsF->activate();
|
||||||
|
selectSpellsW->activate();
|
||||||
|
selectSpellsAll->activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSpellWindow::deactivate()
|
void CSpellWindow::deactivate()
|
||||||
{
|
{
|
||||||
exitBtn->deactivate();
|
exitBtn->deactivate();
|
||||||
|
battleSpells->deactivate();
|
||||||
|
adventureSpells->deactivate();
|
||||||
|
manaPoints->deactivate();
|
||||||
|
|
||||||
|
selectSpellsA->deactivate();
|
||||||
|
selectSpellsE->deactivate();
|
||||||
|
selectSpellsF->deactivate();
|
||||||
|
selectSpellsW->deactivate();
|
||||||
|
selectSpellsAll->deactivate();
|
||||||
}
|
}
|
||||||
|
@ -7,16 +7,21 @@ class CDefHandler;
|
|||||||
struct SDL_Rect;
|
struct SDL_Rect;
|
||||||
class CGHeroInstance;
|
class CGHeroInstance;
|
||||||
|
|
||||||
class ClickableArea : public ClickableL
|
class SpellbookInteractiveArea : public ClickableL, public ClickableR, public Hoverable
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
boost::function<void()> myFunc;
|
boost::function<void()> onLeft;
|
||||||
|
std::string textOnRclick;
|
||||||
|
boost::function<void()> onHoverOn;
|
||||||
|
boost::function<void()> onHoverOff;
|
||||||
public:
|
public:
|
||||||
void clickLeft(boost::logic::tribool down);
|
void clickLeft(boost::logic::tribool down);
|
||||||
|
void clickRight(boost::logic::tribool down);
|
||||||
|
void hover(bool on);
|
||||||
void activate();
|
void activate();
|
||||||
void deactivate();
|
void deactivate();
|
||||||
|
|
||||||
ClickableArea(SDL_Rect & myRect, boost::function<void()> func);//c-tor
|
SpellbookInteractiveArea(SDL_Rect & myRect, boost::function<void()> funcL, std::string textR, boost::function<void()> funcHon, boost::function<void()> funcHoff);//c-tor
|
||||||
};
|
};
|
||||||
|
|
||||||
class CSpellWindow : public IShowActivable, public CIntObject
|
class CSpellWindow : public IShowActivable, public CIntObject
|
||||||
@ -28,14 +33,24 @@ private:
|
|||||||
* schools, //schools' pictures
|
* schools, //schools' pictures
|
||||||
* schoolW, * schoolE, * schoolF, * schoolA; //schools' 'borders'
|
* schoolW, * schoolE, * schoolF, * schoolA; //schools' 'borders'
|
||||||
|
|
||||||
ClickableArea * exitBtn;
|
SpellbookInteractiveArea * exitBtn, * battleSpells, * adventureSpells, * manaPoints;
|
||||||
|
SpellbookInteractiveArea * selectSpellsA, * selectSpellsE, * selectSpellsF, * selectSpellsW, * selectSpellsAll;
|
||||||
CStatusBar * statusBar;
|
CStatusBar * statusBar;
|
||||||
|
Uint8 selectedTab; // 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic, 4 - all schools
|
||||||
public:
|
public:
|
||||||
Uint8 selectedTab;
|
|
||||||
CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHero); //c-tor
|
CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHero); //c-tor
|
||||||
~CSpellWindow(); //d-tor
|
~CSpellWindow(); //d-tor
|
||||||
|
|
||||||
void fexitb();
|
void fexitb();
|
||||||
|
void fadvSpellsb();
|
||||||
|
void fbattleSpellsb();
|
||||||
|
void fmanaPtsb();
|
||||||
|
|
||||||
|
void fspellsAb();
|
||||||
|
void fspellsEb();
|
||||||
|
void fspellsFb();
|
||||||
|
void fspellsWb();
|
||||||
|
void fspellsAllb();
|
||||||
|
|
||||||
void activate();
|
void activate();
|
||||||
void deactivate();
|
void deactivate();
|
||||||
|
Loading…
Reference in New Issue
Block a user