From 0ef44fc4daab9f0ec89bd2abafc756b111259fda Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 22 Feb 2021 21:13:16 +0200 Subject: [PATCH] Changed deprecated StringBuilder.appendln with .appendLine --- .../com/unciv/app/CrashReportSenderAndroid.kt | 2 +- core/src/com/unciv/models/ruleset/Building.kt | 46 +++++++++---------- .../com/unciv/models/ruleset/tile/Terrain.kt | 18 ++++---- .../models/ruleset/tile/TileImprovement.kt | 12 ++--- .../unciv/models/ruleset/tile/TileResource.kt | 16 +++---- .../com/unciv/models/ruleset/unit/BaseUnit.kt | 22 ++++----- .../unciv/models/ruleset/unit/Promotion.kt | 8 ++-- .../translations/TranslationFileWriter.kt | 8 ++-- .../com/unciv/ui/cityscreen/CityInfoTable.kt | 1 - 9 files changed, 66 insertions(+), 67 deletions(-) diff --git a/android/src/com/unciv/app/CrashReportSenderAndroid.kt b/android/src/com/unciv/app/CrashReportSenderAndroid.kt index 7c1b722f51..6e262ba5fc 100644 --- a/android/src/com/unciv/app/CrashReportSenderAndroid.kt +++ b/android/src/com/unciv/app/CrashReportSenderAndroid.kt @@ -20,7 +20,7 @@ class CrashReportSenderAndroid(private val activity: Activity) : CrashReportSend "OS version: %s\n" + "Device model: %s\n" + "Mods: %s\n" + - "Game data: %s\n" + "Game data: \n%s\n" } override fun sendReport(report: CrashReport) { diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index 4853c33c44..9189945db2 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -95,25 +95,25 @@ class Building : NamedStats(), IConstruction { fun getDescription(forBuildingPickerScreen: Boolean, civInfo: CivilizationInfo?, ruleset: Ruleset): String { val stats = getStats(civInfo) val stringBuilder = StringBuilder() - if (uniqueTo != null) stringBuilder.appendln("Unique to [$uniqueTo], replaces [$replaces]".tr()) - if (!forBuildingPickerScreen) stringBuilder.appendln("{Cost}: $cost".tr()) - if (isWonder) stringBuilder.appendln("Wonder".tr()) - if (isNationalWonder) stringBuilder.appendln("National Wonder".tr()) + if (uniqueTo != null) stringBuilder.appendLine("Unique to [$uniqueTo], replaces [$replaces]".tr()) + if (!forBuildingPickerScreen) stringBuilder.appendLine("{Cost}: $cost".tr()) + if (isWonder) stringBuilder.appendLine("Wonder".tr()) + if (isNationalWonder) stringBuilder.appendLine("National Wonder".tr()) if (!forBuildingPickerScreen && requiredTech != null) - stringBuilder.appendln("Required tech: [$requiredTech]".tr()) + stringBuilder.appendLine("Required tech: [$requiredTech]".tr()) if (!forBuildingPickerScreen && requiredBuilding != null) - stringBuilder.appendln("Requires [$requiredBuilding] to be built in the city".tr()) + stringBuilder.appendLine("Requires [$requiredBuilding] to be built in the city".tr()) if (!forBuildingPickerScreen && requiredBuildingInAllCities != null) - stringBuilder.appendln("Requires [$requiredBuildingInAllCities] to be built in all cities".tr()) + stringBuilder.appendLine("Requires [$requiredBuildingInAllCities] to be built in all cities".tr()) for ((resource, amount) in getResourceRequirements()) { - if (amount == 1) stringBuilder.appendln("Consumes 1 [$resource]".tr()) // For now, to keep the existing translations - else stringBuilder.appendln("Consumes [$amount] [$resource]".tr()) + if (amount == 1) stringBuilder.appendLine("Consumes 1 [$resource]".tr()) // For now, to keep the existing translations + else stringBuilder.appendLine("Consumes [$amount] [$resource]".tr()) } if (providesFreeBuilding != null) - stringBuilder.appendln("Provides a free [$providesFreeBuilding] in the city".tr()) + stringBuilder.appendLine("Provides a free [$providesFreeBuilding] in the city".tr()) if (uniques.isNotEmpty()) { - if (replacementTextForUniques != "") stringBuilder.appendln(replacementTextForUniques) - else stringBuilder.appendln(uniques.asSequence().map { it.tr() }.joinToString("\n")) + if (replacementTextForUniques != "") stringBuilder.appendLine(replacementTextForUniques) + else stringBuilder.appendLine(uniques.asSequence().map { it.tr() }.joinToString("\n")) } if (!stats.isEmpty()) stringBuilder.appendln(stats) @@ -127,28 +127,28 @@ class Building : NamedStats(), IConstruction { if (this.greatPersonPoints != null) { val gpp = this.greatPersonPoints!! - if (gpp.production != 0f) stringBuilder.appendln("+" + gpp.production.toInt() + " " + "[Great Engineer] points".tr()) - if (gpp.gold != 0f) stringBuilder.appendln("+" + gpp.gold.toInt() + " " + "[Great Merchant] points".tr()) - if (gpp.science != 0f) stringBuilder.appendln("+" + gpp.science.toInt() + " " + "[Great Scientist] points".tr()) - if (gpp.culture != 0f) stringBuilder.appendln("+" + gpp.culture.toInt() + " " + "[Great Artist] points".tr()) + if (gpp.production != 0f) stringBuilder.appendLine("+" + gpp.production.toInt() + " " + "[Great Engineer] points".tr()) + if (gpp.gold != 0f) stringBuilder.appendLine("+" + gpp.gold.toInt() + " " + "[Great Merchant] points".tr()) + if (gpp.science != 0f) stringBuilder.appendLine("+" + gpp.science.toInt() + " " + "[Great Scientist] points".tr()) + if (gpp.culture != 0f) stringBuilder.appendLine("+" + gpp.culture.toInt() + " " + "[Great Artist] points".tr()) } for ((specialistName, amount) in newSpecialists()) - stringBuilder.appendln("+$amount " + "[$specialistName] slots".tr()) + stringBuilder.appendLine("+$amount " + "[$specialistName] slots".tr()) if (resourceBonusStats != null) { val resources = ruleset.tileResources.values.filter { name == it.building }.joinToString { it.name.tr() } - stringBuilder.appendln("$resources {provide} $resourceBonusStats".tr()) + stringBuilder.appendLine("$resources {provide} $resourceBonusStats".tr()) } if (requiredNearbyImprovedResources != null) - stringBuilder.appendln(("Requires worked [" + requiredNearbyImprovedResources!!.joinToString("/") { it.tr() } + "] near city").tr()) + stringBuilder.appendLine(("Requires worked [" + requiredNearbyImprovedResources!!.joinToString("/") { it.tr() } + "] near city").tr()) - if (cityStrength != 0) stringBuilder.appendln("{City strength} +".tr() + cityStrength) - if (cityHealth != 0) stringBuilder.appendln("{City health} +".tr() + cityHealth) - if (xpForNewUnits != 0) stringBuilder.appendln("+$xpForNewUnits {XP for new units}".tr()) + if (cityStrength != 0) stringBuilder.appendLine("{City strength} +".tr() + cityStrength) + if (cityHealth != 0) stringBuilder.appendLine("{City health} +".tr() + cityHealth) + if (xpForNewUnits != 0) stringBuilder.appendLine("+$xpForNewUnits {XP for new units}".tr()) if (maintenance != 0) - stringBuilder.appendln("{Maintenance cost}: $maintenance {Gold}".tr()) + stringBuilder.appendLine("{Maintenance cost}: $maintenance {Gold}".tr()) return stringBuilder.toString().trim() } diff --git a/core/src/com/unciv/models/ruleset/tile/Terrain.kt b/core/src/com/unciv/models/ruleset/tile/Terrain.kt index 43cf363123..550dc29bf2 100644 --- a/core/src/com/unciv/models/ruleset/tile/Terrain.kt +++ b/core/src/com/unciv/models/ruleset/tile/Terrain.kt @@ -47,30 +47,30 @@ class Terrain : NamedStats() { fun getDescription(ruleset: Ruleset): String { val sb = StringBuilder() - sb.appendln(this.clone().toString()) + sb.appendLine(this.clone().toString()) if (occursOn.isNotEmpty()) - sb.appendln("Occurs on [${occursOn.joinToString(", ") { it.tr() }}]".tr()) + sb.appendLine("Occurs on [${occursOn.joinToString(", ") { it.tr() }}]".tr()) if (turnsInto != null) - sb.appendln("Placed on [$turnsInto]".tr()) + sb.appendLine("Placed on [$turnsInto]".tr()) val resourcesFound = ruleset.tileResources.values.filter { it.terrainsCanBeFoundOn.contains(name) } if (resourcesFound.isNotEmpty()) - sb.appendln("May contain [${resourcesFound.joinToString(", ") { it.name.tr() }}]".tr()) + sb.appendLine("May contain [${resourcesFound.joinToString(", ") { it.name.tr() }}]".tr()) if(uniques.isNotEmpty()) - sb.appendln(uniques.joinToString { it.tr() }) + sb.appendLine(uniques.joinToString { it.tr() }) if (impassable) - sb.appendln(Constants.impassable.tr()) + sb.appendLine(Constants.impassable.tr()) else - sb.appendln("{Movement cost}: $movementCost".tr()) + sb.appendLine("{Movement cost}: $movementCost".tr()) if (defenceBonus != 0f) - sb.appendln("{Defence bonus}: ".tr() + (defenceBonus * 100).toInt() + "%") + sb.appendLine("{Defence bonus}: ".tr() + (defenceBonus * 100).toInt() + "%") if (rough) - sb.appendln("Rough Terrain".tr()) + sb.appendLine("Rough Terrain".tr()) return sb.toString() } diff --git a/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt b/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt index f7735169bb..948e5fdff5 100644 --- a/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt +++ b/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt @@ -39,14 +39,14 @@ class TileImprovement : NamedStats() { fun getDescription(ruleset: Ruleset, forPickerScreen: Boolean = true): String { val stringBuilder = StringBuilder() val statsDesc = this.clone().toString() - if (statsDesc.isNotEmpty()) stringBuilder.appendln(statsDesc) - if (uniqueTo!=null && !forPickerScreen) stringBuilder.appendln("Unique to [$uniqueTo]".tr()) + if (statsDesc.isNotEmpty()) stringBuilder.appendLine(statsDesc) + if (uniqueTo!=null && !forPickerScreen) stringBuilder.appendLine("Unique to [$uniqueTo]".tr()) if (!terrainsCanBeBuiltOn.isEmpty()) { val terrainsCanBeBuiltOnString: ArrayList = arrayListOf() for (i in terrainsCanBeBuiltOn) { terrainsCanBeBuiltOnString.add(i.tr()) } - stringBuilder.appendln("Can be built on ".tr() + terrainsCanBeBuiltOnString.joinToString(", "))//language can be changed when setting changes. + stringBuilder.appendLine("Can be built on ".tr() + terrainsCanBeBuiltOnString.joinToString(", "))//language can be changed when setting changes. } val statsToResourceNames = HashMap>() for (tr: TileResource in ruleset.tileResources.values.filter { it.improvement == name }) { @@ -56,13 +56,13 @@ class TileImprovement : NamedStats() { statsToResourceNames[statsString]!!.add(tr.name.tr()) } statsToResourceNames.forEach { - stringBuilder.appendln(it.key + " for ".tr() + it.value.joinToString(", ")) + stringBuilder.appendLine(it.key + " for ".tr() + it.value.joinToString(", ")) } - if (techRequired != null) stringBuilder.appendln("Required tech: [$techRequired]".tr()) + if (techRequired != null) stringBuilder.appendLine("Required tech: [$techRequired]".tr()) for(unique in uniques) - stringBuilder.appendln (unique.tr()) + stringBuilder.appendLine(unique.tr()) return stringBuilder.toString() } diff --git a/core/src/com/unciv/models/ruleset/tile/TileResource.kt b/core/src/com/unciv/models/ruleset/tile/TileResource.kt index 15b71be75d..784aac11ef 100644 --- a/core/src/com/unciv/models/ruleset/tile/TileResource.kt +++ b/core/src/com/unciv/models/ruleset/tile/TileResource.kt @@ -23,26 +23,26 @@ class TileResource : NamedStats() { fun getDescription(ruleset: Ruleset): String { val stringBuilder = StringBuilder() - stringBuilder.appendln(resourceType.name.tr()) - stringBuilder.appendln(this.clone().toString()) + stringBuilder.appendLine(resourceType.name.tr()) + stringBuilder.appendLine(this.clone().toString()) val terrainsCanBeBuiltOnString: ArrayList = arrayListOf() terrainsCanBeBuiltOnString.addAll(terrainsCanBeFoundOn.map { it.tr() }) - stringBuilder.appendln("Can be found on ".tr() + terrainsCanBeBuiltOnString.joinToString(", ")) + stringBuilder.appendLine("Can be found on ".tr() + terrainsCanBeBuiltOnString.joinToString(", ")) stringBuilder.appendln() - stringBuilder.appendln("Improved by [$improvement]".tr()) - stringBuilder.appendln("{Bonus stats for improvement}: ".tr() + "$improvementStats".tr()) + stringBuilder.appendLine("Improved by [$improvement]".tr()) + stringBuilder.appendLine("{Bonus stats for improvement}: ".tr() + "$improvementStats".tr()) val buildingsThatConsumeThis = ruleset.buildings.values.filter { it.getResourceRequirements().containsKey(name) } if (buildingsThatConsumeThis.isNotEmpty()) - stringBuilder.appendln("{Buildings that consume this resource}: ".tr() + stringBuilder.appendLine("{Buildings that consume this resource}: ".tr() + buildingsThatConsumeThis.joinToString { it.name.tr() }) val unitsThatConsumeThis = ruleset.units.values.filter { it.getResourceRequirements().containsKey(name) } if (unitsThatConsumeThis.isNotEmpty()) - stringBuilder.appendln("{Units that consume this resource}: ".tr() + stringBuilder.appendLine("{Units that consume this resource}: ".tr() + unitsThatConsumeThis.joinToString { it.name.tr() }) - if (unique != null) stringBuilder.appendln(unique!!.tr()) + if (unique != null) stringBuilder.appendLine(unique!!.tr()) return stringBuilder.toString() } } diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index b762f0482e..8540050378 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -56,30 +56,30 @@ class BaseUnit : INamed, IConstruction { fun getDescription(forPickerScreen: Boolean): String { val sb = StringBuilder() for ((resource, amount) in getResourceRequirements()) { - if (amount == 1) sb.appendln("Consumes 1 [$resource]".tr()) - else sb.appendln("Consumes [$amount]] [$resource]".tr()) + if (amount == 1) sb.appendLine("Consumes 1 [$resource]".tr()) + else sb.appendLine("Consumes [$amount]] [$resource]".tr()) } if (!forPickerScreen) { - if (uniqueTo != null) sb.appendln("Unique to [$uniqueTo], replaces [$replaces]".tr()) - else sb.appendln("{Cost}: $cost".tr()) - if (requiredTech != null) sb.appendln("Required tech: [$requiredTech]".tr()) - if (upgradesTo != null) sb.appendln("Upgrades to [$upgradesTo]".tr()) - if (obsoleteTech != null) sb.appendln("Obsolete with [$obsoleteTech]".tr()) + if (uniqueTo != null) sb.appendLine("Unique to [$uniqueTo], replaces [$replaces]".tr()) + else sb.appendLine("{Cost}: $cost".tr()) + if (requiredTech != null) sb.appendLine("Required tech: [$requiredTech]".tr()) + if (upgradesTo != null) sb.appendLine("Upgrades to [$upgradesTo]".tr()) + if (obsoleteTech != null) sb.appendLine("Obsolete with [$obsoleteTech]".tr()) } if (strength != 0) { sb.append("$strength${Fonts.strength}, ") if (rangedStrength != 0) sb.append("$rangedStrength${Fonts.rangedStrength}, ") if (rangedStrength != 0) sb.append("$range${Fonts.range}, ") } - sb.appendln("$movement${Fonts.movement}") + sb.appendLine("$movement${Fonts.movement}") - if (replacementTextForUniques != "") sb.appendln(replacementTextForUniques) + if (replacementTextForUniques != "") sb.appendLine(replacementTextForUniques) else for (unique in uniques) - sb.appendln(Translations.translateBonusOrPenalty(unique)) + sb.appendLine(Translations.translateBonusOrPenalty(unique)) if (promotions.isNotEmpty()) { sb.append((if (promotions.size == 1) "Free promotion:" else "Free promotions:").tr()) - sb.appendln(promotions.joinToString(", ", " ") { it.tr() }) + sb.appendLine(promotions.joinToString(", ", " ") { it.tr() }) } return sb.toString().trim() diff --git a/core/src/com/unciv/models/ruleset/unit/Promotion.kt b/core/src/com/unciv/models/ruleset/unit/Promotion.kt index e25c78f753..4b9db92ba4 100644 --- a/core/src/com/unciv/models/ruleset/unit/Promotion.kt +++ b/core/src/com/unciv/models/ruleset/unit/Promotion.kt @@ -20,7 +20,7 @@ class Promotion : INamed{ val stringBuilder = StringBuilder() for (unique in uniques + effect) { - stringBuilder.appendln(Translations.translateBonusOrPenalty(unique)) + stringBuilder.appendLine(Translations.translateBonusOrPenalty(unique)) } if(prerequisites.isNotEmpty()) { @@ -28,19 +28,19 @@ class Promotion : INamed{ for (i in prerequisites.filter { promotionsForUnitType.any { promotion -> promotion.name == it } }) { prerequisitesString.add(i.tr()) } - stringBuilder.appendln("{Requires}: ".tr() + prerequisitesString.joinToString(" OR ".tr())) + stringBuilder.appendLine("{Requires}: ".tr() + prerequisitesString.joinToString(" OR ".tr())) } if(forCivilopedia){ if (unitTypes.isNotEmpty()) { val unitTypesString = unitTypes.joinToString(", ") { it.tr() } - stringBuilder.appendln("Available for [$unitTypesString]".tr()) + stringBuilder.appendLine("Available for [$unitTypesString]".tr()) } if (ruleSet!=null) { val freeforUnits = ruleSet.units.filter { it.value.promotions.contains(name) } if (freeforUnits.isNotEmpty()) { val freeforString = freeforUnits.map { it.value.name }.joinToString(", ") { it.tr() } - stringBuilder.appendln("Free for [$freeforString]".tr()) + stringBuilder.appendLine("Free for [$freeforString]".tr()) } } } diff --git a/core/src/com/unciv/models/translations/TranslationFileWriter.kt b/core/src/com/unciv/models/translations/TranslationFileWriter.kt index 33d55dda2a..68180c2758 100644 --- a/core/src/com/unciv/models/translations/TranslationFileWriter.kt +++ b/core/src/com/unciv/models/translations/TranslationFileWriter.kt @@ -89,7 +89,7 @@ object TranslationFileWriter { // this stops lots of line breaks between removed translations in G&K stringBuilder.appendln() } else // copy as-is - stringBuilder.appendln(line) + stringBuilder.appendLine(line) continue } @@ -110,11 +110,11 @@ object TranslationFileWriter { if (translationEntry != null && translationEntry.containsKey(language)) { translationValue = translationEntry[language]!! translationsOfThisLanguage++ - } else stringBuilder.appendln(" # Requires translation!") + } else stringBuilder.appendLine(" # Requires translation!") val lineToWrite = translationKey.replace("\n", "\\n") + " = " + translationValue.replace("\n", "\\n") - stringBuilder.appendln(lineToWrite) + stringBuilder.appendLine(lineToWrite) } countOfTranslatedLines[language] = translationsOfThisLanguage @@ -135,7 +135,7 @@ object TranslationFileWriter { private fun writeLanguagePercentages(percentages: HashMap) { val stringBuilder = StringBuilder() for (entry in percentages) { - stringBuilder.appendln(entry.key + " = " + entry.value) + stringBuilder.appendLine(entry.key + " = " + entry.value) } Gdx.files.local(TranslationFileReader.percentagesFileLocation).writeString(stringBuilder.toString(), false) } diff --git a/core/src/com/unciv/ui/cityscreen/CityInfoTable.kt b/core/src/com/unciv/ui/cityscreen/CityInfoTable.kt index 5929e09b49..b6ffe2710c 100644 --- a/core/src/com/unciv/ui/cityscreen/CityInfoTable.kt +++ b/core/src/com/unciv/ui/cityscreen/CityInfoTable.kt @@ -9,7 +9,6 @@ import com.unciv.logic.city.CityInfo import com.unciv.logic.civilization.GreatPersonManager import com.unciv.models.ruleset.Building import com.unciv.models.stats.Stat -import com.unciv.models.stats.StatMap import com.unciv.models.translations.tr import com.unciv.ui.utils.* import java.text.DecimalFormat