aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr/GuiLua/skang.lua
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-04-20 04:51:19 +1000
committerDavid Walter Seikel2014-04-20 04:51:19 +1000
commit407dee6650c6fbb8506146eda91428155890c623 (patch)
tree13a63b74a71f5edb67c4c453d59111edb3a6f4fc /ClientHamr/GuiLua/skang.lua
parentTrying to add widget actions, but it's broken somehow. Think maybe Keyed is ... (diff)
downloadSledjHamr-407dee6650c6fbb8506146eda91428155890c623.zip
SledjHamr-407dee6650c6fbb8506146eda91428155890c623.tar.gz
SledjHamr-407dee6650c6fbb8506146eda91428155890c623.tar.bz2
SledjHamr-407dee6650c6fbb8506146eda91428155890c623.tar.xz
Fix up widget action stuff.
Diffstat (limited to 'ClientHamr/GuiLua/skang.lua')
-rw-r--r--ClientHamr/GuiLua/skang.lua15
1 files changed, 9 insertions, 6 deletions
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua
index e6b6725..fdd61de 100644
--- a/ClientHamr/GuiLua/skang.lua
+++ b/ClientHamr/GuiLua/skang.lua
@@ -881,7 +881,9 @@ thingasm = function (names, ...)
881 local args, err = loadstring('return ' .. thingy.widget) 881 local args, err = loadstring('return ' .. thingy.widget)
882 if args then 882 if args then
883 setfenv(args, parent) 883 setfenv(args, parent)
884 parent.W[name] = {widget = widget(args())} 884 local result = widget(args())
885print('NO IDEA WHY this does isValid() three times on the action, and the first one being a string.')
886 parent.W[name] = {Cwidget = result}
885 else 887 else
886 print("ERROR - " .. err) 888 print("ERROR - " .. err)
887 end 889 end
@@ -1025,21 +1027,21 @@ thingasm('nada', 'Do nothing.', function () --[[ This function intentionally lef
1025local widgets = {} 1027local widgets = {}
1026--thingasm{widgets, 'window', 'The window.', types='userdata'} 1028--thingasm{widgets, 'window', 'The window.', types='userdata'}
1027thingasm{widgets, 'W', 'Holds all the widgets', types='Keyed'} 1029thingasm{widgets, 'W', 'Holds all the widgets', types='Keyed'}
1028widgets.W{'widget', 'The widget.', types='userdata'} 1030widgets.W{'Cwidget', 'The widget.', types='userdata'}
1029widgets.W{'action,a', 'The action for the widget.', 'nada', types='string'} 1031widgets.W{'action,a', 'The action for the widget.', 'nada', types='string'}
1030local aIsValid = function (self, parent) 1032local aIsValid = function (self, parent)
1031 local result = Thing.isValid(self, parent) 1033 local result = Thing.isValid(self, parent)
1032 1034
1033 if result then 1035 if result then
1034 local value = parent[self.names[1] ] 1036 local value = parent[self.names[1] ]
1035print('NEW ACTION - ' .. self.names[1] .. ' = ' .. value) 1037print('NEW ACTION - ' .. self.names[1] .. ' = ' .. value .. ' ' .. type(parent.Cwidget))
1036--printTableStart(parent, '', 'parent') 1038 action(parent.Cwidget, value)
1037 action(parent.widget, value)
1038 end 1039 end
1039 return result 1040 return result
1040end 1041end
1041 1042
1042widgets.W{'look,l', 'The look of the widget.', types='string'} 1043widgets.W{'look,l', 'The look of the widget.', types='string'}
1044--[[
1043widgets.W{'colour,color,c', 'The colours of the widget.', types='table'} 1045widgets.W{'colour,color,c', 'The colours of the widget.', types='table'}
1044widgets.W.c{'red,r', 'The red colour of the widget.', 255, types='number'} 1046widgets.W.c{'red,r', 'The red colour of the widget.', 255, types='number'}
1045widgets.W.c{'green,g', 'The green colour of the widget.', 255, types='number'} 1047widgets.W.c{'green,g', 'The green colour of the widget.', 255, types='number'}
@@ -1051,11 +1053,12 @@ local wMum = getmetatable(widgets.W.c)
1051wMum.__call = function (func, ...) 1053wMum.__call = function (func, ...)
1052 return Colour(func, ...) 1054 return Colour(func, ...)
1053end 1055end
1056]]
1054 1057
1055window = function(w, h, title, name) 1058window = function(w, h, title, name)
1056 name = name or 'myWindow' 1059 name = name or 'myWindow'
1057 local win = {} 1060 local win = {}
1058 win.W = copy(widgets.W, name) 1061 win = copy(widgets, name)
1059 local wMum, wThingy = getStuffed(win.W, 'a') 1062 local wMum, wThingy = getStuffed(win.W, 'a')
1060 wThingy.isValid = aIsValid 1063 wThingy.isValid = aIsValid
1061 win.window = Cwindow(w, h, title, name) 1064 win.window = Cwindow(w, h, title, name)