mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-07 00:41:39 +07:00
Fixed save/load game Clipboard problems
This commit is contained in:
@ -21,8 +21,8 @@ android {
|
|||||||
applicationId "com.unciv.game"
|
applicationId "com.unciv.game"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 72
|
versionCode 74
|
||||||
versionName "2.4.2"
|
versionName "2.4.4"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.unciv.ui
|
package com.unciv.ui
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
@ -14,8 +15,6 @@ import com.unciv.ui.utils.CameraStageBaseScreen
|
|||||||
import com.unciv.ui.utils.disable
|
import com.unciv.ui.utils.disable
|
||||||
import com.unciv.ui.utils.enable
|
import com.unciv.ui.utils.enable
|
||||||
import com.unciv.ui.utils.setFontColor
|
import com.unciv.ui.utils.setFontColor
|
||||||
import java.awt.Toolkit
|
|
||||||
import java.awt.datatransfer.DataFlavor
|
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@ -66,9 +65,8 @@ class LoadScreen : PickerScreen() {
|
|||||||
val errorLabel = Label("",skin).setFontColor(Color.RED)
|
val errorLabel = Label("",skin).setFontColor(Color.RED)
|
||||||
loadFromClipboardButton.addClickListener {
|
loadFromClipboardButton.addClickListener {
|
||||||
try{
|
try{
|
||||||
val clipbordContents = Toolkit.getDefaultToolkit().systemClipboard.getContents(null)
|
val clipboardContentsString = Gdx.app.clipboard.contents
|
||||||
var clipbordContentsString = clipbordContents.getTransferData(DataFlavor.stringFlavor).toString()
|
val loadedGame = Json().fromJson(GameInfo::class.java, clipboardContentsString)
|
||||||
val loadedGame = Json().fromJson(GameInfo::class.java, clipbordContentsString)
|
|
||||||
loadedGame.setTransients()
|
loadedGame.setTransients()
|
||||||
UnCivGame.Current.loadGame(loadedGame)
|
UnCivGame.Current.loadGame(loadedGame)
|
||||||
}catch (ex:Exception){
|
}catch (ex:Exception){
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.unciv.ui
|
package com.unciv.ui
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||||
@ -11,8 +12,6 @@ import com.unciv.ui.cityscreen.addClickListener
|
|||||||
import com.unciv.ui.pickerscreens.PickerScreen
|
import com.unciv.ui.pickerscreens.PickerScreen
|
||||||
import com.unciv.ui.utils.enable
|
import com.unciv.ui.utils.enable
|
||||||
import com.unciv.ui.utils.getRandom
|
import com.unciv.ui.utils.getRandom
|
||||||
import java.awt.Toolkit
|
|
||||||
import java.awt.datatransfer.StringSelection
|
|
||||||
|
|
||||||
class SaveScreen : PickerScreen() {
|
class SaveScreen : PickerScreen() {
|
||||||
val textField = TextField("", skin)
|
val textField = TextField("", skin)
|
||||||
@ -37,17 +36,15 @@ class SaveScreen : PickerScreen() {
|
|||||||
val adjectives = listOf("Prancing","Obese","Junior","Senior","Abstract","Discombobulating","Simple","Awkward","Holy",
|
val adjectives = listOf("Prancing","Obese","Junior","Senior","Abstract","Discombobulating","Simple","Awkward","Holy",
|
||||||
"Dangerous","Greasy","Stinky","Purple","Majestic","Incomprehensible","Cardboard","Chocolate","Robot","Ninja")
|
"Dangerous","Greasy","Stinky","Purple","Majestic","Incomprehensible","Cardboard","Chocolate","Robot","Ninja")
|
||||||
val nouns = listOf("Moose","Pigeon","Weasel","Ferret","Onion","Marshmallow","Crocodile","Inu Shiba",
|
val nouns = listOf("Moose","Pigeon","Weasel","Ferret","Onion","Marshmallow","Crocodile","Inu Shiba",
|
||||||
"Sandwich","Elephant","Kangaroo","Marmot","Beagle","Dolphin","Fish","Tomato","Duck")
|
"Sandwich","Elephant","Kangaroo","Marmot","Beagle","Dolphin","Fish","Tomato","Duck","Dinosaur")
|
||||||
val defaultSaveName = adjectives.getRandom()+" "+nouns.getRandom()
|
val defaultSaveName = adjectives.getRandom()+" "+nouns.getRandom()
|
||||||
textField.text = defaultSaveName
|
textField.text = defaultSaveName
|
||||||
|
|
||||||
newSave.add(Label("Saved game name:",skin)).row()
|
newSave.add(Label("Saved game name:",skin)).row()
|
||||||
newSave.add(textField).width(300f).row()
|
newSave.add(textField).width(300f).pad(10f).row()
|
||||||
|
|
||||||
|
|
||||||
val copyJsonButton = TextButton("Copy game info",skin)
|
val copyJsonButton = TextButton("Copy game info",skin)
|
||||||
val copiedString = StringSelection(Json().toJson(game.gameInfo))
|
copyJsonButton.addClickListener { Gdx.app.clipboard.contents = Json().toJson(game.gameInfo)}
|
||||||
copyJsonButton.addClickListener { Toolkit.getDefaultToolkit().systemClipboard.setContents(copiedString,copiedString) }
|
|
||||||
newSave.add(copyJsonButton)
|
newSave.add(copyJsonButton)
|
||||||
|
|
||||||
topTable.add(newSave)
|
topTable.add(newSave)
|
||||||
|
Reference in New Issue
Block a user