瀏覽代碼

basic functionality

Laserlicht 1 年之前
父節點
當前提交
0b4cf14a3d

+ 4 - 0
client/battle/BattleActionsController.cpp

@@ -864,6 +864,8 @@ void BattleActionsController::onHoverEnded()
 
 void BattleActionsController::onHexLeftClicked(BattleHex clickedHex)
 {
+	owner.stacksController->updateHoveredStacks(true);
+
 	if (owner.stacksController->getActiveStack() == nullptr)
 		return;
 
@@ -994,6 +996,8 @@ void BattleActionsController::activateStack()
 
 void BattleActionsController::onHexRightClicked(BattleHex clickedHex)
 {
+	owner.stacksController->updateHoveredStacks(true);
+
 	auto spellcastActionPredicate = [](PossiblePlayerBattleAction & action)
 	{
 		return action.spellcast();

+ 25 - 19
client/battle/BattleInterfaceClasses.cpp

@@ -467,27 +467,30 @@ StackInfoBasicPanel::StackInfoBasicPanel(const CStack * stack, Point * position,
 void StackInfoBasicPanel::initializeData(const CStack * stack)
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
-	/*auto attack = hero.details->primskills[0];
-	auto defense = hero.details->primskills[1];
-	auto power = hero.details->primskills[2];
-	auto knowledge = hero.details->primskills[3];
-	auto morale = hero.details->morale;
-	auto luck = hero.details->luck;
-	auto currentSpellPoints = hero.details->mana;
-	auto maxSpellPoints = hero.details->manaLimit;
 
-	icons.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("PortraitsLarge"), hero.getIconIndex(), 0, 10, 6));
+	icons.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("TWCRPORT"), stack->creatureId() + 2, 0, 10, 6));
+	labels.push_back(std::make_shared<CLabel>(10 + 58, 6 + 64, FONT_MEDIUM, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, TextOperations::formatMetric(stack->getCount(), 4)));
 
-	//primary stats
+	auto attack = std::to_string(CGI->creatures()->getByIndex(stack->creatureIndex())->getAttack(stack->isShooter())) + "(" + std::to_string(stack->getAttack(stack->isShooter())) + ")";
+	auto defense = std::to_string(CGI->creatures()->getByIndex(stack->creatureIndex())->getDefense(stack->isShooter())) + "(" + std::to_string(stack->getDefense(stack->isShooter())) + ")";
+	auto damage = std::to_string(CGI->creatures()->getByIndex(stack->creatureIndex())->getMinDamage(stack->isShooter())) + "-" + std::to_string(stack->getMaxDamage(stack->isShooter()));
+	auto health = std::to_string(CGI->creatures()->getByIndex(stack->creatureIndex())->getMaxHealth());
+	auto morale = stack->moraleVal();
+	auto luck = stack->luckVal();
+
+	auto killed = stack->getKilled();
+	auto healthRemaining = TextOperations::formatMetric(stack->getAvailableHealth(), 4);
+
+	//primary stats*/
 	labels.push_back(std::make_shared<CLabel>(9, 75, EFonts::FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[380] + ":"));
 	labels.push_back(std::make_shared<CLabel>(9, 87, EFonts::FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[381] + ":"));
-	labels.push_back(std::make_shared<CLabel>(9, 99, EFonts::FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[382] + ":"));
-	labels.push_back(std::make_shared<CLabel>(9, 111, EFonts::FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[383] + ":"));
+	labels.push_back(std::make_shared<CLabel>(9, 99, EFonts::FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[386] + ":"));
+	labels.push_back(std::make_shared<CLabel>(9, 111, EFonts::FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[389] + ":"));
 
-	labels.push_back(std::make_shared<CLabel>(69, 87, EFonts::FONT_TINY, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, std::to_string(attack)));
-	labels.push_back(std::make_shared<CLabel>(69, 99, EFonts::FONT_TINY, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, std::to_string(defense)));
-	labels.push_back(std::make_shared<CLabel>(69, 111, EFonts::FONT_TINY, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, std::to_string(power)));
-	labels.push_back(std::make_shared<CLabel>(69, 123, EFonts::FONT_TINY, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, std::to_string(knowledge)));
+	labels.push_back(std::make_shared<CLabel>(69, 87, EFonts::FONT_TINY, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, attack));
+	labels.push_back(std::make_shared<CLabel>(69, 99, EFonts::FONT_TINY, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, defense));
+	labels.push_back(std::make_shared<CLabel>(69, 111, EFonts::FONT_TINY, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, damage));
+	labels.push_back(std::make_shared<CLabel>(69, 123, EFonts::FONT_TINY, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, health));
 
 	//morale+luck
 	labels.push_back(std::make_shared<CLabel>(9, 131, EFonts::FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[384] + ":"));
@@ -496,9 +499,12 @@ void StackInfoBasicPanel::initializeData(const CStack * stack)
 	icons.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("IMRL22"), morale + 3, 0, 47, 131));
 	icons.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("ILCK22"), luck + 3, 0, 47, 143));
 
-	//spell points
-	labels.push_back(std::make_shared<CLabel>(39, 174, EFonts::FONT_TINY, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[387]));
-	labels.push_back(std::make_shared<CLabel>(39, 186, EFonts::FONT_TINY, ETextAlignment::CENTER, Colors::WHITE, std::to_string(currentSpellPoints) + "/" + std::to_string(maxSpellPoints)));*/
+	//extra information
+	labels.push_back(std::make_shared<CLabel>(9, 168, EFonts::FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, std::string("Killed") + ":"));
+	labels.push_back(std::make_shared<CLabel>(9, 180, EFonts::FONT_TINY, ETextAlignment::TOPLEFT, Colors::WHITE, std::string("Rem He") + ":"));
+
+	labels.push_back(std::make_shared<CLabel>(69, 180, EFonts::FONT_TINY, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, std::to_string(killed)));
+	labels.push_back(std::make_shared<CLabel>(69, 192, EFonts::FONT_TINY, ETextAlignment::BOTTOMRIGHT, Colors::WHITE, healthRemaining));
 }
 
 void StackInfoBasicPanel::update(const CStack * updatedInfo)

