|
@@ -19,7 +19,7 @@
|
|
|
#include <sstream>
|
|
|
#include "AdventureMapButton.h"
|
|
|
#include "CHeroWindow.h"
|
|
|
-
|
|
|
+#pragma warning (disable : 4355)
|
|
|
extern TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX; //fonts
|
|
|
|
|
|
using namespace boost::logic;
|
|
@@ -30,435 +30,6 @@ CAdvMapInt::~CAdvMapInt()
|
|
|
SDL_FreeSurface(bg);
|
|
|
delete heroWindow;
|
|
|
}
|
|
|
-void CList::activate()
|
|
|
-{
|
|
|
- ClickableL::activate();
|
|
|
- ClickableR::activate();
|
|
|
- Hoverable::activate();
|
|
|
- KeyInterested::activate();
|
|
|
- MotionInterested::activate();
|
|
|
-};
|
|
|
-void CList::deactivate()
|
|
|
-{
|
|
|
- ClickableL::deactivate();
|
|
|
- ClickableR::deactivate();
|
|
|
- Hoverable::deactivate();
|
|
|
- KeyInterested::deactivate();
|
|
|
- MotionInterested::deactivate();
|
|
|
-};
|
|
|
-void CList::clickLeft(tribool down)
|
|
|
-{
|
|
|
-};
|
|
|
-CHeroList::CHeroList()
|
|
|
-{
|
|
|
- pos = genRect(192,64,609,196);
|
|
|
-
|
|
|
- arrupp = genRect(16,64,609,196);
|
|
|
- arrdop = genRect(16,64,609,372);
|
|
|
- //32px per hero
|
|
|
- posmobx = 610;
|
|
|
- posmoby = 213;
|
|
|
- posporx = 617;
|
|
|
- pospory = 212;
|
|
|
- posmanx = 666;
|
|
|
- posmany = 213;
|
|
|
-
|
|
|
- arrup = CGI->spriteh->giveDef("IAM012.DEF");
|
|
|
- arrdo = CGI->spriteh->giveDef("IAM013.DEF");
|
|
|
- mobile = CGI->spriteh->giveDef("IMOBIL.DEF");
|
|
|
- mana = CGI->spriteh->giveDef("IMANA.DEF");
|
|
|
- empty = CGI->bitmaph->loadBitmap("HPSXXX.bmp");
|
|
|
- selection = CGI->bitmaph->loadBitmap("HPSYYY.bmp");
|
|
|
- SDL_SetColorKey(selection,SDL_SRCCOLORKEY,SDL_MapRGB(selection->format,0,255,255));
|
|
|
- from = 0;
|
|
|
- pressed = indeterminate;
|
|
|
-}
|
|
|
-
|
|
|
-void CHeroList::init()
|
|
|
-{
|
|
|
- bg = CSDL_Ext::newSurface(68,193,ekran);
|
|
|
- SDL_BlitSurface(LOCPLINT->adventureInt->bg,&genRect(193,68,607,196),bg,&genRect(193,68,0,0));
|
|
|
-}
|
|
|
-void CHeroList::genList()
|
|
|
-{
|
|
|
- int howMany = LOCPLINT->cb->howManyHeroes();
|
|
|
- for (int i=0;i<howMany;i++)
|
|
|
- {
|
|
|
- items.push_back(std::pair<const CGHeroInstance *,CPath *>(LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,i,0),NULL));
|
|
|
- }
|
|
|
-}
|
|
|
-void CHeroList::select(int which)
|
|
|
-{
|
|
|
- selected = which;
|
|
|
- if (which>=items.size())
|
|
|
- return;
|
|
|
- LOCPLINT->adventureInt->centerOn(items[which].first->pos);
|
|
|
- LOCPLINT->adventureInt->selection.type = HEROI_TYPE;
|
|
|
- LOCPLINT->adventureInt->selection.selected = items[which].first;
|
|
|
- LOCPLINT->adventureInt->terrain.currentPath = items[which].second;
|
|
|
- draw();
|
|
|
- LOCPLINT->adventureInt->townList.draw();
|
|
|
-
|
|
|
- LOCPLINT->adventureInt->infoBar.draw(NULL);
|
|
|
-}
|
|
|
-void CHeroList::clickLeft(tribool down)
|
|
|
-{
|
|
|
- if (down)
|
|
|
- {
|
|
|
- /***************************ARROWS*****************************************/
|
|
|
- if(isItIn(&arrupp,LOCPLINT->current->motion.x,LOCPLINT->current->motion.y) && from>0)
|
|
|
- {
|
|
|
- blitAt(arrup->ourImages[1].bitmap,arrupp.x,arrupp.y);
|
|
|
- pressed = true;
|
|
|
- return;
|
|
|
- }
|
|
|
- else if(isItIn(&arrdop,LOCPLINT->current->motion.x,LOCPLINT->current->motion.y) && (items.size()-from>5))
|
|
|
- {
|
|
|
- blitAt(arrdo->ourImages[1].bitmap,arrdop.x,arrdop.y);
|
|
|
- pressed = false;
|
|
|
- return;
|
|
|
- }
|
|
|
- /***************************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)
|
|
|
- return;
|
|
|
- if (((int)(ny+from))==selected)
|
|
|
- LOCPLINT->openHeroWindow(items[selected].first);//print hero screen
|
|
|
- select(ny+from);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (indeterminate(pressed))
|
|
|
- return;
|
|
|
- if (pressed) //up
|
|
|
- {
|
|
|
- blitAt(arrup->ourImages[0].bitmap,arrupp.x,arrupp.y);
|
|
|
- pressed = indeterminate;
|
|
|
- if (!down)
|
|
|
- {
|
|
|
- from--;
|
|
|
- if (from<0)
|
|
|
- from=0;
|
|
|
- draw();
|
|
|
- }
|
|
|
- }
|
|
|
- else if (!pressed) //down
|
|
|
- {
|
|
|
- blitAt(arrdo->ourImages[0].bitmap,arrdop.x,arrdop.y);
|
|
|
- pressed = indeterminate;
|
|
|
- if (!down)
|
|
|
- {
|
|
|
- from++;
|
|
|
- //if (from<items.size()-5)
|
|
|
- // from=items.size()-5;
|
|
|
- draw();
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- throw 0;
|
|
|
-
|
|
|
- }
|
|
|
-}
|
|
|
-void CHeroList::mouseMoved (SDL_MouseMotionEvent & sEvent)
|
|
|
-{
|
|
|
- if(isItIn(&arrupp,LOCPLINT->current->motion.x,LOCPLINT->current->motion.y))
|
|
|
- {
|
|
|
- if (from>0)
|
|
|
- LOCPLINT->adventureInt->statusbar.print(CGI->preth->advHListUp.first);
|
|
|
- else
|
|
|
- LOCPLINT->adventureInt->statusbar.clear();
|
|
|
- return;
|
|
|
- }
|
|
|
- else if(isItIn(&arrdop,LOCPLINT->current->motion.x,LOCPLINT->current->motion.y))
|
|
|
- {
|
|
|
- if ((items.size()-from) > 5)
|
|
|
- LOCPLINT->adventureInt->statusbar.print(CGI->preth->advHListDown.first);
|
|
|
- else
|
|
|
- LOCPLINT->adventureInt->statusbar.clear();
|
|
|
- return;
|
|
|
- }
|
|
|
- //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()))
|
|
|
- {
|
|
|
- LOCPLINT->adventureInt->statusbar.clear();
|
|
|
- return;
|
|
|
- }
|
|
|
- std::vector<std::string> temp;
|
|
|
- temp+=(items[from+ny].first->name),(items[from+ny].first->type->heroClass->name);
|
|
|
- LOCPLINT->adventureInt->statusbar.print( processStr(CGI->generaltexth->allTexts[15],temp) );
|
|
|
- //select(ny+from);
|
|
|
-}
|
|
|
-void CHeroList::clickRight(tribool down)
|
|
|
-{
|
|
|
- if (down)
|
|
|
- {
|
|
|
- /***************************ARROWS*****************************************/
|
|
|
- if(isItIn(&arrupp,LOCPLINT->current->motion.x,LOCPLINT->current->motion.y) && from>0)
|
|
|
- {
|
|
|
- LOCPLINT->adventureInt->handleRightClick(CGI->preth->advHListUp.second,down,this);
|
|
|
- }
|
|
|
- else if(isItIn(&arrdop,LOCPLINT->current->motion.x,LOCPLINT->current->motion.y) && (items.size()-from>5))
|
|
|
- {
|
|
|
- LOCPLINT->adventureInt->handleRightClick(CGI->preth->advHListDown.second,down,this);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- LOCPLINT->adventureInt->handleRightClick(CGI->preth->advHListUp.second,down,this);
|
|
|
- LOCPLINT->adventureInt->handleRightClick(CGI->preth->advHListDown.second,down,this);
|
|
|
- }
|
|
|
-}
|
|
|
-void CHeroList::hover (bool on)
|
|
|
-{
|
|
|
-}
|
|
|
-void CHeroList::keyPressed (SDL_KeyboardEvent & key)
|
|
|
-{
|
|
|
-}
|
|
|
-void CHeroList::updateHList()
|
|
|
-{
|
|
|
- items.clear();
|
|
|
- genList();
|
|
|
-}
|
|
|
-void CHeroList::updateMove(const CGHeroInstance* which) //draws move points bar
|
|
|
-{
|
|
|
- int ser = LOCPLINT->cb->getHeroSerial(which);
|
|
|
- ser -= from;
|
|
|
- int pom = (which->movement)/100;
|
|
|
- blitAt(mobile->ourImages[pom].bitmap,posmobx,posmoby+ser*32); //move point
|
|
|
-}
|
|
|
-void CHeroList::draw()
|
|
|
-{
|
|
|
- for (int iT=0+from;iT<5+from;iT++)
|
|
|
- {
|
|
|
- int i = iT-from;
|
|
|
- if (iT>=items.size())
|
|
|
- {
|
|
|
- blitAt(mobile->ourImages[0].bitmap,posmobx,posmoby+i*32);
|
|
|
- blitAt(mana->ourImages[0].bitmap,posmanx,posmany+i*32);
|
|
|
- blitAt(empty,posporx,pospory+i*32);
|
|
|
- continue;
|
|
|
- }
|
|
|
- int pom = (LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,iT,0)->movement)/100;
|
|
|
- if (pom>25) pom=25;
|
|
|
- if (pom<0) pom=0;
|
|
|
- blitAt(mobile->ourImages[pom].bitmap,posmobx,posmoby+i*32); //move point
|
|
|
- pom = (LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,iT,0)->mana)/5; //bylo: .../10;
|
|
|
- if (pom>25) pom=25;
|
|
|
- if (pom<0) pom=0;
|
|
|
- blitAt(mana->ourImages[pom].bitmap,posmanx,posmany+i*32); //mana
|
|
|
- SDL_Surface * temp = LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,iT,0)->type->portraitSmall;
|
|
|
- blitAt(temp,posporx,pospory+i*32);
|
|
|
- if ((selected == iT) && (LOCPLINT->adventureInt->selection.type == HEROI_TYPE))
|
|
|
- {
|
|
|
- blitAt(selection,posporx,pospory+i*32);
|
|
|
- }
|
|
|
- //TODO: support for custom portraits
|
|
|
- }
|
|
|
- if (from>0)
|
|
|
- blitAt(arrup->ourImages[0].bitmap,arrupp.x,arrupp.y);
|
|
|
- else
|
|
|
- blitAt(arrup->ourImages[2].bitmap,arrupp.x,arrupp.y);
|
|
|
-
|
|
|
- if (items.size()-from>5)
|
|
|
- blitAt(arrdo->ourImages[0].bitmap,arrdop.x,arrdop.y);
|
|
|
- else
|
|
|
- blitAt(arrdo->ourImages[2].bitmap,arrdop.x,arrdop.y);
|
|
|
-}
|
|
|
-CTownList::CTownList()
|
|
|
-{
|
|
|
- pos = genRect(192,48,747,196);
|
|
|
- arrup = CGI->spriteh->giveDef("IAM014.DEF");
|
|
|
- arrdo = CGI->spriteh->giveDef("IAM015.DEF");
|
|
|
-
|
|
|
- arrupp.x=747;
|
|
|
- arrupp.y=196;
|
|
|
- arrupp.w=arrup->ourImages[0].bitmap->w;
|
|
|
- arrupp.h=arrup->ourImages[0].bitmap->h;
|
|
|
- arrdop.x=747;
|
|
|
- arrdop.y=372;
|
|
|
- arrdop.w=arrdo->ourImages[0].bitmap->w;
|
|
|
- arrdop.h=arrdo->ourImages[0].bitmap->h;
|
|
|
- posporx = 747;
|
|
|
- pospory = 212;
|
|
|
-
|
|
|
- pressed = indeterminate;
|
|
|
-
|
|
|
- from = 0;
|
|
|
-
|
|
|
-}
|
|
|
-void CTownList::genList()
|
|
|
-{
|
|
|
- int howMany = LOCPLINT->cb->howManyTowns();
|
|
|
- for (int i=0;i<howMany;i++)
|
|
|
- {
|
|
|
- items.push_back(LOCPLINT->cb->getTownInfo(i,0));
|
|
|
- }
|
|
|
-}
|
|
|
-void CTownList::select(int which)
|
|
|
-{
|
|
|
- selected = which;
|
|
|
- if (which>=items.size())
|
|
|
- return;
|
|
|
- LOCPLINT->adventureInt->centerOn(items[which]->pos);
|
|
|
- LOCPLINT->adventureInt->selection.type = TOWNI_TYPE;
|
|
|
- LOCPLINT->adventureInt->selection.selected = items[which];
|
|
|
- LOCPLINT->adventureInt->terrain.currentPath = NULL;
|
|
|
- draw();
|
|
|
- LOCPLINT->adventureInt->heroList.draw();
|
|
|
-}
|
|
|
-void CTownList::mouseMoved (SDL_MouseMotionEvent & sEvent)
|
|
|
-{
|
|
|
- if(isItIn(&arrupp,LOCPLINT->current->motion.x,LOCPLINT->current->motion.y))
|
|
|
- {
|
|
|
- if (from>0)
|
|
|
- LOCPLINT->adventureInt->statusbar.print(CGI->preth->advTListUp.first);
|
|
|
- else
|
|
|
- LOCPLINT->adventureInt->statusbar.clear();
|
|
|
- return;
|
|
|
- }
|
|
|
- else if(isItIn(&arrdop,LOCPLINT->current->motion.x,LOCPLINT->current->motion.y))
|
|
|
- {
|
|
|
- if ((items.size()-from) > 5)
|
|
|
- LOCPLINT->adventureInt->statusbar.print(CGI->preth->advTListDown.first);
|
|
|
- else
|
|
|
- LOCPLINT->adventureInt->statusbar.clear();
|
|
|
- return;
|
|
|
- }
|
|
|
- //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()))
|
|
|
- {
|
|
|
- LOCPLINT->adventureInt->statusbar.clear();
|
|
|
- return;
|
|
|
- };
|
|
|
- //LOCPLINT->adventureInt->statusbar.print( items[from+ny]->name + ", " + items[from+ny]->town->name ); //TODO - uncomment when pointer to the town type is initialized
|
|
|
-}
|
|
|
-void CTownList::clickLeft(tribool down)
|
|
|
-{
|
|
|
- if (down)
|
|
|
- {
|
|
|
- /***************************ARROWS*****************************************/
|
|
|
- if(isItIn(&arrupp,LOCPLINT->current->motion.x,LOCPLINT->current->motion.y) && from>0)
|
|
|
- {
|
|
|
- blitAt(arrup->ourImages[1].bitmap,arrupp.x,arrupp.y);
|
|
|
- pressed = true;
|
|
|
- return;
|
|
|
- }
|
|
|
- else if(isItIn(&arrdop,LOCPLINT->current->motion.x,LOCPLINT->current->motion.y) && (items.size()-from>5))
|
|
|
- {
|
|
|
- blitAt(arrdo->ourImages[1].bitmap,arrdop.x,arrdop.y);
|
|
|
- pressed = false;
|
|
|
- return;
|
|
|
- }
|
|
|
- /***************************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)
|
|
|
- return;
|
|
|
- if (((int)(ny+from))==selected)
|
|
|
- LOCPLINT->openTownWindow(items[selected]);//print town screen
|
|
|
- else
|
|
|
- select(ny+from);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (indeterminate(pressed))
|
|
|
- return;
|
|
|
- if (pressed) //up
|
|
|
- {
|
|
|
- blitAt(arrup->ourImages[0].bitmap,arrupp.x,arrupp.y);
|
|
|
- pressed = indeterminate;
|
|
|
- if (!down)
|
|
|
- {
|
|
|
- from--;
|
|
|
- if (from<0)
|
|
|
- from=0;
|
|
|
- draw();
|
|
|
- }
|
|
|
- }
|
|
|
- else if (!pressed) //down
|
|
|
- {
|
|
|
- blitAt(arrdo->ourImages[0].bitmap,arrdop.x,arrdop.y);
|
|
|
- pressed = indeterminate;
|
|
|
- if (!down)
|
|
|
- {
|
|
|
- from++;
|
|
|
- //if (from<items.size()-5)
|
|
|
- // from=items.size()-5;
|
|
|
- draw();
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- throw 0;
|
|
|
-
|
|
|
- }
|
|
|
-}
|
|
|
-void CTownList::clickRight(tribool down)
|
|
|
-{
|
|
|
- if (down)
|
|
|
- {
|
|
|
- /***************************ARROWS*****************************************/
|
|
|
- if(isItIn(&arrupp,LOCPLINT->current->motion.x,LOCPLINT->current->motion.y) && from>0)
|
|
|
- {
|
|
|
- LOCPLINT->adventureInt->handleRightClick(CGI->preth->advTListUp.second,down,this);
|
|
|
- }
|
|
|
- else if(isItIn(&arrdop,LOCPLINT->current->motion.x,LOCPLINT->current->motion.y) && (items.size()-from>5))
|
|
|
- {
|
|
|
- LOCPLINT->adventureInt->handleRightClick(CGI->preth->advTListDown.second,down,this);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- LOCPLINT->adventureInt->handleRightClick(CGI->preth->advTListUp.second,down,this);
|
|
|
- LOCPLINT->adventureInt->handleRightClick(CGI->preth->advTListDown.second,down,this);
|
|
|
- }
|
|
|
-}
|
|
|
-void CTownList::hover (bool on)
|
|
|
-{
|
|
|
-}
|
|
|
-void CTownList::keyPressed (SDL_KeyboardEvent & key)
|
|
|
-{
|
|
|
-}
|
|
|
-void CTownList::draw()
|
|
|
-{
|
|
|
- for (int iT=0+from;iT<5+from;iT++)
|
|
|
- {
|
|
|
- int i = iT-from;
|
|
|
- if (iT>=items.size())
|
|
|
- {
|
|
|
- blitAt(CGI->townh->getPic(-1),posporx,pospory+i*32);
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- blitAt(CGI->townh->getPic(items[i]->subID,items[i]->hasFort(),items[i]->builded),posporx,pospory+i*32);
|
|
|
-
|
|
|
- if ((selected == iT) && (LOCPLINT->adventureInt->selection.type == TOWNI_TYPE))
|
|
|
- {
|
|
|
- blitAt(CGI->townh->getPic(-2),posporx,pospory+i*32);
|
|
|
- }
|
|
|
- }
|
|
|
- if (from>0)
|
|
|
- blitAt(arrup->ourImages[0].bitmap,arrupp.x,arrupp.y);
|
|
|
- else
|
|
|
- blitAt(arrup->ourImages[2].bitmap,arrupp.x,arrupp.y);
|
|
|
-
|
|
|
- if (items.size()-from>5)
|
|
|
- blitAt(arrdo->ourImages[0].bitmap,arrdop.x,arrdop.y);
|
|
|
- else
|
|
|
- blitAt(arrdo->ourImages[2].bitmap,arrdop.x,arrdop.y);
|
|
|
-}
|
|
|
CMinimap::CMinimap(bool draw)
|
|
|
{
|
|
|
statusbarTxt = CGI->preth->advWorldMap.first;
|
|
@@ -1235,8 +806,12 @@ nextHero(CGI->preth->advNextHero.first,CGI->preth->advNextHero.second,
|
|
|
&CAdvMapInt::fnextHero, 679, 324, "IAM000.DEF", this),
|
|
|
|
|
|
endTurn(CGI->preth->advEndTurn.first,CGI->preth->advEndTurn.second,
|
|
|
- &CAdvMapInt::fendTurn, 679, 356, "IAM001.DEF", this)
|
|
|
+ &CAdvMapInt::fendTurn, 679, 356, "IAM001.DEF", this),
|
|
|
+
|
|
|
+townList(5,&genRect(192,48,747,196),747,196,747,372)
|
|
|
{
|
|
|
+ townList.owner = this;
|
|
|
+ townList.fun = &CAdvMapInt::selectionChanged;
|
|
|
LOCPLINT->adventureInt=this;
|
|
|
bg = CGI->bitmaph->loadBitmap("ADVMAP.bmp");
|
|
|
blueToPlayersAdv(bg,player);
|
|
@@ -1401,6 +976,16 @@ void CAdvMapInt::update()
|
|
|
//updateRect(&genRect(550,600,6,6));
|
|
|
}
|
|
|
|
|
|
+void CAdvMapInt::selectionChanged()
|
|
|
+{
|
|
|
+ const CGTownInstance *to = townList.items[townList.selected];
|
|
|
+ centerOn(to->pos);
|
|
|
+ selection.type = TOWNI_TYPE;
|
|
|
+ selection.selected = to;
|
|
|
+ terrain.currentPath = NULL;
|
|
|
+ townList.draw();
|
|
|
+ heroList.draw();
|
|
|
+}
|
|
|
void CAdvMapInt::centerOn(int3 on)
|
|
|
{
|
|
|
on.x -= (LOCPLINT->adventureInt->terrain.tilesw/2);
|