-
Notifications
You must be signed in to change notification settings - Fork 228
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
Hotkey interface implementation #2070
Conversation
If the user tries to bind a key which already has a binding, instead of simply removing the old binding, I bind the key binded to the current action to the other action. This is done to prevent having an action without a corresponding key, which is currently not supported by the hotkey implementation.
The problem is that now major modifications to the apply_changes function must be made, and there are some cases in which it's not very clear what to do.
This is done to make it possible to get the actions list properly ordered.
This is not working properly: the listener only detects keypresses when no button has focus and the F keys still aren't properly detected. Also, the listener is used all throughout the main menu, breaking F9 in the first screen.
container = self.widget.findChild(name='keys_container') | ||
button_container = self.widget.findChild(name='button_container') | ||
sec_button_container = self.widget.findChild(name='sec_button_container') | ||
for i in range(len(self.actions)): |
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.
The better way to handle this in idiomatic python is to use enumerate
.
for i, action in enumerate(self.actions):
Don't you dare merge this into production as-is ;-)
After using ChrisOelmueller's hack to place the Hotkeys interface in the Settings menu and making the listeners work, there's only one problem left: I need to call some methods on Confirm and Reset to Default, but those buttons seems to be handled by FIFE, not pychan. Is there any way I could do this? |
I'm (kinda) working on rewriting the settings entirely, so I wouldn't concentrate too much on this one. It definitly will be possible then. And it's not done in fife, but here: https://github.com/unknown-horizons/unknown-horizons/blob/master/horizons/engine/settingsdialog.py#L65 |
…tkey_interface.py. This was done by storing the HotkeyConfiguration in the settingsDialog and calling te corresponding methods before calling applySettings() and setDefaults() from the settingsDialog.
Okay, I think it works now. Please let me know if you find any problems or if you think I did something (too) stupid in the code. |
@@ -22,6 +22,7 @@ | |||
from fife import fife | |||
|
|||
from horizons.util.python.callback import Callback | |||
from horizons.gui.modules.hotkeys_settings import HotkeyConfiguration |
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.
This import looks obsolete.
Can you please merge the master branch in your branch, so it's possible again to test your branch with the last git version of fife and merging your PR will works too after that. |
Conflicts: horizons/gui/keylisteners/keyconfig.py horizons/gui/widgets/pickbeltwidget.py
If the text of a button is "Press any key" and the user clicks another button, the interface should update the text of all buttons, so that no two buttons contain the text "Press any key" at the same time.
I noticed three things which should be fixed in my opinion before merging:
|
Hotkey interface implementation Great work ThePawnbreak!
Great work! |
This partially fixes #1964 and #1893.
I managed to implement a workable interface for binding hotkeys. Although it is currently usable, there are some places where it could be improved: