From 2a3a6f746d8a667dbd0d6e3d1857f3aa739db420 Mon Sep 17 00:00:00 2001 From: line0 Date: Sat, 2 May 2015 22:22:48 +0200 Subject: [PATCH] Toolbox: hide DependencyControl and its dependencies from the uninstall list to prevent accidents --- macros/l0.DependencyControl.Toolbox.moon | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/macros/l0.DependencyControl.Toolbox.moon b/macros/l0.DependencyControl.Toolbox.moon index 6bb348a..19321df 100644 --- a/macros/l0.DependencyControl.Toolbox.moon +++ b/macros/l0.DependencyControl.Toolbox.moon @@ -29,9 +29,14 @@ msgs = { -- Shared Functions -buildInstalledDlgList = (scriptType, config) -> - list, map = {}, {} +buildInstalledDlgList = (scriptType, config, isUninstall) -> + list, map, protectedModules = {}, {}, {} + if isUninstall + protectedModules[mdl.moduleName] = true for mdl in *DepCtrl.version.requiredModules + protectedModules[DepCtrl.version.moduleName] = true + for namespace, script in pairs config.c[scriptType] + continue if protectedModules[namespace] item = "%s v%s%s"\format script.name, depRec\getVersionString(script.version), script.activeChannel and " [#{script.activeChannel}]" or "" list[#list+1] = item @@ -145,8 +150,8 @@ uninstall = -> config = getConfig! -- build macro and module lists as well as reverse mappings - moduleList, moduleMap = buildInstalledDlgList "modules", config - macroList, macroMap = buildInstalledDlgList "macros", config + moduleList, moduleMap = buildInstalledDlgList "modules", config, true + macroList, macroMap = buildInstalledDlgList "macros", config, true btn, res = aegisub.dialog.display getScriptListDlg macroList, moduleList return unless btn