mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 06:51:30 -04:00
Autoplay menu cleanup (#11115)
* Minor linting and fix folder-package mismatch * Actually make AnimatedMenuPopup stay inside the stage in all directions (was done for bottom left only before) * Proper keyboard bindings for AutoPlay and -menu * Testing translations * AutoPlay as widely used term
This commit is contained in:
parent
9f53b7e1ee
commit
eb8fee8edd
@ -2568,6 +2568,7 @@ You returned captured units to us = Vous nous avez rendu des unités capturées
|
|||||||
|
|
||||||
Main Menu = Menu principal
|
Main Menu = Menu principal
|
||||||
World Screen = Écran de jeu
|
World Screen = Écran de jeu
|
||||||
|
AutoPlay menu = Menu Jeu Auto
|
||||||
Map Panning = Défilement de la carte
|
Map Panning = Défilement de la carte
|
||||||
Unit Actions = Actions des unités
|
Unit Actions = Actions des unités
|
||||||
City Screen = Écran de la ville
|
City Screen = Écran de la ville
|
||||||
@ -2576,6 +2577,7 @@ Popups = Fenêtres
|
|||||||
Menu = Menu
|
Menu = Menu
|
||||||
Next Turn = Tour suivant
|
Next Turn = Tour suivant
|
||||||
Next Turn Alternate = Tour suivant (alt.)
|
Next Turn Alternate = Tour suivant (alt.)
|
||||||
|
Open AutoPlay menu = Ouvrir le menu Jeu Auto
|
||||||
Empire Overview = Vue d'ensemble
|
Empire Overview = Vue d'ensemble
|
||||||
Music Player = Lecteur de musique
|
Music Player = Lecteur de musique
|
||||||
Developer Console = Console Développeur
|
Developer Console = Console Développeur
|
||||||
@ -6750,4 +6752,3 @@ Reveal known resources on world screen = Révéler les ressources connues sur l'
|
|||||||
In the Resources overview, click on a resource icon to center the world screen on tiles already discovered and providing this resource. = Dans la Vue d'ensemble des Ressources, cliquez sur une icône de ressource pour centrer la carte sur les cases déjà découvertes et fournissant cette ressource.
|
In the Resources overview, click on a resource icon to center the world screen on tiles already discovered and providing this resource. = Dans la Vue d'ensemble des Ressources, cliquez sur une icône de ressource pour centrer la carte sur les cases déjà découvertes et fournissant cette ressource.
|
||||||
Alternatively, click on the "Unimproved" number to center the world screen only on owned tiles where the resource is not improved. = Il est également possible de cliquer sur la valeur "Non-Aménagées" pour centrer la carte uniquement sur les cases de votre empire où la ressource n'est pas aménagée.
|
Alternatively, click on the "Unimproved" number to center the world screen only on owned tiles where the resource is not improved. = Il est également possible de cliquer sur la valeur "Non-Aménagées" pour centrer la carte uniquement sur les cases de votre empire où la ressource n'est pas aménagée.
|
||||||
If more than one tile is available, click repeatedly on the notification to cycle through all of them. = Si plus d'une case est disponible, cliquez plusieurs fois sur la notification afin de les parcourir en boucle.
|
If more than one tile is available, click repeatedly on the notification to cycle through all of them. = Si plus d'une case est disponible, cliquez plusieurs fois sur la notification afin de les parcourir en boucle.
|
||||||
|
|
||||||
|
@ -39,6 +39,8 @@ enum class KeyboardBinding(
|
|||||||
Menu(Category.WorldScreen, KeyCharAndCode.TAB),
|
Menu(Category.WorldScreen, KeyCharAndCode.TAB),
|
||||||
NextTurn(Category.WorldScreen),
|
NextTurn(Category.WorldScreen),
|
||||||
NextTurnAlternate(Category.WorldScreen, KeyCharAndCode.SPACE),
|
NextTurnAlternate(Category.WorldScreen, KeyCharAndCode.SPACE),
|
||||||
|
AutoPlayMenu(Category.WorldScreen, "Open AutoPlay menu", KeyCharAndCode.UNKNOWN), // 'a' is already assigned to map panning
|
||||||
|
AutoPlay(Category.WorldScreen, "Start AutoPlay", KeyCharAndCode.ctrl('a')),
|
||||||
EmpireOverview(Category.WorldScreen),
|
EmpireOverview(Category.WorldScreen),
|
||||||
MusicPlayer(Category.WorldScreen, KeyCharAndCode.ctrl('m')),
|
MusicPlayer(Category.WorldScreen, KeyCharAndCode.ctrl('m')),
|
||||||
DeveloperConsole(Category.WorldScreen, '`'),
|
DeveloperConsole(Category.WorldScreen, '`'),
|
||||||
@ -134,6 +136,12 @@ enum class KeyboardBinding(
|
|||||||
HideAdditionalActions(Category.UnitActions,"Back", Input.Keys.PAGE_UP),
|
HideAdditionalActions(Category.UnitActions,"Back", Input.Keys.PAGE_UP),
|
||||||
AddInCapital(Category.UnitActions, "Add in capital", 'g'),
|
AddInCapital(Category.UnitActions, "Add in capital", 'g'),
|
||||||
|
|
||||||
|
// The AutoPlayMenu reuses the AutoPlay binding, under Worldscreen above - otherwise clear labeling would be tricky
|
||||||
|
AutoPlayMenuEndTurn(Category.AutoPlayMenu, "AutoPlay End Turn", 't'),
|
||||||
|
AutoPlayMenuMilitary(Category.AutoPlayMenu, "AutoPlay Military Once", 'm'),
|
||||||
|
AutoPlayMenuCivilians(Category.AutoPlayMenu, "AutoPlay Civilians Once", 'c'),
|
||||||
|
AutoPlayMenuEconomy(Category.AutoPlayMenu, "AutoPlay Economy Once", 'e'),
|
||||||
|
|
||||||
// City Screen
|
// City Screen
|
||||||
AddConstruction(Category.CityScreen, "Add to or remove from queue", KeyCharAndCode.RETURN),
|
AddConstruction(Category.CityScreen, "Add to or remove from queue", KeyCharAndCode.RETURN),
|
||||||
RaisePriority(Category.CityScreen, "Raise queue priority", Input.Keys.UP),
|
RaisePriority(Category.CityScreen, "Raise queue priority", Input.Keys.UP),
|
||||||
@ -206,6 +214,9 @@ enum class KeyboardBinding(
|
|||||||
// Conflict checking within group plus keys assigned to UnitActions are a problem
|
// Conflict checking within group plus keys assigned to UnitActions are a problem
|
||||||
override fun checkConflictsIn() = sequenceOf(this, MapPanning, UnitActions)
|
override fun checkConflictsIn() = sequenceOf(this, MapPanning, UnitActions)
|
||||||
},
|
},
|
||||||
|
AutoPlayMenu {
|
||||||
|
override val label = "AutoPlay menu" // adapt to existing usage
|
||||||
|
},
|
||||||
MapPanning {
|
MapPanning {
|
||||||
override fun checkConflictsIn() = sequenceOf(this, WorldScreen)
|
override fun checkConflictsIn() = sequenceOf(this, WorldScreen)
|
||||||
},
|
},
|
||||||
@ -218,7 +229,7 @@ enum class KeyboardBinding(
|
|||||||
Civilopedia,
|
Civilopedia,
|
||||||
Popups
|
Popups
|
||||||
;
|
;
|
||||||
val label = unCamelCase(name)
|
open val label = unCamelCase(name)
|
||||||
open fun checkConflictsIn() = sequenceOf(this)
|
open fun checkConflictsIn() = sequenceOf(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,11 +98,17 @@ open class AnimatedMenuPopup(
|
|||||||
container.setScale(0.05f)
|
container.setScale(0.05f)
|
||||||
container.color.a = 0f
|
container.color.a = 0f
|
||||||
|
|
||||||
open(true) // this only does the screen-covering "click-behind" portion
|
open(true) // this only does the screen-covering "click-behind" portion - and ensures this.stage is set
|
||||||
|
|
||||||
|
// Note that coerceIn throws if min>max, so we defend against newInnerTable being bigger than the stage,
|
||||||
|
// and padding helps the rounded edges to look more natural:
|
||||||
|
val paddedHalfWidth = newInnerTable.width / 2 + 2f
|
||||||
|
val paddedHalfHeight = newInnerTable.height / 2 + 2f
|
||||||
container.setPosition(
|
container.setPosition(
|
||||||
position.x.coerceAtMost(stage.width - newInnerTable.width / 2),
|
if (paddedHalfWidth * 2 > stage.width) stage.width / 2
|
||||||
position.y.coerceAtLeast(newInnerTable.height / 2)
|
else position.x.coerceIn(paddedHalfWidth, stage.width - paddedHalfWidth),
|
||||||
|
if (paddedHalfHeight * 2 > stage.height) stage.height / 2
|
||||||
|
else position.y.coerceIn(paddedHalfHeight, stage.height - paddedHalfHeight)
|
||||||
)
|
)
|
||||||
super.addActor(container)
|
super.addActor(container)
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.unciv.ui.popups
|
package com.unciv.ui.screens.worldscreen.status
|
||||||
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||||
import com.badlogic.gdx.scenes.scene2d.Stage
|
import com.badlogic.gdx.scenes.scene2d.Stage
|
||||||
@ -8,14 +8,11 @@ import com.unciv.logic.automation.civilization.NextTurnAutomation
|
|||||||
import com.unciv.logic.automation.unit.UnitAutomation
|
import com.unciv.logic.automation.unit.UnitAutomation
|
||||||
import com.unciv.logic.civilization.managers.TurnManager
|
import com.unciv.logic.civilization.managers.TurnManager
|
||||||
import com.unciv.ui.components.input.KeyboardBinding
|
import com.unciv.ui.components.input.KeyboardBinding
|
||||||
|
import com.unciv.ui.popups.AnimatedMenuPopup
|
||||||
import com.unciv.ui.screens.worldscreen.WorldScreen
|
import com.unciv.ui.screens.worldscreen.WorldScreen
|
||||||
import com.unciv.ui.screens.worldscreen.status.NextTurnButton
|
|
||||||
|
|
||||||
//todo Check move/top/end for "place one improvement" buildings
|
|
||||||
//todo Check add/remove-all for "place one improvement" buildings
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a number of options
|
* The "context" menu for the AutoPlay button
|
||||||
*/
|
*/
|
||||||
class AutoPlayMenu(
|
class AutoPlayMenu(
|
||||||
stage: Stage,
|
stage: Stage,
|
||||||
@ -25,21 +22,17 @@ class AutoPlayMenu(
|
|||||||
) : AnimatedMenuPopup(stage, getActorTopRight(positionNextTo)) {
|
) : AnimatedMenuPopup(stage, getActorTopRight(positionNextTo)) {
|
||||||
private val settings = GUI.getSettings()
|
private val settings = GUI.getSettings()
|
||||||
|
|
||||||
init {
|
override fun createContentTable(): Table {
|
||||||
closeListeners.add {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun createContentTable(): Table? {
|
|
||||||
val table = super.createContentTable()!!
|
val table = super.createContentTable()!!
|
||||||
|
// Using the same keyboard binding for bypassing this menu and the default option
|
||||||
if (!worldScreen.gameInfo.gameParameters.isOnlineMultiplayer)
|
if (!worldScreen.gameInfo.gameParameters.isOnlineMultiplayer)
|
||||||
table.add(getButton("Start AutoPlay", KeyboardBinding.RaisePriority, ::autoPlay)).row()
|
table.add(getButton("Start AutoPlay", KeyboardBinding.AutoPlay, ::autoPlay)).row()
|
||||||
table.add(getButton("AutoPlay End Turn", KeyboardBinding.RaisePriority, ::autoPlayEndTurn)).row()
|
table.add(getButton("AutoPlay End Turn", KeyboardBinding.AutoPlayMenuEndTurn, ::autoPlayEndTurn)).row()
|
||||||
table.add(getButton("AutoPlay Military Once", KeyboardBinding.RaisePriority, ::autoPlayMilitary)).row()
|
table.add(getButton("AutoPlay Military Once", KeyboardBinding.AutoPlayMenuMilitary, ::autoPlayMilitary)).row()
|
||||||
table.add(getButton("AutoPlay Civilians Once", KeyboardBinding.RaisePriority, ::autoPlayCivilian)).row()
|
table.add(getButton("AutoPlay Civilians Once", KeyboardBinding.AutoPlayMenuCivilians, ::autoPlayCivilian)).row()
|
||||||
table.add(getButton("AutoPlay Economy Once", KeyboardBinding.RaisePriority, ::autoPlayEconomy)).row()
|
table.add(getButton("AutoPlay Economy Once", KeyboardBinding.AutoPlayMenuEconomy, ::autoPlayEconomy)).row()
|
||||||
|
|
||||||
return table.takeUnless { it.cells.isEmpty }
|
return table
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun autoPlayEndTurn() {
|
private fun autoPlayEndTurn() {
|
||||||
|
@ -6,10 +6,11 @@ import com.badlogic.gdx.scenes.scene2d.ui.Stack
|
|||||||
import com.badlogic.gdx.utils.Disposable
|
import com.badlogic.gdx.utils.Disposable
|
||||||
import com.unciv.GUI
|
import com.unciv.GUI
|
||||||
import com.unciv.ui.components.extensions.setSize
|
import com.unciv.ui.components.extensions.setSize
|
||||||
import com.unciv.ui.components.input.onClick
|
import com.unciv.ui.components.input.KeyboardBinding
|
||||||
|
import com.unciv.ui.components.input.keyShortcuts
|
||||||
|
import com.unciv.ui.components.input.onActivation
|
||||||
import com.unciv.ui.components.input.onRightClick
|
import com.unciv.ui.components.input.onRightClick
|
||||||
import com.unciv.ui.images.ImageGetter
|
import com.unciv.ui.images.ImageGetter
|
||||||
import com.unciv.ui.popups.AutoPlayMenu
|
|
||||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||||
import com.unciv.ui.screens.worldscreen.WorldScreen
|
import com.unciv.ui.screens.worldscreen.WorldScreen
|
||||||
|
|
||||||
@ -23,19 +24,21 @@ class AutoPlayStatusButton(
|
|||||||
init {
|
init {
|
||||||
add(Stack(autoPlayImage)).pad(5f)
|
add(Stack(autoPlayImage)).pad(5f)
|
||||||
val settings = GUI.getSettings()
|
val settings = GUI.getSettings()
|
||||||
onClick {
|
onActivation(binding = KeyboardBinding.AutoPlayMenu) {
|
||||||
if (settings.autoPlay.isAutoPlaying())
|
if (settings.autoPlay.isAutoPlaying())
|
||||||
settings.autoPlay.stopAutoPlay()
|
settings.autoPlay.stopAutoPlay()
|
||||||
else if (worldScreen.viewingCiv == worldScreen.gameInfo.currentPlayerCiv)
|
else if (worldScreen.viewingCiv == worldScreen.gameInfo.currentPlayerCiv)
|
||||||
AutoPlayMenu(stage,this, nextTurnButton, worldScreen)
|
AutoPlayMenu(stage,this, nextTurnButton, worldScreen)
|
||||||
}
|
}
|
||||||
onRightClick {
|
val directAutoPlay = {
|
||||||
if (!worldScreen.gameInfo.gameParameters.isOnlineMultiplayer
|
if (!worldScreen.gameInfo.gameParameters.isOnlineMultiplayer
|
||||||
&& worldScreen.viewingCiv == worldScreen.gameInfo.currentPlayerCiv) {
|
&& worldScreen.viewingCiv == worldScreen.gameInfo.currentPlayerCiv) {
|
||||||
settings.autoPlay.startAutoPlay()
|
settings.autoPlay.startAutoPlay()
|
||||||
nextTurnButton.update()
|
nextTurnButton.update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onRightClick(action = directAutoPlay)
|
||||||
|
keyShortcuts.add(KeyboardBinding.AutoPlay, action = directAutoPlay)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createAutoplayImage(): Image {
|
private fun createAutoplayImage(): Image {
|
||||||
@ -51,4 +54,3 @@ class AutoPlayStatusButton(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user