Explorar o código

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

DjWarmonger %!s(int64=11) %!d(string=hai) anos
pai
achega
e77f328844

+ 11 - 3
client/widgets/Buttons.cpp

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

+ 18 - 1
client/widgets/MiscWidgets.cpp

@@ -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);
 	else
 		bg = new CPicture(CGI->townh->factions[faction]->creatureBg120);
-	bg->needRefresh = true;
 	anim = new CCreatureAnim(0, 0, cre->animDefName, Rect());
 	anim->clipRect(cre->isDoubleWide()?170:150, 155, bg->pos.w, bg->pos.h);
 	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.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("");
+}

+ 5 - 0
client/widgets/MiscWidgets.h

@@ -12,6 +12,7 @@
  *
  */
 
+class CLabel;
 class CCreatureAnim;
 class CComponent;
 class CGGarrison;
@@ -85,9 +86,13 @@ class CCreaturePic : public CIntObject
 private:
 	CPicture *bg;
 	CCreatureAnim *anim; //displayed animation
+	CLabel * amount;
 
+	void show(SDL_Surface *to);
 public:
 	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

+ 2 - 0
client/windows/CAdvmapInterface.cpp

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

+ 15 - 6
client/windows/CCreatureWindow.cpp

@@ -56,6 +56,7 @@ struct StackWindowInfo
 	const CCreature * creature;
 	const CCommanderInstance * commander;
 	const CStackInstance * stackNode;
+	const CStack * stack;
 	const CGHeroInstance * owner;
 
 	// temporary objects which should be kept as copy if needed
@@ -92,6 +93,7 @@ StackWindowInfo::StackWindowInfo():
 	creature(nullptr),
 	commander(nullptr),
 	stackNode(nullptr),
+	stack(nullptr),
 	owner(nullptr),
 	creatureCount(0),
 	popupWindow(false)
@@ -214,7 +216,13 @@ void CStackWindow::CWindowSection::createStackInfo(bool showExp, bool showArt)
 	else
 		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;
 	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::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 caster  = parent->info->stackNode->valOfBonuses(Bonus::CASTS);
 
@@ -293,13 +301,13 @@ void CStackWindow::CWindowSection::createStackInfo(bool showExp, bool showArt)
 
 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
 
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 	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
 
@@ -316,7 +324,7 @@ void CStackWindow::CWindowSection::createActiveSpells()
 			int duration = battleStack->getBonusLocalFirst(Selector::source(Bonus::SPELL_EFFECT,effect))->turnsRemain;
 			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);
 			if (++printed >= 8) // interface limit reached
 				break;
@@ -689,7 +697,7 @@ void CStackWindow::initSections()
 	pos.w = currentSection->pos.w;
 	pos.h += currentSection->pos.h;
 
-	if (dynamic_cast<const CStack*>(info->stackNode)) // in battle
+	if (info->stack) // in battle
 	{
 		currentSection = new CWindowSection(this);
 		currentSection->pos.y += pos.h;
@@ -790,6 +798,7 @@ CStackWindow::CStackWindow(const CStack * stack, bool popup):
 	CWindowObject(BORDERED | (popup ? RCLICK_POPUP : 0)),
     info(new StackWindowInfo())
 {
+	info->stack = stack;
 	info->stackNode = stack->base;
 	info->creature = stack->type;
 	info->creatureCount = stack->count;

+ 5 - 2
client/windows/CQuestLog.cpp

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