Added button to update an installed mod from its action menu (#6005)

Much easier and more intuitive than clicking on it, then on the equivalent online mod, then 'download'
This commit is contained in:
Yair Morgenstern 2022-01-22 20:35:19 +02:00 committed by GitHub
parent bebc2c7e21
commit 7e59e28f1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -400,13 +400,13 @@ class ModManagementScreen(
refreshInstalledModTable()
showModDescription(repo.name)
unMarkUpdatedMod(repo.name)
postAction()
}
} catch (ex: Exception) {
postCrashHandlingRunnable {
ToastPopup("Could not download [${repo.name}]", this)
postAction()
}
} finally {
postAction()
}
}
}
@ -452,11 +452,10 @@ class ModManagementScreen(
// offer 'permanent visual mod' toggle
val visualMods = game.settings.visualMods
val isVisual = visualMods.contains(mod.name)
installedModInfo[mod.name]?.state?.isVisual = isVisual
val isVisualMod = visualMods.contains(mod.name)
installedModInfo[mod.name]!!.state.isVisual = isVisualMod
val visualCheckBox = "Permanent audiovisual mod".toCheckBox(isVisual) {
checked ->
val visualCheckBox = "Permanent audiovisual mod".toCheckBox(isVisualMod) { checked ->
if (checked)
visualMods.add(mod.name)
else
@ -468,12 +467,18 @@ class ModManagementScreen(
refreshInstalledModTable()
}
modActionTable.add(visualCheckBox).row()
if (installedModInfo[mod.name]!!.state.hasUpdate) {
val updateModTextbutton = "Update [${mod.name}]".toTextButton()
updateModTextbutton.onClick {
updateModTextbutton.setText("Downloading...".tr())
val repo = onlineModInfo[mod.name]!!.repo!!
downloadMod(repo) { refreshInstalledModActions(mod) }
}
modActionTable.add(updateModTextbutton)
}
}
/*
*/
/** Rebuild the left-hand column containing all installed mods */
internal fun refreshInstalledModTable() {
// pre-init if not already done - important: keep the ModUIData instances later on or