mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-08 14:57:58 +07:00
Disabled NextTurn button from being clicked twice, and moved rendering to the main thread
This commit is contained in:
@ -115,6 +115,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
borderImages.clear()
|
borderImages.clear()
|
||||||
|
|
||||||
if (tileInfo.getOwner() != null) {
|
if (tileInfo.getOwner() != null) {
|
||||||
|
val civColor = tileInfo.getOwner()!!.getCivilization().getColor()
|
||||||
for (neighbor in tileInfo.neighbors.filter { it.getOwner() != tileInfo.getOwner() }) {
|
for (neighbor in tileInfo.neighbors.filter { it.getOwner() != tileInfo.getOwner() }) {
|
||||||
|
|
||||||
val relativeHexPosition = tileInfo.position.cpy().sub(neighbor.position)
|
val relativeHexPosition = tileInfo.position.cpy().sub(neighbor.position)
|
||||||
@ -138,7 +139,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
// we can move with multiples of (b,-a) which is perpendicular to (a,b)
|
// we can move with multiples of (b,-a) which is perpendicular to (a,b)
|
||||||
image.moveBy(relativeWorldPosition.y*i * 4, -relativeWorldPosition.x*i * 4)
|
image.moveBy(relativeWorldPosition.y*i * 4, -relativeWorldPosition.x*i * 4)
|
||||||
|
|
||||||
image.color = tileInfo.getOwner()!!.getCivilization().getColor()
|
image.color = civColor
|
||||||
addActor(image)
|
addActor(image)
|
||||||
borderImages.add(image)
|
borderImages.add(image)
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,18 @@
|
|||||||
package com.unciv.ui.worldscreen
|
package com.unciv.ui.worldscreen
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.math.Vector2
|
import com.badlogic.gdx.math.Vector2
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||||
import com.unciv.logic.GameSaver
|
import com.unciv.logic.GameSaver
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.ui.cityscreen.addClickListener
|
import com.unciv.ui.cityscreen.addClickListener
|
||||||
|
import com.unciv.ui.pickerscreens.GreatPersonPickerScreen
|
||||||
import com.unciv.ui.pickerscreens.PolicyPickerScreen
|
import com.unciv.ui.pickerscreens.PolicyPickerScreen
|
||||||
import com.unciv.ui.pickerscreens.TechPickerScreen
|
import com.unciv.ui.pickerscreens.TechPickerScreen
|
||||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||||
|
import com.unciv.ui.utils.disable
|
||||||
|
import com.unciv.ui.utils.enable
|
||||||
import com.unciv.ui.worldscreen.unit.UnitActionsTable
|
import com.unciv.ui.worldscreen.unit.UnitActionsTable
|
||||||
|
|
||||||
class WorldScreen : CameraStageBaseScreen() {
|
class WorldScreen : CameraStageBaseScreen() {
|
||||||
@ -113,10 +117,21 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
return@addClickListener
|
return@addClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
game.gameInfo.nextTurn()
|
|
||||||
bottomBar.unitTable.currentlyExecutingAction = null
|
bottomBar.unitTable.currentlyExecutingAction = null
|
||||||
kotlin.concurrent.thread { GameSaver().saveGame(game.gameInfo, "Autosave") }
|
|
||||||
update()
|
Gdx.input.inputProcessor = null // remove input processing - nothing will be clicked!
|
||||||
|
nextTurnButton.disable()
|
||||||
|
nextTurnButton.setText("Working...")
|
||||||
|
|
||||||
|
kotlin.concurrent.thread {
|
||||||
|
game.gameInfo.nextTurn()
|
||||||
|
shouldUpdate=true
|
||||||
|
GameSaver().saveGame(game.gameInfo, "Autosave")
|
||||||
|
|
||||||
|
nextTurnButton.setText("Next turn")
|
||||||
|
nextTurnButton.enable()
|
||||||
|
Gdx.input.inputProcessor = stage
|
||||||
|
}
|
||||||
displayTutorials("NextTurn")
|
displayTutorials("NextTurn")
|
||||||
|
|
||||||
if(gameInfo.turns>=100)
|
if(gameInfo.turns>=100)
|
||||||
@ -134,5 +149,15 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
game.setWorldScreen()
|
game.setWorldScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var shouldUpdate=false
|
||||||
|
override fun render(delta: Float) {
|
||||||
|
if(shouldUpdate){ // This is so that updates happen in the MAIN THREAD, where there is a GL Context,
|
||||||
|
// otherwise images will not load properly!
|
||||||
|
update()
|
||||||
|
shouldUpdate=false
|
||||||
|
}
|
||||||
|
super.render(delta)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user