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

Improve & generalise keybind code #152

Merged
merged 2 commits into from
Jan 20, 2024

Conversation

MattSturgeon
Copy link
Member

Building on #126's ModBindings refactor & toggle key handling, this PR:

  • Generalizes the "combo key" logic in FreecamComboKeyMapping
  • Moves control over keybind handlers to the keybinds themselves
  • Introduces a builder to make defining different types of keybinds more declarative.
  • Reduce the amount of "key handling" in Freecam to activateTripodHandler() & resetTripodHandler(),

I also removed ModBinding's "wrapper" methods;
They only existed to make using the enum values prettier, that is now unnecessary because the keybinds to define their own logic & don't care about the enum.
The one exception to this is in MinecraftMixin, however a couple .get()s is worth the reduced complexity/maintenance IMO.
If you disagree, then 00a5b73 can be dropped or reverted easily.

This PR does not affect the existing behavior in any way.

Move combo-key logic to a dedicated class.

Introduce a builder to build key mappings without constructor overloading.

Allow key mappings to define their own handler logic.
@MattSturgeon MattSturgeon added enhancement New feature or request dev Only affects developers labels Jan 9, 2024
Copy link
Collaborator

@hashalite hashalite left a comment

Choose a reason for hiding this comment

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

Thanks, this is much better. Handling the keybinds directly in the tick was pretty sloppy. This makes it much easier to see what exactly each keybind does.

@hashalite hashalite merged commit dd758ea into MinecraftFreecam:main Jan 20, 2024
@MattSturgeon MattSturgeon deleted the config/extended-keys branch January 21, 2024 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev Only affects developers enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants