Skip to content

Conversation

@a1exsh
Copy link
Contributor

@a1exsh a1exsh commented Aug 22, 2021

If an army troop is located in a town that provides a possibility to upgrade
them, display a quick upgrade button on the troop sprite. Clicking the button
invokes the upgrade troop dialog directly.

If an army troop is located in a town that provides a possibility to upgrade
them, display a quick upgrade button on the troop sprite.  Clicking the button
invokes the upgrade troop dialog directly.
@a1exsh
Copy link
Contributor Author

a1exsh commented Aug 22, 2021

To my taste, this change touches a bit too many places, but I haven't found a more direct way to achieve the same effect so far.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ clang-tidy found issue(s) with the introduced code (1/3)

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ clang-tidy found issue(s) with the introduced code (2/3)

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ clang-tidy found issue(s) with the introduced code (3/3)

@a1exsh
Copy link
Contributor Author

a1exsh commented Aug 22, 2021

Screenshot:
image

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ clang-tidy found issue(s) with the introduced code (1/1)

@ihhub
Copy link
Owner

ihhub commented Aug 22, 2021

Hi @a1exsh , I like your great enthusiasm about new ideas but we usually make a discussion at least between members of our team before implementing new things. Please next time propose your idea first in discussion topic :)

@Branikolog , @oleg-derevenetz and @LeHerosInconnu, could you please check this change and express your opinion about it?

@a1exsh
Copy link
Contributor Author

a1exsh commented Aug 22, 2021

@ihhub I'm just using it as an opportunity to study the code ;) I'm going to play a locally modified version for my convenience anyway

@oleg-derevenetz
Copy link
Collaborator

oleg-derevenetz commented Aug 22, 2021

@ihhub @a1exsh Having a working prototype is much better than having just an idea. However, it may happen that the prototype or even the idea itself will not be accepted by the upstream. The author should be ready for this :)

@LeHerosInconnu
Copy link

Hello everyone,

Hi @a1exsh , I like your great enthusiasm about new ideas but we usually make a discussion at least between members of our team before implementing new things. Please next time propose your idea first in discussion topic :)

@Branikolog , @oleg-derevenetz and @LeHerosInconnu, could you please check this change and express your opinion about it?

It is not yet possible to try the change.
But I completely agree with this improvement as it was already on my list of ideas not yet proposed. :D

@Branikolog
Copy link
Collaborator

Hi all.
The proposal to fast upgrade all units is not bad at all, but we firstly should focus on fixing existing bugs, than adding numerous new features.
Also, this feature should be relevant to castle GUI, which is not a trivial without artists.
We can leave this feature for some hot key in a castle view window, if it doesn't break anything.

@LeHerosInconnu
Copy link

Hello @Branikolog,

Hi all.
The proposal to fast upgrade all units is not bad at all, but we firstly should focus on fixing existing bugs, than adding numerous new features.
Also, this feature should be relevant to castle GUI, which is not a trivial without artists.
We can leave this feature for some hot key in a castle view window, if it doesn't break anything.

This is not to upgrade all creatures at once, but to visually indicate which troops can be upgraded.
The player can then choose whether or not to upgrade them one by one.

@Branikolog
Copy link
Collaborator

This is not to upgrade all creatures at once, but to visually indicate which troops can be upgraded.
The player can then choose whether or not to upgrade them one by one.

Oh, sorry for my slight misunderstanding...
Anyway, we can add thousands of such nice features, but without any professional artist, who would add such elements to GUI without ruining game style, the majority of them could be left unimplemented.

@a1exsh
Copy link
Contributor Author

a1exsh commented Aug 22, 2021

Yes, what is implemented here is a small "up" arrow in the top-bottom corner of an upgradable troop. Clicking on that arrow opens the upgrade dialog directly without going through army dialog first where one needs to click Upgrade button (it saves 2 clicks).

@oleg-derevenetz oleg-derevenetz added improvement New feature, request or improvement ui UI/GUI related stuff labels Aug 22, 2021
@LeHerosInconnu
Copy link

Hello everyone,

So, I did some tests.
Everything seems to work fine.
Good job on the singular plural for text for the information about the function of the button in the bottom bar depending on the number of creatures and also on the message when the player doesn't have enough resources to upgrade a troop. :)

