-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathui.lua
executable file
·186 lines (167 loc) · 6.85 KB
/
ui.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
relay.ui = {}
relay.ui.toggles = iup.vbox{
iup.stationtoggle{title="Sector Chat", action=function() relay.toggle("sector") end},
iup.stationtoggle{title="System Chat", action=function() relay.toggle("system") end},
iup.stationtoggle{title="Group Chat", action=function() relay.toggle("group") end},
iup.stationtoggle{title="Channel Chat", action=function() relay.toggle("channel") end},
iup.stationtoggle{title="Debug Print", action=function() relay.toggle("debugprint") end},
iup.stationtoggle{title="Bank Updates", action=function() relay.toggle("updatebank") end},
iup.stationtoggle{title="MOTD Command", action=function() relay.toggle("motd") end},
iup.stationtoggle{title="Relay All IRC Chat", action=function() relay.toggle("allircchat") end},
iup.stationtoggle{title="Relay All Guild Chat", action=function() relay.toggle("allguildchat") end},
iup.stationtoggle{title="Format As [#chan] instead of [irc]", action=function() relay.toggle("showchan") end},
}
local function textaction(self, c, newval)
relay[self.name] = newval
gkini.WriteString("relay", self.name, newval)
end
relay.ui.username = iup.text{expand="HORIZONTAL", name="username", action=textaction}
relay.ui.nickname = iup.text{expand="HORIZONTAL", name="nickname", action=textaction}
relay.ui.password = iup.text{expand="HORIZONTAL", name="password", action=textaction}
relay.ui.server = iup.text{expand="HORIZONTAL", name="server", action=textaction}
relay.ui.guild = iup.text{expand="HORIZONTAL", name="guild", action=textaction}
relay.ui.generalchannel = iup.text{expand="HORIZONTAL", name="generalchannel", action=textaction}
relay.ui.texts = iup.vbox{
iup.hbox{iup.label{title="IRC Username:"}, relay.ui.username, gap=5},
iup.hbox{iup.label{title="IRC Nickname:"}, relay.ui.nickname, gap=5},
iup.hbox{iup.label{title="IRC Server:"}, relay.ui.server, gap=5},
iup.hbox{iup.label{title="NickServ Password:"}, relay.ui.password, gap=5},
iup.hbox{iup.label{title="Guild Acronym:"}, relay.ui.guild, gap=5},
iup.hbox{iup.label{title="Channel Relay Channel:"}, relay.ui.generalchannel, gap=5},
}
relay.ui.channels = iup.pdasubsublist{size=160, expand="VERTICAL"}
relay.ui.removechannelbutton = iup.stationbutton{size=160, title="Remove Channel", font=Font.H5,
action=function(self)
local val = relay.ui.channels.value
if val == 0 then return end
table.remove(relay.channels, val)
gkini.WriteString("relay", "channels", spickle(relay.channels))
relay.updatechannels("update")
iup.SetAttributes(relay.ui.channels, 1, "") -- clear list
for i, channel in ipairs(relay.channels) do relay.ui.channels[i] = channel end
end,
}
relay.ui.addchannelbutton = iup.stationbutton{size=160, title="Add Channel", font=Font.H5,
action=function(self)
local channel = relay.ui.addchannel.value
if channel == "" then return end
table.insert(relay.channels, channel)
relay.updatechannels("update")
gkini.WriteString("relay", "channels", spickle(relay.channels))
relay.ui.channels[#relay.channels] = channel
relay.ui.addchannel.value = ""
end,
}
relay.ui.addchannel = iup.text{size=160, action=function(self, c, val) if c == 13 and #val > 0 then relay.ui.addchannelbutton:action() end end}
relay.ui.channelbox = iup.vbox{
iup.label{title="IRC Channels"},
relay.ui.addchannel,
relay.ui.addchannelbutton,
relay.ui.channels,
relay.ui.removechannelbutton,
}
relay.ui.admins = iup.pdasubsublist{size=160, expand="VERTICAL"}
relay.ui.removeadminbutton = iup.stationbutton{size=160, title="Remove Admin", font=Font.H5,
action=function(self)
local val = relay.ui.admins.value
if val == 0 then return end
table.remove(relay.admins, val)
gkini.WriteString("relay", "admins", spickle(relay.admins))
iup.SetAttributes(relay.ui.admins, 1, "") -- clear list
for i, name in ipairs(relay.admins) do relay.ui.admins[i] = name end
end,
}
relay.ui.addadminbutton = iup.stationbutton{size=160, title="Add Admin", font=Font.H5,
action=function(self)
local name = relay.ui.addadmin.value
if name == "" then return end
table.insert(relay.admins, name)
gkini.WriteString("relay", "admins", spickle(relay.admins))
relay.ui.admins[#relay.admins] = name
relay.ui.addadmin.value = ""
end,
}
relay.ui.addadmin = iup.text{size=160, action=function(self, c, val) if c == 13 and #val > 0 then relay.ui.addadminbutton:action() end end}
relay.ui.adminbox = iup.vbox{
iup.label{title="IRC Admins"},
relay.ui.addadmin,
relay.ui.addadminbutton,
relay.ui.admins,
relay.ui.removeadminbutton,
}
relay.ui.toggle = iup.stationbutton{expand="HORIZONTAL", title="Start Relay", action=function() if relay.isactive() then relay.disconnect() else relay.connect() end end}
relay.ui.close = iup.stationbutton{expand="HORIZONTAL", title="Close", action=function() HideDialog(relay.ui.dlg) end}
relay.ui.version = iup.label{title="Version: "..relay.version}
relay.ui.main = iup.pdarootframe{
iup.pdasubframebg{
iup.vbox{
relay.ui.toggle,
iup.hbox{
iup.vbox{
relay.ui.texts,
relay.ui.toggles,
gap=5,
},
relay.ui.channelbox,
relay.ui.adminbox,
gap=5,
},
relay.ui.close,
gap=5,
},
},
size="HALFx",
expand="NO",
}
relay.ui.dlg = iup.dialog{
iup.vbox{
iup.fill{},
iup.hbox{iup.fill{}, relay.ui.version, iup.fill{}},
iup.fill{size=12},
iup.hbox{
iup.fill{},
relay.ui.main,
iup.fill{},
},
iup.fill{size=12},
iup.label{title=""},
iup.fill{},
},
fullscreen="YES",
border="NO",
topmost="YES",
resize="NO",
menubox="NO",
bgcolor="0 0 0 128 *",
defaultesc=relay.ui.close,
}
function relay.ui.dlg:show_cb() -- initialize ui values
FadeControl(relay.ui.version, 3, 3, 0)
relay.ui.toggles[1].value = relay.sector and "ON" or "OFF"
relay.ui.toggles[2].value = relay.system and "ON" or "OFF"
relay.ui.toggles[3].value = relay.group and "ON" or "OFF"
relay.ui.toggles[4].value = relay.channel and "ON" or "OFF"
relay.ui.toggles[5].value = relay.debugprint and "ON" or "OFF"
relay.ui.toggles[6].value = relay.updatebank and "ON" or "OFF"
relay.ui.toggles[7].value = relay.motd and "ON" or "OFF"
relay.ui.toggles[8].value = relay.allircchat and "ON" or "OFF"
relay.ui.toggles[9].value = relay.allguildchat and "ON" or "OFF"
relay.ui.toggles[10].value = relay.showchan and "ON" or "OFF"
if relay.guild == "" and IsConnected() and GetGuildTag() then
relay.guild = GetGuildTag()
gkini.WriteString("relay", "guild", relay.guild)
end
relay.ui.username.value = relay.username
relay.ui.nickname.value = relay.nickname
relay.ui.password.value = relay.password
relay.ui.server.value = relay.server
relay.ui.guild.value = relay.guild
relay.ui.generalchannel.value = relay.generalchannel
iup.SetAttributes(relay.ui.channels, 1, "") -- clear list
for i, channel in ipairs(relay.channels) do relay.ui.channels[i] = channel end
iup.SetAttributes(relay.ui.admins, 1, "") -- clear list
for i, name in ipairs(relay.admins) do relay.ui.admins[i] = name end
end
function relay.ui.dlg:hide_cb()
FadeStop(relay.ui.version)
end