vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 tinsert(UISpecialFrames, "CT_UnitFramesOptionsFrame"); -- So we can close it with escape
2 CT_UnitFramesOptions = {
3 ["styles"] = {
4 [1] = { -- Box
5 { 1, 1, 1, 1, 1}, -- Selections
6 { 1, 1, 1, 1, 1},
7 { 1, 1, 1, 1, 1},
8 { 1, 1, 1, 1, 1},
9 },
10 [2] = { -- Box
11 { 1, 1, 1, 1, 1}, -- Selections
12 { 1, 1, 1, 1, 1},
13 { 1, 1, 1, 1, 1},
14 { 1, 1, 1, 1, 1},
15 },
16 [3] = { -- Box
17 { 1, 1, 1, 1, 1}, -- Selections
18 { 1, 1, 1, 1, 1},
19 },
20 [4] = { -- Box
21 { 1, 1, 1, 1, 1}, -- Selections
22 { 1, 1, 1, 1, 1},
23 }
24 },
25 };
26 CT_UnitFramesOptions_NumSelections = {
27 4, 4, 2, 2
28 };
29  
30 -- OnLoad handlers
31 function CT_UnitFramesOptions_Radio_OnLoad()
32 getglobal(this:GetName() .. "Name"):SetText(CT_UFO_RADIO[this:GetID()]);
33 end
34  
35 function CT_UnitFramesOptions_Selection_OnLoad()
36 if ( CT_UnitFramesOptions_NumSelections[this:GetParent():GetID()] == 2 ) then
37 getglobal(this:GetName() .. "Name"):SetText(CT_UFO_SELECTION[this:GetID()+(1-mod(this:GetID(), 2))]);
38 else
39 getglobal(this:GetName() .. "Name"):SetText(CT_UFO_SELECTION[this:GetID()]);
40 end
41 end
42  
43 function CT_UnitFramesOptions_Box_OnLoad()
44 getglobal(this:GetName() .. "Name"):SetText(CT_UFO_BOX[this:GetID()]);
45 if ( this:GetID() == 3 ) then
46 getglobal(this:GetName() .. "ClassFrameCBName"):SetText(CT_UFO_TARGETCLASS);
47 end
48 end
49  
50 -- OnClick handlers
51 function CT_UnitFramesOptions_Radio_OnClick()
52 local radioId, selectionId, boxId = this:GetID(), this:GetParent():GetID(), this:GetParent():GetParent():GetID();
53 CT_UnitFramesOptions.styles[boxId][selectionId][1] = radioId;
54 CT_UnitFramesOptions_Radio_Update();
55 end
56  
57 -- Function to update the frame
58 function CT_UnitFramesOptions_Radio_Update()
59 for box = 1, 4, 1 do
60 for selection = 1, CT_UnitFramesOptions_NumSelections[box], 1 do
61 for radio = 1, 4, 1 do
62 getglobal("CT_UnitFramesOptionsFrameBox" .. box .. "Selection" .. selection .. "Radio" .. radio):Enable();
63 getglobal("CT_UnitFramesOptionsFrameBox" .. box .. "Selection" .. selection .. "Radio" .. radio .. "Name"):SetTextColor(0.7, 0.7, 0.7, 1.0);
64 getglobal("CT_UnitFramesOptionsFrameBox" .. box .. "Selection" .. selection .. "Radio" .. radio):SetChecked(false);
65 local color = CT_UnitFramesOptions.styles[box][selection];
66 getglobal("CT_UnitFramesOptionsFrameBox" .. box .. "Selection" .. selection .. "ColorSwatchNormalTexture"):SetVertexColor(color[2], color[3], color[4]);
67 end
68 end
69 end
70  
71 for boxId, box in CT_UnitFramesOptions.styles do
72 for selectionId, selection in box do
73 if ( CT_UnitFramesOptions_NumSelections[boxId] > 2 ) then
74 for radioId = 1, CT_UnitFramesOptions_NumSelections[boxId], 1 do
75 if ( selection[1] > 1 ) then
76 local minBound = 1;
77 if ( selectionId > 2 ) then
78 minBound = 3;
79 end
80 for i = minBound, (minBound+1), 1 do
81 getglobal("CT_UnitFramesOptionsFrameBox" .. boxId .. "Selection" .. i .. "Radio" .. selection[1]):Disable();
82 getglobal("CT_UnitFramesOptionsFrameBox" .. boxId .. "Selection" .. i .. "Radio" .. selection[1] .. "Name"):SetTextColor(0.3, 0.3, 0.3, 1.0);
83 end
84 end
85 end
86 end
87 getglobal("CT_UnitFramesOptionsFrameBox" .. boxId .. "Selection" .. selectionId .. "Radio" .. selection[1]):SetChecked(true);
88 getglobal("CT_UnitFramesOptionsFrameBox" .. boxId .. "Selection" .. selectionId .. "Radio" .. selection[1] .. "Name"):SetTextColor(1.0, 1.0, 1.0, 1.0);
89 end
90 end
91  
92 getglobal("CT_UnitFramesOptionsFrameBox3ClassFrameCB"):SetChecked(CT_UnitFramesOptions.displayTargetClass);
93 getglobal("CT_UnitFramesOptionsFrameBox4DisplayCB"):SetChecked(CT_UnitFramesOptions.shallDisplayAssist);
94  
95 if ( CT_UnitFramesOptions.displayTargetClass ) then
96 CT_TargetFrameClassFrame:Show();
97 else
98 CT_TargetFrameClassFrame:Hide();
99 end
100  
101 -- Call the functions to update player/target/target of target/party
102 CT_ShowPlayerHealth();
103 CT_ShowPlayerMana();
104 CT_ShowTargetHealth();
105 CT_ShowTargetMana();
106 CT_ShowAssistHealth();
107 CT_ShowAssistMana();
108 CT_PlayerFrame_UpdateSBT();
109 for i = 1, 5, 1 do
110 CT_PartyFrame_UpdateMember("party" .. i, 1);
111 CT_PartyFrame_UpdateMember("party" .. i, nil);
112 end
113 end
114  
115 -- Color swatch functions
116 function CT_UnitFrameOptions_ColorSwatch_ShowColorPicker(frame)
117 local selectionId, boxId = this:GetParent():GetID(), this:GetParent():GetParent():GetID();
118 frame.r = CT_UnitFramesOptions.styles[boxId][selectionId][2];
119 frame.g = CT_UnitFramesOptions.styles[boxId][selectionId][3];
120 frame.b = CT_UnitFramesOptions.styles[boxId][selectionId][4];
121 frame.opacity = CT_UnitFramesOptions.styles[boxId][selectionId][5];
122 frame.boxId = boxId;
123 frame.selectionId = selectionId;
124 frame.opacityFunc = CT_UnitFrameOptions_ColorSwatch_SetOpacity;
125 frame.swatchFunc = CT_UnitFrameOptions_ColorSwatch_SetColor;
126 frame.cancelFunc = CT_UnitFrameOptions_ColorSwatch_CancelColor;
127 frame.hasOpacity = 1;
128 UIDropDownMenuButton_OpenColorPicker(frame);
129 end
130  
131 function CT_UnitFrameOptions_ColorSwatch_SetColor()
132 local r, g, b = ColorPickerFrame:GetColorRGB();
133 local boxId, selectionId = CT_UnitFramesOptionsFrame.boxId, CT_UnitFramesOptionsFrame.selectionId;
134 CT_UnitFramesOptions.styles[boxId][selectionId][2] = r;
135 CT_UnitFramesOptions.styles[boxId][selectionId][3] = g;
136 CT_UnitFramesOptions.styles[boxId][selectionId][4] = b;
137  
138 CT_UnitFramesOptions_Radio_Update();
139 end
140  
141 function CT_UnitFrameOptions_ColorSwatch_CancelColor()
142 local boxId, selectionId = CT_UnitFramesOptionsFrame.boxId, CT_UnitFramesOptionsFrame.selectionId;
143 CT_UnitFramesOptions.styles[boxId][selectionId][2] = CT_UnitFramesOptionsFrame.r;
144 CT_UnitFramesOptions.styles[boxId][selectionId][3] = CT_UnitFramesOptionsFrame.g;
145 CT_UnitFramesOptions.styles[boxId][selectionId][4] = CT_UnitFramesOptionsFrame.b;
146 CT_UnitFramesOptions.styles[boxId][selectionId][5] = CT_UnitFramesOptionsFrame.opacity;
147  
148 CT_UnitFramesOptions_Radio_Update();
149 end
150  
151 function CT_UnitFrameOptions_ColorSwatch_SetOpacity()
152 local a = OpacitySliderFrame:GetValue();
153 local boxId, selectionId = CT_UnitFramesOptionsFrame.boxId, CT_UnitFramesOptionsFrame.selectionId;
154 CT_UnitFramesOptions.styles[boxId][selectionId][5] = a;
155  
156 CT_UnitFramesOptions_Radio_Update();
157 end
158  
159 -- Checkboxes
160 function CT_UnitFramesOptions_Box_CB_OnClick()
161 if ( this:GetParent():GetID() == 3 ) then
162 CT_UnitFramesOptions.displayTargetClass = this:GetChecked();
163 else
164 CT_UnitFramesOptions.shallDisplayAssist = this:GetChecked();
165 end
166 CT_UnitFramesOptions_Radio_Update();
167 end
168  
169 -- Slash command
170 SlashCmdList["UNITFRAMESOPTIONS"] = function()
171 if ( CT_UnitFramesOptionsFrame:IsVisible() ) then
172 HideUIPanel(CT_UnitFramesOptionsFrame);
173 else
174 ShowUIPanel(CT_UnitFramesOptionsFrame);
175 end
176 end
177 SLASH_UNITFRAMESOPTIONS1 = "/unitframes";
178 SLASH_UNITFRAMESOPTIONS2 = "/uf";
179  
180 if ( CT_RegisterMod ) then
181 CT_RegisterMod(CT_UFO_MODNAME, CT_UFO_SUBNAME, 4, "Interface\\Icons\\Spell_Ice_Lament", CT_UFO_TOOLTIP, "switch", "", function() if ( CT_UnitFramesOptionsFrame:IsVisible() ) then HideUIPanel(CT_UnitFramesOptionsFrame) else ShowUIPanel(CT_UnitFramesOptionsFrame) end end);
182 else
183 DEFAULT_CHAT_FRAME:AddMessage("<CTMod> CT_UnitFrames loaded. Type |c00FFFFFF/uf|r to show the options dialog.", 1, 1, 0);
184 end