mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 15:27:50 +07:00
Fixed save/load game Clipboard problems
This commit is contained in:
@ -21,8 +21,8 @@ android {
|
||||
applicationId "com.unciv.game"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 26
|
||||
versionCode 72
|
||||
versionName "2.4.2"
|
||||
versionCode 74
|
||||
versionName "2.4.4"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.unciv.ui
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
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.enable
|
||||
import com.unciv.ui.utils.setFontColor
|
||||
import java.awt.Toolkit
|
||||
import java.awt.datatransfer.DataFlavor
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
@ -66,9 +65,8 @@ class LoadScreen : PickerScreen() {
|
||||
val errorLabel = Label("",skin).setFontColor(Color.RED)
|
||||
loadFromClipboardButton.addClickListener {
|
||||
try{
|
||||
val clipbordContents = Toolkit.getDefaultToolkit().systemClipboard.getContents(null)
|
||||
var clipbordContentsString = clipbordContents.getTransferData(DataFlavor.stringFlavor).toString()
|
||||
val loadedGame = Json().fromJson(GameInfo::class.java, clipbordContentsString)
|
||||
val clipboardContentsString = Gdx.app.clipboard.contents
|
||||
val loadedGame = Json().fromJson(GameInfo::class.java, clipboardContentsString)
|
||||
loadedGame.setTransients()
|
||||
UnCivGame.Current.loadGame(loadedGame)
|
||||
}catch (ex:Exception){
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.unciv.ui
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
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.utils.enable
|
||||
import com.unciv.ui.utils.getRandom
|
||||
import java.awt.Toolkit
|
||||
import java.awt.datatransfer.StringSelection
|
||||
|
||||
class SaveScreen : PickerScreen() {
|
||||
val textField = TextField("", skin)
|
||||
@ -37,17 +36,15 @@ class SaveScreen : PickerScreen() {
|
||||
val adjectives = listOf("Prancing","Obese","Junior","Senior","Abstract","Discombobulating","Simple","Awkward","Holy",
|
||||
"Dangerous","Greasy","Stinky","Purple","Majestic","Incomprehensible","Cardboard","Chocolate","Robot","Ninja")
|
||||
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()
|
||||
textField.text = defaultSaveName
|
||||
|
||||
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 copiedString = StringSelection(Json().toJson(game.gameInfo))
|
||||
copyJsonButton.addClickListener { Toolkit.getDefaultToolkit().systemClipboard.setContents(copiedString,copiedString) }
|
||||
copyJsonButton.addClickListener { Gdx.app.clipboard.contents = Json().toJson(game.gameInfo)}
|
||||
newSave.add(copyJsonButton)
|
||||
|
||||
topTable.add(newSave)
|
||||
|
Reference in New Issue
Block a user