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

Implement quick spell cycling #6861

Merged
merged 6 commits into from
Dec 14, 2023
Merged

Implement quick spell cycling #6861

merged 6 commits into from
Dec 14, 2023

Conversation

obligaron
Copy link
Contributor

Fixes #6858

Notes

  • This PR implements unsetting quick spells (try to bind the same spell as currently assigned to quick spell removes the binding).
  • Keymapper supports now mouse wheel up/down/left/right. This can also be rebind to different targets.
  • My mouse don't support mouse wheel left/right, so I couldn't test mouse wheel left/right.

newIndex = *currentIndex == 0 ? (validHotKeyIndexes.size() - 1) : (*currentIndex - 1);
}
ToggleSpell(validHotKeyIndexes[newIndex]);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks.... more complicated than it needs to be, at least at first glance.

Have you considered just creating 2 separate functions, "NextSkill" and "PreviousSkill", instead of combining both here?

Also, isn't there something in C++ like a "circular iterator" that we could tap into? Then, it would be a matter of walking forward or backward on it, while checking for the first valid spell occurrence using those predicate lambdas.

I don't know..... this might be me just misremembering how awful C++ is, but this looks incredibly convoluted for such a simple operation conceptually. Maybe we are just lacking some abstraction here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't given it much thought.
But I don't know anything about a circular iterator.
If you want you can give it a try to improve it. 🙂

@DakkJaniels
Copy link
Contributor

DakkJaniels commented Dec 14, 2023

What happens if the player is on a spell that isn't a hotkey spell and tries to do next/previous? Does it fail? I think that what I was seeing, but wasn't sure.

If that's the case, should it just start from the beginning or end of the spell cycle, instead?

Edit: or maybe it's undefined behavior, because currentIndex is never initialized?

Copy link
Member

@AJenbo AJenbo left a comment

Choose a reason for hiding this comment

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

Nice work, in a world of talkers you are a doer :)
Merry xmas.

@AJenbo AJenbo merged commit 8cb167a into diasurgical:master Dec 14, 2023
19 checks passed
Comment on lines -130 to -133
// This is a hack, mousewheel events should be handled directly by their consumers instead.
event->type = SDL_KEYDOWN;
if (e.wheel.y > 0) {
event->key.keysym.sym = (SDL_GetModState() & KMOD_CTRL) != 0 ? SDLK_KP_PLUS : SDLK_UP;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm super happy to see this gone, thank you! 🎉
Did we lose the Control + Wheel functionality to zoom the map with this change though?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this logic is also removed. You can still zoom with the +/- keys.
But if we want this back as special case, we can implement them the same way as scrolling in shops etc. is done. 🙂

@obligaron
Copy link
Contributor Author

What happens if the player is on a spell that isn't a hotkey spell and tries to do next/previous?

The following behavior is implemented:
On next you get the first quick spell.
On previous you get the last quick spell.
🙂

Nice work, in a world of talkers you are a doer :) Merry xmas.

Thank you very much and have a wonderful Christmas. ❤️

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.

[Feature Request]: Option to use scroll wheel to cycle through quick spells
5 participants