mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-14 02:33:51 +02:00
* first part of exchange window
* minor changes
This commit is contained in:
parent
287e0c016d
commit
8231a6e6cc
@ -168,7 +168,7 @@ const CGHeroInstance * CCallback::getHeroInfo(int val, int mode) const //mode =
|
|||||||
}
|
}
|
||||||
else //object id
|
else //object id
|
||||||
{
|
{
|
||||||
return static_cast<CGHeroInstance*>(gs->map->objects[val]);
|
return static_cast<const CGHeroInstance*>(gs->map->objects[val]);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,8 @@ public:
|
|||||||
virtual void yourTurn(){};
|
virtual void yourTurn(){};
|
||||||
virtual void availableCreaturesChanged(const CGTownInstance *town){};
|
virtual void availableCreaturesChanged(const CGTownInstance *town){};
|
||||||
virtual void heroBonusChanged(const CGHeroInstance *hero, const HeroBonus &bonus, bool gain){};//if gain hero received bonus, else he lost it
|
virtual void heroBonusChanged(const CGHeroInstance *hero, const HeroBonus &bonus, bool gain){};//if gain hero received bonus, else he lost it
|
||||||
virtual void requestRealized(PackageApplied *pa){}
|
virtual void requestRealized(PackageApplied *pa){};
|
||||||
|
virtual void heroExchangeStarted(si32 hero1, si32 hero2){};
|
||||||
virtual void serialize(COSer<CSaveFile> &h, const int version){}; //saving
|
virtual void serialize(COSer<CSaveFile> &h, const int version){}; //saving
|
||||||
virtual void serialize(CISer<CLoadFile> &h, const int version){}; //loading
|
virtual void serialize(CISer<CLoadFile> &h, const int version){}; //loading
|
||||||
|
|
||||||
|
@ -1723,6 +1723,11 @@ void CPlayerInterface::requestRealized( PackageApplied *pa )
|
|||||||
stillMoveHero.setn(CONTINUE_MOVE);
|
stillMoveHero.setn(CONTINUE_MOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CPlayerInterface::heroExchangeStarted(si32 hero1, si32 hero2)
|
||||||
|
{
|
||||||
|
pushInt(new CExchangeWindow(hero1, hero2));
|
||||||
|
}
|
||||||
|
|
||||||
void CPlayerInterface::recreateWanderingHeroes()
|
void CPlayerInterface::recreateWanderingHeroes()
|
||||||
{
|
{
|
||||||
wanderingHeroes.clear();
|
wanderingHeroes.clear();
|
||||||
|
@ -144,6 +144,7 @@ public:
|
|||||||
void availableCreaturesChanged(const CGTownInstance *town);
|
void availableCreaturesChanged(const CGTownInstance *town);
|
||||||
void heroBonusChanged(const CGHeroInstance *hero, const HeroBonus &bonus, bool gain);//if gain hero received bonus, else he lost it
|
void heroBonusChanged(const CGHeroInstance *hero, const HeroBonus &bonus, bool gain);//if gain hero received bonus, else he lost it
|
||||||
void requestRealized(PackageApplied *pa);
|
void requestRealized(PackageApplied *pa);
|
||||||
|
void heroExchangeStarted(si32 hero1, si32 hero2);
|
||||||
void serialize(COSer<CSaveFile> &h, const int version); //saving
|
void serialize(COSer<CSaveFile> &h, const int version); //saving
|
||||||
void serialize(CISer<CLoadFile> &h, const int version); //loading
|
void serialize(CISer<CLoadFile> &h, const int version); //loading
|
||||||
|
|
||||||
|
@ -106,6 +106,7 @@ public:
|
|||||||
void giveHero(int id, int player){};
|
void giveHero(int id, int player){};
|
||||||
void changeObjPos(int objid, int3 newPos, ui8 flags){};
|
void changeObjPos(int objid, int3 newPos, ui8 flags){};
|
||||||
void sendAndApply(CPackForClient * info){};
|
void sendAndApply(CPackForClient * info){};
|
||||||
|
void heroExchange(si32 hero1, si32 hero2){};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
friend class CCallback; //handling players actions
|
friend class CCallback; //handling players actions
|
||||||
|
@ -3208,3 +3208,45 @@ CRClickPopupInt::~CRClickPopupInt()
|
|||||||
if(delInner)
|
if(delInner)
|
||||||
delete inner;
|
delete inner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CExchangeWindow::close()
|
||||||
|
{
|
||||||
|
LOCPLINT->popIntTotally(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CExchangeWindow::activate()
|
||||||
|
{
|
||||||
|
quit->activate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CExchangeWindow::deactivate()
|
||||||
|
{
|
||||||
|
quit->deactivate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CExchangeWindow::show(SDL_Surface * to)
|
||||||
|
{
|
||||||
|
blitAt(bg, pos, to);
|
||||||
|
|
||||||
|
quit->show(to);
|
||||||
|
|
||||||
|
//printing border around window
|
||||||
|
if(screen->w != 800 || screen->h !=600)
|
||||||
|
CMessage::drawBorder(LOCPLINT->playerID,to,828,628,pos.x-14,pos.y-15);
|
||||||
|
}
|
||||||
|
|
||||||
|
CExchangeWindow::CExchangeWindow(si32 hero1, si32 hero2) //c-tor
|
||||||
|
{
|
||||||
|
hero1inst = LOCPLINT->cb->getHeroInfo(hero1, 2);
|
||||||
|
hero2inst = LOCPLINT->cb->getHeroInfo(hero2, 2);
|
||||||
|
|
||||||
|
bg = BitmapHandler::loadBitmap("TRADE2.BMP");
|
||||||
|
graphics->blueToPlayersAdv(bg, hero1inst->tempOwner);
|
||||||
|
quit = new AdventureMapButton(CGI->generaltexth->tcommands[8], "", boost::bind(&CExchangeWindow::close, this), pos.x+732, pos.y+567, "IOKAY.DEF", SDLK_RETURN);
|
||||||
|
}
|
||||||
|
|
||||||
|
CExchangeWindow::~CExchangeWindow() //d-tor
|
||||||
|
{
|
||||||
|
SDL_FreeSurface(bg);
|
||||||
|
delete quit;
|
||||||
|
}
|
@ -566,6 +566,22 @@ public:
|
|||||||
~CGarrisonWindow(); //d-tor
|
~CGarrisonWindow(); //d-tor
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CExchangeWindow : public CIntObject, public IShowActivable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SDL_Surface *bg; //background
|
||||||
|
AdventureMapButton *quit;
|
||||||
|
|
||||||
|
const CGHeroInstance *hero1inst, *hero2inst;
|
||||||
|
|
||||||
|
void close();
|
||||||
|
void activate();
|
||||||
|
void deactivate();
|
||||||
|
void show(SDL_Surface * to);
|
||||||
|
|
||||||
|
CExchangeWindow(si32 hero1, si32 hero2); //c-tor
|
||||||
|
~CExchangeWindow(); //d-tor
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //__GUICLASSES_H__
|
#endif //__GUICLASSES_H__
|
||||||
|
@ -460,3 +460,12 @@ void ShowInInfobox::applyCl(CClient *cl)
|
|||||||
static_cast<CPlayerInterface*>(cl->playerint[player])->showComp(sc);
|
static_cast<CPlayerInterface*>(cl->playerint[player])->showComp(sc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HeroExchange::applyFirstCl(CClient *cl)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void HeroExchange::applyCl(CClient *cl)
|
||||||
|
{
|
||||||
|
cl->playerint[player]->heroExchangeStarted(hero1, hero2);
|
||||||
|
}
|
||||||
|
@ -604,9 +604,11 @@ void CGHeroInstance::onHeroVisit(const CGHeroInstance * h) const
|
|||||||
if(tempOwner == h->tempOwner) //our hero
|
if(tempOwner == h->tempOwner) //our hero
|
||||||
{
|
{
|
||||||
//exchange
|
//exchange
|
||||||
|
cb->heroExchange(id, h->id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//battle
|
||||||
cb->startBattleI(
|
cb->startBattleI(
|
||||||
&h->army,
|
&h->army,
|
||||||
&army,
|
&army,
|
||||||
|
@ -83,6 +83,7 @@ public:
|
|||||||
virtual void giveHero(int id, int player)=0;
|
virtual void giveHero(int id, int player)=0;
|
||||||
virtual void changeObjPos(int objid, int3 newPos, ui8 flags)=0;
|
virtual void changeObjPos(int objid, int3 newPos, ui8 flags)=0;
|
||||||
virtual void sendAndApply(CPackForClient * info)=0;
|
virtual void sendAndApply(CPackForClient * info)=0;
|
||||||
|
virtual void heroExchange(si32 hero1, si32 hero2)=0; //when two heroes meet on adventure map
|
||||||
|
|
||||||
|
|
||||||
friend struct CPackForClient;
|
friend struct CPackForClient;
|
||||||
|
@ -475,6 +475,22 @@ struct GiveHero : public CPackForClient //516
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct HeroExchange : public CPackForClient //517
|
||||||
|
{
|
||||||
|
HeroExchange(){type = 517;};
|
||||||
|
void applyFirstCl(CClient *cl);
|
||||||
|
void applyCl(CClient *cl);
|
||||||
|
DLL_EXPORT void applyGs(CGameState *gs);
|
||||||
|
|
||||||
|
si32 hero1, hero2; //heroes for exchange
|
||||||
|
ui8 player;
|
||||||
|
|
||||||
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
|
{
|
||||||
|
h & hero1 & hero2 & player;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct NewTurn : public CPackForClient //101
|
struct NewTurn : public CPackForClient //101
|
||||||
{
|
{
|
||||||
DLL_EXPORT void applyGs(CGameState *gs);
|
DLL_EXPORT void applyGs(CGameState *gs);
|
||||||
|
@ -418,6 +418,10 @@ DLL_EXPORT void GiveHero::applyGs( CGameState *gs )
|
|||||||
h->inTownGarrison = false;
|
h->inTownGarrison = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DLL_EXPORT void HeroExchange::applyGs(CGameState *gs)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
DLL_EXPORT void NewTurn::applyGs( CGameState *gs )
|
DLL_EXPORT void NewTurn::applyGs( CGameState *gs )
|
||||||
{
|
{
|
||||||
gs->day = day;
|
gs->day = day;
|
||||||
|
@ -93,6 +93,7 @@ void registerTypes2(Serializer &s)
|
|||||||
s.template registerType<SetStackEffect>();
|
s.template registerType<SetStackEffect>();
|
||||||
s.template registerType<StacksInjured>();
|
s.template registerType<StacksInjured>();
|
||||||
s.template registerType<ShowInInfobox>();
|
s.template registerType<ShowInInfobox>();
|
||||||
|
s.template registerType<HeroExchange>();
|
||||||
|
|
||||||
s.template registerType<SaveGame>();
|
s.template registerType<SaveGame>();
|
||||||
s.template registerType<SetSelection>();
|
s.template registerType<SetSelection>();
|
||||||
|
@ -975,7 +975,7 @@ void CMapHandler::terrainRect(int3 top_tile, unsigned char anim, std::vector< st
|
|||||||
|
|
||||||
SDL_SetClipRect(extSurf, &prevClip); //restoring clip_rect
|
SDL_SetClipRect(extSurf, &prevClip); //restoring clip_rect
|
||||||
|
|
||||||
delete rSurf;
|
SDL_FreeSurface(rSurf);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Surface * CMapHandler::getVisBitmap(int x, int y, const std::vector< std::vector< std::vector<unsigned char> > > & visibilityMap, int lvl)
|
SDL_Surface * CMapHandler::getVisBitmap(int x, int y, const std::vector< std::vector< std::vector<unsigned char> > > & visibilityMap, int lvl)
|
||||||
|
@ -1422,6 +1422,21 @@ void CGameHandler::changeObjPos( int objid, int3 newPos, ui8 flags )
|
|||||||
sendAndApply(&cop);
|
sendAndApply(&cop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGameHandler::heroExchange(si32 hero1, si32 hero2)
|
||||||
|
{
|
||||||
|
ui8 player1 = getHero(hero1)->tempOwner;
|
||||||
|
ui8 player2 = getHero(hero2)->tempOwner;
|
||||||
|
|
||||||
|
if(player1 == player2)
|
||||||
|
{
|
||||||
|
HeroExchange hex;
|
||||||
|
hex.hero1 = hero1;
|
||||||
|
hex.hero2 = hero2;
|
||||||
|
hex.player = player1;
|
||||||
|
sendAndApply(&hex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CGameHandler::applyAndAsk( Query * sel, ui8 player, boost::function<void(ui32)> &callback )
|
void CGameHandler::applyAndAsk( Query * sel, ui8 player, boost::function<void(ui32)> &callback )
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::recursive_mutex> lock(gsm);
|
boost::unique_lock<boost::recursive_mutex> lock(gsm);
|
||||||
|
@ -130,6 +130,7 @@ public:
|
|||||||
void setManaPoints(int hid, int val);
|
void setManaPoints(int hid, int val);
|
||||||
void giveHero(int id, int player);
|
void giveHero(int id, int player);
|
||||||
void changeObjPos(int objid, int3 newPos, ui8 flags);
|
void changeObjPos(int objid, int3 newPos, ui8 flags);
|
||||||
|
void heroExchange(si32 hero1, si32 hero2);
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void init(StartInfo *si, int Seed);
|
void init(StartInfo *si, int Seed);
|
||||||
|
Loading…
Reference in New Issue
Block a user