+ 7 - 5
client/battle/BattleStacksController.cpp

@@ -346,7 +346,7 @@ void BattleStacksController::showStack(Canvas & canvas, const CStack * stack)
 
 void BattleStacksController::tick(uint32_t msPassed)
 {
-	updateHoveredStacks();
+	updateHoveredStacks(false);
 	updateBattleAnimations(msPassed);
 }
 
@@ -806,20 +806,21 @@ void BattleStacksController::removeExpiredColorFilters()
 	});
 }
 
-void BattleStacksController::updateHoveredStacks()
+void BattleStacksController::updateHoveredStacks(bool clear)
 {
 	auto newStacks = selectHoveredStacks();
 
+	if(clear)
+		owner.windowObject->updateStackInfoWindow(nullptr);
+
 	for(const auto * stack : mouseHoveredStacks)
 	{
 		if (vstd::contains(newStacks, stack))
 			continue;
 
+		owner.windowObject->updateStackInfoWindow(nullptr);
 		if (stack == activeStack)
-		{
-			owner.windowObject->updateStackInfoWindow(stack);
 			stackAnimation[stack->unitId()]->setBorderColor(AnimationControls::getGoldBorder());
-		}
 		else
 			stackAnimation[stack->unitId()]->setBorderColor(AnimationControls::getNoBorder());
 	}
@@ -829,6 +830,7 @@ void BattleStacksController::updateHoveredStacks()
 		if (vstd::contains(mouseHoveredStacks, stack))
 			continue;
 
+		owner.windowObject->updateStackInfoWindow(newStacks.size() == 1 && vstd::find_pos(newStacks, stack) == 0 ? stack : nullptr);
 		stackAnimation[stack->unitId()]->setBorderColor(AnimationControls::getBlueBorder());
 		if (stackAnimation[stack->unitId()]->framesInGroup(ECreatureAnimType::MOUSEON) > 0 && stack->alive() && !stack->isFrozen())
 			stackAnimation[stack->unitId()]->playOnce(ECreatureAnimType::MOUSEON);

+ 2 - 1
client/battle/BattleStacksController.h

@@ -94,7 +94,6 @@ class BattleStacksController
 	void tickFrameBattleAnimations(uint32_t msPassed);
 
 	void updateBattleAnimations(uint32_t msPassed);
-	void updateHoveredStacks();
 
 	std::vector<const CStack *> selectHoveredStacks();
 
@@ -126,6 +125,8 @@ public:
 
 	void showAliveStack(Canvas & canvas, const CStack * stack);
 	void showStack(Canvas & canvas, const CStack * stack);
+	
+	void updateHoveredStacks(bool clear);
 
 	void collectRenderableObjects(BattleRenderer & renderer);
 

+ 21 - 14
client/battle/BattleWindow.cpp

@@ -261,22 +261,29 @@ void BattleWindow::updateStackInfoWindow(const CStack * stack)
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
 
-	Point position = (GH.screenDimensions().x >= 1000)
-			? Point(pos.x + pos.w + 15, pos.y + 250)
-			: Point(pos.x + pos.w -79, pos.y + 135);
-	defenderStackWindow = std::make_shared<StackInfoBasicPanel>(stack, &position);
-	
-	position = (GH.screenDimensions().x >= 1000)
-			? Point(pos.x - 93, pos.y + 250)
-			: Point(pos.x + 1, pos.y + 135);
-	attackerStackWindow = std::make_shared<StackInfoBasicPanel>(stack, &position);
-
-	//const CStack * stack = owner.getBattle()->battleGetStackByID(unitId.value(), true);
-
 	bool showInfoWindows = settings["battle"]["stickyHeroInfoWindows"].Bool();
 
-	attackerStackWindow->setEnabled(showInfoWindows && stack && stack->unitSide() == BattleSide::ATTACKER);
-	defenderStackWindow->setEnabled(showInfoWindows && stack && stack->unitSide() == BattleSide::DEFENDER);
+	if(stack && stack->unitSide() == BattleSide::DEFENDER)
+	{
+		Point position = (GH.screenDimensions().x >= 1000)
+				? Point(pos.x + pos.w + 15, pos.y + 250)
+				: Point(pos.x + pos.w -79, pos.y + 135);
+		defenderStackWindow = std::make_shared<StackInfoBasicPanel>(stack, &position);
+		defenderStackWindow->setEnabled(showInfoWindows);
+	}
+	else
+		defenderStackWindow = nullptr;
+	
+	if(stack && stack->unitSide() == BattleSide::ATTACKER)
+	{
+		Point position = (GH.screenDimensions().x >= 1000)
+				? Point(pos.x - 93, pos.y + 250)
+				: Point(pos.x + 1, pos.y + 135);
+		attackerStackWindow = std::make_shared<StackInfoBasicPanel>(stack, &position);
+		attackerStackWindow->setEnabled(showInfoWindows);
+	}
+	else
+		attackerStackWindow = nullptr;
 }
 
 void BattleWindow::heroManaPointsChanged(const CGHeroInstance * hero)