aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-18 01:58:05 +1000
committerDavid Walter Seikel2014-05-18 01:58:05 +1000
commitf51e2ba4172dd02658ee5a182e4e00318970d60b (patch)
treea91d456e31456d0933be8c903690abe693566b42 /lib
parentAdd widget hide, show, and text setting functions. (diff)
downloadSledjHamr-f51e2ba4172dd02658ee5a182e4e00318970d60b.zip
SledjHamr-f51e2ba4172dd02658ee5a182e4e00318970d60b.tar.gz
SledjHamr-f51e2ba4172dd02658ee5a182e4e00318970d60b.tar.bz2
SledjHamr-f51e2ba4172dd02658ee5a182e4e00318970d60b.tar.xz
llDialog()'s share the one window and set of widgets now. Still needs more work.
Diffstat (limited to 'lib')
-rw-r--r--lib/LSLGuiMess.lua41
1 files changed, 32 insertions, 9 deletions
diff --git a/lib/LSLGuiMess.lua b/lib/LSLGuiMess.lua
index 25948c9..5c5cd9b 100644
--- a/lib/LSLGuiMess.lua
+++ b/lib/LSLGuiMess.lua
@@ -34,26 +34,49 @@ llSetTouchText(string text)
34TODO - Like the files window, just reuse a single window, hiding and showing it when needed. 34TODO - Like the files window, just reuse a single window, hiding and showing it when needed.
35 The switch button shows the buttons from the next one. 35 The switch button shows the buttons from the next one.
36]] 36]]
37
38 local dialogs = {count = 0, current = 0}
39 local w = 80
40 local h = 20
41 local x = 2 + (((1 - 1) % 3) * w)
42 local y = h * math.floor((1 - 1) / 3)
43 local buttCount = 12 * 8
44 local dialog = skang.window(4 + w * 3, h * math.ceil((--[[#buttons]] buttCount + 1) / 3), message, 'llDialogWindow')
45
46 for i = 1, buttCount do
47 x = 2 + (((i - 1) % 3) * w)
48 y = h * math.floor((i - 1) / 3)
49 skang.thingasm{dialog, 'button' .. i, 'Selects button ' .. i, types = 'widget', widget='"button", "' .. i .. '", ' .. x .. ', ' .. y .. ', ' .. w .. ', ' .. h}
50 skang.hide(dialog.W['button' .. i].Cwidget)
51 end
52 x = 2 + (((3 - 1) % 3) * w)
53 y = h * math.floor((--[[#buttons]] buttCount + 1) / 3)
54 skang.thingasm{dialog, 'ignore', 'Ignore this dialog', types = 'widget', widget='"button", "ignore", ' .. x .. ', ' .. y .. ', ' .. w - 20 .. ', ' .. h}
55 skang.thingasm{dialog, 'switch', 'Switch to next dialog', types = 'widget', widget='"button", ">", ' .. (x + w - 20) .. ', ' .. y .. ', ' .. 20 .. ', ' .. h}
56
37 llDialog = function (id, message, buttons, channel) 57 llDialog = function (id, message, buttons, channel)
38 local w = 80
39 local h = 20
40 local x = 2 + (((1 - 1) % 3) * w) 58 local x = 2 + (((1 - 1) % 3) * w)
41 local y = h * math.floor((1 - 1) / 3) 59 local y = h * math.floor((1 - 1) / 3)
42 local dialog = skang.window(4 + w * 3, h * math.ceil((#buttons + 1) / 3), message, 'llDialogWindow') 60
61 dialogs.count = dialogs.count + 1
62 dialogs[dialogs.count] = buttons
63 -- Hide the last set of buttons
64 if 0 ~= dialogs.current then
65 for i, v in ipairs(dialogs[dialogs.current]) do
66 skang.hide(dialog.W['button' .. i].Cwidget)
67 end
68 end
69 dialogs.current = dialogs.count
43 70
44 for i, v in ipairs(buttons) do 71 for i, v in ipairs(buttons) do
45 x = 2 + (((i - 1) % 3) * w) 72 x = 2 + (((i - 1) % 3) * w)
46 y = h * math.floor((i - 1) / 3) 73 y = h * math.floor((i - 1) / 3)
47 skang.thingasm{dialog, 'button' .. i, 'Selects button ' .. i, types = 'widget', widget='"button", "' .. v .. '", ' .. x .. ', ' .. y .. ', ' .. w .. ', ' .. h} 74 skang.show(dialog.W['button' .. i].Cwidget)
75 dialog.W['button' .. i].text = v
48 dialog.W['button' .. i].action = 'purkle.say(' .. channel .. ', "onefang Rejected", "' .. id .. '", "' .. v .. '")' 76 dialog.W['button' .. i].action = 'purkle.say(' .. channel .. ', "onefang Rejected", "' .. id .. '", "' .. v .. '")'
49 end 77 end
50 x = 2 + (((3 - 1) % 3) * w)
51 y = h * math.floor((#buttons + 1) / 3)
52 skang.thingasm{dialog, 'ignore', 'Ignore this dialog', types = 'widget', widget='"button", "ignore", ' .. x .. ', ' .. y .. ', ' .. w - 20 .. ', ' .. h}
53 skang.thingasm{dialog, 'switch', 'Switch to next dialog', types = 'widget', widget='"button", ">", ' .. (x + w - 20) .. ', ' .. y .. ', ' .. 20 .. ', ' .. h}
54 end 78 end
55 79
56
57 local doLua = function (command) 80 local doLua = function (command)
58 -- Yes I know, it hurt my brain just writing this. lol 81 -- Yes I know, it hurt my brain just writing this. lol
59 -- It just swaps square brackets for curly ones, coz LSL uses [] to surround lists, and Lua uses {} to surround tables. 82 -- It just swaps square brackets for curly ones, coz LSL uses [] to surround lists, and Lua uses {} to surround tables.