Map editor leaves to main menu

This commit is contained in:
Yair Morgenstern 2020-04-21 12:40:38 +03:00
parent 0ed283f5e3
commit 4c3b9e0c14
4 changed files with 22 additions and 24 deletions

View file

@ -68,11 +68,11 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
topTable.add(mainTable).row()
scrollPane.setScrollingDisabled(false, true)
//leftTable Setup
// leftTable Setup
reloadGameListUI()
//A Button to add the currently running game to multiplayerGameList if not yet done
addCurrentGameButton()
// A Button to add the currently running game to multiplayerGameList if not yet done
// addCurrentGameButton()
//rightTable Setup
copyUserIdButton.onClick {

View file

@ -5,6 +5,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton
import com.badlogic.gdx.scenes.scene2d.ui.TextField
import com.badlogic.gdx.utils.Json
import com.unciv.Constants
import com.unciv.MenuScreen
import com.unciv.UncivGame
import com.unciv.logic.MapSaver
import com.unciv.logic.map.MapType
@ -114,8 +115,8 @@ class MapEditorMenuPopup(mapEditorScreen: MapEditorScreen): Popup(mapEditorScree
val exitMapEditorButton = "Exit map editor".toTextButton()
exitMapEditorButton.onClick { UncivGame.Current.setWorldScreen(); mapEditorScreen.dispose() }
add(exitMapEditorButton ).row()
exitMapEditorButton.onClick { mapEditorScreen.game.setScreen(MenuScreen()); mapEditorScreen.dispose() }
val closeOptionsButton = Constants.close.toTextButton()
closeOptionsButton.onClick { close() }

View file

@ -5,12 +5,10 @@ import com.badlogic.gdx.math.Vector2
import com.badlogic.gdx.scenes.scene2d.InputEvent
import com.badlogic.gdx.scenes.scene2d.InputListener
import com.badlogic.gdx.scenes.scene2d.actions.Actions
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
import com.unciv.logic.MapSaver
import com.unciv.logic.map.TileInfo
import com.unciv.logic.map.TileMap
import com.unciv.models.ruleset.RulesetCache
import com.unciv.models.translations.tr
import com.unciv.ui.utils.*
class MapEditorScreen(): CameraStageBaseScreen() {
@ -146,3 +144,4 @@ class MapEditorScreen(): CameraStageBaseScreen() {
}
}

View file

@ -1,6 +1,5 @@
package com.unciv.ui.mapeditor
import com.unciv.ui.utils.AutoScrollPane as ScrollPane
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.Group
@ -19,7 +18,6 @@ import com.unciv.ui.tilegroups.TileGroup
import com.unciv.ui.tilegroups.TileSetStrings
import com.unciv.ui.utils.*
class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(CameraStageBaseScreen.skin){
private val tileSetLocation = "TileSets/"+ UncivGame.Current.settings.tileSet +"/"
@ -30,7 +28,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
var selectedResource: TileResource?=null
var clearImprovement=false
var selectedImprovement:TileImprovement?=null
var selectedImprovement: TileImprovement?=null
var toggleBottomRightRiver=false
var toggleBottomRiver=false
@ -63,7 +61,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
val sliderTab = Table()
val slider = Slider(1f,5f,1f, false, skin)
val slider = Slider(1f, 5f, 1f, false, skin)
val sliderLabel = "{Brush Size} $brushSize".toLabel()
slider.onChange {
@ -76,7 +74,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
sliderTab.add(slider)
add(sliderTab).row()
add(ScrollPane(tabPickerTable).apply { this.width= mapEditorScreen.stage.width/3}).row()
add(AutoScrollPane(tabPickerTable).apply { this.width= mapEditorScreen.stage.width/3}).row()
add(editorPickTable).row()
}
@ -96,30 +94,30 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
for(improvement in ruleset.tileImprovements.values){
if(improvement.name.startsWith("Remove")) continue
val improvementImage = getHex(Color.WHITE,ImageGetter.getImprovementIcon(improvement.name,40f))
val improvementImage = getHex(Color.WHITE, ImageGetter.getImprovementIcon(improvement.name, 40f))
improvementImage.onClick {
clearSelection()
selectedImprovement=improvement
val improvementIcon = getHex(Color.WHITE,ImageGetter.getImprovementIcon(improvement.name,40f))
val improvementIcon = getHex(Color.WHITE, ImageGetter.getImprovementIcon(improvement.name, 40f))
setCurrentHex(improvementIcon, improvement.name.tr()+"\n"+improvement.clone().toString())
}
improvementsTable.add(improvementImage).row()
}
editorPickTable.add(ScrollPane(improvementsTable)).height(scrollPanelHeight)
editorPickTable.add(AutoScrollPane(improvementsTable)).height(scrollPanelHeight)
val nationsTable = Table()
for(nation in ruleset.nations.values){
val nationImage = getHex(Color.WHITE,ImageGetter.getNationIndicator(nation,40f))
val nationImage = getHex(Color.WHITE, ImageGetter.getNationIndicator(nation, 40f))
nationImage.onClick {
clearSelection()
selectedImprovement=TileImprovement().apply { name="StartingLocation "+nation.name }
val nationIcon = getHex(Color.WHITE,ImageGetter.getNationIndicator(nation,40f))
selectedImprovement= TileImprovement().apply { name="StartingLocation "+nation.name }
val nationIcon = getHex(Color.WHITE, ImageGetter.getNationIndicator(nation, 40f))
setCurrentHex(nationIcon, "[${nation.name}] starting location")
}
nationsTable.add(nationImage).row()
}
editorPickTable.add(ScrollPane(nationsTable)).height(scrollPanelHeight)
editorPickTable.add(AutoScrollPane(nationsTable)).height(scrollPanelHeight)
}
private fun getRedCross(size: Float, alpha: Float): Actor {
@ -152,14 +150,14 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
background = ImageGetter.getBackground(Color.GRAY.cpy().apply { a = 0.7f })
val terrainsAndResourcesTable = Table()
terrainsAndResourcesTable.add(ScrollPane(baseTerrainTable).apply { setScrollingDisabled(true,false) }).height(scrollPanelHeight)
terrainsAndResourcesTable.add(AutoScrollPane(baseTerrainTable).apply { setScrollingDisabled(true,false) }).height(scrollPanelHeight)
terrainsAndResourcesTable.add(ScrollPane(terrainFeaturesTable).apply { setScrollingDisabled(true,false) }).height(scrollPanelHeight)
terrainsAndResourcesTable.add(AutoScrollPane(terrainFeaturesTable).apply { setScrollingDisabled(true,false) }).height(scrollPanelHeight)
val resourcesTable = Table()
for(resource in resources) resourcesTable.add(resource).row()
resourcesTable.pack()
terrainsAndResourcesTable.add(ScrollPane(resourcesTable).apply { setScrollingDisabled(true,false) }).height(scrollPanelHeight).row()
terrainsAndResourcesTable.add(AutoScrollPane(resourcesTable).apply { setScrollingDisabled(true,false) }).height(scrollPanelHeight).row()
terrainsAndResourcesTable.pack()
@ -403,12 +401,12 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
}
}
if(tileInfo.getBaseTerrain().impassable || tileInfo.isWater)
tileInfo.roadStatus=RoadStatus.None
tileInfo.roadStatus= RoadStatus.None
}
private fun setCurrentHex(tileInfo: TileInfo, text:String){
val tileGroup = TileGroup(tileInfo,TileSetStrings())
val tileGroup = TileGroup(tileInfo, TileSetStrings())
.apply {
showEntireMap=true
forMapEditorIcon=true
@ -418,7 +416,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
setCurrentHex(tileGroup,text)
}
private fun setCurrentHex(actor:Actor, text:String){
private fun setCurrentHex(actor: Actor, text:String){
currentHex.remove()
val currentHexTable = Table()
currentHexTable.add(text.toLabel()).padRight(30f)