Skip to content

Commit

Permalink
Merge branch 'refs/heads/dev/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
fzzyhmstrs committed Oct 14, 2024
2 parents c90ecb2 + 1be8a8f commit f294890
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* None.

### Changes
* None.
* Config settings with names that don't fit into the row (truncated with ellipses) will now have the full name appear in the tooltip

### Fixes
* Translatable things now properly have their translations respected if they are wrapped with automatic validation.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ internal open class BaseConfigEntry(

private fun createTooltip(): List<OrderedText> {
val list: MutableList<OrderedText> = mutableListOf()
if (truncatedName != name) {
list.addAll(MinecraftClient.getInstance().textRenderer.wrapLines(name, 190))
if (description.string != "")
list.add(FcText.empty().asOrderedText())
}
if (description.string != "") {
list.addAll(MinecraftClient.getInstance().textRenderer.wrapLines(description, 190))
}
Expand All @@ -135,6 +140,10 @@ internal open class BaseConfigEntry(

private fun createFullTooltip(): List<OrderedText> {
val list: MutableList<OrderedText> = mutableListOf()
if (truncatedName != name) {
list.addAll(MinecraftClient.getInstance().textRenderer.wrapLines(name, 190))
list.add(FcText.empty().asOrderedText())
}
if (description.string != "") {
list.addAll(MinecraftClient.getInstance().textRenderer.wrapLines(description, 190))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,19 @@ open class ValidatedAny<T: Any>(defaultValue: T): ValidatedField<T>(defaultValue
}

override fun translationKey(): String {
return (storedValue as? Translatable)?.hasTranslation()?.let { (storedValue as? Translatable)?.translationKey() } ?: super.translationKey()
return (storedValue as? Translatable)?.translationKey()?.takeIf { (storedValue as? Translatable)?.hasTranslation() == true } ?: super.translationKey()
}

override fun descriptionKey(): String {
return (storedValue as? Translatable)?.hasDescription()?.let { (storedValue as? Translatable)?.descriptionKey() } ?: super.descriptionKey()
return (storedValue as? Translatable)?.descriptionKey()?.takeIf { (storedValue as? Translatable)?.hasDescription() == true } ?: super.descriptionKey()
}

override fun translation(fallback: String?): MutableText {
return (storedValue as? Translatable)?.hasTranslation()?.let { (storedValue as? Translatable)?.translation(fallback) } ?: super.translation(fallback)
return (storedValue as? Translatable)?.translation(fallback)?.takeIf { (storedValue as? Translatable)?.hasTranslation() == true } ?: super.translation(fallback)
}

override fun description(fallback: String?): MutableText {
return (storedValue as? Translatable)?.hasDescription()?.let { (storedValue as? Translatable)?.description(fallback) } ?: super.description(fallback)
return (storedValue as? Translatable)?.description(fallback)?.takeIf { (storedValue as? Translatable)?.hasDescription() == true } ?: super.description(fallback)
}

override fun hasTranslation(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"fzzy_config_test.test_config.EPSILON" : "Epsilon",
"fzzy_config_test.test_config.EPSILON.desc" : "The fifth choice",
"fzzy_config_test.test_config.list1" : "Very Wow Long List Name For Testing",
"fzzy_config_test.test_config.list1.desc" : "such description. much tip.",

"fzzy_config_test.test_config2.int1" : "Test integer",
"fzzy_config_test.test_config2.int1.desc" : "Integers have cool descriptions",
Expand Down

0 comments on commit f294890

Please sign in to comment.