aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-03-27 00:03:34 +1000
committerDavid Walter Seikel2014-03-27 00:03:34 +1000
commit1342d5655da85c87c3ff1d5441ffd5117effc07f (patch)
treecf1682052baac6f4bea421ebb5cad4f81a22a59a
parentSmall tweaks to skang.thing() types parsing. (diff)
downloadSledjHamr-1342d5655da85c87c3ff1d5441ffd5117effc07f.zip
SledjHamr-1342d5655da85c87c3ff1d5441ffd5117effc07f.tar.gz
SledjHamr-1342d5655da85c87c3ff1d5441ffd5117effc07f.tar.bz2
SledjHamr-1342d5655da85c87c3ff1d5441ffd5117effc07f.tar.xz
More notes, TODO, and default Thing pattern.
-rw-r--r--ClientHamr/GuiLua/GuiLua.c6
-rw-r--r--ClientHamr/GuiLua/skang.lua23
2 files changed, 29 insertions, 0 deletions
diff --git a/ClientHamr/GuiLua/GuiLua.c b/ClientHamr/GuiLua/GuiLua.c
index 87766b0..3588ea0 100644
--- a/ClientHamr/GuiLua/GuiLua.c
+++ b/ClientHamr/GuiLua/GuiLua.c
@@ -172,6 +172,12 @@ of telling if the number is pixels or character cells. Also, relative
172to what part of the other widget? Some more thought needs to be put 172to what part of the other widget? Some more thought needs to be put
173into this. 173into this.
174 174
175Another idea for relative numbers could be to have a coord object with
176various methods, so we could have something like -
177
178widget:bottom(-10):right(5) -- 10 pixels below the bottom of widget, 5 pixels to the right of the right edge of widget.
179widget:width("12") -- 12 characters longer than the width of widget.
180
175*/ 181*/
176 182
177 183
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua
index b8e418b..e89de8e 100644
--- a/ClientHamr/GuiLua/skang.lua
+++ b/ClientHamr/GuiLua/skang.lua
@@ -212,6 +212,26 @@ Other Thing things are -
212 Actually, not sure matrix-RAD solved that either. lol 212 Actually, not sure matrix-RAD solved that either. lol
213]] 213]]
214 214
215--[[ ideas
216use a Lua pattern instead of a mask, with ^ and $ automatically added at the ends.
217__newindex could catch a table being assigned - test.foo = {widget = '...', acl='...'}
218 though that interferes with using tables for Stuff
219 test.someStuff = {key='blah', field0='something', field1=1, ...}
220 test.someStuff.key
221 happily Lua function call syntax supports test.foo{ ... } as a function call with a table argument. B-)
222 so maybe a use for __call after all, if the argument is that table
223 the table itself is passed to __call as the first argument, the rest of the arguments follow.
224 test.foo(1, 'two') -> __call(foo, 1, 'two')
225 foo has to be a table value though, with a metatable
226 and the rest of skang is treating test.foo as a nil value so that __index and __newindex work. B-(
227 test itself is a table, so all is not lost -
228 test{'foo', widget='...', acl='..'} -> __call(test, {'foo', ...})
229 which would assign stuff to skang.things.foo.widget and skang.things.foo.acl
230 as opposed to -
231 skang.things.foo = {widget='...', acl='...'}
232 which blanks out the other stuff.
233]]
234
215-- Default things values. 235-- Default things values.
216Thing.help = 'No description supplied.' 236Thing.help = 'No description supplied.'
217Thing.types = {'string'} 237Thing.types = {'string'}
@@ -221,6 +241,7 @@ Thing.required = false
221 241
222Thing.action = 'nada' -- An optional action to perform. 242Thing.action = 'nada' -- An optional action to perform.
223Thing.tell = '' -- The skang command that created this Thing. 243Thing.tell = '' -- The skang command that created this Thing.
244Thing.pattern = '.*' -- A pattern to restrict values.
224 245
225Thing.isReadOnly = false -- Is this Thing read only? 246Thing.isReadOnly = false -- Is this Thing read only?
226Thing.isServer = false -- Is this Thing server side? 247Thing.isServer = false -- Is this Thing server side?
@@ -256,6 +277,7 @@ Thing.__index = function (table, key)
256 -- First see if this is a Thing. 277 -- First see if this is a Thing.
257 -- TODO - Java skang called isValid() on get(). On the other hand, doesn't seem to call it on set(), but calls it on append(). 278 -- TODO - Java skang called isValid() on get(). On the other hand, doesn't seem to call it on set(), but calls it on append().
258 -- Ah, it was doing isValid() on setStufflet(). 279 -- Ah, it was doing isValid() on setStufflet().
280 -- TODO - Call thing.func() if it exists.
259 if thing then return thing.value or thing.default end 281 if thing then return thing.value or thing.default end
260 282
261 -- Then see if we can inherit it from Thing. 283 -- Then see if we can inherit it from Thing.
@@ -322,6 +344,7 @@ thing = function (names, help, default, types, widget, required, acl, boss)
322 n[i] = v 344 n[i] = v
323 i = i + 1 345 i = i + 1
324 end 346 end
347 -- TODO - Should bitch and return if no names, has to be at least one name.
325 local name = n[1] 348 local name = n[1]
326 349
327 -- Find type, default to string, then break out the other types. 350 -- Find type, default to string, then break out the other types.