diff --git a/android/Images/TileIcons/MapOverlayToggleMovement.png b/android/Images/TileIcons/MapOverlayToggleMovement.png new file mode 100644 index 0000000000..e3b2a57205 Binary files /dev/null and b/android/Images/TileIcons/MapOverlayToggleMovement.png differ diff --git a/android/Images/TileIcons/MapOverlayToggleResources.png b/android/Images/TileIcons/MapOverlayToggleResources.png new file mode 100644 index 0000000000..39624cc8b7 Binary files /dev/null and b/android/Images/TileIcons/MapOverlayToggleResources.png differ diff --git a/android/Images/TileIcons/MapOverlayToggleWorkedTiles.png b/android/Images/TileIcons/MapOverlayToggleWorkedTiles.png new file mode 100644 index 0000000000..49bafc3e83 Binary files /dev/null and b/android/Images/TileIcons/MapOverlayToggleWorkedTiles.png differ diff --git a/android/Images/TileIcons/MapOverlayToggleYields.png b/android/Images/TileIcons/MapOverlayToggleYields.png new file mode 100644 index 0000000000..4675641dd8 Binary files /dev/null and b/android/Images/TileIcons/MapOverlayToggleYields.png differ diff --git a/android/ImagesToNotAddToGame/MapOverlayToggleMovement.xcf b/android/ImagesToNotAddToGame/MapOverlayToggleMovement.xcf new file mode 100644 index 0000000000..bbf51f0d32 Binary files /dev/null and b/android/ImagesToNotAddToGame/MapOverlayToggleMovement.xcf differ diff --git a/android/ImagesToNotAddToGame/MapOverlayToggleResources.xcf b/android/ImagesToNotAddToGame/MapOverlayToggleResources.xcf new file mode 100644 index 0000000000..649215a2e4 Binary files /dev/null and b/android/ImagesToNotAddToGame/MapOverlayToggleResources.xcf differ diff --git a/android/ImagesToNotAddToGame/MapOverlayToggleWorkedTiles.xcf b/android/ImagesToNotAddToGame/MapOverlayToggleWorkedTiles.xcf new file mode 100644 index 0000000000..1af8e2b08e Binary files /dev/null and b/android/ImagesToNotAddToGame/MapOverlayToggleWorkedTiles.xcf differ diff --git a/android/ImagesToNotAddToGame/MapOverlayToggleYields.xcf b/android/ImagesToNotAddToGame/MapOverlayToggleYields.xcf new file mode 100644 index 0000000000..928ec029cf Binary files /dev/null and b/android/ImagesToNotAddToGame/MapOverlayToggleYields.xcf differ diff --git a/android/assets/game.atlas b/android/assets/game.atlas index a3a2684f1d..b8c4fa12b4 100644 --- a/android/assets/game.atlas +++ b/android/assets/game.atlas @@ -125,21 +125,21 @@ EmojiIcons/Happiness index: -1 EmojiIcons/Production rotate: false - xy: 552, 215 + xy: 544, 1087 size: 50, 50 orig: 50, 50 offset: 0, 0 index: -1 EmojiIcons/Science rotate: false - xy: 552, 41 + xy: 544, 913 size: 50, 50 orig: 50, 50 offset: 0, 0 index: -1 EmojiIcons/Turn rotate: false - xy: 544, 1029 + xy: 544, 797 size: 50, 50 orig: 50, 50 offset: 0, 0 @@ -755,7 +755,7 @@ OtherIcons/NationSwap index: -1 OtherIcons/Nations rotate: false - xy: 552, 331 + xy: 552, 99 size: 50, 50 orig: 50, 50 offset: 0, 0 @@ -783,7 +783,7 @@ OtherIcons/Options index: -1 OtherIcons/Pause rotate: false - xy: 552, 273 + xy: 552, 41 size: 50, 50 orig: 50, 50 offset: 0, 0 @@ -1322,14 +1322,14 @@ TileIcons/Worked index: -1 StatIcons/Range rotate: false - xy: 552, 157 + xy: 544, 1029 size: 50, 50 orig: 50, 50 offset: 0, 0 index: -1 StatIcons/RangedStrength rotate: false - xy: 552, 99 + xy: 544, 971 size: 50, 50 orig: 50, 50 offset: 0, 0 @@ -1357,7 +1357,7 @@ StatIcons/Specialist index: -1 StatIcons/Strength rotate: false - xy: 544, 1087 + xy: 544, 855 size: 50, 50 orig: 50, 50 offset: 0, 0 @@ -1390,6 +1390,34 @@ TileIcons/Locked orig: 100, 100 offset: 0, 0 index: -1 +TileIcons/MapOverlayToggleMovement + rotate: false + xy: 552, 331 + size: 50, 50 + orig: 50, 50 + offset: 0, 0 + index: -1 +TileIcons/MapOverlayToggleResources + rotate: false + xy: 552, 273 + size: 50, 50 + orig: 50, 50 + offset: 0, 0 + index: -1 +TileIcons/MapOverlayToggleWorkedTiles + rotate: false + xy: 552, 215 + size: 50, 50 + orig: 50, 50 + offset: 0, 0 + index: -1 +TileIcons/MapOverlayToggleYields + rotate: false + xy: 552, 157 + size: 50, 50 + orig: 50, 50 + offset: 0, 0 + index: -1 TileIcons/NotWorked rotate: false xy: 1399, 1607 diff --git a/android/assets/game.png b/android/assets/game.png index 0640b10729..9cf92033a0 100644 Binary files a/android/assets/game.png and b/android/assets/game.png differ diff --git a/core/src/com/unciv/ui/images/IconCircleGroup.kt b/core/src/com/unciv/ui/images/IconCircleGroup.kt index c6a0d684be..231b4b1b71 100644 --- a/core/src/com/unciv/ui/images/IconCircleGroup.kt +++ b/core/src/com/unciv/ui/images/IconCircleGroup.kt @@ -7,7 +7,7 @@ import com.badlogic.gdx.scenes.scene2d.Group import com.badlogic.gdx.utils.Align import com.unciv.ui.components.extensions.center -class IconCircleGroup( +open class IconCircleGroup( size: Float, val actor: Actor, resizeActor: Boolean = true, diff --git a/core/src/com/unciv/ui/screens/worldscreen/minimap/MapOverlayToggleButton.kt b/core/src/com/unciv/ui/screens/worldscreen/minimap/MapOverlayToggleButton.kt index 68e0b8652e..0ef3dfb033 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/minimap/MapOverlayToggleButton.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/minimap/MapOverlayToggleButton.kt @@ -1,42 +1,37 @@ package com.unciv.ui.screens.worldscreen.minimap import com.badlogic.gdx.graphics.Color -import com.badlogic.gdx.scenes.scene2d.Actor import com.badlogic.gdx.scenes.scene2d.ui.Image import com.unciv.GUI -import com.unciv.ui.images.IconCircleGroup +import com.unciv.ui.components.extensions.setSize import com.unciv.ui.components.input.onClick -import com.unciv.ui.components.extensions.surroundWithCircle +import com.unciv.ui.images.IconCircleGroup +import com.unciv.ui.images.ImageGetter +import com.unciv.ui.screens.worldscreen.WorldScreen /** * Class that unifies the behaviour of the little green map overlay toggle buttons shown next to the minimap. * - * @param icon An [Image] to display. + * @param iconPath Path to an [Image] to display, will be fetched via [ImageGetter.getImage]. + * @param iconSize inner icon size (2f outer circle will be added). * @property getter A function that returns the current backing state of the toggle. * @property setter A function for setting the backing state of the toggle. - * @param backgroundColor If non-null, a background colour to show behind the image. */ class MapOverlayToggleButton( - icon: Image, + iconPath: String, + iconSize: Float = 30f, private val getter: () -> Boolean, - private val setter: (Boolean) -> Unit, - backgroundColor: Color? = null + private val setter: (Boolean) -> Unit +) : IconCircleGroup( + size = iconSize + 2f, + actor = ImageGetter.getImage(iconPath).apply { + setSize(iconSize) + }, + resizeActor = false ) { - /** [Actor] of the button. Add this to whatever layout. */ - val actor: IconCircleGroup by lazy { - var innerActor: Actor = icon - val iconSize = 30f - if (backgroundColor != null) { - innerActor = innerActor - .surroundWithCircle(iconSize) - .apply { circle.color = backgroundColor } - } else innerActor.setSize(iconSize,iconSize) - // So, the "Food" and "Population" stat icons have green as part of their image, but the "Cattle" icon needs a background colour, which is… An interesting mixture/reuse of texture data and render-time processing. - innerActor.surroundWithCircle(32f, resizeActor = false).apply { circle.color = Color.BLACK } - } - init { - actor.onClick(::toggle) + circle.color = Color.BLACK + onClick(::toggle) } /** Toggle overlay. Called on click. */ @@ -48,6 +43,6 @@ class MapOverlayToggleButton( /** Update. Called via [WorldScreen.shouldUpdate] on toggle. */ fun update() { - actor.actor.color.a = if (getter()) 1f else 0.5f + actor.color.a = if (getter()) 1f else 0.5f } } diff --git a/core/src/com/unciv/ui/screens/worldscreen/minimap/MinimapHolder.kt b/core/src/com/unciv/ui/screens/worldscreen/minimap/MinimapHolder.kt index 159d814275..5496e989e1 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/minimap/MinimapHolder.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/minimap/MinimapHolder.kt @@ -7,7 +7,6 @@ import com.badlogic.gdx.utils.Align import com.unciv.GUI import com.unciv.UncivGame import com.unciv.logic.civilization.Civilization -import com.unciv.ui.images.ImageGetter import com.unciv.ui.screens.basescreen.BaseScreen import com.unciv.ui.screens.worldscreen.WorldMapHolder @@ -18,40 +17,37 @@ class MinimapHolder(val mapHolder: WorldMapHolder) : Table() { /** Button, next to the minimap, to toggle the unit movement map overlay. */ val movementsImageButton = MapOverlayToggleButton( - ImageGetter.getImage("StatIcons/Movement").apply { setColor(0f, 0f, 0f, 1f) }, + "TileIcons/MapOverlayToggleMovement", getter = { UncivGame.Current.settings.showUnitMovements }, - setter = { UncivGame.Current.settings.showUnitMovements = it }, - backgroundColor = Color.GREEN + setter = { UncivGame.Current.settings.showUnitMovements = it } ) /** Button, next to the minimap, to toggle the tile yield map overlay. */ val yieldImageButton = MapOverlayToggleButton( - ImageGetter.getImage("StatIcons/Food"), + "TileIcons/MapOverlayToggleYields", // This is a use in the UI that has little to do with the stat… These buttons have more in common with each other than they do with other uses of getStatIcon(). getter = { UncivGame.Current.settings.showTileYields }, setter = { UncivGame.Current.settings.showTileYields = it } ) /** Button, next to the minimap, to toggle the worked tiles map overlay. */ val populationImageButton = MapOverlayToggleButton( - ImageGetter.getImage("StatIcons/Population"), + "TileIcons/MapOverlayToggleWorkedTiles", getter = { UncivGame.Current.settings.showWorkedTiles }, setter = { UncivGame.Current.settings.showWorkedTiles = it } ) /** Button, next to the minimap, to toggle the resource icons map overlay. */ val resourceImageButton = MapOverlayToggleButton( - ImageGetter.getImage("ResourceIcons/Cattle"), + "TileIcons/MapOverlayToggleResources", getter = { UncivGame.Current.settings.showResourcesAndImprovements }, - setter = { UncivGame.Current.settings.showResourcesAndImprovements = it }, - backgroundColor = Color.GREEN + setter = { UncivGame.Current.settings.showResourcesAndImprovements = it } ) private fun rebuildIfSizeChanged(civInfo: Civilization) { // For Spectator should not restrict minimap - var civInfo: Civilization? = civInfo - if(GUI.getViewingPlayer().isSpectator()) civInfo = null + val civ: Civilization? = civInfo.takeUnless { GUI.getViewingPlayer().isSpectator() } val newMinimapSize = worldScreen.game.settings.minimapSize - if (newMinimapSize == minimapSize && civInfo?.exploredRegion?.shouldUpdateMinimap() != true) return + if (newMinimapSize == minimapSize && civ?.exploredRegion?.shouldUpdateMinimap() != true) return minimapSize = newMinimapSize - rebuild(civInfo) + rebuild(civ) } private fun rebuild(civInfo: Civilization?) { @@ -88,10 +84,10 @@ class MinimapHolder(val mapHolder: WorldMapHolder) : Table() { private fun getToggleIcons(): Table { val toggleIconTable = Table() - toggleIconTable.add(movementsImageButton.actor).row() - toggleIconTable.add(yieldImageButton.actor).row() - toggleIconTable.add(populationImageButton.actor).row() - toggleIconTable.add(resourceImageButton.actor).row() + toggleIconTable.add(movementsImageButton).row() + toggleIconTable.add(yieldImageButton).row() + toggleIconTable.add(populationImageButton).row() + toggleIconTable.add(resourceImageButton).row() return toggleIconTable }