mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-05 21:11:35 +07:00
Moved map toggle icons near the minimap
This commit is contained in:
parent
5577022bd7
commit
347d329233
@ -193,7 +193,7 @@ fun Actor.onClick(function: () -> Unit) {
|
||||
} )
|
||||
}
|
||||
|
||||
fun Image.surroundWithCircle(size:Float): IconCircleGroup {
|
||||
fun Actor.surroundWithCircle(size:Float): IconCircleGroup {
|
||||
return IconCircleGroup(size,this)
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.unciv.ui.utils
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||
import com.badlogic.gdx.scenes.scene2d.Group
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||
|
||||
class IconCircleGroup(size:Float, val image: Image): Group(){
|
||||
class IconCircleGroup(size:Float, val image: Actor): Group(){
|
||||
val circle = ImageGetter.getImage("OtherIcons/Circle").apply { setSize(size, size) }
|
||||
init {
|
||||
setSize(size, size)
|
||||
|
@ -6,12 +6,15 @@ import com.badlogic.gdx.scenes.scene2d.Group
|
||||
import com.badlogic.gdx.scenes.scene2d.InputListener
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.HexMath
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.utils.onClick
|
||||
import com.unciv.ui.utils.surroundWithCircle
|
||||
|
||||
class Minimap(val tileMapHolder: TileMapHolder) : ScrollPane(null){
|
||||
val allTiles = Group()
|
||||
@ -79,4 +82,58 @@ class Minimap(val tileMapHolder: TileMapHolder) : ScrollPane(null){
|
||||
else hex.color = tileInfo.getBaseTerrain().getColor().lerp(Color.GRAY, 0.5f) // Todo add to baseterrain as function
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MinimapHolder(val tileMapHolder: TileMapHolder): Table(){
|
||||
val minimap = Minimap(tileMapHolder)
|
||||
val worldScreen = tileMapHolder.worldScreen
|
||||
|
||||
init{
|
||||
add(getToggleIcons()).align(Align.bottom)
|
||||
add(getWrappedMinimap())
|
||||
pack()
|
||||
}
|
||||
|
||||
fun getWrappedMinimap(): Table {
|
||||
val internalMinimapWrapper = Table()
|
||||
internalMinimapWrapper.add(minimap).size(worldScreen.stage.width/5,worldScreen.stage.height/5)
|
||||
internalMinimapWrapper.background=ImageGetter.getBackground(Color.GRAY)
|
||||
internalMinimapWrapper.pack()
|
||||
|
||||
val externalMinimapWrapper = Table()
|
||||
externalMinimapWrapper.add(internalMinimapWrapper).pad(5f)
|
||||
externalMinimapWrapper.background=ImageGetter.getBackground(Color.WHITE)
|
||||
externalMinimapWrapper.pack()
|
||||
|
||||
return externalMinimapWrapper
|
||||
}
|
||||
|
||||
fun getToggleIcons():Table{
|
||||
val toggleIconTable=Table()
|
||||
val settings = UnCivGame.Current.settings
|
||||
|
||||
val populationImage = ImageGetter.getStatIcon("Population").surroundWithCircle(40f)
|
||||
populationImage.circle.color = Color.BLACK
|
||||
populationImage.image.color.a = if(settings.showWorkedTiles) 1f else 0.5f
|
||||
populationImage.onClick {
|
||||
settings.showWorkedTiles = !settings.showWorkedTiles
|
||||
populationImage.image.color.a = if(settings.showWorkedTiles) 1f else 0.5f
|
||||
worldScreen.update()
|
||||
}
|
||||
toggleIconTable.add(populationImage).row()
|
||||
|
||||
val resourceImage = ImageGetter.getResourceImage("Cattle",30f).surroundWithCircle(40f)
|
||||
resourceImage.circle.color = Color.BLACK
|
||||
resourceImage.image.color.a = if(settings.showResourcesAndImprovements) 1f else 0.5f
|
||||
resourceImage.onClick {
|
||||
settings.showResourcesAndImprovements = !settings.showResourcesAndImprovements
|
||||
resourceImage.image.color.a = if(settings.showResourcesAndImprovements) 1f else 0.5f
|
||||
worldScreen.update()
|
||||
}
|
||||
toggleIconTable.add(resourceImage)
|
||||
toggleIconTable.pack()
|
||||
return toggleIconTable
|
||||
}
|
||||
|
||||
fun update(civInfo:CivilizationInfo){minimap.update(civInfo)}
|
||||
}
|
@ -27,7 +27,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
internal val civInfo: CivilizationInfo = gameInfo.getPlayerCivilization()
|
||||
|
||||
val tileMapHolder: TileMapHolder = TileMapHolder(this, gameInfo.tileMap)
|
||||
val minimap = Minimap(tileMapHolder)
|
||||
val minimapWrapper = MinimapHolder(tileMapHolder)
|
||||
|
||||
private val topBar = WorldScreenTopBar(this)
|
||||
val bottomBar = WorldScreenBottomBar(this)
|
||||
@ -48,15 +48,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
notificationsScroll = NotificationsScroll(this)
|
||||
notificationsScroll.width = stage.width/3
|
||||
|
||||
val externalMinimapWrapper = Table()
|
||||
val internalMinimapWrapper = Table()
|
||||
internalMinimapWrapper.add(minimap).size(stage.width/5,stage.height/5)
|
||||
internalMinimapWrapper.background=ImageGetter.getBackground(Color.GRAY)
|
||||
internalMinimapWrapper.pack()
|
||||
externalMinimapWrapper.add(internalMinimapWrapper).pad(5f)
|
||||
externalMinimapWrapper.background=ImageGetter.getBackground(Color.WHITE)
|
||||
externalMinimapWrapper.pack()
|
||||
externalMinimapWrapper.x = stage.width - externalMinimapWrapper.width
|
||||
minimapWrapper.x = stage.width - minimapWrapper.width
|
||||
|
||||
tileMapHolder.addTiles()
|
||||
|
||||
@ -66,7 +58,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
}
|
||||
|
||||
stage.addActor(tileMapHolder)
|
||||
stage.addActor(externalMinimapWrapper)
|
||||
stage.addActor(minimapWrapper)
|
||||
stage.addActor(topBar)
|
||||
stage.addActor(nextTurnButton)
|
||||
stage.addActor(techButton)
|
||||
@ -141,15 +133,15 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
updateDiplomacyButton(cloneCivilization)
|
||||
|
||||
bottomBar.update(tileMapHolder.selectedTile) // has to come before tilemapholder update because the tilemapholder actions depend on the selected unit!
|
||||
minimap.update(cloneCivilization)
|
||||
minimap.parent.parent.y = bottomBar.height // couldn't be bothered to create a separate val for minimap wrapper
|
||||
minimapWrapper.update(cloneCivilization)
|
||||
minimapWrapper.y = bottomBar.height // couldn't be bothered to create a separate val for minimap wrapper
|
||||
|
||||
unitActionsTable.update(bottomBar.unitTable.selectedUnit)
|
||||
unitActionsTable.y = bottomBar.height
|
||||
|
||||
// if we use the clone, then when we update viewable tiles
|
||||
// it doesn't update the explored tiles of the civ... need to think about that harder
|
||||
// it causes a bug when we move a unit to an unexplored tile (for instance cavalry unit which can move far)
|
||||
// it causes a bug when we move a unit to an unexplored tile (for instance a cavalry unit which can move far)
|
||||
tileMapHolder.updateTiles(civInfo)
|
||||
|
||||
topBar.update(cloneCivilization)
|
||||
|
@ -1,10 +1,7 @@
|
||||
package com.unciv.ui.worldscreen.bottombar
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.map.TileInfo
|
||||
@ -22,7 +19,6 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table() {
|
||||
val civInfo = worldScreen.civInfo
|
||||
columnDefaults(0).padRight(10f)
|
||||
|
||||
add(getCheckboxTable())
|
||||
if (civInfo.exploredTiles.contains(tile.position) || UnCivGame.Current.viewEntireMapForDebug) {
|
||||
add(getStatsTable(tile)).pad(10f)
|
||||
add(Label(tile.toString(), skin)).colspan(2)
|
||||
@ -33,35 +29,6 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table() {
|
||||
setPosition(worldScreen.stage.width - 10f - width, 10f)
|
||||
}
|
||||
|
||||
fun getCheckboxTable(): Table {
|
||||
val settings = UnCivGame.Current.settings
|
||||
val table=Table()
|
||||
|
||||
val populationCheckbox = CheckBox("",CameraStageBaseScreen.skin)
|
||||
populationCheckbox.add(ImageGetter.getStatIcon("Population")).size(20f)
|
||||
populationCheckbox.isChecked = settings.showWorkedTiles
|
||||
populationCheckbox.addListener(object : ChangeListener(){
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
settings.showWorkedTiles = populationCheckbox.isChecked
|
||||
worldScreen.update()
|
||||
}
|
||||
})
|
||||
table.add(populationCheckbox).row()
|
||||
|
||||
val resourceCheckbox = CheckBox("",CameraStageBaseScreen.skin)
|
||||
resourceCheckbox.add(ImageGetter.getResourceImage("Cattle",20f))
|
||||
resourceCheckbox.isChecked = settings.showResourcesAndImprovements
|
||||
resourceCheckbox.addListener(object : ChangeListener(){
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
settings.showResourcesAndImprovements = resourceCheckbox.isChecked
|
||||
worldScreen.update()
|
||||
}
|
||||
})
|
||||
table.add(resourceCheckbox).row()
|
||||
|
||||
return table
|
||||
}
|
||||
|
||||
fun getStatsTable(tile: TileInfo):Table{
|
||||
val table=Table()
|
||||
table.pad(10f)
|
||||
|
Loading…
Reference in New Issue
Block a user