mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-03 22:22:51 +07:00
Added game ID copy and join, so one person can create a game, send it to someone else, and the other person can join it
This commit is contained in:
parent
fd4d96ed8e
commit
bc1592bafe
@ -150,7 +150,6 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
||||
if (construction.canBePurchased()) {
|
||||
val constructionGoldCost = construction.getGoldCost(city.civInfo)
|
||||
purchaseConstructionButton = TextButton("Buy for [$constructionGoldCost] gold".tr(), CameraStageBaseScreen.skin)
|
||||
purchaseConstructionButton.labelCell.pad(10f)
|
||||
purchaseConstructionButton.onClick("coin") {
|
||||
YesNoPopupTable("Would you like to purchase [${construction.name}] for [$constructionGoldCost] gold?".tr(), {
|
||||
cityConstructions.purchaseConstruction(construction.name)
|
||||
@ -166,6 +165,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
||||
purchaseConstructionButton = TextButton("Buy".tr(), CameraStageBaseScreen.skin)
|
||||
purchaseConstructionButton.disable()
|
||||
}
|
||||
purchaseConstructionButton.labelCell.pad(10f)
|
||||
add(purchaseConstructionButton).pad(10f).row()
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.unciv.ui.worldscreen.optionstable
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.map.RoadStatus
|
||||
import com.unciv.models.gamebasics.tr
|
||||
@ -10,7 +11,11 @@ import com.unciv.ui.mapeditor.MapEditorScreen
|
||||
import com.unciv.ui.newgamescreen.NewGameScreen
|
||||
import com.unciv.ui.saves.LoadGameScreen
|
||||
import com.unciv.ui.saves.SaveGameScreen
|
||||
import com.unciv.ui.utils.setFontColor
|
||||
import com.unciv.ui.utils.toLabel
|
||||
import com.unciv.ui.worldscreen.WorldScreen
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class WorldScreenMenuTable(val worldScreen: WorldScreen) : PopupTable(worldScreen) {
|
||||
|
||||
@ -47,6 +52,12 @@ class WorldScreenMenuTable(val worldScreen: WorldScreen) : PopupTable(worldScree
|
||||
|
||||
addButton("Start new game".tr()){ UnCivGame.Current.screen = NewGameScreen() }
|
||||
|
||||
if(worldScreen.gameInfo.gameParameters.isOnlineMultiplayer){
|
||||
addButton("Copy game ID to clipboard".tr()){ Gdx.app.clipboard.contents = worldScreen.gameInfo.gameId }
|
||||
}
|
||||
|
||||
// addJoinMultiplayerButton()
|
||||
|
||||
addButton("Victory status".tr()) { UnCivGame.Current.screen = VictoryScreen() }
|
||||
|
||||
addButton("Options".tr()){
|
||||
@ -63,6 +74,37 @@ class WorldScreenMenuTable(val worldScreen: WorldScreen) : PopupTable(worldScree
|
||||
|
||||
open()
|
||||
}
|
||||
|
||||
private fun addJoinMultiplayerButton() {
|
||||
addButton("Join multiplayer".tr()) {
|
||||
close()
|
||||
val joinMultiplayerPopup = PopupTable(screen)
|
||||
joinMultiplayerPopup.addGoodSizedLabel("Copy the game ID to your clipboard, and click the Join Game button!").row()
|
||||
val badGameIdLabel = "".toLabel().setFontColor(Color.RED)
|
||||
badGameIdLabel.isVisible = false
|
||||
joinMultiplayerPopup.addButton("Join Game") {
|
||||
val gameId = Gdx.app.clipboard.contents.trim()
|
||||
try {
|
||||
UUID.fromString(gameId)
|
||||
} catch (ex: Exception) {
|
||||
badGameIdLabel.setText("Invalid game ID!")
|
||||
badGameIdLabel.isVisible = true
|
||||
return@addButton
|
||||
}
|
||||
try {
|
||||
val game = OnlineMultiplayer().tryDownloadGame(gameId)
|
||||
UnCivGame.Current.loadGame(game)
|
||||
} catch (ex: Exception) {
|
||||
badGameIdLabel.setText("Could not download game1!")
|
||||
badGameIdLabel.isVisible = true
|
||||
return@addButton
|
||||
}
|
||||
}.row()
|
||||
joinMultiplayerPopup.add(badGameIdLabel).row()
|
||||
joinMultiplayerPopup.addCloseButton()
|
||||
joinMultiplayerPopup.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class WorldScreenCommunityTable(val worldScreen: WorldScreen) : PopupTable(worldScreen) {
|
||||
|
@ -69,6 +69,7 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr
|
||||
update()
|
||||
}
|
||||
|
||||
|
||||
innerTable.add("Auto-assign city production".toLabel())
|
||||
innerTable.addButton(if(settings.autoAssignCityProduction) "Yes".tr() else "No".tr()) {
|
||||
settings.autoAssignCityProduction= !settings.autoAssignCityProduction
|
||||
|
Loading…
Reference in New Issue
Block a user