mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-23 12:08:45 +02:00
- some fixes for Castle Gate and Hill Fort
- removed unavailable in Hill Fort upgrades from cr_upgrade_list.txt - fixed bug in upgrading creatures - workaround to make VCMI work with Russian language files (possibly fixed 289)
This commit is contained in:
parent
221728c680
commit
e025a43cb0
@ -726,6 +726,12 @@ void CCastleInterface::buildingClicked(int building)
|
|||||||
break;
|
break;
|
||||||
/*Inferno*/ case 3: //Castle Gate
|
/*Inferno*/ case 3: //Castle Gate
|
||||||
{
|
{
|
||||||
|
if (!town->visitingHero)
|
||||||
|
{
|
||||||
|
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[126], std::vector<SComponent*>(), soundBase::sound_todo);
|
||||||
|
break;//only visiting hero can use castle gates
|
||||||
|
}
|
||||||
|
|
||||||
std::vector <int> availableTowns;
|
std::vector <int> availableTowns;
|
||||||
std::vector <const CGTownInstance*> Towns = LOCPLINT->cb->getTownsInfo(false);
|
std::vector <const CGTownInstance*> Towns = LOCPLINT->cb->getTownsInfo(false);
|
||||||
for(size_t i=0;i<Towns.size();i++)
|
for(size_t i=0;i<Towns.size();i++)
|
||||||
@ -737,11 +743,6 @@ void CCastleInterface::buildingClicked(int building)
|
|||||||
availableTowns.push_back(t->id);//add to the list
|
availableTowns.push_back(t->id);//add to the list
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!town->visitingHero)
|
|
||||||
{
|
|
||||||
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[126], std::vector<SComponent*>(), soundBase::sound_todo);
|
|
||||||
break;//only visiting hero can use castle gates
|
|
||||||
}
|
|
||||||
CPicture *titlePic = new CPicture (bicons->ourImages[building].bitmap, 0,0, false);//will be deleted by selection window
|
CPicture *titlePic = new CPicture (bicons->ourImages[building].bitmap, 0,0, false);//will be deleted by selection window
|
||||||
GH.pushInt (new CObjectListWindow(availableTowns, titlePic, CGI->generaltexth->jktexts[40],
|
GH.pushInt (new CObjectListWindow(availableTowns, titlePic, CGI->generaltexth->jktexts[40],
|
||||||
CGI->generaltexth->jktexts[41], boost::bind (&CCastleInterface::castleTeleport, this, _1)));
|
CGI->generaltexth->jktexts[41], boost::bind (&CCastleInterface::castleTeleport, this, _1)));
|
||||||
@ -790,7 +791,6 @@ void CCastleInterface::castleTeleport(int where)
|
|||||||
{
|
{
|
||||||
const CGTownInstance * dest = LOCPLINT->cb->getTownInfo(where, 1);
|
const CGTownInstance * dest = LOCPLINT->cb->getTownInfo(where, 1);
|
||||||
LOCPLINT->cb->teleportHero(town->visitingHero, dest);
|
LOCPLINT->cb->teleportHero(town->visitingHero, dest);
|
||||||
close();//close this window, interface with new town will be called by town::onVisit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCastleInterface::defaultBuildingClicked(int building)
|
void CCastleInterface::defaultBuildingClicked(int building)
|
||||||
|
@ -351,6 +351,8 @@ void CPlayerInterface::heroCreated(const CGHeroInstance * hero)
|
|||||||
}
|
}
|
||||||
void CPlayerInterface::openTownWindow(const CGTownInstance * town)
|
void CPlayerInterface::openTownWindow(const CGTownInstance * town)
|
||||||
{
|
{
|
||||||
|
if (castleInt)
|
||||||
|
GH.popIntTotally(castleInt);
|
||||||
castleInt = new CCastleInterface(town);
|
castleInt = new CCastleInterface(town);
|
||||||
GH.pushInt(castleInt);
|
GH.pushInt(castleInt);
|
||||||
}
|
}
|
||||||
|
@ -6031,7 +6031,7 @@ CHillFortWindow::CHillFortWindow(const CGHeroInstance *visitor, const CGObjectIn
|
|||||||
for (int i=0; i<slotsCount; i++)
|
for (int i=0; i<slotsCount; i++)
|
||||||
{
|
{
|
||||||
currState[i] = getState(i);
|
currState[i] = getState(i);
|
||||||
upgrade[i] = new AdventureMapButton("","",boost::bind(&CHillFortWindow::makeDeal, this, i), 107+i*76, 171, getDefForSlot(i));
|
upgrade[i] = new AdventureMapButton(getTextForSlot(i),"",boost::bind(&CHillFortWindow::makeDeal, this, i), 107+i*76, 171, getDefForSlot(i));
|
||||||
upgrade[i]->block(currState[i] == -1);
|
upgrade[i]->block(currState[i] == -1);
|
||||||
}
|
}
|
||||||
currState[slotsCount] = getState(slotsCount);
|
currState[slotsCount] = getState(slotsCount);
|
||||||
@ -6079,8 +6079,9 @@ void CHillFortWindow::updateGarrisons()
|
|||||||
if (info.newID.size())//we have upgrades here - update costs
|
if (info.newID.size())//we have upgrades here - update costs
|
||||||
for(std::set<std::pair<int,int> >::iterator it=info.cost[0].begin(); it!=info.cost[0].end(); it++)
|
for(std::set<std::pair<int,int> >::iterator it=info.cost[0].begin(); it!=info.cost[0].end(); it++)
|
||||||
{
|
{
|
||||||
costs[i].insert(*it);
|
std::pair<int, int> pair = std::make_pair(it->first, it->second * hero->getAmount(i) );
|
||||||
totalSumm[it->first] += it->second;
|
costs[i].insert(pair);
|
||||||
|
totalSumm[pair.first] += pair.second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6089,6 +6090,7 @@ void CHillFortWindow::updateGarrisons()
|
|||||||
currState[i] = newState;
|
currState[i] = newState;
|
||||||
upgrade[i]->setDef(getDefForSlot(i), false, true);
|
upgrade[i]->setDef(getDefForSlot(i), false, true);
|
||||||
upgrade[i]->block(currState[i] == -1);
|
upgrade[i]->block(currState[i] == -1);
|
||||||
|
upgrade[i]->hoverTexts[0] = getTextForSlot(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6182,6 +6184,21 @@ std::string CHillFortWindow::getDefForSlot(int slot)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CHillFortWindow::getTextForSlot(int slot)
|
||||||
|
{
|
||||||
|
if ( !hero->getCreature(slot) )//we dont have creature here
|
||||||
|
return "";
|
||||||
|
|
||||||
|
std::string str = CGI->generaltexth->allTexts[318];
|
||||||
|
int amount = hero->getAmount(slot);
|
||||||
|
if ( amount == 1 )
|
||||||
|
boost::algorithm::replace_first(str,"%s",hero->getCreature(slot)->nameSing);
|
||||||
|
else
|
||||||
|
boost::algorithm::replace_first(str,"%s",hero->getCreature(slot)->namePl);
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
int CHillFortWindow::getState(int slot)
|
int CHillFortWindow::getState(int slot)
|
||||||
{
|
{
|
||||||
if ( slot == slotsCount )//"Upgrade all" slot
|
if ( slot == slotsCount )//"Upgrade all" slot
|
||||||
|
@ -1153,7 +1153,8 @@ public:
|
|||||||
void activate();
|
void activate();
|
||||||
void deactivate();
|
void deactivate();
|
||||||
void showAll (SDL_Surface *to);
|
void showAll (SDL_Surface *to);
|
||||||
std::string getDefForSlot(int slot);
|
std::string getDefForSlot(int slot);//return def name for this slot
|
||||||
|
std::string getTextForSlot(int slot);//return hover text for this slot
|
||||||
void makeDeal(int slot);//-1 for upgrading all creatures
|
void makeDeal(int slot);//-1 for upgrading all creatures
|
||||||
int getState(int slot); //-1 = no creature 0=can't upgrade, 1=upgraded, 2=can upgrade
|
int getState(int slot); //-1 = no creature 0=can't upgrade, 1=upgraded, 2=can upgrade
|
||||||
void updateGarrisons();//update buttons after garrison changes
|
void updateGarrisons();//update buttons after garrison changes
|
||||||
|
@ -61,20 +61,4 @@
|
|||||||
114 129
|
114 129
|
||||||
115 123
|
115 123
|
||||||
130 131
|
130 131
|
||||||
2 137
|
|
||||||
3 137
|
|
||||||
18 137
|
|
||||||
19 137
|
|
||||||
34 136
|
|
||||||
35 136
|
|
||||||
8 136
|
|
||||||
9 136
|
|
||||||
13 150
|
|
||||||
27 151
|
|
||||||
41 152
|
|
||||||
55 153
|
|
||||||
69 154
|
|
||||||
83 155
|
|
||||||
97 156
|
|
||||||
111 157
|
|
||||||
131 15
|
131 15
|
@ -450,7 +450,13 @@ void CHeroHandler::loadHeroClasses()
|
|||||||
char name[BUFFER_SIZE+1];
|
char name[BUFFER_SIZE+1];
|
||||||
str.get(name, BUFFER_SIZE, '\t');
|
str.get(name, BUFFER_SIZE, '\t');
|
||||||
hc->name = name;
|
hc->name = name;
|
||||||
str >> hc->aggression;
|
//workaround for locale issue (different localisations use different decimal separator)
|
||||||
|
int intPart,fracPart;
|
||||||
|
str >> intPart;
|
||||||
|
str.ignore();//ignore decimal separator
|
||||||
|
str >> fracPart;
|
||||||
|
hc->aggression = intPart + fracPart/100.0f;
|
||||||
|
|
||||||
str >> hc->initialAttack;
|
str >> hc->initialAttack;
|
||||||
str >> hc->initialDefence;
|
str >> hc->initialDefence;
|
||||||
str >> hc->initialPower;
|
str >> hc->initialPower;
|
||||||
|
@ -2794,17 +2794,17 @@ bool CGameHandler::upgradeCreature( ui32 objid, ui8 pos, ui32 upgID )
|
|||||||
UpgradeInfo ui = gs->getUpgradeInfo(obj->getStack(pos));
|
UpgradeInfo ui = gs->getUpgradeInfo(obj->getStack(pos));
|
||||||
int player = obj->tempOwner;
|
int player = obj->tempOwner;
|
||||||
int crQuantity = obj->slots[pos].count;
|
int crQuantity = obj->slots[pos].count;
|
||||||
|
int newIDpos= vstd::findPos(ui.newID, upgID);//get position of new id in UpgradeInfo
|
||||||
|
|
||||||
//check if upgrade is possible
|
//check if upgrade is possible
|
||||||
if((ui.oldID<0 || !vstd::contains(ui.newID,upgID)) && complain("That upgrade is not possible!"))
|
if( (ui.oldID<0 || newIDpos == -1 ) && complain("That upgrade is not possible!"))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//check if player has enough resources
|
//check if player has enough resources
|
||||||
for(int i=0;i<ui.cost.size();i++)
|
for (std::set<std::pair<int,int> >::iterator j=ui.cost[newIDpos].begin(); j!=ui.cost[newIDpos].end(); j++)
|
||||||
{
|
|
||||||
for (std::set<std::pair<int,int> >::iterator j=ui.cost[i].begin(); j!=ui.cost[i].end(); j++)
|
|
||||||
{
|
{
|
||||||
if(gs->getPlayer(player)->resources[j->first] < j->second*crQuantity)
|
if(gs->getPlayer(player)->resources[j->first] < j->second*crQuantity)
|
||||||
{
|
{
|
||||||
@ -2812,12 +2812,9 @@ bool CGameHandler::upgradeCreature( ui32 objid, ui8 pos, ui32 upgID )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//take resources
|
//take resources
|
||||||
for(int i=0;i<ui.cost.size();i++)
|
for (std::set<std::pair<int,int> >::iterator j=ui.cost[newIDpos].begin(); j!=ui.cost[newIDpos].end(); j++)
|
||||||
{
|
|
||||||
for (std::set<std::pair<int,int> >::iterator j=ui.cost[i].begin(); j!=ui.cost[i].end(); j++)
|
|
||||||
{
|
{
|
||||||
SetResource sr;
|
SetResource sr;
|
||||||
sr.player = player;
|
sr.player = player;
|
||||||
@ -2825,7 +2822,6 @@ bool CGameHandler::upgradeCreature( ui32 objid, ui8 pos, ui32 upgID )
|
|||||||
sr.val = gs->getPlayer(player)->resources[j->first] - j->second*crQuantity;
|
sr.val = gs->getPlayer(player)->resources[j->first] - j->second*crQuantity;
|
||||||
sendAndApply(&sr);
|
sendAndApply(&sr);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//upgrade creature
|
//upgrade creature
|
||||||
SetGarrisons sg;
|
SetGarrisons sg;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user