-
-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typing a number in creature split/recruit screen replaces the value instead of appending #9672
base: master
Are you sure you want to change the base?
Conversation
Hi @modo-lv, could you please fix the code style issue. |
0856eb8
to
c4f9c1a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done, @modo-lv !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @modo-lv , I left just one very minor suggestion here. Can you please take a look at it?
src/fheroes2/gui/ui_tool.h
Outdated
@@ -224,7 +224,8 @@ namespace fheroes2 | |||
|
|||
void InvertedShadow( Image & image, const Rect & roi, const Rect & excludedRoi, const uint8_t paletteId, const int32_t paletteCount ); | |||
|
|||
bool processIntegerValueTyping( const int32_t minimum, const int32_t maximum, int32_t & value ); | |||
/// <param name="replace">Replace current value with the newly entered digit, instead of appending to it?</param> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use any Doxygen like comments. I suggest to make it simpler:
// "replace" parameter is used to replace the existing value with a newly entered digit rather than appending a new digit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They allow for quickly checking a function's documentation without having to leave the call site
Plain comments allow this as well:
But, unlike Doxygen-like comments, plain comments are readable in plaintext viewers and editors (e.g. joe or mcedit) without having to dig through all that XML. Doxygen is good for auto-generating the documentation, but we don't do that anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plain comments allow this as well:
Oh, cool, I didn't know that. I have changed the comment to plain syntax (and added a method summary).
c4f9c1a
to
aa5b7ac
Compare
…r clicking buttons (ihhub#1631).
aa5b7ac
to
c2d95fe
Compare
Hi @modo-lv I'm currently thinking about some more extensive modernization of these input fields. For example, they have such a problem that although it is possible to erase the value completely (using the Backspace), this will not be visible. In addition, if, for example, the minimum value for an input field is 20, then it will be very difficult to turn it to 100 by editing - you can erase the value (although this will not be visible), but as soon as 1 is entered, the value will become 20 again. Etc. |
I agree, the numeric inputs could be better. I think a couple things could really improve it:
All of these are lot more work though, so I made this PR as a quick-fix for now, to let people with keyboards have a more efficient and less confusing way of quickly typing a number while a full-fledged solution is being worked on. |
Hi @modo-lv
I suggest going this way - we will automatically get the keyboard input almost everywhere, even where it did not exist before due to the presence of several input fields in one window at once. Consider: fheroes2.engine.version_.1.1.7.2025-03-26.16-53-29.mp4I made the necessary changes immediately as part of this PR for now. @Districh-ru @zenseii what do you think about this approach? P.S. Please note that the keyboard input is currently available for numeric keyboards only. |
Hi @Districh-ru @zenseii I also noticed that, in the recruit dialog, the recruit dialog is closed when I use the Enter key to close the virtual keyboard (but if I press the OKAY button in that virtual keyboard, this doesn't happen). This happens in the fheroes2.engine.version_.1.1.7.2025-03-26.17-05-50.mp4Is this behavior intentional? |
I agree, although in windows with only one input field, I would still like it to also be editable directly with a keyboard (or else a keyboard key to open the numeric input, something like |
In this case, we still face the same numerous issues as we face now. BTW, in the original game you need to click on the input field to enter digits. Also, for certain windows (like the recruit window), we can open the virtual keyboard with an empty value, so the user will be able to save some time by avoiding the "backspacing". |
Yes, good point. It's better that all input fields work the same way, and having the popup numpad is a good solution. A shortcut key for opening it using a keyboard would also be nice, but isn't crucial. |
Since the recruiting is a "hot path", I made it so that you didn't have to press Backspace in the corresponding window: fheroes2.engine.version_.1.1.7.2025-03-26.18-14-45.mp4
Yes, that's a good idea. But we need to think separately about which windows and under which sauce it can be served. There are multiple windows that support the virtual keyboard, and in some of them you can still enter the value right away (e.g. the "save game" window), so you generally cannot use the "Spacebar" key to open the virtual keyboard, for instance. |
Yes, I would definitely suggest something that isn't also a typing key. |
For now, we can use the hotkey just to open the numpad - because, if you need to open the "full" virtual keyboard, you most likely just don't have the "real" keyboard to press the hotkey :) I added the support for this in some windows: fheroes2.engine.version_.1.1.7.2025-03-26.18-40-10.mp4I believe, later this can be added to more places (it depends on how many input fields of this type there are in the same window).
Our hotkey config doesn't support the key combinations so far, so I used just the Spacebar button. It doesn't get in the way in these windows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @oleg-derevenetz, thanks for fixing the Enter key bug for the Recruit dialog, but now it is a bit harder to edit numbers in dialogs with one numeric input field due to the lack of fheroes2::processIntegerValueTyping()
.
So I prefer the master build, where for example in Battle Only mode when adding a troop I press backspace once and type in the desired number of creatures and press enter once. While in this PR I have to open the virtual keyboard (while I don't need it because I have a real keyboard :) ), press backspace, type in the desired number and press enter twice.
Having a hotkey to open the numeric virtual keyboard looks questionable, since you need a real keyboard to press the hotkey, and if you have the real one, the virtual is not needed.
I suggest to keep all improvements but return back the ability to quick edit numbers in dialog_selectcount
and in the Recruit dialog because these dialogs are with a single numeric input field and we can do input there.
Maybe we should add the numeric virtual keyboard to the dialog_selectcount
...
Hi @Districh-ru
Now at least you will get what you see, and there is no problem with typing in any number. In addition, the solution with
There is no problem to make the same behavior in the Battle Only mode as in the recruit dialog (press the spacebar instead of backspace and get the empty field). You will need just to press spacebar instead of backspace, that's all.
??? But it already has the virtual numeric keyboard... You can see it in my videos. |
68a8b81
to
c2d95fe
Compare
OK, I moved my changes related to the keyboard support in the virtual numpad to #9690 and reverted my changes here.
I believe that even if the current implementation of the keyboard input maybe sometimes works "almost normal", it is fundamentally broken in general, as I already mentioned before. I really suggest you try to set in the I suggest thinking about how this can be fundamentally fixed rather than introducing an ad-hoc workarounds. I believe that the correctness is important, even if it entails some complication of the UI. In the original game, you need to click on the input field first, then enter the number, then press Enter, and only then you will be able to close the window (even the mouse cursor was hidden during the editing process) - and that was okay, no one died from a few extra actions, but it looked consistent and worked correctly. If you have any ideas on how to implement this in fheroes2 consistently and correctly for the general case, let's get these ideas done.
IMHO, first of all, it looks kind of scary :) And secondly the following quite logical question arises: "what about the rest of the places where these input fields are used?" This cannot be used in a unified way. BTW, when testing the virtual numpads in different places, I noticed the following issue: fheroes2.engine.version_.1.1.7.2025-03-26.22-38-12.mp4Here, the Enter key closes both the virtual numpad window and the event details window. Could you please take a look how it can be fixed in a most "conventional" way according to the rest of the Editor's code? |
I understand this case and know that if
Yes, but we already have a quick edit feature for numeric input fields, and there are no big complaints about it.
Sure, I'll take a look. The problem is that both dialogs use the same hotkey for confirmation. And we need to reset the hotkey state after it's processed and not accept it until it is pressed again. |
Fixes #1631.