mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-21 13:18:56 +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:
@ -150,7 +150,6 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
|||||||
if (construction.canBePurchased()) {
|
if (construction.canBePurchased()) {
|
||||||
val constructionGoldCost = construction.getGoldCost(city.civInfo)
|
val constructionGoldCost = construction.getGoldCost(city.civInfo)
|
||||||
purchaseConstructionButton = TextButton("Buy for [$constructionGoldCost] gold".tr(), CameraStageBaseScreen.skin)
|
purchaseConstructionButton = TextButton("Buy for [$constructionGoldCost] gold".tr(), CameraStageBaseScreen.skin)
|
||||||
purchaseConstructionButton.labelCell.pad(10f)
|
|
||||||
purchaseConstructionButton.onClick("coin") {
|
purchaseConstructionButton.onClick("coin") {
|
||||||
YesNoPopupTable("Would you like to purchase [${construction.name}] for [$constructionGoldCost] gold?".tr(), {
|
YesNoPopupTable("Would you like to purchase [${construction.name}] for [$constructionGoldCost] gold?".tr(), {
|
||||||
cityConstructions.purchaseConstruction(construction.name)
|
cityConstructions.purchaseConstruction(construction.name)
|
||||||
@ -166,6 +165,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
|||||||
purchaseConstructionButton = TextButton("Buy".tr(), CameraStageBaseScreen.skin)
|
purchaseConstructionButton = TextButton("Buy".tr(), CameraStageBaseScreen.skin)
|
||||||
purchaseConstructionButton.disable()
|
purchaseConstructionButton.disable()
|
||||||
}
|
}
|
||||||
|
purchaseConstructionButton.labelCell.pad(10f)
|
||||||
add(purchaseConstructionButton).pad(10f).row()
|
add(purchaseConstructionButton).pad(10f).row()
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.unciv.ui.worldscreen.optionstable
|
package com.unciv.ui.worldscreen.optionstable
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.unciv.UnCivGame
|
import com.unciv.UnCivGame
|
||||||
import com.unciv.logic.map.RoadStatus
|
import com.unciv.logic.map.RoadStatus
|
||||||
import com.unciv.models.gamebasics.tr
|
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.newgamescreen.NewGameScreen
|
||||||
import com.unciv.ui.saves.LoadGameScreen
|
import com.unciv.ui.saves.LoadGameScreen
|
||||||
import com.unciv.ui.saves.SaveGameScreen
|
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 com.unciv.ui.worldscreen.WorldScreen
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
class WorldScreenMenuTable(val worldScreen: WorldScreen) : PopupTable(worldScreen) {
|
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() }
|
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("Victory status".tr()) { UnCivGame.Current.screen = VictoryScreen() }
|
||||||
|
|
||||||
addButton("Options".tr()){
|
addButton("Options".tr()){
|
||||||
@ -63,6 +74,37 @@ class WorldScreenMenuTable(val worldScreen: WorldScreen) : PopupTable(worldScree
|
|||||||
|
|
||||||
open()
|
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) {
|
class WorldScreenCommunityTable(val worldScreen: WorldScreen) : PopupTable(worldScreen) {
|
||||||
|
@ -69,6 +69,7 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr
|
|||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
innerTable.add("Auto-assign city production".toLabel())
|
innerTable.add("Auto-assign city production".toLabel())
|
||||||
innerTable.addButton(if(settings.autoAssignCityProduction) "Yes".tr() else "No".tr()) {
|
innerTable.addButton(if(settings.autoAssignCityProduction) "Yes".tr() else "No".tr()) {
|
||||||
settings.autoAssignCityProduction= !settings.autoAssignCityProduction
|
settings.autoAssignCityProduction= !settings.autoAssignCityProduction
|
||||||
|
Reference in New Issue
Block a user