springsettings featuring hotkey editor

springsettings featuring hotkey editor

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

User avatar
very_bad_soldier
Posts: 1397
Joined: 20 Feb 2007, 01:10

springsettings featuring hotkey editor

Post by very_bad_soldier »

This is the first version of a springsettings branch which includes a hotkey editor. It also does what the famous "selectionEditor.exe" can do. It will read and write your uikeys.txt and also save different profiles of hotkeys inside your springsettings.conf. Only the differences to the default hotkeys will be saved.
You can still modify your uikeys.txt manually, springsettings will detect the changes and create a new profile for it.

Image

Here are some things that are not supported at the moment. How important are those?
  • META as possible keycode
  • you cannot control the "any"-modifier. It gets added automatically when there are no other modifiers like shift, alt or ctrl
  • you cannot control the order of the bind/unbind commands in uikeys.txt. I think they get sorted by command name.
The list of available commands and the default spring hotkeys are currently hardcoded. I will try to make it somehow more flexible in the future. You can still add "custom commands" inside the panel though. Are there any important commands missing or commands that should be removed to keep it as simple as possible and to not present 400+ commands to the user?

Whats is missing are also proper descriptions for each command (will require some work to put them in and also someone who can actually provide the descriptions). Also there is the possiblity to categorize the commands. Maybe someone has good ideas for the categories.

Would be great if some people could take a look at it and give some feedback. I am interested in bug reports, feature requests and all other suggestions regarding GUI, functionality or whatever.

Here is the source code (CMake files and visual studio project files may be still incomplete. Also there may be crlf-issues. I have to clean that up):
http://github.com/verybadsoldier/springlobby
(use branch "hotkey_tab")

http://github.com/verybadsoldier/wxKeybinder

Windows binaries: http://springrts.com/phpbb/download/file.php?id=4959
Attachments
springsettings_hotkeys.zip
springsettings hotkeys (Windows)
(1.89 MiB) Downloaded 30 times
screen.jpg
screen
(140.4 KiB) Downloaded 3 times
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Re: springsettings featuring hotkey editor

Post by BrainDamage »

thanks a lot!

I merged it in my repo's master: git://springlobby.info/git/BrainDamage/springlobby.git

I did several changes:
did not merge files which had only line endings changes or file permission changes
changed the exception to runtime_assertion so it would compile on gcc
added wxkeyeditor to src/wxkeyeditor since it's an old lib and i doubt anyone would want to edit/compile it externally
fixed the cmake files
fixed relative paths and minor issues

made a quick test on linux and it works, next SL/settings release will include if you're ok with it
if possible, start from scratch using my master as base to fix the line endings/file mode issues
User avatar
Jazcash
Posts: 5309
Joined: 08 Dec 2007, 17:39

Re: springsettings featuring hotkey editor

Post by Jazcash »

You sir, just earned 5 and a half cookies.
User avatar
Jazcash
Posts: 5309
Joined: 08 Dec 2007, 17:39

Re: springsettings featuring hotkey editor

Post by Jazcash »

God damn you you stole my idea.
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Re: springsettings featuring hotkey editor

Post by Das Bruce »

What is the name of the style of window that 'commands' is?
User avatar
very_bad_soldier
Posts: 1397
Joined: 20 Feb 2007, 01:10

Re: springsettings featuring hotkey editor

Post by very_bad_soldier »

BrainDamage wrote: I merged it in my repo's master: git://springlobby.info/git/BrainDamage/springlobby.git
Wow you are fast! I planned to ask about 2000 questions about what to change to bring it to a quality level that can be merged though. For example I totallly messed up the naming conventions. I had the feeling your conventions were not very strict so I decided at one point to just stick to the ones I am used to for the moment (and convert later to yours). :mrgreen:
BrainDamage wrote:
I did several changes:
did not merge files which had only line endings changes or file permission changes
Yeah sorry, git has some problems on Windows converting those new lines (or possibly I have still problems with git). I had already the feeling they might be messed up in my repo.
BrainDamage wrote:
changed the exception to runtime_assertion so it would compile on gcc
added wxkeyeditor to src/wxkeyeditor since it's an old lib and i doubt anyone would want to edit/compile it externally
fixed the cmake files
fixed relative paths and minor issues
Big thanks for the fixes, good that I wont have to mess with cmake.
But I am quite confused about the change of the exception. gcc should know "std::exception" for sure since it is totally standard C++ AFAIK. But I never heard of "runtime_assertion". Even google can't find documentation. Is it C++? or Linux?
edit:
I see, it is runtime_error now. I derived from std::exception and used wxString for the message to keep the unicode support cause those exceptions contain error messages directly presented to the user (which is not very nice maybe).
BrainDamage wrote:
made a quick test on linux and it works, next SL/settings release will include if you're ok with it
if possible, start from scratch using my master as base to fix the line endings/file mode issues
Sure, I am very happy with that, thanks!

