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

Feature: Added hotkeys to tooltips and dropdown menu's #9732

Closed
wants to merge 1 commit into from

Conversation

Kuhnovic
Copy link
Contributor

@Kuhnovic Kuhnovic commented Dec 5, 2021

Motivation / Problem

OpenTTD is full of useful hotkeys, but these are never shown to the user. Having these hotkeys visible makes it much easier to learn about them.

Description

image
Tooltips

image
Dropdown menu's

The hotkeys have been added to:

  • Main toolbar
  • Dropdowns of main toolbar
  • Transparancy window
  • Order window
  • All other toolbars that have hotkeys: rail toolbar, road toolbar, etc
  • Scenario editor
  • Probably some other places that I forgot...

Limitations

  • The widget system and the hotkey system are completely independent, and making an association between the two was much harder than I anticipated. I eventually got things working but the solution feels a little convoluted in certain areas. If anyone has ideas for a more straightforward solution, feel free to start the discussion.
  • I had to use some platform specific voodoo to fetch the character of the "toggle console" hotkey, `~ on a US keyboard. Since I only have access to a Windows machine, I could not write an implementation for other platforms (at least not one I can test).
  • For some hotkeys the text becomes a little ambigious, see the image below. Which hotkey does F3 refer to? I might be able to solve this with a string control command and parameters, but I haven't gone down that rabbit hole just yet.

image

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR touches english.txt or translations? Check the guidelines
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

Comment on lines +62 to +64
{"SHIFT", WKC_SHIFT, "Shift"},
{"CTRL", WKC_CTRL, "Ctrl"},
{"ALT", WKC_ALT, "Alt"},
Copy link
Contributor

Choose a reason for hiding this comment

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

These need to be translatable strings. For example, in Germany the Ctrl key is called Strg. Also keep in mind that many hotkeys on Mac systems use the Cmd key where other platforms use Ctrl.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As pointed out by dP in the development discord channel, I need to do quite a bit more work on the translating / formatting parts. I will take your comments into account as well.

Comment on lines +261 to +264
if (keycode & WKC_SHIFT) append("Shift");
if (keycode & WKC_CTRL) append("Ctrl");
if (keycode & WKC_ALT) append("Alt");
if (keycode & WKC_META) append("Meta");
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs to be translatable.

Comment on lines +355 to +358
const bool is_global = keycode & WKC_GLOBAL_HOTKEY;
ss << (is_global ? "[" : "(");
ss << KeycodeToDisplayString(keycode);
ss << (is_global ? "]" : ")");
Copy link
Contributor

Choose a reason for hiding this comment

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

Make sure this results in meaningful results on right-to-left languages (mainly Arabic and Hebrew.)

@LC-Zorg
Copy link

LC-Zorg commented Dec 5, 2021

What would be most useful in theme of shortcuts is an option to select these shortcuts in the game interface. Then the average player wouldn't only find out what shortcuts exist, but could also change them. :)
Regardless of the above, I think this could be a useful change, but I would have two remarks.

First of all (sorry, maybe it's obvious, but I'm almost blind when it comes to reading the code) are these shortcut tooltips permanent or depending on the chosen setting in the config file? Personally, I use completely revised shortcuts, and it would be weird to see hints that are unrelated to the facts.

The second note concerns the tooltips in the dropdown menu - I believe that they are redundant and reduce readability unnecessarily. Minimal, but they do decrease. Moreover, once someone knows about this shortcuts, this information becomes intrusive after time. In both visible cases (L / Shift + F11) these tooltips will be available after hovering over the icon. I think that is really enough. :)

Shortcut tooltips

@Kuhnovic
Copy link
Contributor Author

Kuhnovic commented Dec 6, 2021

@LC-Zorg A hotkey configuration window would indeed be great, but that would be a PR on its own ;)

The hotkeys are read from hotkeys.cfg, so they will display whatever you set them to.

The dropdown items can indeed be quite intrusive, especially if there are multiple key combination configured. I added them for completeness, but I'm not entirely sure if I want to keep them. For now I'll keep them in, I can always throw those part of the code away later.

image

@Kuhnovic
Copy link
Contributor Author

I'm giving up on this one, it's becoming a huge hassle for something that I initially thought would be relatively simple to do. I don't want to spend so much time that's going to a relatively small contribution to the overall gameplay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants