1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Merge branch 'develop' of https://github.com/vcmi/vcmi into develop

This commit is contained in:
DjWarmonger
2014-09-21 16:01:46 +02:00
6 changed files with 56 additions and 12 deletions

View File

@@ -706,16 +706,24 @@ void CSlider::keyPressed(const SDL_KeyboardEvent & key)
{ {
if(key.state != SDL_PRESSED) return; if(key.state != SDL_PRESSED) return;
int moveDest = 0; int moveDest = value;
switch(key.keysym.sym) switch(key.keysym.sym)
{ {
case SDLK_UP: case SDLK_UP:
if (!horizontal)
moveDest = value - scrollStep;
break;
case SDLK_LEFT: case SDLK_LEFT:
moveDest = value - scrollStep; if (horizontal)
moveDest = value - scrollStep;
break; break;
case SDLK_DOWN: case SDLK_DOWN:
if (!horizontal)
moveDest = value + scrollStep;
break;
case SDLK_RIGHT: case SDLK_RIGHT:
moveDest = value + scrollStep; if (horizontal)
moveDest = value + scrollStep;
break; break;
case SDLK_PAGEUP: case SDLK_PAGEUP:
moveDest = value - capacity + scrollStep; moveDest = value - capacity + scrollStep;

View File

@@ -432,11 +432,28 @@ CCreaturePic::CCreaturePic(int x, int y, const CCreature *cre, bool Big, bool An
bg = new CPicture(CGI->townh->factions[faction]->creatureBg130); bg = new CPicture(CGI->townh->factions[faction]->creatureBg130);
else else
bg = new CPicture(CGI->townh->factions[faction]->creatureBg120); bg = new CPicture(CGI->townh->factions[faction]->creatureBg120);
bg->needRefresh = true;
anim = new CCreatureAnim(0, 0, cre->animDefName, Rect()); anim = new CCreatureAnim(0, 0, cre->animDefName, Rect());
anim->clipRect(cre->isDoubleWide()?170:150, 155, bg->pos.w, bg->pos.h); anim->clipRect(cre->isDoubleWide()?170:150, 155, bg->pos.w, bg->pos.h);
anim->startPreview(cre->hasBonusOfType(Bonus::SIEGE_WEAPON)); anim->startPreview(cre->hasBonusOfType(Bonus::SIEGE_WEAPON));
amount = new CLabel(bg->pos.w, bg->pos.h, FONT_MEDIUM, BOTTOMRIGHT, Colors::WHITE);
pos.w = bg->pos.w; pos.w = bg->pos.w;
pos.h = bg->pos.h; pos.h = bg->pos.h;
} }
void CCreaturePic::show(SDL_Surface *to)
{
// redraw everything in a proper order
bg->showAll(to);
anim->show(to);
amount->showAll(to);
}
void CCreaturePic::setAmount(int newAmount)
{
if (newAmount != 0)
amount->setText(boost::lexical_cast<std::string>(newAmount));
else
amount->setText("");
}

View File

@@ -12,6 +12,7 @@
* *
*/ */
class CLabel;
class CCreatureAnim; class CCreatureAnim;
class CComponent; class CComponent;
class CGGarrison; class CGGarrison;
@@ -85,9 +86,13 @@ class CCreaturePic : public CIntObject
private: private:
CPicture *bg; CPicture *bg;
CCreatureAnim *anim; //displayed animation CCreatureAnim *anim; //displayed animation
CLabel * amount;
void show(SDL_Surface *to);
public: public:
CCreaturePic(int x, int y, const CCreature *cre, bool Big=true, bool Animated=true); //c-tor CCreaturePic(int x, int y, const CCreature *cre, bool Big=true, bool Animated=true); //c-tor
void setAmount(int newAmount);
}; };
/// Resource bar like that at the bottom of the adventure map screen /// Resource bar like that at the bottom of the adventure map screen

View File

@@ -765,6 +765,7 @@ void CAdvMapInt::selectionChanged()
if (selection != to) if (selection != to)
select(to); select(to);
} }
void CAdvMapInt::centerOn(int3 on) void CAdvMapInt::centerOn(int3 on)
{ {
bool switchedLevels = on.z != position.z; bool switchedLevels = on.z != position.z;
@@ -780,6 +781,7 @@ void CAdvMapInt::centerOn(int3 on)
underground->redraw(); underground->redraw();
if (switchedLevels) if (switchedLevels)
minimap.setLevel(position.z); minimap.setLevel(position.z);
minimap.redraw();
} }
void CAdvMapInt::centerOn(const CGObjectInstance *obj) void CAdvMapInt::centerOn(const CGObjectInstance *obj)

