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