Auto-reload plugin

This commit is contained in:
luboslenco
2019-10-14 10:57:12 +02:00
parent 2ca0d83741
commit 12d13ce989
3 changed files with 12 additions and 20 deletions
+1
View File
@@ -26,6 +26,7 @@ class Plugin {
#if js
untyped __js__("(1, eval)({0})", blob.toString());
#end
iron.data.Data.deleteBlob("plugins/" + plugin);
});
}
catch(e:Dynamic) { trace("Failed to load plugin '" + plugin + "'"); trace(e); }
+10 -19
View File
@@ -78,9 +78,18 @@ class TabPlugins{
}
if (ui.isHovered && ui.inputReleasedR) {
UIMenu.draw(function(ui:Zui) {
ui.fill(0, 0, ui._w / ui.SCALE, ui.t.ELEMENT_H * 4, ui.t.SEPARATOR_COL);
ui.fill(0, 0, ui._w / ui.SCALE, ui.t.ELEMENT_H * 3, ui.t.SEPARATOR_COL);
ui.text(f, Right);
var path = Krom.getFilesLocation() + sep + dataPath + sep + "plugins" + sep + f;
if (ui.button("Edit", Left)) {
#if krom_windows
Krom.sysCommand('"' + path + '"');
#elseif krom_linux
Krom.sysCommand('xdg-open "' + path + '"');
#else
Krom.sysCommand('open "' + path + '"');
#end
}
if (ui.button("Delete", Left)) {
if (Config.raw.plugins.indexOf(f) >= 0) {
Config.raw.plugins.remove(f);
@@ -94,24 +103,6 @@ class TabPlugins{
#end
Krom.sysCommand(cmd + '"' + path + '"');
}
if (ui.button("Edit", Left)) {
#if krom_windows
Krom.sysCommand('"' + path + '"');
#elseif krom_linux
Krom.sysCommand('xdg-open "' + path + '"');
#else
Krom.sysCommand('open "' + path + '"');
#end
}
if (ui.button("Reload", Left)) {
if (Config.raw.plugins.indexOf(f) >= 0) {
Plugin.stop(f);
}
iron.data.Data.deleteBlob("plugins/" + f);
if (Config.raw.plugins.indexOf(f) >= 0) {
Plugin.start(f);
}
}
});
}
}