mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 06:50:08 -04:00
Unified Menu Popups (#4113)
This commit is contained in:
parent
0d79326869
commit
ea852f9fa0
@ -86,8 +86,8 @@ class MainMenuScreen: CameraStageBaseScreen() {
|
||||
}
|
||||
}
|
||||
|
||||
val column1 = Table().apply { defaults().pad(10f) }
|
||||
val column2 = if(singleColumn) column1 else Table().apply { defaults().pad(10f) }
|
||||
val column1 = Table().apply { defaults().pad(10f).fillX() }
|
||||
val column2 = if(singleColumn) column1 else Table().apply { defaults().pad(10f).fillX() }
|
||||
|
||||
val autosaveGame = GameSaver.getSave(autosave, false)
|
||||
if (autosaveGame.exists()) {
|
||||
|
@ -11,6 +11,7 @@ import com.unciv.ui.utils.*
|
||||
class MapEditorMenuPopup(var mapEditorScreen: MapEditorScreen): Popup(mapEditorScreen) {
|
||||
|
||||
init {
|
||||
defaults().fillX()
|
||||
addButton("New map", 'n') { UncivGame.Current.setScreen(NewMapScreen(mapEditorScreen.tileMap.mapParameters)) }
|
||||
addButton("Save map", 's') { mapEditorScreen.game.setScreen(SaveAndLoadMapScreen(mapEditorScreen.tileMap, true, mapEditorScreen)); this.close() }
|
||||
addButton("Load map", 'l') { mapEditorScreen.game.setScreen(SaveAndLoadMapScreen(mapEditorScreen.tileMap, false, mapEditorScreen)); this.close() }
|
||||
|
@ -73,6 +73,7 @@ open class Popup(val screen: CameraStageBaseScreen): Table(CameraStageBaseScreen
|
||||
/* All additions to the popup are to the inner table - we shouldn't care that there's an inner table at all */
|
||||
final override fun <T : Actor?> add(actor: T): Cell<T> = innerTable.add(actor)
|
||||
override fun row(): Cell<Actor> = innerTable.row()
|
||||
override fun defaults(): Cell<Actor> = innerTable.defaults()
|
||||
fun addSeparator() = innerTable.addSeparator()
|
||||
|
||||
/**
|
||||
|
@ -19,50 +19,31 @@ import com.unciv.ui.victoryscreen.VictoryScreen
|
||||
import com.unciv.ui.worldscreen.WorldScreen
|
||||
|
||||
class WorldScreenMenuPopup(val worldScreen: WorldScreen) : Popup(worldScreen) {
|
||||
|
||||
val buttonWidth = 200f
|
||||
val buttonHeight = 30f
|
||||
|
||||
init {
|
||||
addMenuButton("Main menu") { worldScreen.game.setScreen(MainMenuScreen()) }
|
||||
addMenuButton("Civilopedia") { worldScreen.game.setScreen(CivilopediaScreen(worldScreen.gameInfo.ruleSet)) }
|
||||
addMenuButton("Save game") { worldScreen.game.setScreen(SaveGameScreen(worldScreen.gameInfo)) }
|
||||
addMenuButton("Load game") { worldScreen.game.setScreen(LoadGameScreen(worldScreen)) }
|
||||
defaults().fillX()
|
||||
addButton("Main menu") { worldScreen.game.setScreen(MainMenuScreen()) }
|
||||
addButton("Civilopedia") { worldScreen.game.setScreen(CivilopediaScreen(worldScreen.gameInfo.ruleSet)) }
|
||||
addButton("Save game") { worldScreen.game.setScreen(SaveGameScreen(worldScreen.gameInfo)) }
|
||||
addButton("Load game") { worldScreen.game.setScreen(LoadGameScreen(worldScreen)) }
|
||||
|
||||
addMenuButton("Start new game") {
|
||||
addButton("Start new game") {
|
||||
val newGameScreen = NewGameScreen(worldScreen, GameSetupInfo(worldScreen.gameInfo))
|
||||
worldScreen.game.setScreen(newGameScreen)
|
||||
}
|
||||
|
||||
addMenuButton("Victory status") { worldScreen.game.setScreen(VictoryScreen(worldScreen)) }
|
||||
addMenuButton("Options") { worldScreen.openOptionsPopup() }
|
||||
addMenuButton("Community") { WorldScreenCommunityPopup(worldScreen).open(force = true) }
|
||||
|
||||
addSquareButton(Constants.close) {
|
||||
addButton("Victory status") { worldScreen.game.setScreen(VictoryScreen(worldScreen)) }
|
||||
addButton("Options") { worldScreen.openOptionsPopup() }
|
||||
addButton("Community") {
|
||||
close()
|
||||
}.size(buttonWidth, buttonHeight)
|
||||
}
|
||||
|
||||
fun addMenuButton(text: String, action: () -> Unit) {
|
||||
addSquareButton(text) {
|
||||
action()
|
||||
close()
|
||||
}.size(buttonWidth, buttonHeight)
|
||||
innerTable.addSeparator()
|
||||
}
|
||||
|
||||
|
||||
fun addSquareButton(text: String, action: () -> Unit): Cell<Table> {
|
||||
val button = Table()
|
||||
button.add(text.toLabel())
|
||||
button.onClick(action)
|
||||
button.touchable = Touchable.enabled
|
||||
return add(button).apply { row() }
|
||||
WorldScreenCommunityPopup(worldScreen).open(force = true) }
|
||||
addCloseButton()
|
||||
pack()
|
||||
}
|
||||
}
|
||||
|
||||
class WorldScreenCommunityPopup(val worldScreen: WorldScreen) : Popup(worldScreen) {
|
||||
init {
|
||||
defaults().fillX()
|
||||
addButton("Discord") {
|
||||
Gdx.net.openURI("https://discord.gg/bjrB4Xw")
|
||||
close()
|
||||
|
Loading…
x
Reference in New Issue
Block a user