diff options
-rw-r--r-- | dalos-binaryops.lua | 3 | ||||
-rw-r--r-- | dalos-hexview.lua | 1 | ||||
-rw-r--r-- | dalos-input.lua | 3 | ||||
-rw-r--r-- | dalos-limiter.lua | 1 | ||||
-rw-r--r-- | dalos-textbuffer.lua | 3 | ||||
-rw-r--r-- | dalos.lua | 82 |
6 files changed, 65 insertions, 28 deletions
diff --git a/dalos-binaryops.lua b/dalos-binaryops.lua index 095e7eb..17c9b63 100644 --- a/dalos-binaryops.lua +++ b/dalos-binaryops.lua @@ -100,6 +100,7 @@ Maximize: %b[No,Yes]{Check if you want to maximize the output} tab.default_name = "Binary Ops"
tab.draw = dalosp.binaryops.draw
tab.get_settings = dalosp.binaryops.get_settings
+ tab.ntype = "Binary Ops"
local extra = { }
if settings then extra.op = settings.op extra.maximize = settings.maximize end
@@ -108,4 +109,4 @@ Maximize: %b[No,Yes]{Check if you want to maximize the output} }
dalos.binaryops = dalosp.binaryops.create
-dalos:register_obj("Binary Ops", dalos.binaryops)
\ No newline at end of file +dalos:register_obj("Binary Ops", dalos.binaryops)
diff --git a/dalos-hexview.lua b/dalos-hexview.lua index f3111d7..26eaa77 100644 --- a/dalos-hexview.lua +++ b/dalos-hexview.lua @@ -113,6 +113,7 @@ dalosp.hexview = { tab.ninputs = 1
tab.noutputs = 12
tab.default_name = "Hexview"
+ tab.ntype = "Hexview"
local extra = { }
diff --git a/dalos-input.lua b/dalos-input.lua index 7588046..86dce5a 100644 --- a/dalos-input.lua +++ b/dalos-input.lua @@ -1,6 +1,6 @@ dalosp.input = {
get_settings = function (self)
- return { filename = extra.filename }
+ return { filename = self.extra.filename }
end,
configure = function (self)
@@ -25,6 +25,7 @@ dalosp.input = { tab.otype = dalos.objtype.HANDLE
tab.configure = dalosp.input.configure
tab.default_name = "Input"
+ tab.ntype = "Input"
tab.get_settings = dalosp.input.get_settings
local extra = { }
if settings then extra.filename = settings.filename end
diff --git a/dalos-limiter.lua b/dalos-limiter.lua index 8454775..d27c0b5 100644 --- a/dalos-limiter.lua +++ b/dalos-limiter.lua @@ -44,6 +44,7 @@ Limit: %i{The actual size this limiter is going to produce} tab.configure = dalosp.limiter.configure
tab.input_change = dalosp.limiter.input_change
tab.default_name = "Limiter"
+ tab.ntype = "Limiter"
tab.get_settings = dalosp.limiter.get_settings
local extra = { }
if settings then extra.limit = settings.limit end
diff --git a/dalos-textbuffer.lua b/dalos-textbuffer.lua index 5b15e5f..d52bb76 100644 --- a/dalos-textbuffer.lua +++ b/dalos-textbuffer.lua @@ -1,6 +1,6 @@ dalosp.textbuffer = {
get_settings = function (self)
- return { text = extra.text }
+ return { text = self.extra.text }
end,
activate = function (self)
@@ -20,6 +20,7 @@ dalosp.textbuffer = { tab.otype = dalos.objtype.HANDLE
tab.activate = dalosp.textbuffer.activate
tab.default_name = "Text Buffer"
+ tab.ntype = "Text Buffer"
tab.get_settings = dalosp.textbuffer.get_settings
local extra = { }
if settings then extra.text = settings.text end
@@ -7,8 +7,8 @@ load "iupe-tview.lua" if not dalosp then dalosp = {} end if not dalos then dalos = {} end -dalos.objects = {} -dalos.objects_by_name = {} +dalos.objectstypes = {} +dalos.objectstypes_by_name = {} dalosp.NORTH = 1 dalosp.SOUTH = 2 @@ -17,11 +17,11 @@ dalosp.EAST = 4 dalosp.cross = { } function dalos:register_obj(name, constructor) - if self.objects_by_name[name] then + if self.objectstypes_by_name[name] then error("An object of that name already exists: " .. name) end - table.insert(self.objects, { name = name, constructor = constructor, counter = 1 }) - self.objects_by_name[name] = #self.objects + table.insert(self.objectstypes, { name = name, constructor = constructor, counter = 1 }) + self.objectstypes_by_name[name] = #self.objectstypes if self.activemenu then self.activemenu:update_objects() end @@ -427,6 +427,39 @@ dalosp.menu = { end, action_save = function(self) + local s_obj = { } + if not dalos.active_canvas then return end + local d = dalos.active_canvas + for i, v in ipairs(d.objects) do + s_obj[i] = { x = v.x, y = v.y, name = v.obj.name, ntype = v.obj.ntype, settings = v.obj:get_settings(), lookup = v } + end + local s_links = { } + for iobj, obj in ipairs(d.objects) do + for iout, out in pairs(obj.obj.outputs) do + for ilookup, lobj in ipairs(s_obj) do + if lobj.lookup == out.obj then + table.insert(s_links, { src = iobj, dst = ilookup, isrc = iout, idst = out.ind }) + end + end + end + end + for i, v in ipairs(s_obj) do + v.lookup = nil + end + local save = { objects = s_obj, links = s_links } + local dlg = iup.filedlg { + dialogtype = "Save", + } + iup.Popup(dlg) + if dlg.status ~= -1 then + print(dlg.value) + local s, v = pcall(Output, dlg.value) + if s then + v:write "local " + dumpvars(v, save, "save") + v:write "return save" + end + end end, action_exit = function (self) @@ -484,25 +517,23 @@ dalosp.menu = { local east_menu = { radio = "1" } local west_menu = { radio = "1" } local south_menu = { radio = "1" } - if type(dalos.objects) == "table" then - local item - for k, v in ipairs(dalos.objects) do - item = iup.item { title = v.name } - item.action = function (self) dalosp.menu.add_object(canvas, v) end - table.insert(add_menu, item) - item = iup.item { title = v.name } - item.action = function (self) dalosp.menu.set_cross(canvas, v, dalosp.NORTH) end - table.insert(north_menu, item) - item = iup.item { title = v.name } - item.action = function (self) dalosp.menu.set_cross(canvas, v, dalosp.EAST) end - table.insert(east_menu, item) - item = iup.item { title = v.name } - item.action = function (self) dalosp.menu.set_cross(canvas, v, dalosp.WEST) end - table.insert(west_menu, item) - item = iup.item { title = v.name } - item.action = function (self) dalosp.menu.set_cross(canvas, v, dalosp.SOUTH) end - table.insert(south_menu, item) - end + local item + for k, v in ipairs(dalos.objectstypes) do + item = iup.item { title = v.name } + item.action = function (self) dalosp.menu.add_object(canvas, v) end + table.insert(add_menu, item) + item = iup.item { title = v.name } + item.action = function (self) dalosp.menu.set_cross(canvas, v, dalosp.NORTH) end + table.insert(north_menu, item) + item = iup.item { title = v.name } + item.action = function (self) dalosp.menu.set_cross(canvas, v, dalosp.EAST) end + table.insert(east_menu, item) + item = iup.item { title = v.name } + item.action = function (self) dalosp.menu.set_cross(canvas, v, dalosp.WEST) end + table.insert(west_menu, item) + item = iup.item { title = v.name } + item.action = function (self) dalosp.menu.set_cross(canvas, v, dalosp.SOUTH) end + table.insert(south_menu, item) end local menu_file = iup.submenu { iup.menu { item_load, item_save, iup.separator {}, item_exit }, title = "File" } local menu_add = iup.submenu { iup.menu(add_menu), title = "Add" } @@ -623,6 +654,7 @@ dalosp.object = { outputs = {}, curinput = 1, curoutput = 1, + ntype = tab.ntype, quicksetting = tab.quicksetting, otype = tab.otype or dalos.objtype.DUMMY, activate = tab.activate or dalosp.object.default_activate, @@ -635,7 +667,7 @@ dalosp.object = { input_change = tab.input_change or dalosp.object.default_inputchange, output_change = tab.output_change or dalosp.object.default_outputchange, set_houtput = dalosp.object.set_houtput, - get_settings = tab.get_setings or dalosp.object.default_get_settings, + get_settings = tab.get_settings or dalosp.object.default_get_settings, houtputs = {}, get_linked_input = dalosp.object.get_linked_input, dcanvas = dcanvas, |