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

Clean up overmap drawing code and consolidate to one function #74700

Merged
merged 2 commits into from
Jun 28, 2024

Conversation

ehughsbaird
Copy link
Contributor

Summary

Infrastructure "clean up overmap drawing code and consolidate to one function"

Purpose of change

There are four separate places that take information from the overmap and draw colored symbols to represent it. This creates a maintenance burden and makes it so that changing how this is done requires writing the same code in each of these four places.

These four places are:

  1. The overmap ui or map screen
  2. The map display on the sidebar
  3. The window used to teleport between translocator gates in magiclysm
  4. game::draw_minimap, which isn't called by anything.

Describe the solution

Remove the unused game::draw_minimap, and replace the code in the three remaining places that finds the symbol and color to draw for each tile with a call to a common function, oter_symbol_and_color.

Because the different ways to draw the overmap have a wide variety of options, this function takes two structs as arguments.

The first struct, oter_display_options, holds the settings for drawing that do not change from tile to tile.
It controls

  • whether or not to draw overlays (the ones that can blink on the map screen)
  • whether or not to show scent symbols
  • whether the active mission target should be drawn by giving the tile a red background, or by drawing a red asterisk on it
  • whether the PC position should be drawn with blue hilight of the tile, instead of an '@' symbol
  • if the mission target is in the screen, and thus whether or not to draw an pointer to the mission on the screen edge
  • if explored tiles should be darkened
  • if hordes should be drawn
  • if map tiles revealed by a map should be drawn
  • if the PC should be drawn at all
  • if weather tiles should be drawn instead of terrain

It also provides information on where the PC is, where their mission target is, and some zone and path info used by the overmap screen. If positions and colors of NPCs are provided, they will be drawn on the map as well.

The second struct provides information that changes between tiles

  • if it's seen
  • it it's on the edge of the screen, and can have a mission pointer drawn on it
  • los checks for horde/weather display

It can also take a pointer to a structure which serves as a LRU cache - this was already existing in the map screen version of the draw code.

Testing

  1. Open up the non-tiles overmap screen and go through the various options, visit different places, etc - find hordes, mark places as explored, place notes, use a map, turn on debug overlays, check for a mission tile.
  2. View the same things with the minimap on the sidebar.
  3. Load a world with Magiclysm and use the debug map editor to place a translocator gate. Examine it to attune to it, then debug in the translocation spell. Use the spell, and see that the map displayed is correct. Get a mission with a target inside the drawn area, and one outside, and see that the one inside is drawn, and the one outside draws an indicator on the edge of the map.

@github-actions github-actions bot added Info / User Interface Game - player communication, menus, etc. Map / Mapgen Overmap, Mapgen, Map extras, Map display [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels Jun 21, 2024
@ehughsbaird ehughsbaird force-pushed the cleaner-overmap-drawing branch from 93c2de3 to a292d42 Compare June 21, 2024 21:39
Make the three different places that draw overmap displays use a single
function to get the color and symbol to draw at a point, instead of them
each doing it their own way.

To support the slightly different ways each of them do it, as well as
the extreme degree of options presented by the main overmap view, this
function takes two different structs as arguments. The first struct is
the immediate "arguments" of the function (things that change for each
tile), while the second struct outlines the options this display wants
and does not change between calls.

A pointer to another struct can be provided for a minor LRU
optimization.
@ehughsbaird ehughsbaird force-pushed the cleaner-overmap-drawing branch from a292d42 to 7ef7a79 Compare June 23, 2024 16:12
@Maleclypse Maleclypse merged commit d054031 into CleverRaven:master Jun 28, 2024
25 of 26 checks passed
@ehughsbaird ehughsbaird deleted the cleaner-overmap-drawing branch June 29, 2024 02:06
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` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Info / User Interface Game - player communication, menus, etc. 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.

2 participants