mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-15 01:24:45 +02:00
* partially done spell window
This commit is contained in:
@ -25,6 +25,7 @@
|
||||
#include "hch/CObjectHandler.h"
|
||||
#include <boost/thread.hpp>
|
||||
#include "map.h"
|
||||
#include "client/CSpellWindow.h"
|
||||
#pragma warning (disable : 4355)
|
||||
extern TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX; //fonts
|
||||
|
||||
@ -1001,6 +1002,14 @@ void CAdvMapInt::fmoveHero()
|
||||
}
|
||||
void CAdvMapInt::fshowSpellbok()
|
||||
{
|
||||
if (selection->ID!=HEROI_TYPE) //checking necessary values
|
||||
return;
|
||||
|
||||
LOCPLINT->curint->deactivate();
|
||||
|
||||
CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, 90, 2), ((const CGHeroInstance*)LOCPLINT->adventureInt->selection));
|
||||
spellWindow->activate();
|
||||
LOCPLINT->objsToBlit.push_back(spellWindow);
|
||||
}
|
||||
void CAdvMapInt::fadventureOPtions()
|
||||
{
|
||||
|
113
client/CSpellWindow.cpp
Normal file
113
client/CSpellWindow.cpp
Normal file
@ -0,0 +1,113 @@
|
||||
#include "CSpellWindow.h"
|
||||
#include "client/Graphics.h"
|
||||
#include "hch/CDefHandler.h"
|
||||
#include "hch/CObjectHandler.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include <boost/bind.hpp>
|
||||
#include <sstream>
|
||||
|
||||
extern SDL_Surface * screen;
|
||||
extern SDL_Color tytulowy, zwykly ;
|
||||
extern TTF_Font *GEOR16;
|
||||
|
||||
ClickableArea::ClickableArea(SDL_Rect &myRect, boost::function<void()> func)
|
||||
{
|
||||
pos = myRect;
|
||||
myFunc = func;
|
||||
}
|
||||
|
||||
void ClickableArea::clickLeft(boost::logic::tribool down)
|
||||
{
|
||||
if(!down)
|
||||
{
|
||||
myFunc();
|
||||
}
|
||||
}
|
||||
|
||||
void ClickableArea::activate()
|
||||
{
|
||||
ClickableL::activate();
|
||||
}
|
||||
void ClickableArea::deactivate()
|
||||
{
|
||||
ClickableL::deactivate();
|
||||
}
|
||||
|
||||
CSpellWindow::CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHero): selectedTab(4)
|
||||
{
|
||||
pos = myRect;
|
||||
background = BitmapHandler::loadBitmap("SpelBack.bmp");
|
||||
graphics->blueToPlayersAdv(background, myHero->tempOwner);
|
||||
|
||||
std::stringstream mana;
|
||||
mana<<myHero->mana;
|
||||
CSDL_Ext::printAtMiddle(mana.str(), 434, 425, GEOR16, tytulowy, background);
|
||||
|
||||
leftCorner = BitmapHandler::loadBitmap("SpelTrnL.bmp");
|
||||
rightCorner = BitmapHandler::loadBitmap("SpelTrnL.bmp");
|
||||
spells = CDefHandler::giveDef("Spells.def");
|
||||
spellTab = CDefHandler::giveDef("SpelTab.def");
|
||||
schools = CDefHandler::giveDef("Schools.def");
|
||||
schoolW = CDefHandler::giveDef("SplevW.def");
|
||||
schoolE = CDefHandler::giveDef("SplevE.def");
|
||||
schoolF = CDefHandler::giveDef("SplevF.def");
|
||||
schoolA = CDefHandler::giveDef("SplevA.def");
|
||||
|
||||
exitBtn = new ClickableArea(genRect(45, 35, 569, 407), boost::bind(&CSpellWindow::fexitb, this));
|
||||
statusBar = new CStatusBar(97, 571, "Spelroll.bmp");
|
||||
}
|
||||
|
||||
CSpellWindow::~CSpellWindow()
|
||||
{
|
||||
SDL_FreeSurface(background);
|
||||
SDL_FreeSurface(leftCorner);
|
||||
SDL_FreeSurface(rightCorner);
|
||||
delete spells;
|
||||
delete spellTab;
|
||||
delete schools;
|
||||
delete schoolW;
|
||||
delete schoolE;
|
||||
delete schoolF;
|
||||
delete schoolA;
|
||||
|
||||
delete exitBtn;
|
||||
delete statusBar;
|
||||
}
|
||||
|
||||
void CSpellWindow::fexitb()
|
||||
{
|
||||
deactivate();
|
||||
|
||||
for(int g=0; g<LOCPLINT->objsToBlit.size(); ++g)
|
||||
{
|
||||
if(dynamic_cast<CSpellWindow*>(LOCPLINT->objsToBlit[g]))
|
||||
{
|
||||
LOCPLINT->objsToBlit.erase(LOCPLINT->objsToBlit.begin()+g);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete this;
|
||||
LOCPLINT->curint->activate();
|
||||
}
|
||||
|
||||
void CSpellWindow::show(SDL_Surface *to)
|
||||
{
|
||||
if(to == NULL) //evaluating to
|
||||
to = screen;
|
||||
|
||||
SDL_BlitSurface(background, NULL, to, &pos);
|
||||
blitAt(spellTab->ourImages[selectedTab].bitmap, 614, 96, to);
|
||||
|
||||
statusBar->show();
|
||||
}
|
||||
|
||||
void CSpellWindow::activate()
|
||||
{
|
||||
exitBtn->activate();
|
||||
}
|
||||
|
||||
void CSpellWindow::deactivate()
|
||||
{
|
||||
exitBtn->deactivate();
|
||||
}
|
43
client/CSpellWindow.h
Normal file
43
client/CSpellWindow.h
Normal file
@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
#include "global.h"
|
||||
#include "CPlayerInterface.h"
|
||||
|
||||
struct SDL_Surface;
|
||||
class CDefHandler;
|
||||
struct SDL_Rect;
|
||||
class CGHeroInstance;
|
||||
|
||||
class ClickableArea : public ClickableL
|
||||
{
|
||||
private:
|
||||
boost::function<void()> myFunc;
|
||||
public:
|
||||
void clickLeft(boost::logic::tribool down);
|
||||
void activate();
|
||||
void deactivate();
|
||||
|
||||
ClickableArea(SDL_Rect & myRect, boost::function<void()> func);//c-tor
|
||||
};
|
||||
|
||||
class CSpellWindow : public IShowActivable, public CIntObject
|
||||
{
|
||||
private:
|
||||
SDL_Surface * background, * leftCorner, * rightCorner;
|
||||
CDefHandler * spells, //pictures of spells
|
||||
* spellTab, //school select
|
||||
* schools, //schools' pictures
|
||||
* schoolW, * schoolE, * schoolF, * schoolA; //schools' 'borders'
|
||||
|
||||
ClickableArea * exitBtn;
|
||||
CStatusBar * statusBar;
|
||||
public:
|
||||
Uint8 selectedTab;
|
||||
CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHero); //c-tor
|
||||
~CSpellWindow(); //d-tor
|
||||
|
||||
void fexitb();
|
||||
|
||||
void activate();
|
||||
void deactivate();
|
||||
void show(SDL_Surface * to = NULL);
|
||||
};
|
Reference in New Issue
Block a user