Added username and ID - this will be how we recognize players in multiplayer
This commit is contained in:
parent
c138fbc385
commit
05e4e33a3d
2 changed files with 25 additions and 13 deletions
|
@ -1,6 +1,8 @@
|
||||||
package com.unciv
|
package com.unciv
|
||||||
|
|
||||||
import com.unciv.logic.GameSaver
|
import com.unciv.logic.GameSaver
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
class GameSettings {
|
class GameSettings {
|
||||||
var showWorkedTiles: Boolean = false
|
var showWorkedTiles: Boolean = false
|
||||||
|
@ -17,6 +19,9 @@ class GameSettings {
|
||||||
var showTutorials: Boolean = true
|
var showTutorials: Boolean = true
|
||||||
var autoAssignCityProduction: Boolean = true
|
var autoAssignCityProduction: Boolean = true
|
||||||
|
|
||||||
|
var userName:String=""
|
||||||
|
var userId = UUID.randomUUID().toString()
|
||||||
|
|
||||||
fun save(){
|
fun save(){
|
||||||
GameSaver().setGeneralSettings(this)
|
GameSaver().setGeneralSettings(this)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,7 @@ package com.unciv.ui.worldscreen.optionstable
|
||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch
|
import com.badlogic.gdx.graphics.g2d.Batch
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
import com.badlogic.gdx.scenes.scene2d.ui.*
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Slider
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
||||||
import com.badlogic.gdx.utils.Array
|
import com.badlogic.gdx.utils.Array
|
||||||
import com.unciv.UnCivGame
|
import com.unciv.UnCivGame
|
||||||
|
@ -90,22 +88,14 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr
|
||||||
innerTable.add("Version".toLabel())
|
innerTable.add("Version".toLabel())
|
||||||
innerTable.add(UnCivGame.Current.version.toLabel()).row()
|
innerTable.add(UnCivGame.Current.version.toLabel()).row()
|
||||||
|
|
||||||
|
addUsernameAndId(innerTable)
|
||||||
|
|
||||||
val scrollPane = ScrollPane(innerTable,skin)
|
val scrollPane = ScrollPane(innerTable,skin)
|
||||||
scrollPane.setOverscroll(false,false)
|
scrollPane.setOverscroll(false,false)
|
||||||
scrollPane.fadeScrollBars=false
|
scrollPane.fadeScrollBars=false
|
||||||
scrollPane.setScrollingDisabled(true,false)
|
scrollPane.setScrollingDisabled(true,false)
|
||||||
add(scrollPane).maxHeight(screen.stage.height*0.6f).row()
|
add(scrollPane).maxHeight(screen.stage.height*0.6f).row()
|
||||||
|
|
||||||
|
|
||||||
addButton("Dropbox Testing"){
|
|
||||||
// val folderList = DropBox().getFolderList("/Maps")
|
|
||||||
// for(folder in folderList.entries)
|
|
||||||
// print(folder.name)
|
|
||||||
// DropBox().downloadFile("/Maps/China starts on tundra")
|
|
||||||
DropBox().uploadFile("/Maps/Test","blabla")
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
addButton("Close"){ remove() }
|
addButton("Close"){ remove() }
|
||||||
|
|
||||||
pack() // Needed to show the background.
|
pack() // Needed to show the background.
|
||||||
|
@ -113,6 +103,23 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr
|
||||||
UnCivGame.Current.worldScreen.shouldUpdate=true
|
UnCivGame.Current.worldScreen.shouldUpdate=true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun addUsernameAndId(innerTable: PopupTable) {
|
||||||
|
innerTable.add("Username".toLabel())
|
||||||
|
val userNameTextField = TextField(UnCivGame.Current.settings.userName, skin)
|
||||||
|
userNameTextField.addListener {
|
||||||
|
UnCivGame.Current.settings.userName = userNameTextField.text
|
||||||
|
UnCivGame.Current.settings.save()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
innerTable.add(userNameTextField).row()
|
||||||
|
|
||||||
|
|
||||||
|
innerTable.add("User Id".toLabel())
|
||||||
|
val userIdButton = TextButton("Click to copy".tr(),skin)
|
||||||
|
userIdButton.onClick { Gdx.app.clipboard.contents = UnCivGame.Current.settings.userId }
|
||||||
|
innerTable.add(userIdButton).row()
|
||||||
|
}
|
||||||
|
|
||||||
private fun addSoundEffectsVolumeSlider(innerTable: PopupTable) {
|
private fun addSoundEffectsVolumeSlider(innerTable: PopupTable) {
|
||||||
innerTable.add("Sound effects volume".tr())
|
innerTable.add("Sound effects volume".tr())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue