mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
Garrison interface in Exchange Window.
This commit is contained in:
parent
6be7a77fee
commit
9093320da8
@ -413,7 +413,7 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town)
|
|||||||
animval = 0;
|
animval = 0;
|
||||||
|
|
||||||
//garrison
|
//garrison
|
||||||
garr = new CGarrisonInt(pos.x+305,pos.y+387,4,32,townInt,243,13,town,town->visitingHero);
|
garr = new CGarrisonInt(pos.x+305,pos.y+387,4,Point(0,96),townInt,Point(62,374),town,town->visitingHero);
|
||||||
|
|
||||||
townlist = new CTownList(3,pos.x+744,pos.y+414,"IAM014.DEF","IAM015.DEF");//744,526);
|
townlist = new CTownList(3,pos.x+744,pos.y+414,"IAM014.DEF","IAM015.DEF");//744,526);
|
||||||
exit = new AdventureMapButton
|
exit = new AdventureMapButton
|
||||||
|
@ -203,7 +203,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
|
|||||||
portraitArea->text = hero->getBiography();
|
portraitArea->text = hero->getBiography();
|
||||||
|
|
||||||
delete garr;
|
delete garr;
|
||||||
/*gar4button->owner = */garr = new CGarrisonInt(pos.x+80, pos.y+493, 8, 0, curBack, 15, 485, curHero);
|
/*gar4button->owner = */garr = new CGarrisonInt(pos.x+80, pos.y+493, 8, Point(), curBack, Point(65,8), curHero);
|
||||||
garr->update = false;
|
garr->update = false;
|
||||||
gar4button->callback = boost::bind(&CGarrisonInt::splitClick,garr);//actualization of callback function
|
gar4button->callback = boost::bind(&CGarrisonInt::splitClick,garr);//actualization of callback function
|
||||||
|
|
||||||
|
@ -61,7 +61,6 @@ using namespace CSDL_Ext;
|
|||||||
|
|
||||||
void processCommand(const std::string &message, CClient *&client);
|
void processCommand(const std::string &message, CClient *&client);
|
||||||
|
|
||||||
extern TTF_Font * GEOR16;
|
|
||||||
extern std::queue<SDL_Event*> events;
|
extern std::queue<SDL_Event*> events;
|
||||||
extern boost::mutex eventsM;
|
extern boost::mutex eventsM;
|
||||||
|
|
||||||
|
@ -160,6 +160,24 @@ struct Rect : public SDL_Rect
|
|||||||
y += p.y;
|
y += p.y;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
Rect& operator+=(const Point &p) //works as operator+
|
||||||
|
{
|
||||||
|
x += p.x;
|
||||||
|
y += p.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
Rect& operator-=(const Rect &p) //works as operator+
|
||||||
|
{
|
||||||
|
x -= p.x;
|
||||||
|
y -= p.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
Rect& operator-=(const Point &p) //works as operator+
|
||||||
|
{
|
||||||
|
x -= p.x;
|
||||||
|
y -= p.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
Rect operator&(const Rect &p) const //rect intersection
|
Rect operator&(const Rect &p) const //rect intersection
|
||||||
{
|
{
|
||||||
bool intersect = true;
|
bool intersect = true;
|
||||||
|
@ -291,8 +291,16 @@ CGarrisonSlot::CGarrisonSlot(CGarrisonInt *Owner, int x, int y, int IID, int Upg
|
|||||||
creature = Creature;
|
creature = Creature;
|
||||||
pos.x = x;
|
pos.x = x;
|
||||||
pos.y = y;
|
pos.y = y;
|
||||||
pos.w = 58;
|
if(Owner->smallIcons)
|
||||||
pos.h = 64;
|
{
|
||||||
|
pos.w = 32;
|
||||||
|
pos.h = 32;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pos.w = 58;
|
||||||
|
pos.h = 64;
|
||||||
|
}
|
||||||
owner = Owner;
|
owner = Owner;
|
||||||
}
|
}
|
||||||
CGarrisonSlot::~CGarrisonSlot()
|
CGarrisonSlot::~CGarrisonSlot()
|
||||||
@ -302,26 +310,28 @@ CGarrisonSlot::~CGarrisonSlot()
|
|||||||
}
|
}
|
||||||
void CGarrisonSlot::show(SDL_Surface * to)
|
void CGarrisonSlot::show(SDL_Surface * to)
|
||||||
{
|
{
|
||||||
|
std::map<int,SDL_Surface*> &imgs = (owner->smallIcons ? graphics->smallImgs : graphics->bigImgs);
|
||||||
if(creature)
|
if(creature)
|
||||||
{
|
{
|
||||||
char buf[15];
|
char buf[15];
|
||||||
SDL_itoa(count,buf,10);
|
SDL_itoa(count,buf,10);
|
||||||
blitAt(graphics->bigImgs[creature->idNumber],pos,to);
|
blitAt(imgs[creature->idNumber],pos,to);
|
||||||
printToWR(buf,pos.x+56,pos.y+62,GEOR16,zwykly,to);
|
printToWR(buf, pos.x+pos.w-2, pos.y+pos.h-2, owner->smallIcons ? GEORM : GEOR16, zwykly, to);
|
||||||
|
|
||||||
if((owner->highlighted==this)
|
if((owner->highlighted==this)
|
||||||
|| (owner->splitting && owner->highlighted->creature == creature))
|
|| (owner->splitting && owner->highlighted->creature == creature))
|
||||||
{
|
{
|
||||||
blitAt(graphics->bigImgs[-1],pos,to);
|
blitAt(imgs[-1],pos,to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else //empty slot
|
else //empty slot
|
||||||
{
|
{
|
||||||
SDL_Rect jakis1 = genRect(pos.h,pos.w,owner->offx+ID*(pos.w+owner->interx),owner->offy+upg*(pos.h+owner->intery)),
|
Rect pos1 = pos, pos2 = pos; //positions on the garr bg sur and scren
|
||||||
jakis2 = pos;
|
pos1 -= owner->surOffset;
|
||||||
SDL_BlitSurface(owner->sur,&jakis1,to,&jakis2);
|
|
||||||
|
SDL_BlitSurface(owner->sur,&pos1,to,&pos2);
|
||||||
if(owner->splitting)
|
if(owner->splitting)
|
||||||
blitAt(graphics->bigImgs[-1],pos,to);
|
blitAt(imgs[-1],pos,to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CGarrisonInt::~CGarrisonInt()
|
CGarrisonInt::~CGarrisonInt()
|
||||||
@ -415,6 +425,17 @@ void CGarrisonInt::activeteSlots()
|
|||||||
}
|
}
|
||||||
void CGarrisonInt::createSlots()
|
void CGarrisonInt::createSlots()
|
||||||
{
|
{
|
||||||
|
int h, w; //height and width of slot
|
||||||
|
if(smallIcons)
|
||||||
|
{
|
||||||
|
h = w = 32;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
h = 64;
|
||||||
|
w = 58;
|
||||||
|
}
|
||||||
|
|
||||||
if(set1)
|
if(set1)
|
||||||
{
|
{
|
||||||
sup = new std::vector<CGarrisonSlot*>(7,(CGarrisonSlot *)(NULL));
|
sup = new std::vector<CGarrisonSlot*>(7,(CGarrisonSlot *)(NULL));
|
||||||
@ -423,12 +444,12 @@ void CGarrisonInt::createSlots()
|
|||||||
i!=set1->slots.end(); i++)
|
i!=set1->slots.end(); i++)
|
||||||
{
|
{
|
||||||
(*sup)[i->first] =
|
(*sup)[i->first] =
|
||||||
new CGarrisonSlot(this, pos.x + (i->first*(58+interx)), pos.y,i->first, 0,
|
new CGarrisonSlot(this, pos.x + (i->first*(w+interx)), pos.y,i->first, 0,
|
||||||
&CGI->creh->creatures[i->second.first],i->second.second);
|
&CGI->creh->creatures[i->second.first],i->second.second);
|
||||||
}
|
}
|
||||||
for(int i=0; i<sup->size(); i++)
|
for(int i=0; i<sup->size(); i++)
|
||||||
if((*sup)[i] == NULL)
|
if((*sup)[i] == NULL)
|
||||||
(*sup)[i] = new CGarrisonSlot(this, pos.x + (i*(58+interx)), pos.y,i,0,NULL, 0);
|
(*sup)[i] = new CGarrisonSlot(this, pos.x + (i*(w+interx)), pos.y,i,0,NULL, 0);
|
||||||
}
|
}
|
||||||
if(set2)
|
if(set2)
|
||||||
{
|
{
|
||||||
@ -438,12 +459,12 @@ void CGarrisonInt::createSlots()
|
|||||||
i!=set2->slots.end(); i++)
|
i!=set2->slots.end(); i++)
|
||||||
{
|
{
|
||||||
(*sdown)[i->first] =
|
(*sdown)[i->first] =
|
||||||
new CGarrisonSlot(this, pos.x + (i->first*(58+interx)), pos.y + 64 + intery,i->first,1,
|
new CGarrisonSlot(this, pos.x + (i->first*(w+interx)) + garOffset.x, pos.y + garOffset.y,i->first,1,
|
||||||
&CGI->creh->creatures[i->second.first],i->second.second);
|
&CGI->creh->creatures[i->second.first],i->second.second);
|
||||||
}
|
}
|
||||||
for(int i=0; i<sdown->size(); i++)
|
for(int i=0; i<sdown->size(); i++)
|
||||||
if((*sdown)[i] == NULL)
|
if((*sdown)[i] == NULL)
|
||||||
(*sdown)[i] = new CGarrisonSlot(this, pos.x + (i*(58+interx)), pos.y + 64 + intery,i,1, NULL, 0);
|
(*sdown)[i] = new CGarrisonSlot(this, pos.x + (i*(w+interx)) + garOffset.x, pos.y + garOffset.y,i,1, NULL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void CGarrisonInt::deleteSlots()
|
void CGarrisonInt::deleteSlots()
|
||||||
@ -507,10 +528,10 @@ void CGarrisonInt::splitStacks(int am2)
|
|||||||
am2);
|
am2);
|
||||||
|
|
||||||
}
|
}
|
||||||
CGarrisonInt::CGarrisonInt(int x, int y, int inx, int iny, SDL_Surface *&pomsur, int OX, int OY, const CArmedInstance *s1,
|
CGarrisonInt::CGarrisonInt(int x, int y, int inx, const Point &garsOffset, SDL_Surface *&pomsur, const Point& SurOffset,
|
||||||
const CArmedInstance *s2)
|
const CArmedInstance *s1, const CArmedInstance *s2, bool smallImgs)
|
||||||
:interx(inx),intery(iny),highlighted(NULL),sur(pomsur),offx(OX),offy(OY),sup(NULL),
|
:interx(inx),garOffset(garsOffset),highlighted(NULL),sur(pomsur),surOffset(surOffset),sup(NULL),
|
||||||
sdown(NULL),oup(s1),odown(s2)
|
sdown(NULL),oup(s1),odown(s2), smallIcons(smallImgs)
|
||||||
{
|
{
|
||||||
active = false;
|
active = false;
|
||||||
splitting = false;
|
splitting = false;
|
||||||
@ -3177,7 +3198,7 @@ CGarrisonWindow::CGarrisonWindow( const CArmedInstance *up, const CGHeroInstance
|
|||||||
pos.w = screen->w;
|
pos.w = screen->w;
|
||||||
pos.h = screen->h;
|
pos.h = screen->h;
|
||||||
|
|
||||||
garr = new CGarrisonInt(pos.x+92, pos.y+129, 4, 30, bg, 92, 129, up, down);
|
garr = new CGarrisonInt(pos.x+92, pos.y+129, 4, Point(0,94), bg, Point(0,0), up, down);
|
||||||
split = new AdventureMapButton(CGI->generaltexth->tcommands[3],"",boost::bind(&CGarrisonInt::splitClick,garr),pos.x+88,pos.y+314,"IDV6432.DEF");
|
split = new AdventureMapButton(CGI->generaltexth->tcommands[3],"",boost::bind(&CGarrisonInt::splitClick,garr),pos.x+88,pos.y+314,"IDV6432.DEF");
|
||||||
quit = new AdventureMapButton(CGI->generaltexth->tcommands[8],"",boost::bind(&CGarrisonWindow::close,this),pos.x+399,pos.y+314,"IOK6432.DEF",SDLK_RETURN);
|
quit = new AdventureMapButton(CGI->generaltexth->tcommands[8],"",boost::bind(&CGarrisonWindow::close,this),pos.x+399,pos.y+314,"IOK6432.DEF",SDLK_RETURN);
|
||||||
}
|
}
|
||||||
@ -3645,6 +3666,7 @@ void CExchangeWindow::close()
|
|||||||
void CExchangeWindow::activate()
|
void CExchangeWindow::activate()
|
||||||
{
|
{
|
||||||
quit->activate();
|
quit->activate();
|
||||||
|
garr->activate();
|
||||||
|
|
||||||
artifs[0]->activate();
|
artifs[0]->activate();
|
||||||
artifs[1]->activate();
|
artifs[1]->activate();
|
||||||
@ -3683,6 +3705,7 @@ void CExchangeWindow::activate()
|
|||||||
void CExchangeWindow::deactivate()
|
void CExchangeWindow::deactivate()
|
||||||
{
|
{
|
||||||
quit->deactivate();
|
quit->deactivate();
|
||||||
|
garr->deactivate();
|
||||||
|
|
||||||
artifs[0]->deactivate();
|
artifs[0]->deactivate();
|
||||||
artifs[1]->deactivate();
|
artifs[1]->deactivate();
|
||||||
@ -3735,6 +3758,8 @@ void CExchangeWindow::show(SDL_Surface * to)
|
|||||||
{
|
{
|
||||||
questlogButton[g]->show(to);
|
questlogButton[g]->show(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
garr->show(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CExchangeWindow::questlog(int whichHero)
|
void CExchangeWindow::questlog(int whichHero)
|
||||||
@ -3872,6 +3897,9 @@ CExchangeWindow::CExchangeWindow(si32 hero1, si32 hero2) //c-tor
|
|||||||
//statusbar
|
//statusbar
|
||||||
ourBar = new CStatusBar(pos.x + 3, pos.y + 577, "TSTATBAR.bmp", 726);
|
ourBar = new CStatusBar(pos.x + 3, pos.y + 577, "TSTATBAR.bmp", 726);
|
||||||
|
|
||||||
|
//garrison interface
|
||||||
|
garr = new CGarrisonInt(pos.x + 69, pos.y + 131, 4, Point(418,0), bg, Point(0,0), heroInst[0],heroInst[1], true);
|
||||||
|
|
||||||
delete un32;
|
delete un32;
|
||||||
delete skilldef;
|
delete skilldef;
|
||||||
}
|
}
|
||||||
@ -3883,6 +3911,7 @@ CExchangeWindow::~CExchangeWindow() //d-tor
|
|||||||
delete artifs[0];
|
delete artifs[0];
|
||||||
delete artifs[1];
|
delete artifs[1];
|
||||||
|
|
||||||
|
delete garr;
|
||||||
delete ourBar;
|
delete ourBar;
|
||||||
|
|
||||||
for(int g=0; g<ARRAY_COUNT(secSkillAreas); g++)
|
for(int g=0; g<ARRAY_COUNT(secSkillAreas); g++)
|
||||||
|
@ -197,12 +197,15 @@ public:
|
|||||||
class CGarrisonInt :public CIntObject
|
class CGarrisonInt :public CIntObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int interx, intery; //intervals between slots
|
int interx; //space between slots
|
||||||
CGarrisonSlot *highlighted; //choosen slot
|
Point garOffset, //offset between garrisons (not used if only one hero)
|
||||||
|
surOffset; //offset between garrison position on the bg surface and position on the screen
|
||||||
|
CGarrisonSlot *highlighted; //chosen slot
|
||||||
|
|
||||||
SDL_Surface *&sur; //TODO: comment me
|
SDL_Surface *&sur; //bg surface
|
||||||
int offx, offy, p2; //TODO: comment me
|
int p2; //TODO: comment me
|
||||||
bool ignoreEvent, update, active, splitting, pb;
|
bool ignoreEvent, update, active, splitting, pb,
|
||||||
|
smallIcons; //true - 32x32 imgs, false - 58x64
|
||||||
|
|
||||||
const CCreatureSet *set1; //top set of creatures
|
const CCreatureSet *set1; //top set of creatures
|
||||||
const CCreatureSet *set2; //bottom set of creatures
|
const CCreatureSet *set2; //bottom set of creatures
|
||||||
@ -222,7 +225,7 @@ public:
|
|||||||
void splitClick(); //handles click on split button
|
void splitClick(); //handles click on split button
|
||||||
void splitStacks(int am2); //TODO: comment me
|
void splitStacks(int am2); //TODO: comment me
|
||||||
|
|
||||||
CGarrisonInt(int x, int y, int inx, int iny, SDL_Surface *&pomsur, int OX, int OY, const CArmedInstance *s1, const CArmedInstance *s2=NULL); //c-tor
|
CGarrisonInt(int x, int y, int inx, const Point &garsOffset, SDL_Surface *&pomsur, const Point &SurOffset, const CArmedInstance *s1, const CArmedInstance *s2=NULL, bool smallImgs = false); //c-tor
|
||||||
~CGarrisonInt(); //d-tor
|
~CGarrisonInt(); //d-tor
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -668,7 +671,7 @@ public:
|
|||||||
~CGarrisonWindow(); //d-tor
|
~CGarrisonWindow(); //d-tor
|
||||||
};
|
};
|
||||||
|
|
||||||
class CExchangeWindow : public CIntObject, public IShowActivable
|
class CExchangeWindow : public CIntObject, public CWindowWithGarrison
|
||||||
{
|
{
|
||||||
CStatusBar * ourBar; //internal statusbar
|
CStatusBar * ourBar; //internal statusbar
|
||||||
|
|
||||||
|
@ -598,6 +598,8 @@ bool CGHeroInstance::needsLastStack() const
|
|||||||
}
|
}
|
||||||
void CGHeroInstance::onHeroVisit(const CGHeroInstance * h) const
|
void CGHeroInstance::onHeroVisit(const CGHeroInstance * h) const
|
||||||
{
|
{
|
||||||
|
if(h == this) return; //exclude potential self-visiting
|
||||||
|
|
||||||
if (ID == HEROI_TYPE) //hero
|
if (ID == HEROI_TYPE) //hero
|
||||||
{
|
{
|
||||||
//TODO: check for allies
|
//TODO: check for allies
|
||||||
|
Loading…
x
Reference in New Issue
Block a user