mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
* improved Events handling
* fixed saving town available creatures info * minor improvements
This commit is contained in:
parent
48661bd714
commit
23803c9f17
@ -309,12 +309,14 @@ void CBattleInterface::setPrintCellBorders(bool set)
|
||||
{
|
||||
settings.printCellBorders = set;
|
||||
redrawBackgroundWithHexes(activeStack);
|
||||
LOCPLINT->totalRedraw();
|
||||
}
|
||||
|
||||
void CBattleInterface::setPrintStackRange(bool set)
|
||||
{
|
||||
settings.printStackRange = set;
|
||||
redrawBackgroundWithHexes(activeStack);
|
||||
LOCPLINT->totalRedraw();
|
||||
}
|
||||
|
||||
void CBattleInterface::setPrintMouseShadow(bool set)
|
||||
|
@ -91,17 +91,17 @@ void CGarrisonSlot::hover (bool on)
|
||||
{
|
||||
if(owner->highlighted == this)
|
||||
{
|
||||
temp = CGI->generaltexth->tcommands[4];
|
||||
temp = CGI->generaltexth->tcommands[4]; //View %s
|
||||
boost::algorithm::replace_first(temp,"%s",creature->nameSing);
|
||||
}
|
||||
else if (owner->highlighted->creature == creature)
|
||||
{
|
||||
temp = CGI->generaltexth->tcommands[2];
|
||||
temp = CGI->generaltexth->tcommands[2]; //Combine %s armies
|
||||
boost::algorithm::replace_first(temp,"%s",creature->nameSing);
|
||||
}
|
||||
else if (owner->highlighted->creature)
|
||||
{
|
||||
temp = CGI->generaltexth->tcommands[7];
|
||||
temp = CGI->generaltexth->tcommands[7]; //Exchange %s with %s
|
||||
boost::algorithm::replace_first(temp,"%s",owner->highlighted->creature->nameSing);
|
||||
boost::algorithm::replace_first(temp,"%s",creature->nameSing);
|
||||
}
|
||||
@ -116,11 +116,15 @@ void CGarrisonSlot::hover (bool on)
|
||||
{
|
||||
if(upg)
|
||||
{
|
||||
temp = CGI->generaltexth->tcommands[32];
|
||||
temp = CGI->generaltexth->tcommands[32]; //Select %s (visiting)
|
||||
}
|
||||
else if(owner->oup && owner->oup->ID == TOWNI_TYPE)
|
||||
{
|
||||
temp = CGI->generaltexth->tcommands[12]; //Select %s (in garrison)
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = CGI->generaltexth->tcommands[12];
|
||||
temp = CGI->generaltexth->allTexts[481]; //Select %s
|
||||
}
|
||||
boost::algorithm::replace_first(temp,"%s",creature->nameSing);
|
||||
};
|
||||
@ -135,17 +139,17 @@ void CGarrisonSlot::hover (bool on)
|
||||
&& owner->highlighted->upg != upg //we're moving it to the other garrison
|
||||
)
|
||||
{
|
||||
temp = CGI->generaltexth->tcommands[5]; //cannot move last stack!
|
||||
temp = CGI->generaltexth->tcommands[5]; //Cannot move last army to garrison
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = CGI->generaltexth->tcommands[6];
|
||||
temp = CGI->generaltexth->tcommands[6]; //Move %s
|
||||
boost::algorithm::replace_first(temp,"%s",owner->highlighted->creature->nameSing);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = CGI->generaltexth->tcommands[11];
|
||||
temp = CGI->generaltexth->tcommands[11]; //Empty
|
||||
}
|
||||
}
|
||||
LOCPLINT->statusbar->print(temp);
|
||||
@ -532,7 +536,7 @@ void CGarrisonInt::splitStacks(int am2)
|
||||
}
|
||||
CGarrisonInt::CGarrisonInt(int x, int y, int inx, const Point &garsOffset, SDL_Surface *&pomsur, const Point& SurOffset,
|
||||
const CArmedInstance *s1, const CArmedInstance *s2, bool smallImgs)
|
||||
:interx(inx),garOffset(garsOffset),highlighted(NULL),sur(pomsur),surOffset(surOffset),sup(NULL),
|
||||
:interx(inx),garOffset(garsOffset),highlighted(NULL),sur(pomsur),surOffset(SurOffset),sup(NULL),
|
||||
sdown(NULL),oup(s1),odown(s2), smallIcons(smallImgs)
|
||||
{
|
||||
active = false;
|
||||
@ -694,7 +698,7 @@ void SComponent::init(Etype Type, int Subtype, int Val)
|
||||
subtitle = CGI->arth->artifacts[Subtype].Name();
|
||||
break;
|
||||
case primskill:
|
||||
oss << ((Val>0)?("+"):("-")) << Val << " ";
|
||||
oss << std::showpos << Val << " ";
|
||||
if(Subtype < 4)
|
||||
{
|
||||
description = CGI->generaltexth->arraytxt[2+Subtype];
|
||||
|
@ -462,10 +462,6 @@ void ShowInInfobox::applyCl(CClient *cl)
|
||||
}
|
||||
}
|
||||
|
||||
void OpenWindow::applyFirstCl(CClient *cl)
|
||||
{
|
||||
}
|
||||
|
||||
void OpenWindow::applyCl(CClient *cl)
|
||||
{
|
||||
switch(window)
|
||||
|
@ -2553,7 +2553,10 @@ void CGEvent::activated( const CGHeroInstance * h ) const
|
||||
{
|
||||
InfoWindow iw;
|
||||
iw.player = h->tempOwner;
|
||||
iw.text << message;
|
||||
if(message.size())
|
||||
iw.text << message;
|
||||
else
|
||||
iw.text.addTxt(MetaString::ADVOB_TXT, 16);
|
||||
cb->showInfoDialog(&iw);
|
||||
cb->startBattleI(h->id,army,pos,boost::bind(&CGEvent::endBattle,this,h,_1));
|
||||
}
|
||||
@ -2688,9 +2691,15 @@ void CGEvent::giveContents( const CGHeroInstance *h, bool afterBattle ) const
|
||||
}
|
||||
|
||||
iw.components.clear();
|
||||
getText(iw,afterBattle,183,h);
|
||||
for(int i=0; i<artifacts.size(); i++)
|
||||
{
|
||||
iw.components.push_back(Component(Component::ARTIFACT,artifacts[i],0,0));
|
||||
if(iw.components.size() >= 14)
|
||||
{
|
||||
cb->showInfoDialog(&iw);
|
||||
iw.components.clear();
|
||||
}
|
||||
}
|
||||
if(iw.components.size())
|
||||
{
|
||||
@ -2768,7 +2777,7 @@ void CGEvent::giveContents( const CGHeroInstance *h, bool afterBattle ) const
|
||||
return;
|
||||
}
|
||||
|
||||
if(!afterBattle)
|
||||
if(!afterBattle && message.size())
|
||||
{
|
||||
iw.text << message;
|
||||
cb->showInfoDialog(&iw);
|
||||
@ -2780,7 +2789,7 @@ void CGEvent::giveContents( const CGHeroInstance *h, bool afterBattle ) const
|
||||
|
||||
void CGEvent::getText( InfoWindow &iw, bool &afterBattle, int text, const CGHeroInstance * h ) const
|
||||
{
|
||||
if(afterBattle)
|
||||
if(afterBattle || !message.size())
|
||||
{
|
||||
iw.text.addTxt(MetaString::ADVOB_TXT,text);//%s has lost treasure.
|
||||
iw.text.addReplacement(h->name);
|
||||
@ -2796,7 +2805,7 @@ void CGEvent::getText( InfoWindow &iw, bool &afterBattle, int val, int negative,
|
||||
{
|
||||
iw.components.clear();
|
||||
iw.text.clear();
|
||||
if(afterBattle)
|
||||
if(afterBattle || !message.size())
|
||||
{
|
||||
iw.text.addTxt(MetaString::ADVOB_TXT,val < 0 ? negative : positive); //%s's luck takes a turn for the worse / %s's luck increases
|
||||
iw.text.addReplacement(h->name);
|
||||
@ -2952,7 +2961,7 @@ void CGScholar::onHeroVisit( const CGHeroInstance * h ) const
|
||||
{
|
||||
case 0:
|
||||
cb->changePrimSkill(h->id,bid,+1);
|
||||
iw.components.push_back(Component(Component::PRIM_SKILL,bid,ssl+1,0));
|
||||
iw.components.push_back(Component(Component::PRIM_SKILL,bid,+1,0));
|
||||
break;
|
||||
case 1:
|
||||
cb->changeSecSkill(h->id,bid,+1);
|
||||
|
@ -334,7 +334,7 @@ public:
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & static_cast<CArmedInstance&>(*this);
|
||||
h & static_cast<CGDwelling&>(*this);
|
||||
h & name & builded & destroyed & identifier & alignment & forbiddenBuildings & builtBuildings
|
||||
& possibleSpells & obligatorySpells & spells & /*strInfo & */events;
|
||||
|
||||
|
@ -516,9 +516,7 @@ struct GiveHero : public CPackForClient //516
|
||||
struct OpenWindow : public CPackForClient //517
|
||||
{
|
||||
OpenWindow(){type = 517;};
|
||||
void applyFirstCl(CClient *cl);
|
||||
void applyCl(CClient *cl);
|
||||
DLL_EXPORT void applyGs(CGameState *gs);
|
||||
|
||||
enum EWindow {EXCHANGE_WINDOW, RECRUITMENT_FIRST, RECRUITMENT_ALL};
|
||||
ui8 window;
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
DLL_EXPORT void SetResource::applyGs( CGameState *gs )
|
||||
{
|
||||
amax(val, 0); //new value must be >= 0
|
||||
gs->getPlayer(player)->resources[resid] = val;
|
||||
}
|
||||
|
||||
@ -141,6 +142,7 @@ DLL_EXPORT void ChangeSpells::applyGs( CGameState *gs )
|
||||
DLL_EXPORT void SetMana::applyGs( CGameState *gs )
|
||||
{
|
||||
CGHeroInstance *hero = gs->getHero(hid);
|
||||
amax(val, 0); //not less than 0
|
||||
hero->mana = val;
|
||||
}
|
||||
|
||||
@ -424,10 +426,6 @@ DLL_EXPORT void GiveHero::applyGs( CGameState *gs )
|
||||
h->inTownGarrison = false;
|
||||
}
|
||||
|
||||
DLL_EXPORT void OpenWindow::applyGs(CGameState *gs)
|
||||
{
|
||||
}
|
||||
|
||||
DLL_EXPORT void NewTurn::applyGs( CGameState *gs )
|
||||
{
|
||||
gs->day = day;
|
||||
|
@ -1296,7 +1296,7 @@ void CGameHandler::giveResource(int player, int which, int val)
|
||||
SetResource sr;
|
||||
sr.player = player;
|
||||
sr.resid = which;
|
||||
sr.val = (gs->players.find(player)->second.resources[which]+val);
|
||||
sr.val = gs->players.find(player)->second.resources[which]+val;
|
||||
sendAndApply(&sr);
|
||||
}
|
||||
void CGameHandler::showCompInfo(ShowInInfobox * comp)
|
||||
|
Loading…
Reference in New Issue
Block a user