Skip next unit button (#11244)

* Added a next turn menu to skip all the next unit actions

* Added a move automated units button

* Added whitespace

* Added unique NextTurnMenu KeyboardBindings
This commit is contained in:
Oskar Niesen 2024-03-05 15:06:13 -06:00 committed by GitHub
parent b5a39bbb39
commit 28e0e7ee2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 38 additions and 0 deletions

View File

@ -142,6 +142,10 @@ enum class KeyboardBinding(
AutoPlayMenuCivilians(Category.AutoPlayMenu, "AutoPlay Civilians Once", 'c'),
AutoPlayMenuEconomy(Category.AutoPlayMenu, "AutoPlay Economy Once", 'e'),
// NextTurnMenu
NextTurnMenuNextTurn(Category.NextTurnMenu, "Next Turn", 'n'),
NextTurnMenuMoveAutomatedUnits(Category.NextTurnMenu, "Move Automated Units", 'm'),
// City Screen
AddConstruction(Category.CityScreen, "Add to or remove from queue", KeyCharAndCode.RETURN),
RaisePriority(Category.CityScreen, "Raise queue priority", Input.Keys.UP),
@ -217,6 +221,9 @@ enum class KeyboardBinding(
AutoPlayMenu {
override val label = "AutoPlay menu" // adapt to existing usage
},
NextTurnMenu {
override val label = "NextTurn menu" // adapt to existing usage
},
MapPanning {
override fun checkConflictsIn() = sequenceOf(this, WorldScreen)
},

View File

@ -9,6 +9,7 @@ import com.unciv.ui.components.extensions.setSize
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.images.IconTextButton
import com.unciv.ui.images.ImageGetter
import com.unciv.ui.popups.hasOpenPopups
@ -22,6 +23,7 @@ class NextTurnButton(
// label.setFontSize(30)
labelCell.pad(10f)
onActivation { nextTurnAction.action(worldScreen) }
onRightClick { NextTurnMenu(stage, this, this, worldScreen) }
keyShortcuts.add(KeyboardBinding.NextTurn)
keyShortcuts.add(KeyboardBinding.NextTurnAlternate)
// Let unit actions override this for command "Wait".

View File

@ -0,0 +1,29 @@
package com.unciv.ui.screens.worldscreen.status
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.Stage
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.unciv.ui.components.input.KeyboardBinding
import com.unciv.ui.popups.AnimatedMenuPopup
import com.unciv.ui.screens.worldscreen.WorldScreen
class NextTurnMenu(
stage: Stage,
positionNextTo: Actor,
private val nextTurnButton: NextTurnButton,
private val worldScreen: WorldScreen
) : AnimatedMenuPopup(stage, getActorTopRight(positionNextTo)) {
override fun createContentTable(): Table {
val table = super.createContentTable()!!
table.add(getButton("Next Turn", KeyboardBinding.NextTurnMenuNextTurn) {
worldScreen.nextTurn()
}).row()
val automateUnitsAction = NextTurnAction.MoveAutomatedUnits
if (automateUnitsAction.isChoice(worldScreen))
table.add(getButton("Move automated units", KeyboardBinding.NextTurnMenuMoveAutomatedUnits) {
automateUnitsAction.action(worldScreen)
}).row()
return table
}
}