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

Toggle between the map and look around #76433

Merged
merged 3 commits into from
Sep 16, 2024

Conversation

Brambor
Copy link
Contributor

@Brambor Brambor commented Sep 14, 2024

Summary

Interface "Toggle between the map and look around"

Purpose of change

Describe the solution

Add uistate.open_menu. It stores a function to be executed in the main loop. It is used to open a menu with arguments. Unlike ACTIONS arguments can be passed. Unlike ACTIVITY it doesn't take a turn for the player.

This is utilized to remember the position of look around/map when toggling to the other one. It can be used in more places, such as:

Describe alternatives you've considered

Put avatar.open_menu somewhere else than into avatar. Could be in the game. I think of it as an ACTIVITY/ACTION, so I prefer avatar over game. Creature/Character cannot have it, only avatar can. But maybe it belongs to some uistate or how was it called. Done.

Don't use (and therefore implement) uistate.open_menu, but simply call the look_around from map directly (and vice versa). This approach would grow on the stack as the player would toggle from one to the other. The stack would then need to be collapsed again when the player finally closes look_around or map. The closing would require additional cleanup or maybe just action = "QUIT"; break;.

The function calls on the stack provide no additional benefit. The variables stored there aren't needed and therefore are confusing. A stack overflow error could also occur. This is why I decided on the uistate.open_menu which doesn't grow the stack at all and only useful variables are passed and remembered.

Opening map is forbidden (If I did it correctly) when working with zones. This is to prevent what you can see in Bug below.

Testing

Usecase from

Cataclysm_.Dark.Days.Ahead.-.0.G-12112-g67067d0465-dirty.2024-09-14.19-45-03.mp4

Bug

When long-range teleporting, the player can do ;; (Look around, View map). This returns an invalid point to the teleport, so the teleport doesn't happen. In this case, "Look around" should be forbidden. I don't know how to do that without additional parameter bool forbid_open_map to look_around. So I didn't do it.

Additional context

@github-actions github-actions bot added <Documentation> Design documents, internal info, guides and help. Info / User Interface Game - player communication, menus, etc. [JSON] Changes (can be) made in JSON Map / Mapgen Overmap, Mapgen, Map extras, Map display [C++] Changes (can be) made in C++. Previously named `Code` [Markdown] Markdown issues and PRs <Bugfix> This is a fix for a bug (or closes open issue) astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels Sep 14, 2024
@Brambor Brambor force-pushed the toggle-map-look-around branch from 510b79d to b92134a Compare September 14, 2024 18:39
@Brambor Brambor marked this pull request as draft September 14, 2024 22:45
@Brambor
Copy link
Contributor Author

Brambor commented Sep 14, 2024

I decided to move avatar.open_menu to uistate.open_menu.

I finally learned to mark it as a draft in time, because somebody would sneakily merge it otherwise.

Edit: done!

@CoroNaut
Copy link

Noticed this PR was similar to a suggestion I made a while back as well, just putting this here to link it #70072. Thanks for adding this!

@Brambor Brambor force-pushed the toggle-map-look-around branch from b92134a to 4396c3d Compare September 14, 2024 23:28
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Sep 14, 2024
@Brambor Brambor marked this pull request as ready for review September 14, 2024 23:30
@Brambor Brambor force-pushed the toggle-map-look-around branch from 4396c3d to b2c8b6f Compare September 15, 2024 12:13
@Brambor
Copy link
Contributor Author

Brambor commented Sep 15, 2024

I will change the implementation a bit yet again so that AIM can use it too.

@Brambor Brambor marked this pull request as draft September 15, 2024 14:16
@Brambor Brambor force-pushed the toggle-map-look-around branch from b2c8b6f to e65c14e Compare September 15, 2024 15:19
@Brambor Brambor marked this pull request as ready for review September 15, 2024 15:19
@Maleclypse Maleclypse merged commit b7fc6a9 into CleverRaven:master Sep 16, 2024
32 of 33 checks passed
@Brambor Brambor deleted the toggle-map-look-around branch September 16, 2024 17:06
@alef alef mentioned this pull request Oct 1, 2024
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 <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` <Documentation> Design documents, internal info, guides and help. 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 [Markdown] Markdown issues and PRs
Projects
None yet
3 participants