Some suggestions and possible improvements (can be done in another PR for some of them).

  • display the graphic in the upper left corner to avoid the arrow to cover the sprite of the creature, in the examples with Dragons, Cavalry and Paladin.
    Quick upgrade button 001
    Quick upgrade button 002

  • in the TOWNS/CASTLES screen, also display the graphic in the upper left corner, it would be also better to use a smaller graphic in this screen.
    Quick upgrade button 003
    Quick upgrade button 004

  • for the Green Dragon, it should be possible either to add a second graphic below the first one to allow the Green Dragon to be upgraded directly to Black Dragon or to add at least one button that allows this in the validation window.
    Quick upgrade button 005
    Quick upgrade button 006

  • a color code for the graphic could also be used to visually indicate to the player if he can upgrade the troop directly (yellow arrow), if he can upgrade the troop provided he exchanges resources (orange arrow), if he cannot upgrade the troop even by exchanging resources (red arrow).
    Quick upgrade button 007

@a1exsh
Copy link
Contributor Author

a1exsh commented Aug 24, 2021

@LeHerosInconnu thanks for having a look: you raise a number of good points!

It occurs to me now that all monsters in Heroes II are looking to the right, so probably it makes sense to move the quick upgrade button to the top left corner.
Now I see where the mini army bar is used: in kingdom overview. Haven't found this in the code. 😅

Will check the green -> black dragon interaction. I also like the idea to give a (color) hint when upgrade is not possible due to lack of resources.

@LeHerosInconnu
Copy link

LeHerosInconnu commented Aug 24, 2021

Hello @a1exsh,

Now I see where the mini army bar is used: in kingdom overview. Haven't found this in the code.

You made me think that a mini creature army bar is also displayed in the hero meeting screen.

In the following example, Rebecca is located in a castle where the Irons Golems can be upgraded.
Quick upgrade button 008

But during the meeting with another hero (Rebecca stays in the castle), the graphic for upgrading the Iron Golems is not displayed, while it is possible to upgrade the Iron Golems with the default method.
The upgrade graphics should also be displayed in the hero meeting screen.
Quick upgrade button 009
Quick upgrade button 010

Edit:

The Iron Golem can still be upgraded if the player clicks where the upgrade graphic should be displayed.
Quick upgrade button 011

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ clang-tidy found issue(s) with the introduced code (1/1)


const fheroes2::Sprite ArmyBar::GetUpgradeButton()
{
static const fheroes2::Sprite upButton = fheroes2::AGG::GetICN( ICN::RECRUIT, 0 );
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-const-return-type ⚠️
return type const fheroes2::Sprite is const-qualified at the top level, which may reduce code readability without improving const correctness

Suggested change
static const fheroes2::Sprite upButton = fheroes2::AGG::GetICN( ICN::RECRUIT, 0 );
static const fheroes2::Sprite upButton oes2::AGG::GetICN( ICN::RECRUIT, 0 );

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, these "suggested changes"... Sometimes they are completely broken. I'll have to take a look sometime.

Copy link
Owner

Choose a reason for hiding this comment

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

Wow!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @ihhub I (hopefully) fixed such issues with suggested changes, corresponding PR is merged to the upstream, you may want to sync fheroes2/clang-tidy-pr-comments with the upstream.

@a1exsh
Copy link
Contributor Author

a1exsh commented Aug 25, 2021

Thanks for the review, @ihhub and @LeHerosInconnu !

I've addressed the code comments and also made the clickable area of the button a bit bigger, as suggested. I will also try to see if we can cast a shadow under the button to make it stand out a little more, like on the actual "recruit troop" dialog.

@ihhub
Copy link
Owner

ihhub commented Aug 26, 2021

Thanks for the review, @ihhub and @LeHerosInconnu !

I've addressed the code comments and also made the clickable area of the button a bit bigger, as suggested. I will also try to see if we can cast a shadow under the button to make it stand out a little more, like on the actual "recruit troop" dialog.

Making a shadow is very simple. We already have a function to do this. Please check agg_image.cpp file for examples.

@a1exsh
Copy link
Contributor Author

a1exsh commented Aug 26, 2021

The shadow produced by addShadow() is really hard to see, or maybe I'm doing something wrong. Let's skip this for now.

@a1exsh a1exsh requested a review from ihhub August 26, 2021 07:28
@oleg-derevenetz
Copy link
Collaborator

oleg-derevenetz commented Aug 28, 2021

@a1exsh if you sync this PR with master branch, quick upgrades should work for guardian heroes armies too.

@a1exsh a1exsh requested a review from ihhub September 1, 2021 06:58
Copy link
Owner

@ihhub ihhub left a comment

Choose a reason for hiding this comment

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

Hi @a1exsh , I left just 2 more comments here. Would you mind to take a look?

I think we still need to make it as a button. I'll check in a while how to render such properly.

return _army != nullptr;
}

