Added "user id from clipboard" button in New Game screen

Fixed other user id problems
This commit is contained in:
Yair Morgenstern 2019-09-03 23:22:27 +03:00
parent 455de79d28
commit 91ac744692
6 changed files with 25 additions and 12 deletions

1
.gitignore vendored
View file

@ -134,3 +134,4 @@ android/assets/fonts/
android/release/android.aab
android/assets/maps/
android/release/android.aab.sig
android/release/android-release.aab

View file

@ -9,10 +9,10 @@ android:
- platform-tools
# The BuildTools version used by your project
- build-tools-28.0.3
- build-tools-29.0.3
# The SDK version used to compile your project
- android-28
- android-29
jdk:

View file

@ -20,9 +20,9 @@ android {
defaultConfig {
applicationId "com.unciv.app"
minSdkVersion 14
targetSdkVersion 28
versionCode 293
versionName "3.0.0"
targetSdkVersion 29
versionCode 294
versionName "3.0.1"
}
// Had to add this crap for Travis to build, it wanted to sign the app

View file

@ -9,6 +9,7 @@ buildscript {
repositories {
// gradle
// Chinese mirrors for quicker loading for chinese devs
maven{ url 'https://maven.aliyun.com/repository/jcenter'}
maven{ url 'https://maven.aliyun.com/repository/google'}
maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
@ -42,6 +43,7 @@ allprojects {
repositories {
// gradle
// Chinese mirrors for quicker loading for chinese devs
maven{ url 'https://maven.aliyun.com/repository/jcenter'}
maven{ url 'https://maven.aliyun.com/repository/google'}
maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}

View file

@ -1,5 +1,6 @@
package com.unciv.ui.newgamescreen
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Touchable
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
@ -60,11 +61,12 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
playerIdTable.add("Player ID:".toLabel())
val playerIdTextfield = TextField(player.playerId, CameraStageBaseScreen.skin)
playerIdTable.add(playerIdTextfield)
playerIdTable.add(playerIdTextfield).colspan(2)
val errorLabel = "Not a valid user id!".toLabel().setFontColor(Color.RED)
errorLabel.isVisible=false
playerIdTable.add(errorLabel)
playerIdTextfield.addListener {
fun onPlayerIdTextUpdated(){
try {
val uuid = UUID.fromString(playerIdTextfield.text)
player.playerId = playerIdTextfield.text
@ -72,19 +74,27 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
} catch (ex: Exception) {
errorLabel.isVisible=true
}
true
}
playerIdTextfield.addListener { onPlayerIdTextUpdated(); true }
playerIdTable.row()
val currentUserId = UnCivGame.Current.settings.userId
val setCurrentUserButton = TextButton("Set current user", CameraStageBaseScreen.skin)
val setCurrentUserButton = TextButton("Set current user".tr(), CameraStageBaseScreen.skin)
setCurrentUserButton.onClick {
playerIdTextfield.text = currentUserId
errorLabel.isVisible = false
onPlayerIdTextUpdated()
}
playerIdTable.add(setCurrentUserButton)
val copyFromClipboardButton = TextButton("Player ID from clipboard",CameraStageBaseScreen.skin)
copyFromClipboardButton.onClick {
playerIdTextfield.text = Gdx.app.clipboard.contents
onPlayerIdTextUpdated()
}
playerIdTable.add(copyFromClipboardButton).pad(5f)
playerTable.add(playerIdTable).colspan(playerTable.columns)
}

View file

@ -96,9 +96,9 @@ class WorldScreenMenuTable(val worldScreen: WorldScreen) : PopupTable(worldScree
val badGameIdLabel = "".toLabel().setFontColor(Color.RED)
badGameIdLabel.isVisible = false
multiplayerPopup.addButton("Join Game") {
val gameId = Gdx.app.clipboard.contents.trim()
val gameId = Gdx.app.clipboard.contents
try {
UUID.fromString(gameId)
UUID.fromString(gameId.trim())
} catch (ex: Exception) {
badGameIdLabel.setText("Invalid game ID!")
badGameIdLabel.isVisible = true