vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 ---------------------------------------------------------------------------------------------------
2 -- From TimeStamp
3 ----------------------------------------------------------------------------------------------------
4  
5 -- C O L O R P I C K E R F U N C T I O N S --
6 -- Opens a color picker for the timestamp color
7 function ChatBox_TimeStamp_ColorPicker()
8 -- Get the current color
9 local color = ChatBox.TimeStamp_Settings.color;
10 local r, g, b;
11  
12 -- Set the current red, green, blue values
13 if (color and string.find(color, "%x%x%x%x%x%x")) then
14 -- Convert the hexadecimal number into seperate floats for each color channel
15 r = tonumber(string.sub(color, 1, 2), 16) / 255.0;
16 g = tonumber(string.sub(color, 3, 4), 16) / 255.0;
17 b = tonumber(string.sub(color, 5, 6), 16) / 255.0;
18 else
19 -- There was no color specified, so fall back to white
20 r = 1.0;
21 g = 1.0;
22 b = 1.0;
23 end
24  
25 -- Set up color picker values and events
26 ColorPickerFrame.previousValue = color;
27 ColorPickerFrame.func = ChatBox_TimeStamp_ColorPicker_Update;
28 ColorPickerFrame.cancelFunc = ChatBox_TimeStamp_ColorPicker_Cancel;
29 ColorPickerFrame.hasOpacity = false;
30 ColorPickerFrame:SetColorRGB(r, g, b);
31  
32 -- Show the color picker
33 ShowUIPanel(ColorPickerFrame);
34 end
35  
36 -- Event triggered when the color in the color picker is changed
37 function ChatBox_TimeStamp_ColorPicker_Update()
38 local r, g, b = ColorPickerFrame:GetColorRGB();
39 ChatBox.TimeStamp_Settings.color = ChatBox_TimeStamp_FloatColorsToHex(r, g, b);
40 end
41  
42 -- Event triggered when cancel button on the color picker is clicked
43 function ChatBox_TimeStamp_ColorPicker_Cancel()
44 ChatBox.TimeStamp_Settings.color = ColorPickerFrame.previousValue;
45 end
46  
47 -- Converts a color in the format of 3 floats in the range 0.0 - 1.0 into
48 -- one hexadecimal number with a fixed size of 6 digits (2 per float)
49 function ChatBox_TimeStamp_FloatColorsToHex(r, g, b)
50 return string.format("%02X%02X%02X", r * 255.0, g * 255.0, b * 255.0);
51 end