mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-08 23:08:35 +07:00
(Tool) Tiny helper to load MP saves (from issues for debugging) as hotseat (#10610)
* Linting * Another button on the "secret" debug tab: Load MP as hotseat * Remove password wall from Debug Options (but not the Ctrl-Shift gate)
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
package com.unciv.ui.popups.options
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle
|
||||
import com.unciv.GUI
|
||||
@ -16,7 +17,9 @@ import com.unciv.ui.components.extensions.toLabel
|
||||
import com.unciv.ui.components.extensions.toTextButton
|
||||
import com.unciv.ui.components.input.onClick
|
||||
import com.unciv.ui.components.widgets.UncivSlider
|
||||
import com.unciv.ui.popups.ToastPopup
|
||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
import com.unciv.utils.Concurrency
|
||||
import com.unciv.utils.DebugUtils
|
||||
|
||||
fun debugTab(
|
||||
@ -125,6 +128,21 @@ fun debugTab(
|
||||
}
|
||||
add(giveResourcesButton).colspan(2).row()
|
||||
|
||||
add("Load online multiplayer game as hotseat from clipboard".toTextButton().onClick {
|
||||
// Code duplication : LoadGameScreen.getLoadFromClipboardButton
|
||||
Concurrency.run {
|
||||
try {
|
||||
val clipboardContentsString = Gdx.app.clipboard.contents.trim()
|
||||
val loadedGame = UncivFiles.gameInfoFromString(clipboardContentsString)
|
||||
loadedGame.gameParameters.isOnlineMultiplayer = false
|
||||
optionsPopup.game.loadGame(loadedGame, true)
|
||||
optionsPopup.close()
|
||||
} catch (ex: Exception) {
|
||||
ToastPopup(ex.message ?: ex::class.java.simpleName, optionsPopup.stageToShowOn).open(true)
|
||||
}
|
||||
}
|
||||
}).colspan(2).row()
|
||||
|
||||
addSeparator()
|
||||
add("* Crash Unciv! *".toTextButton(skin.get("negative", TextButtonStyle::class.java)).onClick {
|
||||
throw UncivShowableException("Intentional crash")
|
||||
|
@ -120,7 +120,7 @@ class OptionsPopup(
|
||||
tabs.addPage("Locate mod errors", content, ImageGetter.getImage("OtherIcons/Mods"), 24f)
|
||||
}
|
||||
if (withDebug || Gdx.input.areSecretKeysPressed()) {
|
||||
tabs.addPage("Debug", debugTab(this), ImageGetter.getImage("OtherIcons/SecretOptions"), 24f, secret = true)
|
||||
tabs.addPage("Debug", debugTab(this), ImageGetter.getImage("OtherIcons/SecretOptions"), 24f)
|
||||
}
|
||||
|
||||
addCloseButton {
|
||||
@ -142,7 +142,6 @@ class OptionsPopup(
|
||||
override fun setVisible(visible: Boolean) {
|
||||
super.setVisible(visible)
|
||||
if (!visible) return
|
||||
tabs.askForPassword(secretHashCode = 2747985)
|
||||
if (tabs.activePage < 0) tabs.selectPage(selectPage)
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ class WorldScreen(
|
||||
globalShortcuts.add(KeyCharAndCode.BACK) { backButtonAndESCHandler() }
|
||||
|
||||
|
||||
globalShortcuts.add('`'){
|
||||
globalShortcuts.add('`') {
|
||||
// No cheating unless you're by yourself
|
||||
if (gameInfo.civilizations.count { it.isHuman() } > 1) return@add
|
||||
val consolePopup = DevConsolePopup(this)
|
||||
|
Reference in New Issue
Block a user