diff --git a/src/fheroes2/heroes/heroes_dialog.cpp b/src/fheroes2/heroes/heroes_dialog.cpp index 5220b400513..bd00ab54c4e 100644 --- a/src/fheroes2/heroes/heroes_dialog.cpp +++ b/src/fheroes2/heroes/heroes_dialog.cpp @@ -267,6 +267,9 @@ int Heroes::OpenDialog( const bool readonly, const bool fade, const bool disable dst_pt.y = dialogRoi.y + ( isEditor ? 76 : 86 ); ExperienceIndicator experienceInfo( this ); experienceInfo.SetPos( dst_pt ); + if ( isEditor ) { + experienceInfo.setDefaultState( useDefaultExperience ); + } experienceInfo.Redraw(); // Spell points indicator. @@ -279,6 +282,9 @@ int Heroes::OpenDialog( const bool readonly, const bool fade, const bool disable dst_pt.y += 2; SpellPointsIndicator spellPointsInfo( this ); spellPointsInfo.SetPos( dst_pt ); + if ( isEditor ) { + spellPointsInfo.setDefaultState( useDefaultSpellPoints ); + } spellPointsInfo.Redraw(); // Color "crest" icon. @@ -500,6 +506,7 @@ int Heroes::OpenDialog( const bool readonly, const bool fade, const bool disable if ( Dialog::SelectCount( _( "Set Experience value" ), 0, experienceMaxValue, value ) ) { useDefaultExperience = false; experience = value; + experienceInfo.setDefaultState( useDefaultExperience ); experienceInfo.Redraw(); drawTitleText( name, _race, true ); needRedraw = true; @@ -508,6 +515,7 @@ int Heroes::OpenDialog( const bool readonly, const bool fade, const bool disable else if ( le.MouseClickRight() ) { useDefaultExperience = true; experience = GetStartingXp(); + experienceInfo.setDefaultState( useDefaultExperience ); experienceInfo.Redraw(); drawTitleText( name, _race, true ); needRedraw = true; @@ -525,9 +533,10 @@ int Heroes::OpenDialog( const bool readonly, const bool fade, const bool disable if ( le.MouseClickLeft() ) { uint32_t value = GetSpellPoints(); - if ( Dialog::SelectCount( message, 0, spellPointsMaxValue, value ) ) { + if ( Dialog::SelectCount( _( "Set Spell Points value" ), 0, spellPointsMaxValue, value ) ) { useDefaultSpellPoints = false; SetSpellPoints( value ); + spellPointsInfo.setDefaultState( useDefaultSpellPoints ); spellPointsInfo.Redraw(); needRedraw = true; } @@ -536,6 +545,7 @@ int Heroes::OpenDialog( const bool readonly, const bool fade, const bool disable // Reset spell points modification. useDefaultSpellPoints = true; SetSpellPoints( GetMaxSpellPoints() ); + spellPointsInfo.setDefaultState( useDefaultSpellPoints ); spellPointsInfo.Redraw(); needRedraw = true; } @@ -589,6 +599,7 @@ int Heroes::OpenDialog( const bool readonly, const bool fade, const bool disable if ( useDefaultSpellPoints ) { SetSpellPoints( GetMaxSpellPoints() ); } + spellPointsInfo.Redraw(); needRedraw = true; } diff --git a/src/fheroes2/heroes/heroes_indicator.cpp b/src/fheroes2/heroes/heroes_indicator.cpp index 293e80d7de7..24ccd11c5ad 100644 --- a/src/fheroes2/heroes/heroes_indicator.cpp +++ b/src/fheroes2/heroes/heroes_indicator.cpp @@ -202,7 +202,7 @@ void ExperienceIndicator::Redraw() const const fheroes2::Sprite & sprite = fheroes2::AGG::GetICN( ICN::HSICONS, 1 ); fheroes2::Blit( sprite, display, _area.x, _area.y ); - const fheroes2::Text text( std::to_string( _hero->GetExperience() ), fheroes2::FontType::smallWhite() ); + const fheroes2::Text text( _isDefault ? "-" : std::to_string( _hero->GetExperience() ), fheroes2::FontType::smallWhite() ); text.draw( _area.x + 17 - text.width() / 2, _area.y + 25, display ); } @@ -240,7 +240,9 @@ void SpellPointsIndicator::Redraw() const const fheroes2::Sprite & sprite = fheroes2::AGG::GetICN( ICN::HSICONS, 8 ); fheroes2::Blit( sprite, display, _area.x, _area.y ); - const fheroes2::Text text( std::to_string( _hero->GetSpellPoints() ) + "/" + std::to_string( _hero->GetMaxSpellPoints() ), fheroes2::FontType::smallWhite() ); + const fheroes2::Text text( _isDefault ? std::to_string( _hero->GetMaxSpellPoints() ) + : std::to_string( _hero->GetSpellPoints() ) + "/" + std::to_string( _hero->GetMaxSpellPoints() ), + fheroes2::FontType::smallWhite() ); text.draw( _area.x + sprite.width() / 2 - text.width() / 2, _area.y + 23, display ); } diff --git a/src/fheroes2/heroes/heroes_indicator.h b/src/fheroes2/heroes/heroes_indicator.h index 4473d3b7a2f..d13d754d304 100644 --- a/src/fheroes2/heroes/heroes_indicator.h +++ b/src/fheroes2/heroes/heroes_indicator.h @@ -1,6 +1,6 @@ /*************************************************************************** * fheroes2: https://github.com/ihhub/fheroes2 * - * Copyright (C) 2019 - 2023 * + * Copyright (C) 2019 - 2024 * * * * Free Heroes2 Engine: http://sourceforge.net/projects/fheroes2 * * Copyright (C) 2009 by Andrey Afletdinov * @@ -110,6 +110,16 @@ class ExperienceIndicator : public HeroesIndicator void Redraw() const; void QueueEventProcessing() const; + + // Set if default value is used. Use this method only in Editor! + void setDefaultState( const bool isDefault ) + { + _isDefault = isDefault; + } + +private: + // This state is used in Editor to show that default value is used. + bool _isDefault{ false }; }; class SpellPointsIndicator : public HeroesIndicator @@ -119,6 +129,16 @@ class SpellPointsIndicator : public HeroesIndicator void Redraw() const; void QueueEventProcessing() const; + + // Set if default value is used. Use this method only in Editor! + void setDefaultState( const bool isDefault ) + { + _isDefault = isDefault; + } + +private: + // This state is used in Editor to show that default value is used. + bool _isDefault{ false }; }; #endif