Skip to content
2 changes: 1 addition & 1 deletion src/fheroes2/dialog/dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace Dialog
void DwellingInfo( const Monster &, uint32_t available );
bool SetGuardian( Heroes &, Troop &, CapturedObject &, bool readonly );
int ArmyInfo( const Troop & troop, int flags, bool isReflected = false );
int ArmyJoinFree( const Troop &, Heroes & );
int ArmyJoinFree( const std::string &, const std::string &, const Troop &, Heroes & );
int ArmyJoinWithCost( const Troop &, uint32_t join, uint32_t gold, Heroes & );
int ArmySplitTroop( uint32_t freeSlots, const uint32_t redistributeMax, uint32_t & redistributeCount, bool & useFastSplit );
void Marketplace( Kingdom & kingdom, bool fromTradingPost );
Expand Down
13 changes: 5 additions & 8 deletions src/fheroes2/dialog/dialog_armyinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,29 +610,26 @@ void DrawMonster( fheroes2::RandomMonsterAnimation & monsterAnimation, const Tro
monsterAnimation.increment();
}

int Dialog::ArmyJoinFree( const Troop & troop, Heroes & hero )
int Dialog::ArmyJoinFree( const std::string & dialogTitle, const std::string & message, const Troop & troop, Heroes & hero )
{
fheroes2::Display & display = fheroes2::Display::instance();
const bool isEvilInterface = Settings::Get().ExtGameEvilInterface();

// setup cursor
const CursorRestorer cursorRestorer( true, Cursor::POINTER );

const Text title( _( "Followers" ), Font::YELLOW_BIG );

std::string message = _( "A group of %{monster} with a desire for greater glory wish to join you.\nDo you accept?" );
StringReplace( message, "%{monster}", Translation::StringLower( troop.GetMultiName() ) );
const fheroes2::Text title( dialogTitle, fheroes2::FontType::normalYellow() );

TextBox textbox( message, Font::BIG, BOXAREA_WIDTH );
const int buttons = Dialog::YES | Dialog::NO;
int posy = 0;

FrameBox box( 10 + 2 * title.h() + textbox.h() + 10, true );
FrameBox box( 10 + 2 * title.height() + textbox.h() + 10, true );
const fheroes2::Rect & pos = box.GetArea();

title.Blit( pos.x + ( pos.width - title.w() ) / 2, pos.y );
title.draw( pos.x + ( pos.width - title.width() ) / 2, pos.y, display );

posy = pos.y + 2 * title.h() - 3;
posy = pos.y + 2 * title.height() - 3;
textbox.Blit( pos.x, posy );

fheroes2::ButtonGroup btnGroup( pos, buttons );
Expand Down
11 changes: 8 additions & 3 deletions src/fheroes2/heroes/heroes_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,12 @@ void ActionToMonster( Heroes & hero, int32_t dst_index )
else if ( join.reason == NeutralMonsterJoiningCondition::Reason::Free ) {
DEBUG_LOG( DBG_GAME, DBG_INFO, hero.GetName() << " join monster " << troop.GetName() )

if ( Dialog::YES == Dialog::ArmyJoinFree( troop, hero ) ) {
const fheroes2::Text header( _( "Followers" ), fheroes2::FontType::normalYellow() );
Comment thread
zenseii marked this conversation as resolved.
std::string message = _( "A group of %{monster} with a desire for greater glory wish to join you.\nDo you accept?" );
StringReplace( message, "%{monster}", Translation::StringLower( troop.GetMultiName() ) );
const fheroes2::Text body( message, fheroes2::FontType::normalWhite() );

if ( Dialog::YES == Dialog::ArmyJoinFree( header.text(), body.text(), troop, hero ) ) {
hero.GetArmy().JoinTroop( troop );

I.GetStatusWindow().SetRedraw();
Expand Down Expand Up @@ -2214,7 +2219,7 @@ void ActionToDwellingJoinMonster( Heroes & hero, const MP2::MapObjectType object

AudioManager::PlaySound( M82::EXPERNCE );

if ( Dialog::YES == Dialog::Message( title, message, Font::BIG, Dialog::YES | Dialog::NO ) ) {
if ( Dialog::YES == Dialog::ArmyJoinFree( title, message, troop, hero ) ) {
if ( !hero.GetArmy().CanJoinTroop( troop ) )
Comment thread
shprotru marked this conversation as resolved.
Dialog::Message( troop.GetName(), _( "You are unable to recruit at this time, your ranks are full." ), Font::BIG, Dialog::OK );
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now there is no way to make this message about ranks being full appear since you cannot press "Yes":
image.

I suggest to remove this message and make the else statement further down the default action for this dialog. What do you think?

else {
Expand Down Expand Up @@ -2303,7 +2308,7 @@ void ActionToDwellingRecruitMonster( Heroes & hero, const MP2::MapObjectType obj

if ( !troop.isValid() )
Dialog::Message( title, msg_void, Font::BIG, Dialog::OK );
else if ( Dialog::YES == Dialog::Message( title, msg_full, Font::BIG, Dialog::YES | Dialog::NO ) )
else if ( Dialog::YES == Dialog::ArmyJoinFree( title, msg_full, troop, hero ) )
RecruitMonsterFromTile( hero, tile, title, troop, false );

hero.SetVisited( dst_index, Visit::GLOBAL );
Expand Down