1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

* moved map reading to the map.cpp

* merged changes from trunk (since r461)
This commit is contained in:
Michał W. Urbańczyk
2008-06-21 13:27:52 +00:00
parent c7dde147c3
commit c351496a47
15 changed files with 2346 additions and 2275 deletions

View File

@@ -213,7 +213,7 @@ void CBattleInterface::show(SDL_Surface * to)
}
}
//showing selected unit's range
if(creAnims[activeStack]->getType() != 0) //don't show if unit is moving
if(activeStack != -1 && creAnims[activeStack]->getType() != 0) //don't show if unit is moving
{
showRange(to, activeStack);
}
@@ -240,37 +240,68 @@ void CBattleInterface::show(SDL_Surface * to)
defendingHero->show(to);
//showing units //a lot of work...
int stackByHex[187];
for(int b=0; b<187; ++b)
stackByHex[b] = -1;
std::vector<int> stackAliveByHex[187];
//double loop because dead stacks should be printed first
for(std::map<int, CStack>::iterator j=stacks.begin(); j!=stacks.end(); ++j)
{
stackByHex[j->second.position] = j->second.ID;
if(j->second.alive)
stackAliveByHex[j->second.position].push_back(j->second.ID);
}
std::vector<int> stackDeadByHex[187];
for(std::map<int, CStack>::iterator j=stacks.begin(); j!=stacks.end(); ++j)
{
if(!j->second.alive)
stackDeadByHex[j->second.position].push_back(j->second.ID);
}
attackingShowHelper(); // handle attack animation
for(int b=0; b<187; ++b)
for(int b=0; b<187; ++b) //showing dead stacks
{
if(stackByHex[b]!=-1)
for(int v=0; v<stackDeadByHex[b].size(); ++v)
{
creAnims[stackByHex[b]]->nextFrame(to, creAnims[stackByHex[b]]->pos.x, creAnims[stackByHex[b]]->pos.y, creDir[stackByHex[b]], (animCount%2==0 || creAnims[stackByHex[b]]->getType()!=2) && stacks[stackByHex[b]].alive, stackByHex[b]==activeStack); //increment always when moving, never if stack died
creAnims[stackDeadByHex[b][v]]->nextFrame(to, creAnims[stackDeadByHex[b][v]]->pos.x, creAnims[stackDeadByHex[b][v]]->pos.y, creDir[stackDeadByHex[b][v]], (animCount%2==0 || creAnims[stackDeadByHex[b][v]]->getType()!=2) && stacks[stackDeadByHex[b][v]].alive, stackDeadByHex[b][v]==activeStack); //increment always when moving, never if stack died
//printing amount
if(stacks[stackByHex[b]].amount > 0) //don't print if stack is not alive
if(stacks[stackDeadByHex[b][v]].amount > 0) //don't print if stack is not alive
{
if(stacks[stackByHex[b]].attackerOwned)
if(stacks[stackDeadByHex[b][v]].attackerOwned)
{
CSDL_Ext::blit8bppAlphaTo24bpp(amountNormal, NULL, to, &genRect(amountNormal->h, amountNormal->w, creAnims[stackByHex[b]]->pos.x + 220, creAnims[stackByHex[b]]->pos.y + 260));
CSDL_Ext::blit8bppAlphaTo24bpp(amountNormal, NULL, to, &genRect(amountNormal->h, amountNormal->w, creAnims[stackDeadByHex[b][v]]->pos.x + 220, creAnims[stackDeadByHex[b][v]]->pos.y + 260));
std::stringstream ss;
ss<<stacks[stackByHex[b]].amount;
CSDL_Ext::printAtMiddleWB(ss.str(), creAnims[stackByHex[b]]->pos.x + 220 + 14, creAnims[stackByHex[b]]->pos.y + 260 + 4, GEOR13, 20, zwykly, to);
ss<<stacks[stackDeadByHex[b][v]].amount;
CSDL_Ext::printAtMiddleWB(ss.str(), creAnims[stackDeadByHex[b][v]]->pos.x + 220 + 14, creAnims[stackDeadByHex[b][v]]->pos.y + 260 + 4, GEOR13, 20, zwykly, to);
}
else
{
CSDL_Ext::blit8bppAlphaTo24bpp(amountNormal, NULL, to, &genRect(amountNormal->h, amountNormal->w, creAnims[stackByHex[b]]->pos.x + 202, creAnims[stackByHex[b]]->pos.y + 260));
CSDL_Ext::blit8bppAlphaTo24bpp(amountNormal, NULL, to, &genRect(amountNormal->h, amountNormal->w, creAnims[stackDeadByHex[b][v]]->pos.x + 202, creAnims[stackDeadByHex[b][v]]->pos.y + 260));
std::stringstream ss;
ss<<stacks[stackByHex[b]].amount;
CSDL_Ext::printAtMiddleWB(ss.str(), creAnims[stackByHex[b]]->pos.x + 202 + 14, creAnims[stackByHex[b]]->pos.y + 260 + 4, GEOR13, 20, zwykly, to);
ss<<stacks[stackDeadByHex[b][v]].amount;
CSDL_Ext::printAtMiddleWB(ss.str(), creAnims[stackDeadByHex[b][v]]->pos.x + 202 + 14, creAnims[stackDeadByHex[b][v]]->pos.y + 260 + 4, GEOR13, 20, zwykly, to);
}
}
}
}
for(int b=0; b<187; ++b) //showing alive stacks
{
for(int v=0; v<stackAliveByHex[b].size(); ++v)
{
creAnims[stackAliveByHex[b][v]]->nextFrame(to, creAnims[stackAliveByHex[b][v]]->pos.x, creAnims[stackAliveByHex[b][v]]->pos.y, creDir[stackAliveByHex[b][v]], (animCount%2==0 || creAnims[stackAliveByHex[b][v]]->getType()!=2) && stacks[stackAliveByHex[b][v]].alive, stackAliveByHex[b][v]==activeStack); //increment always when moving, never if stack died
//printing amount
if(stacks[stackAliveByHex[b][v]].amount > 0) //don't print if stack is not alive
{
if(stacks[stackAliveByHex[b][v]].attackerOwned)
{
CSDL_Ext::blit8bppAlphaTo24bpp(amountNormal, NULL, to, &genRect(amountNormal->h, amountNormal->w, creAnims[stackAliveByHex[b][v]]->pos.x + 220, creAnims[stackAliveByHex[b][v]]->pos.y + 260));
std::stringstream ss;
ss<<stacks[stackAliveByHex[b][v]].amount;
CSDL_Ext::printAtMiddleWB(ss.str(), creAnims[stackAliveByHex[b][v]]->pos.x + 220 + 14, creAnims[stackAliveByHex[b][v]]->pos.y + 260 + 4, GEOR13, 20, zwykly, to);
}
else
{
CSDL_Ext::blit8bppAlphaTo24bpp(amountNormal, NULL, to, &genRect(amountNormal->h, amountNormal->w, creAnims[stackAliveByHex[b][v]]->pos.x + 202, creAnims[stackAliveByHex[b][v]]->pos.y + 260));
std::stringstream ss;
ss<<stacks[stackAliveByHex[b][v]].amount;
CSDL_Ext::printAtMiddleWB(ss.str(), creAnims[stackAliveByHex[b][v]]->pos.x + 202 + 14, creAnims[stackAliveByHex[b][v]]->pos.y + 260 + 4, GEOR13, 20, zwykly, to);
}
}
}
@@ -1113,12 +1144,11 @@ bool CBattleConsole::addText(std::string text)
{
texts.push_back( text.substr(firstInToken, i-firstInToken) );
firstInToken = i+1;
lastShown++;
}
}
texts.push_back( text.substr(firstInToken, text.size()) );
lastShown++;
lastShown = texts.size()-1;
return true;
}