@Bruce:
Do you mean that tree control? It is wxTreeCtrl from wxWidgets. Btw nearly the whole panel is taken from wxkeybinder with some tweaks to better fit our needs.
edit: I realized I have no idea what "style" you mean.

@rest:
thanks for all the cookies ;)
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: springsettings featuring hotkey editor

Post by CarRepairer »

very_bad_soldier wrote: you cannot control the order of the bind/unbind commands in uikeys.txt. I think they get sorted by command name.
I had this same problem when I wrote a windows uikeys editor (in C#). It's around the time I gave up. It's pretty crucial in some cases to have the common buildings come first when you cycle. I hope you can solve it.

Maybe you can use an idea I thought of. Allow an optional "priority" number that the user can add to an action. If two actions have the same keybind, see if they (or at least one of them) have priority and order them in that order.
User avatar
very_bad_soldier
Posts: 1397
Joined: 20 Feb 2007, 01:10

Re: springsettings featuring hotkey editor

Post by very_bad_soldier »

CarRepairer wrote: Maybe you can use an idea I thought of. Allow an optional "priority" number that the user can add to an action. If two actions have the same keybind, see if they (or at least one of them) have priority and order them in that order.
Yeaht thats probably the way it will work internally. My problem is to make that functionality nicely accessible while keeping the GUI simple.
I was thinking about an extra window (that pops up by clicking a small button somewhere) showing all keys that share one command. Clicking on a key shows the associated commands in a list sorted by priority. Buttons with arrow-up/arrow-down below that to change priority.

Any opinion about the META-key and the any-modifier issues? Also necessary?
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Re: springsettings featuring hotkey editor

Post by BrainDamage »

very_bad_soldier wrote: Wow you are fast! I planned to ask about 2000 questions about what to change to bring it to a quality level that can be merged though. For example I totallly messed up the naming conventions. I had the feeling your conventions were not very strict so I decided at one point to just stick to the ones I am used to for the moment (and convert later to yours).
ofc there's still stuff to fix, but I feel that it shouldn't block merging, so now there's less chance of tons of conflicts
very_bad_soldier wrote:
Yeah sorry, git has some problems on Windows converting those new lines (or possibly I have still problems with git). I had already the feeling they might be messed up in my repo.
git config --global core.autctrlf input
very_bad_soldier wrote:
I see, it is runtime_error now. I derived from std::exception and used wxString for the message to keep the unicode support cause those exceptions contain error messages directly presented to the user (which is not very nice maybe).
it's still unicode, it converts it first in utf-8 which is a special unicode encoding that fits ascii-8 width chars, then converts it back to the internal structure before displaying it, it's not very elegant, but it works
what didn't work, was inherithing std::exception without adding a tons of overrides for virtual dtor and throw(); i tought this soultion would be simpler
very_bad_soldier wrote: Any opinion about the META-key and the any-modifier issues? Also necessary?
yes, you really NEED to remove the Any+ auto appending and make it optional, this creates a series of problems, for example, the code:

Code: Select all

bind		c	capture
bind		Ctrl+c	select AllMap+_Commander+_ClearSelection_SelectOne+
vs

Code: Select all

bind        Any+c capture
bind		Ctrl+c	select AllMap+_Commander+_ClearSelection_SelectOne+
in the first snippet, pressing ctrl c repeatedly will keep cycling select coms, in the second, as soon as first commander is selected, capture will be triggered, and will stop cycling ( because Any matches Ctrl, while key alone means no other key is being held )

another example is:

Code: Select all

bind		Any+c	capture
bind		Alt+c	controlunit
controlunit would never be executed if current selected unit has capture command
I realize that it could be partially solved using ordering, but I think it'd much more correct to not auto append Any+

for meta, perhaps simply silently autoreplace all meta bindings with the fakemeta key
Last edited by BrainDamage on 14 Sep 2010, 18:17, edited 1 time in total.
User avatar
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

Re: springsettings featuring hotkey editor

Post by Pxtl »

Mod support? Can I bind the CA Jump key in this?
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Re: springsettings featuring hotkey editor

Post by BrainDamage »

Pxtl wrote:Mod support? Can I bind the CA Jump key in this?
How about trying it? ( I know the answer, but even just looking by the screenshot you could guess it )
User avatar
very_bad_soldier
Posts: 1397
Joined: 20 Feb 2007, 01:10

Re: springsettings featuring hotkey editor

Post by very_bad_soldier »

BrainDamage wrote: what didn't work, was inherithing std::exception without adding a tons of overrides for virtual dtor and throw(); i tought this soultion would be simpler
Adding a one-liner like

Code: Select all

virtual ~HotkeyException() throws() {};
should have been sufficient I think?

Thanks for the other hints, I will get back to it in the next days to clean stuff up.
SirMaverick
Posts: 834
Joined: 19 May 2009, 21:10

Re: springsettings featuring hotkey editor

Post by SirMaverick »

BrainDamage wrote:
Pxtl wrote:Mod support? Can I bind the CA Jump key in this?
How about trying it? ( I know the answer, but even just looking by the screenshot you could guess it )
And the current selected one is used? Do I have to change this in springsettings every time I play another mod?

BUG: Currently (at least) the "keysym" command is not preserved.
User avatar
Licho
Zero-K Developer
Posts: 3803
Joined: 19 May 2006, 19:13

Re: springsettings featuring hotkey editor

Post by Licho »

If there is something like list of custom commands to be passed to editor i could connect it to lobby somehow.
Lobby could export list of custom commands per game in some format for editor.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: springsettings featuring hotkey editor

Post by Beherith »

Cool stuff - got the any+ bug, but other than that, seems great!
Oh right, and every time I launch it, it creates a new profile, even though my keys haven't changed.
User avatar
very_bad_soldier
Posts: 1397
Joined: 20 Feb 2007, 01:10

Re: springsettings featuring hotkey editor

Post by very_bad_soldier »

SirMaverick wrote: BUG: Currently (at least) the "keysym" command is not preserved.
Maybe you did not assign a key to that command? All custom commands without assigned keys will be auto-cleaned up. Maybe I will change that.
Beherith wrote: Cool stuff - got the any+ bug, but other than that, seems great!
Oh right, and every time I launch it, it creates a new profile, even though my keys haven't changed.
The any+ bug? The fact that "any" gets automatically added?
Could you please send me your uikeys.txt so I can try to reproduce that "create new profile"-bug?
SirMaverick
Posts: 834
Joined: 19 May 2009, 21:10

Re: springsettings featuring hotkey editor

Post by SirMaverick »

very_bad_soldier wrote:
SirMaverick wrote: BUG: Currently (at least) the "keysym" command is not preserved.
Maybe you did not assign a key to that command? All custom commands without assigned keys will be auto-cleaned up. Maybe I will change that.

Code: Select all

$ grep oe uikeys.txt
keysym  oe      0xF6
bind    Any+oe  toggleradarandjammer
open springsettings, profile will be created, exit with save

Code: Select all

$ grep oe uikeys.txt
:(
jivvz
Posts: 38
Joined: 04 May 2009, 00:03

Re: springsettings featuring hotkey editor

Post by jivvz »

very nice but it can have a lot more. like binding buildings or even like a uikeys i once had that were able to cycle through metal related buildings by pressing 'z' for example, and x for energy.
maybe there already is but there should be an easy way to go back and forth from base to a unit or group with a key. maybe doublepressing a group alias is easiest though.
User avatar
Johannes
Posts: 1265
Joined: 17 Sep 2010, 15:49

Re: springsettings featuring hotkey editor

Post by Johannes »

yes, it adds any+ in front of everything... it definitely should not. Like if a command is bound to c, then that gets issued when i'd want to select comm with ctrl+c for example.

It also makes the custom commands order alphabetical. So when I have several buildings bound to same key, they switch the number of presses it takes to bring different buildings up.

Also there should be a way to easily restore uikeys.txt to how it was before it was touched by this program. Now it took a while to get my useable keybinds again.
Post Reply

Return to “Engine”