Skip to content

Commit 15a8cb2

Browse files
committed
Toolbox: add macro to configure per-script settings
still incomplete (not available for modules and some settings missing)
1 parent 1ae5a7a commit 15a8cb2

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

macros/l0.DependencyControl.Toolbox.moon

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ msgs = {
2222
lockedFiles: "%s Some script files are still in use and will be deleted during the next restart/reload."
2323
error: "Error: %s"
2424
}
25+
macroConfig: {
26+
hints: {
27+
customMenu: "Lets you sort your automation macros into submenus. Use / to denote submenu levels."
28+
userFeed: "When set the updater will use this feed exclusively to update the script in question."
29+
}
30+
}
2531
}
2632

2733
-- Shared Functions
@@ -167,9 +173,36 @@ update = ->
167173
runUpdaterTask mdl, res.exhaustive
168174
runUpdaterTask macro, res.exhaustive
169175

176+
macroConfig = ->
177+
config = getConfig "macros"
178+
179+
dlg, i = {}, 1
180+
for nsp, macro in pairs config.userConfig
181+
dlg[i*5+t-1] = tbl for t, tbl in ipairs {
182+
{label: macro.name, class: "label", x: 0, y: i, width: 1, height: 1 },
183+
{label: "Menu Group: ", class: "label", x: 1, y: i, width: 1, height: 1 },
184+
{name: "#{nsp}.customMenu", class: "edit", x: 2, y: i, width: 1, height: 1,
185+
text: macro.customMenu or "", hint: msgs.macroConfig.hints.customMenu },
186+
{label: "Custom Update Feed: ", class: "label", x: 3, y: i, width: 1, height: 1 },
187+
{name: "#{nsp}.userFeed", class: "edit", x: 4, y: i, width: 1, height: 1,
188+
text: macro.userFeed or "", hint: msgs.macroConfig.hints.userFeed }
189+
}
190+
i += 1
191+
btn, res = aegisub.dialog.display dlg
192+
return unless btn
193+
194+
for k, v in pairs res
195+
nsp, prop = k\match "(.+)%.(.+)"
196+
if config.c[nsp][prop] and v == ""
197+
config.c[nsp][prop] = nil
198+
elseif v != ""
199+
config.c[nsp][prop] = v
200+
201+
config\write!
170202

171203
depRec\registerMacros{
172204
{"Install Script", "Installs an automation script or module on your system.", install},
173205
{"Update Script", "Manually check and perform updates to any installed script.", update},
174206
{"Uninstall Script", "Removes an automation script or module from your system.", uninstall},
207+
{"Macro Configuration", "Lets you change per-automation script settings.", macroConfig},
175208
}

0 commit comments

Comments
 (0)