View File

@@ -56,6 +56,7 @@ struct StackWindowInfo
const CCreature * creature; const CCreature * creature;
const CCommanderInstance * commander; const CCommanderInstance * commander;
const CStackInstance * stackNode; const CStackInstance * stackNode;
const CStack * stack;
const CGHeroInstance * owner; const CGHeroInstance * owner;
// temporary objects which should be kept as copy if needed // temporary objects which should be kept as copy if needed
@@ -92,6 +93,7 @@ StackWindowInfo::StackWindowInfo():
creature(nullptr), creature(nullptr),
commander(nullptr), commander(nullptr),
stackNode(nullptr), stackNode(nullptr),
stack(nullptr),
owner(nullptr), owner(nullptr),
creatureCount(0), creatureCount(0),
popupWindow(false) popupWindow(false)
@@ -214,7 +216,13 @@ void CStackWindow::CWindowSection::createStackInfo(bool showExp, bool showArt)
else else
createBackground("info-panel-0"); createBackground("info-panel-0");
new CCreaturePic(5, 41, parent->info->creature); auto pic = new CCreaturePic(5, 41, parent->info->creature);
if (parent->info->stackNode != nullptr && parent->info->commander == nullptr)
{
//normal stack, not a commander and not non-existing stack (e.g. recruitment dialog)
pic->setAmount(parent->info->stackNode->count);
}
std::string visibleName; std::string visibleName;
if (parent->info->commander != nullptr) if (parent->info->commander != nullptr)
@@ -234,7 +242,7 @@ void CStackWindow::CWindowSection::createStackInfo(bool showExp, bool showArt)
printStatBase(EStat::HEALTH, CGI->generaltexth->allTexts[388], parent->info->creature->valOfBonuses(Bonus::STACK_HEALTH), parent->info->stackNode->valOfBonuses(Bonus::STACK_HEALTH)); printStatBase(EStat::HEALTH, CGI->generaltexth->allTexts[388], parent->info->creature->valOfBonuses(Bonus::STACK_HEALTH), parent->info->stackNode->valOfBonuses(Bonus::STACK_HEALTH));
printStatBase(EStat::SPEED, CGI->generaltexth->zelp[441].first, parent->info->creature->Speed(), parent->info->stackNode->Speed()); printStatBase(EStat::SPEED, CGI->generaltexth->zelp[441].first, parent->info->creature->Speed(), parent->info->stackNode->Speed());
const CStack * battleStack = dynamic_cast<const CStack*>(parent->info->stackNode); const CStack * battleStack = parent->info->stack;
bool shooter = parent->info->stackNode->hasBonusOfType(Bonus::SHOOTER) && parent->info->stackNode->valOfBonuses(Bonus::SHOTS); bool shooter = parent->info->stackNode->hasBonusOfType(Bonus::SHOOTER) && parent->info->stackNode->valOfBonuses(Bonus::SHOTS);
bool caster = parent->info->stackNode->valOfBonuses(Bonus::CASTS); bool caster = parent->info->stackNode->valOfBonuses(Bonus::CASTS);
@@ -293,13 +301,13 @@ void CStackWindow::CWindowSection::createStackInfo(bool showExp, bool showArt)
void CStackWindow::CWindowSection::createActiveSpells() void CStackWindow::CWindowSection::createActiveSpells()
{ {
static const Point firstPos(7 ,4); // position of 1st spell box static const Point firstPos(6, 2); // position of 1st spell box
static const Point offset(54, 0); // offset of each spell box from previous static const Point offset(54, 0); // offset of each spell box from previous
OBJ_CONSTRUCTION_CAPTURING_ALL; OBJ_CONSTRUCTION_CAPTURING_ALL;
createBackground("spell-effects"); createBackground("spell-effects");
const CStack * battleStack = dynamic_cast<const CStack*>(parent->info->stackNode); const CStack * battleStack = parent->info->stack;
assert(battleStack); // Section should be created only for battles assert(battleStack); // Section should be created only for battles
@@ -316,7 +324,7 @@ void CStackWindow::CWindowSection::createActiveSpells()
int duration = battleStack->getBonusLocalFirst(Selector::source(Bonus::SPELL_EFFECT,effect))->turnsRemain; int duration = battleStack->getBonusLocalFirst(Selector::source(Bonus::SPELL_EFFECT,effect))->turnsRemain;
boost::replace_first (spellText, "%d", boost::lexical_cast<std::string>(duration)); boost::replace_first (spellText, "%d", boost::lexical_cast<std::string>(duration));
new CAnimImage("SpellInt", effect + 1, 0, firstPos.x + offset.x * printed, firstPos.x + offset.y * printed); new CAnimImage("SpellInt", effect + 1, 0, firstPos.x + offset.x * printed, firstPos.y + offset.y * printed);
new LRClickableAreaWText(Rect(firstPos + offset * printed, Point(50, 38)), spellText, spellText); new LRClickableAreaWText(Rect(firstPos + offset * printed, Point(50, 38)), spellText, spellText);
if (++printed >= 8) // interface limit reached if (++printed >= 8) // interface limit reached
break; break;
@@ -689,7 +697,7 @@ void CStackWindow::initSections()
pos.w = currentSection->pos.w; pos.w = currentSection->pos.w;
pos.h += currentSection->pos.h; pos.h += currentSection->pos.h;
if (dynamic_cast<const CStack*>(info->stackNode)) // in battle if (info->stack) // in battle
{ {
currentSection = new CWindowSection(this); currentSection = new CWindowSection(this);
currentSection->pos.y += pos.h; currentSection->pos.y += pos.h;
@@ -790,6 +798,7 @@ CStackWindow::CStackWindow(const CStack * stack, bool popup):
CWindowObject(BORDERED | (popup ? RCLICK_POPUP : 0)), CWindowObject(BORDERED | (popup ? RCLICK_POPUP : 0)),
info(new StackWindowInfo()) info(new StackWindowInfo())
{ {
info->stack = stack;
info->stackNode = stack->base; info->stackNode = stack->base;
info->creature = stack->type; info->creature = stack->type;
info->creatureCount = stack->count; info->creatureCount = stack->count;

View File

@@ -71,6 +71,8 @@ CMinimap (position),
void CQuestMinimap::addQuestMarks (const QuestInfo * q) void CQuestMinimap::addQuestMarks (const QuestInfo * q)
{ {
OBJ_CONSTRUCTION_CAPTURING_ALL; OBJ_CONSTRUCTION_CAPTURING_ALL;
for (auto icon : icons)
delete icon;
icons.clear(); icons.clear();
int3 tile; int3 tile;
@@ -104,7 +106,7 @@ void CQuestMinimap::iconClicked()
{ {
if (currentQuest->obj) if (currentQuest->obj)
adventureInt->centerOn (currentQuest->obj->pos); adventureInt->centerOn (currentQuest->obj->pos);
moveAdvMapSelection(); //moveAdvMapSelection();
} }
void CQuestMinimap::showAll(SDL_Surface * to) void CQuestMinimap::showAll(SDL_Surface * to)
@@ -160,7 +162,6 @@ void CQuestLog::showAll(SDL_Surface * to)
CSDL_Ext::drawBorder(to, Rect::around(labels[questIndex]->pos), int3(Colors::METALLIC_GOLD.r, Colors::METALLIC_GOLD.g, Colors::METALLIC_GOLD.b)); CSDL_Ext::drawBorder(to, Rect::around(labels[questIndex]->pos), int3(Colors::METALLIC_GOLD.r, Colors::METALLIC_GOLD.g, Colors::METALLIC_GOLD.b));
} }
description->show(to); description->show(to);
minimap->update();
minimap->show(to); minimap->show(to);
} }
@@ -178,6 +179,7 @@ void CQuestLog::recreateQuestList (int newpos)
labels[i]->deactivate(); labels[i]->deactivate();
} }
} }
minimap->update();
} }
void CQuestLog::selectQuest (int which) void CQuestLog::selectQuest (int which)
@@ -190,6 +192,7 @@ void CQuestLog::selectQuest (int which)
std::vector<Component> components; //TODO: display them std::vector<Component> components; //TODO: display them
currentQuest->quest->getVisitText (text, components , currentQuest->quest->isCustomFirst, true); currentQuest->quest->getVisitText (text, components , currentQuest->quest->isCustomFirst, true);
description->setText (text.toString()); //TODO: use special log entry text description->setText (text.toString()); //TODO: use special log entry text
minimap->update();
redraw(); redraw();
} }