Resolved ANR when copying game data to clipboard

This commit is contained in:
Yair Morgenstern
2022-02-20 19:53:19 +02:00
parent 2786e0091c
commit cd92f66c3a
2 changed files with 25 additions and 23 deletions

View File

@ -39,12 +39,14 @@ class SaveGameScreen(val gameInfo: GameInfo) : PickerScreen(disableScroll = true
val copyJsonButton = "Copy to clipboard".toTextButton()
copyJsonButton.onClick {
try {
val json = Json().toJson(gameInfo)
val base64Gzip = Gzip.zip(json)
Gdx.app.clipboard.contents = base64Gzip
} catch (OOM: OutOfMemoryError) {
// you don't get a special toast, this isn't nearly common enough, this is a total edge-case
thread(name="Copy to clipboard") { // the Gzip rarely leads to ANRs
try {
val json = Json().toJson(gameInfo)
val base64Gzip = Gzip.zip(json)
Gdx.app.clipboard.contents = base64Gzip
} catch (OOM: OutOfMemoryError) {
// you don't get a special toast, this isn't nearly common enough, this is a total edge-case
}
}
}
newSave.add(copyJsonButton).row()

View File

@ -1526,12 +1526,7 @@ Applicable to: Conditional
## Deprecated uniques
- "[stats] from every Wonder" - Deprecated as of 3.19.1, replace with "[stats] from every [Wonder]"
- "[stats] from every [buildingFilter] in cities where this religion has at least [amount] followers" - Deprecated as of 3.19.3, replace with "[stats] from every [buildingFilter] <in cities where this religion has at least [amount] followers>"
- "+[amount]% [stat] from every [tileFilter/specialist/buildingName]" - Deprecated as of 3.18.17, replace with "[+amount]% [stat] from every [tileFilter/specialist/buildingName]"
- "+[amount]% yield from every [tileFilter]" - Deprecated as of 3.18.17, replace with "[+amount]% Yield from every [tileFilter]"
- "+25% Production towards any buildings that already exist in the Capital" - Deprecated as of 3.19.3, replace with "[+25]% Production towards any buildings that already exist in the Capital"
- "City-State Influence degrades [amount]% slower" - Deprecated as of 3.18.17, replace with "[-amount]% City-State Influence degradation"
- "Quantity of Resources gifted by City-States increased by [amount]%" - Deprecated as of 3.18.17, replace with "[+amount]% resources gifted by City-States"
- "Happiness from Luxury Resources gifted by City-States increased by [amount]%" - Deprecated as of 3.18.17, replace with "[+amount]% Happiness from luxury resources gifted by City-States"
- "[amount]% of food is carried over after population increases" - Deprecated as of 3.19.2, replace with "[amount]% Food is carried over after population increases [in this city]"
- "[amount]% of food is carried over [cityFilter] after population increases" - Deprecated as of 3.19.2, replace with "[amount]% Food is carried over after population increases [cityFilter]"
- "[amount]% Culture cost of natural border growth [cityFilter]" - Deprecated as of 3.19.2, replace with "[amount]% Culture cost of natural border growth [cityFilter]"
@ -1539,18 +1534,6 @@ Applicable to: Conditional
- "[amount]% cost of natural border growth" - Deprecated as of 3.19.1, replace with "[amount]% Culture cost of natural border growth [in all cities]"
- "-[amount]% Gold cost of acquiring tiles [cityFilter]" - Deprecated as of 3.19.1, replace with "[-amount]% Gold cost of acquiring tiles [cityFilter]"
- "[stat] cost of purchasing [baseUnitFilter] units in cities [amount]%" - Deprecated as of 3.19.3, replace with "[stat] cost of purchasing [baseUnitFilter] units [amount]%"
- "Maintenance on roads & railroads reduced by [amount]%" - Deprecated as of 3.18.17, replace with "[-amount]% maintenance on road & railroads"
- "-[amount]% maintenance cost for buildings [cityFilter]" - Deprecated as of 3.18.17, replace with "[-amount]% maintenance cost for buildings [cityFilter]"
- "+[amount] happiness from each type of luxury resource" - Deprecated as of 3.18.17, replace with "[+amount] Happiness from each type of luxury resource"
- "Culture cost of adopting new Policies reduced by [amount]%" - Deprecated as of 3.18.17, replace with "[-amount]% Culture cost of adopting new Policies"
- "[amount]% Culture cost of adopting new policies" - Deprecated as of 3.19.1, replace with "[amount]% Culture cost of adopting new Policies"
- "Defensive buildings in all cities are 25% more effective" - Deprecated as of 3.18.17, replace with "[+25]% City Strength from defensive buildings"
- "[amount]% Strength for [mapUnitFilter] units which have another [mapUnitFilter] unit in an adjacent tile" - Deprecated as of 3.18.17, replace with "[amount]% Strength <for [mapUnitFilter] units> <when adjacent to a [mapUnitFilter] unit>"
- "Gold cost of upgrading [baseUnitFilter] units reduced by [amount]%" - Deprecated as of 3.18.17, replace with "[-amount]% Gold cost of upgrading <for [baseUnitFilter] units>"
- "Double gold from Great Merchant trade missions" - Deprecated as of 3.18.17, replace with "[+100]% Gold from Great Merchant trade missions"
- "Golden Age length increased by [amount]%" - Deprecated as of 3.18.17, replace with "[+amount]% Golden Age length"
- "+[amount]% Defensive Strength for cities" - Deprecated as of 3.18.17, replace with "[+amount]% Strength for cities <when defending>"
- "[amount]% Attacking Strength for cities" - Deprecated as of 3.18.17, replace with "[+amount]% Strength for cities <when attacking>"
- "+[amount]% attacking strength for cities with garrisoned units" - Deprecated as of 3.19.1, replace with "[+amount]% Strength for cities <with a garrison> <when attacking>"
- "Can embark and move over Coasts and Oceans immediately" - Deprecated as of 3.19.9, replace with "Enables embarkation for land units <starting from the [Ancient era]>", "Enables embarked units to enter ocean tiles <starting from the [Ancient era]>"
- "Population loss from nuclear attacks -[amount]%" - Deprecated as of 3.19.2, replace with "Population loss from nuclear attacks [-amount]% [in this city]"
@ -1559,6 +1542,23 @@ Applicable to: Conditional
- "Melee units pay no movement cost to pillage" - Deprecated as of 3.18.17, replace with "No movement cost to pillage <for [Melee] units>"
- "Heal adjacent units for an additional 15 HP per turn" - Deprecated as of 3.19.3, replace with "All adjacent units heal [+15] HP when healing"
- "+[amount]% attack strength to all [mapUnitFilter] units for [amount2] turns" - Deprecated as of 3.19.8, replace with "[+amount]% Strength <when attacking> <for [mapUnitFilter] units> <for [amount2] turns>"
- "Golden Age length increased by [amount]%" - Deprecated as of 3.18.17, replace with "[+amount]% Golden Age length"
- "+[amount]% Defensive Strength for cities" - Deprecated as of 3.18.17, replace with "[+amount]% Strength for cities <when defending>"
- "[amount]% Attacking Strength for cities" - Deprecated as of 3.18.17, replace with "[+amount]% Strength for cities <when attacking>"
- "[amount]% Strength for [mapUnitFilter] units which have another [mapUnitFilter] unit in an adjacent tile" - Deprecated as of 3.18.17, replace with "[amount]% Strength <for [mapUnitFilter] units> <when adjacent to a [mapUnitFilter] unit>"
- "Gold cost of upgrading [baseUnitFilter] units reduced by [amount]%" - Deprecated as of 3.18.17, replace with "[-amount]% Gold cost of upgrading <for [baseUnitFilter] units>"
- "Double gold from Great Merchant trade missions" - Deprecated as of 3.18.17, replace with "[+100]% Gold from Great Merchant trade missions"
- "Defensive buildings in all cities are 25% more effective" - Deprecated as of 3.18.17, replace with "[+25]% City Strength from defensive buildings"
- "Maintenance on roads & railroads reduced by [amount]%" - Deprecated as of 3.18.17, replace with "[-amount]% maintenance on road & railroads"
- "-[amount]% maintenance cost for buildings [cityFilter]" - Deprecated as of 3.18.17, replace with "[-amount]% maintenance cost for buildings [cityFilter]"
- "+[amount] happiness from each type of luxury resource" - Deprecated as of 3.18.17, replace with "[+amount] Happiness from each type of luxury resource"
- "Culture cost of adopting new Policies reduced by [amount]%" - Deprecated as of 3.18.17, replace with "[-amount]% Culture cost of adopting new Policies"
- "[amount]% Culture cost of adopting new policies" - Deprecated as of 3.19.1, replace with "[amount]% Culture cost of adopting new Policies"
- "Quantity of Resources gifted by City-States increased by [amount]%" - Deprecated as of 3.18.17, replace with "[+amount]% resources gifted by City-States"
- "City-State Influence degrades [amount]% slower" - Deprecated as of 3.18.17, replace with "[-amount]% City-State Influence degradation"
- "Happiness from Luxury Resources gifted by City-States increased by [amount]%" - Deprecated as of 3.18.17, replace with "[+amount]% Happiness from luxury resources gifted by City-States"
- "+[amount]% [stat] from every [tileFilter/specialist/buildingName]" - Deprecated as of 3.18.17, replace with "[+amount]% [stat] from every [tileFilter/specialist/buildingName]"
- "+[amount]% yield from every [tileFilter]" - Deprecated as of 3.18.17, replace with "[+amount]% Yield from every [tileFilter]"
- "[stats] per turn from cities before [tech/policy]" - Deprecated as of 3.18.14, replace with "[stats] [in all cities] <before discovering [tech]>" OR "[stats] [in all cities] <before adopting [policy]>"
- "[mapUnitFilter] units gain [amount]% more Experience from combat" - Deprecated as of 3.18.12, replace with "[amount]% XP gained from combat <for [mapUnitFilter] units>"
- "[amount]% maintenance costs for [mapUnitFilter] units" - Deprecated as of 3.18.14, replace with "[amount]% maintenance costs <for [mapUnitFilter] units>"