mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
* right click popups with infoboxes for heroes/towns lists
* separation activate/show functions in advmapint
This commit is contained in:
parent
8b5a50f619
commit
dbf3b8d08e
@ -283,6 +283,19 @@ void CTownList<T>::clickRight(tribool down)
|
||||
{
|
||||
LOCPLINT->adventureInt->handleRightClick(CGI->preth->zelp[307].second,down,this);
|
||||
}
|
||||
//if not buttons then towns
|
||||
int hx = LOCPLINT->current->motion.x, hy = LOCPLINT->current->motion.y;
|
||||
hx-=pos.x;
|
||||
hy-=pos.y; hy-=arrup->ourImages[0].bitmap->h;
|
||||
float ny = (float)hy/(float)32;
|
||||
if ((ny>5 || ny<0) || (from+ny>=items.size()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//show popup
|
||||
CInfoPopup * ip = new CInfoPopup(LOCPLINT->townWins[items[from+ny]->identifier],LOCPLINT->current->motion.x-LOCPLINT->townWins[items[from+ny]->identifier]->w,LOCPLINT->current->motion.y-LOCPLINT->townWins[items[from+ny]->identifier]->h,false);
|
||||
ip->activate();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -920,7 +920,23 @@ void CAdvMapInt::fendTurn()
|
||||
|
||||
void CAdvMapInt::activate()
|
||||
{
|
||||
//todo - docelowo wartoby rozdzielic czesc odpowiedzialna za wyswietlanie i aktywacje
|
||||
LOCPLINT->curint = this;
|
||||
LOCPLINT->statusbar = &statusbar;
|
||||
kingOverview.activate();
|
||||
underground.activate();
|
||||
questlog.activate();
|
||||
sleepWake.activate();
|
||||
moveHero.activate();
|
||||
spellbook.activate();
|
||||
sysOptions.activate();
|
||||
advOptions.activate();
|
||||
nextHero.activate();
|
||||
endTurn.activate();
|
||||
|
||||
minimap.activate();
|
||||
heroList.activate();
|
||||
townList.activate();
|
||||
terrain.activate();
|
||||
show();
|
||||
}
|
||||
void CAdvMapInt::deactivate()
|
||||
@ -929,38 +945,22 @@ void CAdvMapInt::deactivate()
|
||||
}
|
||||
void CAdvMapInt::show()
|
||||
{
|
||||
LOCPLINT->curint = this;
|
||||
LOCPLINT->statusbar = &statusbar;
|
||||
blitAt(bg,0,0);
|
||||
|
||||
kingOverview.show();
|
||||
kingOverview.activate();
|
||||
underground.show();
|
||||
underground.activate();
|
||||
questlog.show();
|
||||
questlog.activate();
|
||||
sleepWake.show();
|
||||
sleepWake.activate();
|
||||
moveHero.show();
|
||||
moveHero.activate();
|
||||
spellbook.show();
|
||||
spellbook.activate();
|
||||
advOptions.show();
|
||||
advOptions.activate();
|
||||
sysOptions.show();
|
||||
sysOptions.activate();
|
||||
nextHero.show();
|
||||
nextHero.activate();
|
||||
endTurn.show();
|
||||
endTurn.activate();
|
||||
|
||||
minimap.activate();
|
||||
minimap.draw();
|
||||
heroList.activate();
|
||||
heroList.draw();
|
||||
townList.activate();
|
||||
townList.draw();
|
||||
terrain.activate();
|
||||
update();
|
||||
|
||||
resdatabar.draw();
|
||||
|
@ -276,7 +276,7 @@ void CCastleInterface::close()
|
||||
LOCPLINT->objsToBlit.erase(std::find(LOCPLINT->objsToBlit.begin(),LOCPLINT->objsToBlit.end(),this));
|
||||
deactivate();
|
||||
LOCPLINT->castleInt = NULL;
|
||||
LOCPLINT->adventureInt->show();
|
||||
LOCPLINT->adventureInt->activate();
|
||||
delete this;
|
||||
}
|
||||
void CCastleInterface::splitF()
|
||||
@ -292,6 +292,7 @@ void CCastleInterface::showAll(SDL_Surface * to)
|
||||
LOCPLINT->adventureInt->resdatabar.draw();
|
||||
townlist->draw();
|
||||
|
||||
garr->show();
|
||||
int pom;
|
||||
|
||||
//draw fort icon
|
||||
@ -381,7 +382,6 @@ void CCastleInterface::show(SDL_Surface * to)
|
||||
{
|
||||
if (!to)
|
||||
to=ekran;
|
||||
garr->show();
|
||||
count++;
|
||||
if(count==4)
|
||||
{
|
||||
|
@ -523,7 +523,7 @@ void CHeroWindow::quit()
|
||||
}
|
||||
deactivate();
|
||||
|
||||
LOCPLINT->adventureInt->show();
|
||||
LOCPLINT->adventureInt->activate();
|
||||
|
||||
SDL_FreeSurface(curBack);
|
||||
curBack = NULL;
|
||||
|
@ -119,6 +119,7 @@ void CGarrisonSlot::clickLeft(tribool down)
|
||||
{
|
||||
if(creature)
|
||||
owner->highlighted = this;
|
||||
show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -375,6 +376,46 @@ void CInfoWindow::close()
|
||||
CInfoWindow::~CInfoWindow()
|
||||
{
|
||||
}
|
||||
|
||||
CInfoPopup::CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free)
|
||||
:bitmap(Bitmap),free(Free)
|
||||
{
|
||||
pos.x = x;
|
||||
pos.y = y;
|
||||
pos.h = bitmap->h;
|
||||
pos.w = bitmap->w;
|
||||
}
|
||||
void CInfoPopup::clickRight (tribool down)
|
||||
{
|
||||
//if(!down)
|
||||
close();
|
||||
}
|
||||
void CInfoPopup::activate()
|
||||
{
|
||||
ClickableR::activate();
|
||||
LOCPLINT->objsToBlit.push_back(this);
|
||||
}
|
||||
void CInfoPopup::deactivate()
|
||||
{
|
||||
ClickableR::deactivate();
|
||||
LOCPLINT->objsToBlit.erase(std::find(LOCPLINT->objsToBlit.begin(),LOCPLINT->objsToBlit.end(),this));
|
||||
}
|
||||
void CInfoPopup::close()
|
||||
{
|
||||
deactivate();
|
||||
if(free)
|
||||
SDL_FreeSurface(bitmap);
|
||||
delete this;
|
||||
if(LOCPLINT->curint == LOCPLINT->adventureInt)
|
||||
LOCPLINT->adventureInt->show();
|
||||
else if(LOCPLINT->curint == LOCPLINT->castleInt)
|
||||
LOCPLINT->castleInt->showAll();
|
||||
}
|
||||
void CInfoPopup::show(SDL_Surface * to)
|
||||
{
|
||||
blitAt(bitmap,pos.x,pos.y,(to)?(to):(ekran));
|
||||
}
|
||||
|
||||
SComponent::SComponent(Etype Type, int Subtype, int Val)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
@ -788,7 +829,7 @@ void CPlayerInterface::yourTurn()
|
||||
unsigned char & animVal = LOCPLINT->adventureInt->anim; //for animations handling
|
||||
unsigned char & heroAnimVal = LOCPLINT->adventureInt->heroAnim;
|
||||
adventureInt->infoBar.newDay(cb->getDate(1));
|
||||
adventureInt->show();
|
||||
adventureInt->activate();
|
||||
//show rest of things
|
||||
|
||||
//initializing framerate keeper
|
||||
@ -820,11 +861,13 @@ void CPlayerInterface::yourTurn()
|
||||
{
|
||||
tab[i] = CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap->format->palette->colors[224 + (i+1)%32];
|
||||
}
|
||||
//SDL_SaveBMP(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap,"t1.bmp");
|
||||
for(int i=0; i<32; ++i)
|
||||
{
|
||||
CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap->format->palette->colors[224 + i] = tab[i];
|
||||
}
|
||||
CSDL_Ext::update(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap);
|
||||
//SDL_SaveBMP(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap,"t2.bmp");
|
||||
CSDL_Ext::update(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap);
|
||||
}
|
||||
}
|
||||
//water tiles updated
|
||||
@ -2077,6 +2120,19 @@ void CHeroList::clickRight(tribool down)
|
||||
{
|
||||
LOCPLINT->adventureInt->handleRightClick(CGI->preth->zelp[304].second,down,this);
|
||||
}
|
||||
//if not buttons then heroes
|
||||
int hx = LOCPLINT->current->motion.x, hy = LOCPLINT->current->motion.y;
|
||||
hx-=pos.x;
|
||||
hy-=pos.y; hy-=arrup->ourImages[0].bitmap->h;
|
||||
float ny = (float)hy/(float)32;
|
||||
if ((ny>5 || ny<0) || (from+ny>=items.size()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//show popup
|
||||
CInfoPopup * ip = new CInfoPopup(LOCPLINT->heroWins[items[from+ny].first->subID],LOCPLINT->current->motion.x-LOCPLINT->heroWins[items[from+ny].first->subID]->w,LOCPLINT->current->motion.y-LOCPLINT->heroWins[items[from+ny].first->subID]->h,false);
|
||||
ip->activate();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -151,10 +151,25 @@ public:
|
||||
|
||||
class CRClickPopup : public IShowable, public ClickableR
|
||||
{
|
||||
public:
|
||||
virtual void activate()=0;
|
||||
virtual void deactivate()=0;
|
||||
virtual void close()=0;
|
||||
virtual void show()=0;
|
||||
virtual ~CRClickPopup(){};
|
||||
};
|
||||
|
||||
class CInfoPopup : public CRClickPopup
|
||||
{
|
||||
public:
|
||||
bool free;
|
||||
SDL_Surface * bitmap;
|
||||
CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free=false);
|
||||
void clickRight (tribool down);
|
||||
void activate();
|
||||
void deactivate();
|
||||
void close();
|
||||
void show(SDL_Surface * to = NULL);
|
||||
~CInfoPopup(){};
|
||||
};
|
||||
|
||||
class SComponent : public ClickableR
|
||||
|
Loading…
Reference in New Issue
Block a user