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

Add two travel-related overmap keybinds for a better UX #64174

Conversation

strategineer
Copy link
Contributor

@strategineer strategineer commented Mar 12, 2023

Summary

Interface "Add two travel-related overmap keybinds for a better UX"

Add two new keybinds GO_TO_DESTINATION and CENTER_ON_DESTINATION that allow the player to:

  • Go to the current travel destination without the cursor needing to be on it.
  • Move the cursor to the current travel destination.

Purpose of change

I was getting annoyed about constantly having to open the overmap and pan over to my destination over and over again when traveling somewhere to resume traveling after enemies showed up.

Describe the solution

  • Added the keybinds
  • Refactored the code used by the CHOOSE_DESTINATION keybind into a function so that I can call it from the GO_TO_DESTINATION keybind code.

Describe alternatives you've considered

For next steps, I'd like to make the GO_TO_DESTINATION keybind work directly from the game world as well as the overmap. Although that seems like a bigger change.

Let me know if you've got a better idea for the default values for the keybinds.

Testing

  • Tested the two keybinds and ensured that they're doing what's expected.
  • Checked that the UI hints were displaying well.
  • Ensured that the two keybinds' default values aren't overlapping with any other overmap keybinds.

Additional context

Overmap screen with new keybinds being displayed:
cataclysm-tiles_kzvH8Yd1ed

GO_TO_DESTINATION key pressed when the cursor is NOT on the destination:
cataclysm-tiles_4fe0I3zeD3

GO_TO_DESTINATION or CHOOSE_DESTINATION key pressed when the cursor is already on the destination:
cataclysm-tiles_Ue8uNhXXyb

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Info / User Interface Game - player communication, menus, etc. Map / Mapgen Overmap, Mapgen, Map extras, Map display labels Mar 12, 2023
src/overmap_ui.cpp Outdated Show resolved Hide resolved
src/overmap_ui.cpp Outdated Show resolved Hide resolved
src/overmap_ui.cpp Outdated Show resolved Hide resolved
src/overmap_ui.cpp Outdated Show resolved Hide resolved
src/overmap_ui.cpp Outdated Show resolved Hide resolved
src/overmap_ui.cpp Outdated Show resolved Hide resolved
data/raw/keybindings.json Outdated Show resolved Hide resolved
data/raw/keybindings.json Outdated Show resolved Hide resolved
@strategineer strategineer force-pushed the add_convenience_travel_keybinds_to_overmap branch from 0fecfd9 to bcb7469 Compare March 12, 2023 03:53
@github-actions github-actions bot added json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Mar 12, 2023
strategineer and others added 2 commits March 12, 2023 14:44
Add two new keybinds GO_TO_DESTINATION and CENTER_ON_DESTINATION that allow the player to:
- Move the cursor to the current travel destination.
- Go to the current travel destination without the cursor needing to be on it.

I was getting annoyed about constantly having to open the overmap and pan over to my destination over and over again when traveling somewhere to resume traveling after enemies showed up
…rd_code because it's unnecessary when setting keybinds for lower case letters

Co-authored-by: Jianxiang Wang (王健翔) <[email protected]>
@strategineer strategineer force-pushed the add_convenience_travel_keybinds_to_overmap branch from f4820b5 to 2180185 Compare March 12, 2023 18:44
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Mar 13, 2023
@bombasticSlacks bombasticSlacks merged commit 29ba754 into CleverRaven:master Mar 17, 2023
}
return "QUIT";
}
return nullptr;
Copy link
Member

Choose a reason for hiding this comment

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

Why return a nullptr here?

Copy link
Contributor Author

@strategineer strategineer Mar 18, 2023

Choose a reason for hiding this comment

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

No particular reason (unfortunately). Looking back at the code I think it would be cleaner to return true/false in this function and set the action variable to "QUIT" conditionally from the calling code. Although we've still got a function that returns a value and has a side-effect which isn't ideal... Let me type up a quick PR before I forget to refactor this.

EDIT: #64353

Copy link
Member

@BrettDong BrettDong Mar 18, 2023

Choose a reason for hiding this comment

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

I meant constructing a std::string from nullptr is going to crash the program here.

Edit: #64355

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Huh interesting, it wasn't crashing on my end when i tested it. But I'm not surprised that it could. Thanks for keeping an eye out!

Copy link
Member

Choose a reason for hiding this comment

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

If you press N to the prompt you'll reach here and access nullptr memory.

strategineer added a commit to strategineer/Cataclysm-DDA that referenced this pull request Mar 18, 2023
dseguin pushed a commit that referenced this pull request Mar 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions Map / Mapgen Overmap, Mapgen, Map extras, Map display
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants