mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 15:27:50 +07:00
Display scroll position on minimap (#3593)
This commit is contained in:

committed by
GitHub

parent
f2af128546
commit
1e981abe53
BIN
android/Images/OtherIcons/Camera.png
Normal file
BIN
android/Images/OtherIcons/Camera.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
@ -410,6 +410,13 @@ OtherIcons/Crosshair
|
||||
orig: 100, 100
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
OtherIcons/Camera
|
||||
rotate: false
|
||||
xy: 500, 500
|
||||
size: 100, 100
|
||||
orig: 100, 100
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
OtherIcons/DisbandUnit
|
||||
rotate: false
|
||||
xy: 1503, 1730
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 874 KiB After Width: | Height: | Size: 856 KiB |
@ -2,8 +2,10 @@ package com.unciv.ui.worldscreen
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.Batch
|
||||
import com.badlogic.gdx.math.MathUtils
|
||||
import com.badlogic.gdx.math.Vector2
|
||||
import com.badlogic.gdx.scenes.scene2d.Group
|
||||
import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.utils.Align
|
||||
@ -21,6 +23,7 @@ import kotlin.math.min
|
||||
class Minimap(val mapHolder: WorldMapHolder) : Table(){
|
||||
private val allTiles = Group()
|
||||
private val tileImages = HashMap<TileInfo, Image>()
|
||||
private val scrollPosistionIndicator = ImageGetter.getImage("OtherIcons/Camera")
|
||||
|
||||
init {
|
||||
isTransform = false // don't try to resize rotate etc - this table has a LOT of children so that's valuable render time!
|
||||
@ -65,10 +68,28 @@ class Minimap(val mapHolder: WorldMapHolder) : Table(){
|
||||
// so we zero out the starting position of the whole board so they will be displayed as well
|
||||
allTiles.setSize(topX - bottomX, topY - bottomY)
|
||||
|
||||
scrollPosistionIndicator.touchable = Touchable.disabled
|
||||
allTiles.addActor(scrollPosistionIndicator)
|
||||
|
||||
add(allTiles)
|
||||
layout()
|
||||
}
|
||||
|
||||
fun updateScrollPosistion(scrollPos: Vector2, scale: Vector2){
|
||||
|
||||
val scrollPosistionIndicatorBaseScale = Vector2(allTiles.width / mapHolder.maxX, allTiles.height / mapHolder.maxY)
|
||||
|
||||
scrollPosistionIndicator.scaleX = scrollPosistionIndicatorBaseScale.x * 10f * max(2f - scale.x, 0.25f)
|
||||
scrollPosistionIndicator.scaleY = scrollPosistionIndicatorBaseScale.y * 10f * max(2f - scale.y, 0.25f)
|
||||
|
||||
val scrollPositionIndicatorOffset = Vector2(-50f * scrollPosistionIndicator.scaleX, 125f + (50f * (1-scrollPosistionIndicator.scaleY)))
|
||||
|
||||
val scrollPosOnMinimap = Vector2((scrollPos.x / mapHolder.maxX) * allTiles.width, (scrollPos.y / mapHolder.maxY) * allTiles.height)
|
||||
scrollPosOnMinimap.x = MathUtils.clamp(scrollPosOnMinimap.x, -scrollPositionIndicatorOffset.x, allTiles.width + scrollPositionIndicatorOffset.x)
|
||||
scrollPosOnMinimap.y = MathUtils.clamp(scrollPosOnMinimap.y, -scrollPositionIndicatorOffset.x, scrollPositionIndicatorOffset.y)
|
||||
scrollPosistionIndicator.setPosition(scrollPositionIndicatorOffset.x + scrollPosOnMinimap.x, scrollPositionIndicatorOffset.y - scrollPosOnMinimap.y)
|
||||
}
|
||||
|
||||
private class CivAndImage(val civInfo: CivilizationInfo, val image: IconCircleGroup)
|
||||
private val cityIcons = HashMap<TileInfo, CivAndImage>()
|
||||
|
||||
|
@ -630,6 +630,10 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
}
|
||||
// topBar.selectedCivLabel.setText(Gdx.graphics.framesPerSecond) // for framerate testing
|
||||
|
||||
var scrollPos = Vector2(mapHolder.scrollX, mapHolder.scrollY);
|
||||
var viewScale = Vector2(mapHolder.scaleX, mapHolder.scaleY);
|
||||
minimapWrapper.minimap.updateScrollPosistion(scrollPos, viewScale)
|
||||
|
||||
super.render(delta)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user