mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 22:06:05 -04:00
Crash Report omits GameInfo stuff when crashing from MainMenu, MapEditor or Options (#6808)
This commit is contained in:
parent
f8e0f572e4
commit
05f656b6c1
@ -6,15 +6,13 @@ import com.badlogic.gdx.scenes.scene2d.Actor
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
import com.badlogic.gdx.utils.Json
|
|
||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.json.json
|
import com.unciv.logic.GameSaver
|
||||||
import com.unciv.models.ruleset.RulesetCache
|
import com.unciv.models.ruleset.RulesetCache
|
||||||
import com.unciv.ui.images.IconTextButton
|
import com.unciv.ui.images.IconTextButton
|
||||||
import com.unciv.ui.images.ImageGetter
|
import com.unciv.ui.images.ImageGetter
|
||||||
import com.unciv.ui.popup.ToastPopup
|
import com.unciv.ui.popup.ToastPopup
|
||||||
import com.unciv.ui.saves.Gzip
|
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
import java.io.PrintWriter
|
import java.io.PrintWriter
|
||||||
import java.io.StringWriter
|
import java.io.StringWriter
|
||||||
@ -53,24 +51,28 @@ class CrashScreen(val exception: Throwable): BaseScreen() {
|
|||||||
private set
|
private set
|
||||||
|
|
||||||
/** @return The last active save game serialized as a compressed string if any, or an informational note otherwise. */
|
/** @return The last active save game serialized as a compressed string if any, or an informational note otherwise. */
|
||||||
private fun tryGetSaveGame()
|
private fun tryGetSaveGame(): String {
|
||||||
= try {
|
if (!UncivGame.isCurrentInitialized() || !UncivGame.Current.isGameInfoInitialized())
|
||||||
UncivGame.Current.gameInfo.let { gameInfo ->
|
return ""
|
||||||
json().toJson(gameInfo).let {
|
return "\n**Save Data:**\n<details><summary>Show Saved Game</summary>\n\n```" +
|
||||||
jsonString -> Gzip.zip(jsonString)
|
try {
|
||||||
}
|
GameSaver.gameInfoToString(UncivGame.Current.gameInfo, forceZip = true)
|
||||||
} // Taken from old CrashController().buildReport().
|
} catch (e: Throwable) {
|
||||||
} catch (e: Throwable) {
|
"No save data: $e" // In theory .toString() could still error here.
|
||||||
"No save data: $e" // In theory .toString() could still error here.
|
} + "\n```\n</details>\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return Mods from the last active save game if any, or an informational note otherwise. */
|
/** @return Mods from the last active save game if any, or an informational note otherwise. */
|
||||||
private fun tryGetSaveMods()
|
private fun tryGetSaveMods(): String {
|
||||||
= try { // Also from old CrashController().buildReport(), also could still error at .toString().
|
if (!UncivGame.isCurrentInitialized() || !UncivGame.Current.isGameInfoInitialized())
|
||||||
LinkedHashSet(UncivGame.Current.gameInfo.gameParameters.getModsAndBaseRuleset()).toString()
|
return ""
|
||||||
} catch (e: Throwable) {
|
return "\n**Save Mods:**\n```\n" +
|
||||||
"No mod data: $e"
|
try { // Also from old CrashController().buildReport(), also could still error at .toString().
|
||||||
}
|
LinkedHashSet(UncivGame.Current.gameInfo.gameParameters.getModsAndBaseRuleset()).toString()
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
"No mod data: $e"
|
||||||
|
} + "\n```\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,32 +91,19 @@ class CrashScreen(val exception: Throwable): BaseScreen() {
|
|||||||
**Version:** ${UncivGame.Current.version.prependIndentToOnlyNewLines(subIndent)}
|
**Version:** ${UncivGame.Current.version.prependIndentToOnlyNewLines(subIndent)}
|
||||||
**Rulesets:** ${RulesetCache.keys.toString().prependIndentToOnlyNewLines(subIndent)}
|
**Rulesets:** ${RulesetCache.keys.toString().prependIndentToOnlyNewLines(subIndent)}
|
||||||
**Last Screen:** `$lastScreenType`
|
**Last Screen:** `$lastScreenType`
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
${UncivGame.Current.crashReportSysInfo?.getInfo().toString().prependIndentToOnlyNewLines(baseIndent)}
|
${UncivGame.Current.crashReportSysInfo?.getInfo().toString().prependIndentToOnlyNewLines(baseIndent)}
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
|
|
||||||
**Message:**
|
**Message:**
|
||||||
```
|
```
|
||||||
${message.prependIndentToOnlyNewLines(baseIndent)}
|
${message.prependIndentToOnlyNewLines(baseIndent)}
|
||||||
```
|
```
|
||||||
|
""".trimIndent() + tryGetSaveMods() + tryGetSaveGame()
|
||||||
**Save Mods:**
|
|
||||||
```
|
|
||||||
${tryGetSaveMods().prependIndentToOnlyNewLines(baseIndent)}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Save Data:**
|
|
||||||
<details><summary>Show Saved Game</summary>
|
|
||||||
|
|
||||||
```
|
|
||||||
${tryGetSaveGame().prependIndentToOnlyNewLines(baseIndent)}
|
|
||||||
```
|
|
||||||
</details>
|
|
||||||
""".trimIndent()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user