mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
* setting army formation
* minor changes
This commit is contained in:
parent
72331db843
commit
70673674dc
@ -159,6 +159,20 @@ void AdventureMapButton::block( bool on )
|
||||
bitmapOffset = on ? 2 : 0;
|
||||
show();
|
||||
}
|
||||
void CHighlightableButton::select(bool on)
|
||||
{
|
||||
selected = on;
|
||||
state = selected ? 3 : 0;
|
||||
if(selected)
|
||||
callback();
|
||||
else
|
||||
callback2();
|
||||
if(hoverTexts.size()>1)
|
||||
{
|
||||
hover(false);
|
||||
hover(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CHighlightableButton::clickLeft( tribool down )
|
||||
{
|
||||
@ -172,17 +186,7 @@ void CHighlightableButton::clickLeft( tribool down )
|
||||
if (pressedL && (down==false))
|
||||
{
|
||||
pressedL=state;
|
||||
selected = !selected;
|
||||
state = selected ? 3 : 0;
|
||||
if(selected)
|
||||
callback();
|
||||
else
|
||||
callback2();
|
||||
if(hoverTexts.size()>1)
|
||||
{
|
||||
hover(false);
|
||||
hover(true);
|
||||
}
|
||||
select(!selected);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
CHighlightableButton(const CFunctionList<void()> &onSelect, const CFunctionList<void()> &onDeselect, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, bool activ );
|
||||
bool selected;
|
||||
CFunctionList<void()> callback2; //when disselecting
|
||||
void select(bool on);
|
||||
void clickLeft (tribool down);
|
||||
};
|
||||
|
||||
|
@ -586,4 +586,10 @@ void CCallback::trade( int mode, int id1, int id2, int val1 )
|
||||
int p1, p2;
|
||||
getMarketOffer(id1,id2,p1,p2,mode);
|
||||
*cl->serv << ui16(511) << ui8(player) << ui32(mode) << ui32(id1) << ui32(id2) << ui32(val1);
|
||||
}
|
||||
|
||||
void CCallback::setFormation(const CGHeroInstance * hero, bool loose)
|
||||
{
|
||||
hero->looseFormation = loose;
|
||||
*cl->serv << ui16(512) << hero->id << ui8(loose);
|
||||
}
|
@ -42,6 +42,7 @@ public:
|
||||
virtual void swapGarrisonHero(const CGTownInstance *town)=0;
|
||||
virtual void buyArtifact(const CGHeroInstance *hero, int aid)=0; //used to buy artifacts in towns (including spell book in the guild and war machines in blacksmith)
|
||||
virtual void trade(int mode, int id1, int id2, int val1)=0; //mode==0: sell val1 units of id1 resource for id2 resiurce
|
||||
virtual void setFormation(const CGHeroInstance * hero, bool loose)=0;
|
||||
|
||||
//get info
|
||||
virtual bool verifyPath(CPath * path, bool blockSea)=0;
|
||||
@ -121,6 +122,7 @@ public:
|
||||
void swapGarrisonHero(const CGTownInstance *town);
|
||||
void buyArtifact(const CGHeroInstance *hero, int aid);
|
||||
void trade(int mode, int id1, int id2, int val1);
|
||||
void setFormation(const CGHeroInstance * hero, bool loose);
|
||||
|
||||
//get info
|
||||
bool verifyPath(CPath * path, bool blockSea);
|
||||
|
@ -48,8 +48,8 @@ CHeroWindow::CHeroWindow(int playerColor):
|
||||
dismissButton = new AdventureMapButton(std::string(), CGI->generaltexth->heroscrn[28], boost::bind(&CHeroWindow::dismissCurrent,this), 519, 437, "hsbtns2.def", false, NULL, false);
|
||||
questlogButton = new AdventureMapButton(CGI->generaltexth->heroscrn[0], std::string(), boost::bind(&CHeroWindow::questlog,this), 379, 437, "hsbtns4.def", false, NULL, false);
|
||||
|
||||
gar1button = new AdventureMapButton(CGI->generaltexth->heroscrn[23], CGI->generaltexth->heroscrn[29], boost::bind(&CHeroWindow::gar1,this), 546, 491, "hsbtns6.def", false, NULL, false);
|
||||
gar3button = new AdventureMapButton(CGI->generaltexth->heroscrn[24], CGI->generaltexth->heroscrn[30], boost::bind(&CHeroWindow::gar3,this), 546, 527, "hsbtns7.def", false, NULL, false);
|
||||
gar1button = new CHighlightableButton(0,0,map_list_of(0,CGI->generaltexth->heroscrn[23]), CGI->generaltexth->heroscrn[29], false, "hsbtns6.def" , NULL,546, 491, false);
|
||||
gar3button = new CHighlightableButton(0,0,map_list_of(0,CGI->generaltexth->heroscrn[24]), CGI->generaltexth->heroscrn[30], false, "hsbtns7.def", NULL, 546, 527, false);
|
||||
gar2button = new CHighlightableButton(0, 0, map_list_of(0,CGI->generaltexth->heroscrn[26])(3,CGI->generaltexth->heroscrn[25]), CGI->generaltexth->heroscrn[31], false, "hsbtns8.def", NULL, 604, 491, false);
|
||||
gar4button = new AdventureMapButton(CGI->generaltexth->allTexts[256], CGI->generaltexth->heroscrn[32], boost::function<void()>(), 604, 527, "hsbtns9.def", false, NULL, false);
|
||||
boost::algorithm::replace_first(gar4button->hoverTexts[0],"%s",CGI->generaltexth->allTexts[43]);
|
||||
@ -307,9 +307,21 @@ void CHeroWindow::setHero(const CGHeroInstance *Hero)
|
||||
else
|
||||
{
|
||||
gar2button->block(false);
|
||||
gar2button->callback = boost::bind(vstd::assign<bool,bool>,boost::ref(hero->tacticFormationEnabled), true);
|
||||
gar2button->callback2 = boost::bind(vstd::assign<bool,bool>,boost::ref(hero->tacticFormationEnabled), true);
|
||||
gar2button->callback = vstd::assigno(hero->tacticFormationEnabled,true);
|
||||
gar2button->callback2 = vstd::assigno(hero->tacticFormationEnabled,false);
|
||||
}
|
||||
gar1button->callback.clear();
|
||||
gar1button->callback = vstd::assigno(hero->looseFormation,true);
|
||||
gar1button->callback += boost::bind(&CHighlightableButton::select, gar3button, false);
|
||||
gar1button->callback += boost::bind(&CCallback::setFormation, LOCPLINT->cb, Hero, true);
|
||||
gar3button->callback.clear();
|
||||
gar3button->callback = vstd::assigno(hero->looseFormation,false);
|
||||
gar3button->callback += boost::bind(&CHighlightableButton::select, gar1button, false);
|
||||
gar3button->callback += boost::bind(&CCallback::setFormation, LOCPLINT->cb, Hero, false);
|
||||
if(hero->looseFormation)
|
||||
gar1button->select(true);
|
||||
else
|
||||
gar3button->select(true);
|
||||
redrawCurBack();
|
||||
}
|
||||
|
||||
|
@ -91,14 +91,8 @@ class CHeroWindow: public IShowActivable, public virtual CIntObject
|
||||
|
||||
//buttons
|
||||
AdventureMapButton * gar4button; //splitting
|
||||
//std::vector< AdventureMapButton<CHeroWindow> * > heroList; //list of heroes
|
||||
std::vector<LClickableAreaHero *> heroListMi; //new better list of heroes
|
||||
|
||||
//artifact places
|
||||
//CArtPlace * artHead, * artLRing, * artRRing, * artLHand, * artRhand,
|
||||
// * artFeet, * artSpellBook, * artMach1, * artMach2, * artMach3,
|
||||
// * artMach4, * artMisc1, * artMisc2, * artMisc3, * artMisc4,
|
||||
// * artMisc5, * artTorso, * artNeck, * artShoulders; //hero's artifacts
|
||||
std::vector<CArtPlace *> artWorn; // 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
|
||||
std::vector<CArtPlace *> backpack; //hero's visible backpack (only 5 elements!)
|
||||
int backpackPos; //unmber of first art visible in backpack (in hero's vector)
|
||||
@ -111,9 +105,8 @@ class CHeroWindow: public IShowActivable, public virtual CIntObject
|
||||
std::vector<LRClickableAreaWTextComp *> secSkillAreas;
|
||||
public:
|
||||
AdventureMapButton * quitButton, * dismissButton, * questlogButton, //general
|
||||
* gar1button, * gar3button, //garrison / formation handling
|
||||
* leftArtRoll, * rightArtRoll;
|
||||
CHighlightableButton *gar2button;
|
||||
CHighlightableButton *gar2button, *gar1button, *gar3button; //garrison / formation handling;
|
||||
int player;
|
||||
CHeroWindow(int playerColor); //c-tor
|
||||
~CHeroWindow(); //d-tor
|
||||
|
@ -412,7 +412,7 @@ void CClient::process(int what)
|
||||
CGHeroInstance *h = gs->getHero(bs.heroid);
|
||||
if(vstd::contains(playerint,h->tempOwner))
|
||||
{
|
||||
boost::function<void(ui32)> callback = boost::function<void(ui32)>(boost::bind(&CCallback::selectionMade,cb,_1,bs.id));
|
||||
boost::function<void(ui32)> callback = boost::function<void(ui32)>(boost::bind(&CCallback::selectionMade,LOCPLINT->cb,_1,bs.id));
|
||||
playerint[h->tempOwner]->heroGotLevel((const CGHeroInstance *)h,(int)bs.primskill,bs.skills, callback);
|
||||
}
|
||||
break;
|
||||
|
@ -565,7 +565,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ClassDiagram1.cd"
|
||||
RelativePath=".\ttt.txt"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
|
19
global.h
19
global.h
@ -157,6 +157,25 @@ namespace vstd
|
||||
{
|
||||
a1 = a2;
|
||||
}
|
||||
template <typename t1, typename t2>
|
||||
struct assigner
|
||||
{
|
||||
public:
|
||||
t1 &op1;
|
||||
t2 op2;
|
||||
assigner(t1 &a1, t2 a2)
|
||||
:op1(a1), op2(a2)
|
||||
{}
|
||||
void operator()()
|
||||
{
|
||||
op1 = op2;
|
||||
}
|
||||
};
|
||||
template <typename t1, typename t2>
|
||||
assigner<t1,t2> assigno(t1 &a1, const t2 &a2)
|
||||
{
|
||||
return assigner<t1,t2>(a1,a2);
|
||||
}
|
||||
template <typename t1, typename t2, typename t3>
|
||||
bool equal(const t1 &a1, const t3 t1::* point, const t2 &a2)
|
||||
{
|
||||
|
@ -397,6 +397,7 @@ CGObjectInstance::~CGObjectInstance()
|
||||
}
|
||||
CGHeroInstance::CGHeroInstance()
|
||||
{
|
||||
looseFormation = true;
|
||||
tacticFormationEnabled = inTownGarrison = false;
|
||||
portrait = level = exp = -1;
|
||||
isStanding = true;
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
mutable int moveDir; //format: 123
|
||||
// 8 4
|
||||
// 765
|
||||
mutable bool isStanding, tacticFormationEnabled;
|
||||
mutable ui8 isStanding, tacticFormationEnabled, looseFormation;
|
||||
CHero * type;
|
||||
ui32 exp; //experience point
|
||||
int level; //current level of hero
|
||||
|
@ -849,6 +849,14 @@ upgend:
|
||||
sr.val = gs->players[player].resources[id2] + (int)uzysk;
|
||||
sendAndApply(&sr);
|
||||
|
||||
break;
|
||||
}
|
||||
case 512:
|
||||
{
|
||||
si32 hid;
|
||||
ui8 formation;
|
||||
c >> hid >> formation;
|
||||
gs->getHero(hid)->army.formation = !formation;
|
||||
break;
|
||||
}
|
||||
case 2001:
|
||||
|
Loading…
Reference in New Issue
Block a user