mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-31 15:19:29 +07:00
Nicer menu table
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package com.unciv.ui.worldscreen.optionstable
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Cell
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
@ -39,6 +40,14 @@ open class PopupTable(val screen: CameraStageBaseScreen): Table(CameraStageBaseS
|
||||
return add(button).apply { row() }
|
||||
}
|
||||
|
||||
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() }
|
||||
}
|
||||
|
||||
fun addCloseButton() = addButton("Close"){close()}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import com.unciv.ui.mapeditor.MapEditorScreen
|
||||
import com.unciv.ui.newgamescreen.NewGameScreen
|
||||
import com.unciv.ui.saves.LoadGameScreen
|
||||
import com.unciv.ui.saves.SaveGameScreen
|
||||
import com.unciv.ui.utils.addSeparator
|
||||
import com.unciv.ui.utils.disable
|
||||
import com.unciv.ui.utils.setFontColor
|
||||
import com.unciv.ui.utils.toLabel
|
||||
@ -21,7 +22,9 @@ import kotlin.collections.ArrayList
|
||||
class WorldScreenMenuTable(val worldScreen: WorldScreen) : PopupTable(worldScreen) {
|
||||
|
||||
init {
|
||||
addButton("Map editor".tr()){
|
||||
val width = 200f
|
||||
val height = 30f
|
||||
addSquareButton("Map editor".tr()){
|
||||
val tileMapClone = worldScreen.gameInfo.tileMap.clone()
|
||||
for(tile in tileMapClone.values){
|
||||
tile.militaryUnit=null
|
||||
@ -34,46 +37,58 @@ class WorldScreenMenuTable(val worldScreen: WorldScreen) : PopupTable(worldScree
|
||||
}
|
||||
UnCivGame.Current.screen = MapEditorScreen(tileMapClone)
|
||||
remove()
|
||||
}
|
||||
}.size(width,height)
|
||||
addSeparator()
|
||||
|
||||
addButton("Civilopedia".tr()){
|
||||
addSquareButton("Civilopedia".tr()){
|
||||
UnCivGame.Current.screen = CivilopediaScreen()
|
||||
remove()
|
||||
}
|
||||
}.size(width,height)
|
||||
addSeparator()
|
||||
|
||||
addButton("Load game".tr()){
|
||||
addSquareButton("Load game".tr()){
|
||||
UnCivGame.Current.screen = LoadGameScreen()
|
||||
remove()
|
||||
}
|
||||
}.size(width,height)
|
||||
addSeparator()
|
||||
|
||||
addButton("Save game".tr()) {
|
||||
addSquareButton("Save game".tr()) {
|
||||
UnCivGame.Current.screen = SaveGameScreen()
|
||||
remove()
|
||||
}
|
||||
}.size(width,height)
|
||||
addSeparator()
|
||||
|
||||
addButton("Start new game".tr()){ UnCivGame.Current.screen = NewGameScreen() }
|
||||
addSquareButton("Start new game".tr()){ UnCivGame.Current.screen = NewGameScreen() }.size(width,height)
|
||||
addSeparator()
|
||||
|
||||
|
||||
addButton("Multiplayer".tr()) { openMultiplayerPopup() }
|
||||
addSquareButton("Multiplayer".tr()) { openMultiplayerPopup() }.size(width,height)
|
||||
addSeparator()
|
||||
|
||||
addButton("Victory status".tr()) { UnCivGame.Current.screen = VictoryScreen() }
|
||||
addSquareButton("Victory status".tr()) { UnCivGame.Current.screen = VictoryScreen() }.size(width,height)
|
||||
addSeparator()
|
||||
|
||||
addButton("Options".tr()){
|
||||
addSquareButton("Options".tr()){
|
||||
UnCivGame.Current.worldScreen.stage.addActor(WorldScreenOptionsTable(worldScreen))
|
||||
remove()
|
||||
}
|
||||
}.size(width,height)
|
||||
addSeparator()
|
||||
|
||||
addButton("Community"){
|
||||
addSquareButton("Community"){
|
||||
WorldScreenCommunityTable(worldScreen)
|
||||
remove()
|
||||
}
|
||||
}.size(width,height)
|
||||
addSeparator()
|
||||
|
||||
addCloseButton()
|
||||
addSquareButton("Close"){
|
||||
close()
|
||||
}.size(width,height)
|
||||
|
||||
open()
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun openMultiplayerPopup(){
|
||||
|
||||
close()
|
||||
|
Reference in New Issue
Block a user