vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2  
3 The UltimateUI Configuration Master
4  
5 This is a set of functions and a window, designed
6 to accept a list of variables, editable in a simple
7 configuration view.
8  
9 by Alexander Brazie
10  
11 ==> Demo at the Bottom <==
12  
13 Revision: $Rev: 1142 $
14 Last Author: $Author: AlexYoshi $
15 Last Change: $Date: 2005-03-22 10:20:48 -0600 (Tue, 22 Mar 2005) $
16 ]]--
17  
18 -- Global values
19 ULTIMATEUIMASTER_DISPLAY_LIMIT = 10;
20 ULTIMATEUIMASTER_HEIGHT_LIMIT = 32;
21 ULTIMATEUIMASTER_CHAT_INIT_WAIT = 1;
22 ULTIMATEUIMASTER_CHAT_JOIN_DELAY = 3;
23 ULTIMATEUIMASTER_CHAT_UPDATE_WAIT = 1;
24 ULTIMATEUIMASTER_CHAT_STABLE_CHECK = 3;
25 ULTIMATEUIMASTER_VERSION = "$Rev: 1142 $";
26 ULTIMATEUIMASTER_UPDATE = "$Date: 2005-03-22 10:20:48 -0600 (Tue, 22 Mar 2005) $";
27  
28 -- Debugger Toggles
29 ULTIMATEUIMASTER_DEBUG = 1;
30 CSM_DEBUG = "ULTIMATEUIMASTER_DEBUG";
31  
32 -- Blizzard Registrations
33 UIPanelWindows["UltimateUIMasterFrame"] = { area = "center", pushable = 0 };
34  
35 -- These contain the registered variables, and their respective settings
36 UltimateUIMaster_Configurations = { };
37 UltimateUIMaster_ChatCommands = { };
38 UltimateUIMaster_ChatWatches = { };
39 UltimateUIMaster_ChatTypeMap = { };
40 UltimateUIMaster_Buttons = { };
41 UltimateUIMaster_ChannelOrder = { };
42 UltimateUIMaster_UltimateUIUsers = { };
43  
44 -- Store UltimateUI Users between sessions?
45 -- RegisterForSave("UltimateUIMaster_UltimateUIUsers");
46 -- RegisterForSave("UltimateUIMaster_CVars");
47  
48 -- Keywords (for use by anyone)
49 CSM_VARIABLE = "variable";
50 CSM_TYPE = "type";
51 CSM_STRING = "string";
52 CSM_DESCRIPTION = "description";
53 CSM_HANDLER = "onchange";
54 CSM_CHECKONOFF = "checked";
55 CSM_SLIDERSTRING = "substring";
56 CSM_DEFAULTVALUE = "slidervalue";
57 CSM_SLIDERVALUE = "slidervalue";
58 CSM_SLIDERMIN = "slidermin";
59 CSM_SLIDERMAX = "slidermax";
60 CSM_SLIDERSTEP = "sliderstep";
61 CSM_SLIDERVALUETEXTTOGGLE = "slidervaluetexttoggle";
62 CSM_SLIDERTEXTAPPEND = "append";
63 CSM_SLIDERVALUETEXTMULTIPLIER = "multiplier";
64 CSM_SECTION = "section";
65 CSM_ID = "id";
66 CSM_NAME = "name";
67 CSM_ICON = "icon";
68 CSM_LONGDESCRIPTION = "longdescription";
69 CSM_CALLBACK = "callback";
70 CSM_TESTFUNCTION = "testfunction";
71 CSM_ALIASES = "aliases";
72 CSM_PREVIOUSFUNCTION = "prevfunction";
73 CSM_CHAINPRE = "chainpre"; -- Chain commands before you call yourself
74 CSM_CHAINPOST = "chainpost"; -- Chain commands after you call yourself
75 CSM_CHAINNONE = "chainnone"; -- Don't chain
76 CSM_CHAINPREVIOUSONLY = "chainpreviousonly"; -- Ignore yourself if you already exist
77 CSM_TYPELIST = "typelist";
78 CSM_CHANNELINDEX = "chanindex";
79 CSM_CHANNELNAME = "channame";
80 CSM_CHANNELDESC = "chandesc";
81 CSM_CHANNELSTATE = "chanstate";
82 CSM_CHANNELCREATE = "chantimeorder";
83  
84 -- These contain global variables, used for timing/state checks
85 UltimateUIMaster_StartTime = 0;
86 UltimateUIMaster_WaitMessage = "";
87 UltimateUIMaster_WaitButton = "";
88 UltimateUIMaster_CurrentChannel = "";
89 UltimateUIMaster_LastChatTime = 0;
90 UltimateUIMaster_JoinDelay = ULTIMATEUIMASTER_CHAT_JOIN_DELAY;
91 UltimateUIMaster_LeaveDelay = ULTIMATEUIMASTER_CHAT_JOIN_DELAY;
92 UltimateUIMaster_VarsLoaded = nil;
93 UltimateUIMaster_LastPlayer = nil;
94 UltimateUIMaster_LastRealm = nil;
95 UltimateUIMaster_ChansLoaded = nil;
96 UltimateUIMaster_ChansWasOnTaxi = nil;
97 UltimateUIMaster_LastAsked = nil;
98 UltimateUIMaster_ChanList = {};
99 UltimateUIMaster_ChanIDList = {};
100 UltimateUIMaster_Section = "UUI_COS";
101 UltimateUIMaster_UseChatFunctions = true;
102 UltimateUIMaster_LastSection = UltimateUIMaster_Section;
103 UltimateUIMaster_LastSeparator = nil;
104 CHANNEL_ULTIMATEUI = "ULTIMATEUI_CHANNEL";
105 CHANNEL_PARTY = "ULTIMATEUI_PARTY";
106  
107 -- This registers a variable with the configuration client. --
108  
109 --[[
110  
111 This MUST be called for a variable to appear in the configuration menu.
112  
113 ParameterList:
114 uui_variable - the global var used and string for the CVar
115 uui_type - CHECKBOX, SLIDER, BOTH, BUTTON, SEPARATOR, or SECTION
116 uui_string - Associated string
117 uui_description - A three line max description of the variable for the users sake
118 uui_handerfunction - Function called with value as first parameter, and second as toggle state when changed.
119 uui_defaultcheckedvalue - 1 = Checked, 0 = Unchecked
120 uui_defaultvalue - Default value returned when checked
121 uui_min - Minimum slider value
122 uui_max - Maximum slider value
123 uui_substring - Slider or button text
124 uui_sliderstep - Increments at which the slider may move
125 uui_slidervaluetexton - Toggle for the exact value display of a slider
126 uui_slidervalueappend - Whats added to the end of the number
127 uui_slidervaluemultiplier - Whats the value multiplied by for display.
128  
129 ]]--
130  
131 function UltimateUI_RegisterConfiguration(
132 uui_variable,
133 uui_type,
134 uui_string,
135 uui_description,
136 uui_handlerfunction,
137 uui_defaultcheckedvalue,
138 uui_defaultvalue,
139 uui_min,
140 uui_max,
141 uui_substring,
142 uui_sliderstep,
143 uui_slidervaluetexton,
144 uui_slidervalueappend,
145 uui_slidervaluemultiplier )
146  
147 -- Prepare for nil values
148 if ( uui_description == nil ) then uui_description = ""; end
149 if ( uui_defaultcheckedvalue == nil or uui_defaultcheckedvalue == false or uui_defaultcheckedvalue == 0 ) then uui_defaultcheckedvalue = 0;
150 else uui_defaultcheckedvalue = 1; end
151 if ( uui_defaultvalue == nil ) then uui_defaultvalue = 1; end
152 if ( uui_min == nil ) then uui_min = 0; end
153 if ( uui_max == nil ) then uui_max = 1; end
154 if ( uui_slidervalueappend == nil ) then uui_slidervalueappend = ""; end
155 if ( uui_slidervaluemultiplier == nil ) then uui_slidervaluemultiplier = 1; end
156 if ( uui_type == nil ) then uui_type = "nil"; end
157 if ( uui_substring == nil ) then uui_substring = ""; end
158 if ( uui_sliderstep == nil ) then uui_sliderstep = .01; end
159 if ( uui_handlerfunction == nil ) then uui_handlerfunction = function ( x ) return; end; end;
160 if ( uui_slidervaluetexton == nil or uui_slidervaluetexton == 0) then uui_slidervaluetexton = 0;
161 else uui_slidervaluetexton = 1;
162 end
163  
164 if (not string.find ( uui_variable, "UUI_" )) then
165 -- Sea.io.print ( "Invalid Prefix" );
166 return; -- We won't permit CVars that could mess up the game
167 -- So they must be prefixed with UUI_
168 end
169  
170 -- Check the specified type
171 if ( not uui_type == "CHECKBOX" and not uui_type == "SLIDER" and not uui_type == "SEPARATOR" and not uui_type == "BOTH" and not uui_type == "BUTTON" and not uui_type == "SECTION" ) then
172 -- Sea.io.print ( "Invalid Type: "..uui_type );
173 return; -- Return if it does not suit our handleable types
174 end
175 if ( uui_type == "SLIDER" or uui_type == "BOTH" ) then
176 if ( uui_defaultvalue == nil) then uui_defaultvalue = 1; end
177 end
178 if ( uui_type == "SECTION" ) then
179 UltimateUIMaster_LastSection = uui_variable;
180 end
181 if ( uui_type == "SEPARATOR" ) then
182 UltimateUIMaster_LastSeparator = uui_variable;
183 end
184  
185 local newRegistrant = {
186 [CSM_VARIABLE] = uui_variable,
187 [CSM_TYPE] = uui_type,
188 [CSM_STRING] = uui_string,
189 [CSM_DESCRIPTION] = uui_description,
190 [CSM_SLIDERSTRING] = uui_substring,
191 [CSM_CHECKONOFF] = uui_defaultcheckedvalue,
192 [CSM_SLIDERMIN] = uui_min,
193 [CSM_SLIDERMAX] = uui_max,
194 [CSM_SLIDERVALUE] = uui_defaultvalue,
195 [CSM_SLIDERSTEP] = uui_sliderstep,
196 [CSM_SLIDERVALUETEXTTOGGLE] = uui_slidervaluetexton,
197 [CSM_SLIDERVALUETEXTMULTIPLIER] = uui_slidervaluemultiplier,
198 [CSM_SLIDERTEXTAPPEND] = uui_slidervalueappend,
199 [CSM_HANDLER] = uui_handlerfunction,
200 [CSM_SECTION] = UltimateUIMaster_LastSection
201 }
202  
203 -- Check if its already been registered and flag an error
204 local found = false;
205 for k,v in UltimateUIMaster_Configurations do
206 if ( UltimateUIMaster_Configurations[k][CSM_VARIABLE] == uui_variable ) then
207 if (((UltimateUIMaster_Configurations[k][CSM_TYPE] == "SECTION") and (uui_type == "SECTION")) or ((UltimateUIMaster_Configurations[k][CSM_TYPE] == "SEPARATOR") and (uui_type == "SEPARATOR"))) then
208 return true;
209 else
210 -- Sea.io.print ( " UltimateUI Register Configuration Error: Duplicate Configuration - "..uui_variable );
211 found = true;
212 end
213 end
214 end
215 if ( found == false ) then
216 local index = nil;
217 if (UltimateUIMaster_LastSection and (uui_type ~= "SECTION")) then
218 local foundSection = false;
219 local foundSeparator = false;
220 for k in UltimateUIMaster_Configurations do
221 if (foundSeparator and ((UltimateUIMaster_Configurations[k][CSM_TYPE] == "SECTION") or (UltimateUIMaster_Configurations[k][CSM_TYPE] == "SEPARATOR"))) then
222 break;
223 end
224 if (foundSection and UltimateUIMaster_LastSeparator and (UltimateUIMaster_Configurations[k][CSM_VARIABLE] == UltimateUIMaster_LastSeparator)) then
225 foundSeparator = true;
226 end
227 if (foundSection and (UltimateUIMaster_Configurations[k][CSM_TYPE] == "SECTION")) then
228 break;
229 end
230 if (UltimateUIMaster_Configurations[k][CSM_VARIABLE] == UltimateUIMaster_LastSection) then
231 foundSection = true;
232 end
233 if (foundSection) then
234 index = k;
235 end
236 end
237 end
238 -- Add the new registrant to the list
239 if (index) then
240 table.insert ( UltimateUIMaster_Configurations, index + 1, newRegistrant );
241 else
242 table.insert ( UltimateUIMaster_Configurations, newRegistrant );
243 end
244 end
245  
246 --if ( uui_type=="SLIDER" or uui_type=="BOTH" ) then
247 UltimateUI_RegisterCVar(uui_variable, uui_defaultvalue);
248 --end
249 --if ( uui_type=="CHECKBOX" or uui_type=="BOTH" ) then
250 UltimateUI_RegisterCVar(uui_variable.."_X", uui_defaultcheckedvalue);
251 --end
252  
253 return true;
254  
255 end
256  
257 --[[
258 UltimateUI_UpdateValue allows you to manually update a parameter.
259  
260 I presume upon the user to use this properly.
261 If you break it, tough luck. No error checking here.
262  
263 parameter list:
264  
265 uui_uniqueid - UniqueID (CVar) (technically it updates every match)
266 uui_parameter - Parameter to be updated,
267 uui_value - new value to be set.
268  
269 Example usage
270 UltimateUI_UpdateValue( "UUI_MYVAR", CSM_TYPE, "BUTTON" );
271 UltimateUI_UpdateValue( "UUI_MYVAR", CSM_SLIDERVALUETEXTMULTIPLIER, UnitHealthMax("player") );
272 ]]--
273  
274 function UltimateUI_UpdateValue( uui_uniqueid, uui_parameter, uui_value )
275  
276 if( uui_parameter == CSM_CHECKONOFF ) then
277 if ( uui_value+0 == 0 or uui_value+0 == 1 ) then
278 else return; end
279 end
280 if( uui_parameter == CSM_TYPE ) then
281 if ( uui_value == "SLIDER" or uui_value == "CHECKBOX" or uui_value == "BOTH"
282 or uui_value == "BUTTON" or uui_value == "SEPARATOR" or uui_value == "SECTION" ) then
283 else return; end
284 end
285 if( uui_parameter == CSM_SLIDERSTEP ) then
286 if ( uui_value == 0 ) then uui_value = .01;
287 else return; end
288 end
289  
290 for index, value in UltimateUIMaster_Configurations do
291 if ( value[CSM_VARIABLE] == uui_uniqueid ) then
292 value[uui_parameter] = uui_value; -- Hope the user doesnt break it.
293 end
294 end
295  
296 end
297  
298 --[[
299  
300 UltimateUI_RegisterChatCommand
301  
302 Allows you to register an in-game chat command with UltimateUI's simple registration system.
303 It will also cause your command to be listed with the /help or /eshelp command locally.
304  
305 usage:
306  
307 UltimateUI_RegisterChatCommand( GroupID, Array of commands, handler of 1 argument, chaining instructions );
308  
309 example: this.chatFrame.channelList[i] = name;
310 this.chatFrame.zoneChannelList[i] = zoneChannel;
311 function MyCallback (message) DEFAULT_CHAT_FRAME:AddMessage(message,r,g,b); end
312 MyCommands = { "/testa", "/testb", "/testc" }
313 UltimateUI_RegisterChatCommand( "TESTGROUP", MyCommands, MyCallback, "My Function", CSM_CHAINPOST);
314  
315 Will create a command that executes MyCallback, and anything else that was listed for testgroup previously.
316  
317 ]]--
318  
319 function UltimateUI_RegisterChatCommand( uui_groupid, uui_commands, uui_handler, uui_descriptionstring, uui_chaintype )
320 -- Error checking.
321 if ( uui_groupid == nil ) then
322 -- Sea.io.print( " No Group ID specified." );
323 return;
324 end
325 if ( uui_commands == nil ) then
326 -- Sea.io.print( uui_groupid.." No /command specified." );
327 return;
328 end
329 if ( uui_handler == nil ) then
330 -- Sea.io.print( uui_groupid.." No functions specified." );
331 return;
332 end
333  
334 -- Adds the command handler to the chat global pane
335 cmdlist = getglobal ( "SlashCmdList" );
336  
337 local uui_prevfunc = nil;
338  
339 -- Save the old commands if you're overwriting one
340 if ( cmdlist [ uui_groupid ] ~= nil ) then
341 uui_prevfunc = cmdlist [ uui_groupid ] ;
342 end
343  
344 -- Error checking
345 if ( uui_prevfunc == nil ) then
346 uui_prevfunc = function () return; end;
347 end
348  
349 -- Set the new command
350 if ( uui_chaintype == CSM_CHAINPRE ) then
351 cmdlist [ uui_groupid ]
352 = function (msg)
353 uui_prevfunc(msg);
354 uui_handler(msg);
355 end;
356 end
357  
358 if ( uui_chaintype == CSM_CHAINPOST ) then
359 cmdlist [ uui_groupid ]
360 = function (msg)
361 uui_handler(msg);
362 uui_prevfunc(msg);
363 end;
364 end
365 if ( uui_chaintype == CSM_CHAINPREVIOUSONLY ) then
366 cmdlist [ uui_groupid ]
367 = function (msg)
368 uui_prevfunc(msg);
369 end;
370 end
371 if ( uui_chaintype == nil or uui_chaintype == CSM_CHAINNONE ) then
372 cmdlist [ uui_groupid ]
373 = function (msg)
374 uui_handler(msg);
375 end;
376 end
377  
378 -- Create a new command and save it locally.
379 -- Sky.registerSlashCommand({id=uui_groupid,commands=uui_commands,onExecute=uui_handler,action=uui_prevfunc, helpText=uui_descriptionstring} );
380 end
381  
382 --[[
383  
384 RegisterButton
385  
386 Allow you to create a button of your mod in the UltimateUI Features Frame.
387  
388 Usage:
389  
390 UltimateUI_RegisterButton ( name, description, ToolTip_description, icon, callback, testfunction )
391  
392 Example:
393  
394 UltimateUI_RegisterButton (
395 "Name",
396 "Little Text",
397 "Long Tool Tip Text",
398 "Interface\\Icons\\Spell_Holy_BlessingOfStrength",
399 function()
400 if (GamesListFrame:IsVisible()) then
401 HideUIPanel(GamesListFrame);
402 else
403 ShowUIPanel(GamesListFrame);
404 end
405 end,
406 function()
407 if (UnitInParty("party1")) then
408 return true; -- The button is enabled
409 else
410 return false; -- The button is disabled
411 end
412 end
413 );
414  
415 A button will be created in the Features Frame.
416  
417 Description must not be more than 2 words, you should put a longer description in the tool tip.
418  
419 ]]--
420  
421 function UltimateUI_RegisterButton ( uui_name, uui_description, uui_longdescription, uui_icon, uui_callback, uui_testfunction )
422 if ( uui_name == nil ) then
423 -- Sea.io.print ( "Missing a name for the Button.");
424 end
425 if ( uui_icon == nil ) then
426 -- Sea.io.print ( "Missing an icon path for the Button.");
427 end
428 if ( uui_callback == nil ) then
429 -- Sea.io.print ( "Missing a callback for the Button.");
430 end
431 if ( uui_testfunction == nil ) then
432 uui_testfunction = function () return true; end;
433 end
434  
435 temp = { };
436 temp[CSM_NAME] = uui_name;
437 temp[CSM_DESCRIPTION] = uui_description;
438 temp[CSM_LONGDESCRIPTION] = uui_longdescription;
439 temp[CSM_ICON] = uui_icon;
440 temp[CSM_CALLBACK] = uui_callback;
441 temp[CSM_TESTFUNCTION] = uui_testfunction;
442  
443 tinsert ( UltimateUIMaster_Buttons, temp );
444  
445 UltimateUIButton_UpdateButton();
446 end
447  
448 --[[
449  
450 RegisterChatWatch
451  
452 Allows you to register a command to be called when a condition
453 is met within a block of text in incoming chat messages.
454  
455 Usage:
456  
457 UltimateUI_RegisterChatWatch ( id, typearray, handlerfunction, description );
458  
459 Example;
460  
461 UltimateUI_RegisterChatWatch ( "NOYELLS", {"YELL"}, function (msg) return 0; end );
462  
463 This would create a function which disables yells by returning a 0
464 (indicating to halt all commands) whenever a type 'YELL' is seen.
465  
466 Description is entirely for debugging and observational purposes.
467  
468 You can watch the ultimateui channel, just use CHANNEL_ULTIMATEUI instead of the channel type.
469 You can watch the ultimateui party channel, just use CHANNEL_PARTY instead of the channel type.
470  
471 ]]--
472  
473 function UltimateUI_RegisterChatWatch ( uui_id, uui_typelist, uui_handler, uui_description )
474  
475 if ( uui_id == nil ) then
476 -- Sea.io.print ( "Missing an ID for ChatWatch.");
477 end
478 if ( uui_typelist == nil or getn( uui_typelist) == 0 ) then
479 -- Sea.io.print ( "No chat types specified for observation");
480 end
481 if ( uui_handler == nil ) then
482 -- Sea.io.print ( "No handler function specified to apply to chat messages");
483 end
484  
485 newChatWatch = {};
486 newChatWatch[CSM_ID] = uui_id;
487 newChatWatch[CSM_TYPELIST] = uui_typelist;
488 newChatWatch[CSM_HANDLER] = uui_handler;
489 newChatWatch[CSM_DESCRIPTION] = uui_description;
490  
491 -- Ignore this really useless line
492 tinsert ( UltimateUIMaster_ChatWatches, newChatWatch );
493 for k,v in uui_typelist do
494 if ( UltimateUIMaster_ChatTypeMap[v] == nil ) then UltimateUIMaster_ChatTypeMap[v] = {}; end
495 tinsert ( UltimateUIMaster_ChatTypeMap[v], {handler=uui_handler;id=uui_id} );
496 end
497 end
498  
499 -- this function iterates through the list and processes all commands that match and return not 0
500 function UltimateUIMaster_PreprocessChat(event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, loops, frame)
501 -- Sea.io.error("If you're seeing this message, you have an out of date FrameXML folder. Delete it and patch again.");
502 end
503  
504 -- Cleans out ultimateui channels
505 function UltimateUIMaster_CleanChannels()
506 local foundChan = false;
507 for i = 1, 10, 1 do
508 local channelNum, channelName = GetChannelName(i);
509 if (channelNum > 0 and channelName ~= nil) then
510 if ( string.find(channelName, "ZParty") or string.find(channelName, "ZUltimateUITemp") or (channelName == UltimateUIMaster_GetChannelName())) then
511 LeaveChannelByName(channelName);
512 foundChan = true;
513 end
514 end
515 end
516 if (foundChan) then
517 --UltimateUI_Schedule(1, UltimateUIMaster_CleanChannels);
518 return;
519 end
520 if (UnitOnTaxi("player")) then
521 UltimateUIMaster_ChansWasOnTaxi = true;
522 --UltimateUI_Schedule(1, UltimateUIMaster_CleanChannels);
523 return;
524 end
525 if (UltimateUIMaster_ChansWasOnTaxi) then
526 UltimateUIMaster_ChansWasOnTaxi = false;
527 --UltimateUI_Schedule(ULTIMATEUIMASTER_CHAT_INIT_WAIT, UltimateUIMaster_CleanChannels);
528 return;
529 end
530 UltimateUIMaster_ChansLoaded = true;
531 end
532  
533 -- Keeps up with new channels that have been joined, and assigns an appropriate number to them in the virtual number system
534 function UltimateUIMaster_WatchChatOrder()
535 end
536  
537 -- Replacement for the normal channel listing, lists UltimateUI numbered channels
538 function UltimateUIMaster_ListChannels(message, chanNum)
539 end
540  
541 -- This fuction obtains the number of the specified channel
542 function UltimateUIMaster_GetChannelNumber(channel)
543 end
544  
545 -- This fuction obtains the number of the specified channel in the ultimateui channel list
546 function UltimateUIMaster_GetChannelID(name)
547 end
548  
549 -- This Determines the name of the UltimateUI channel
550 function UltimateUIMaster_GetChannelName()
551 end
552  
553 function UltimateUIMaster_JoinChannel(channelName)
554 end
555  
556 -- Joins a channel and assigns it a number in the ultimateui channel list
557 -- Dont pass channelID if you want the channel to no longer have a specified ID
558 function UltimateUIMaster_JoinChannelByID(channelName, channelID)
559 end
560  
561 function UltimateUI_LeaveChannel(channelName, loops)
562 end
563  
564 function UltimateUI_SendMessage(message)
565 end
566  
567 function UltimateUI_LeaveParty()
568 for i = 1, 20, 1 do
569 local channelNum, channelName = GetChannelName(i);
570  
571 if (channelNum > 0 and channelName ~= nil) then
572 if ( string.find(channelName, "ZParty") ~= nil ) then
573 UltimateUI_LeaveChannel(channelName);
574 end
575 end
576 end
577 end
578  
579 function UltimateUI_SendPartyMessage(message)
580 end
581  
582 function UltimateUIMaster_ChangePartyChannel()
583 end
584  
585 function UltimateUIMaster_GetCurrentPartyChannel()
586 local gleader = "gg";
587  
588 return "ZParty"..gleader;
589 end
590  
591 -- Update callback
592 function UltimateUIMaster_Update()
593 UltimateUIMaster_DrawData();
594 end
595  
596 -- Loading function
597 function UltimateUIMasterFrame_Show()
598 UltimateUIMasterFrame_IsLoading = true;
599 UltimateUIMaster_DrawData();
600 UltimateUIMasterFrame_IsLoading = false;
601 end
602  
603 function FixMacroActionButtonErrors()
604 -- thanks to iriel :)
605 if (not MacroFrame_EditMacro) then
606 function MacroFrame_EditMacro()
607 if (MacroFrame_SaveMacro) then
608 MacroFrame_SaveMacro();
609 end
610 end
611 end
612  
613 end
614  
615 -- Basic Initialization of global variables
616 function UltimateUIMaster_Init()
617 -- Register UltimateUI' chat commands
618 UltimateUI_RegisterUltimateUIChatCommands();
619  
620 -- Add CVar watching
621 this:RegisterEvent("CVAR_UPDATE");
622 this:RegisterEvent("PARTY_LEADER_CHANGED");
623 this:RegisterEvent("RAID_ROSTER_UPDATE");
624 this:RegisterEvent("VARIABLES_LOADED");
625 this:RegisterEvent("UNIT_NAME_UPDATE");
626 this:RegisterEvent("PLAYER_ENTERING_WORLD");
627  
628 -- Set Up the timers
629 UltimateUIMaster_StartTime = GetTime();
630 UltimateUIMaster_WaitButton = GetTime() + 0.1;
631  
632 -- Reload all variables.
633 UltimateUIMaster_Reset();
634  
635 local comlist = ULTIMATEUI_COMM;
636 local desc = ULTIMATEUI_DESC;
637 local id = "ULTIMATEUIOTHER";
638 local func = function(msg)
639 if (msg) then
640 UltimateUI_SendMessage('<C>'..msg);
641 UltimateUIMaster_LastAsked = strupper(msg);
642 --UltimateUI_Schedule(5,UltimateUI_DontHaveUltimateUI, msg);
643 end
644 end
645 UltimateUI_RegisterChatCommand ( id, comlist, func, desc );
646  
647 FixMacroActionButtonErrors();
648  
649 UltimateUI_IsLoaded = "true";
650 end
651  
652 -- Event handling
653 function UltimateUIMaster_OnEvent(event)
654 if (( event == "UNIT_NAME_UPDATE" ) and (arg1 == "player") and (not UltimateUIMaster_VarsLoaded)) then
655 playername = UnitName("player");
656 if (playername) then
657 if ((playername ~= UKNOWNBEING) and ( playername ~= UNKNOWNOBJECT )) then
658 UltimateUIMaster_LastPlayer = UltimateUIMaster_CVars[UUI_LAST_PLAYER];
659 UltimateUIMaster_LastRealm = UltimateUIMaster_CVars[UUI_LAST_REALM];
660 UltimateUIMaster_CVars[UUI_LAST_PLAYER] = playername;
661 UltimateUIMaster_CVars[UUI_LAST_REALM] = GetCVar("realmName");
662 UltimateUIMaster_VarsLoaded = true;
663 UltimateUI_RegisterMissed();
664 UltimateUI_SetMissed();
665 UltimateUIMaster_LoadVariables();
666 UltimateUIMaster_SyncVars();
667 UltimateUI_CallVarsLoaded();
668 end
669 end
670 end
671 if (event == "VARIABLES_LOADED") then
672 UltimateUIMaster_LastPlayer = UltimateUIMaster_CVars[UUI_LAST_PLAYER];
673 UltimateUIMaster_LastRealm = UltimateUIMaster_CVars[UUI_LAST_REALM];
674 UltimateUIMaster_CVars[UUI_LAST_PLAYER] = playername;
675 UltimateUIMaster_CVars[UUI_LAST_REALM] = GetCVar("realmName");
676 UltimateUIMaster_VarsLoaded = true;
677 UltimateUI_RegisterMissed();
678 UltimateUI_SetMissed();
679 UltimateUIMaster_LoadVariables();
680 UltimateUIMaster_SyncVars();
681 UltimateUI_CallVarsLoaded();
682 end
683 end
684  
685 function UltimateUIMaster_OnUpdate(elapsed)
686 end
687  
688 -- Basic Saving
689 function UltimateUIMaster_Save()
690 UltimateUIMaster_StoreVariables();
691 UltimateUIMaster_SyncVars();
692 -- RegisterForSave("UltimateUIMaster_CVars");
693 end
694  
695 -- Basic Reverting
696 function UltimateUIMaster_Reset()
697 UltimateUIMaster_LoadVariables();
698 UltimateUIMaster_SyncVars();
699 end
700  
701 -- Displays the commands help list
702 function UltimateUIMaster_ChatCommandsHelpDisplay (msg)
703 -- Sea.io.print ( "UltimateUI Help: ");
704 for index, value in UltimateUIMaster_ChatCommands do
705 if ( value[CSM_DESCRIPTION] == "" ) then
706 else
707 local aliases = value[CSM_ALIASES];
708 if ( aliases and value[CSM_DESCRIPTION]) then
709 local helpmsg = "- "..aliases[1].." - "..value[CSM_DESCRIPTION];
710 -- Sea.io.printc ( {r=.7,g=.6,b=.8}, helpmsg );
711 end
712 end
713 end
714  
715 end
716  
717 -- Shows the current version.
718 function UltimateUIMaster_ChatVersionDisplay(msg)
719 -- Sea.io.print ( "UltimateUI Version: "..ULTIMATEUIMASTER_VERSION.."\n".."UltimateUI Menu Updated: "..ULTIMATEUIMASTER_UPDATE );
720 end
721  
722 -- Returns the command alias list for a registered command.
723 function UltimateUIMaster_GetCommandAliases ( uui_id )
724 -- Sea.io.print(uui_id, .5, .5, .5); -- Debug: This will list all commands passed through
725  
726 for index, value in UltimateUIMaster_ChatCommands do
727 if ( value[CSM_ID] == uui_id ) then
728 return value[CSM_ALIASES];
729 end
730 end
731 -- If none was found, return nil
732 return nil;
733 end
734  
735 -- Gets the prior functions for a registered command
736 function UltimateUIMaster_GetPreviousCommand ( uui_id )
737 for index, value in UltimateUIMaster_ChatCommands do
738 if ( value[CSM_ID] == uui_id ) then
739 return value[CSM_PREVIOUSFUNCTION];
740 end
741 end
742 -- If none was found, return nil
743 return nil;
744  
745 end
746  
747 -- Displays description text.
748 function UltimateUIMaster_SetInfo( index )
749 local realindex = index + FauxScrollFrame_GetOffset(UltimateUIMasterScrollFrame);
750  
751 -- Make sure its a valid index.
752 if ( realindex > getn ( UltimateUIMaster_Configurations ) ) then return; end
753  
754 local config = UltimateUIMaster_GetOffsetValue(realindex);
755 if (not config) then return; end
756 local descriptiontext = config[CSM_DESCRIPTION];
757  
758 if ( realindex == 0 ) then
759 -- Sea.io.error ("Invalid UltimateUI Index: 0 ");
760 else
761 local config = UltimateUIMaster_GetOffsetValue(realindex);
762 local descriptiontext = config[CSM_DESCRIPTION];
763  
764 if ( not (descriptiontext == "") ) then
765 UltimateUIMaster_ClearInfo();
766 UltimateUIMasterTextbox:AddMessage("\n"..descriptiontext.."\n ", 156/256, 212/256, 1.0 );
767 end
768 end
769 end
770  
771 -- Displays description text.
772 function UltimateUIMaster_SetSectionInfo( index )
773 local realindex = index + FauxScrollFrame_GetOffset(UltimateUIMasterSectionScrollFrame);
774  
775 -- Make sure its a valid index.
776 if ( realindex > UltimateUIMaster_GetSectCount() ) then return; end
777  
778 local config = UltimateUIMaster_GetOffsetSection(realindex);
779 if (not config) then return; end
780 local descriptiontext = config[CSM_DESCRIPTION];
781  
782 if ( realindex == 0 ) then
783 -- Sea.io.error ("Invalid UltimateUI Index: 0 ");
784 else
785 local config = UltimateUIMaster_GetOffsetSection(realindex);
786 local descriptiontext = config[CSM_DESCRIPTION];
787  
788 if ( not (descriptiontext == "") ) then
789 UltimateUIMaster_ClearInfo();
790 UltimateUIMasterTextbox:AddMessage("\n"..descriptiontext.."\n ", 156/256, 212/256, 1.0 );
791 end
792 end
793 end
794  
795 function UltimateUIMaster_ClearInfo()
796 UltimateUIMasterTextbox:AddMessage("\n\n\n\n");
797 end
798  
799 -- Switches sections
800 function UltimateUIMaster_Section_OnClick(index)
801 if ( not (UltimateUIMasterFrame_IsLoading == 1) and (UltimateUIMaster_DrawDataStarted==0) ) then
802 local sectOffset = FauxScrollFrame_GetOffset(UltimateUIMasterSectionScrollFrame);
803 local sectionButton = getglobal ("UltimateUISection"..index);
804 local section = UltimateUIMaster_GetOffsetSection(index+sectOffset); -- change to + offset
805 if (section[CSM_VARIABLE] and (section[CSM_VARIABLE] ~= UltimateUIMaster_Section)) then
806 UltimateUIMaster_Section = section[CSM_VARIABLE];
807 UltimateUIMaster_DrawData();
808 end
809 end
810 end
811  
812 -- Updates the value when a slider changes...
813 function UltimateUIMaster_Slider (relativeindex, slidervalue )
814  
815 if ( not (UltimateUIMasterFrame_IsLoading == 1) and (UltimateUIMaster_DrawDataStarted==0) ) then
816 local append = "";
817 local index = relativeindex;
818 local funcOffset = FauxScrollFrame_GetOffset(UltimateUIMasterScrollFrame);
819 local value = UltimateUIMaster_GetOffsetValue(index+funcOffset); -- change to + offset
820 local slider = getglobal ("UltimateUI"..index.."Slider");
821 local slidervaluetext = getglobal("UltimateUI"..index.."Slider".."ValueText");
822  
823 -- This makes sure that the correct type is being used before setting the value
824 if ( value[CSM_TYPE] == "SLIDER" or value[CSM_TYPE] == "BOTH" ) then
825  
826 -- Rounds off value to 2 Decimal places
827 local newvalue = slidervalue;
828 newvalue = floor(newvalue * 100+.5)/100;
829  
830 value[CSM_SLIDERVALUE] = newvalue;
831  
832 if ( value[CSM_SLIDERVALUETEXTTOGGLE] == 1 ) then
833 -- Show only 2 decimal places of accuracy in text
834 local valuetext = floor(value[CSM_SLIDERVALUE]*value[CSM_SLIDERVALUETEXTMULTIPLIER]*100+.5)/100;
835 valuetext = valuetext..value[CSM_SLIDERTEXTAPPEND];
836  
837 slidervaluetext:SetText ( valuetext );
838 slidervaluetext:Show();
839 else
840 slidervaluetext:Hide();
841  
842 end
843  
844 slidervalue = value[CSM_SLIDERVALUE];
845  
846 -- Call the referring function
847 local callback = value[CSM_HANDLER];
848 callback(value[CSM_CHECKONOFF],slidervalue);
849 end
850 end
851  
852 end
853  
854 --[[ Handles Checkbox Events ]]--
855 function UltimateUIMaster_CheckBox (relativeindex, checkedvalue )
856 if ( not UltimateUIMasterFrame_IsLoading ) then
857 local index = relativeindex;
858 local funcOffset = FauxScrollFrame_GetOffset(UltimateUIMasterScrollFrame);
859 index = index + funcOffset;
860 local value = UltimateUIMaster_GetOffsetValue(index);
861  
862 local checkbox = getglobal("UltimateUI"..index.."Checkbox");
863 local checkboxtext = getglobal("UltimateUI"..index.."FrameText");
864  
865 if ( value[CSM_TYPE] == "CHECKBOX") then
866 value[CSM_CHECKONOFF] = checkedvalue;
867 else
868 if ( value[CSM_TYPE] == "BOTH" ) then
869 value[CSM_CHECKONOFF] = checkedvalue;
870 else
871 value[CSM_CHECKONOFF] = 1;
872 end
873 end
874  
875 -- Call the referring function
876 local callback = value[CSM_HANDLER];
877 local setval = (0);
878 if ( value[CSM_SLIDERVALUE] ) then
879 setval = value[CSM_SLIDERVALUE];
880 end
881 callback(value[CSM_CHECKONOFF], setval);
882  
883 end
884 end
885  
886 function UltimateUIMaster_Button (relativeindex)
887 if ( not (UltimateUIMasterFrame_IsLoading==1) ) then
888 local index = relativeindex;
889 local funcOffset = FauxScrollFrame_GetOffset(UltimateUIMasterScrollFrame);
890 local value = UltimateUIMaster_GetOffsetValue(index+funcOffset); -- change to + offset
891  
892 -- Call the referring function
893 local callback = value[CSM_HANDLER];
894 local setval = value[CSM_SLIDERVALUE];
895 local checked = value[CSM_CHECKONOFF];
896 if (setval == nil) then setval=1; end
897 callback(checked, setval);
898 end
899 end
900  
901 -- Turns channel management on/off
902 function UltimateUIMaster_ToggleChannelManager ( toggle, value )
903 UltimateUIMaster_ChannelManager = toggle;
904 end
905  
906 -- Default behaviour
907 function UltimateUIMaster_CheckGui( slot )
908 --SendChatMessage( "Error, invalid value at slot" + slot );
909 end
910  
911 function UltimateUI_UserMessage(message)
912 -- Sea.io.print(message);
913 end
914  
915 function UltimateUI_DontHaveUltimateUI(user)
916 if (strupper(UltimateUIMaster_LastAsked) == strupper(user)) then
917 UltimateUI_UserMessage(format(ULTIMATEUI_DONTHAVE,user));
918 end
919 end
920  
921 -- Updates the ultimateui user list
922 function UltimateUIMaster_UltimateUIUsers_Update( type, info, message, player, language )
923 if ( message == "<CL>" ) then
924 UltimateUIMaster_UltimateUIUsers[player] = GetTime();
925 if (strupper(player) == UltimateUIMaster_LastAsked) then
926 UltimateUI_UserMessage(format(ULTIMATEUI_HAVE,player));
927 end
928  
929 return 0;
930 end
931  
932 if ( "<C>" == strsub(message, 1, 3) ) then
933 local name = strsub(message, 4, strlen(message));
934 if (strupper(UnitName("player")) == strupper(name)) then
935 UltimateUIMaster_UltimateUIUsers[player] = GetTime();
936 UltimateUI_SendMessage('<CL>');
937 end
938  
939 return 0;
940 end
941 end
942  
943 function UltimateUIMaster_OnOkayClick()
944 PlaySound("gsTitleOptionOK");
945 UltimateUIMaster_Save();
946 HideUIPanel(UltimateUIMasterFrame);
947 end
948 -- Synchronizes all global variables
949 function UltimateUIMaster_SyncVars()
950 for index, value in UltimateUIMaster_Configurations do
951 if ( value[CSM_TYPE] == "SEPARATOR" or value[CSM_TYPE] == "BUTTON" or value[CSM_TYPE] == "SECTION" ) then
952 else
953 setglobal(value[CSM_VARIABLE], value[CSM_SLIDERVALUE] );
954 setglobal(value[CSM_VARIABLE]..'_X',value[CSM_CHECKONOFF]);
955 local callback = value[CSM_HANDLER];
956 local slidervalue = value[CSM_SLIDERVALUE];
957 callback(value[CSM_CHECKONOFF],slidervalue);
958 end
959 end
960 end
961  
962 -- Load all variables from CVars
963 function UltimateUIMaster_LoadVariables()
964  
965 for index, value in UltimateUIMaster_Configurations do
966 -- Ignore separators
967 if ( value[CSM_TYPE] == "SEPARATOR" or value[CSM_TYPE] == "BUTTON" or value[CSM_TYPE] == "SECTION" ) then
968 else
969 if ( value[CSM_TYPE]=="SLIDER" or value[CSM_TYPE]=="BOTH" ) then
970 val = UltimateUI_GetCVar(value[CSM_VARIABLE]);
971 if ( val ~= nil ) then
972 value[CSM_SLIDERVALUE] = val + 0;
973 else
974 UltimateUI_SetCVar(value[CSM_VARIABLE], value[CSM_SLIDERVALUE]);
975 end
976 end
977 if ( value[CSM_TYPE]=="CHECKBOX" or value[CSM_TYPE]=="BOTH" ) then
978 val = UltimateUI_GetCVar(value[CSM_VARIABLE].."_X");
979 if ( val ~= nil ) then
980 value[CSM_CHECKONOFF] = val + 0;
981 else
982 UltimateUI_SetCVar(value[CSM_VARIABLE], value[CSM_CHECKONOFF]);
983 end
984 end
985 end
986 end
987 end
988  
989 -- Store all variables to CVars
990 function UltimateUIMaster_StoreVariables()
991 for index, value in UltimateUIMaster_Configurations do
992 if (not ( value[CSM_TYPE]=="SEPARATOR") and not (value[CSM_TYPE] == "BUTTON") and not (value[CSM_TYPE] == "SECTION") ) then
993 if ( value[CSM_TYPE]=="SLIDER" or value[CSM_TYPE]=="BOTH" ) then
994 local slidervalue = value[CSM_SLIDERVALUE] ;
995  
996 UltimateUI_SetCVar(value[CSM_VARIABLE], slidervalue);
997 end
998 if ( value[CSM_TYPE]=="CHECKBOX" or value[CSM_TYPE]=="BOTH" ) then
999 UltimateUI_SetCVar(value[CSM_VARIABLE].."_X", value[CSM_CHECKONOFF]);
1000 end
1001 end
1002 end
1003  
1004 end
1005  
1006 -- Notify all stored methods
1007 function UltimateUIMaster_NotifyAll()
1008 for index, value in UltimateUIMaster_Configurations do
1009 if (not ( value[CSM_TYPE] == "SEPARATOR") and not (value[CSM_TYPE] == "BUTTON") and not (value[CSM_TYPE] == "SECTION") ) then
1010 f = value[CSM_HANDLER];
1011 local slidervalue = value[CSM_SLIDERVALUE];
1012  
1013 f(value[CSM_CHECKONOFF],slidervalue);
1014 end
1015 end
1016 end
1017  
1018 -- Watch CVars
1019 function UltimateUIMaster_HandleCVarUpdate(cvar, val, checked)
1020 --[[
1021 for index, value in UltimateUIMaster_Configurations do
1022 if ( cvar == value[CSM_VARIABLE] ) then
1023 -- this function now works for checkbox types, but
1024 -- probably not much else --Thott
1025 if(value[CSM_TYPE] == "CHECKBOX") then
1026 value[CSM_CHECKONOFF] = val+0;
1027 end
1028  
1029 value[CSM_SLIDERVALUE] = val;
1030 end
1031 end
1032 UltimateUIMaster_NotifyAll();
1033 UltimateUIMaster_DrawData();
1034 ]]
1035 end
1036  
1037 -- Helper function to get Offset
1038 function UltimateUIMaster_GetOffsetValue(offset)
1039 local curList = {};
1040 local curIndex = 1;
1041 for dex, curVal in UltimateUIMaster_Configurations do
1042 if (curVal and (curVal[CSM_TYPE] ~= "SECTION") and (curVal[CSM_SECTION] == UltimateUIMaster_Section)) then
1043 table.insert(curList, curVal);
1044 end
1045 end
1046 return curList[offset];
1047 end
1048  
1049 -- Helper function to get the number of configurations for the current header
1050 function UltimateUIMaster_GetConfCount()
1051 confCount = 0;
1052 for dex, curVal in UltimateUIMaster_Configurations do
1053 if (curVal and (curVal[CSM_TYPE] ~= "SECTION") and (curVal[CSM_SECTION] == UltimateUIMaster_Section)) then
1054 confCount = confCount + 1;
1055 end
1056 end
1057 return confCount;
1058 end
1059  
1060 -- Helper function to sort the list of the sections
1061 function UltimateUIMaster_SectionComparator(section1, section2)
1062 if ( ( section1 ) and ( section2 ) ) then
1063 if ( ( section1[CSM_STRING] ) and ( section2[CSM_STRING] ) ) then
1064 if ( section1[CSM_STRING] == TEXT(ULTIMATEUI_CONFIG_SEP) ) then
1065 return true;
1066 elseif ( section2[CSM_STRING] == TEXT(ULTIMATEUI_CONFIG_SEP) ) then
1067 return false;
1068 else
1069 return (section1[CSM_STRING] < section2[CSM_STRING]);
1070 end
1071 elseif ( section1[CSM_STRING] ) then
1072 return false;
1073 elseif ( section2[CSM_STRING] ) then
1074 return true;
1075 end
1076 elseif ( section1 ) then
1077 return false;
1078 elseif ( section2 ) then
1079 return true;
1080 end
1081 end
1082  
1083 -- Helper function to get a list of the sections
1084 function UltimateUIMaster_GenerateSectionList()
1085 local curList = {};
1086 for dex, curVal in UltimateUIMaster_Configurations do
1087 if (curVal and (curVal[CSM_TYPE] == "SECTION")) then
1088 table.insert(curList, curVal);
1089 end
1090 end
1091 table.sort(curList, UltimateUIMaster_SectionComparator);
1092 return curList;
1093 end
1094  
1095 -- Helper function to get Offset
1096 function UltimateUIMaster_GetOffsetSection(offset)
1097 local curList = UltimateUIMaster_GenerateSectionList();
1098 return curList[offset];
1099 end
1100  
1101 -- Helper function to get the number of sections
1102 function UltimateUIMaster_GetSectCount()
1103 sectCount = 0;
1104 for dex, curVal in UltimateUIMaster_Configurations do
1105 if (curVal[CSM_TYPE] == "SECTION") then
1106 sectCount = sectCount + 1;
1107 end
1108 end
1109 return sectCount;
1110 end
1111  
1112 -- Helper function to set up a section button
1113 function UltimateUIMaster_SectionSetup(button, visible, section)
1114 local normalTexture = getglobal(button:GetName().."NormalTexture");
1115  
1116 if (section) then
1117 button:SetText(section[CSM_STRING]);
1118 if (section[CSM_VARIABLE] == UltimateUIMaster_Section) then
1119 button:LockHighlight();
1120 else
1121 button:UnlockHighlight();
1122 end
1123 end
1124  
1125 if (visible) then
1126 if (not button:IsVisible()) then
1127 button:Show();
1128 end
1129 else
1130 if (button:IsVisible()) then
1131 button:Hide();
1132 end
1133 end
1134  
1135 if (UltimateUIMaster_GetSectCount() <= 18) then
1136 button:SetWidth(160);
1137 else
1138 button:SetWidth(132);
1139 end
1140 end
1141  
1142 -- Draws the boxes data
1143 function UltimateUIMaster_DrawData()
1144 local sectCount = UltimateUIMaster_GetSectCount()+2;
1145 FauxScrollFrame_Update(UltimateUIMasterSectionScrollFrame, sectCount, 18, 32 );
1146 local sectOffset = FauxScrollFrame_GetOffset(UltimateUIMasterSectionScrollFrame);
1147 for index=1, 18, 1 do
1148 local button = getglobal("UltimateUISection"..index);
1149 local section = UltimateUIMaster_GetOffsetSection(index+sectOffset);
1150 if (section) then
1151 UltimateUIMaster_SectionSetup(button, true, section);
1152 else
1153 UltimateUIMaster_SectionSetup(button);
1154 end
1155 end
1156  
1157 local confCount = UltimateUIMaster_GetConfCount()+2;
1158 FauxScrollFrame_Update(UltimateUIMasterScrollFrame, confCount, 10, 32 );
1159  
1160 local funcOffset = FauxScrollFrame_GetOffset(UltimateUIMasterScrollFrame);
1161 local limit = ULTIMATEUIMASTER_DISPLAY_LIMIT;
1162  
1163 if ( UltimateUIMaster_DrawDataStarted == 1 ) then return;
1164 else UltimateUIMaster_DrawDataStarted = 1; end
1165  
1166 UltimateUIMaster_HideAll();
1167  
1168 -- Update all boxes from the configuration
1169 for index=1, 10, 1 do
1170 if ( index <= 10 and funcOffset >= 0 and index < getn(UltimateUIMaster_Configurations)) then
1171 -- Acquire the value object
1172 local value = UltimateUIMaster_GetOffsetValue(index+funcOffset);
1173 index = index;
1174 if ( value == nil ) then break; end
1175  
1176 -- Update checkboxes
1177 local checkbox = getglobal("UltimateUI"..index.."Checkbox");
1178 local checkboxtext = getglobal("UltimateUI"..index.."FrameText");
1179 local chatbox = getglobal("DEFAULT_CHAT_FRAMEEditBox");
1180  
1181 if( value[CSM_TYPE] == "CHECKBOX" or value[CSM_TYPE] == "BOTH"
1182 or value[CSM_TYPE] == "SLIDER" or value[CSM_TYPE] == "BUTTON") then
1183 if ( value[CSM_STRING] == null ) then
1184 checkboxtext:Hide();
1185 else
1186 checkboxtext:SetText(value[CSM_STRING]);
1187 checkboxtext:Show();
1188 end
1189 end
1190  
1191 if ( value[CSM_TYPE] == "CHECKBOX" or value[CSM_TYPE] == "BOTH" ) then
1192 checkbox:Show();
1193  
1194 if ( value[CSM_CHECKONOFF] == 1) then
1195 checkbox:SetChecked(1);
1196 else
1197 checkbox:SetChecked(0);
1198 end
1199 end
1200  
1201 -- Update sliders
1202  
1203 if ( value[CSM_TYPE] == "SLIDER" or value[CSM_TYPE] == "BOTH" ) then
1204 local slider = getglobal ("UltimateUI"..index.."Slider");
1205 local slidertext = getglobal("UltimateUI"..index.."Slider".."Text");
1206 local slidervaluetext = getglobal("UltimateUI"..index.."Slider".."ValueText");
1207  
1208 if ( value[CSM_SLIDERVALUETEXTTOGGLE] == 1 ) then
1209 local valuetext = floor(value[CSM_SLIDERVALUE]*value[CSM_SLIDERVALUETEXTMULTIPLIER]*100+.5)/100;
1210  
1211 valuetext = valuetext..value[CSM_SLIDERTEXTAPPEND];
1212  
1213 slidervaluetext:SetText ( valuetext );
1214 slidervaluetext:Show();
1215 else
1216 slidervaluetext:Hide();
1217 end
1218 slidertext:SetText ( value[CSM_SLIDERSTRING] );
1219 slidertext:Show();
1220 local slidervalue = value[CSM_SLIDERVALUE];
1221 slider:SetMinMaxValues( value[CSM_SLIDERMIN], value[CSM_SLIDERMAX] );
1222 slider:SetValueStep( value[CSM_SLIDERSTEP] );
1223 slider:SetValue( slidervalue );
1224 slider:Show();
1225 end
1226  
1227 -- Update Separators
1228  
1229 if ( value[CSM_TYPE] == "SEPARATOR" ) then
1230 local separator = getglobal("UltimateUI"..index.."Separator");
1231 local separatortext = getglobal("UltimateUI"..index.."Separator".."Text");
1232  
1233 if ( value[CSM_STRING] == nil ) then
1234 separatortext:Hide();
1235 separator:Show();
1236 else
1237 separatortext:SetText ( value[CSM_STRING] );
1238 separatortext:Show();
1239 separator:Show();
1240 end
1241  
1242 checkbox:Hide();
1243 end
1244  
1245 -- Update Buttons
1246 if ( value[CSM_TYPE] == "BUTTON" ) then
1247 local button = getglobal("UltimateUI"..index.."Button");
1248  
1249 if ( value[CSM_SLIDERSTRING] == nil ) then
1250 button:SetText("Options");
1251 else
1252 button:SetText ( value[CSM_SLIDERSTRING] );
1253 end
1254 button:Show();
1255 end
1256 end
1257 end
1258  
1259 UltimateUIMasterFrame_IsLoading = false;
1260 UltimateUIMaster_DrawDataStarted = 0;
1261  
1262 end
1263  
1264 --[[ Hides all gui items ]]--
1265 function UltimateUIMaster_HideAll()
1266 -- Reset all boxes.
1267 for index = 1, ULTIMATEUIMASTER_DISPLAY_LIMIT, 1 do
1268 local checkbox = getglobal("UltimateUI"..index.."Checkbox");
1269 local checkboxtext = getglobal("UltimateUI"..index.."FrameText");
1270 local slider = getglobal ("UltimateUI"..index.."Slider");
1271 local slidertext = getglobal("UltimateUI"..index.."Slider".."Text");
1272 local slidervaluetext = getglobal("UltimateUI"..index.."Slider".."ValueText");
1273 local button = getglobal("UltimateUI"..index.."Button");
1274 local separator = getglobal("UltimateUI"..index.."Separator");
1275  
1276 checkbox:SetChecked(0);
1277 checkbox:Hide();
1278 checkboxtext:Hide();
1279 checkboxtext:SetText("Reset");
1280 slider:Hide();
1281 slidertext:Hide();
1282 slidervaluetext:Hide();
1283 button:SetText("");
1284 button:Hide();
1285 separator:Hide();
1286 end
1287 end
1288  
1289 --Shows the UltimateUI Menu Button in the game menu
1290 function ToggleGameMenu(clicked)
1291 if ( StaticPopup_Visible("CAMP") or StaticPopup_Visible("QUIT") ) then
1292 return;
1293 end
1294  
1295 if ( clicked ) then
1296 if ( OptionsFrame:IsVisible() ) then
1297 OptionsFrameCancel:Click();
1298 end
1299 if ( UltimateUIMasterFrame) then
1300 if ( UltimateUIMasterFrame:IsVisible() ) then
1301 UltimateUIMasterFrameCancel:Click();
1302 end
1303 end
1304 if ( GameMenuFrame:IsVisible() ) then
1305 PlaySound("igMainMenuQuit");
1306 HideUIPanel(GameMenuFrame);
1307 else
1308 CloseMenus();
1309 CloseAllWindows()
1310 PlaySound("igMainMenuOpen");
1311 ShowUIPanel(GameMenuFrame);
1312 end
1313 return;
1314 end
1315  
1316  
1317 if ( OptionsFrame:IsVisible() ) then
1318 OptionsFrameCancel:Click();
1319 elseif ( GameMenuFrame:IsVisible() ) then
1320 PlaySound("igMainMenuQuit");
1321 HideUIPanel(GameMenuFrame);
1322 elseif ( CloseMenus() ) then
1323 elseif ( SpellStopCasting() ) then
1324 elseif ( SpellStopTargeting() ) then
1325 elseif ( CloseAllWindows() ) then
1326 elseif ( ClearTarget() ) then
1327 else
1328 PlaySound("igMainMenuOpen");
1329 ShowUIPanel(GameMenuFrame);
1330 end
1331 end
1332  
1333  
1334 -------------------------------------------------------------------------------
1335 -- Example Code
1336 -------------------------------------------------------------------------------
1337  
1338 --[[
1339 An Example of how this could be used :
1340  
1341 -- Example Callback Functions
1342 function CombatCaller_HealthEnabledCallback (state, onoff)
1343 if( onoff == 1) then
1344 SendChatMessage ( state );
1345 end
1346 end
1347 function CombatCaller_ManaEnabledCallback (state, onoff)
1348 if ( onoff == 1) then
1349 SendChatMessage ( state );
1350 end
1351 end
1352  
1353 All you have to do is call:
1354  
1355 UltimateUI_RegisterConfiguration("UUI_MYMOD_MYVALUE", "BOTH", "Abc ShortDescription", "Abc Long description\n line12",CombatCaller_HealthEnabledCallback, 0, .5, 0, 1, "BarName", 1, 1, "%");
1356  
1357 And I'll call CombatCaller_HealthEnabledCallback(value); every time the value changes!
1358  
1359 If you need to read the value regularly, just check the variable ULTIMATEUI_MYMOD_MYVALUE.
1360  
1361 Example arrays stored:
1362 (You dont have to create these, I make them in Register)
1363  
1364 UltimateUI_CombatCallerEnableHealthConfig = {
1365 [CSM_VARIABLE]="UUI_COMBATCALLER_HEALTHENABLED", -- The CVar and global value that is updated
1366 [CSM_TYPE]="BOTH", -- CHECKBOX, SLIDER or BOTH
1367 [CSM_STRING]="Enable Auto Low Health Shout", -- The Text string
1368 [CSM_DESCRIPTION]="Long description here\n moretext";
1369 [CSM_CHECKONOFF]=1, -- Starts off checked = true (1)
1370 [CSM_HANDLER]=CombatCaller_HealthEnabledCallback, -- The Function called when the value changes.
1371 [CSM_SLIDERMIN]=0, -- Min value on slider
1372 [CSM_SLIDERMAX]=1, -- Max value on slider
1373 [CSM_SLIDERVALUE]=.5, -- Default value on slider
1374 [CSM_SLIDERSTEP]=.01, -- Increments on slider
1375 [CSM_SLIDERSTRING]="Health Limit", -- Slider Text (optional)
1376 [CSM_SLIDERVALUETEXTTOGGLE]=1, -- Slider Text On/Off toggle
1377 [CSM_SLIDERTEXTAPPEND]="\%",
1378 [CSM_SLIDERVALUETEXTMULTIPLIER]=100
1379 }
1380 UltimateUIMaster_CombatCallerThankYouConfig = {
1381 [CSM_VARIABLE]="UUI_COMBATCALLER_THANKYOUENABLED",
1382 [CSM_TYPE]="CHECKBOX",
1383 [CSM_STRING]="Enable Auto Thank You Shout",
1384 [CSM_DESCRIPTION]="",
1385 [CSM_CHECKONOFF]=1, -- Default on?
1386 [CSM_HANDLER]=CombatCaller_HealthEnabledCallback,
1387 [CSM_SLIDERMIN]=0, -- Everything below is useless for checkbox only.
1388 [CSM_SLIDERMAX]=1,
1389 [CSM_SLIDERVALUE]=1,
1390 [CSM_SLIDERSTEP]=.01, --Unimportant for checkboxes
1391 [CSM_SLIDERSTRING]="",
1392 [CSM_SLIDERVALUETEXTTOGGLE]=0 -- 0 for off!
1393 }
1394  
1395 Please use this wisely.
1396  
1397 -Alex
1398  
1399 ------------------------------------------------------------------
1400  
1401 How to register a chat command:
1402  
1403 --Create a function for your command:
1404 function myfunc () return 4; end
1405  
1406 --Create a list of /commands you want applied.
1407 mycommands = { "/mycommand", "/mycommands" };
1408  
1409 --Create a help description
1410 local mydesc = "This is my command!";
1411  
1412 --Pick a name or an action you are overwriting.
1413 local myfuncname = "CUSTOMMINE";
1414  
1415 --Choose how to handle a command if you overwrite it. (usually CSM_CHAINNONE)
1416 local mychain = CSM_CHAINNONE;
1417  
1418 --Register it
1419 UltimateUIMaster_RegisterChatCommand( myfuncname, mycommands, myfunc, mydesc, mychain );
1420  
1421 -- Thats it!
1422  
1423 ]]--
1424  
1425  
1426 -- Compatability stuffs
1427 -- UltimateUI_Schedule = Chronos.schedule;
1428 -- UltimateUI_ScheduleByName = Chronos.scheduleByName;
1429 -- UltimateUI_AfterInit = Chronos.afterInit;