diff --git a/core/src/com/unciv/ui/pickerscreens/ModManagementOptions.kt b/core/src/com/unciv/ui/pickerscreens/ModManagementOptions.kt index 4f4570e4dc..7d30e73c47 100644 --- a/core/src/com/unciv/ui/pickerscreens/ModManagementOptions.kt +++ b/core/src/com/unciv/ui/pickerscreens/ModManagementOptions.kt @@ -161,7 +161,7 @@ class ModUIData( val repo: Github.Repo?, var y: Float, var height: Float, - var button: Button + var button: TextButton ) { var state = ModStateImages() // visible only on the 'installed' side - todo? @@ -180,7 +180,7 @@ class ModUIData( null, repo, 0f, 0f, (repo.name + (if (isUpdated) " - {Updated}" else "" )).toTextButton() ) { - state.isUpdated = isUpdated + state.hasUpdate = isUpdated } fun lastUpdated() = ruleset?.modOptions?.lastUpdated ?: repo?.updated_at ?: "" @@ -198,20 +198,20 @@ class ModUIData( /** Helper class keeps references to decoration images of installed mods to enable dynamic visibility * (actually we do not use isVisible but refill a container selectively which allows the aggregate height to adapt and the set to center vertically) * @param visualImage image indicating _enabled as permanent visual mod_ - * @param updatedImage image indicating _online mod has been updated_ + * @param hasUpdateImage image indicating _online mod has been updated_ */ class ModStateImages ( isVisual: Boolean = false, isUpdated: Boolean = false, val visualImage: Image = ImageGetter.getImage("UnitPromotionIcons/Scouting"), - val updatedImage: Image = ImageGetter.getImage("OtherIcons/Mods") + val hasUpdateImage: Image = ImageGetter.getImage("OtherIcons/Mods") ) { /** The table containing the indicators (one per mod, narrow, arranges up to three indicators vertically) */ val container: Table = Table().apply { defaults().size(20f).align(Align.topLeft) } // mad but it's really initializing with the primary constructor parameter and not calling update() var isVisual: Boolean = isVisual set(value) { if (field!=value) { field = value; update() } } - var isUpdated: Boolean = isUpdated + var hasUpdate: Boolean = isUpdated set(value) { if (field!=value) { field = value; update() } } private val spacer = Table().apply { width = 20f; height = 0f } @@ -219,15 +219,15 @@ class ModStateImages ( container.run { clear() if (isVisual) add(visualImage).row() - if (isUpdated) add(updatedImage).row() - if (!isVisual && !isUpdated) add(spacer) + if (hasUpdate) add(hasUpdateImage).row() + if (!isVisual && !hasUpdate) add(spacer) pack() } } fun sortWeight() = when { - isUpdated && isVisual -> 3 - isUpdated -> 2 + hasUpdate && isVisual -> 3 + hasUpdate -> 2 isVisual -> 1 else -> 0 } diff --git a/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt b/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt index 887fa329de..536a7277b0 100644 --- a/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt @@ -230,7 +230,7 @@ class ModManagementScreen( if (installedMod != null) { if (isUpdatedVersionOfInstalledMod) { - installedModInfo[repo.name]!!.state.isUpdated = true + installedModInfo[repo.name]!!.state.hasUpdate = true } if (installedMod.modOptions.author.isEmpty()) { @@ -293,12 +293,12 @@ class ModManagementScreen( lastSyncMarkedButton?.color = Color.WHITE lastSyncMarkedButton = null // look for sync-able same mod in other list - val pos = modNameToData[modName] ?: return + val modUIDataInOtherList = modNameToData[modName] ?: return // scroll into view - scroll.scrollY = (pos.y + (pos.height - scroll.height) / 2).coerceIn(0f, scroll.maxY) + scroll.scrollY = (modUIDataInOtherList.y + (modUIDataInOtherList.height - scroll.height) / 2).coerceIn(0f, scroll.maxY) // and color it so it's easier to find. ROYAL and SLATE too dark. - pos.button.color = Color.valueOf("7499ab") // about halfway between royal and sky - lastSyncMarkedButton = pos.button + modUIDataInOtherList.button.color = Color.valueOf("7499ab") // about halfway between royal and sky + lastSyncMarkedButton = modUIDataInOtherList.button } /** Recreate the information part of the right-hand column @@ -367,7 +367,7 @@ class ModManagementScreen( showModDescription(repo.name) removeRightSideClickListeners() rightSideButton.enable() - val label = if (installedModInfo[repo.name]?.state?.isUpdated == true) + val label = if (installedModInfo[repo.name]?.state?.hasUpdate == true) "Update [${repo.name}]" else "Download [${repo.name}]" rightSideButton.setText(label.tr()) @@ -432,9 +432,9 @@ class ModManagementScreen( * (called under postRunnable posted by background thread) */ private fun unMarkUpdatedMod(name: String) { - installedModInfo[name]?.state?.isUpdated = false - onlineModInfo[name]?.state?.isUpdated = false - val button = (onlineModInfo[name]?.button as? TextButton) + installedModInfo[name]?.state?.hasUpdate = false + onlineModInfo[name]?.state?.hasUpdate = false + val button = onlineModInfo[name]?.button button?.setText(name) if (optionsManager.sortInstalled == SortType.Status) refreshInstalledModTable() @@ -589,11 +589,5 @@ class ModManagementScreen( val blockedModsFile = Gdx.files.internal("jsons/ManuallyBlockedMods.json") JsonParser().getFromJson(Array::class.java, blockedModsFile) } - val modsToHideNames by lazy { - val regex = Regex(""".*/([^/]+)/?$""") - modsToHideAsUrl.map { url -> - regex.replace(url) { it.groups[1]!!.value }.replace('-', ' ') - } - } } }