summaryrefslogtreecommitdiff
path: root/dalos-struct.lua
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2009-12-26 20:15:19 +0100
committerPixel <pixel@nobis-crew.org>2009-12-26 20:15:19 +0100
commitef0404604e36a45ea950439c2396eb0ea3b5bdf9 (patch)
treec272438ed960ab16ffe3fb521ab88675668d4d4f /dalos-struct.lua
parent1325aa091d6061913969d6e45775cf5d032c833b (diff)
Template system rework.
Diffstat (limited to 'dalos-struct.lua')
-rw-r--r--dalos-struct.lua34
1 files changed, 32 insertions, 2 deletions
diff --git a/dalos-struct.lua b/dalos-struct.lua
index 7d6b8b0..0835b7d 100644
--- a/dalos-struct.lua
+++ b/dalos-struct.lua
@@ -6,6 +6,8 @@ local function imLoadImage(fname)
end
dalosp.struct = {
+ templates = {},
+
images = {
up = imLoadImage "12-em-up.tga",
down = imLoadImage "12-em-down.tga",
@@ -48,6 +50,7 @@ dalosp.struct = {
},
get_settings = function (self)
+ return { self.extra.entries }
end,
configure = function (self)
@@ -151,6 +154,15 @@ dalosp.struct = {
mx.redraw = "All"
end,
+ gen_template = function (self)
+ return self:get_settings()
+ end,
+
+ apply_template = function (self, data)
+ self.extra.entries = data.entries
+ self:cacheoffset()
+ end,
+
cfg_draw_cb = function (self, lin, col, x1, x2, y1, y2, cv)
if col == 1 then
dalosp.struct.images.plus:cdCanvasPutImageRect(cv, x1 + 3, y2 + 5, 12, 12, 0, 12, 0, 12)
@@ -301,6 +313,8 @@ dalosp.struct = {
obj.cacheoffset = dalosp.struct.cacheoffset
obj.isunique = dalosp.struct.isunique
obj.getunique = dalosp.struct.getunique
+ obj.gen_template = dalosp.struct.gen_template
+ obj.apply_template = dalosp.struct.apply_template
obj:cacheoffset()
@@ -350,7 +364,19 @@ dalosp.struct = {
iup.fill {},
iup.button {
title = "Ok",
- action = function (self) return iup.CLOSE end
+ action = function (self) return iup.CLOSE end,
+ },
+ iup.button {
+ title = "Import",
+ action = function() obj:load_template() return iup.CLOSE end,
+ },
+ iup.button {
+ title = "Export",
+ action = function() obj:save_template(self:gen_template()) end,
+ },
+ iup.button {
+ title = "Use Template",
+ action = function() obj:use_template() end,
},
iup.fill {},
},
@@ -367,7 +393,11 @@ dalosp.struct = {
return obj
end,
+
+ register_template = function (data, tname)
+ dalosp.struct.templates[tname] = data
+ end,
}
dalos.struct = dalosp.struct.create
-dalos:register_obj("Struct", dalos.struct, "Programmable")
+dalos:register_obj("Struct", dalos.struct, "Programmable", dalosp.struct.register_template)