vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- default Variables |
2 | configdata = { |
||
3 | activetab = 1, |
||
4 | mainframeposx = 10 , |
||
5 | mainframeposy = -300, |
||
6 | namessize = 200, |
||
7 | usenamebar = true, |
||
8 | hidenamebar = true, |
||
9 | namebartext = "!trigger - !count", |
||
10 | titletext = "!tNext [!iExpired/!iAll]", |
||
11 | namebarposx = 10, |
||
12 | namebarposy = -450, |
||
13 | minimizedposx = 10, |
||
14 | minimizedposy = -500, |
||
15 | minimized = true, |
||
16 | triggerconfposx = 300, |
||
17 | triggerconfposx = -400, |
||
18 | timersort = 1, |
||
19 | timersortascending = false, |
||
20 | triggersort = 1, |
||
21 | triggersortascending = false, |
||
22 | spamto = TIMERS_LOC_ALLWOSELF, |
||
23 | spamonpress = 10, |
||
24 | alldisabled = false, |
||
25 | framescale = 100 |
||
26 | }; |
||
27 | |||
28 | TimerscurrentTime = nil; |
||
29 | |||
30 | timerdata = {}; |
||
31 | |||
32 | -- Hooks |
||
33 | local Timers_OldSpellHook; |
||
34 | local Timers_OldSpellHookByName; |
||
35 | local Timers_OldUseAction; |
||
36 | |||
37 | -- local variables |
||
38 | local timerUpdateFlag = false; |
||
39 | local triggerPointer = {}; |
||
40 | local timeIsCorrect = false; |
||
41 | local timers_dropdown_row; |
||
42 | local trigger_edit; |
||
43 | local triggerdata_DEFAULT = {}; |
||
44 | local configdata_DEFAULT = {}; |
||
45 | local groupdata_DEFAULT = {}; |
||
46 | local inCombat = false; |
||
47 | local timeSinceUpdate = 0; |
||
48 | local currSpellCast; |
||
49 | local IconArray = {}; |
||
50 | local Timers_Debug = false; |
||
51 | |||
52 | -- GUI Functions |
||
53 | function TimersDropDownMainMenu_Init() |
||
54 | UIDropDownMenu_Initialize(this, TimersMenu_CreateMainMenuDropDown, "MENU"); |
||
55 | end |
||
56 | |||
57 | function TimersDropDownTimerRowMenu_Init() |
||
58 | UIDropDownMenu_Initialize(this, TimersMenu_CreateTimerRowDropDown, "MENU"); |
||
59 | end |
||
60 | |||
61 | function TimersDropDownTimerRowMenuEntry_Init() |
||
62 | if string.find(this:GetName(),"ChanBox") ~= nil then |
||
63 | UIDropDownMenu_Initialize(this, TimersMenu_CreateTimerRowChannelDropDown, "SELECTOR"); |
||
64 | elseif string.find(this:GetName(),"TypeBox") ~= nil then |
||
65 | UIDropDownMenu_Initialize(this, TimersMenu_CreateTimerRowTypeDropDown, "SELECTOR"); |
||
66 | elseif string.find(this:GetName(),"ModeBox") ~= nil then |
||
67 | UIDropDownMenu_Initialize(this, TimersMenu_CreateTimerRowModeDropDown, "SELECTOR"); |
||
68 | elseif string.find(this:GetName(), "TextBox") or string.find(this:GetName(), "EditBox4") then |
||
69 | UIDropDownMenu_Initialize(this, TimersMenu_CreateTimerRowTextDropDown, "SELECTOR"); |
||
70 | end |
||
71 | end |
||
72 | |||
73 | function TimersMenu_CreateTimerRowTextDropDown(level) |
||
74 | if level == 1 then |
||
75 | info = {["text"] = TIMERS_LOC_COMBATSTART, ["func"] = TimersEdit_SaveTextImplicit, ["arg1"] = this ,["arg2"] = TIMERS_LOC_COMBATSTART}; |
||
76 | UIDropDownMenu_AddButton(info, 1); |
||
77 | info = {["text"] = TIMERS_LOC_COMBATSTOP, ["func"] = TimersEdit_SaveTextImplicit, ["arg1"] = this ,["arg2"] = TIMERS_LOC_COMBATSTOP}; |
||
78 | UIDropDownMenu_AddButton(info, 1); |
||
79 | info = {["text"] = TIMERS_LOC_ZONEENTER, ["func"] = TimersEdit_SaveTextImplicit, ["arg1"] = this ,["arg2"] = TIMERS_LOC_ZONEENTER}; |
||
80 | UIDropDownMenu_AddButton(info, 1); |
||
81 | info = {["text"] = TIMERS_LOC_SPELL_CAST, ["func"] = TimersEdit_SaveTextImplicit, ["arg1"] = this ,["arg2"] = TIMERS_LOC_SPELL_CAST}; |
||
82 | UIDropDownMenu_AddButton(info, 1); |
||
83 | end |
||
84 | end |
||
85 | |||
86 | function TimersConfig_CreateSpamToDropDown(level) |
||
87 | if level == 1 then |
||
88 | info = {["text"] = TIMERS_LOC_ALL, ["func"] = TimersMenu_SetConfigSpam, ["arg1"] = this , ["arg2"] = TIMERS_LOC_ALL}; |
||
89 | UIDropDownMenu_AddButton(info, 1); |
||
90 | info = {["text"] = TIMERS_LOC_ALLWOSELF, ["func"] = TimersMenu_SetConfigSpam, ["arg1"] = this ,["arg2"] = TIMERS_LOC_ALLWOSELF}; |
||
91 | UIDropDownMenu_AddButton(info, 1); |
||
92 | info = {["text"] = TIMERS_LOC_ONLYSELECTED, ["func"] = TimersMenu_SetConfigSpam, ["arg1"] = this ,["arg2"] = TIMERS_LOC_ONLYSELECTED}; |
||
93 | UIDropDownMenu_AddButton(info, 1); |
||
94 | info = {["text"] = TIMERS_LOC_ONLYHIGHER, ["func"] = TimersMenu_SetConfigSpam, ["arg1"] = this ,["arg2"] = TIMERS_LOC_ONLYHIGHER}; |
||
95 | UIDropDownMenu_AddButton(info, 1); |
||
96 | end |
||
97 | end |
||
98 | |||
99 | function TimersMenu_CreateTimerRowChannelDropDown(level) |
||
100 | if level == 1 then |
||
101 | if not (triggerdata[trigger_edit].name == "default") then |
||
102 | info = {["text"] = TIMERS_LOC_DEFAULT, ["func"] = TimersEdit_SaveChannel, ["arg1"] = this , ["arg2"] = TIMERS_LOC_DEFAULT}; |
||
103 | UIDropDownMenu_AddButton(info, 1); |
||
104 | end |
||
105 | info = {["text"] = TIMERS_LOC_SELF, ["func"] = TimersEdit_SaveChannel, ["arg1"] = this ,["arg2"] = TIMERS_LOC_SELF}; |
||
106 | UIDropDownMenu_AddButton(info, 1); |
||
107 | info = {["text"] = TIMERS_LOC_PARTY, ["func"] = TimersEdit_SaveChannel, ["arg1"] = this ,["arg2"] = TIMERS_LOC_PARTY}; |
||
108 | UIDropDownMenu_AddButton(info, 1); |
||
109 | info = {["text"] = TIMERS_LOC_RAID, ["func"] = TimersEdit_SaveChannel, ["arg1"] = this ,["arg2"] = TIMERS_LOC_RAID}; |
||
110 | UIDropDownMenu_AddButton(info, 1); |
||
111 | info = {["text"] = TIMERS_LOC_CTRAID, ["func"] = TimersEdit_SaveChannel, ["arg1"] = this ,["arg2"] = TIMERS_LOC_CTRAID}; |
||
112 | UIDropDownMenu_AddButton(info, 1); |
||
113 | end |
||
114 | end |
||
115 | |||
116 | function TimersMenu_CreateTimerRowTypeDropDown(level) |
||
117 | if level == 1 then |
||
118 | if not (triggerdata[trigger_edit].name == "default") then |
||
119 | info = {["text"] = TIMERS_LOC_DEFAULT, ["func"] = TimersEdit_SaveType, ["arg1"] = this ,["arg2"] = TIMERS_LOC_DEFAULT}; |
||
120 | UIDropDownMenu_AddButton(info, 1); |
||
121 | end |
||
122 | info = {["text"] = TIMERS_LOC_MULTIPLE, ["func"] = TimersEdit_SaveType, ["arg1"] = this ,["arg2"] = TIMERS_LOC_MULTIPLE}; |
||
123 | UIDropDownMenu_AddButton(info, 1); |
||
124 | info = {["text"] = TIMERS_LOC_ONCE, ["func"] = TimersEdit_SaveType, ["arg1"] = this ,["arg2"] = TIMERS_LOC_ONCE}; |
||
125 | UIDropDownMenu_AddButton(info, 1); |
||
126 | info = {["text"] = TIMERS_LOC_ONCEGROUP, ["func"] = TimersEdit_SaveType, ["arg1"] = this ,["arg2"] = TIMERS_LOC_ONCEGROUP}; |
||
127 | UIDropDownMenu_AddButton(info, 1); |
||
128 | info = {["text"] = TIMERS_LOC_PAUSE, ["func"] = TimersEdit_SaveType, ["arg1"] = this ,["arg2"] = TIMERS_LOC_PAUSE}; |
||
129 | UIDropDownMenu_AddButton(info, 1); |
||
130 | info = {["text"] = TIMERS_LOC_STOP, ["func"] = TimersEdit_SaveType, ["arg1"] = this ,["arg2"] = TIMERS_LOC_STOP}; |
||
131 | UIDropDownMenu_AddButton(info, 1); |
||
132 | info = {["text"] = TIMERS_LOC_WARNONLY, ["func"] = TimersEdit_SaveType, ["arg1"] = this ,["arg2"] = TIMERS_LOC_WARNONLY}; |
||
133 | UIDropDownMenu_AddButton(info, 1); |
||
134 | end |
||
135 | end |
||
136 | |||
137 | function TimersMenu_CreateTimerRowModeDropDown(level) |
||
138 | if level == 1 then |
||
139 | if not (triggerdata[trigger_edit].name == "default") then |
||
140 | info = {["text"] = TIMERS_LOC_DEFAULT, ["func"] = TimersEdit_SaveMode, ["arg1"] = this ,["arg2"] = TIMERS_LOC_DEFAULT}; |
||
141 | UIDropDownMenu_AddButton(info, 1); |
||
142 | end |
||
143 | info = {["text"] = TIMERS_LOC_CONTINUE, ["func"] = TimersEdit_SaveMode, ["arg1"] = this ,["arg2"] = TIMERS_LOC_CONTINUE}; |
||
144 | UIDropDownMenu_AddButton(info, 1); |
||
145 | info = {["text"] = TIMERS_LOC_DELETE, ["func"] = TimersEdit_SaveMode, ["arg1"] = this ,["arg2"] = TIMERS_LOC_DELETE}; |
||
146 | UIDropDownMenu_AddButton(info, 1); |
||
147 | info = {["text"] = TIMERS_LOC_RESET, ["func"] = TimersEdit_SaveMode, ["arg1"] = this ,["arg2"] = TIMERS_LOC_RESET}; |
||
148 | UIDropDownMenu_AddButton(info, 1); |
||
149 | info = {["text"] = TIMERS_LOC_INC, ["func"] = TimersEdit_SaveMode, ["arg1"] = this ,["arg2"] = TIMERS_LOC_INC}; |
||
150 | UIDropDownMenu_AddButton(info, 1); |
||
151 | end |
||
152 | end |
||
153 | |||
154 | function TimersMenu_CreateMainMenuDropDown(level) |
||
155 | if configdata.activetab == 1 then |
||
156 | if level == 1 then |
||
157 | if configdata.alldisabled then |
||
158 | info = {["text"] = TIMERS_LOC_ENABLEALL, ["func"] = TimersEdit_ToggleDisableAll}; |
||
159 | UIDropDownMenu_AddButton(info, 1); |
||
160 | else |
||
161 | info = {["text"] = TIMERS_LOC_DISABLEALL, ["func"] = TimersEdit_ToggleDisableAll}; |
||
162 | UIDropDownMenu_AddButton(info, 1); |
||
163 | end |
||
164 | info = {["text"] = " -------- ",["notClickable"] = 1}; |
||
165 | UIDropDownMenu_AddButton(info, 1); |
||
166 | info = {["text"] = TIMERS_LOC_DELETEXPIRED, ["func"] = TimersEdit_DeleteExpired}; |
||
167 | UIDropDownMenu_AddButton(info, 1); |
||
168 | info = {["text"] = TIMERS_LOC_DELETEBYGROUP, ["hasArrow"] = 1}; |
||
169 | UIDropDownMenu_AddButton(info, 1); |
||
170 | info = {["text"] = TIMERS_LOC_DELETALL, ["func"] = TimersEdit_DeleteAllTimer}; |
||
171 | UIDropDownMenu_AddButton(info, 1); |
||
172 | info = {["text"] = " -------- ",["notClickable"] = 1}; |
||
173 | UIDropDownMenu_AddButton(info, 1); |
||
174 | info = {["text"] = TIMERS_LOC_RESETEXPIRED, ["func"] = TimersEdit_ResetExpired}; |
||
175 | UIDropDownMenu_AddButton(info, 1); |
||
176 | info = {["text"] = TIMERS_LOC_RESETBYGROUP, ["hasArrow"] = 1}; |
||
177 | UIDropDownMenu_AddButton(info, 1); |
||
178 | info = {["text"] = TIMERS_LOC_RESETALL, ["func"] = TimersEdit_ResetAll}; |
||
179 | UIDropDownMenu_AddButton(info, 1); |
||
180 | info = {["text"] = " -------- ",["notClickable"] = 1}; |
||
181 | UIDropDownMenu_AddButton(info, 1); |
||
182 | info = {["text"] = TIMERS_LOC_SPAMALLTO,["hasArrow"] = 1}; |
||
183 | UIDropDownMenu_AddButton(info, 1); |
||
184 | elseif level == 2 and string.find(this:GetName(), "Button4") then |
||
185 | if table.getn(timerdata) == 0 then |
||
186 | info = {["text"] = TIMERS_LOC_NO_TIMERS,["notClickable"] = 1}; |
||
187 | UIDropDownMenu_AddButton(info, 2); |
||
188 | else |
||
189 | for i=1, table.getn(groupdata) do |
||
190 | local hasTimer = false; |
||
191 | for j=1, table.getn(timerdata) do |
||
192 | if triggerdata[Timers_TriggerNameToNumber(timerdata[j].trigger)].group == groupdata[i].name or (not triggerdata[Timers_TriggerNameToNumber(timerdata[j].trigger)].group and groupdata[i].name == TIMERS_LOC_NOGROUP) then |
||
193 | hasTimer = i; |
||
194 | end |
||
195 | end |
||
196 | if hasTimer then |
||
197 | info = {["text"] = groupdata[i].name, ["func"] = TimersEdit_DeleteByGroup, ["arg1"] = groupdata[i].name}; |
||
198 | UIDropDownMenu_AddButton(info, 2); |
||
199 | end |
||
200 | end |
||
201 | end |
||
202 | elseif level == 2 and string.find(this:GetName(), "Button8") then |
||
203 | if table.getn(timerdata) == 0 then |
||
204 | info = {["text"] = TIMERS_LOC_NO_TIMERS,["notClickable"] = 1}; |
||
205 | UIDropDownMenu_AddButton(info, 2); |
||
206 | else |
||
207 | for i=1, table.getn(groupdata) do |
||
208 | local hasTimer = false; |
||
209 | for j=1, table.getn(timerdata) do |
||
210 | if triggerdata[Timers_TriggerNameToNumber(timerdata[j].trigger)].group == groupdata[i].name or (not triggerdata[Timers_TriggerNameToNumber(timerdata[j].trigger)].group and groupdata[i].name == TIMERS_LOC_NOGROUP) then |
||
211 | hasTimer = i; |
||
212 | end |
||
213 | end |
||
214 | if hasTimer then |
||
215 | info = {["text"] = groupdata[i].name, ["func"] = TimersEdit_ResetByGroup, ["arg1"] = groupdata[i].name}; |
||
216 | UIDropDownMenu_AddButton(info, 2); |
||
217 | end |
||
218 | end |
||
219 | end |
||
220 | elseif level == 2 and string.find(this:GetName(), "Button11") then |
||
221 | if ChatEdit_GetLastTellTarget(ChatFrameEditBox) ~= "" then |
||
222 | info = {["text"] = TIMERS_LOC_REPLY.." ("..ChatEdit_GetLastTellTarget(ChatFrameEditBox)..")", ["func"]=TimersSend_AllTimer, ["arg1"]="REPLY"}; |
||
223 | UIDropDownMenu_AddButton(info, 2); |
||
224 | end |
||
225 | info = {["text"] = TIMERS_LOC_SELF, ["func"]=TimersSend_AllTimer, ["arg1"]=TIMERS_LOC_SELF}; |
||
226 | UIDropDownMenu_AddButton(info, 2); |
||
227 | info = {["text"] = TIMERS_LOC_PARTY, ["func"]=TimersSend_AllTimer, ["arg1"]=TIMERS_LOC_PARTY}; |
||
228 | UIDropDownMenu_AddButton(info, 2); |
||
229 | info = {["text"] = TIMERS_LOC_RAID, ["func"]=TimersSend_AllTimer, ["arg1"]=TIMERS_LOC_RAID}; |
||
230 | UIDropDownMenu_AddButton(info, 2); |
||
231 | info = {["text"] = TIMERS_LOC_OFFICER, ["func"]=TimersSend_AllTimer, ["arg1"]=TIMERS_LOC_OFFICER}; |
||
232 | UIDropDownMenu_AddButton(info, 2); |
||
233 | end |
||
234 | elseif configdata.activetab == 3 then |
||
235 | if level == 1 then |
||
236 | if configdata.hideinactive then |
||
237 | info = {["text"] = TIMERS_LOC_TOGGLEALLINACTIVSHOW, ["func"] = Timers_ToggleShowInactive}; |
||
238 | UIDropDownMenu_AddButton(info, 1); |
||
239 | else |
||
240 | info = {["text"] = TIMERS_LOC_TOGGLEALLINACTIVHIDE, ["func"] = Timers_ToggleShowInactive}; |
||
241 | UIDropDownMenu_AddButton(info, 1); |
||
242 | end |
||
243 | info = {["text"] = TIMERS_LOC_TOGGLEALLFOLD, ["func"]= Timers_ToggleFoldAll}; |
||
244 | UIDropDownMenu_AddButton(info, 1); |
||
245 | info = {["text"] = TIMERS_LOC_TOGGLEALL, ["func"] = Timers_ToggleActiveAll}; |
||
246 | UIDropDownMenu_AddButton(info, 1); |
||
247 | info = {["text"] = " -------- ",["notClickable"] = 1}; |
||
248 | UIDropDownMenu_AddButton(info, 1); |
||
249 | info = {["text"] = TIMERS_LOC_RESETALLCNT, ["func"] = Timers_ResetAllCnt}; |
||
250 | UIDropDownMenu_AddButton(info, 1); |
||
251 | info = {["text"] = " -------- ",["notClickable"] = 1}; |
||
252 | UIDropDownMenu_AddButton(info, 1); |
||
253 | info = {["text"] = TIMERS_LOC_ADDGROUP, ["func"] = Timers_AddGroup }; |
||
254 | UIDropDownMenu_AddButton(info, 1); |
||
255 | info = {["text"] = TIMERS_LOC_DELETEGROUP, ["hasArrow"] = 1}; |
||
256 | UIDropDownMenu_AddButton(info, 1); |
||
257 | info = {["text"] = TIMERS_LOC_ADDTRIGGER, ["func"] = Timers_AddTrigger}; |
||
258 | UIDropDownMenu_AddButton(info, 1); |
||
259 | info = {["text"] = " -------- ",["notClickable"] = 1}; |
||
260 | UIDropDownMenu_AddButton(info, 1); |
||
261 | info = {["text"] = TIMERS_LOC_RESETALLTRIGGER, ["func"] = Timers_ResetAllTrigger}; |
||
262 | UIDropDownMenu_AddButton(info, 1); |
||
263 | elseif level == 2 then |
||
264 | local onlydefault = true; |
||
265 | for i = 1, table.getn(groupdata) do |
||
266 | if groupdata[i].isnotdefault then |
||
267 | info = {["text"] = groupdata[i].name, ["func"] = Timers_DeleteGroup, ["arg1"] = i}; |
||
268 | UIDropDownMenu_AddButton(info, 2); |
||
269 | onlydefault = false; |
||
270 | end |
||
271 | end |
||
272 | if onlydefault then |
||
273 | info = {["text"] = TIMERS_LOC_NOT_DELETE_DEFAULT, ["notClickable"] = 1}; |
||
274 | UIDropDownMenu_AddButton(info, 2); |
||
275 | end |
||
276 | end |
||
277 | end |
||
278 | end |
||
279 | |||
280 | function TimersMenu_CreateTimerRowDropDown(level) |
||
281 | if (configdata.activetab == 1 or configdata.activetab == 2) then |
||
282 | if level == 1 then |
||
283 | local i = Timers_GetRow(this)+FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame); |
||
284 | timers_dropdown_row = Timers_GetRow(this); |
||
285 | info = {["text"] = TIMERS_LOC_INVOKED,["notClickable"] = 1}; |
||
286 | UIDropDownMenu_AddButton(info, 1); |
||
287 | info = {["text"] = timerdata[i].trigger,["notClickable"] = 1}; |
||
288 | UIDropDownMenu_AddButton(info, 1); |
||
289 | info = {["text"] = " -------- ",["notClickable"] = 1}; |
||
290 | UIDropDownMenu_AddButton(info, 1); |
||
291 | info = {["text"] = TIMERS_LOC_DELETE, ["func"] = TimersEdit_DeleteTimer, ["arg1"] = this}; |
||
292 | UIDropDownMenu_AddButton(info, 1); |
||
293 | info = {["text"] = TIMERS_LOC_RESET, ["func"] = TimersEdit_ResetTimer, ["arg1"] = this}; |
||
294 | UIDropDownMenu_AddButton(info, 1); |
||
295 | if not timerdata[i].stopped then |
||
296 | if not timerdata[i].paused then |
||
297 | info = {["text"] = TIMERS_LOC_PAUSE, ["func"] = TimersEdit_TogglePaused, ["arg1"] = this}; |
||
298 | UIDropDownMenu_AddButton(info, 1); |
||
299 | else |
||
300 | info = {["text"] = TIMERS_LOC_RESUME, ["func"] = TimersEdit_TogglePaused, ["arg1"] = this}; |
||
301 | UIDropDownMenu_AddButton(info, 1); |
||
302 | end |
||
303 | if triggerdata[Timers_TriggerNameToNumber(timerdata[i].trigger)].mode == TIMERS_LOC_INC then |
||
304 | info = {["text"] = TIMERS_LOC_STOP, ["func"] = TimersEdit_StopTimer, ["arg1"] = this}; |
||
305 | UIDropDownMenu_AddButton(info, 1); |
||
306 | end |
||
307 | end |
||
308 | info = {["text"] = TIMERS_LOC_SPAMTO,["hasArrow"] = 1}; |
||
309 | UIDropDownMenu_AddButton(info, 1); |
||
310 | elseif level == 2 then |
||
311 | if ChatEdit_GetLastTellTarget(ChatFrameEditBox) ~= "" then |
||
312 | info = {["text"] = TIMERS_LOC_REPLY.." ("..ChatEdit_GetLastTellTarget(ChatFrameEditBox)..")", ["func"] = TimersSend_Timer, ["arg1"] = timers_dropdown_row, ["arg2"] = "REPLY"}; |
||
313 | UIDropDownMenu_AddButton(info, 2); |
||
314 | end |
||
315 | info = {["text"] = TIMERS_LOC_PARTY, ["func"] = TimersSend_Timer, ["arg1"] = timers_dropdown_row, ["arg2"] = TIMERS_LOC_PARTY}; |
||
316 | UIDropDownMenu_AddButton(info, 2); |
||
317 | info = {["text"] = TIMERS_LOC_RAID, ["func"] = TimersSend_Timer, ["arg1"] = timers_dropdown_row, ["arg2"] = TIMERS_LOC_RAID}; |
||
318 | UIDropDownMenu_AddButton(info, 2); |
||
319 | info = {["text"] = TIMERS_LOC_CTRAID, ["func"] = TimersSend_Timer, ["arg1"] = timers_dropdown_row, ["arg2"] = TIMERS_LOC_CTRAID}; |
||
320 | UIDropDownMenu_AddButton(info, 2); |
||
321 | info = {["text"] = TIMERS_LOC_OFFICER, ["func"] = TimersSend_Timer, ["arg1"] = timers_dropdown_row, ["arg2"] = TIMERS_LOC_OFFICER}; |
||
322 | UIDropDownMenu_AddButton(info, 2); |
||
323 | end |
||
324 | else |
||
325 | if level == 1 then |
||
326 | timers_dropdown_row = Timers_GetRow(this); |
||
327 | info = {["text"] = TIMERS_LOC_ADVANCEDCONF, ["func"] = Timers_ShowAdvancedConfig}; |
||
328 | UIDropDownMenu_AddButton(info, 1); |
||
329 | info = {["text"] = TIMERS_LOC_RESETCNT, ["func"] = Timers_ResetCnt, ["arg1"] = this}; |
||
330 | UIDropDownMenu_AddButton(info, 1); |
||
331 | if triggerdata[Timers_RowToTrigger(timers_dropdown_row+FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame))].isnotdefault then |
||
332 | info = {["text"] = TIMERS_LOC_DELETETRIGGER, ["func"] = Timers_DeleteTrigger, ["arg1"] = this}; |
||
333 | UIDropDownMenu_AddButton(info, 1); |
||
334 | end |
||
335 | if not (triggerdata[Timers_RowToTrigger(Timers_GetRow(this)+FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame))].name == "default") then |
||
336 | info = {["text"] = TIMERS_LOC_MOVETOGROUP,["hasArrow"] = 1}; |
||
337 | UIDropDownMenu_AddButton(info, 1); |
||
338 | end |
||
339 | if Timers_TriggerNameToDefaultNumber(triggerdata[Timers_RowToTrigger(Timers_GetRow(this)+FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame))].name) then |
||
340 | info = {["text"] = TIMERS_LOC_RESETTRIGGER, ["func"] = Timers_ResetTriggerByRow, ["arg1"] = this}; |
||
341 | UIDropDownMenu_AddButton(info, 1); |
||
342 | end |
||
343 | elseif level == 2 then |
||
344 | for i = 1, table.getn(groupdata) do |
||
345 | info = {["text"] = groupdata[i].name, ["func"] = Timers_MoveToGroup, ["arg1"] = timers_dropdown_row, ["arg2"] = i}; |
||
346 | UIDropDownMenu_AddButton(info, 2); |
||
347 | end |
||
348 | end |
||
349 | end |
||
350 | end |
||
351 | |||
352 | function TimersMenu_SetConfigSpam(arg,text) |
||
353 | configdata.spamto = text; |
||
354 | TimersMenu_SetEditBoxText(arg,text); |
||
355 | end |
||
356 | |||
357 | function TimersMenu_SetEditBoxText(caller,text) |
||
358 | getglobal(caller:GetParent():GetName().."Text"):SetText(text); |
||
359 | end |
||
360 | |||
361 | |||
362 | function Timers_TabControl(arg) -- Tab Control |
||
363 | |||
364 | activeset = 0; -- Verschiebung für das Active Tab |
||
365 | |||
366 | -- Erstes Tab Testen |
||
367 | if arg == TimersMainFrameTabButton1 then |
||
368 | TimersMainFrameTabButton1MiddleDisabled:Show(); |
||
369 | TimersMainFrameTabButton1RightDisabled:Show(); |
||
370 | TimersMainFrameTabButton1LeftDisabled:Show(); |
||
371 | TimersMainFrameTabButton1Middle:Hide(); |
||
372 | TimersMainFrameTabButton1Right:Hide(); |
||
373 | TimersMainFrameTabButton1Left:Hide(); |
||
374 | arg:SetPoint("TOPLEFT","TimersMainFrame","BOTTOMLEFT",2,0); |
||
375 | activeset = 4; |
||
376 | configdata.activetab = 1; |
||
377 | else |
||
378 | TimersMainFrameTabButton1MiddleDisabled:Hide(); |
||
379 | TimersMainFrameTabButton1RightDisabled:Hide(); |
||
380 | TimersMainFrameTabButton1LeftDisabled:Hide(); |
||
381 | TimersMainFrameTabButton1Middle:Show(); |
||
382 | TimersMainFrameTabButton1Right:Show(); |
||
383 | TimersMainFrameTabButton1Left:Show(); |
||
384 | TimersMainFrameTabButton1:SetPoint("TOPLEFT","TimersMainFrame","BOTTOMLEFT",2,4); |
||
385 | end |
||
386 | |||
387 | -- Tab 2 bis 5 setzen |
||
388 | for i = 2, 5 do |
||
389 | if arg == getglobal("TimersMainFrameTabButton"..i) then |
||
390 | getglobal("TimersMainFrameTabButton"..i.."MiddleDisabled"):Show(); |
||
391 | getglobal("TimersMainFrameTabButton"..i.."RightDisabled"):Show(); |
||
392 | getglobal("TimersMainFrameTabButton"..i.."LeftDisabled"):Show(); |
||
393 | getglobal("TimersMainFrameTabButton"..i.."Middle"):Hide(); |
||
394 | getglobal("TimersMainFrameTabButton"..i.."Right"):Hide(); |
||
395 | getglobal("TimersMainFrameTabButton"..i.."Left"):Hide(); |
||
396 | getglobal("TimersMainFrameTabButton"..i):SetPoint("TOPLEFT",getglobal("TimersMainFrameTabButton"..(i-1)),"TOPRIGHT",0,-4); |
||
397 | activeset = 4; |
||
398 | configdata.activetab = i; |
||
399 | else |
||
400 | getglobal("TimersMainFrameTabButton"..i.."MiddleDisabled"):Hide(); |
||
401 | getglobal("TimersMainFrameTabButton"..i.."RightDisabled"):Hide(); |
||
402 | getglobal("TimersMainFrameTabButton"..i.."LeftDisabled"):Hide(); |
||
403 | getglobal("TimersMainFrameTabButton"..i.."Middle"):Show(); |
||
404 | getglobal("TimersMainFrameTabButton"..i.."Right"):Show(); |
||
405 | getglobal("TimersMainFrameTabButton"..i.."Left"):Show(); |
||
406 | getglobal("TimersMainFrameTabButton"..i):SetPoint("TOPLEFT",getglobal("TimersMainFrameTabButton"..(i-1)),"TOPRIGHT",0,activeset); |
||
407 | activeset = 0; |
||
408 | end |
||
409 | end |
||
410 | Timers_TabContentControl(); |
||
411 | end |
||
412 | |||
413 | function Timers_TabContentControl() |
||
414 | |||
415 | -- creating default window sys (timerframe) |
||
416 | TimersMainFrame:SetBackdropBorderColor(1, 1, 1, 1); |
||
417 | TimersMainFrame:SetBackdropColor(0,0, 0, 0.8); |
||
418 | TimersMainFrameTitle:Show(); |
||
419 | TimersMainFrameScrollFrame:Show(); |
||
420 | TimersMainFrameCloseButton:Show(); |
||
421 | TimersMainFrameMenuButton:Show(); |
||
422 | TimersMainFrameMinimizeButton:Show(); |
||
423 | TimersMainFrameSortButton1:Show(); |
||
424 | TimersMainFrameSortButton2:Show(); |
||
425 | TimersMainFrameToggleNameBoxButton:Show(); |
||
426 | TimersMainFrameScrollFrame:Show(); |
||
427 | |||
428 | for i = 2, 5 do |
||
429 | getglobal("TimersMainFrameTabButton"..i):Show(); |
||
430 | end |
||
431 | |||
432 | TimersMainFrameTabButton1Middle:SetAlpha(1); |
||
433 | TimersMainFrameTabButton1Left:SetAlpha(1); |
||
434 | TimersMainFrameTabButton1Right:SetAlpha(1); |
||
435 | |||
436 | for i = 1, 10 do |
||
437 | getglobal("TimersMainFrameTimerRow"..i):Hide(); |
||
438 | getglobal("TimersMainFrameTimerRow"..i.."GrpByPlaytime"):Hide(); |
||
439 | getglobal("TimersMainFrameTimerRow"..i.."GrpByPlaytimeTitle"):Hide(); |
||
440 | getglobal("TimersMainFrameTimerRow"..i.."GrpResetCnt"):Hide(); |
||
441 | getglobal("TimersMainFrameTimerRow"..i.."GrpResetCntTitle"):Hide(); |
||
442 | getglobal("TimersMainFrameTimerRow"..i.."GrpDeleteTimer"):Hide(); |
||
443 | getglobal("TimersMainFrameTimerRow"..i.."GrpDeleteTimerTitle"):Hide(); |
||
444 | getglobal("TimersMainFrameTimerRow"..i.."GrpOnStartTitle"):Hide(); |
||
445 | getglobal("TimersMainFrameTimerRow"..i.."DeleteButton"):Show(); |
||
446 | getglobal("TimersMainFrameTimerRow"..i.."Active"):Hide(); |
||
447 | getglobal("TimersMainFrameTimerRow"..i.."MenuButton"):SetText("!"); |
||
448 | getglobal("TimersMainFrameTimerRow"..i.."MenuButton"):Show(); |
||
449 | getglobal("TimersMainFrameTimerRow"..i.."EditBox1"):SetPoint("TOPLEFT","$parentMenuButton","TOPRIGHT",0,0); |
||
450 | getglobal("TimersMainFrameTimerRow"..i.."Middle"):SetWidth(80+configdata.namessize); |
||
451 | getglobal("TimersMainFrameTimerRow"..i.."EditBox1"):SetWidth(configdata.namessize-40); |
||
452 | getglobal("TimersMainFrameTimerRow"..i.."Middle"):SetAlpha(0.8); |
||
453 | getglobal("TimersMainFrameTimerRow"..i.."Left"):SetAlpha(0.8); |
||
454 | getglobal("TimersMainFrameTimerRow"..i.."Right"):SetAlpha(0.8); |
||
455 | getglobal("TimersMainFrameTimerRow"..i.."EditBox2"):SetPoint("TOPLEFT","$parentEditBox1","TOPRIGHT",20,0); |
||
456 | getglobal("TimersMainFrameTimerRow"..i.."EditBox2"):Show(); |
||
457 | for j = 3, 5 do |
||
458 | getglobal("TimersMainFrameTimerRow"..i.."EditBox"..j):Hide(); |
||
459 | end |
||
460 | end |
||
461 | |||
462 | TimersMainFrame:SetWidth(130+configdata.namessize); |
||
463 | TimersMainFrameScrollFrame:SetWidth(95+configdata.namessize); |
||
464 | |||
465 | TimersMainFrameSortButton1:Show(); |
||
466 | TimersMainFrameSortButton1:SetWidth(configdata.namessize); |
||
467 | TimersMainFrameSortButton2:Show(); |
||
468 | for i = 3, 5 do |
||
469 | getglobal("TimersMainFrameSortButton"..i):Hide(); |
||
470 | end |
||
471 | |||
472 | TimersMainFrameConfig:Hide(); |
||
473 | TimersMainFrameHelp:Hide(); |
||
474 | TimersMainFrameTextFrame:Hide(); |
||
475 | |||
476 | if configdata.activetab == 1 then |
||
477 | Timers_SetTimerData(); |
||
478 | elseif configdata.activetab == 2 then |
||
479 | TimersMainFrame:SetBackdropBorderColor(0, 0, 0, 0); |
||
480 | TimersMainFrame:SetBackdropColor(0, 0, 0, 0); |
||
481 | TimersMainFrameTitle:Hide(); |
||
482 | TimersMainFrameMenuButton:Hide(); |
||
483 | TimersMainFrameCloseButton:Hide(); |
||
484 | TimersMainFrameMinimizeButton:Hide(); |
||
485 | TimersMainFrameSortButton1:Hide(); |
||
486 | TimersMainFrameSortButton2:Hide(); |
||
487 | TimersMainFrameToggleNameBoxButton:Hide(); |
||
488 | |||
489 | for i = 2, 5 do |
||
490 | getglobal("TimersMainFrameTabButton"..i):Hide(); |
||
491 | end |
||
492 | |||
493 | TimersMainFrameTabButton1Middle:SetAlpha(0); |
||
494 | TimersMainFrameTabButton1Left:SetAlpha(0); |
||
495 | TimersMainFrameTabButton1Right:SetAlpha(0); |
||
496 | |||
497 | for i = 1, 10 do |
||
498 | getglobal("TimersMainFrameTimerRow"..i.."Middle"):SetAlpha(0); |
||
499 | getglobal("TimersMainFrameTimerRow"..i.."Left"):SetAlpha(0); |
||
500 | getglobal("TimersMainFrameTimerRow"..i.."Right"):SetAlpha(0); |
||
501 | getglobal("TimersMainFrameTimerRow"..i.."MenuButton"):Hide(); |
||
502 | getglobal("TimersMainFrameTimerRow"..i.."DeleteButton"):Hide(); |
||
503 | end |
||
504 | Timers_SetTimerData(); |
||
505 | elseif configdata.activetab == 3 then |
||
506 | TimersMainFrame:SetWidth(710); |
||
507 | TimersMainFrameScrollFrame:SetWidth(675); |
||
508 | for i = 3, 5 do |
||
509 | getglobal("TimersMainFrameSortButton"..i):Show(); |
||
510 | end |
||
511 | |||
512 | TimersMainFrameSortButton1:SetWidth(200); |
||
513 | |||
514 | for i = 1, 10 do |
||
515 | getglobal("TimersMainFrameTimerRow"..i.."Active"):Show(); |
||
516 | getglobal("TimersMainFrameTimerRow"..i.."DeleteButton"):Hide(); |
||
517 | getglobal("TimersMainFrameTimerRow"..i.."EditBox1"):SetPoint("TOPLEFT","$parentMenuButton","TOPRIGHT",20,0); |
||
518 | getglobal("TimersMainFrameTimerRow"..i.."Middle"):SetWidth(660); |
||
519 | getglobal("TimersMainFrameTimerRow"..i.."EditBox1"):SetWidth(160); |
||
520 | getglobal("TimersMainFrameTimerRow"..i.."EditBox2"):SetPoint("TOPLEFT","$parentEditBox1","TOPRIGHT",0,0); |
||
521 | for j = 3, 5 do |
||
522 | getglobal("TimersMainFrameTimerRow"..i.."EditBox"..j):Show(); |
||
523 | end |
||
524 | end |
||
525 | Timers_SetTriggerData(); |
||
526 | elseif configdata.activetab == 4 then |
||
527 | for i = 1, 10 do |
||
528 | getglobal("TimersMainFrameTimerRow"..i):Hide(); |
||
529 | end |
||
530 | TimersMainFrame:SetWidth(330); |
||
531 | TimersMainFrameScrollFrame:Hide(); |
||
532 | TimersMainFrameMenuButton:Hide(); |
||
533 | TimersMainFrameSortButton1:Hide(); |
||
534 | TimersMainFrameSortButton2:Hide(); |
||
535 | TimersMainFrameConfig:Show(); |
||
536 | elseif configdata.activetab == 5 then |
||
537 | for i = 1, 10 do |
||
538 | getglobal("TimersMainFrameTimerRow"..i):Hide(); |
||
539 | end |
||
540 | TimersMainFrame:SetWidth(330); |
||
541 | TimersMainFrameScrollFrame:Hide(); |
||
542 | TimersMainFrameMenuButton:Hide(); |
||
543 | TimersMainFrameSortButton1:Hide(); |
||
544 | TimersMainFrameSortButton2:Hide(); |
||
545 | TimersMainFrameHelp:Show(); |
||
546 | end |
||
547 | end |
||
548 | |||
549 | function Timers_ShowHelp(nr) |
||
550 | TimersMainFrameHelp:Hide(); |
||
551 | TimersMainFrameTextFrame:Show(); |
||
552 | if nr == 1 then |
||
553 | TimersMainFrameHelpFrameText:SetText(TIMERS_LOC_HELP_CAT1); |
||
554 | elseif nr == 2 then |
||
555 | TimersMainFrameHelpFrameText:SetText(TIMERS_LOC_HELP_CAT2); |
||
556 | elseif nr == 3 then |
||
557 | TimersMainFrameHelpFrameText:SetText(TIMERS_LOC_HELP_CAT3); |
||
558 | elseif nr == 4 then |
||
559 | TimersMainFrameHelpFrameText:SetText(TIMERS_LOC_HELP_CAT4); |
||
560 | elseif nr == 5 then |
||
561 | TimersMainFrameHelpFrameText:SetText(TIMERS_LOC_HELP_CAT5); |
||
562 | elseif nr == 6 then |
||
563 | TimersMainFrameHelpFrameText:SetText(TIMERS_LOC_HELP_CAT6); |
||
564 | elseif nr == 7 then |
||
565 | TimersMainFrameHelpFrameText:SetText(TIMERS_LOC_HELP_CAT7); |
||
566 | end |
||
567 | end |
||
568 | |||
569 | function Timers_WindowControl() |
||
570 | TimersMainFrame:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", configdata.mainframeposx, configdata.mainframeposy); |
||
571 | TimersNameBar:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", configdata.namebarposx , configdata.namebarposy); |
||
572 | TimersMinimizedFrame:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", configdata.minimizedposx , configdata.minimizedposy); |
||
573 | TimersTriggersConfigFrame:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", configdata.triggerconfposx , configdata.triggerconfposy); |
||
574 | if configdata.usenamebar and not (configdata.hidenamebar) then |
||
575 | TimersNameBar:Show(); |
||
576 | else |
||
577 | TimersNameBar:Hide(); |
||
578 | end |
||
579 | Timers_MinimizedControl(); |
||
580 | end |
||
581 | |||
582 | function Timers_ScaleControl() |
||
583 | TimersMainFrame:SetScale(configdata.framescale/100); |
||
584 | TimersNameBar:SetScale(configdata.framescale/100); |
||
585 | TimersMinimizedFrame:SetScale(configdata.framescale/100); |
||
586 | end |
||
587 | |||
588 | function Timers_MinimizedControl() |
||
589 | if configdata.minimized then |
||
590 | TimersMainFrame:Hide(); |
||
591 | TimersMinimizedFrame:Show(); |
||
592 | if (not (configdata.titletext)) or configdata.titletext == "" then |
||
593 | TimersMinimizedFrame:SetWidth(100); |
||
594 | else |
||
595 | TimersMinimizedFrame:SetWidth(207); |
||
596 | end |
||
597 | else |
||
598 | TimersMainFrame:Show(); |
||
599 | TimersMinimizedFrame:Hide(); |
||
600 | end |
||
601 | end |
||
602 | |||
603 | function TimersConfig_ToggleNameBar() |
||
604 | if(this:GetChecked() ~= nil) then |
||
605 | TimersNameBar:Show(); |
||
606 | configdata.usenamebar = true; |
||
607 | else |
||
608 | TimersNameBar:Hide(); |
||
609 | configdata.usenamebar = false; |
||
610 | end |
||
611 | end |
||
612 | |||
613 | function Timers_ToggleNamebox() |
||
614 | if(configdata.hidenamebar) then |
||
615 | configdata.hidenamebar = nil; |
||
616 | TimersNameBar:Show(); |
||
617 | else |
||
618 | configdata.hidenamebar = true; |
||
619 | TimersNameBar:Hide(); |
||
620 | end |
||
621 | end |
||
622 | |||
623 | function Timers_ShowAdvancedConfig() |
||
624 | trigger_edit = Timers_RowToTrigger(timers_dropdown_row+FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame)); |
||
625 | TimersTriggersConfigFrameNameInput:SetText(triggerdata[trigger_edit].name); |
||
626 | TimersTriggersConfigFrameTimeInput:SetText(Timers_TimeToText(tonumber(Timers_GetFieldValue(triggerdata[trigger_edit],"time")))); |
||
627 | TimersTriggersConfigFrameTextBox:SetText(triggerdata[trigger_edit].text); |
||
628 | if triggerdata[trigger_edit].mode then |
||
629 | TimersTriggersConfigFrameModeBox:SetText(triggerdata[trigger_edit].mode); |
||
630 | else |
||
631 | TimersTriggersConfigFrameModeBox:SetText(TIMERS_LOC_DEFAULT); |
||
632 | end |
||
633 | if triggerdata[trigger_edit].type then |
||
634 | TimersTriggersConfigFrameTypeBox:SetText(triggerdata[trigger_edit].type); |
||
635 | else |
||
636 | TimersTriggersConfigFrameTypeBox:SetText(TIMERS_LOC_DEFAULT); |
||
637 | end |
||
638 | if triggerdata[trigger_edit].warnchannel then |
||
639 | TimersTriggersConfigFrameWarnChanBox:SetText(triggerdata[trigger_edit].warnchannel); |
||
640 | else |
||
641 | TimersTriggersConfigFrameWarnChanBox:SetText(TIMERS_LOC_DEFAULT); |
||
642 | end |
||
643 | TimersTriggersConfigFrameWarnTimeInput:SetText(Timers_GetFieldValue(triggerdata[trigger_edit],"prewarn")); |
||
644 | TimersTriggersConfigFrameWarnMessInput:SetText(Timers_GetFieldValue(triggerdata[trigger_edit],"warnmessage")); |
||
645 | if triggerdata[trigger_edit].channel then |
||
646 | TimersTriggersConfigFrameExpChanBox:SetText(triggerdata[trigger_edit].channel); |
||
647 | else |
||
648 | TimersTriggersConfigFrameExpChanBox:SetText(TIMERS_LOC_DEFAULT); |
||
649 | end |
||
650 | TimersTriggersConfigFrameExpMessInput:SetText(Timers_GetFieldValue(triggerdata[trigger_edit],"message")); |
||
651 | TimersTriggersConfigFrameThresholdInput:SetText(Timers_GetFieldValue(triggerdata[trigger_edit],"threshold")); |
||
652 | TimersTriggersConfigFrameCountInput:SetText(Timers_GetFieldValue(triggerdata[trigger_edit],"count")); |
||
653 | TimersTriggersConfigFrame:Show(); |
||
654 | end |
||
655 | |||
656 | |||
657 | function TimersSlash_Reset() |
||
658 | configdata = Timers_cloneTable(configdata_DEFAULT); |
||
659 | TimersNameBarNameBox:SetText(configdata.namebartext); |
||
660 | Timers_ScaleControl(); |
||
661 | Timers_WindowControl(); |
||
662 | Timers_TabContentControl(); |
||
663 | Timers_PrintText(TIMERS_LOC_RESETTED); |
||
664 | end |
||
665 | |||
666 | function TimersSlash_Invoke(name) |
||
667 | local NotSucc = true; |
||
668 | for i = 1, table.getn(triggerdata) do |
||
669 | if triggerdata[i].name == name then |
||
670 | Timers_StartTimer(triggerdata[i],nil); |
||
671 | Timers_PrintText(name..TIMERS_LOC_MSGINVOKED); |
||
672 | NotSucc = false; |
||
673 | timerUpdateFlag = true; |
||
674 | end |
||
675 | end |
||
676 | if NotSucc then |
||
677 | Timers_PrintText(TIMERS_LOC_NO_TRIGGERNAME); |
||
678 | end |
||
679 | end |
||
680 | |||
681 | |||
682 | function TimersConfig_Reset() |
||
683 | configdata = Timers_cloneTable(configdata_DEFAULT); |
||
684 | configdata.activetab = 4; |
||
685 | TimersNameBarNameBox:SetText(configdata.namebartext); |
||
686 | Timers_ScaleControl(); |
||
687 | Timers_WindowControl(); |
||
688 | Timers_TabContentControl(); |
||
689 | end |
||
690 | |||
691 | function TimersEdit_ToggleDisableAll() |
||
692 | if configdata.alldisabled then |
||
693 | configdata.alldisabled = false; |
||
694 | Timers_PrintText(TIMERS_LOC_ALLTRIGGER_ENABLED); |
||
695 | else |
||
696 | configdata.alldisabled = true; |
||
697 | Timers_PrintText(TIMERS_LOC_ALLTRIGGER_DISABLED); |
||
698 | end |
||
699 | end |
||
700 | |||
701 | function Timers_SetSort(arg) |
||
702 | if configdata.activetab == 1 then |
||
703 | if not IsShiftKeyDown() then |
||
704 | if configdata.timersortascending then |
||
705 | configdata.timersortascending = false; |
||
706 | else |
||
707 | configdata.timersortascending = true; |
||
708 | end |
||
709 | configdata.timersort = arg; |
||
710 | table.sort(timerdata, Timers_CompareTimers); |
||
711 | timerUpdateFlag = true; |
||
712 | else |
||
713 | Timers_SpamOnPress(arg); |
||
714 | end |
||
715 | else |
||
716 | if configdata.triggersortascending then |
||
717 | configdata.triggersortascending = false; |
||
718 | else |
||
719 | configdata.triggersortascending = true; |
||
720 | end |
||
721 | configdata.triggersort = arg; |
||
722 | table.sort(triggerdata, Timers_CompareTriggers); |
||
723 | Timers_SetTriggerData(); |
||
724 | end |
||
725 | if not IsShiftKeyDown() then |
||
726 | Timers_UpdateSortArrows(); |
||
727 | end |
||
728 | end |
||
729 | |||
730 | function Timers_UpdateSortArrows() |
||
731 | for i = 1, 5 do |
||
732 | getglobal("TimersMainFrameSortButton"..i.."Arrow"):Hide(); |
||
733 | end |
||
734 | if configdata.activetab == 1 or configdata.activetab == 2 then |
||
735 | getglobal("TimersMainFrameSortButton"..configdata.timersort.."Arrow"):Show(); |
||
736 | else |
||
737 | getglobal("TimersMainFrameSortButton"..configdata.triggersort.."Arrow"):Show(); |
||
738 | end |
||
739 | end |
||
740 | |||
741 | function Timers_MsgSendTo(msg, channel) |
||
742 | if channel == TIMERS_LOC_RAID or channel == TIMERS_LOC_CTRAID then |
||
743 | if GetNumRaidMembers() == 0 then |
||
744 | msg = TIMERS_LOC_NOT_IN_RAID..": "..msg; |
||
745 | channel = TIMERS_LOC_SELF; |
||
746 | elseif channel == TIMERS_LOC_RAID then |
||
747 | SendChatMessage(msg,"RAID"); |
||
748 | else |
||
749 | CT_RA_AddMessage("MS "..msg); |
||
750 | end |
||
751 | end |
||
752 | if channel == TIMERS_LOC_PARTY then |
||
753 | if GetNumPartyMembers() == 0 then |
||
754 | msg = TIMERS_LOC_NOT_IN_PARTY..": "..msg; |
||
755 | channel = TIMERS_LOC_SELF; |
||
756 | else |
||
757 | SendChatMessage(msg,"PARTY"); |
||
758 | end |
||
759 | end |
||
760 | if channel == TIMERS_LOC_SELF then |
||
761 | Timers_PrintText(msg); |
||
762 | end |
||
763 | if channel == TIMERS_LOC_REPLY then |
||
764 | SendChatMessage(msg,"WHISPER",nil,ChatEdit_GetLastTellTarget(ChatFrameEditBox)); |
||
765 | end |
||
766 | if channel == TIMERS_LOC_OFFICER then |
||
767 | SendChatMessage(msg,"OFFICER"); |
||
768 | end |
||
769 | end |
||
770 | |||
771 | function TimersSend_Timer(row, channel) |
||
772 | local Offset = FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame); |
||
773 | TimersSend_TimerByNr(row+Offset,channel); |
||
774 | end |
||
775 | |||
776 | function TimersSend_TimerByNr(i,channel) |
||
777 | if not (Timers_GetFieldValue(triggerdata[Timers_TriggerNameToNumber(timerdata[i].trigger)],"mode") == TIMERS_LOC_INC) then |
||
778 | msg = timerdata[i].name.." "..TIMERS_LOC_EXPIRES_IN..": "..Timers_TimeToText(timerdata[i].time-Timers_GetLocalTime()); |
||
779 | else |
||
780 | msg = timerdata[i].name.." "..TIMERS_LOC_IS_CURRENTLY_AT..": "..Timers_TimeToText(Timers_GetLocalTime()-timerdata[i].time); |
||
781 | end |
||
782 | if not channel then |
||
783 | channel = Timers_GetFieldValue(triggerdata[Timers_TriggerNameToNumber(timerdata[i].trigger)],"channel"); |
||
784 | end |
||
785 | Timers_MsgSendTo(msg, channel); |
||
786 | end |
||
787 | |||
788 | function TimersSend_AllTimer(channel) |
||
789 | for i = 1, table.getn(timerdata) do |
||
790 | TimersSend_TimerByNr(i,channel); |
||
791 | end |
||
792 | end |
||
793 | |||
794 | function TimersSend_ToActive(msg) |
||
795 | local channel = ChatFrameEditBox.chatType; |
||
796 | if channel == "WHISPER" then |
||
797 | SendChatMessage(msg,"WHISPER",nil,ChatFrameEditBox.tellTarget); |
||
798 | else |
||
799 | SendChatMessage(msg,ChatFrameEditBox.chatType); |
||
800 | end |
||
801 | end |
||
802 | |||
803 | function Timers_SpamOnPress(arg) |
||
804 | if arg == 1 then |
||
805 | if configdata.spamonpress < table.getn(timerdata) then |
||
806 | max = configdata.spamonpress |
||
807 | else |
||
808 | max = table.getn(timerdata) |
||
809 | end |
||
810 | for i = 1, max do |
||
811 | if not (Timers_GetFieldValue(triggerdata[Timers_TriggerNameToNumber(timerdata[i].trigger)],"mode") == TIMERS_LOC_INC) then |
||
812 | msg = timerdata[i].name.." "..TIMERS_LOC_EXPIRES_IN..": "..Timers_TimeToText(timerdata[i].time-Timers_GetLocalTime()); |
||
813 | else |
||
814 | msg = timerdata[i].name.." "..TIMERS_LOC_IS_CURRENTLY_AT..": "..Timers_TimeToText(Timers_GetLocalTime()-timerdata[i].time); |
||
815 | end |
||
816 | TimersSend_ToActive(msg); |
||
817 | end |
||
818 | else |
||
819 | for i = 1, table.getn(timerdata) do |
||
820 | if timerdata[i].time-Timers_GetLocalTime() < configdata.spamonpress*60 then |
||
821 | if not (Timers_GetFieldValue(triggerdata[Timers_TriggerNameToNumber(timerdata[i].trigger)],"mode") == TIMERS_LOC_INC) then |
||
822 | msg = timerdata[i].name.." "..TIMERS_LOC_EXPIRES_IN..": "..Timers_TimeToText(timerdata[i].time-Timers_GetLocalTime()); |
||
823 | else |
||
824 | msg = timerdata[i].name.." "..TIMERS_LOC_IS_CURRENTLY_AT..": "..Timers_TimeToText(Timers_GetLocalTime()-timerdata[i].time); |
||
825 | end |
||
826 | TimersSend_ToActive(msg); |
||
827 | end |
||
828 | end |
||
829 | end |
||
830 | end |
||
831 | |||
832 | function Timers_SpamOnWhisper(arg,name) |
||
833 | if arg == nil or arg == "" then |
||
834 | arg = configdata.spamonpress; |
||
835 | else |
||
836 | arg = tonumber(arg); |
||
837 | end |
||
838 | local NotSend = true; |
||
839 | for i = 1, table.getn(timerdata) do |
||
840 | if timerdata[i].time-Timers_GetLocalTime() < arg*60 then |
||
841 | if not (Timers_GetFieldValue(triggerdata[Timers_TriggerNameToNumber(timerdata[i].trigger)],"mode") == TIMERS_LOC_INC) then |
||
842 | msg = timerdata[i].name.." "..TIMERS_LOC_EXPIRES_IN..": "..Timers_TimeToText(timerdata[i].time-Timers_GetLocalTime()); |
||
843 | else |
||
844 | msg = timerdata[i].name.." "..TIMERS_LOC_IS_CURRENTLY_AT..": "..Timers_TimeToText(timerdata[i].time-Timers_GetLocalTime()); |
||
845 | end |
||
846 | SendChatMessage(msg,"WHISPER",nil,name); |
||
847 | NotSend = false; |
||
848 | end |
||
849 | end |
||
850 | if NotSend then |
||
851 | SendChatMessage(TIMERS_LOC_NO_TIMERS_EXPIRING,"WHISPER",nil,name); |
||
852 | end |
||
853 | end |
||
854 | |||
855 | function Timers_GetLocalTime() |
||
856 | local strtime = date("%j%H%M%S"); |
||
857 | local time = tonumber(string.sub(strtime,-2)); |
||
858 | time = time + tonumber(string.sub(strtime,-4,-3)) * 60; |
||
859 | time = time + tonumber(string.sub(strtime,-6,-5)) * 3600; |
||
860 | time = time + tonumber(string.sub(strtime,-9,-7)) * 86400; |
||
861 | return time; |
||
862 | end |
||
863 | |||
864 | -- OnEvent Functions |
||
865 | |||
866 | function Timers_OnEvent(event) |
||
867 | if event == "VARIABLES_LOADED" then |
||
868 | if state and state.triggerList then |
||
869 | Timers_ImportTrigger(); |
||
870 | end |
||
871 | Timers_VersionCorrections(); |
||
872 | Timers_CheckForNewTrigger(); |
||
873 | Timers_CorrectTimerData(); |
||
874 | Timers_SetSort(configdata.timersort); |
||
875 | Timers_WindowControl(); |
||
876 | Timers_TabControl(getglobal("TimersMainFrameTabButton"..configdata.activetab)); |
||
877 | TimersNameBarNameBox:SetText(configdata.namebartext); |
||
878 | elseif event == "CHAT_MSG_WHISPER" then |
||
879 | if (string.find(arg1, "showtime") ~= nil) then |
||
880 | local _,n = string.find(arg1,"showtime"); |
||
881 | n = tonumber(string.sub(arg1, n+2)); |
||
882 | Timers_SpamOnWhisper(n,arg2); |
||
883 | end |
||
884 | elseif event == "TRAINER_CLOSED" or event == "SPELLS_CHANGED" then |
||
885 | Timers_CreateIconArray(); |
||
886 | else |
||
887 | local text; |
||
888 | if (event == "SPELLCAST_START" or event == "SPELLCAST_STOP" or event == "SPELLCAST_FAILED" or event == "SPELLCAST_INTERRUPTED") then |
||
889 | Timers_SpellEvent(event,arg1,arg2); |
||
890 | else |
||
891 | if (event == "CHAT_MSG_MONSTER_EMOTE") then |
||
892 | text = arg2.." "..arg1; |
||
893 | elseif (event == "ZONE_CHANGED_NEW_AREA" or event == "ZONE_CHANGED" or event == "ZONE_CHANGED_INDOORS") then |
||
894 | Timers_ZoneEvent(); |
||
895 | elseif (event ~= nil) then |
||
896 | text = arg1; |
||
897 | end |
||
898 | if text then |
||
899 | Timers_EventParser(event,text); |
||
900 | end |
||
901 | end |
||
902 | end |
||
903 | end |
||
904 | |||
905 | function Timers_OnLoad() |
||
906 | |||
907 | Timers_OldSpellHook = CastSpell; |
||
908 | Timers_OldSpellHookByName = CastSpellByName; |
||
909 | Timers_OldUseAction = UseAction; |
||
910 | CastSpell = Timers_SpellHook; |
||
911 | CastSpellByName = Timers_SpellHookByName; |
||
912 | UseAction = Timers_UseActionHook; |
||
913 | this:SetBackdropColor(0.0, 0.0, 0.0, 0.8); |
||
914 | |||
915 | this:RegisterEvent("CHAT_MSG_SPELL_TRADESKILLS"); |
||
916 | this:RegisterEvent("VARIABLES_LOADED"); |
||
917 | this:RegisterEvent("CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE"); |
||
918 | this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS"); |
||
919 | this:RegisterEvent("CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF"); |
||
920 | this:RegisterEvent("CHAT_MSG_SPELL_HOSTILEPLAYER_DAMAGE"); |
||
921 | this:RegisterEvent("CHAT_MSG_SPELL_HOSTILEPLAYER_BUFF"); |
||
922 | this:RegisterEvent("CHAT_MSG_MONSTER_EMOTE"); |
||
923 | this:RegisterEvent("CHAT_MSG_MONSTER_SAY"); |
||
924 | this:RegisterEvent("CHAT_MSG_MONSTER_YELL"); |
||
925 | this:RegisterEvent("CHAT_MSG_MONSTER_WHISPER"); |
||
926 | this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE"); |
||
927 | this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_BUFFS"); |
||
928 | this:RegisterEvent("CHAT_MSG_SPELL_AURA_GONE_OTHER"); |
||
929 | this:RegisterEvent("CHAT_MSG_COMBAT_HOSTILE_DEATH"); |
||
930 | this:RegisterEvent("CHAT_MSG_WHISPER"); |
||
931 | this:RegisterEvent("CHAT_MSG_LOOT"); |
||
932 | this:RegisterEvent("CHAT_MSG_COMBAT_CREATURE_VS_SELF_HITS"); |
||
933 | this:RegisterEvent("CHAT_MSG_COMBAT_CREATURE_VS_SELF_MISSES"); |
||
934 | this:RegisterEvent("ZONE_CHANGED_NEW_AREA"); |
||
935 | this:RegisterEvent("ZONE_CHANGED_INDOORS"); |
||
936 | this:RegisterEvent("ZONE_CHANGED"); |
||
937 | this:RegisterEvent("SPELLCAST_START"); |
||
938 | this:RegisterEvent("SPELLCAST_STOP"); |
||
939 | this:RegisterEvent("SPELLCAST_FAILED"); |
||
940 | this:RegisterEvent("SPELLCAST_INTERRUPTED"); |
||
941 | this:RegisterEvent("TRAINER_CLOSED"); |
||
942 | this:RegisterEvent("SPELLS_CHANGED"); |
||
943 | |||
944 | SlashCmdList["TIMERCOMMANDS"] = Timers_SlashCommandHandler; |
||
945 | SLASH_TIMERCOMMANDS1 = "/atimer"; |
||
946 | SLASH_TIMERCOMMANDS2 = "/ati"; |
||
947 | triggerdata_DEFAULT = Timers_cloneTable(triggerdata); |
||
948 | configdata_DEFAULT = Timers_cloneTable(configdata); |
||
949 | groupdata_DEFAULT = Timers_cloneTable(groupdata); |
||
950 | end |
||
951 | |||
952 | function Timers_CheckForOnce(name) |
||
953 | for i = 1, table.getn(timerdata) do |
||
954 | if timerdata[i].trigger == name then |
||
955 | return false; |
||
956 | end |
||
957 | end |
||
958 | return true; |
||
959 | end |
||
960 | |||
961 | function Timers_CheckForOnceGroup(name) |
||
962 | for i = 1, table.getn(timerdata) do |
||
963 | if triggerdata[Timers_TriggerNameToNumber(timerdata[i].trigger)].group == name then |
||
964 | return false; |
||
965 | end |
||
966 | end |
||
967 | return true; |
||
968 | end |
||
969 | |||
970 | function Timers_ZoneEvent(event) |
||
971 | if event == "ZONE_CHANGED_NEW_AREA" then |
||
972 | currentZone = GetZoneText(); |
||
973 | else |
||
974 | currentZone = GetSubZoneText(); |
||
975 | end |
||
976 | for i = 1, table.getn(triggerdata) do |
||
977 | if string.find(triggerdata[i].text,currentZone) and string.find(triggerdata[i].text,TIMERS_LOC_ZONEENTER) then |
||
978 | Timers_EventParser(event,triggerdata[i].text); |
||
979 | end |
||
980 | end |
||
981 | end |
||
982 | |||
983 | function Timers_SpellEvent(event,arg1,arg2) |
||
984 | if event == "SPELLCAST_FAILED" or event == "SPELLCAST_INTERRUPTED" then |
||
985 | currSpellCast = nil; |
||
986 | elseif event == "SPELLCAST_STOP" then |
||
987 | if currSpellCast then |
||
988 | Timers_EventParser(event,currSpellCast.text); |
||
989 | currSpellCast = nil; |
||
990 | end |
||
991 | end |
||
992 | end |
||
993 | |||
994 | function Timers_ParseSpellName(name) |
||
995 | Timers_PrintDebug("Action: "..name); |
||
996 | for i = 1, table.getn(triggerdata) do |
||
997 | if string.find(triggerdata[i].text, TIMERS_LOC_SPELL_CAST) and string.find(triggerdata[i].text, name) then |
||
998 | currSpellCast = triggerdata[i]; |
||
999 | end |
||
1000 | end |
||
1001 | end |
||
1002 | |||
1003 | function Timers_SpellHook(ID,book) |
||
1004 | Timers_ParseSpellName(GetSpellName(ID,book)); |
||
1005 | Timers_OldSpellHook(ID,book); |
||
1006 | end |
||
1007 | |||
1008 | function Timers_SpellHookByName(name) |
||
1009 | Timers_ParseSpellName(name); |
||
1010 | Timers_OldSpellHookByName(name); |
||
1011 | end |
||
1012 | |||
1013 | function Timers_UseActionHook(slot,arg1,arg2) |
||
1014 | if (not (GetActionText(slot))) and IconArray[GetActionTexture(slot)] then |
||
1015 | Timers_ParseSpellName(IconArray[GetActionTexture(slot)]); |
||
1016 | end |
||
1017 | Timers_OldUseAction(slot,arg1,arg2); |
||
1018 | end |
||
1019 | |||
1020 | function Timers_EventParser(event,msg) |
||
1021 | for i = 1, table.getn(triggerdata) do |
||
1022 | if string.find(msg,triggerdata[i].text) then |
||
1023 | if (not (triggerdata[i].lastinvoked) or triggerdata[i].lastinvoked+tonumber(Timers_GetFieldValue(triggerdata[i],"threshold"))<Timers_GetLocalTime()) and not (triggerdata[i].inactive or groupdata[Timers_GroupNameToNumber(triggerdata[i].group)].inactive) then |
||
1024 | if Timers_GetFieldValue(triggerdata[i],"type") == TIMERS_LOC_MULTIPLE then |
||
1025 | Timers_StartTimer(triggerdata[i],msg); |
||
1026 | elseif Timers_GetFieldValue(triggerdata[i],"type") == TIMERS_LOC_ONCE and Timers_CheckForOnce(triggerdata[i].name) then |
||
1027 | Timers_StartTimer(triggerdata[i],msg); |
||
1028 | elseif Timers_GetFieldValue(triggerdata[i],"type") == TIMERS_LOC_ONCEGROUP and Timers_CheckForOnceGroup(triggerdata[i].group) then |
||
1029 | Timers_StartTimer(triggerdata[i],msg); |
||
1030 | elseif Timers_GetFieldValue(triggerdata[i],"type") == TIMERS_LOC_PAUSE then |
||
1031 | if Timers_CheckForOnceGroup(triggerdata[i].group) then |
||
1032 | Timers_StartTimer(triggerdata[i],msg); |
||
1033 | else |
||
1034 | for j = 1, table.getn(timerdata) do |
||
1035 | if triggerdata[Timers_TriggerNameToNumber(timerdata[j].trigger)].group == triggerdata[i].group then |
||
1036 | TimersEdit_TogglePaused(nil,j); |
||
1037 | Timers_WarnOnly(triggerdata[i],msg,timerdata[j].time); |
||
1038 | end |
||
1039 | end |
||
1040 | end |
||
1041 | elseif Timers_GetFieldValue(triggerdata[i],"type") == TIMERS_LOC_STOP then |
||
1042 | for j = 1, table.getn(timerdata) do |
||
1043 | if triggerdata[Timers_TriggerNameToNumber(timerdata[j].trigger)].group == triggerdata[i].group then |
||
1044 | TimersEdit_StopTimer(arg,j); |
||
1045 | end |
||
1046 | end |
||
1047 | elseif Timers_GetFieldValue(triggerdata[i],"type") == TIMERS_LOC_WARNONLY then |
||
1048 | Timers_WarnOnly(triggerdata[i],msg); |
||
1049 | end |
||
1050 | end |
||
1051 | timerUpdateFlag = true; |
||
1052 | end |
||
1053 | end |
||
1054 | end |
||
1055 | |||
1056 | function Timers_StartTimer(trigger,msg) |
||
1057 | trigger.lastinvoked = Timers_GetLocalTime(); |
||
1058 | if trigger.count then |
||
1059 | trigger.count = trigger.count + 1; |
||
1060 | else |
||
1061 | trigger.count = 1; |
||
1062 | end |
||
1063 | if configdata.usenamebar then |
||
1064 | Timers_StartByEvent(configdata.namebartext,trigger,msg); |
||
1065 | else |
||
1066 | if not (StaticPopup_Visible(TIMERS_MESSAGE_POPUP)) then |
||
1067 | StaticPopupDialogs["TIMERS_MESSAGE_POPUP"].text = TIMERS_LOC_NEW_TIMER_NAME; |
||
1068 | StaticPopupDialogs["TIMERS_MESSAGE_POPUP"].arg1 = trigger; |
||
1069 | StaticPopupDialogs["TIMERS_MESSAGE_POPUP"].arg2 = msg; |
||
1070 | Timers_OnMessageBoxAccept = Timers_StartByEvent; |
||
1071 | StaticPopup_Show("TIMERS_MESSAGE_POPUP"); |
||
1072 | elseif trigger.type == TIMERS_LOC_PAUSE then |
||
1073 | if Timers_OnMessageBoxAccept == Timers_StartPausedByEvent then |
||
1074 | Timers_OnMessageBoxAccept = Timers_StartByEvent; |
||
1075 | else |
||
1076 | Timers_OnMessageBoxAccept = Timers_StartPausedByEvent; |
||
1077 | end |
||
1078 | end |
||
1079 | end |
||
1080 | end |
||
1081 | |||
1082 | function Timers_StartByEvent(name,trigger,msg) |
||
1083 | name = string.gsub(name,"!count",Timers_GetFieldValue(trigger,"count")); |
||
1084 | name = string.gsub(name,"!coord",TimersString_Replace_Coord()); |
||
1085 | name = string.gsub(name,"!trigger",trigger.name); |
||
1086 | if Timers_GetFieldValue(trigger,"mode") == TIMERS_LOC_INC then |
||
1087 | table.insert(timerdata, {name=name, time=Timers_GetLocalTime()-tonumber(Timers_GetFieldValue(trigger,"time")), trigger=trigger.name, msg = msg}); |
||
1088 | else |
||
1089 | table.insert(timerdata, {name=name, time=tonumber(Timers_GetFieldValue(trigger,"time"))+Timers_GetLocalTime(), trigger=trigger.name, msg = msg}); |
||
1090 | end |
||
1091 | timerUpdateFlag = true; |
||
1092 | end |
||
1093 | |||
1094 | function Timers_StartPausedByEvent(name,trigger,msg) |
||
1095 | name = string.gsub(name,"!count",Timers_GetFieldValue(trigger,"count")); |
||
1096 | name = string.gsub(name,"!coord",TimersString_Replace_Coord()); |
||
1097 | name = string.gsub(name,"!trigger",trigger.name); |
||
1098 | if Timers_GetFieldValue(trigger,"mode") == TIMERS_LOC_INC then |
||
1099 | table.insert(timerdata, {name=name, time=Timers_GetLocalTime()-tonumber(Timers_GetFieldValue(trigger,"time")), trigger=trigger.name, msg = msg, paused = Timers_GetLocalTime()}); |
||
1100 | else |
||
1101 | table.insert(timerdata, {name=name, time=tonumber(Timers_GetFieldValue(trigger,"time"))+Timers_GetLocalTime(), trigger=trigger.name, msg = msg, paused = Timers_GetLocalTime()}); |
||
1102 | end |
||
1103 | timerUpdateFlag = true; |
||
1104 | end |
||
1105 | |||
1106 | function Timers_OnUpdate(arg1) |
||
1107 | timeSinceUpdate = timeSinceUpdate + arg1; |
||
1108 | if (timeSinceUpdate > 0.25) then |
||
1109 | if (not UnitAffectingCombat("player")) and inCombat then |
||
1110 | inCombat = false; |
||
1111 | Timers_EventParser(nil,TIMERS_LOC_COMBATSTOP); |
||
1112 | end |
||
1113 | if UnitAffectingCombat("player") and not inCombat then |
||
1114 | inCombat = true; |
||
1115 | Timers_EventParser(nil,TIMERS_LOC_COMBATSTART); |
||
1116 | end |
||
1117 | if configdata.activetab == 1 or configdata.activetab == 2 then |
||
1118 | if timerUpdateFlag then |
||
1119 | table.sort(timerdata,Timers_CompareTimers); |
||
1120 | Timers_SetTimerData(); |
||
1121 | timerUpdateFlag = false; |
||
1122 | end |
||
1123 | Timers_UpdateTimes(); |
||
1124 | end |
||
1125 | if timeIsCorrect then |
||
1126 | TimerscurrentTime = Timers_GetLocalTime(); |
||
1127 | end |
||
1128 | if TimersMainFrame:GetScale() ~= (configdata.framescale/100) then |
||
1129 | Timers_ScaleControl(); |
||
1130 | -- Timers_WindowControl(); |
||
1131 | end |
||
1132 | Timers_UpdateTitle(); |
||
1133 | Timers_CheckWarnAllTimers(); |
||
1134 | timeSinceUpdate = 0; |
||
1135 | end |
||
1136 | end |
||
1137 | |||
1138 | function TimersMainFrame_OnScroll() |
||
1139 | if configdata.activetab == 1 then |
||
1140 | Timers_SetTimerData(); |
||
1141 | elseif configdata.activetab == 3 then |
||
1142 | Timers_SetTriggerData(); |
||
1143 | end |
||
1144 | end |
||
1145 | |||
1146 | function TimersFrame_ToggleMinimized() |
||
1147 | if configdata.minimized then |
||
1148 | configdata.minimized = false; |
||
1149 | else |
||
1150 | configdata.minimized = true; |
||
1151 | end |
||
1152 | Timers_MinimizedControl(); |
||
1153 | end |
||
1154 | |||
1155 | function Timers_TriggerMenuButton() |
||
1156 | if configdata.activetab == 3 and not getglobal(this:GetParent():GetName().."EditBox2"):IsVisible() then |
||
1157 | local i = Timers_GetRow(this) + FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame); |
||
1158 | local k = Timers_RowToGroup(i); |
||
1159 | if groupdata[k].fold then |
||
1160 | groupdata[k].fold = false; |
||
1161 | else |
||
1162 | groupdata[k].fold = true; |
||
1163 | end |
||
1164 | Timers_SetTriggerData(); |
||
1165 | else |
||
1166 | ToggleDropDownMenu(1, nil, getglobal(this:GetParent():GetName().."DropDownMenu"), this, 0, 0); |
||
1167 | end |
||
1168 | end |
||
1169 | |||
1170 | function Timers_ToggleFoldAll() |
||
1171 | local fold = 0; |
||
1172 | local unfold = 0; |
||
1173 | for i = 1, table.getn(groupdata) do |
||
1174 | if groupdata[i].fold then |
||
1175 | fold = fold + 1; |
||
1176 | else |
||
1177 | unfold = unfold + 1; |
||
1178 | end |
||
1179 | end |
||
1180 | local set; |
||
1181 | if fold > unfold then |
||
1182 | set = false; |
||
1183 | else |
||
1184 | set = true; |
||
1185 | end |
||
1186 | for i = 1, table.getn(groupdata) do |
||
1187 | groupdata[i].fold = set; |
||
1188 | end |
||
1189 | Timers_SetTriggerData(); |
||
1190 | end |
||
1191 | |||
1192 | function Timers_ToggleActiveAll() |
||
1193 | local active = 0; |
||
1194 | local inactive = 0; |
||
1195 | for i = 1, table.getn(triggerdata) do |
||
1196 | if triggerdata[i].inactive then |
||
1197 | inactive = inactive + 1; |
||
1198 | else |
||
1199 | active = active + 1; |
||
1200 | end |
||
1201 | end |
||
1202 | local set; |
||
1203 | if inactive > active then |
||
1204 | set = false; |
||
1205 | else |
||
1206 | set = true; |
||
1207 | end |
||
1208 | for i = 1, table.getn(groupdata) do |
||
1209 | groupdata[i].inactive = set; |
||
1210 | end |
||
1211 | for i = 1, table.getn(triggerdata) do |
||
1212 | triggerdata[i].inactive = set; |
||
1213 | end |
||
1214 | Timers_SetTriggerData(); |
||
1215 | end |
||
1216 | |||
1217 | function Timers_ResetAllCnt() |
||
1218 | for i = 1, table.getn(timerdata) do |
||
1219 | timerdata[i].count = 0; |
||
1220 | end |
||
1221 | Timers_SetTriggerData(); |
||
1222 | end |
||
1223 | |||
1224 | function Timers_ResetCnt(arg) |
||
1225 | local i = Timers_GetRow(arg) + FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame); |
||
1226 | triggerdata[Timers_RowToTrigger(i)].count = "0"; |
||
1227 | Timers_SetTriggerData(); |
||
1228 | end |
||
1229 | |||
1230 | function Timers_DeleteTrigger(arg) |
||
1231 | local i = Timers_GetRow(arg) + FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame); |
||
1232 | table.remove(triggerdata,Timers_RowToTrigger(i)); |
||
1233 | Timers_SetTriggerData(); |
||
1234 | end |
||
1235 | |||
1236 | |||
1237 | |||
1238 | -- System functions |
||
1239 | |||
1240 | function Timers_CompareTimers(item1, item2) |
||
1241 | if configdata.timersort == 1 then |
||
1242 | if configdata.timersortascending then |
||
1243 | return item1.name < item2.name; |
||
1244 | else |
||
1245 | return item1.name > item2.name; |
||
1246 | end |
||
1247 | elseif configdata.timersort == 2 then |
||
1248 | if configdata.timersortascending then |
||
1249 | return tonumber(item1.time) < tonumber(item2.time); |
||
1250 | else |
||
1251 | return tonumber(item1.time) > tonumber(item2.time); |
||
1252 | end |
||
1253 | end |
||
1254 | end |
||
1255 | |||
1256 | function Timers_CompareTriggers(item1, item2) |
||
1257 | if configdata.triggersort == 1 then |
||
1258 | return Timers_SortByText(item1,item2,"name"); |
||
1259 | elseif configdata.triggersort == 2 then |
||
1260 | return Timers_SortByNumber(item1,item2,"time"); |
||
1261 | elseif configdata.triggersort == 3 then |
||
1262 | return Timers_SortByNumber(item1, item2,"prewarn"); |
||
1263 | elseif configdata.triggersort == 4 then |
||
1264 | return Timers_SortByText(item1,item2,"text"); |
||
1265 | elseif configdata.triggersort == 5 then |
||
1266 | return Timers_SortByText(item1,item2,"message"); |
||
1267 | elseif configdata.triggersort == 6 then |
||
1268 | return Timers_SortByText(item1,item2,"channel"); |
||
1269 | elseif configdata.triggersort == 7 then |
||
1270 | return Timers_SortByNumber(item1,item2,"count"); |
||
1271 | elseif configdata.triggersort == 8 then |
||
1272 | return Timers_SortByNumber(item1,item2,"threshold"); |
||
1273 | elseif configdata.triggersort == 9 then |
||
1274 | return Timers_SortByText(item1,item2,"type"); |
||
1275 | elseif configdata.triggersort == 10 then |
||
1276 | return Timers_SortByText(item1,item2,"mode"); |
||
1277 | end |
||
1278 | end |
||
1279 | |||
1280 | function Timers_CompareGroups(item1, item2) |
||
1281 | return item1.name < item2.name; |
||
1282 | end |
||
1283 | |||
1284 | function Timers_SortByNumber(item1,item2,field) |
||
1285 | if not tonumber(item1[field]) or not tonumber(item2[field]) then |
||
1286 | if not tonumber(item1[field]) and not tonumber(item2[field]) then |
||
1287 | return false; |
||
1288 | elseif not tonumber(item1[field]) then |
||
1289 | if configdata.triggersortascending then |
||
1290 | return tonumber(Timers_GetDefaultValue(field)) < tonumber(item2[field]); |
||
1291 | else |
||
1292 | return tonumber(Timers_GetDefaultValue(field)) > tonumber(item2[field]); |
||
1293 | end |
||
1294 | else |
||
1295 | if configdata.triggersortascending then |
||
1296 | return tonumber(item1[field]) < tonumber(Timers_GetDefaultValue(field)); |
||
1297 | else |
||
1298 | return tonumber(item1[field]) > tonumber(Timers_GetDefaultValue(field)); |
||
1299 | end |
||
1300 | end |
||
1301 | elseif configdata.triggersortascending then |
||
1302 | return tonumber(item1[field]) < tonumber(item2[field]); |
||
1303 | else |
||
1304 | return tonumber(item1[field]) > tonumber(item2[field]); |
||
1305 | end |
||
1306 | end |
||
1307 | |||
1308 | function Timers_SortByText(item1,item2,field) |
||
1309 | if not item1[field] or not item2[field] then |
||
1310 | if not item1[field] and not item2[field] then |
||
1311 | return false; |
||
1312 | elseif not item1[field] then |
||
1313 | if configdata.triggersortascending then |
||
1314 | return Timers_GetDefaultValue(field) < item2[field]; |
||
1315 | else |
||
1316 | return Timers_GetDefaultValue(field) > item2[field]; |
||
1317 | end |
||
1318 | elseif configdata.triggersortascending then |
||
1319 | return item1[field] < Timers_GetDefaultValue(field); |
||
1320 | else |
||
1321 | return item1[field] > Timers_GetDefaultValue(field); |
||
1322 | end |
||
1323 | else |
||
1324 | if configdata.triggersortascending then |
||
1325 | return item1[field] < item2[field]; |
||
1326 | else |
||
1327 | return item1[field] > item2[field]; |
||
1328 | end |
||
1329 | end |
||
1330 | end |
||
1331 | |||
1332 | function Timers_DeleteGroup(nr) |
||
1333 | local hasTrigger = false; |
||
1334 | for i = 1, table.getn(triggerdata) do |
||
1335 | if triggerdata[i].group == groupdata[nr].name then |
||
1336 | hasTrigger = true; |
||
1337 | triggerdata[i].fromGroup = true; |
||
1338 | end |
||
1339 | end |
||
1340 | table.remove(groupdata, nr); |
||
1341 | if hasTrigger then |
||
1342 | StaticPopupDialogs["TIMERS_ACCEPT_POPUP"].text = TIMERS_LOC_DELETE_GROUP_NOT_EMPTY; |
||
1343 | Timers_OnAcceptBoxButton = Timers_SetNewGroupByBox; |
||
1344 | StaticPopup_Show("TIMERS_ACCEPT_POPUP"); |
||
1345 | else |
||
1346 | Timers_SetTriggerData(); |
||
1347 | end |
||
1348 | end |
||
1349 | |||
1350 | function Timers_TextToTime(text) |
||
1351 | local i = 0; |
||
1352 | local mul = 1; |
||
1353 | local time = 0; |
||
1354 | local minus = false; |
||
1355 | if string.sub(text,1,1) == "-" then |
||
1356 | minus = true; |
||
1357 | text = string.sub(text,2); |
||
1358 | end |
||
1359 | while string.find(text,":") do |
||
1360 | Pos = string.find(text,":",-3); |
||
1361 | time = time + mul*tonumber(string.sub(text,Pos+1)); |
||
1362 | text = string.sub(text,1,Pos-1); |
||
1363 | mul = mul*60; |
||
1364 | i=i+1; |
||
1365 | end |
||
1366 | if i == 3 then |
||
1367 | mul = 86400; |
||
1368 | end |
||
1369 | time = time + mul*tonumber(text); |
||
1370 | if minus then |
||
1371 | time = -time; |
||
1372 | end |
||
1373 | return time; |
||
1374 | end |
||
1375 | |||
1376 | function Timers_GetRow(arg) |
||
1377 | local i = 10; |
||
1378 | while i > 0 do |
||
1379 | if string.find(arg:GetName(),"Row"..i) then |
||
1380 | return i; |
||
1381 | end |
||
1382 | i = i - 1; |
||
1383 | end |
||
1384 | end |
||
1385 | |||
1386 | function Timers_ParseArguments(msg) |
||
1387 | local args = {}; |
||
1388 | local tmp = {}; |
||
1389 | |||
1390 | -- Find all space delimited words. |
||
1391 | for value in string.gfind(msg, "[^ ]+") do |
||
1392 | table.insert(tmp, value); |
||
1393 | end |
||
1394 | |||
1395 | -- Make a pass through the table, and concatenate all words that have quotes. |
||
1396 | local quoteOpened = false; |
||
1397 | local quotedArg = ""; |
||
1398 | for i = 1, table.getn(tmp) do |
||
1399 | if (string.find(tmp[i], "\"") == nil) then |
||
1400 | if (quoteOpened) then |
||
1401 | quotedArg = quotedArg.." "..string.gsub(tmp[i], "\"", ""); |
||
1402 | else |
||
1403 | table.insert(args, tmp[i]); |
||
1404 | end |
||
1405 | else |
||
1406 | for value in string.gfind(tmp[i], "\"") do |
||
1407 | quoteOpened = not quoteOpened; |
||
1408 | end |
||
1409 | |||
1410 | if (quoteOpened) then |
||
1411 | quotedArg = string.gsub(tmp[i], "\"", ""); |
||
1412 | else |
||
1413 | if (string.len(quotedArg) > 0) then |
||
1414 | quotedArg = quotedArg.." "..string.gsub(tmp[i], "\"", ""); |
||
1415 | else |
||
1416 | quotedArg = string.gsub(tmp[i], "\"", ""); |
||
1417 | end |
||
1418 | |||
1419 | table.insert(args, quotedArg); |
||
1420 | quotedArg = ""; |
||
1421 | end |
||
1422 | end |
||
1423 | end |
||
1424 | |||
1425 | if (string.len(quotedArg) > 0) then |
||
1426 | table.insert(args, quotedArg); |
||
1427 | end |
||
1428 | |||
1429 | return args; |
||
1430 | end |
||
1431 | |||
1432 | function Timers_SlashCommandHandler(msg) |
||
1433 | local command; |
||
1434 | local args; |
||
1435 | |||
1436 | args = Timers_ParseArguments(msg); |
||
1437 | |||
1438 | if (args[1] ~= nil) then |
||
1439 | command = string.lower(args[1]); |
||
1440 | end |
||
1441 | |||
1442 | if (command == "add") and (args[2] ~= nil and args[3] ~=nil) then |
||
1443 | Timers_add(args[2], args[3], args[4]); |
||
1444 | elseif (command == "reset") then |
||
1445 | TimersSlash_Reset(); |
||
1446 | elseif (command == "invoke" and args[2] ~= nil) then |
||
1447 | TimersSlash_Invoke(args[2]); |
||
1448 | elseif (command == "show") then |
||
1449 | ShowUIPanel(TimersMainFrame); |
||
1450 | elseif (command == "debug") then |
||
1451 | Timers_ToggleDebug() |
||
1452 | end |
||
1453 | end |
||
1454 | |||
1455 | function Timers_ShowMainPanel() |
||
1456 | ShowUIPanel(TimersMainFrame); |
||
1457 | if configdata.minimized then |
||
1458 | TimersFrame_ToggleMinimized(); |
||
1459 | end |
||
1460 | end |
||
1461 | |||
1462 | function Timers_PrintDebug(text) |
||
1463 | if Timers_Debug then |
||
1464 | Timers_PrintText("[DEBUG] "..text); |
||
1465 | end |
||
1466 | end |
||
1467 | |||
1468 | function Timers_ToggleDebug() |
||
1469 | if Timers_Debug then |
||
1470 | Timers_Debug = false; |
||
1471 | else |
||
1472 | Timers_Debug = true; |
||
1473 | end |
||
1474 | end |
||
1475 | |||
1476 | function Timers_PrintText(text) |
||
1477 | DEFAULT_CHAT_FRAME:AddMessage("|cFFFFFF00[Timers]: "..text.."|r"); |
||
1478 | end |
||
1479 | |||
1480 | function Timers_TimeToText(time) |
||
1481 | local TIME_FORMAT = "%02d:%02d:%02d"; |
||
1482 | local TIME_FORMAT_D = "%02d:%02d:%02d:%02d"; |
||
1483 | local absTime = math.abs(time); |
||
1484 | |||
1485 | local days=0; |
||
1486 | local hours = absTime / 3600; |
||
1487 | local minutes = math.mod(absTime / 60, 60); |
||
1488 | local seconds = math.mod(absTime, 60); |
||
1489 | |||
1490 | if(hours>=24) then |
||
1491 | days = hours/24; |
||
1492 | hours = math.mod(hours, 24); |
||
1493 | end |
||
1494 | |||
1495 | if (time >= 0) then |
||
1496 | if (days>0) then |
||
1497 | return format(TIME_FORMAT_D, days, hours, minutes, seconds); |
||
1498 | else |
||
1499 | return format(TIME_FORMAT, hours, minutes, seconds); |
||
1500 | end |
||
1501 | else |
||
1502 | return format("-"..TIME_FORMAT, hours, minutes, seconds); |
||
1503 | end |
||
1504 | end |
||
1505 | |||
1506 | function Timers_GetDefaultValue(field) |
||
1507 | if field == "text" then |
||
1508 | return " "; |
||
1509 | end |
||
1510 | for i = 1, table.getn(triggerdata) do |
||
1511 | if triggerdata[i].name == "default" then |
||
1512 | return triggerdata[i][field]; |
||
1513 | end |
||
1514 | end |
||
1515 | end |
||
1516 | |||
1517 | -- Core Functions |
||
1518 | |||
1519 | function Timers_AddGroup() |
||
1520 | StaticPopupDialogs["TIMERS_MESSAGE_POPUP"].text = TIMERS_LOC_NEW_GROUP_NAME; |
||
1521 | Timers_OnMessageBoxAccept = Timers_GetNewGroupName; |
||
1522 | StaticPopup_Show("TIMERS_MESSAGE_POPUP"); |
||
1523 | end |
||
1524 | |||
1525 | function Timers_AddTrigger() |
||
1526 | table.insert(triggerdata, {["name"] = "New Trigger", ["text"] = TIMERS_LOC_EMPTYTEXT, ["isnotdefault"] = true}); |
||
1527 | groupdata[Timers_GroupNameToNumber(TIMERS_LOC_NOGROUP)].fold = false; |
||
1528 | Timers_SetTriggerData(); |
||
1529 | end |
||
1530 | |||
1531 | function Timers_ResetAllTrigger() |
||
1532 | StaticPopupDialogs["TIMERS_ACCEPT_POPUP"].text = TIMERS_LOC_DELETE_ALL_NON_DEFAULT; |
||
1533 | Timers_OnAcceptBoxButton = Timers_ResetAllTriggerMsg; |
||
1534 | StaticPopup_Show("TIMERS_ACCEPT_POPUP"); |
||
1535 | end |
||
1536 | |||
1537 | function Timers_ResetAllTriggerMsg(nondefault) |
||
1538 | if nondefault then |
||
1539 | triggerdata = {}; |
||
1540 | end |
||
1541 | for i = 1, table.getn(triggerdata_DEFAULT) do |
||
1542 | Timers_ResetByTrigger(triggerdata_DEFAULT[i]); |
||
1543 | end |
||
1544 | table.sort(triggerdata,Timers_CompareTriggers); |
||
1545 | Timers_SetTriggerData(); |
||
1546 | end |
||
1547 | |||
1548 | function Timers_ResetTriggerByRow(arg) |
||
1549 | local trigger = triggerdata_DEFAULT[Timers_TriggerNameToDefaultNumber(triggerdata[Timers_RowToTrigger(Timers_GetRow(arg)+FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame))].name)]; |
||
1550 | Timers_ResetByTrigger(trigger); |
||
1551 | Timers_SetTriggerData(); |
||
1552 | end |
||
1553 | |||
1554 | function Timers_ResetByTrigger(trigger) |
||
1555 | local j = table.getn(triggerdata); |
||
1556 | while j > 0 do |
||
1557 | if triggerdata[j].name == trigger.name then |
||
1558 | table.remove(triggerdata,j); |
||
1559 | end |
||
1560 | j = j - 1; |
||
1561 | end |
||
1562 | table.insert(triggerdata,Timers_cloneTable(trigger)); |
||
1563 | end |
||
1564 | |||
1565 | function Timers_cloneTable(t) |
||
1566 | local new = {}; |
||
1567 | local i, v = next(t, nil); |
||
1568 | while i do |
||
1569 | if type(v)=="table" then |
||
1570 | v=Timers_cloneTable(v); |
||
1571 | end |
||
1572 | new[i] = v; |
||
1573 | i, v = next(t, i); |
||
1574 | end |
||
1575 | return new; |
||
1576 | end |
||
1577 | |||
1578 | function Timers_GetNewGroupName(text) |
||
1579 | table.insert(groupdata, {["name"] = text, ["isnotdefault"] = true}); |
||
1580 | Timers_SetTriggerData(); |
||
1581 | end |
||
1582 | |||
1583 | function Timers_SetNewGroupByBox(state) |
||
1584 | local i = table.getn(triggerdata); |
||
1585 | while i > 0 do |
||
1586 | if triggerdata[i].fromGroup then |
||
1587 | if state then |
||
1588 | table.remove(triggerdata,i); |
||
1589 | else |
||
1590 | triggerdata[i].group = nil; |
||
1591 | triggerdata[i].fromGroup = nil; |
||
1592 | end |
||
1593 | end |
||
1594 | i = i - 1; |
||
1595 | end |
||
1596 | Timers_SetTriggerData(); |
||
1597 | end |
||
1598 | |||
1599 | function Timers_SetTriggerData() |
||
1600 | table.sort(groupdata,Timers_CompareGroups); |
||
1601 | table.sort(timerdata,Timers_CompareTimers); |
||
1602 | local group; |
||
1603 | -- create Pointer list |
||
1604 | Timers_Init_TriggerPointer(); |
||
1605 | local Max = 0 |
||
1606 | for i = 1, table.getn(triggerPointer) do |
||
1607 | if triggerPointer[i] then |
||
1608 | Max = Max + 1; |
||
1609 | end |
||
1610 | end |
||
1611 | for i = 1, table.getn(triggerdata) do |
||
1612 | group = Timers_GroupNameToNumber(triggerdata[i].group); |
||
1613 | if(not(groupdata[group].fold) and not((groupdata[group].inactive or triggerdata[i].inactive) and configdata.hideinactive)) then |
||
1614 | table.insert(triggerPointer[group],i); |
||
1615 | Max = Max + 1; |
||
1616 | end |
||
1617 | end |
||
1618 | FauxScrollFrame_Update(TimersMainFrameScrollFrame, Max, 10, 20); |
||
1619 | Timers_Print_TriggerPointer(); |
||
1620 | end |
||
1621 | |||
1622 | function Timers_Print_TriggerPointer() |
||
1623 | local Offset = FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame); |
||
1624 | local Alli = 1; |
||
1625 | for i = 1, table.getn(triggerPointer) do |
||
1626 | if triggerPointer[i] then |
||
1627 | if Alli > Offset and Alli - Offset <= 10 then |
||
1628 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."EditBox1"):SetText("--- "..groupdata[i].name.." ---"); |
||
1629 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."EditBox1"):SetTextColor(0.2,0.2,1,1); |
||
1630 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."GrpByPlaytime"):Show(); |
||
1631 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."GrpByPlaytime"):SetChecked(groupdata[i].byplaytime); |
||
1632 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."GrpByPlaytimeTitle"):Show(); |
||
1633 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."GrpResetCnt"):Show(); |
||
1634 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."GrpResetCnt"):SetChecked(groupdata[i].onstartreset); |
||
1635 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."GrpResetCntTitle"):Show(); |
||
1636 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."GrpDeleteTimer"):Show(); |
||
1637 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."GrpDeleteTimer"):SetChecked(groupdata[i].onstartdelete); |
||
1638 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."GrpDeleteTimerTitle"):Show(); |
||
1639 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."GrpOnStartTitle"):Show(); |
||
1640 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset)):Show(); |
||
1641 | if groupdata[i].inactive then |
||
1642 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."Active"):SetChecked(false); |
||
1643 | else |
||
1644 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."Active"):SetChecked(true); |
||
1645 | end |
||
1646 | if groupdata[i].fold then |
||
1647 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."MenuButton"):SetText("+"); |
||
1648 | else |
||
1649 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."MenuButton"):SetText("-"); |
||
1650 | end |
||
1651 | for j = 2, 5 do |
||
1652 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."EditBox"..j):Hide(); |
||
1653 | end |
||
1654 | end |
||
1655 | Alli = Alli + 1; |
||
1656 | for j = 1, table.getn(triggerPointer[i]) do |
||
1657 | if Alli > Offset and Alli - Offset <= 10 then |
||
1658 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."EditBox1"):SetText(triggerdata[triggerPointer[i][j]].name); |
||
1659 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."EditBox1"):SetTextColor(1,1,1,1); |
||
1660 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."GrpByPlaytime"):Hide(); |
||
1661 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."GrpByPlaytimeTitle"):Hide(); |
||
1662 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."GrpResetCnt"):Hide(); |
||
1663 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."GrpResetCntTitle"):Hide(); |
||
1664 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."GrpDeleteTimer"):Hide(); |
||
1665 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."GrpDeleteTimerTitle"):Hide(); |
||
1666 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."GrpOnStartTitle"):Hide(); |
||
1667 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."MenuButton"):SetText("!"); |
||
1668 | if triggerdata[triggerPointer[i][j]].inactive then |
||
1669 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."Active"):SetChecked(false); |
||
1670 | else |
||
1671 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."Active"):SetChecked(true); |
||
1672 | end |
||
1673 | for j = 2, 5 do |
||
1674 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."EditBox"..j):Show(); |
||
1675 | end |
||
1676 | Timers_SetEditBox(triggerdata[triggerPointer[i][j]],"time",(Alli-Offset),"2"); |
||
1677 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."EditBox2"):SetTextColor(1,1,1,1); |
||
1678 | Timers_SetEditBox(triggerdata[triggerPointer[i][j]],"prewarn",(Alli-Offset),"3"); |
||
1679 | Timers_SetEditBox(triggerdata[triggerPointer[i][j]],"text",(Alli-Offset),"4"); |
||
1680 | if triggerdata[triggerPointer[i][j]].count == nil then |
||
1681 | triggerdata[triggerPointer[i][j]].count = 0; |
||
1682 | end |
||
1683 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset).."EditBox5"):SetText(triggerdata[triggerPointer[i][j]].count); |
||
1684 | getglobal("TimersMainFrameTimerRow"..(Alli-Offset)):Show(); |
||
1685 | end |
||
1686 | Alli = Alli + 1; |
||
1687 | end |
||
1688 | end |
||
1689 | end |
||
1690 | if Alli-Offset <= 10 then |
||
1691 | if Alli <= Offset then |
||
1692 | Alli = Offset + 1; |
||
1693 | end |
||
1694 | for k = Alli-Offset, 10 do |
||
1695 | getglobal("TimersMainFrameTimerRow"..k):Hide(); |
||
1696 | end |
||
1697 | end |
||
1698 | end |
||
1699 | |||
1700 | function Timers_ToggleShowInactive() |
||
1701 | if configdata.hideinactive then |
||
1702 | configdata.hideinactive = false; |
||
1703 | Timers_PrintText(TIMERS_LOC_SHOWINACTIVE); |
||
1704 | else |
||
1705 | configdata.hideinactive = true; |
||
1706 | Timers_PrintText(TIMERS_LOC_HIDEINACTIVE); |
||
1707 | end |
||
1708 | Timers_SetTriggerData(); |
||
1709 | end |
||
1710 | |||
1711 | function Timers_GroupNameToNumber(name) |
||
1712 | if name == nil then |
||
1713 | name = TIMERS_LOC_NOGROUP; |
||
1714 | end |
||
1715 | for i = 1, table.getn(groupdata) do |
||
1716 | if groupdata[i].name == name then |
||
1717 | return i; |
||
1718 | end |
||
1719 | end |
||
1720 | return Timers_GroupNameToNumber(nil); |
||
1721 | end |
||
1722 | |||
1723 | function Timers_TriggerNameToNumber(name) |
||
1724 | if name == nil then |
||
1725 | name = "default"; |
||
1726 | end |
||
1727 | for i = 1, table.getn(triggerdata) do |
||
1728 | if triggerdata[i].name == name then |
||
1729 | return i; |
||
1730 | end |
||
1731 | end |
||
1732 | return Timers_TriggerNameToNumber(nil); |
||
1733 | end |
||
1734 | |||
1735 | function Timers_TriggerNameToDefaultNumber(name) |
||
1736 | for i = 1, table.getn(triggerdata_DEFAULT) do |
||
1737 | if triggerdata_DEFAULT[i].name == name then |
||
1738 | return i; |
||
1739 | end |
||
1740 | end |
||
1741 | return nil; |
||
1742 | end |
||
1743 | |||
1744 | function Timers_RowToGroup(i) |
||
1745 | local j = 1; |
||
1746 | local k = 1; |
||
1747 | while j < i do |
||
1748 | j = j + 1 + table.getn(triggerPointer[k]); |
||
1749 | k = k + 1; |
||
1750 | end |
||
1751 | return k; |
||
1752 | end |
||
1753 | |||
1754 | function Timers_RowToTrigger(i) |
||
1755 | local j = 0; |
||
1756 | local k = 0; |
||
1757 | while j < i do |
||
1758 | j = j + 1 + table.getn(triggerPointer[k+1]); |
||
1759 | k = k + 1; |
||
1760 | end |
||
1761 | return triggerPointer[k][(table.getn(triggerPointer[k])-(j-i))]; |
||
1762 | end |
||
1763 | |||
1764 | function Timers_ToggleTriggerActive() |
||
1765 | if getglobal(this:GetParent():GetName().."EditBox2"):IsVisible() then |
||
1766 | if this:GetChecked() then |
||
1767 | triggerdata[Timers_RowToTrigger(Timers_GetRow(this)+FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame))].inactive = false; |
||
1768 | else |
||
1769 | triggerdata[Timers_RowToTrigger(Timers_GetRow(this)+FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame))].inactive = true; |
||
1770 | end |
||
1771 | else |
||
1772 | if this:GetChecked() then |
||
1773 | groupdata[Timers_RowToGroup(Timers_GetRow(this)+FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame))].inactive = false; |
||
1774 | else |
||
1775 | groupdata[Timers_RowToGroup(Timers_GetRow(this)+FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame))].inactive = true; |
||
1776 | end |
||
1777 | end |
||
1778 | Timers_SetTriggerData(); |
||
1779 | end |
||
1780 | |||
1781 | function Timers_ToggleGrpByPlaytime() |
||
1782 | if this:GetChecked() then |
||
1783 | groupdata[Timers_RowToGroup(Timers_GetRow(this)+FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame))].byplaytime = true; |
||
1784 | else |
||
1785 | groupdata[Timers_RowToGroup(Timers_GetRow(this)+FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame))].byplaytime = nil; |
||
1786 | end |
||
1787 | end |
||
1788 | |||
1789 | function Timers_ToggleGrpDeleteTimer() |
||
1790 | if this:GetChecked() then |
||
1791 | groupdata[Timers_RowToGroup(Timers_GetRow(this)+FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame))].onstartdelete = true; |
||
1792 | else |
||
1793 | groupdata[Timers_RowToGroup(Timers_GetRow(this)+FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame))].onstartdelete = nil; |
||
1794 | end |
||
1795 | end |
||
1796 | |||
1797 | function Timers_ToggleGrpResetCnt() |
||
1798 | if this:GetChecked() then |
||
1799 | groupdata[Timers_RowToGroup(Timers_GetRow(this)+FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame))].onstartreset = true; |
||
1800 | else |
||
1801 | groupdata[Timers_RowToGroup(Timers_GetRow(this)+FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame))].onstartreset = nil; |
||
1802 | end |
||
1803 | end |
||
1804 | |||
1805 | function Timers_Init_TriggerPointer() |
||
1806 | triggerPointer = {}; |
||
1807 | for i = 1, table.getn(groupdata) do |
||
1808 | if groupdata[i].inactive and configdata.hideinactive then |
||
1809 | triggerPointer[i] = false; |
||
1810 | else |
||
1811 | triggerPointer[i] = {}; |
||
1812 | end |
||
1813 | end |
||
1814 | end |
||
1815 | |||
1816 | function Timers_GetFieldValue(trigger,field) |
||
1817 | if trigger[field] and trigger[field] ~= TIMERS_LOC_DEFAULT then |
||
1818 | return trigger[field]; |
||
1819 | else |
||
1820 | if field == "count" then |
||
1821 | return "0"; |
||
1822 | elseif field == "group" then |
||
1823 | return TIMERS_LOC_NOGROUP; |
||
1824 | else |
||
1825 | for i = 1, table.getn(triggerdata) do |
||
1826 | if triggerdata[i].name == "default" then |
||
1827 | return triggerdata[i][field]; |
||
1828 | end |
||
1829 | end |
||
1830 | end |
||
1831 | end |
||
1832 | end |
||
1833 | |||
1834 | function Timers_SetEditBox(trigger,field,row,nr) |
||
1835 | if trigger[field] == nil and (field == "channel" or field == "mode" or field == "type") then |
||
1836 | trigger[field] = TIMERS_LOC_DEFAULT; |
||
1837 | end |
||
1838 | if trigger[field] == nil then |
||
1839 | for i = 1, table.getn(triggerdata) do |
||
1840 | if triggerdata[i].name == "default" then |
||
1841 | if field == "time" then |
||
1842 | getglobal("TimersMainFrameTimerRow"..row.."EditBox"..nr):SetText(Timers_TimeToText(tonumber(triggerdata[i][field]))); |
||
1843 | else |
||
1844 | getglobal("TimersMainFrameTimerRow"..row.."EditBox"..nr):SetText(triggerdata[i][field]); |
||
1845 | end |
||
1846 | end |
||
1847 | end |
||
1848 | elseif field == "time" then |
||
1849 | getglobal("TimersMainFrameTimerRow"..row.."EditBox"..nr):SetText(Timers_TimeToText(tonumber(trigger[field]))); |
||
1850 | else |
||
1851 | getglobal("TimersMainFrameTimerRow"..row.."EditBox"..nr):SetText(trigger[field]); |
||
1852 | end |
||
1853 | end |
||
1854 | |||
1855 | function Timers_add(name,time,trigger) |
||
1856 | if tonumber(time) then |
||
1857 | time = time*60; |
||
1858 | else |
||
1859 | time = Timers_TextToTime(time); |
||
1860 | end |
||
1861 | local isnotValid = true; |
||
1862 | for i = 1, table.getn(triggerdata) do |
||
1863 | if triggerdata[i].name == trigger then |
||
1864 | if not time then |
||
1865 | time = triggerdata[i].time; |
||
1866 | end |
||
1867 | isnotValid = false; |
||
1868 | end |
||
1869 | end |
||
1870 | if isnotValid then |
||
1871 | trigger = "default"; |
||
1872 | end |
||
1873 | if Timers_GetFieldValue(triggerdata[Timers_TriggerNameToNumber(trigger)],"mode") == TIMERS_LOC_INC then |
||
1874 | table.insert(timerdata, {name=name, time=Timers_GetLocalTime(), trigger=trigger}); |
||
1875 | else |
||
1876 | table.insert(timerdata, {name=name, time=time+Timers_GetLocalTime(), trigger=trigger}); |
||
1877 | end |
||
1878 | timerUpdateFlag = true; |
||
1879 | Timers_PrintText(TIMERS_LOC_TIMERADDED); |
||
1880 | end |
||
1881 | |||
1882 | function Timers_SetTimerData() |
||
1883 | local Offset = FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame); |
||
1884 | local Max = table.getn(timerdata); |
||
1885 | for i = 1 , 10 do |
||
1886 | if Max < i+Offset then |
||
1887 | getglobal("TimersMainFrameTimerRow"..i):Hide(); |
||
1888 | else |
||
1889 | getglobal("TimersMainFrameTimerRow"..i.."EditBox1"):SetText(timerdata[i+Offset].name); |
||
1890 | getglobal("TimersMainFrameTimerRow"..i.."EditBox1"):SetTextColor(1,1,1,1); |
||
1891 | getglobal("TimersMainFrameTimerRow"..i):Show(); |
||
1892 | end |
||
1893 | end |
||
1894 | FauxScrollFrame_Update(TimersMainFrameScrollFrame, table.getn(timerdata), 10, 20); |
||
1895 | end |
||
1896 | |||
1897 | function Timers_UpdateTimes() |
||
1898 | local Offset = FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame); |
||
1899 | local Max = table.getn(timerdata); |
||
1900 | for i = 1 , 10 do |
||
1901 | if Max >= i+Offset then |
||
1902 | if not timerdata[i+Offset].paused and not timerdata[i+Offset].editing then |
||
1903 | if Timers_GetFieldValue(triggerdata[Timers_TriggerNameToNumber(timerdata[i+Offset].trigger)],"mode") == TIMERS_LOC_INC then |
||
1904 | getglobal("TimersMainFrameTimerRow"..i.."EditBox2"):SetText(Timers_TimeToText(Timers_GetLocalTime()-timerdata[i+Offset].time)); |
||
1905 | getglobal("TimersMainFrameTimerRow"..i.."EditBox2"):SetTextColor(1,1,1,1); |
||
1906 | else |
||
1907 | getglobal("TimersMainFrameTimerRow"..i.."EditBox2"):SetText(Timers_TimeToText(timerdata[i+Offset].time-Timers_GetLocalTime())); |
||
1908 | if timerdata[i+Offset].time-Timers_GetLocalTime() > 0 then |
||
1909 | getglobal("TimersMainFrameTimerRow"..i.."EditBox2"):SetTextColor(1,1,1,1); |
||
1910 | else |
||
1911 | getglobal("TimersMainFrameTimerRow"..i.."EditBox2"):SetTextColor(1,0,0,1); |
||
1912 | end |
||
1913 | if timerdata[i+Offset].paused then |
||
1914 | getglobal("TimersMainFrameTimerRow"..i.."EditBox2"):SetTextColor(1,1,0,1); |
||
1915 | end |
||
1916 | end |
||
1917 | elseif timerdata[i+Offset].paused and not timerdata[i+Offset].editing then |
||
1918 | getglobal("TimersMainFrameTimerRow"..i.."EditBox2"):SetText(Timers_TimeToText(timerdata[i+Offset].paused-timerdata[i+Offset].time)); |
||
1919 | getglobal("TimersMainFrameTimerRow"..i.."EditBox2"):SetTextColor(1,1,0,1); |
||
1920 | end |
||
1921 | end |
||
1922 | end |
||
1923 | end |
||
1924 | |||
1925 | function Timers_UpdateTitle() |
||
1926 | local Title = "Timers "..configdata.titletext; |
||
1927 | Title = string.gsub(Title,"!tNext",TimersString_Replace_tNext()); |
||
1928 | Title = string.gsub(Title,"!iAll",TimersString_Replace_iAll()); |
||
1929 | Title = string.gsub(Title,"!iExpired",TimersString_Replace_iExpired()); |
||
1930 | Title = string.gsub(Title,"!nNext",TimersString_Replace_nNext()); |
||
1931 | if configdata.minimized then |
||
1932 | TimersMinimizedFrameTitle:SetText(Title); |
||
1933 | else |
||
1934 | TimersMainFrameTitle:SetText(Title); |
||
1935 | end |
||
1936 | end |
||
1937 | |||
1938 | function Timers_CheckForNewTrigger() |
||
1939 | for i = 1, table.getn(groupdata_DEFAULT) do |
||
1940 | local notFound = true; |
||
1941 | for j = 1, table.getn(groupdata) do |
||
1942 | if groupdata_DEFAULT[i].name == groupdata[j].name then |
||
1943 | notFound = false; |
||
1944 | end |
||
1945 | end |
||
1946 | if notFound then |
||
1947 | table.insert(groupdata,Timers_cloneTable(groupdata_DEFAULT[i])); |
||
1948 | end |
||
1949 | end |
||
1950 | for i = 1, table.getn(triggerdata_DEFAULT) do |
||
1951 | local notFound = true; |
||
1952 | for j = 1, table.getn(triggerdata) do |
||
1953 | if triggerdata_DEFAULT[i].name == triggerdata[j].name then |
||
1954 | notFound = false; |
||
1955 | end |
||
1956 | end |
||
1957 | if notFound then |
||
1958 | table.insert(triggerdata,Timers_cloneTable(triggerdata_DEFAULT[i])); |
||
1959 | end |
||
1960 | end |
||
1961 | end |
||
1962 | |||
1963 | function Timers_CorrectTimerData() |
||
1964 | if TimerscurrentTime then |
||
1965 | local Div = Timers_GetLocalTime() - TimerscurrentTime; |
||
1966 | local i = table.getn(timerdata); |
||
1967 | while i > 0 do |
||
1968 | if groupdata[Timers_GroupNameToNumber(triggerdata[Timers_TriggerNameToNumber(timerdata[i].trigger)].group)].byplaytime then |
||
1969 | timerdata[i].time = timerdata[i].time + Div; |
||
1970 | if timerdata[i].paused then |
||
1971 | timerdata[i].paused = timerdata[i].paused + Div; |
||
1972 | end |
||
1973 | error("corrected"); |
||
1974 | end |
||
1975 | if groupdata[Timers_GroupNameToNumber(triggerdata[Timers_TriggerNameToNumber(timerdata[i].trigger)].group)].onstartdelete then |
||
1976 | table.remove(timerdata,i); |
||
1977 | end |
||
1978 | i = i -1; |
||
1979 | end |
||
1980 | end |
||
1981 | timeIsCorrect = true; |
||
1982 | for i = 1, table.getn(triggerdata) do |
||
1983 | if groupdata[Timers_GroupNameToNumber(triggerdata[i].group)].onstartreset then |
||
1984 | triggerdata[i].count = 0; |
||
1985 | end |
||
1986 | end |
||
1987 | end |
||
1988 | |||
1989 | function Timers_VersionCorrections() |
||
1990 | -- zu 3.2 (reload default trigger vor warnmessage/channel |
||
1991 | if (not (Timers_GetDefaultValue("warnmessage"))) then |
||
1992 | local trigger; |
||
1993 | for i = 1, table.getn(triggerdata_DEFAULT) do |
||
1994 | if triggerdata_DEFAULT[i].name == "default" then |
||
1995 | trigger = triggerdata_DEFAULT[i]; |
||
1996 | end |
||
1997 | end |
||
1998 | Timers_ResetByTrigger(trigger); |
||
1999 | end |
||
2000 | end |
||
2001 | |||
2002 | -- String replacements |
||
2003 | function TimersString_Replace_tNext() |
||
2004 | local time; |
||
2005 | for i = 1, table.getn(timerdata) do |
||
2006 | if timerdata[i].time > Timers_GetLocalTime() and (time == nil or timerdata[i].time < time) and triggerdata[Timers_TriggerNameToNumber(timerdata[i].trigger)].mode ~= TIMERS_LOC_INC then |
||
2007 | time = timerdata[i].time; |
||
2008 | end |
||
2009 | end |
||
2010 | if time ~= nil then |
||
2011 | return Timers_TimeToText(time-Timers_GetLocalTime()); |
||
2012 | else |
||
2013 | return 0; |
||
2014 | end |
||
2015 | end |
||
2016 | |||
2017 | function TimersString_Replace_Coord() |
||
2018 | local x,y = GetPlayerMapPosition("player"); |
||
2019 | x = math.ceil(x*1000)/10; |
||
2020 | y = math.ceil(y*1000)/10; |
||
2021 | return (x.."/"..y) |
||
2022 | end |
||
2023 | |||
2024 | function TimersString_Replace_iAll() |
||
2025 | return table.getn(timerdata); |
||
2026 | end |
||
2027 | |||
2028 | function TimersString_Replace_iExpired() |
||
2029 | local Expired = 0; |
||
2030 | for i = 1, table.getn(timerdata) do |
||
2031 | if timerdata[i].time < Timers_GetLocalTime() then |
||
2032 | Expired = Expired + 1; |
||
2033 | end |
||
2034 | end |
||
2035 | return Expired; |
||
2036 | end |
||
2037 | |||
2038 | function TimersString_Replace_nNext() |
||
2039 | local time, name; |
||
2040 | for i = 1, table.getn(timerdata) do |
||
2041 | if timerdata[i].time > Timers_GetLocalTime() and (time == nil or timerdata[i].time < time) then |
||
2042 | time = timerdata[i].time; |
||
2043 | name = timerdata[i].name; |
||
2044 | end |
||
2045 | end |
||
2046 | if name ~= nil then |
||
2047 | return name; |
||
2048 | else |
||
2049 | return "--"; |
||
2050 | end |
||
2051 | end |
||
2052 | |||
2053 | function TimersString_Replace_Msgsub(timer) |
||
2054 | return string.gsub(timer.msg,triggerdata[Timers_TriggerNameToNumber(timer.trigger)].text," "); |
||
2055 | end |
||
2056 | |||
2057 | function TimersString_Replace_Msgsub_4Warn(trigger,msg) |
||
2058 | return string.gsub(msg,trigger.text," "); |
||
2059 | end |
||
2060 | |||
2061 | -- Edit Functions |
||
2062 | |||
2063 | function TimersEdit_SaveName() |
||
2064 | if this:GetText() == "" then |
||
2065 | this:SetText(TIMERS_LOC_NO_NAME_SET); |
||
2066 | end |
||
2067 | if this:GetText() == "default" then |
||
2068 | this:SetText("newdefault"); |
||
2069 | end |
||
2070 | if string.find(this:GetName(),"Row") then |
||
2071 | local i = Timers_GetRow(this) + FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame); |
||
2072 | if configdata.activetab == 1 or configdata.activetab == 2 then |
||
2073 | timerdata[i].name = this:GetText(); |
||
2074 | elseif getglobal(this:GetParent():GetName().."EditBox2"):IsVisible() then |
||
2075 | triggerdata[Timers_RowToTrigger(i)].name = this:GetText(); |
||
2076 | else |
||
2077 | for j = 1, table.getn(triggerdata) do |
||
2078 | if triggerdata[j].group == groupdata[Timers_RowToGroup(i)].name then |
||
2079 | triggerdata[j].group = this:GetText(); |
||
2080 | end |
||
2081 | end |
||
2082 | groupdata[Timers_RowToGroup(i)].name = this:GetText(); |
||
2083 | end |
||
2084 | else |
||
2085 | triggerdata[trigger_edit].name = this:GetText(); |
||
2086 | end |
||
2087 | Timers_SetTriggerData(); |
||
2088 | end |
||
2089 | |||
2090 | function TimersEdit_DeleteAllTimer() |
||
2091 | timerdata = {}; |
||
2092 | timerUpdateFlag = true; |
||
2093 | end |
||
2094 | |||
2095 | function TimersEdit_DeleteExpired() |
||
2096 | local i = table.getn(timerdata); |
||
2097 | while i > 0 do |
||
2098 | if timerdata[i].time-Timers_GetLocalTime() < 0 then |
||
2099 | table.remove(timerdata, i); |
||
2100 | end |
||
2101 | i = i - 1; |
||
2102 | end |
||
2103 | timerUpdateFlag = true; |
||
2104 | end |
||
2105 | |||
2106 | function TimersEdit_DeleteByGroup(grp) |
||
2107 | local i = table.getn(timerdata); |
||
2108 | while i > 0 do |
||
2109 | if triggerdata[Timers_TriggerNameToNumber(timerdata[i].trigger)].group == grp or (grp == TIMERS_LOC_NOGROUP and not triggerdata[Timers_TriggerNameToNumber(timerdata[i].trigger)].group) then |
||
2110 | table.remove(timerdata, i); |
||
2111 | end |
||
2112 | i = i - 1; |
||
2113 | end |
||
2114 | timerUpdateFlag = true; |
||
2115 | end |
||
2116 | |||
2117 | function TimersEdit_DeleteTimer(arg) |
||
2118 | local i = Timers_GetRow(arg) + FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame); |
||
2119 | table.remove(timerdata, i); |
||
2120 | timerUpdateFlag = true; |
||
2121 | end |
||
2122 | |||
2123 | function TimersEdit_TogglePaused(arg,i) |
||
2124 | if i == nil then |
||
2125 | i = Timers_GetRow(arg) + FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame); |
||
2126 | end |
||
2127 | if timerdata[i].paused == nil then |
||
2128 | timerdata[i].paused = Timers_GetLocalTime(); |
||
2129 | else |
||
2130 | timerdata[i].time = timerdata[i].time + (Timers_GetLocalTime() - timerdata[i].paused); |
||
2131 | timerdata[i].paused = nil; |
||
2132 | end |
||
2133 | end |
||
2134 | |||
2135 | function TimersEdit_StopTimer(arg,i) |
||
2136 | if i == nil then |
||
2137 | i = Timers_GetRow(arg) + FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame); |
||
2138 | end |
||
2139 | timerdata[i].paused = Timers_GetLocalTime(); |
||
2140 | timerdata[i].stopped = true; |
||
2141 | timerUpdateFlag = true; |
||
2142 | end |
||
2143 | |||
2144 | function TimersEdit_ResetTimer(arg,i) |
||
2145 | if i == nil then |
||
2146 | i = Timers_GetRow(arg) + FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame); |
||
2147 | end |
||
2148 | TimersEdit_ResetTimerByNr(i); |
||
2149 | timerUpdateFlag = true; |
||
2150 | end |
||
2151 | |||
2152 | function TimersEdit_ResetTimerByNr(i) |
||
2153 | timerdata[i].time = triggerdata[Timers_TriggerNameToNumber(timerdata[i].trigger)].time+Timers_GetLocalTime(); |
||
2154 | timerdata[i].prewarned = nil; |
||
2155 | timerdata[i].warned = nil; |
||
2156 | end |
||
2157 | |||
2158 | function TimersEdit_ResetExpired() |
||
2159 | for i = 1, table.getn(timerdata) do |
||
2160 | if timerdata[i].time-Timers_GetLocalTime() < 0 then |
||
2161 | TimersEdit_ResetTimerByNr(i); |
||
2162 | end |
||
2163 | end |
||
2164 | timerUpdateFlag = true; |
||
2165 | end |
||
2166 | |||
2167 | function TimersEdit_ResetByGroup(grp) |
||
2168 | for i = 1, table.getn(timerdata) do |
||
2169 | if triggerdata[Timers_TriggerNameToNumber(timerdata[i].trigger)].group == grp or (grp == TIMERS_LOC_NOGROUP and not triggerdata[Timers_TriggerNameToNumber(timerdata[i].trigger)].group) then |
||
2170 | TimersEdit_ResetTimerByNr(i); |
||
2171 | end |
||
2172 | end |
||
2173 | timerUpdateFlag = true; |
||
2174 | end |
||
2175 | |||
2176 | function TimersEdit_ResetAll() |
||
2177 | for i = 1, table.getn(timerdata) do |
||
2178 | TimersEdit_ResetTimerByNr(i) |
||
2179 | end |
||
2180 | timerUpdateFlag = true; |
||
2181 | end |
||
2182 | |||
2183 | function TimersEdit_EditTime() |
||
2184 | local i = Timers_GetRow(this) + FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame); |
||
2185 | if configdata.activetab == 1 or configdata.activetab == 2 then |
||
2186 | timerdata[i].editing = true; |
||
2187 | end |
||
2188 | end |
||
2189 | |||
2190 | function TimersEdit_EditName() |
||
2191 | if not (configdata.activetab == 1 or configdata.activetab == 2) then |
||
2192 | if not getglobal(this:GetParent():GetName().."EditBox2"):IsVisible() then |
||
2193 | if groupdata[Timers_RowToGroup(Timers_GetRow(this) + FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame))].isnotdefault then |
||
2194 | this:SetText(string.sub(this:GetText(),5,-5)); |
||
2195 | else |
||
2196 | this:ClearFocus(); |
||
2197 | StaticPopupDialogs["TIMERS_ERROR_POPUP"].text = TIMERS_LOC_NOT_EDIT_DEFAULT_GROUPS; |
||
2198 | StaticPopup_Show("TIMERS_ERROR_POPUP"); |
||
2199 | end |
||
2200 | else |
||
2201 | if this:GetText() == "default" then |
||
2202 | this:ClearFocus(); |
||
2203 | StaticPopupDialogs["TIMERS_ERROR_POPUP"].text = TIMERS_LOC_NOT_EDIT_DEFAULT; |
||
2204 | StaticPopup_Show("TIMERS_ERROR_POPUP"); |
||
2205 | end |
||
2206 | end |
||
2207 | end |
||
2208 | end |
||
2209 | |||
2210 | function TimersEdit_EditNameAdv() |
||
2211 | if this:GetText() == "default" then |
||
2212 | this:ClearFocus(); |
||
2213 | StaticPopupDialogs["TIMERS_ERROR_POPUP"].text = TIMERS_LOC_NOT_EDIT_DEFAULT; |
||
2214 | StaticPopup_Show("TIMERS_ERROR_POPUP"); |
||
2215 | end |
||
2216 | end |
||
2217 | |||
2218 | function TimersEdit_SaveTime() |
||
2219 | if this:GetText() == "" then |
||
2220 | this:SetText("0"); |
||
2221 | end |
||
2222 | if string.find(this:GetName(),"Row") then |
||
2223 | local i = Timers_GetRow(this) + FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame); |
||
2224 | if configdata.activetab == 1 or configdata.activetab == 2 then |
||
2225 | local time = Timers_TextToTime(this:GetText()); |
||
2226 | timerdata[i].time = Timers_GetLocalTime()+time; |
||
2227 | timerdata[i].editing = nil; |
||
2228 | else |
||
2229 | triggerdata[Timers_RowToTrigger(i)].time = Timers_TextToTime(this:GetText()); |
||
2230 | end |
||
2231 | else |
||
2232 | triggerdata[trigger_edit].time = Timers_TextToTime(this:GetText()); |
||
2233 | end |
||
2234 | Timers_SetTriggerData(); |
||
2235 | end |
||
2236 | |||
2237 | function TimersEdit_SaveChannel(caller,text) |
||
2238 | TimersMenu_SetEditBoxText(caller,text); |
||
2239 | if string.find(caller:GetName(),"Warn") then |
||
2240 | triggerdata[trigger_edit].warnchannel = text; |
||
2241 | else |
||
2242 | triggerdata[trigger_edit].channel = text; |
||
2243 | end |
||
2244 | Timers_SetTriggerData(); |
||
2245 | end |
||
2246 | |||
2247 | function TimersEdit_SaveMode(caller, text) |
||
2248 | TimersMenu_SetEditBoxText(caller,text); |
||
2249 | triggerdata[trigger_edit].mode = text; |
||
2250 | Timers_SetTriggerData(); |
||
2251 | end |
||
2252 | |||
2253 | function TimersEdit_SaveType(caller, text) |
||
2254 | TimersMenu_SetEditBoxText(caller,text); |
||
2255 | triggerdata[trigger_edit].type = text; |
||
2256 | Timers_SetTriggerData(); |
||
2257 | end |
||
2258 | |||
2259 | function TimersEdit_SaveTextImplicit(arg,text) |
||
2260 | local i; |
||
2261 | if string.find(arg:GetName(),"Row") then |
||
2262 | i = Timers_RowToTrigger(Timers_GetRow(arg) + FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame)); |
||
2263 | else |
||
2264 | i = trigger_edit; |
||
2265 | end |
||
2266 | if triggerdata[i].name == "default" then |
||
2267 | StaticPopupDialogs["TIMERS_ERROR_POPUP"].text = TIMERS_LOC_NOT_TEXT; |
||
2268 | StaticPopup_Show("TIMERS_ERROR_POPUP"); |
||
2269 | else |
||
2270 | triggerdata[i].text = text; |
||
2271 | end |
||
2272 | if i == trigger_edit then |
||
2273 | TimersTriggersConfigFrameTextBox:SetText(text); |
||
2274 | end |
||
2275 | Timers_SetTriggerData(); |
||
2276 | end |
||
2277 | |||
2278 | function TimersEdit_SaveText() |
||
2279 | local i; |
||
2280 | if string.find(this:GetName(),"Row") then |
||
2281 | i = Timers_RowToTrigger(Timers_GetRow(this) + FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame)); |
||
2282 | else |
||
2283 | i = trigger_edit; |
||
2284 | end |
||
2285 | if triggerdata[i].name == "default" then |
||
2286 | StaticPopupDialogs["TIMERS_ERROR_POPUP"].text = TIMERS_LOC_NOT_TEXT; |
||
2287 | StaticPopup_Show("TIMERS_ERROR_POPUP"); |
||
2288 | else |
||
2289 | triggerdata[i].text = this:GetText(); |
||
2290 | end |
||
2291 | end |
||
2292 | |||
2293 | function TimersEdit_SaveMessage() |
||
2294 | if string.find(this:GetName(),"Warn") then |
||
2295 | if Timers_GetDefaultValue("warnmessage") ~= this:GetText() then |
||
2296 | triggerdata[trigger_edit].warnmessage = this:GetText(); |
||
2297 | end |
||
2298 | else |
||
2299 | if Timers_GetDefaultValue("message") ~= this:GetText() then |
||
2300 | triggerdata[trigger_edit].message = this:GetText(); |
||
2301 | end |
||
2302 | end |
||
2303 | Timers_SetTriggerData(); |
||
2304 | end |
||
2305 | |||
2306 | function TimersEdit_SaveCount() |
||
2307 | triggerdata[trigger_edit].count = this:GetText(); |
||
2308 | end |
||
2309 | |||
2310 | function TimersEdit_SaveThreshold() |
||
2311 | triggerdata[trigger_edit].threshold = this:GetText(); |
||
2312 | end |
||
2313 | |||
2314 | function TimersEdit_SavePrewarn() |
||
2315 | triggerdata[trigger_edit].prewarn = this:GetText(); |
||
2316 | end |
||
2317 | |||
2318 | function Timers_MoveToGroup(row, nr) |
||
2319 | local i = row + FauxScrollFrame_GetOffset(TimersMainFrameScrollFrame); |
||
2320 | triggerdata[Timers_RowToTrigger(i)].group = groupdata[nr].name; |
||
2321 | Timers_SetTriggerData(); |
||
2322 | end |
||
2323 | |||
2324 | function Timers_StartMoving(frame) |
||
2325 | if not (configdata.activetab == 2) then |
||
2326 | frame:StartMoving(); |
||
2327 | end |
||
2328 | end |
||
2329 | |||
2330 | function Timers_OnMessageBoxAccept(text) |
||
2331 | end |
||
2332 | |||
2333 | function Timers_OnAcceptBoxButton(state) |
||
2334 | end |
||
2335 | |||
2336 | function Timers_CheckWarnAllTimers() |
||
2337 | local msg; |
||
2338 | local i = table.getn(timerdata); |
||
2339 | while i > 0 do |
||
2340 | if not (Timers_GetFieldValue(triggerdata[Timers_TriggerNameToNumber(timerdata[i].trigger)],"mode") == TIMERS_LOC_INC) then |
||
2341 | local currTrigger = Timers_TriggerNameToNumber(timerdata[i].trigger); |
||
2342 | if (not timerdata[i].prewarned and Timers_GetFieldValue(triggerdata[currTrigger],"prewarn") ~= "0" and timerdata[i].time-Timers_GetLocalTime() <= tonumber(Timers_GetFieldValue(triggerdata[currTrigger],"prewarn"))*60) then |
||
2343 | Timers_WarnTimer(timerdata[i],true); |
||
2344 | timerdata[i].prewarned = true; |
||
2345 | end |
||
2346 | if (not timerdata[i].warned and timerdata[i].time-Timers_GetLocalTime() <= 0) then |
||
2347 | Timers_WarnTimer(timerdata[i],false); |
||
2348 | timerdata[i].warned = true; |
||
2349 | if Timers_GetFieldValue(triggerdata[Timers_TriggerNameToNumber(timerdata[i].trigger)],"mode") == TIMERS_LOC_DELETE then |
||
2350 | table.remove(timerdata,i); |
||
2351 | timerUpdateFlag = true; |
||
2352 | elseif Timers_GetFieldValue(triggerdata[Timers_TriggerNameToNumber(timerdata[i].trigger)],"mode") == TIMERS_LOC_RESET then |
||
2353 | TimersEdit_ResetTimer(nil,i); |
||
2354 | end |
||
2355 | end |
||
2356 | end |
||
2357 | i = i - 1; |
||
2358 | end |
||
2359 | end |
||
2360 | |||
2361 | function Timers_ImportTrigger() |
||
2362 | Timers_PrintText(TIMERS_LOC_IMPORTING); |
||
2363 | local counter = 0; |
||
2364 | for index, trigger in state.triggerList do |
||
2365 | local notfound = true; |
||
2366 | for i = 1, table.getn(triggerdata) do |
||
2367 | if string.tolower(triggerdata[i].name) == string.tolower(index) then |
||
2368 | notfound = false; |
||
2369 | end |
||
2370 | end |
||
2371 | if notfound then |
||
2372 | table.insert(triggerdata,{name=index, time=state.triggerList[index].time, isnotdefault = true}); |
||
2373 | counter = counter + 1; |
||
2374 | end |
||
2375 | end |
||
2376 | Timers_PrintText(counter..TIMERS_LOC_IMPORTED); |
||
2377 | end |
||
2378 | |||
2379 | function Timers_WarnTimer(timer,prewarn) |
||
2380 | local msg; |
||
2381 | local channel; |
||
2382 | if prewarn then |
||
2383 | msg = Timers_GetFieldValue(triggerdata[Timers_TriggerNameToNumber(timer.trigger)],"warnmessage"); |
||
2384 | channel = Timers_GetFieldValue(triggerdata[Timers_TriggerNameToNumber(timer.trigger)],"warnchannel"); |
||
2385 | else |
||
2386 | msg = Timers_GetFieldValue(triggerdata[Timers_TriggerNameToNumber(timer.trigger)],"message"); |
||
2387 | channel = Timers_GetFieldValue(triggerdata[Timers_TriggerNameToNumber(timer.trigger)],"channel"); |
||
2388 | end |
||
2389 | if Timers_GetFieldValue(triggerdata[Timers_TriggerNameToNumber(timer.trigger)],"mode") == TIMERS_LOC_INC then |
||
2390 | msg = string.gsub(msg,"!time",Timers_TimeToText(Timers_GetLocalTime()-timer.time)); |
||
2391 | else |
||
2392 | msg = string.gsub(msg,"!time",Timers_TimeToText(timer.time-Timers_GetLocalTime())); |
||
2393 | end |
||
2394 | msg = string.gsub(msg,"!name",timer.name); |
||
2395 | msg = string.gsub(msg,"!trigger",timer.trigger); |
||
2396 | msg = string.gsub(msg,"!count",Timers_GetFieldValue(triggerdata[Timers_TriggerNameToNumber(timer.trigger)],"count")); |
||
2397 | msg = string.gsub(msg,"!group",Timers_GetFieldValue(triggerdata[Timers_TriggerNameToNumber(timer.trigger)],"group")); |
||
2398 | if timer.msg then |
||
2399 | msg = string.gsub(msg,"!msgsub",TimersString_Replace_Msgsub(timer)); |
||
2400 | msg = string.gsub(msg,"!msg",timer.msg); |
||
2401 | else |
||
2402 | msg = string.gsub(msg,"!msgsub",TIMERS_LOC_INVOKED_MANUAL); |
||
2403 | msg = string.gsub(msg,"!msg",TIMERS_LOC_INVOKED_MANUAL); |
||
2404 | end |
||
2405 | Timers_MsgSendTo(msg,channel); |
||
2406 | end |
||
2407 | |||
2408 | function Timers_WarnOnly(trigger,Invokemsg,time) |
||
2409 | local msg = Timers_GetFieldValue(trigger,"message"); |
||
2410 | local channel = Timers_GetFieldValue(trigger,"channel"); |
||
2411 | msg = string.gsub(msg,"!trigger",trigger.name); |
||
2412 | msg = string.gsub(msg,"!count",Timers_GetFieldValue(trigger,"count")); |
||
2413 | msg = string.gsub(msg,"!group",Timers_GetFieldValue(trigger,"group")); |
||
2414 | msg = string.gsub(msg,"!msgsub",TimersString_Replace_Msgsub_4Warn(trigger,Invokemsg)); |
||
2415 | msg = string.gsub(msg,"!msg",Invokemsg); |
||
2416 | if time then |
||
2417 | if Timers_GetFieldValue(trigger,"mode") == TIMERS_LOC_INC then |
||
2418 | msg = string.gsub(msg,"!time",Timers_TimeToText(Timers_GetLocalTime()-time)); |
||
2419 | else |
||
2420 | msg = string.gsub(msg,"!time",Timers_TimeToText(time-Timers_GetLocalTime())); |
||
2421 | end |
||
2422 | end |
||
2423 | Timers_MsgSendTo(msg,channel); |
||
2424 | end |
||
2425 | |||
2426 | function Timers_CreateIconArray() |
||
2427 | local i = 1; |
||
2428 | while GetSpellName(i,BOOKTYPE_SPELL) do |
||
2429 | if GetSpellTexture(i,BOOKTYPE_SPELL) then |
||
2430 | IconArray[GetSpellTexture(i,BOOKTYPE_SPELL)] = GetSpellName(i,BOOKTYPE_SPELL); |
||
2431 | end |
||
2432 | i = i + 1; |
||
2433 | end |
||
2434 | end |
||
2435 | |||
2436 | -- PopupBox |
||
2437 | |||
2438 | StaticPopupDialogs["TIMERS_MESSAGE_POPUP"] = { |
||
2439 | button1 = TEXT(ACCEPT), |
||
2440 | button2 = TEXT(CANCEL), |
||
2441 | hasEditBox = 1, |
||
2442 | maxLetters = 20, |
||
2443 | OnAccept = function() |
||
2444 | local editBox = getglobal(this:GetParent():GetName().."EditBox"); |
||
2445 | Timers_OnMessageBoxAccept("!trigger"..editBox:GetText(),StaticPopupDialogs["TIMERS_MESSAGE_POPUP"].arg1,StaticPopupDialogs["TIMERS_MESSAGE_POPUP"].arg2); |
||
2446 | end, |
||
2447 | OnShow = function() |
||
2448 | getglobal(this:GetName().."EditBox"):SetFocus(); |
||
2449 | getglobal(this:GetName().."EditBox"):SetText(""); |
||
2450 | end, |
||
2451 | OnHide = function() |
||
2452 | if ( ChatFrameEditBox:IsVisible() ) then |
||
2453 | ChatFrameEditBox:SetFocus(); |
||
2454 | end |
||
2455 | getglobal(this:GetName().."EditBox"):SetText(""); |
||
2456 | end, |
||
2457 | EditBoxOnEnterPressed = function() |
||
2458 | local editBox = getglobal(this:GetParent():GetName().."EditBox"); |
||
2459 | Timers_OnMessageBoxAccept("!trigger"..editBox:GetText(),StaticPopupDialogs["TIMERS_MESSAGE_POPUP"].arg1,StaticPopupDialogs["TIMERS_MESSAGE_POPUP"].arg2); |
||
2460 | this:GetParent():Hide(); |
||
2461 | end, |
||
2462 | EditBoxOnEscapePressed = function() |
||
2463 | this:GetParent():Hide(); |
||
2464 | end, |
||
2465 | timeout = 0, |
||
2466 | exclusive = 1, |
||
2467 | whileDead = 1 |
||
2468 | }; |
||
2469 | |||
2470 | StaticPopupDialogs["TIMERS_ACCEPT_POPUP"] = { |
||
2471 | button1 = TEXT(ACCEPT), |
||
2472 | button2 = TEXT(CANCEL), |
||
2473 | OnAccept = function() |
||
2474 | Timers_OnAcceptBoxButton(true); |
||
2475 | end, |
||
2476 | OnCancel = function() |
||
2477 | Timers_OnAcceptBoxButton(false); |
||
2478 | end, |
||
2479 | timeout = 0, |
||
2480 | exclusive = 1, |
||
2481 | whileDead = 1 |
||
2482 | }; |
||
2483 | |||
2484 | StaticPopupDialogs["TIMERS_ERROR_POPUP"] = { |
||
2485 | button1 = TEXT(OKAY), |
||
2486 | timeout = 0, |
||
2487 | exclusive = 1, |
||
2488 | whileDead = 1 |
||
2489 | }; |