mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 15:01:09 -04:00
Revert "Revert "Revert "Redraw TechPickerScreen and PickerScreen, Make map symmetrical if it's not wrapped (#3757)"" (#3991)"
This reverts commit 298693ab03eba3ea5fc4d7d88fa15c97d140c432.
This commit is contained in:
parent
298693ab03
commit
f71ac0deab
@ -34,7 +34,7 @@ class LanguageTable(val language:String, val percentComplete: Int):Table(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LanguagePickerScreen : PickerScreen() {
|
class LanguagePickerScreen : PickerScreen(){
|
||||||
var chosenLanguage = "English"
|
var chosenLanguage = "English"
|
||||||
|
|
||||||
private val languageTables = ArrayList<LanguageTable>()
|
private val languageTables = ArrayList<LanguageTable>()
|
||||||
|
@ -120,11 +120,9 @@ class TileGroupMap<T: TileGroup>(tileGroups: Collection<T>, private val leftAndR
|
|||||||
|
|
||||||
// there are tiles "below the zero",
|
// there are tiles "below the zero",
|
||||||
// so we zero out the starting position of the whole board so they will be displayed as well
|
// so we zero out the starting position of the whole board so they will be displayed as well
|
||||||
// Map's width is reduced by groupSize if it is wrapped, because wrapped map will miss a tile on the right.
|
// The width has to be lowered by groupSize because wrapped maps are missing a tile on the right.
|
||||||
// This ensures that wrapped maps have a smooth transition.
|
// This ensures that wrapped maps have a smooth transition.
|
||||||
// If map is not wrapped, Map's width doesn't need to be reduce by groupSize
|
setSize(topX - bottomX + leftAndRightPadding * 2 - groupSize, topY - bottomY + topAndBottomPadding * 2)
|
||||||
if (worldWrap) setSize(topX - bottomX + leftAndRightPadding * 2 - groupSize, topY - bottomY + topAndBottomPadding * 2)
|
|
||||||
else setSize(topX - bottomX + leftAndRightPadding * 2, topY - bottomY + topAndBottomPadding * 2)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +16,7 @@ import com.unciv.ui.utils.*
|
|||||||
* updates [mapEditorScreen] and switches to it.
|
* updates [mapEditorScreen] and switches to it.
|
||||||
* @param [mapEditorScreen] previous screen from map editor.
|
* @param [mapEditorScreen] previous screen from map editor.
|
||||||
*/
|
*/
|
||||||
class GameParametersScreen(var mapEditorScreen: MapEditorScreen): IPreviousScreen, PickerScreen() {
|
class GameParametersScreen(var mapEditorScreen: MapEditorScreen): IPreviousScreen, PickerScreen(disableScroll = true) {
|
||||||
override var gameSetupInfo = mapEditorScreen.gameSetupInfo.clone()
|
override var gameSetupInfo = mapEditorScreen.gameSetupInfo.clone()
|
||||||
override var ruleset = RulesetCache.getComplexRuleset(gameSetupInfo.gameParameters.mods)
|
override var ruleset = RulesetCache.getComplexRuleset(gameSetupInfo.gameParameters.mods)
|
||||||
var playerPickerTable = PlayerPickerTable(this, gameSetupInfo.gameParameters)
|
var playerPickerTable = PlayerPickerTable(this, gameSetupInfo.gameParameters)
|
||||||
|
@ -18,7 +18,7 @@ import kotlin.concurrent.thread
|
|||||||
import com.unciv.ui.utils.AutoScrollPane as ScrollPane
|
import com.unciv.ui.utils.AutoScrollPane as ScrollPane
|
||||||
|
|
||||||
class SaveAndLoadMapScreen(mapToSave: TileMap?, save:Boolean = false, previousScreen: CameraStageBaseScreen)
|
class SaveAndLoadMapScreen(mapToSave: TileMap?, save:Boolean = false, previousScreen: CameraStageBaseScreen)
|
||||||
: PickerScreen() {
|
: PickerScreen(disableScroll = true) {
|
||||||
private var chosenMap: FileHandle? = null
|
private var chosenMap: FileHandle? = null
|
||||||
val deleteButton = "Delete map".toTextButton()
|
val deleteButton = "Delete map".toTextButton()
|
||||||
val mapsTable = Table().apply { defaults().pad(10f) }
|
val mapsTable = Table().apply { defaults().pad(10f) }
|
||||||
|
@ -13,7 +13,7 @@ import com.unciv.ui.utils.onClick
|
|||||||
import com.unciv.ui.utils.toLabel
|
import com.unciv.ui.utils.toLabel
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class AddMultiplayerGameScreen(backScreen: MultiplayerScreen) : PickerScreen() {
|
class AddMultiplayerGameScreen(backScreen: MultiplayerScreen) : PickerScreen(){
|
||||||
init {
|
init {
|
||||||
val gameNameTextField = TextField("", skin)
|
val gameNameTextField = TextField("", skin)
|
||||||
val gameIDTextField = TextField("", skin)
|
val gameIDTextField = TextField("", skin)
|
||||||
|
@ -14,7 +14,7 @@ import kotlin.concurrent.thread
|
|||||||
|
|
||||||
/** Subscreen of MultiplayerScreen to edit and delete saves
|
/** Subscreen of MultiplayerScreen to edit and delete saves
|
||||||
* backScreen is used for getting back to the MultiplayerScreen so it doesn't have to be created over and over again */
|
* backScreen is used for getting back to the MultiplayerScreen so it doesn't have to be created over and over again */
|
||||||
class EditMultiplayerGameInfoScreen(game: GameInfo?, gameName: String, backScreen: MultiplayerScreen): PickerScreen() {
|
class EditMultiplayerGameInfoScreen(game: GameInfo?, gameName: String, backScreen: MultiplayerScreen): PickerScreen(){
|
||||||
init {
|
init {
|
||||||
val textField = TextField(gameName, skin)
|
val textField = TextField(gameName, skin)
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class GameSetupInfo(var gameId:String, var gameParameters: GameParameters, var m
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NewGameScreen(private val previousScreen: CameraStageBaseScreen, _gameSetupInfo: GameSetupInfo?=null): IPreviousScreen, PickerScreen() {
|
class NewGameScreen(private val previousScreen: CameraStageBaseScreen, _gameSetupInfo: GameSetupInfo?=null): IPreviousScreen, PickerScreen(disableScroll = true) {
|
||||||
override val gameSetupInfo = _gameSetupInfo ?: GameSetupInfo()
|
override val gameSetupInfo = _gameSetupInfo ?: GameSetupInfo()
|
||||||
override var ruleset = RulesetCache.getComplexRuleset(gameSetupInfo.gameParameters.mods) // needs to be set because the GameOptionsTable etc. depend on this
|
override var ruleset = RulesetCache.getComplexRuleset(gameSetupInfo.gameParameters.mods) // needs to be set because the GameOptionsTable etc. depend on this
|
||||||
var newGameOptionsTable = GameOptionsTable(this) { desiredCiv: String -> playerPickerTable.update(desiredCiv) }
|
var newGameOptionsTable = GameOptionsTable(this) { desiredCiv: String -> playerPickerTable.update(desiredCiv) }
|
||||||
|
@ -26,7 +26,7 @@ import kotlin.concurrent.thread
|
|||||||
*/
|
*/
|
||||||
// All picker screens auto-wrap the top table in a ScrollPane.
|
// All picker screens auto-wrap the top table in a ScrollPane.
|
||||||
// Since we want the different parts to scroll separately, we disable the default ScrollPane, which would scroll everything at once.
|
// Since we want the different parts to scroll separately, we disable the default ScrollPane, which would scroll everything at once.
|
||||||
class ModManagementScreen: PickerScreen() {
|
class ModManagementScreen: PickerScreen(disableScroll = true) {
|
||||||
|
|
||||||
private val modTable = Table().apply { defaults().pad(10f) }
|
private val modTable = Table().apply { defaults().pad(10f) }
|
||||||
private val scrollInstalledMods = ScrollPane(modTable)
|
private val scrollInstalledMods = ScrollPane(modTable)
|
||||||
|
@ -6,12 +6,13 @@ import com.unciv.UncivGame
|
|||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
import com.unciv.ui.utils.AutoScrollPane as ScrollPane
|
import com.unciv.ui.utils.AutoScrollPane as ScrollPane
|
||||||
|
|
||||||
open class PickerScreen : CameraStageBaseScreen() {
|
open class PickerScreen(val disableScroll: Boolean = false) : CameraStageBaseScreen() {
|
||||||
|
|
||||||
internal var closeButton: TextButton = Constants.close.toTextButton()
|
internal var closeButton: TextButton = Constants.close.toTextButton()
|
||||||
protected var descriptionLabel: Label
|
protected var descriptionLabel: Label
|
||||||
private var rightSideGroup = VerticalGroup()
|
protected var rightSideGroup = VerticalGroup()
|
||||||
protected var rightSideButton: TextButton
|
protected var rightSideButton: TextButton
|
||||||
|
private var screenSplit = 0.85f
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The table displaying the choices from which to pick (usually).
|
* The table displaying the choices from which to pick (usually).
|
||||||
@ -19,15 +20,15 @@ open class PickerScreen : CameraStageBaseScreen() {
|
|||||||
*/
|
*/
|
||||||
protected var topTable: Table
|
protected var topTable: Table
|
||||||
var bottomTable:Table = Table()
|
var bottomTable:Table = Table()
|
||||||
|
internal var splitPane: SplitPane
|
||||||
protected var scrollPane: ScrollPane
|
protected var scrollPane: ScrollPane
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val bottomTableHeight = 150f
|
|
||||||
bottomTable.add(closeButton).pad(10f)
|
bottomTable.add(closeButton).pad(10f)
|
||||||
|
|
||||||
descriptionLabel = "".toLabel()
|
descriptionLabel = "".toLabel()
|
||||||
descriptionLabel.wrap = true
|
descriptionLabel.wrap = true
|
||||||
val labelScroll = ScrollPane(descriptionLabel)
|
val labelScroll = ScrollPane(descriptionLabel,skin)
|
||||||
bottomTable.add(labelScroll).pad(5f).fill().expand()
|
bottomTable.add(labelScroll).pad(5f).fill().expand()
|
||||||
|
|
||||||
rightSideButton = "".toTextButton()
|
rightSideButton = "".toTextButton()
|
||||||
@ -35,16 +36,18 @@ open class PickerScreen : CameraStageBaseScreen() {
|
|||||||
rightSideGroup.addActor(rightSideButton)
|
rightSideGroup.addActor(rightSideButton)
|
||||||
|
|
||||||
bottomTable.add(rightSideGroup).pad(10f).right()
|
bottomTable.add(rightSideGroup).pad(10f).right()
|
||||||
|
bottomTable.height = stage.height * (1 - screenSplit)
|
||||||
|
|
||||||
topTable = Table()
|
topTable = Table()
|
||||||
scrollPane = ScrollPane(topTable)
|
scrollPane = ScrollPane(topTable)
|
||||||
|
|
||||||
val pickerScreenTable = Table()
|
scrollPane.setScrollingDisabled(disableScroll, disableScroll)
|
||||||
pickerScreenTable.add(scrollPane).height(stage.height - bottomTableHeight - 2f).row()
|
scrollPane.setSize(stage.width, stage.height * screenSplit)
|
||||||
pickerScreenTable.addSeparator()
|
|
||||||
pickerScreenTable.add(bottomTable).height(bottomTableHeight).fillX().expandX().row()
|
splitPane = SplitPane(scrollPane, bottomTable, true, skin)
|
||||||
pickerScreenTable.setFillParent(true)
|
splitPane.splitAmount = screenSplit
|
||||||
stage.addActor(pickerScreenTable)
|
splitPane.setFillParent(true)
|
||||||
|
stage.addActor(splitPane)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setDefaultCloseAction(previousScreen: CameraStageBaseScreen?=null) {
|
fun setDefaultCloseAction(previousScreen: CameraStageBaseScreen?=null) {
|
||||||
|
@ -15,7 +15,6 @@ import com.unciv.models.translations.tr
|
|||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
import kotlin.math.max
|
|
||||||
|
|
||||||
|
|
||||||
class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Technology? = null) : PickerScreen() {
|
class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Technology? = null) : PickerScreen() {
|
||||||
@ -61,7 +60,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
|||||||
|
|
||||||
createTechTable()
|
createTechTable()
|
||||||
setButtonsInfo()
|
setButtonsInfo()
|
||||||
topTable.add(techTable).fill().expand()
|
topTable.add(techTable)
|
||||||
|
|
||||||
rightSideButton.setText("Pick a tech".tr())
|
rightSideButton.setText("Pick a tech".tr())
|
||||||
rightSideButton.onClick(UncivSound.Paper) {
|
rightSideButton.onClick(UncivSound.Paper) {
|
||||||
@ -96,30 +95,30 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
|||||||
val allTechs = civInfo.gameInfo.ruleSet.technologies.values
|
val allTechs = civInfo.gameInfo.ruleSet.technologies.values
|
||||||
if (allTechs.isEmpty()) return
|
if (allTechs.isEmpty()) return
|
||||||
val columns = allTechs.map { it.column!!.columnNumber }.maxOrNull()!! + 1
|
val columns = allTechs.map { it.column!!.columnNumber }.maxOrNull()!! + 1
|
||||||
val rows = allTechs.map { it.row }.maxOrNull()!!
|
val rows = allTechs.map { it.row }.maxOrNull()!! + 1
|
||||||
val techMatrix = Array<Array<Technology?>>(columns) { arrayOfNulls(rows) } // Divided into columns, then rows
|
val techMatrix = Array<Array<Technology?>>(columns) { arrayOfNulls(rows) } // Divided into columns, then rows
|
||||||
val erasNamesToColumns = LinkedHashMap<String, ArrayList<Int>>()
|
|
||||||
|
|
||||||
allTechs.forEach { technology ->
|
for (technology in allTechs) {
|
||||||
techMatrix[technology.column!!.columnNumber][technology.row - 1] = technology
|
techMatrix[technology.column!!.columnNumber][technology.row - 1] = technology
|
||||||
|
}
|
||||||
|
|
||||||
val era = technology.era()
|
val erasNamesToColumns = LinkedHashMap<String, ArrayList<Int>>()
|
||||||
|
for (tech in allTechs) {
|
||||||
|
val era = tech.era()
|
||||||
if (!erasNamesToColumns.containsKey(era)) erasNamesToColumns[era] = ArrayList()
|
if (!erasNamesToColumns.containsKey(era)) erasNamesToColumns[era] = ArrayList()
|
||||||
val columnNumber = technology.column!!.columnNumber
|
val columnNumber = tech.column!!.columnNumber
|
||||||
if (!erasNamesToColumns[era]!!.contains(columnNumber))
|
if (!erasNamesToColumns[era]!!.contains(columnNumber)) erasNamesToColumns[era]!!.add(columnNumber)
|
||||||
erasNamesToColumns[era]!!.add(columnNumber)
|
|
||||||
}
|
}
|
||||||
var i = 0
|
var i = 0
|
||||||
erasNamesToColumns.forEach { (era, columns) ->
|
for ((era, columns) in erasNamesToColumns) {
|
||||||
val columnSpan = columns.size
|
val columnSpan = columns.size
|
||||||
val color = if (i % 2 == 0) Color.BLUE else Color.FIREBRICK
|
val color = if (i % 2 == 0) Color.BLUE else Color.FIREBRICK
|
||||||
i++
|
i++
|
||||||
techTable.add(era.toLabel().addBorder(2f, color)).fill().expand().colspan(columnSpan)
|
techTable.add(era.toLabel().addBorder(2f, color)).fill().colspan(columnSpan)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (rowIndex in 0 until rows) {
|
for (rowIndex in 0..rows - 1) {
|
||||||
val rowPadding = max(5f,(stage.height - 40 - 150 - 2 - 100 * rows) / (2 * rows))
|
techTable.row().pad(5f).padRight(40f)
|
||||||
techTable.row().pad(rowPadding).padLeft(20f).padRight(20f)
|
|
||||||
|
|
||||||
for (columnIndex in techMatrix.indices) {
|
for (columnIndex in techMatrix.indices) {
|
||||||
val tech = techMatrix[columnIndex][rowIndex]
|
val tech = techMatrix[columnIndex][rowIndex]
|
||||||
@ -131,7 +130,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
|||||||
|
|
||||||
techNameToButton[tech.name] = techButton
|
techNameToButton[tech.name] = techButton
|
||||||
techButton.onClick { selectTechnology(tech, false) }
|
techButton.onClick { selectTechnology(tech, false) }
|
||||||
techTable.add(techButton).height(100f).fillX()
|
techTable.add(techButton).fillX()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -286,9 +285,4 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun resize(width: Int, height: Int) {
|
|
||||||
if (stage.viewport.screenWidth != width || stage.viewport.screenHeight != height) {
|
|
||||||
game.setScreen(TechPickerScreen(civInfo))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -20,7 +20,7 @@ import java.util.concurrent.CancellationException
|
|||||||
import kotlin.concurrent.thread
|
import kotlin.concurrent.thread
|
||||||
import com.unciv.ui.utils.AutoScrollPane as ScrollPane
|
import com.unciv.ui.utils.AutoScrollPane as ScrollPane
|
||||||
|
|
||||||
class LoadGameScreen(previousScreen:CameraStageBaseScreen) : PickerScreen() {
|
class LoadGameScreen(previousScreen:CameraStageBaseScreen) : PickerScreen(disableScroll = true) {
|
||||||
lateinit var selectedSave: String
|
lateinit var selectedSave: String
|
||||||
private val copySavedGameToClipboardButton = "Copy saved game to clipboard".toTextButton()
|
private val copySavedGameToClipboardButton = "Copy saved game to clipboard".toTextButton()
|
||||||
private val saveTable = Table()
|
private val saveTable = Table()
|
||||||
|
@ -17,7 +17,7 @@ import kotlin.concurrent.thread
|
|||||||
import com.unciv.ui.utils.AutoScrollPane as ScrollPane
|
import com.unciv.ui.utils.AutoScrollPane as ScrollPane
|
||||||
|
|
||||||
|
|
||||||
class SaveGameScreen(val gameInfo: GameInfo) : PickerScreen() {
|
class SaveGameScreen(val gameInfo: GameInfo) : PickerScreen(disableScroll = true) {
|
||||||
private val gameNameTextField = TextField("", skin)
|
private val gameNameTextField = TextField("", skin)
|
||||||
val currentSaves = Table()
|
val currentSaves = Table()
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx
|
|||||||
import com.badlogic.gdx.Screen
|
import com.badlogic.gdx.Screen
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.GL20
|
import com.badlogic.gdx.graphics.GL20
|
||||||
|
import com.badlogic.gdx.graphics.g2d.Batch
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas
|
import com.badlogic.gdx.graphics.g2d.TextureAtlas
|
||||||
@ -89,6 +90,7 @@ open class CameraStageBaseScreen : Screen {
|
|||||||
skin.get(SelectBox.SelectBoxStyle::class.java).listStyle.font = Fonts.font.apply { data.setScale(20 / Fonts.ORIGINAL_FONT_SIZE) }
|
skin.get(SelectBox.SelectBoxStyle::class.java).listStyle.font = Fonts.font.apply { data.setScale(20 / Fonts.ORIGINAL_FONT_SIZE) }
|
||||||
skin
|
skin
|
||||||
}
|
}
|
||||||
|
internal var batch: Batch = SpriteBatch()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onBackButtonClicked(action: () -> Unit) {
|
fun onBackButtonClicked(action: () -> Unit) {
|
||||||
|
@ -11,6 +11,10 @@ open class ZoomableScrollPane: ScrollPane(null) {
|
|||||||
var continuousScrollingX = false
|
var continuousScrollingX = false
|
||||||
|
|
||||||
init{
|
init{
|
||||||
|
// Remove the existing inputListener
|
||||||
|
// which defines that mouse scroll = vertical movement
|
||||||
|
val zoomListener = listeners.last { it is InputListener && it !in captureListeners }
|
||||||
|
removeListener(zoomListener)
|
||||||
addZoomListeners()
|
addZoomListeners()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,10 +30,7 @@ open class ZoomableScrollPane: ScrollPane(null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun addZoomListeners() {
|
private fun addZoomListeners() {
|
||||||
// At first, Remove the existing inputListener
|
|
||||||
// which defines that mouse scroll = vertical movement
|
|
||||||
val zoomListener = listeners.last { it is InputListener && it !in captureListeners }
|
|
||||||
removeListener(zoomListener)
|
|
||||||
addListener(object : InputListener() {
|
addListener(object : InputListener() {
|
||||||
override fun scrolled(event: InputEvent?, x: Float, y: Float, amountX: Float, amountY: Float): Boolean {
|
override fun scrolled(event: InputEvent?, x: Float, y: Float, amountX: Float, amountY: Float): Boolean {
|
||||||
if (amountX > 0 || amountY > 0) zoomOut()
|
if (amountX > 0 || amountY > 0) zoomOut()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user