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

Change: add support for next/previous railtype global hotkeys #7851

Open
wants to merge 1 commit into
base: master
from

Conversation

@grossws
Copy link
Contributor

@grossws grossws commented Dec 1, 2019

This patch adds support for next/prev railtype global hotkeys which are basically autorail + special modifier which selects previous or next available railtype.

Such behaviour is useful for players who use PURR, Useless Tracks and similar NewGRFs for quick selection.

I use PURR with semantic tracks coloring (e.g. white purr for waiting bays, red purr for prio zones etc).

Current patch binds this feature to GLOBAL+[ and GLOBAL+].

UPD If user explicitly selected some widget in railway build toolbar it won't switch to autorail.

Signed-off-by: Konstantin Gribov grossws@gmail.com

@grossws grossws changed the title Change: [add support for next/previous railtype global hotkeys Change: add support for next/previous railtype global hotkeys Dec 1, 2019
@grossws grossws force-pushed the grossws:change-prev-next-railtype-hotkeys branch from ff01b43 to f29dd26 Dec 1, 2019
src/widgets/rail_widget.h Outdated Show resolved Hide resolved
@grossws grossws force-pushed the grossws:change-prev-next-railtype-hotkeys branch from f29dd26 to c42996b Dec 1, 2019
@nielsmh
Copy link
Contributor

@nielsmh nielsmh commented Dec 2, 2019

This needs to be tested with keyboard layouts where the [ ] characters are on AltGr combinations with the number row. (Several continental European layouts.)

@grossws
Copy link
Contributor Author

@grossws grossws commented Dec 2, 2019

@nielsmh, I tested it on Linux w/ SDL2 and default German layout where [/] are on AltGr+8/9. Hotkeys work as expected when PR #7850 is applied, on same keys where [/] are on US layout.

@grossws
Copy link
Contributor Author

@grossws grossws commented Dec 7, 2019

Some additional thoughts about this feature. Currently it switches to autorail but better in UX terms would be to stay with same chosen widget if one is selected.

Then you can just switch railtype on the fly with say converse or depot instead of switching railtype and choosing converse/depot/whatever after that. Behavior when rail building tools are inactive should stay the same: choose railtype and activate autorail.

src/rail_gui.cpp Outdated Show resolved Hide resolved
src/rail_gui.cpp Outdated Show resolved Hide resolved
src/rail_gui.cpp Outdated Show resolved Hide resolved
src/rail_gui.cpp Outdated Show resolved Hide resolved
src/rail_gui.cpp Outdated Show resolved Hide resolved
@grossws
Copy link
Contributor Author

@grossws grossws commented Dec 24, 2019

@LordAro, ok, I'll fix things mentioned above. In case of code style I just did by example and got smacked by CI once)

Anyway, I will mark this as work-in-progress since I wish to change some logic (see #7851 (comment))

@grossws grossws changed the title Change: add support for next/previous railtype global hotkeys [WIP] Change: add support for next/previous railtype global hotkeys Dec 24, 2019
@TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented Dec 24, 2020

hi @grossws : exactly a year later, as if I planned this! (I did not :D). I was wondering if you are still interested in seeing this PR through? It seems you have a few comments open that needs resolving .. would be cool if you could! Tnx!

@andythenorth
Copy link
Contributor

@andythenorth andythenorth commented Dec 24, 2020

Is it extensible to roadtypes also? :D No problem if not, just curious.

@grossws
Copy link
Contributor Author

@grossws grossws commented Dec 28, 2020

@TrueBrain, I can possibly look into this and update PR but after Jan, 7th when I return from vacation. Quite eventful year it was ,)

@andythenorth, didn't look into that, but it may be possible if it has similar implementation. I don't recall different road types at all, could you point what additional GRFs should I have to check that?

@grossws grossws force-pushed the grossws:change-prev-next-railtype-hotkeys branch 3 times, most recently from 5b9e88a to 9f690f6 Jan 13, 2021
@grossws grossws changed the title [WIP] Change: add support for next/previous railtype global hotkeys Change: add support for next/previous railtype global hotkeys Jan 14, 2021
@grossws
Copy link
Contributor Author

@grossws grossws commented Jan 14, 2021

Possible modification: instead of adding RailToolbarWidgetModifiers enum just add prev/next_railtype to RailToolbarWidgets with explicit constants like 0xfd/0xfe.

Initially I put them into separate enum because I thought that it would be confusing to have WID_RAT_* enum values not represented in toolbar as a button. But caption already exists, so maybe it's not the case.

Also, GHK_MOD_RAT_* became simple special hotkeys and not actually modifiers for WID_RAT_AUTORAIL, another point to putting them into RailToolbarWidgets enum.

@grossws grossws requested a review from LordAro Jan 14, 2021
This patch adds support for next/prev railtype global hotkeys which are basically autorail + special modifier which selects previous or next available railtype.
If user selected any widget in railway build toolbox it won't switch to autorail but keep current widget instead.

Such behaviour is useful for players who use PURR, Useless Tracks and similar NewGRFs for quick selection.

I use PURR with semantic tracks coloring (e.g. white purr for waiting bays, red purr for prio zones etc).

Current patch binds this feature to `GLOBAL+[` and `GLOBAL+]`.

Signed-off-by: Konstantin Gribov <grossws@gmail.com>
@grossws grossws force-pushed the grossws:change-prev-next-railtype-hotkeys branch from 9f690f6 to 6064c3f Jan 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.