mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-19 21:10:12 +02:00
heroWindow is now show/hideable ;]
This commit is contained in:
parent
e62cfed95f
commit
2ce033aba9
@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
#include "SDL_Extensions.h"
|
||||
#include "hch\CDefHandler.h"
|
||||
#include "CGameInfo.h"
|
||||
#include "hch\CLodHandler.h"
|
||||
template <typename T>
|
||||
AdventureMapButton<T>::AdventureMapButton ()
|
||||
{
|
||||
|
@ -25,6 +25,7 @@ using namespace CSDL_Ext;
|
||||
CAdvMapInt::~CAdvMapInt()
|
||||
{
|
||||
SDL_FreeSurface(bg);
|
||||
delete heroWindow;
|
||||
}
|
||||
void CList::activate()
|
||||
{
|
||||
@ -1277,7 +1278,7 @@ endTurn(CGI->preth->advEndTurn.first,CGI->preth->advEndTurn.second,
|
||||
//townList.init();
|
||||
townList.genList();
|
||||
|
||||
heroWindow = CHeroWindow();
|
||||
heroWindow = new CHeroWindow(this->player);
|
||||
|
||||
gems.push_back(CGI->spriteh->giveDef("agemLL.def"));
|
||||
gems.push_back(CGI->spriteh->giveDef("agemLR.def"));
|
||||
|
@ -237,7 +237,7 @@ public:
|
||||
CTownList townList;
|
||||
CInfoBar infoBar;
|
||||
|
||||
CHeroWindow heroWindow;
|
||||
CHeroWindow * heroWindow;
|
||||
|
||||
struct CurrentSelection
|
||||
{
|
||||
|
@ -2,21 +2,27 @@
|
||||
#include "CHeroWindow.h"
|
||||
#include "SDL.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include "CAdvmapInterface.h"
|
||||
#include "AdventureMapButton.h"
|
||||
|
||||
extern SDL_Surface * ekran;
|
||||
|
||||
CHeroWindow::CHeroWindow()
|
||||
CHeroWindow::CHeroWindow(int playerColor)
|
||||
{
|
||||
background = SDL_LoadBMP("Data\\HEROSCR4.bmp");
|
||||
pos.x = 0;
|
||||
pos.y = 0;
|
||||
CSDL_Ext::blueToPlayersAdv(background, playerColor);
|
||||
pos.x = 65;
|
||||
pos.y = 8;
|
||||
pos.h = background->h;
|
||||
pos.w = background->w;
|
||||
|
||||
quitButton = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::quit, 674, 524, "hsbtns.def", this);
|
||||
}
|
||||
|
||||
CHeroWindow::~CHeroWindow()
|
||||
{
|
||||
SDL_FreeSurface(background);
|
||||
delete quitButton;
|
||||
}
|
||||
|
||||
void CHeroWindow::show(SDL_Surface *to)
|
||||
@ -24,9 +30,28 @@ void CHeroWindow::show(SDL_Surface *to)
|
||||
if(!to)
|
||||
to=ekran;
|
||||
blitAt(background,pos.x,pos.y,to);
|
||||
quitButton->show();
|
||||
}
|
||||
|
||||
void CHeroWindow::setHero(const CGHeroInstance *hero)
|
||||
{
|
||||
curHero = hero;
|
||||
}
|
||||
}
|
||||
|
||||
void CHeroWindow::quit()
|
||||
{
|
||||
for(int i=0; i<LOCPLINT->objsToBlit.size(); ++i)
|
||||
{
|
||||
if( dynamic_cast<CHeroWindow*>( LOCPLINT->objsToBlit[i] ) )
|
||||
{
|
||||
LOCPLINT->objsToBlit.erase(LOCPLINT->objsToBlit.begin()+i);
|
||||
}
|
||||
}
|
||||
quitButton->deactivate();
|
||||
LOCPLINT->adventureInt->show();
|
||||
}
|
||||
|
||||
void CHeroWindow::activate()
|
||||
{
|
||||
quitButton->activate();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "CPlayerInterface.h"
|
||||
|
||||
template <typename T> class AdventureMapButton;
|
||||
class SDL_Surface;
|
||||
class CGHeroInstance;
|
||||
|
||||
@ -8,9 +9,14 @@ class CHeroWindow: public IShowable, public virtual CIntObject
|
||||
{
|
||||
SDL_Surface * background;
|
||||
const CGHeroInstance * curHero;
|
||||
|
||||
//buttons
|
||||
AdventureMapButton<CHeroWindow> * quitButton;
|
||||
public:
|
||||
CHeroWindow(); //c-tor
|
||||
CHeroWindow(int playerColor); //c-tor
|
||||
~CHeroWindow(); //d-tor
|
||||
void setHero(const CGHeroInstance * hero); //sets main displayed hero
|
||||
void activate(); //activates hero window;
|
||||
virtual void show(SDL_Surface * to = NULL); //shows hero window
|
||||
void quit(); //stops displaying hero window
|
||||
};
|
@ -1569,6 +1569,8 @@ void CPlayerInterface::tileHidden(int3 pos)
|
||||
}
|
||||
void CPlayerInterface::openHeroWindow(const CGHeroInstance *hero)
|
||||
{
|
||||
adventureInt->heroWindow.setHero(hero);
|
||||
adventureInt->heroWindow.show();
|
||||
adventureInt->heroWindow->setHero(hero);
|
||||
this->objsToBlit.push_back(adventureInt->heroWindow);
|
||||
adventureInt->heroWindow->activate();
|
||||
adventureInt->hide();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user