Skip to content
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

keybind translations #631

Merged
merged 8 commits into from
Apr 15, 2017
Merged

keybind translations #631

merged 8 commits into from
Apr 15, 2017

Conversation

commy2
Copy link
Contributor

@commy2 commy2 commented Apr 8, 2017

When merged this pull request will:

  • use keyName instead of static array names for displaying the keybinds, which means that Y vs. Z is now respected on German keyboards etc. and the keys like "Home" are translated correctly.
  • also translate the modifier keys
  • affects menu and diary
  • fixed a bug where duplicated keys would be shown as keybind title + tooltip in red instead of just the title.
  • macros for XBOX controller keys
  • added GVARs and replaced some magic numbers with macros
  • rewrote a contrived logic to generate the readable keybinds for the diary

http://i.imgur.com/5cfH2Wu.jpg
http://i.imgur.com/RAyrvgA.jpg

todos:

  • test unbound key

@commy2 commy2 added the WIP label Apr 8, 2017
@kymckay
Copy link
Contributor

kymckay commented Apr 8, 2017

Is there a reason the keyName command isn't used?

@jonpas
Copy link
Member

jonpas commented Apr 8, 2017

Problem is that there is no* way to detect via SQF the language of the keyboard...

https://community.bistudio.com/wiki/language

@commy2
Copy link
Contributor Author

commy2 commented Apr 8, 2017

@SilentSpike Good question, I will take a look.
@jonpas That is not the keyboard language. The game language could be easily tested by making a dummy stringtable entry:

<English>English</English>
<German>German</German>

@PabstMirror
Copy link
Contributor

What about using a location hash instead of a oversized array?
GVAR(keyHash) getVariable (str _x)?

@commy2
Copy link
Contributor Author

commy2 commented Apr 8, 2017

One problem with keyName is, that it reports the keys as weird "string in string".

keyName 0x15
-> """Z"""

Solution:

_s = keyName 0x15; _s select [1, count _s -2]

@commy2
Copy link
Contributor Author

commy2 commented Apr 8, 2017

keyName is an excellent solution that even works for the "controller" keys:

keyName 327684
"""XBox Up"""

It also handles the keyboard language problem:

cba_keybinding_keynames select 0x15
-> "Y"

_s = keyName 0x15; _s select [1, count _s -2]
-> "Z"

@commy2
Copy link
Contributor Author

commy2 commented Apr 8, 2017

I use the location now like Pabst suggested. I don't use keyName directly with what is given by the script, because that would break the whole "unknown keycode: 123" thing and might even report wrong stuff (like "2xC", which is not supported).
Since namespaces are based on LOCATION's and are deleted at every mission start, I generate a CBA hash instead at game start (and take care of the duplicated ") and "deserialize" that with the function I wrote a few weeks ago. :)

@commy2 commy2 added Enhancement and removed WIP labels Apr 9, 2017
@commy2 commy2 changed the base branch from master to improve-keybinding-ui April 14, 2017 19:57
@commy2 commy2 changed the base branch from improve-keybinding-ui to master April 14, 2017 19:57
@commy2 commy2 added this to the 3.4 milestone Apr 15, 2017
@commy2 commy2 merged commit 6b7564d into master Apr 15, 2017
@commy2 commy2 deleted the keybinding-translations branch April 15, 2017 12:47
@commy2 commy2 modified the milestones: 3.3, 3.4 Apr 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants