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,16 +400,16 @@ class ModManagementScreen(
refreshInstalledModTable() refreshInstalledModTable()
showModDescription(repo.name) showModDescription(repo.name)
unMarkUpdatedMod(repo.name) unMarkUpdatedMod(repo.name)
postAction()
} }
} catch (ex: Exception) { } catch (ex: Exception) {
postCrashHandlingRunnable { postCrashHandlingRunnable {
ToastPopup("Could not download [${repo.name}]", this) ToastPopup("Could not download [${repo.name}]", this)
}
} finally {
postAction() postAction()
} }
} }
} }
}
/** Rewrite modOptions file for a mod we just installed to include metadata we got from the GitHub api /** Rewrite modOptions file for a mod we just installed to include metadata we got from the GitHub api
* *
@ -452,11 +452,10 @@ class ModManagementScreen(
// offer 'permanent visual mod' toggle // offer 'permanent visual mod' toggle
val visualMods = game.settings.visualMods val visualMods = game.settings.visualMods
val isVisual = visualMods.contains(mod.name) val isVisualMod = visualMods.contains(mod.name)
installedModInfo[mod.name]?.state?.isVisual = isVisual installedModInfo[mod.name]!!.state.isVisual = isVisualMod
val visualCheckBox = "Permanent audiovisual mod".toCheckBox(isVisual) { val visualCheckBox = "Permanent audiovisual mod".toCheckBox(isVisualMod) { checked ->
checked ->
if (checked) if (checked)
visualMods.add(mod.name) visualMods.add(mod.name)
else else
@ -468,11 +467,17 @@ class ModManagementScreen(
refreshInstalledModTable() refreshInstalledModTable()
} }
modActionTable.add(visualCheckBox).row() 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 */ /** Rebuild the left-hand column containing all installed mods */
internal fun refreshInstalledModTable() { internal fun refreshInstalledModTable() {