diff --git a/CGameInterface.h b/CGameInterface.h index 5a0d8ac51..9f4752236 100644 --- a/CGameInterface.h +++ b/CGameInterface.h @@ -53,7 +53,7 @@ public: virtual void tileRevealed(int3 pos){}; virtual void tileHidden(int3 pos){}; virtual void receivedResource(int type, int val){}; - virtual void showInfoDialog(std::string text, std::vector &components)=0; + virtual void showInfoDialog(std::string text, std::vector &components){}; virtual void showSelDialog(std::string text, std::vector & components, int askID)=0; virtual void garrisonChanged(const CGObjectInstance * obj){}; virtual void buildChanged(const CGTownInstance *town, int buildingID, int what){}; //what: 1 - built, 2 - demolished diff --git a/CGameState.cpp b/CGameState.cpp index 6c945371c..69705d9a8 100644 --- a/CGameState.cpp +++ b/CGameState.cpp @@ -47,6 +47,7 @@ CGObjectInstance * createObject(int id, int subid, int3 pos, int owner) nobj->defInfo->visitMap[5] = 2; nobj->artifacts.resize(20); nobj->artifWorn[16] = 3; + nobj->portrait = subid; nobj->primSkills.resize(4); nobj->primSkills[0] = nobj->type->heroClass->initialAttack; nobj->primSkills[1] = nobj->type->heroClass->initialDefence; @@ -581,7 +582,7 @@ void CGameState::randomizeObject(CGObjectInstance *cur) CGHeroInstance *h = dynamic_cast(cur); if(!h) {std::cout<<"Wrong random hero at "<pos<ID = ran.first; - cur->subID = ran.second; + h->portrait = cur->subID = ran.second; h->type = VLC->heroh->heroes[ran.second]; map->heroes.push_back(h); return; //TODO: maybe we should do something with definfo? @@ -606,7 +607,11 @@ void CGameState::randomizeObject(CGObjectInstance *cur) cur->ID = ran.first; cur->subID = ran.second; map->defs.insert(cur->defInfo = VLC->dobjinfo->gobjs[ran.first][ran.second]); - if(!cur->defInfo){std::cout<<"Missing def declaration for "<ID<<" "<subID<defInfo) + { + std::cout<<"Missing def declaration for "<ID<<" "<subID<ourImages[state].bitmap,pos.x,pos.y); @@ -51,8 +66,25 @@ void HighButton::press(bool down) SDL_BlitSurface(imgs->ourImages[i].bitmap,NULL,screen,&pos); updateRect(&pos); } +Button::Button( SDL_Rect Pos, boost::function Fun,CDefHandler* Imgs, bool Sel, CGroup* gr, int id) + :HighButton(Pos,Imgs,Sel,id),ourGroup(gr),fun(Fun) +{ + type=1; +}; +Button::Button() +{ + ourGroup=NULL;type=1; +}; -template void SetrButton::press(bool down) +SetrButton::SetrButton() +{ + type=1; + selectable=false; + selected=false; + state=0; + highlightable=false; +} +void SetrButton::press(bool down) { #ifndef __GNUC__ if (!down && state==1) @@ -77,11 +109,11 @@ void HighButton::hover(bool on) SDL_BlitSurface(imgs->ourImages[i].bitmap,NULL,screen,&pos); updateRect(&pos); } -template void Button::hover(bool on) +void Button::hover(bool on) { HighButton::hover(on); } -template void Button::select(bool on) +void Button::select(bool on) { int i; if (on) state=i=3; @@ -96,11 +128,7 @@ template void Button::select(bool on) } } -//void Slider::clickDown(int x, int y, bool bzgl=true); -//void Slider::clickUp(int x, int y, bool bzgl=true); -//void Slider::mMove(int x, int y, bool bzgl=true); - -template <> void Slider::updateSlid() +void Slider::updateSlid() { float perc = ((float)whereAreWe)/((float)positionsAmnt-capacity); float myh; @@ -121,20 +149,19 @@ template <> void Slider::updateSlid() updateRect(&pos); } -template<> void Slider::moveDown() +void Slider::moveDown() { if (whereAreWe*fun)(++whereAreWe); + fun(++whereAreWe); updateSlid(); } -template<> void Slider::moveUp() +void Slider::moveUp() { if (whereAreWe>0) - (CPG->*fun)(--whereAreWe); + fun(--whereAreWe); updateSlid(); } -//void Slider::moveByOne(bool up); -template<> Slider::Slider(int x, int y, int h, int amnt, int cap, bool ver) +Slider::Slider(int x, int y, int h, int amnt, int cap, bool ver) { vertical=ver; positionsAmnt = amnt; @@ -142,26 +169,26 @@ template<> Slider::Slider(int x, int y, int h, int amnt, int cap, bool if (ver) { pos = genRect(h,16,x,y); - down = Button(genRect(16,16,x,y+h-16),&Slider::moveDown,CDefHandler::giveDef("SCNRBDN.DEF"),false); - up = Button(genRect(16,16,x,y),&Slider::moveUp,CDefHandler::giveDef("SCNRBUP.DEF"),false); - slider = Button(genRect(16,16,x,y+16),NULL,CDefHandler::giveDef("SCNRBSL.DEF"),false); + down = Button(genRect(16,16,x,y+h-16),boost::bind(&Slider::moveDown,this),CDefHandler::giveDef("SCNRBDN.DEF"),false); + up = Button(genRect(16,16,x,y),boost::bind(&Slider::moveUp,this),CDefHandler::giveDef("SCNRBUP.DEF"),false); + slider = Button(genRect(16,16,x,y+16),boost::function(),CDefHandler::giveDef("SCNRBSL.DEF"),false); } else { pos = genRect(16,h,x,y); - down = Button(genRect(16,16,x+h-16,y),&Slider::moveDown,CDefHandler::giveDef("SCNRBRT.DEF"),false); - up = Button(genRect(16,16,x,y),&Slider::moveUp,CDefHandler::giveDef("SCNRBLF.DEF"),false); - slider = Button(genRect(16,16,x+16,y),NULL,CDefHandler::giveDef("SCNRBSL.DEF"),false); + down = Button(genRect(16,16,x+h-16,y),boost::bind(&Slider::moveDown,this),CDefHandler::giveDef("SCNRBRT.DEF"),false); + up = Button(genRect(16,16,x,y),boost::bind(&Slider::moveUp,this),CDefHandler::giveDef("SCNRBLF.DEF"),false); + slider = Button(genRect(16,16,x+16,y),boost::function(),CDefHandler::giveDef("SCNRBSL.DEF"),false); } moving = false; whereAreWe=0; } -template<>void Slider::deactivate() +void Slider::deactivate() { CPG->interested.erase(std::find(CPG->interested.begin(),CPG->interested.end(),this)); } -template<>void Slider::activate() +void Slider::activate() { SDL_FillRect(screen,&pos,0); up.show(); @@ -172,7 +199,7 @@ template<>void Slider::activate() CPG->interested.push_back(this); } -template<>void Slider::handleIt(SDL_Event sEvent) +void Slider::handleIt(SDL_Event sEvent) { if ((sEvent.type==SDL_MOUSEBUTTONDOWN) && (sEvent.button.button == SDL_BUTTON_LEFT)) { @@ -210,7 +237,7 @@ template<>void Slider::handleIt(SDL_Event sEvent) whereAreWe = pe*(positionsAmnt-capacity); if (whereAreWe<0)whereAreWe=0; updateSlid(); - (CPG->*fun)(whereAreWe); + fun(whereAreWe); } } else if ((sEvent.type==SDL_MOUSEBUTTONUP) && (sEvent.button.button == SDL_BUTTON_LEFT)) @@ -218,11 +245,11 @@ template<>void Slider::handleIt(SDL_Event sEvent) if ((down.state==1) && isItIn(&down.pos,sEvent.motion.x,sEvent.motion.y)) { - (this->*down.fun)(); + this->down.fun(); } if ((up.state==1) && isItIn(&up.pos,sEvent.motion.x,sEvent.motion.y)) { - (this->*up.fun)(); + this->up.fun(); } if (down.state==1) down.press(false); if (up.state==1) up.press(false); @@ -273,7 +300,7 @@ template<>void Slider::handleIt(SDL_Event sEvent) whereAreWe=ktory; updateSlid(); } - (CPG->*fun)(whereAreWe); + fun(whereAreWe); } } @@ -312,6 +339,31 @@ template<>void Slider::handleIt(SDL_Event sEvent) }*/ } +IntBut::IntBut() +{ + type=2; + fun=NULL; + highlightable=false; +} +void IntBut::set() +{ + *what=key; +} +void CPoinGroup::setYour(IntSelBut * your) +{ + *gdzie=your->key; +}; +IntSelBut::IntSelBut( SDL_Rect Pos, boost::function Fun,CDefHandler* Imgs, bool Sel, CPoinGroup* gr, int My) + : Button(Pos,Fun,Imgs,Sel,gr),key(My) +{ + ourPoinGroup=gr; +}; +void IntSelBut::select(bool on) +{ + Button::select(on); + ourPoinGroup->setYour(this); + CPG->printRating(); +} /********************************************************************************************/ void PreGameTab::show() { @@ -630,8 +682,8 @@ void Options::init() rCastle = BitmapHandler::loadBitmap("HPSRAND0.bmp"); nHero = BitmapHandler::loadBitmap("HPSRAND6.bmp"); nCastle = BitmapHandler::loadBitmap("HPSRAND5.bmp"); - turnLength = new Slider<>(57,557,195,11,1,false); - turnLength->fun=&CPreGame::setTurnLength; + turnLength = new Slider(57,557,195,11,1,false); + turnLength->fun=boost::bind(&CPreGame::setTurnLength,CPG,_1); flags.push_back(CDefHandler::giveDef("AOFLGBR.DEF")); flags.push_back(CDefHandler::giveDef("AOFLGBB.DEF")); @@ -1047,7 +1099,7 @@ void MapSel::init() loscon.key=_loscon; nrplayer.poin=mapsize.poin=type.poin=name.poin=viccon.poin=loscon.poin=(int*)(&sortBy); - nrplayer.fun=mapsize.fun=type.fun=name.fun=viccon.fun=loscon.fun=&CPreGame::sortMaps; + nrplayer.fun=mapsize.fun=type.fun=name.fun=viccon.fun=loscon.fun=boost::bind(&CPreGame::sortMaps,CPG); Dtypes = CDefHandler::giveDef("SCSELC.DEF"); Dvic = CDefHandler::giveDef("SCNRVICT.DEF"); @@ -1057,8 +1109,8 @@ void MapSel::init() sFlags = CDefHandler::giveDef("ITGFLAGS.DEF"); group.join_all(); std::sort(ourMaps.begin(),ourMaps.end(),mapSorter(_name)); - slid = new Slider<>(375,92,480,ourMaps.size(),18,true); - slid->fun = &CPreGame::printMapsFrom; + slid = new Slider(375,92,480,ourMaps.size(),18,true); + slid->fun = boost::bind(&CPreGame::printMapsFrom,CPG,_1); } void MapSel::moveByOne(bool up) { @@ -1083,9 +1135,9 @@ void MapSel::moveByOne(bool up) select(help); slid->updateSlid(); } -void MapSel::select(int which, bool updateMapsList) +void MapSel::select(int which, bool updateMapsList, bool forceSettingsUpdate) { - bool dontSaveSettings = ((selected!=which) || (CPG->ret.playerInfos.size()==0)); + bool dontSaveSettings = ((selected!=which) || (CPG->ret.playerInfos.size()==0) || forceSettingsUpdate); selected = which; CPG->ret.mapname = ourMaps[selected].filename; if(updateMapsList) @@ -1381,26 +1433,26 @@ void CPreGame::initScenSel() SDL_SetColorKey(ourScenSel->randMap,SDL_SRCCOLORKEY,SDL_MapRGB(ourScenSel->randMap->format,0,255,255)); SDL_SetColorKey(ourScenSel->options,SDL_SRCCOLORKEY,SDL_MapRGB(ourScenSel->options->format,0,255,255)); - ourScenSel->difficulty = new CPoinGroup<>(); + ourScenSel->difficulty = new CPoinGroup(); ourScenSel->difficulty->type=1; ourScenSel->selectedDiff=-77; ourScenSel->difficulty->gdzie = &ourScenSel->selectedDiff; - ourScenSel->bEasy = IntSelBut<>(genRect(0,0,506,456),NULL,CDefHandler::giveDef("GSPBUT3.DEF"),true,ourScenSel->difficulty,0); - ourScenSel->bNormal = IntSelBut<>(genRect(0,0,538,456),NULL,CDefHandler::giveDef("GSPBUT4.DEF"),true,ourScenSel->difficulty,1); - ourScenSel->bHard = IntSelBut<>(genRect(0,0,570,456),NULL,CDefHandler::giveDef("GSPBUT5.DEF"),true,ourScenSel->difficulty,2); - ourScenSel->bExpert = IntSelBut<>(genRect(0,0,602,456),NULL,CDefHandler::giveDef("GSPBUT6.DEF"),true,ourScenSel->difficulty,3); - ourScenSel->bImpossible = IntSelBut<>(genRect(0,0,634,456),NULL,CDefHandler::giveDef("GSPBUT7.DEF"),true,ourScenSel->difficulty,4); + ourScenSel->bEasy = IntSelBut(genRect(0,0,506,456),NULL,CDefHandler::giveDef("GSPBUT3.DEF"),true,ourScenSel->difficulty,0); + ourScenSel->bNormal = IntSelBut(genRect(0,0,538,456),NULL,CDefHandler::giveDef("GSPBUT4.DEF"),true,ourScenSel->difficulty,1); + ourScenSel->bHard = IntSelBut(genRect(0,0,570,456),NULL,CDefHandler::giveDef("GSPBUT5.DEF"),true,ourScenSel->difficulty,2); + ourScenSel->bExpert = IntSelBut(genRect(0,0,602,456),NULL,CDefHandler::giveDef("GSPBUT6.DEF"),true,ourScenSel->difficulty,3); + ourScenSel->bImpossible = IntSelBut(genRect(0,0,634,456),NULL,CDefHandler::giveDef("GSPBUT7.DEF"),true,ourScenSel->difficulty,4); - ourScenSel->bBack = Button<>(genRect(0,0,584,535),&CPreGame::showNewMenu,CDefHandler::giveDef("SCNRBACK.DEF")); - ourScenSel->bBegin = Button<>(genRect(0,0,414,535),&CPreGame::begin,CDefHandler::giveDef("SCNRBEG.DEF")); + ourScenSel->bBack = Button(genRect(0,0,584,535),boost::bind(&CPreGame::showNewMenu,this),CDefHandler::giveDef("SCNRBACK.DEF")); + ourScenSel->bBegin = Button(genRect(0,0,414,535),boost::bind(&CPreGame::begin,this),CDefHandler::giveDef("SCNRBEG.DEF")); + ourScenSel->bScens = Button(genRect(0,0,414,81),boost::bind(&CPreGame::showScenList,this),CDefHandler::giveDef("GSPBUTT.DEF")); - ourScenSel->bScens = Button<>(genRect(0,0,414,81),&CPreGame::showScenList,CDefHandler::giveDef("GSPBUTT.DEF")); for (int i=0; ibScens.imgs->ourImages.size(); i++) CSDL_Ext::printAt(CGI->generaltexth->allTexts[500],25+i,2+i,GEOR13,zwykly,ourScenSel->bScens.imgs->ourImages[i].bitmap); //"Show Available Scenarios" - ourScenSel->bRandom = Button<>(genRect(0,0,414,105),&CPreGame::showScenList,CDefHandler::giveDef("GSPBUTT.DEF")); + ourScenSel->bRandom = Button(genRect(0,0,414,105),boost::bind(&CPreGame::showScenList,this),CDefHandler::giveDef("GSPBUTT.DEF")); for (int i=0; ibRandom.imgs->ourImages.size(); i++) CSDL_Ext::printAt(CGI->generaltexth->allTexts[740],25+i,2+i,GEOR13,zwykly,ourScenSel->bRandom.imgs->ourImages[i].bitmap); - ourScenSel->bOptions = Button<>(genRect(0,0,414,509),&CPreGame::showOptions,CDefHandler::giveDef("GSPBUTT.DEF")); + ourScenSel->bOptions = Button(genRect(0,0,414,509),boost::bind(&CPreGame::showOptions,this),CDefHandler::giveDef("GSPBUTT.DEF")); for (int i=0; ibOptions.imgs->ourImages.size(); i++) CSDL_Ext::printAt(CGI->generaltexth->allTexts[501],25+i,2+i,GEOR13,zwykly,ourScenSel->bOptions.imgs->ourImages[i].bitmap); //"Show Advanced Options" @@ -1675,8 +1727,8 @@ void CPreGame::showAskBox (std::string data, void(*f1)(),void(*f2)()) (*btnspos)[0].y+=pos.y; (*btnspos)[1].x+=pos.x; (*btnspos)[1].y+=pos.y; - btns.push_back(new Button<>((*btnspos)[0],&CPreGame::quit,ok,false, NULL,2)); - btns.push_back(new Button<>((*btnspos)[1],(&CPreGame::hideBox),cancel,false, NULL,2)); + btns.push_back(new Button((*btnspos)[0],boost::bind(&CPreGame::quit,this),ok,false, NULL,2)); + btns.push_back(new Button((*btnspos)[1],boost::bind(&CPreGame::hideBox,this),cancel,false, NULL,2)); delete cmh; delete przyciski; delete btnspos; @@ -1728,7 +1780,7 @@ void CPreGame::scenHandleEv(SDL_Event& sEvent) if (isItIn(&btns[i]->pos,sEvent.motion.x,sEvent.motion.y)) { btns[i]->press(true); - ourScenSel->pressed=(Button<>*)btns[i]; + ourScenSel->pressed=(Button*)btns[i]; } } if ((currentTab==&ourScenSel->mapsel) && (sEvent.button.y>121) &&(sEvent.button.y<570) @@ -1741,7 +1793,7 @@ void CPreGame::scenHandleEv(SDL_Event& sEvent) } else if ((sEvent.type==SDL_MOUSEBUTTONUP) && (sEvent.button.button == SDL_BUTTON_LEFT)) { - Button<> * prnr=ourScenSel->pressed; + Button * prnr=ourScenSel->pressed; if (ourScenSel->pressed && ourScenSel->pressed->state==1) { ourScenSel->pressed->press(false); @@ -1753,17 +1805,19 @@ void CPreGame::scenHandleEv(SDL_Event& sEvent) { if (btns[i]->selectable) btns[i]->select(true); - if (btns[i]->type==1 && ((Button<>*)btns[i])->fun) - (this->*(((Button<>*)btns[i])->fun))(); + if (btns[i]->type==1 && ((Button*)btns[i])->fun) + ((Button*)btns[i])->fun(); int zz = btns.size(); if (i>=zz) break; if (btns[i]==prnr && btns[i]->type==2) { - ((IntBut<> *)(btns[i]))->set(); + ((IntBut*)(btns[i]))->set(); ourScenSel->mapsel.slid->whereAreWe=0; ourScenSel->mapsel.slid->updateSlid(); ourScenSel->mapsel.slid->positionsAmnt=ourScenSel->mapsel.countWL(); + ourScenSel->mapsel.select(ourScenSel->mapsel.whichWL(0)); + ourScenSel->mapsel.printMaps(0); } } @@ -1988,7 +2042,7 @@ StartInfo CPreGame::runLoop() for (int i=0;ipos,sEvent.motion.x,sEvent.motion.y)) - (this->*(((Button<>*)btns[i])->fun))(); + ((Button*)btns[i])->fun(); else { btns[i]->press(false); @@ -2106,8 +2160,12 @@ void CPreGame::quitAskBox() } void CPreGame::sortMaps() { - std::sort(ourScenSel->mapsel.ourMaps.begin(),ourScenSel->mapsel.ourMaps.end(),mapSorter(ourScenSel->mapsel.sortBy)); - ourScenSel->mapsel.select(0); + std::sort(ourScenSel->mapsel.ourMaps.begin(),ourScenSel->mapsel.ourMaps.end(),mapSorter(_name)); + if(ourScenSel->mapsel.sortBy != _name) + std::stable_sort(ourScenSel->mapsel.ourMaps.begin(),ourScenSel->mapsel.ourMaps.end(),mapSorter(ourScenSel->mapsel.sortBy)); + ourScenSel->mapsel.select(ourScenSel->mapsel.whichWL(0),false,true); + ourScenSel->mapsel.slid->whereAreWe=0; + ourScenSel->mapsel.slid->updateSlid(); printMapsFrom(0); } void CPreGame::setTurnLength(int on) diff --git a/CPreGame.h b/CPreGame.h index d83662856..cabd9fc20 100644 --- a/CPreGame.h +++ b/CPreGame.h @@ -8,14 +8,16 @@ #include "CMessage.h" #include "map.h" #include "hch/CMusicHandler.h" +#include +#include class CPreGame; class CDefHandler; extern CPreGame * CPG; typedef void(CPreGame::*ttt)(); -template class CGroup; -template class CPoinGroup ; - +class CGroup; +class CPoinGroup ; +class IntSelBut; struct HighButton { @@ -24,9 +26,8 @@ struct HighButton SDL_Rect pos; CDefHandler* imgs; int state; - HighButton( SDL_Rect Pos, CDefHandler* Imgs, bool Sel=false, int id=-1) - {type=0;imgs=Imgs;selectable=Sel;selected=false;state=0;pos=Pos;ID=id;highlightable=false;}; - HighButton(){state=0;} + HighButton( SDL_Rect Pos, CDefHandler* Imgs, bool Sel=false, int id=-1); + HighButton(); bool selectable, selected; bool highlightable, highlighted; virtual void show(); @@ -34,33 +35,33 @@ struct HighButton virtual void hover(bool on=true)=0; virtual void select(bool on=true)=0; }; -template struct Button: public HighButton +struct Button: public HighButton { - CGroup * ourGroup; - Button( SDL_Rect Pos, T Fun,CDefHandler* Imgs, bool Sel=false, CGroup* gr=NULL, int id=-1) - :HighButton(Pos,Imgs,Sel,id),ourGroup(gr),fun(Fun){type=1;}; - Button(){ourGroup=NULL;type=1;}; - T fun; + CGroup *ourGroup; + Button( SDL_Rect Pos, boost::function Fun,CDefHandler* Imgs, bool Sel=false, CGroup* gr=NULL, int id=-1); + Button(); + boost::function fun; virtual void hover(bool on=true); virtual void select(bool on=true); }; -template struct SetrButton: public Button +struct SetrButton: public Button { int key, * poin; virtual void press(bool down=true); - SetrButton(){int type=1;bool selectable=false;bool selected=false;int state=0;bool highlightable=false;} + SetrButton(); }; -template class Slider -{ // + +class Slider +{ public: bool vertical; // false means horizontal SDL_Rect pos; // position - Button up, down, //or left/right + Button up, down, //or left/right slider; int positionsAmnt, capacity;// capacity - amount of positions dispplayed at once int whereAreWe; // first displayed thing bool moving; - void(T::*fun)(int); + boost::function fun; void clickDown(int x, int y, bool bzgl=true); void clickUp(int x, int y, bool bzgl=true); void mMove(int x, int y, bool bzgl=true); @@ -71,47 +72,39 @@ public: Slider(int x, int y, int h, int amnt, int cap, bool ver); void updateSlid(); void handleIt(SDL_Event sev); - }; -//template -template struct IntBut: public Button + +struct IntBut: public Button { public: int key; int * what; - IntBut(){int type=2;int fun=NULL;bool highlightable=false;}; - void set(){*what=key;}; + IntBut(); + void set(); }; -template struct IntSelBut: public Button +class CGroup { public: - CPoinGroup * ourPoinGroup; - int key; - IntSelBut(){}; - IntSelBut( SDL_Rect Pos, T Fun,CDefHandler* Imgs, bool Sel=false, CPoinGroup* gr=NULL, int My=-1) - : Button(Pos,Fun,Imgs,Sel,gr),key(My){ourPoinGroup=gr;}; - void select(bool on=true) {(*this).Button::select(on);ourPoinGroup->setYour(this); - #if !defined(__amigaos4__) && !defined(__unix__) - CPG->printRating(); - #else - #warning not compile here - #endif - } -}; -template class CPoinGroup :public CGroup -{ -public: - int * gdzie; //where (po polsku, bo by było słowo kluczowe :/) - void setYour(IntSelBut * your){*gdzie=your->key;}; -}; -template class CGroup -{ -public: - Button * selected; + Button * selected; int type; // 1=sinsel CGroup():selected(NULL),type(0){}; }; +class CPoinGroup :public CGroup +{ +public: + int * gdzie; //where (po polsku, bo by było słowo kluczowe :/) + void setYour(IntSelBut * your); +}; +struct IntSelBut: public Button +{ +public: + CPoinGroup * ourPoinGroup; + int key; + IntSelBut(){}; + IntSelBut( SDL_Rect Pos, boost::function Fun,CDefHandler* Imgs, bool Sel=false, CPoinGroup* gr=NULL, int My=-1); + void select(bool on=true); +}; class PreGameTab { public: @@ -123,9 +116,9 @@ public: }; class RanSel : public PreGameTab { - Button<> horcpl[9], horcte[9], conpl[9], conte[8], water[4], monster[4], //last is random + Button horcpl[9], horcte[9], conpl[9], conte[8], water[4], monster[4], //last is random size[4], twoLevel, showRand; - CGroup<> *Ghorcpl, *Ghorcte, *Gconpl, *Gconte, *Gwater, *Gmonster, *Gsize; + CGroup *Ghorcpl, *Ghorcte, *Gconpl, *Gconte, *Gwater, *Gmonster, *Gsize; }; class Options : public PreGameTab { @@ -164,7 +157,7 @@ class Options : public PreGameTab }; public: std::set usedHeroes; - Slider<> * turnLength; + Slider * turnLength; SDL_Surface * bg, * rHero, * rCastle, * nHero, * nCastle; std::vector bgs; @@ -195,9 +188,9 @@ public: std::vector scenImgs; //int current; std::vector ourMaps; - IntBut<> small, medium, large, xlarge, all; - SetrButton<> nrplayer, mapsize, type, name, viccon, loscon; - Slider<> *slid, *descslid; + IntBut small, medium, large, xlarge, all; + SetrButton nrplayer, mapsize, type, name, viccon, loscon; + Slider *slid, *descslid; int sizeFilter; int whichWL(int nr); int countWL(); @@ -206,7 +199,7 @@ public: void init(); std::string gdiff(std::string ss); void printMaps(int from,int to=18, int at=0, bool abs=false); - void select(int which, bool updateMapsList=true); + void select(int which, bool updateMapsList=true, bool forceSettingsUpdate=false); void moveByOne(bool up); void printSelectedInfo(); void printFlags(); @@ -221,10 +214,10 @@ public: //RanSel ransel; MapSel mapsel; SDL_Surface * background, *scenInf, *scenList, *randMap, *options ; - Button<> bScens, bOptions, bRandom, bBegin, bBack; - IntSelBut<> bEasy, bNormal, bHard, bExpert, bImpossible; - Button<> * pressed; - CPoinGroup<> * difficulty; + Button bScens, bOptions, bRandom, bBegin, bBack; + IntSelBut bEasy, bNormal, bHard, bExpert, bImpossible; + Button * pressed; + CPoinGroup * difficulty; std::vector maps; int selectedDiff; void initRanSel(); @@ -243,7 +236,7 @@ public: StartInfo ret; bool run; bool first; //hasn't we showed the scensel - std::vector *> interested; + std::vector interested; CMusicHandler * mush; std::vector btns; CPreGameTextHandler * preth ; diff --git a/client/Client.cpp b/client/Client.cpp index c4bfaec6c..6b77a7ea9 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -146,7 +146,9 @@ CClient::CClient(CConnection *con, StartInfo *si) ui8 color = gs->scenarioOps->playerInfos[i].color; CCallback *cb = new CCallback(gs,color,this); if(!gs->scenarioOps->playerInfos[i].human) + { playerint[color] = static_cast(CAIHandler::getNewAI(cb,"EmptyAI.dll")); + } else { gs->currentPlayer = color; @@ -252,8 +254,7 @@ void CClient::process(int what) { for(std::set::iterator i=th->fowRevealed.begin(); i != th->fowRevealed.end(); i++) playerint[player]->tileRevealed(*i); - //boost::function tr = boost::bind(&CGameInterface::tileRevealed,playerint[player]); - //std::for_each(th->fowRevealed.begin(),th->fowRevealed.end(),tr); + //std::for_each(th->fowRevealed.begin(),th->fowRevealed.end(),boost::bind(&CGameInterface::tileRevealed,playerint[player],_1)); } //notify interfacesabout move diff --git a/client/Graphics.cpp b/client/Graphics.cpp index 99b17e3ad..54fe23859 100644 --- a/client/Graphics.cpp +++ b/client/Graphics.cpp @@ -36,8 +36,8 @@ SDL_Surface * Graphics::drawPrimarySkill(const CGHeroInstance *curh, SDL_Surface SDL_Surface * Graphics::drawHeroInfoWin(const CGHeroInstance * curh) { char * buf = new char[10]; - SDL_Surface * ret = SDL_DisplayFormat(hInfo); blueToPlayersAdv(hInfo,curh->tempOwner); + SDL_Surface * ret = SDL_DisplayFormat(hInfo); SDL_SetColorKey(ret,SDL_SRCCOLORKEY,SDL_MapRGB(ret->format,0,255,255)); printAt(curh->name,75,15,GEOR13,zwykly,ret); drawPrimarySkill(curh, ret); @@ -53,7 +53,6 @@ SDL_Surface * Graphics::drawHeroInfoWin(const CGHeroInstance * curh) delete[] buf; blitAt(morale22->ourImages[curh->getCurrentMorale()+3].bitmap,14,84,ret); blitAt(luck22->ourImages[curh->getCurrentLuck()+3].bitmap,14,101,ret); - //SDL_SaveBMP(ret,"inf1.bmp"); return ret; } SDL_Surface * Graphics::drawTownInfoWin(const CGTownInstance * curh) diff --git a/hch/CObjectHandler.cpp b/hch/CObjectHandler.cpp index fb92cb7d3..6b943ce1a 100644 --- a/hch/CObjectHandler.cpp +++ b/hch/CObjectHandler.cpp @@ -349,7 +349,7 @@ CGObjectInstance::~CGObjectInstance() } CGHeroInstance::CGHeroInstance() { - level = exp = -1; + portrait = level = exp = -1; isStanding = true; moveDir = 4; mana = 0; diff --git a/map.cpp b/map.cpp index fa25e279e..531d1d77e 100644 --- a/map.cpp +++ b/map.cpp @@ -1118,6 +1118,8 @@ void Mapa::initFromBytes(unsigned char * bufor) bool portrait=bufor[i]; ++i; if (portrait) i++; //TODO read portrait nr, save, open + else + nhi->portrait = nhi->subID; if(readChar(bufor,i))//true if hero has specified abilities {