-
-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved morale ui when all troops are undead (#9398)
- Loading branch information
Showing
3 changed files
with
31 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/*************************************************************************** | ||
* fheroes2: https://github.com/ihhub/fheroes2 * | ||
* Copyright (C) 2019 - 2024 * | ||
* Copyright (C) 2019 - 2025 * | ||
* * | ||
* Free Heroes2 Engine: http://sourceforge.net/projects/fheroes2 * | ||
* Copyright (C) 2009 by Andrey Afletdinov <[email protected]> * | ||
|
@@ -1205,18 +1205,13 @@ int Army::GetMoraleModificator( std::string * strs ) const | |
// different race penalty | ||
std::set<int> races; | ||
bool hasUndead = false; | ||
bool allUndead = true; | ||
|
||
for ( const Troop * troop : *this ) | ||
if ( troop->isValid() ) { | ||
races.insert( troop->GetRace() ); | ||
hasUndead = hasUndead || troop->isUndead(); | ||
allUndead = allUndead && troop->isUndead(); | ||
} | ||
|
||
if ( allUndead ) | ||
return Morale::NORMAL; | ||
|
||
int result = Morale::NORMAL; | ||
|
||
// check castle modificator | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/*************************************************************************** | ||
* fheroes2: https://github.com/ihhub/fheroes2 * | ||
* Copyright (C) 2019 - 2024 * | ||
* Copyright (C) 2019 - 2025 * | ||
* * | ||
* Free Heroes2 Engine: http://sourceforge.net/projects/fheroes2 * | ||
* Copyright (C) 2009 by Andrey Afletdinov <[email protected]> * | ||
|
@@ -55,6 +55,7 @@ | |
#include "maps_tiles_helper.h" | ||
#include "math_base.h" | ||
#include "mp2.h" | ||
#include "pal.h" | ||
#include "profit.h" | ||
#include "resource.h" | ||
#include "screen.h" | ||
|
@@ -760,7 +761,20 @@ namespace | |
// morale | ||
if ( isFullInfo ) { | ||
const int32_t morale = hero.GetMorale(); | ||
const fheroes2::Sprite & sprite = fheroes2::AGG::GetICN( ICN::MINILKMR, ( 0 > morale ? 3 : ( 0 < morale ? 4 : 5 ) ) ); | ||
|
||
uint32_t spriteInx = 5; | ||
if ( morale < 0 ) { | ||
spriteInx = 3; | ||
} | ||
else if ( morale > 0 ) { | ||
spriteInx = 4; | ||
} | ||
|
||
fheroes2::Sprite sprite = fheroes2::AGG::GetICN( ICN::MINILKMR, spriteInx ); | ||
if ( hero.GetArmy().AllTroopsAreUndead() ) { | ||
fheroes2::ApplyPalette( sprite, PAL::GetPalette( PAL::PaletteType::GRAY ) ); | ||
fheroes2::ApplyPalette( sprite, PAL::GetPalette( PAL::PaletteType::DARKENING ) ); | ||
} | ||
uint32_t count = ( 0 == morale ? 1 : std::abs( morale ) ); | ||
dst_pt.x = cur_rt.x + 10; | ||
dst_pt.y = cur_rt.y + ( count == 1 ? 20 : 13 ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/*************************************************************************** | ||
* fheroes2: https://github.com/ihhub/fheroes2 * | ||
* Copyright (C) 2019 - 2024 * | ||
* Copyright (C) 2019 - 2025 * | ||
* * | ||
* Free Heroes2 Engine: http://sourceforge.net/projects/fheroes2 * | ||
* Copyright (C) 2009 by Andrey Afletdinov <[email protected]> * | ||
|
@@ -33,7 +33,9 @@ | |
#include "dialog.h" | ||
#include "heroes.h" | ||
#include "icn.h" | ||
#include "image.h" | ||
#include "localevent.h" | ||
#include "pal.h" | ||
#include "screen.h" | ||
#include "tools.h" | ||
#include "translations.h" | ||
|
@@ -149,12 +151,22 @@ void MoraleIndicator::Redraw() | |
_description.append( modificators ); | ||
} | ||
|
||
uint32_t spriteInx = 7; | ||
if ( _morale < Morale::NORMAL ) { | ||
spriteInx = 5; | ||
} | ||
else if ( _morale > Morale::NORMAL ) { | ||
spriteInx = 4; | ||
} | ||
|
||
fheroes2::Sprite sprite = fheroes2::AGG::GetICN( ICN::HSICONS, spriteInx ); | ||
if ( _hero->GetArmy().AllTroopsAreUndead() ) { | ||
_description.append( "\n\n" ); | ||
_description.append( _( "Entire army is undead, so morale does not apply." ) ); | ||
fheroes2::ApplyPalette( sprite, PAL::GetPalette( PAL::PaletteType::GRAY ) ); | ||
fheroes2::ApplyPalette( sprite, PAL::GetPalette( PAL::PaletteType::DARKENING ) ); | ||
} | ||
|
||
const fheroes2::Sprite & sprite = fheroes2::AGG::GetICN( ICN::HSICONS, ( 0 > _morale ? 5 : ( 0 < _morale ? 4 : 7 ) ) ); | ||
const int32_t inter = 6; | ||
int32_t count = ( 0 == _morale ? 1 : std::abs( _morale ) ); | ||
int32_t cx = _area.x + ( _area.width - ( sprite.width() + inter * ( count - 1 ) ) ) / 2; | ||
|