From bae8bd2468ec710c5f1e870e12440fa03d610dbc Mon Sep 17 00:00:00 2001 From: yairm210 Date: Thu, 23 Sep 2021 12:04:16 +0300 Subject: [PATCH] Mod error detection improvements! Separated Warning vs Error, show "options only" warning in options only, color warnings by severity --- core/src/com/unciv/models/ruleset/Ruleset.kt | 11 +++++++---- .../src/com/unciv/models/ruleset/unique/UniqueType.kt | 6 +++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/src/com/unciv/models/ruleset/Ruleset.kt b/core/src/com/unciv/models/ruleset/Ruleset.kt index ef3143f957..21ecc7301e 100644 --- a/core/src/com/unciv/models/ruleset/Ruleset.kt +++ b/core/src/com/unciv/models/ruleset/Ruleset.kt @@ -296,10 +296,13 @@ class Ruleset { val deprecationAnnotation = unique.type.declaringClass.getField(unique.type.name) .getAnnotation(Deprecated::class.java) if (deprecationAnnotation != null) { - // Not user-visible - lines.add("$name's unique \"${unique.text}\" is deprecated ${deprecationAnnotation.message}," + - " replace with \"${deprecationAnnotation.replaceWith.expression}\"", - RulesetErrorSeverity.WarningOptionsOnly) + val deprecationText = "$name's unique \"${unique.text}\" is deprecated ${deprecationAnnotation.message}," + + " replace with \"${deprecationAnnotation.replaceWith.expression}\"" + val severity = if(deprecationAnnotation.level == DeprecationLevel.WARNING) + RulesetErrorSeverity.WarningOptionsOnly // Not user-visible + else RulesetErrorSeverity.Warning // User visible + + lines.add(deprecationText, severity) } } } diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index ebbdf0a23e..a8a94eeaf8 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -52,11 +52,11 @@ enum class UniqueType(val text:String, vararg target: UniqueTarget) { FreeUnits("[amount] units cost no maintenance", UniqueTarget.Global), UnitMaintenanceDiscount("[amount]% maintenance costs for [mapUnitFilter] units", UniqueTarget.Global), - @Deprecated("As of 3.16.16", ReplaceWith("[amount]% maintenance costs for [mapUnitFilter] units")) + @Deprecated("As of 3.16.16", ReplaceWith("[amount]% maintenance costs for [mapUnitFilter] units"), DeprecationLevel.WARNING) DecreasedUnitMaintenanceCostsByFilter("-[amount]% [mapUnitFilter] unit maintenance costs"), // No conditional support - @Deprecated("As of 3.16.16", ReplaceWith("[amount]% maintenance costs for [mapUnitFilter] units")) + @Deprecated("As of 3.16.16", ReplaceWith("[amount]% maintenance costs for [mapUnitFilter] units"), DeprecationLevel.WARNING) DecreasedUnitMaintenanceCostsGlobally("-[amount]% unit upkeep costs"), // No conditional support - @Deprecated("As of 3.16.16", ReplaceWith("[stats] ")) + @Deprecated("As of 3.16.16", ReplaceWith("[stats] "), DeprecationLevel.WARNING) StatBonusForNumberOfSpecialists("[stats] if this city has at least [amount] specialists"), // No conditional support // TODO: Unify these (I'm in favor of "gain a free" above "provides" because it fits more cases)