Skip to content

Add looping minimap viewport if worldwrap enabled #5349

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

Merged
merged 1 commit into from
Oct 3, 2021

Conversation

Thyrum
Copy link
Contributor

@Thyrum Thyrum commented Sep 29, 2021

The viewport now also appears on the other side of the minimap when viewing the border of the world with worldwrap enabled.

image

The viewport now also appears on the other side of the minimap when
viewing the border of the world with worldwrap enabled.
@Thyrum
Copy link
Contributor Author

Thyrum commented Sep 29, 2021

The one problem with this approach is that it doesn't look good on very tiny maps with world wrap enabled (when you can see more than one copy of the map at once):
image

Possible solution: Stop drawing the sides (left & right) of the viewport rectangle once different viewports start to overlap. I don't know how to implement this yet though, any ideas would be appreciated.

@xlenstra
Copy link
Collaborator

Possible solution: Stop drawing the sides (left & right) of the viewport rectangle once different viewports start to overlap. I don't know how to implement this yet though, any ideas would be appreciated.

I don't know how the code for drawing the minimap works, but I assume that somewhere the width of the minimap viewport is calculated, which can then be compared with the width of the entire minimap. If it's larger, you know the edges are going to overlap, and then can stop drawing the minimap viewport entirely?

@SomeTroglodyte
Copy link
Collaborator

Hey, first of all: 👍 good idea (had it a while ago, too, but was too lazy to find out how), and 👍 for actually pulling it off, no matter if there's room for improvement.
à propos: The whole new block lines 123-131 could be one loop too - just declare the [1] indicator is the "main" one. To avoid cursing mutability of Gdx geometry too much, scrollPositionIndicator[i].setViewport(Rectangle(miniViewport).apply { x += (i-1) * allTiles.width }) will probably work.

@yairm210
Copy link
Owner

Nice!

@Thyrum
Copy link
Contributor Author

Thyrum commented Sep 29, 2021

I don't know how the code for drawing the minimap works, but I assume that somewhere the width of the minimap viewport is calculated, which can then be compared with the width of the entire minimap. If it's larger, you know the edges are going to overlap, and then can stop drawing the minimap viewport entirely?

What I meant is I don't know how to only draw the top & bottom of the viewport (leaving out the sides). The rectangle is currently just an image which is scaled to the proper size. Personally I would want to impelement it as an actual rectangle built from lines (instead of a PNG), making it easier to leave out some lines. I would have to look into how drawing works using Kotlin though.

I don't think we should stop drawing the viewport whenever it overlaps. This will probably just create confusion since people will think the minimap glitches when the viewport overlay suddenly disappears.

@SomeTroglodyte
Copy link
Collaborator

drawing works using Kotlin

It's not kotlin you have to watch out for, it's OpenGL. See ImageGetter.getLine or its use in Diplomacy Overview or Tech tree?

@yairm210
Copy link
Owner

yairm210 commented Oct 3, 2021

This is already an improvement on the current state, I'm merging this and if you change to a "draw lines" approach that can be a separate PR :)

@yairm210 yairm210 merged commit c3242f3 into yairm210:master Oct 3, 2021
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.

4 participants