mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-24 03:53:12 -04:00
Fix mod names with dashes in them (#13523)
* Fix mod names with three dashes * Fix display of mods with three dashes in the name * Remove unneeded Ruleset call
This commit is contained in:
parent
7adf726580
commit
d0b43599d9
@ -74,6 +74,8 @@ class ModManagementScreen private constructor(
|
|||||||
const val maxAllowedPreviewImageSize = 200f
|
const val maxAllowedPreviewImageSize = 200f
|
||||||
/** Github queries use this limit */
|
/** Github queries use this limit */
|
||||||
const val amountPerPage = 100
|
const val amountPerPage = 100
|
||||||
|
|
||||||
|
fun cleanModName(modName: String): String = modName.replace(" ", " - ")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since we're `RecreateOnResize`, preserve the portrait/landscape mode for our lifetime
|
// Since we're `RecreateOnResize`, preserve the portrait/landscape mode for our lifetime
|
||||||
@ -466,8 +468,8 @@ class ModManagementScreen private constructor(
|
|||||||
|
|
||||||
rightSideButton.isVisible = true
|
rightSideButton.isVisible = true
|
||||||
rightSideButton.enable()
|
rightSideButton.enable()
|
||||||
val label = if (installedModInfo[repo.name]?.hasUpdate == true) "Update [${repo.name}]"
|
val label = if (installedModInfo[repo.name]?.hasUpdate == true) "Update [${cleanModName(repo.name)}]"
|
||||||
else "Download [${repo.name}]"
|
else "Download [${cleanModName(repo.name)}]"
|
||||||
rightSideButton.setText(label.tr())
|
rightSideButton.setText(label.tr())
|
||||||
rightSideButton.clearActivationActions(ActivationTypes.Tap)
|
rightSideButton.clearActivationActions(ActivationTypes.Tap)
|
||||||
rightSideButton.onClick {
|
rightSideButton.onClick {
|
||||||
@ -556,7 +558,7 @@ class ModManagementScreen private constructor(
|
|||||||
}
|
}
|
||||||
onlineModInfo[name]?.run {
|
onlineModInfo[name]?.run {
|
||||||
hasUpdate = false
|
hasUpdate = false
|
||||||
modButtons[this]?.setText(name)
|
modButtons[this]?.setText(cleanModName(name))
|
||||||
}
|
}
|
||||||
if (optionsManager.sortInstalled == SortType.Status)
|
if (optionsManager.sortInstalled == SortType.Status)
|
||||||
refreshInstalledModTable()
|
refreshInstalledModTable()
|
||||||
@ -636,7 +638,7 @@ class ModManagementScreen private constructor(
|
|||||||
|
|
||||||
syncInstalledSelected(mod.name, button)
|
syncInstalledSelected(mod.name, button)
|
||||||
refreshInstalledModActions(mod.ruleset!!)
|
refreshInstalledModActions(mod.ruleset!!)
|
||||||
val deleteText = "Delete [${mod.name}]"
|
val deleteText = "Delete [${cleanModName(mod.name)}]"
|
||||||
rightSideButton.setText(deleteText.tr())
|
rightSideButton.setText(deleteText.tr())
|
||||||
// Don't let the player think he can delete Vanilla and G&K rulesets
|
// Don't let the player think he can delete Vanilla and G&K rulesets
|
||||||
rightSideButton.isEnabled = mod.ruleset.folderLocation!=null
|
rightSideButton.isEnabled = mod.ruleset.folderLocation!=null
|
||||||
@ -652,7 +654,7 @@ class ModManagementScreen private constructor(
|
|||||||
) {
|
) {
|
||||||
deleteMod(mod.ruleset)
|
deleteMod(mod.ruleset)
|
||||||
modActionTable.clear()
|
modActionTable.clear()
|
||||||
rightSideButton.setText("[${mod.name}] was deleted.".tr())
|
rightSideButton.setText("[${cleanModName(mod.name)}] was deleted.".tr())
|
||||||
}.open()
|
}.open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.unciv.models.metadata.ModCategories
|
|||||||
import com.unciv.models.ruleset.Ruleset
|
import com.unciv.models.ruleset.Ruleset
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.components.fonts.Fonts
|
import com.unciv.ui.components.fonts.Fonts
|
||||||
|
import com.unciv.ui.screens.modmanager.ModManagementScreen
|
||||||
|
|
||||||
/** Helper class holds combined mod info for ModManagementScreen, used for both installed and online lists.
|
/** Helper class holds combined mod info for ModManagementScreen, used for both installed and online lists.
|
||||||
*
|
*
|
||||||
@ -44,8 +45,8 @@ class ModUIData private constructor(
|
|||||||
fun author() = ruleset?.modOptions?.author ?: repo?.owner?.login ?: ""
|
fun author() = ruleset?.modOptions?.author ?: repo?.owner?.login ?: ""
|
||||||
fun topics() = ruleset?.modOptions?.topics ?: repo?.topics ?: emptyList()
|
fun topics() = ruleset?.modOptions?.topics ?: repo?.topics ?: emptyList()
|
||||||
fun buttonText() = when {
|
fun buttonText() = when {
|
||||||
ruleset != null -> ruleset.name
|
ruleset != null -> ModManagementScreen.cleanModName(ruleset.name)
|
||||||
repo != null -> repo.name + (if (hasUpdate) " - {Updated}" else "")
|
repo != null -> ModManagementScreen.cleanModName(repo.name) + (if (hasUpdate) " - {Updated}" else "")
|
||||||
else -> ""
|
else -> ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import com.unciv.ui.components.extensions.toCheckBox
|
|||||||
import com.unciv.ui.components.input.onChange
|
import com.unciv.ui.components.input.onChange
|
||||||
import com.unciv.ui.components.widgets.ExpanderTab
|
import com.unciv.ui.components.widgets.ExpanderTab
|
||||||
import com.unciv.ui.components.widgets.UncivTextField
|
import com.unciv.ui.components.widgets.UncivTextField
|
||||||
|
import com.unciv.ui.screens.modmanager.ModManagementScreen
|
||||||
import com.unciv.ui.popups.ToastPopup
|
import com.unciv.ui.popups.ToastPopup
|
||||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||||
import com.unciv.utils.Concurrency
|
import com.unciv.utils.Concurrency
|
||||||
@ -57,6 +58,7 @@ class ModCheckboxTable(
|
|||||||
|
|
||||||
for (mod in modRulesets.sortedBy { it.name }) {
|
for (mod in modRulesets.sortedBy { it.name }) {
|
||||||
val checkBox = mod.name.toCheckBox(mod.name in mods)
|
val checkBox = mod.name.toCheckBox(mod.name in mods)
|
||||||
|
checkBox.setText(ModManagementScreen.cleanModName(mod.name))
|
||||||
checkBox.onChange {
|
checkBox.onChange {
|
||||||
// Checks are run in parallel thread to avoid ANRs
|
// Checks are run in parallel thread to avoid ANRs
|
||||||
Concurrency.run { checkBoxChanged(checkBox, mod) }
|
Concurrency.run { checkBoxChanged(checkBox, mod) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user