mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-04 16:11:46 +07:00
Add optional on-screen buttons to zoom in and out (#6933)
This commit is contained in:
parent
57c027dca5
commit
ea31bd164f
@ -654,6 +654,7 @@ Show pixel units =
|
|||||||
Show pixel improvements =
|
Show pixel improvements =
|
||||||
Enable Nuclear Weapons =
|
Enable Nuclear Weapons =
|
||||||
Experimental Demographics scoreboard =
|
Experimental Demographics scoreboard =
|
||||||
|
Show zoom buttons in world screen =
|
||||||
Show tile yields =
|
Show tile yields =
|
||||||
Show unit movement arrows =
|
Show unit movement arrows =
|
||||||
Continuous rendering =
|
Continuous rendering =
|
||||||
|
@ -50,6 +50,7 @@ class GameSettings {
|
|||||||
var isFreshlyCreated = false
|
var isFreshlyCreated = false
|
||||||
var visualMods = HashSet<String>()
|
var visualMods = HashSet<String>()
|
||||||
var useDemographics: Boolean = false
|
var useDemographics: Boolean = false
|
||||||
|
var showZoomButtons: Boolean = false
|
||||||
|
|
||||||
var multiplayer = GameSettingsMultiplayer()
|
var multiplayer = GameSettingsMultiplayer()
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ import com.unciv.ui.popup.ToastPopup
|
|||||||
import com.unciv.ui.popup.YesNoPopup
|
import com.unciv.ui.popup.YesNoPopup
|
||||||
import com.unciv.ui.tilegroups.TileGroup
|
import com.unciv.ui.tilegroups.TileGroup
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
|
import com.unciv.ui.worldscreen.ZoomButtonPair
|
||||||
|
|
||||||
|
|
||||||
//todo normalize properly
|
//todo normalize properly
|
||||||
@ -65,6 +66,7 @@ class MapEditorScreen(map: TileMap? = null): BaseScreen() {
|
|||||||
var mapHolder: EditorMapHolder
|
var mapHolder: EditorMapHolder
|
||||||
val tabs: MapEditorMainTabs
|
val tabs: MapEditorMainTabs
|
||||||
var tileClickHandler: ((tile: TileInfo)->Unit)? = null
|
var tileClickHandler: ((tile: TileInfo)->Unit)? = null
|
||||||
|
private var zoomController: ZoomButtonPair? = null
|
||||||
|
|
||||||
private val highlightedTileGroups = mutableListOf<TileGroup>()
|
private val highlightedTileGroups = mutableListOf<TileGroup>()
|
||||||
|
|
||||||
@ -139,6 +141,13 @@ class MapEditorScreen(map: TileMap? = null): BaseScreen() {
|
|||||||
modsTabNeedsRefresh = true
|
modsTabNeedsRefresh = true
|
||||||
editTabsNeedRefresh = true
|
editTabsNeedRefresh = true
|
||||||
naturalWondersNeedRefresh = true
|
naturalWondersNeedRefresh = true
|
||||||
|
|
||||||
|
if (UncivGame.Current.settings.showZoomButtons) {
|
||||||
|
zoomController = ZoomButtonPair(result)
|
||||||
|
zoomController!!.setPosition(10f, 10f)
|
||||||
|
stage.addActor(zoomController)
|
||||||
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ fun displayTab(
|
|||||||
optionsPopup.addCheckbox(this, "Show pixel units", settings.showPixelUnits, true) { settings.showPixelUnits = it }
|
optionsPopup.addCheckbox(this, "Show pixel units", settings.showPixelUnits, true) { settings.showPixelUnits = it }
|
||||||
optionsPopup.addCheckbox(this, "Show pixel improvements", settings.showPixelImprovements, true) { settings.showPixelImprovements = it }
|
optionsPopup.addCheckbox(this, "Show pixel improvements", settings.showPixelImprovements, true) { settings.showPixelImprovements = it }
|
||||||
optionsPopup.addCheckbox(this, "Experimental Demographics scoreboard", settings.useDemographics, true) { settings.useDemographics = it }
|
optionsPopup.addCheckbox(this, "Experimental Demographics scoreboard", settings.useDemographics, true) { settings.useDemographics = it }
|
||||||
|
optionsPopup.addCheckbox(this, "Show zoom buttons in world screen", settings.showZoomButtons, true) { settings.showZoomButtons = it }
|
||||||
|
|
||||||
addMinimapSizeSlider(this, settings, optionsPopup.screen, optionsPopup.selectBoxMinWidth)
|
addMinimapSizeSlider(this, settings, optionsPopup.screen, optionsPopup.selectBoxMinWidth)
|
||||||
|
|
||||||
@ -119,4 +120,4 @@ private fun addTileSetSelectBox(table: Table, settings: GameSettings, selectBoxM
|
|||||||
TileSetCache.assembleTileSetConfigs(ImageGetter.ruleset.mods)
|
TileSetCache.assembleTileSetConfigs(ImageGetter.ruleset.mods)
|
||||||
onTilesetChange()
|
onTilesetChange()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ import java.util.*
|
|||||||
* @property isPlayersTurn (readonly) Indicates it's the player's ([viewingCiv]) turn
|
* @property isPlayersTurn (readonly) Indicates it's the player's ([viewingCiv]) turn
|
||||||
* @property selectedCiv Selected civilization, used in spectator and replay mode, equals viewingCiv in ordinary games
|
* @property selectedCiv Selected civilization, used in spectator and replay mode, equals viewingCiv in ordinary games
|
||||||
* @property canChangeState (readonly) `true` when it's the player's turn unless he is a spectator
|
* @property canChangeState (readonly) `true` when it's the player's turn unless he is a spectator
|
||||||
* @property mapHolder A [MinimapHolder] instance
|
* @property mapHolder A [WorldMapHolder] instance
|
||||||
* @property bottomUnitTable Bottom left widget holding information about a selected unit or city
|
* @property bottomUnitTable Bottom left widget holding information about a selected unit or city
|
||||||
*/
|
*/
|
||||||
class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : BaseScreen() {
|
class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : BaseScreen() {
|
||||||
@ -125,6 +125,8 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Bas
|
|||||||
private val notificationsScroll: NotificationsScroll
|
private val notificationsScroll: NotificationsScroll
|
||||||
var shouldUpdate = false
|
var shouldUpdate = false
|
||||||
|
|
||||||
|
private val zoomController = ZoomButtonPair(mapHolder)
|
||||||
|
|
||||||
private var nextTurnUpdateJob: Job? = null
|
private var nextTurnUpdateJob: Job? = null
|
||||||
|
|
||||||
private val events = EventBus.EventReceiver()
|
private val events = EventBus.EventReceiver()
|
||||||
@ -178,6 +180,9 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Bas
|
|||||||
stage.addActor(techPolicyAndVictoryHolder)
|
stage.addActor(techPolicyAndVictoryHolder)
|
||||||
stage.addActor(tutorialTaskTable)
|
stage.addActor(tutorialTaskTable)
|
||||||
|
|
||||||
|
if (UncivGame.Current.settings.showZoomButtons) {
|
||||||
|
stage.addActor(zoomController)
|
||||||
|
}
|
||||||
|
|
||||||
diplomacyButtonHolder.defaults().pad(5f)
|
diplomacyButtonHolder.defaults().pad(5f)
|
||||||
stage.addActor(fogOfWarButton)
|
stage.addActor(fogOfWarButton)
|
||||||
@ -499,6 +504,10 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Bas
|
|||||||
updateGameplayButtons()
|
updateGameplayButtons()
|
||||||
notificationsScroll.update(viewingCiv.notifications, bottomTileInfoTable.height)
|
notificationsScroll.update(viewingCiv.notifications, bottomTileInfoTable.height)
|
||||||
notificationsScroll.setTopRight(stage.width - 10f, statusButtons.y - 5f)
|
notificationsScroll.setTopRight(stage.width - 10f, statusButtons.y - 5f)
|
||||||
|
|
||||||
|
val posZoomFromRight = if (game.settings.showMinimap) minimapWrapper.width
|
||||||
|
else bottomTileInfoTable.width
|
||||||
|
zoomController.setPosition(stage.width - posZoomFromRight - 10f, 10f, Align.bottomRight)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCurrentTutorialTask(): String {
|
private fun getCurrentTutorialTask(): String {
|
||||||
|
30
core/src/com/unciv/ui/worldscreen/ZoomButtonPair.kt
Normal file
30
core/src/com/unciv/ui/worldscreen/ZoomButtonPair.kt
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package com.unciv.ui.worldscreen
|
||||||
|
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Cell
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||||
|
import com.badlogic.gdx.utils.Align
|
||||||
|
import com.unciv.ui.utils.BaseScreen
|
||||||
|
import com.unciv.ui.utils.ZoomableScrollPane
|
||||||
|
import com.unciv.ui.utils.onClick
|
||||||
|
import com.unciv.ui.utils.setFontSize
|
||||||
|
|
||||||
|
class ZoomButtonPair(private val mapHolder: ZoomableScrollPane) : Table(BaseScreen.skin) {
|
||||||
|
init {
|
||||||
|
addButton("+") {
|
||||||
|
mapHolder.zoomIn()
|
||||||
|
}.padRight(10f)
|
||||||
|
addButton("–") { // figure dash U+2013, not minus, looks better
|
||||||
|
mapHolder.zoomOut()
|
||||||
|
}
|
||||||
|
pack()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addButton(text: String, action: () -> Unit): Cell<TextButton> {
|
||||||
|
val button = TextButton(text, skin)
|
||||||
|
button.label.setFontSize(30)
|
||||||
|
button.label.setAlignment(Align.center)
|
||||||
|
button.onClick(action)
|
||||||
|
return add(button)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user