1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00
This commit is contained in:
Ivan Savenko
2010-01-01 18:54:31 +00:00
parent 711094da82
commit 58d1ec7ac5
5 changed files with 45 additions and 66 deletions

View File

@@ -1034,7 +1034,7 @@ void CCastleInterface::CCreaInfo::hover(bool on)
}
void CCastleInterface::CCreaInfo::clickLeft(tribool down, bool previousState)
{
if(down)
if(previousState && (!down))
{
LOCPLINT->castleInt->showRecruitmentWindow(bid);
}
@@ -1169,7 +1169,7 @@ void CCastleInterface::CTownInfo::hover(bool on)
}
void CCastleInterface::CTownInfo::clickLeft(tribool down, bool previousState)
{
if(down)
if(previousState && (!down))
if (LOCPLINT->castleInt->town->builtBuildings.find(bid)!=LOCPLINT->castleInt->town->builtBuildings.end())
LOCPLINT->castleInt->buildingClicked(bid);//activate building
}
@@ -1321,7 +1321,11 @@ void CHallInterface::CBuildingBox::clickRight(tribool down, bool previousState)
void CHallInterface::CBuildingBox::show(SDL_Surface * to)
{
CCastleInterface *ci = LOCPLINT->castleInt;
blitAt(ci->bicons->ourImages[BID].bitmap,pos.x,pos.y,to);
if (( (BID == 18) && (vstd::contains(ci->town->builtBuildings,(ci->town->town->hordeLvl[0]+37))))
|| ( (BID == 24) && (vstd::contains(ci->town->builtBuildings,(ci->town->town->hordeLvl[1]+37)))) )
blitAt(ci->bicons->ourImages[BID+1].bitmap,pos.x,pos.y,to);
else
blitAt(ci->bicons->ourImages[BID].bitmap,pos.x,pos.y,to);
int pom, pom2=-1;
switch (state)
{
@@ -1349,30 +1353,20 @@ void CHallInterface::CBuildingBox::show(SDL_Surface * to)
blitAt(ci->status->ourImages[pom2].bitmap,pos.x+135, pos.y+54,to);
CSDL_Ext::printAtMiddle(CGI->buildh->buildings[ci->town->subID][BID]->Name(),pos.x-1+ci->bars->ourImages[0].bitmap->w/2,pos.y+71+ci->bars->ourImages[0].bitmap->h/2, GEOR13,zwykly,to);
}
void CHallInterface::CBuildingBox::activate()
{
activateHover();
activateLClick();
activateRClick();
}
void CHallInterface::CBuildingBox::deactivate()
{
deactivateHover();
deactivateLClick();
deactivateRClick();
}
CHallInterface::CBuildingBox::~CBuildingBox()
{
}
CHallInterface::CBuildingBox::CBuildingBox(int id)
:BID(id)
{
used = LCLICK | RCLICK | HOVER;
pos.w = 150;
pos.h = 88;
}
CHallInterface::CBuildingBox::CBuildingBox(int id, int x, int y)
:BID(id)
{
used = LCLICK | RCLICK | HOVER;
pos.x = x;
pos.y = y;
pos.w = 150;
@@ -1797,16 +1791,6 @@ void CFortScreen::RecArea::clickLeft(tribool down, bool previousState)
}
//ClickableL::clickLeft(down);
}
void CFortScreen::RecArea::activate()
{
activateLClick();
activateRClick();
}
void CFortScreen::RecArea::deactivate()
{
deactivateLClick();
deactivateRClick();
}
void CFortScreen::RecArea::clickRight(tribool down, bool previousState)
{
@@ -1933,20 +1917,6 @@ void CMageGuildScreen::Scroll::hover(bool on)
}
void CMageGuildScreen::Scroll::activate()
{
activateLClick();
activateRClick();
activateHover();
}
void CMageGuildScreen::Scroll::deactivate()
{
deactivateLClick();
deactivateRClick();
deactivateHover();
}
CBlacksmithDialog::CBlacksmithDialog(bool possible, int creMachineID, int aid, int hid)
{
SDL_Surface *bg2 = BitmapHandler::loadBitmap("TPSMITH.bmp");

View File

@@ -160,8 +160,6 @@ public:
void clickLeft(tribool down, bool previousState);
void clickRight(tribool down, bool previousState);
void show(SDL_Surface * to);
void activate();
void deactivate();
CBuildingBox(int id); //c-tor
CBuildingBox(int id, int x, int y); //c-tor
~CBuildingBox(); //d-tor
@@ -207,11 +205,9 @@ class CFortScreen : public CIntObject
{
public:
int bid;
RecArea(int BID):bid(BID){}; //c-tor
RecArea(int BID):bid(BID){used = LCLICK | RCLICK;}; //c-tor
void clickLeft(tribool down, bool previousState);
void clickRight(tribool down, bool previousState);
void activate();
void deactivate();
};
public:
CMinorResDataBar * resdatabar;
@@ -239,12 +235,10 @@ public:
public:
CSpell *spell;
Scroll(CSpell *Spell):spell(Spell){};
Scroll(CSpell *Spell):spell(Spell){used = LCLICK | RCLICK | HOVER;};
void clickLeft(tribool down, bool previousState);
void clickRight(tribool down, bool previousState);
void hover(bool on);
void activate();
void deactivate();
};
std::vector<std::vector<SDL_Rect> > positions;