const fheroes2::Sprite & ArmyBar::GetUpgradeButton() const
Copy link
Owner

Choose a reason for hiding this comment

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

I think this method should be static instead of const as we can have multiple ArmyBar instances but all of them use the same resource. The static method could have a single boolean argument useMiniIcon as a replacement of use_mini_sprite member usage. In this case we can avoid memory duplication.

Copy link
Owner

Choose a reason for hiding this comment

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

Also this method should be private as it's not used anywhere outside the class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess there was no memory duplication either way, because of static storage used inside the function. Moved it to private namespace, I hope that also works with you? :)


const fheroes2::Sprite & GetUpgradeButton() const;
fheroes2::Rect GetUpgradeButtonPos( const fheroes2::Rect & itemPos ) const;
void DrawUpgadeButton( const fheroes2::Rect & pos, fheroes2::Image & dstsf ) const;
Copy link
Owner

Choose a reason for hiding this comment

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

Could we please rename (copy-pasted) dstsf variable into something like outputImage to be more obvious? dstsf was standing for destination surface but here we don't have surfaces anymore :)

@ihhub ihhub added this to the 1.0 milestone Sep 5, 2021
@a1exsh
Copy link
Contributor Author

a1exsh commented Sep 6, 2021

I think we still need to make it as a button. I'll check in a while how to render such properly.

@ihhub in the OG editor there is a clickable button (it has a pressed state image as well) for drop down menus:
image

I guess it should be part of the game resources, so we could use it here if we mirrored it vertically.

Do you by chance know the icon name for this one?

@ihhub
Copy link
Owner

ihhub commented Sep 6, 2021

I think we still need to make it as a button. I'll check in a while how to render such properly.

@ihhub in the OG editor there is a clickable button (it has a pressed state image as well) for drop down menus:
image

I guess it should be part of the game resources, so we could use it here if we mirrored it vertically.

Do you by chance know the icon name for this one?

ICN::LISTBOX is what you're looking for.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ clang-tidy found issue(s) with the introduced code (1/1)

}

virtual bool ActionBarLeftMouseHold( Item &, Item & )
virtual bool ActionBarLeftMouseHold( const fheroes2::Point & /*unused*/, Item & /*unused*/, const fheroes2::Rect & /*unused*/ )
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ clang-diagnostic-inconsistent-missing-override ⚠️
ActionBarLeftMouseHold overrides a member function but is not marked override

}

virtual bool ActionBarLeftMouseHold( Item & )
virtual bool ActionBarLeftMouseHold( Item &, Item & )
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-named-parameter ⚠️
all parameters should be named in a function

Suggested change
virtual bool ActionBarLeftMouseHold( Item &, Item & )
virtual bool ActionBarLeftMouseHold( Item & /*unused*/, Item & )

}

virtual bool ActionBarLeftMouseHold( Item & )
virtual bool ActionBarLeftMouseHold( Item &, Item & )
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ readability-named-parameter ⚠️
all parameters should be named in a function

Suggested change
virtual bool ActionBarLeftMouseHold( Item &, Item & )
virtual bool ActionBarLeftMouseHold( Item &, Item & /*unused*/)

@a1exsh
Copy link
Contributor Author

a1exsh commented Sep 8, 2021

Updated the button icon, thanks for the hint, @ihhub ! :-)
image

In order to render pressed and released state I had to further extend ActionBarLeftMouseHold with cursor and item position parameters, though this approach doesn't seem to scale really well.

I see that we have a special class for the buttons here: https://github.com/ihhub/fheroes2/blob/master/src/fheroes2/gui/ui_button.h#L99
Using it, however, requires fixed position on the screen. For us to use it in the ArmyBar, we would need to keep a mapping between the troops and the buttons. That would also remove the need to pass item position in the Click/Hold event handlers.

I will have a look later.

@ihhub ihhub modified the milestones: 1.0, Beyond 1.0 Dec 19, 2022
@GeorgeK1ng
Copy link
Contributor

Wow! I really like these improvements!

@ihhub ihhub marked this pull request as draft July 22, 2023 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement New feature, request or improvement ui UI/GUI related stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants