Skip to content

Add a basic minimap#916

Open
ajhalme wants to merge 7 commits intoC7-Game:Developmentfrom
ajhalme:minimap
Open

Add a basic minimap#916
ajhalme wants to merge 7 commits intoC7-Game:Developmentfrom
ajhalme:minimap

Conversation

@ajhalme
Copy link
Contributor

@ajhalme ajhalme commented Mar 11, 2026

Add a basic minimap:

  • Render map tiles as pixels in an image (with a fixed palette for now)
  • Muted terrain colours, super-saturated civ colours
  • Support for click to center (!)
  • Render viewport edge
  • Supports zoom
  • Supports different map sizes via stretching

Lots of TODOs around configurability, and I'm sure the colours could use some work, but it's a start. Already super handy.

Should be trivially parallelizable.

Tested briefly with civ3 and standalone modes.

minimap_large minimap_standalone minimap_tiny

Copy link
Contributor

@stavrosfa stavrosfa left a comment

Choose a reason for hiding this comment

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

Brilliant stuff! It definetly needs some work, but it's a great feature to have!

I 'll dump here some comments in general.

First and most importantly, the go-to functionality is broken. When I press G and then click on the map, it moves the map rather than acepting the click.

On the visual side of things that could be future TODOs or if you want to tackle some more things in this PR:

  1. Add the frame texture for the minimapp, this is the easy part now :P
  2. I see cities in the original are a 3x3 pixel square to make them more visible. Now, sometimes they are 2x2, 2x3, etc.
  3. The sea tiles that are inside someones territory are not shaded with the civ's color, but simply as the sea color.
  4. The territory seems to have a bit of transparency, blending more naturally with the underlying map.
  5. Right/Left clicks should be disabled when over the minimap (I think left click is ok, right click is not)
Image
  1. Dragging the square in the minimap doesn't move the map
  2. Dragging on the map to move, should stop when over a UI element (like the minimap). This is implemented for the Lower Right box if you want to hava a look.
  3. The square also doesn't support wrapping. If I move the map manually and wrap around, the square remains squashed.
  4. When it's on the top/bottom edges of the map (that usually don't wrap around), it shouldn't get squashed
  5. Fog of war tiles in the minimap (original), seem to have an extra layer of gradient, going from total black to semi-transparent black, then to whatever tile color they represent.
  6. The square seems to be a bit thicker at times than it should
  7. Sometimes it also seems that its size is not consistent.
  8. We need to stop using gD.GetFirstHumanPlayer() and start passing the player controller as an argument to pretty much all the UI elements.
  9. Perhaps render the minimap texture in layers? The terrain is unlikely to change, so we can have this as a base, then add forests, cities, etc on top? We could have a hook to recalculate what we need if there are changes. This would also enable us to quickly toggle between a geographic view of the map and a more full one (even add more as we go)

These are my thoughts so far

@ajhalme
Copy link
Contributor Author

ajhalme commented Mar 19, 2026

First and most importantly, the go-to functionality is broken. When I press G and then click on the map, it moves the map rather than acepting the click.

Hmm, not 100% sure what the intended functionality is here. Are you pressing G and then clicking the minimap and expecting the Goto to set the target there automatically, without centering the screen, or?

I tried to fix issue (5) by disabling the right click, maybe that changes the GoTo behaviour as well.

Changed the case order so sea tiles get drawn before civ owned tiles, which I think fixes (3).

Also had a go at enabling the frame texture, even made a variant of the one used in the standalone (see C7-Game/Assets#4).

The layer suggestion is interesting, I'll give that a go. And fixing wrap should fix a few of the issues listed.

The minimap content is stretched by nature, so getting it pixel perfect with that technique might be a hassle. There might be a way to make it more stable by selecting the dimensions carefully, like only even widths allowed or something, etc.

--

Some more screens with the frames:

Screenshot at 2026-03-19 00-20-27 Screenshot at 2026-03-19 00-21-38

@stavrosfa
Copy link
Contributor

Hmm, not 100% sure what the intended functionality is here. Are you pressing G and then clicking the minimap and expecting the Goto to set the target there automatically, without centering the screen, or?

No, imagine there is no minimap, I was trying to move a unit with the go-to command and clicking on a tile on the regular map, that's what was broken.

I briefly tried this PR, the go-to seems fixed, so we are good on that!

Issue 3 seems ok
Issue 5, now even the right click goes through as far as I can tell, and it moves the map, not the minimap :/

The minimap content is stretched by nature, so getting it pixel perfect with that technique might be a hassle. There might be a way to make it more stable by selecting the dimensions carefully, like only even widths allowed or something, etc.

Not sure what you are referring to here

As I said in my previous comment, these are suggestions and TODOs, I don't expect you to solve them all or something, if everything is working, or rather, if nothing is broken, we can merge this at any point, add a bunch of TODOs, and come back to it later, so, no pressure

@ajhalme
Copy link
Contributor Author

ajhalme commented Mar 24, 2026

Refactored the minimap drawing to multiple components and the map itself to multiple draw layers.

Also implemented basic bounds logic to handle drawing the minimap across the edges of the map.

Screenshot at 2026-03-24 01-17-24

@ajhalme
Copy link
Contributor Author

ajhalme commented Mar 25, 2026

Added some color blending for transparency effects (city, fog over) -- the blend parameter need some tunic.

Also added basic minimap panning.

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.

2 participants