View File

@@ -1124,6 +1124,28 @@ std::pair<int,int> CGameState::pickObject (CGObjectInstance *obj)
}
return std::pair<int,int>(-1,-1);
}
void convertHordes(CGTownInstance * town)//converting hordes from -36..-30 to 18 & 24
{
for (int i = 0; i<CREATURES_PER_TOWN; i++)
if (vstd::contains(town->builtBuildings,(-31-i))) //if we have horde for this level
{
town->builtBuildings.erase(-31-i);//remove old ID
if (town->town->hordeLvl[0] == i)//if town first horde is this one
{
town->builtBuildings.insert(18);//add it
if (vstd::contains(town->builtBuildings,(37+i)))//if we have upgraded dwelling as well
town->builtBuildings.insert(19);//add it as well
}
if (town->town->hordeLvl[1] == i)//if town second horde is this one
{
town->builtBuildings.insert(24);//add it
if (vstd::contains(town->builtBuildings,(37+i)))//if we have upgraded dwelling as well
town->builtBuildings.insert(25);//add it as well
}
}
}
void CGameState::randomizeObject(CGObjectInstance *cur)
{
std::pair<int,int> ran = pickObject(cur);
@@ -1138,6 +1160,7 @@ void CGameState::randomizeObject(CGObjectInstance *cur)
t->defInfo = forts[t->subID];
else
t->defInfo = villages[t->subID];
convertHordes(t);
}
return;
}
@@ -1164,6 +1187,7 @@ void CGameState::randomizeObject(CGObjectInstance *cur)
t->defInfo = forts[t->subID];
else
t->defInfo = villages[t->subID];
convertHordes(t);
map->towns.push_back(t);
return;
}

View File

@@ -39,21 +39,8 @@ static std::set<si32> convertBuildings(const std::set<si32> h3m, int castleID)
ret.insert(mapa[*i]);
else if(mapa[*i] >= (-CREATURES_PER_TOWN)) // horde buildings
{
int level = (-mapa[*i]);
if(h3m.find(20+(level*3)) != h3m.end()) //upgraded creature horde building
{
if(((castleID==1 && level==5) || (castleID==3 && level==3)))
ret.insert(25);
else
ret.insert(19);
}
//else
//{
if(((castleID==1 && level==5) || (castleID==3 && level==3)))
ret.insert(24);
else
ret.insert(18);
//}
int level = (mapa[*i]);
ret.insert(level-30);//(-30)..(-36) - horde buildings (for game loading only), don't see other way to handle hordes in random towns
}
else
{

View File

@@ -2018,11 +2018,15 @@ bool CGameHandler::buildStructure( si32 tid, si32 bid )
NewStructures ns;
ns.tid = tid;
if(bid>36) //upg dwelling
if ( (bid == 18) && (vstd::contains(t->builtBuildings,(t->town->hordeLvl[0]+37))) )
ns.bid.insert(19);//we have upgr. dwelling, upgr. horde will be builded as well
else if ( (bid == 24) && (vstd::contains(t->builtBuildings,(t->town->hordeLvl[1]+37))) )
ns.bid.insert(25);
else if(bid>36) //upg dwelling
{
if(t->getHordeLevel(0) == (bid-37))
ns.bid.insert(19);
else if(t->getHordeLevel(1) == (bid-37))
if ( (bid-37 == t->town->hordeLvl[0]) && (vstd::contains(t->builtBuildings,18)) )
ns.bid.insert(19);//we have horde, will be upgraded as well as dwelling
if ( (bid-37 == t->town->hordeLvl[1]) && (vstd::contains(t->builtBuildings,24)) )
ns.bid.insert(25);
SetAvailableCreatures ssi;