vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --============================================================================================-- |
2 | --============================================================================================-- |
||
3 | -- -- |
||
4 | -- INTERFACE FUNCTIONS -- |
||
5 | -- -- |
||
6 | --============================================================================================-- |
||
7 | --============================================================================================-- |
||
8 | |||
9 | local function TEXT(key) return Localization.GetString("Wardrobe", key) end |
||
10 | |||
11 | WARDROBE_TEXTCOLORS = { |
||
12 | {1.00, 0.00, 0.00}, -- red |
||
13 | {1.00, 0.50, 0.50}, -- light red |
||
14 | {1.00, 0.50, 0.00}, -- orange |
||
15 | {1.00, 0.75, 0.50}, -- light orange |
||
16 | {1.00, 0.75, 0.00}, -- gold |
||
17 | {1.00, 0.87, 0.50}, -- light gold |
||
18 | |||
19 | {1.00, 1.00, 0.00}, -- yellow |
||
20 | {1.00, 1.00, 0.50}, -- light yellow |
||
21 | {0.50, 1.00, 0.00}, -- yellow-green |
||
22 | {0.75, 1.00, 0.50}, -- light yellow-green |
||
23 | {0.00, 1.00, 0.00}, -- green |
||
24 | {0.50, 1.00, 0.50}, -- light green |
||
25 | |||
26 | {0.00, 1.00, 0.50}, -- blue-green |
||
27 | {0.50, 1.00, 0.75}, -- light blue-green |
||
28 | {0.00, 1.00, 1.00}, -- cyan |
||
29 | {0.50, 1.00, 1.00}, -- light cyan |
||
30 | {0.00, 0.00, 1.00}, -- blue |
||
31 | {0.50, 0.50, 1.00}, -- light blue |
||
32 | |||
33 | {0.50, 0.00, 1.00}, -- blue-purple |
||
34 | {0.75, 0.50, 1.00}, -- light blue-purple |
||
35 | {1.00, 0.00, 1.00}, -- purple |
||
36 | {1.00, 0.50, 1.00}, -- light purple |
||
37 | {1.00, 0.00, 0.50}, -- pink-red |
||
38 | {1.00, 0.50, 0.75} -- light pink-red |
||
39 | }; |
||
40 | |||
41 | WARDROBE_DRABCOLORS = { |
||
42 | {0.50, 0.00, 0.00}, -- red |
||
43 | {0.50, 0.25, 0.25}, -- light red |
||
44 | {0.50, 0.25, 0.00}, -- orange |
||
45 | {0.50, 0.38, 0.25}, -- light orange |
||
46 | {0.50, 0.38, 0.00}, -- gold |
||
47 | {0.50, 0.43, 0.25}, -- light gold |
||
48 | |||
49 | {0.50, 0.50, 0.00}, -- yellow |
||
50 | {0.50, 0.50, 0.25}, -- light yellow |
||
51 | {0.25, 0.50, 0.00}, -- yellow-green |
||
52 | {0.38, 0.50, 0.25}, -- light yellow-green |
||
53 | {0.00, 0.50, 0.00}, -- green |
||
54 | {0.25, 0.50, 0.25}, -- light green |
||
55 | |||
56 | {0.00, 0.50, 0.25}, -- blue-green |
||
57 | {0.25, 0.50, 0.38}, -- light blue-green |
||
58 | {0.00, 0.50, 0.50}, -- cyan |
||
59 | {0.25, 0.50, 0.50}, -- light cyan |
||
60 | {0.00, 0.00, 0.50}, -- blue |
||
61 | {0.25, 0.25, 0.50}, -- light blue |
||
62 | |||
63 | {0.25, 0.00, 0.50}, -- blue-purple |
||
64 | {0.38, 0.25, 0.50}, -- light blue-purple |
||
65 | {0.50, 0.00, 0.50}, -- purple |
||
66 | {0.50, 0.25, 0.50}, -- light purple |
||
67 | {0.50, 0.00, 0.25}, -- pink-red |
||
68 | {0.50, 0.25, 0.38}, -- light pink-red |
||
69 | }; |
||
70 | |||
71 | WARDROBE_UNAVAILIBLECOLOR = {0.70, 0.76, 0.65}; |
||
72 | |||
73 | --=============================================================================== |
||
74 | -- |
||
75 | -- UI Menu and Button |
||
76 | -- |
||
77 | --=============================================================================== |
||
78 | |||
79 | --------------------------------------------------------------------------------- |
||
80 | -- Start dragging the wardrobe button |
||
81 | --------------------------------------------------------------------------------- |
||
82 | function Wardrobe.OnDragStart() |
||
83 | if (not Wardrobe.DragLock) then |
||
84 | Wardrobe.IconFrame:StartMoving() |
||
85 | Wardrobe.BeingDragged = true; |
||
86 | end |
||
87 | end |
||
88 | |||
89 | |||
90 | --------------------------------------------------------------------------------- |
||
91 | -- Stop dragging the wardrobe button |
||
92 | --------------------------------------------------------------------------------- |
||
93 | function Wardrobe.OnDragStop() |
||
94 | if (Wardrobe.BeingDragged) then |
||
95 | Wardrobe.IconFrame:StopMovingOrSizing() |
||
96 | Wardrobe.BeingDragged = false; |
||
97 | local x,y = this:GetCenter(); |
||
98 | local px,py = this:GetParent():GetCenter(); |
||
99 | local ox = x-px; |
||
100 | local oy = y-py; |
||
101 | Wardrobe_Config.xOffset = ox; |
||
102 | Wardrobe_Config.yOffset = oy; |
||
103 | end |
||
104 | end |
||
105 | |||
106 | --------------------------------------------------------------------------------- |
||
107 | -- Set the DropDownMenu Scale |
||
108 | --------------------------------------------------------------------------------- |
||
109 | function Wardrobe.SetDropDownScale(scale) |
||
110 | scale = tonumber(scale); |
||
111 | if (not scale) then |
||
112 | scale = 1; |
||
113 | end |
||
114 | if (scale > 1 or scale < .5) then |
||
115 | Wardrobe.ShowHelp(); |
||
116 | return; |
||
117 | end |
||
118 | Wardrobe_Config.DropDownScale = scale; |
||
119 | DropDownList1:SetScale(scale); |
||
120 | DropDownList2:SetScale(scale); |
||
121 | DropDownList3:SetScale(scale); |
||
122 | end |
||
123 | |||
124 | --------------------------------------------------------------------------------- |
||
125 | -- Toggle whether the wardrobe button can be moved or not |
||
126 | --------------------------------------------------------------------------------- |
||
127 | function Wardrobe.ToggleLockButton(toggle) |
||
128 | Wardrobe.DragLock = toggle; |
||
129 | if (Wardrobe.DragLock) then |
||
130 | Wardrobe.Print(TEXT("TXT_BUTTONLOCKED")); |
||
131 | else |
||
132 | Wardrobe.Print(TEXT("TXT_BUTTONUNLOCKED")); |
||
133 | end |
||
134 | end |
||
135 | |||
136 | --------------------------------------------------------------------------------- |
||
137 | -- Toggle whether the wardrobe menu requires a click of the button to show |
||
138 | --------------------------------------------------------------------------------- |
||
139 | function Wardrobe.ToggleClickButton(toggle) |
||
140 | Wardrobe_Config.MustClickUIButton = toggle; |
||
141 | if (Wardrobe_Config.MustClickUIButton) then |
||
142 | Wardrobe.Print(TEXT("TXT_BUTTONONCLICK")); |
||
143 | else |
||
144 | Wardrobe.Print(TEXT("TXT_BUTTONONMOUSEOVER")); |
||
145 | end |
||
146 | end |
||
147 | |||
148 | |||
149 | --------------------------------------------------------------------------------- |
||
150 | -- Register the wardrobe button |
||
151 | --------------------------------------------------------------------------------- |
||
152 | function Wardrobe.ButtonOnLoad() |
||
153 | this:RegisterForDrag("LeftButton"); |
||
154 | if (MobileMinimapButtons_AddButton) then |
||
155 | MobileMinimapButtons_AddButton("Wardrobe_IconFrame", TEXT("TXT_WARDROBEBUTTON")); |
||
156 | end |
||
157 | end |
||
158 | |||
159 | |||
160 | --------------------------------------------------------------------------------- |
||
161 | -- Update function for showing/hiding the wardrobe button |
||
162 | --------------------------------------------------------------------------------- |
||
163 | function Wardrobe.ButtonUpdateVisibility() |
||
164 | if (TitanGetVar) then |
||
165 | if (TitanGetVar(WARDROBE_TITAN_ID, "ShowMinimapIcon")) then |
||
166 | Wardrobe_Config[WD_realmID][WD_charID].MinimapButtonVisible = 1; |
||
167 | Wardrobe.IconFrame:Show(); |
||
168 | else |
||
169 | Wardrobe_Config[WD_realmID][WD_charID].MinimapButtonVisible = 0; |
||
170 | Wardrobe.IconFrame:Hide(); |
||
171 | end |
||
172 | elseif (not Wardrobe_Config[WD_realmID][WD_charID].MinimapButtonVisible) or (Wardrobe_Config[WD_realmID][WD_charID].MinimapButtonVisible == 1) then |
||
173 | Wardrobe_Config[WD_realmID][WD_charID].MinimapButtonVisible = 1; |
||
174 | Wardrobe.IconFrame:Show(); |
||
175 | else |
||
176 | Wardrobe.IconFrame:Hide(); |
||
177 | end |
||
178 | end |
||
179 | |||
180 | |||
181 | --------------------------------------------------------------------------------- |
||
182 | -- When the user clicks on the UI button (currently disabled) |
||
183 | --------------------------------------------------------------------------------- |
||
184 | function Wardrobe.HandleUIMenuTriggerClick() |
||
185 | if (Wardrobe_Config.MustClickUIButton) then |
||
186 | Wardrobe.ShowUIMenu(); |
||
187 | end |
||
188 | end |
||
189 | |||
190 | |||
191 | --------------------------------------------------------------------------------- |
||
192 | -- When the user mouses over the UI button |
||
193 | --------------------------------------------------------------------------------- |
||
194 | function Wardrobe.HandleUIMenuTriggerEnter() |
||
195 | if (not Wardrobe_Config.MustClickUIButton) then |
||
196 | Wardrobe.ShowUIMenu(); |
||
197 | end |
||
198 | end |
||
199 | |||
200 | |||
201 | --------------------------------------------------------------------------------- |
||
202 | -- When the user mouses off the UI button |
||
203 | --------------------------------------------------------------------------------- |
||
204 | function Wardrobe.HandleUIMenuTriggerLeave() |
||
205 | GameTooltip:Hide(); |
||
206 | end |
||
207 | |||
208 | |||
209 | --------------------------------------------------------------------------------- |
||
210 | -- Show the UI menu |
||
211 | --------------------------------------------------------------------------------- |
||
212 | function Wardrobe.ShowUIMenu() |
||
213 | ToggleDropDownMenu(1, nil, WardrobeDropDown, this:GetName(), 0, 0, "TOPRIGHT"); |
||
214 | end |
||
215 | |||
216 | function Wardrobe.DropDown_OnLoad() |
||
217 | -- Fake menu frame.... who says you need a frame, bah! |
||
218 | WardrobeDropDown = { |
||
219 | initialize = Wardrobe.LoadDropDownMenu; |
||
220 | GetName = function() return "WardrobeDropDown" end; |
||
221 | SetHeight = function() end; |
||
222 | } |
||
223 | end |
||
224 | |||
225 | function Wardrobe.LoadDropDownMenu() |
||
226 | |||
227 | local outfitList = Wardrobe.GetListOfOutfits(); |
||
228 | local dropdownList = {}; |
||
229 | |||
230 | --Title |
||
231 | local info = {}; |
||
232 | info.text = UnitName("player").."'s "..TEXT("TEXT_MENU_TITLE"); |
||
233 | info.notClickable = 1; |
||
234 | info.isTitle = 1; |
||
235 | UIDropDownMenu_AddButton(info, 1); |
||
236 | |||
237 | for i, text in outfitList do |
||
238 | info = {}; |
||
239 | info.text = text; |
||
240 | info.arg1 = i; |
||
241 | info.notCheckable = true; |
||
242 | info.justifyH = "CENTER"; |
||
243 | info.func = Wardrobe.WearOutfit; |
||
244 | UIDropDownMenu_AddButton(info, 1); |
||
245 | end |
||
246 | |||
247 | info = {}; |
||
248 | info.text = TEXT("TEXT_MENU_OPEN"); |
||
249 | info.notCheckable = true; |
||
250 | info.justifyH = "CENTER"; |
||
251 | info.func = Wardrobe.ShowMainMenu; |
||
252 | UIDropDownMenu_AddButton(info, 1); |
||
253 | |||
254 | end |
||
255 | |||
256 | |||
257 | --------------------------------------------------------------------------------- |
||
258 | -- Handle keybinding clicks |
||
259 | --------------------------------------------------------------------------------- |
||
260 | function Wardrobe.Keybinding(outfitNum) |
||
261 | if (outfitNum <= table.getn(Wardrobe_Config[WD_realmID][WD_charID].Outfit)) then |
||
262 | Wardrobe.WearOutfit(Wardrobe_Config[WD_realmID][WD_charID].Outfit[outfitNum].OutfitName); |
||
263 | end |
||
264 | end |
||
265 | |||
266 | |||
267 | --=============================================================================== |
||
268 | -- |
||
269 | -- Confirmation windows |
||
270 | -- |
||
271 | --=============================================================================== |
||
272 | |||
273 | --------------------------------------------------------------------------------- |
||
274 | -- Confirm a popup menu |
||
275 | --------------------------------------------------------------------------------- |
||
276 | function Wardrobe.PopupConfirm_OnClick() |
||
277 | |||
278 | Wardrobe.NamePopup:Hide(); |
||
279 | Wardrobe.PopupConfirm:Hide(); |
||
280 | |||
281 | if (Wardrobe.PopupFunction == "[Add]") then |
||
282 | Wardrobe.NewWardrobeName = Wardrobe.NamePopupEditBox:GetText(); |
||
283 | Wardrobe.ShowWardrobe_ConfigurationScreen(); |
||
284 | elseif (Wardrobe.PopupFunction == "[Delete]" or Wardrobe.PopupFunction == "DeleteFromSort") then |
||
285 | Wardrobe.EraseOutfit(Wardrobe.NamePopupEditBox:GetText()); |
||
286 | if (Wardrobe.PopupFunction == "DeleteFromSort") then |
||
287 | Wardrobe.PopulateMainMenu(); |
||
288 | Wardrobe.ToggleMainMenuFrameVisibility(true); |
||
289 | end |
||
290 | Wardrobe.PopupFunction = ""; |
||
291 | elseif (Wardrobe.PopupFunction == "[Edit]") then |
||
292 | Wardrobe.NewWardrobeName = Wardrobe.NamePopupEditBox:GetText(); |
||
293 | Wardrobe.RenameOutfit(Wardrobe.Rename_OldName, Wardrobe.NewWardrobeName); |
||
294 | Wardrobe.StoreVirtualOutfit(WARDROBE_TEMP_OUTFIT_NAME, Wardrobe.NewWardrobeName); |
||
295 | Wardrobe.WearOutfit(Wardrobe.NewWardrobeName, true); |
||
296 | Wardrobe.PopupFunction = "[Update]"; |
||
297 | Wardrobe.ShowWardrobe_ConfigurationScreen(); |
||
298 | elseif (Wardrobe.PopupFunction == "[Update]") then |
||
299 | Wardrobe.NewWardrobeName = Wardrobe.NamePopupEditBox:GetText(); |
||
300 | Wardrobe.ShowWardrobe_ConfigurationScreen(); |
||
301 | elseif (Wardrobe.PopupFunction == "[Mounted]") then |
||
302 | if (not Wardrobe.FoundOutfitName(Wardrobe.NamePopupEditBox:GetText()) or Wardrobe.NamePopupEditBox:GetText() == "") then |
||
303 | Wardrobe.Print(TEXT("TXT_MOUNTEDNOTEXIST")); |
||
304 | UIErrorsFrame:AddMessage(TEXT("TXT_NOTEXISTERROR"), 0.0, 1.0, 0.0, 1.0, UIERRORS_HOLD_TIME); |
||
305 | Wardrobe.PopupFunction = ""; |
||
306 | else |
||
307 | Wardrobe.SetMountedOutfit(Wardrobe.NamePopupEditBox:GetText()); |
||
308 | Wardrobe.PopupFunction = ""; |
||
309 | end |
||
310 | end |
||
311 | |||
312 | end |
||
313 | |||
314 | |||
315 | --------------------------------------------------------------------------------- |
||
316 | -- Cancel a popup menu |
||
317 | --------------------------------------------------------------------------------- |
||
318 | function Wardrobe.PopupCancel_OnClick() |
||
319 | Wardrobe.NamePopup:Hide(); |
||
320 | Wardrobe.PopupConfirm:Hide(); |
||
321 | if (Wardrobe.PopupFunction == "DeleteFromSort") then |
||
322 | Wardrobe.ToggleMainMenuFrameVisibility(true); |
||
323 | end |
||
324 | end |
||
325 | |||
326 | |||
327 | |||
328 | --=============================================================================== |
||
329 | -- |
||
330 | -- Paperdoll configuration windows |
||
331 | -- |
||
332 | --=============================================================================== |
||
333 | |||
334 | --------------------------------------------------------------------------------- |
||
335 | -- Show the screen that lets the user confirm his/her wardrobe selection (check off items, etc) |
||
336 | --------------------------------------------------------------------------------- |
||
337 | function Wardrobe.ShowWardrobe_ConfigurationScreen() |
||
338 | |||
339 | Wardrobe.CheckboxToggleState = Wardrobe_Config.DefaultCheckboxState; |
||
340 | Wardrobe.CurrentOutfitButtonColor = WARDROBE_DEFAULT_BUTTON_COLOR; |
||
341 | |||
342 | for i, slotName in Wardrobe.InventorySlots do |
||
343 | getglobal("Character"..slotName.."WardrobeCheckBox"):SetCheckedTexture("Interface\\AddOns\\Wardrobe\\Images\\Check"); |
||
344 | --getglobal("Character"..Wardrobe.InventorySlots[i].."WardrobeCheckBox"):SetDisabledCheckedTexture("Interface\\AddOns\\Wardrobe\\Images\\X"); |
||
345 | end |
||
346 | |||
347 | if (Wardrobe.PopupFunction == "[Add]") then |
||
348 | if (Wardrobe_Config.DefaultCheckboxState == 1 or Wardrobe_Config.DefaultCheckboxState == 0) then |
||
349 | for i, slotName in Wardrobe.InventorySlots do |
||
350 | getglobal("Character"..slotName.."WardrobeCheckBox"):SetChecked(Wardrobe_Config.DefaultCheckboxState); |
||
351 | end |
||
352 | else |
||
353 | Wardrobe.Print(TEXT("TXT_WARDROBENAME")..tostring(Wardrobe_Config.DefaultCheckboxState)); |
||
354 | end |
||
355 | |||
356 | elseif (Wardrobe.PopupFunction == "[Update]") then |
||
357 | |||
358 | -- for each outfit |
||
359 | for i, outfit in Wardrobe_Config[WD_realmID][WD_charID].Outfit do |
||
360 | |||
361 | -- if it's the wardrobe we're updating |
||
362 | if (outfit.OutfitName == Wardrobe.NewWardrobeName) then |
||
363 | |||
364 | Wardrobe.CurrentOutfitButtonColor = outfit.ButtonColor; |
||
365 | |||
366 | -- for each item in the outfit, set the checkbox |
||
367 | for j=1, Wardrobe.InventorySlotsSize do |
||
368 | local IsSlotUsed; |
||
369 | if (not outfit.Item[j]) or (outfit.Item[j].IsSlotUsed ~= 1) then |
||
370 | IsSlotUsed = 0; |
||
371 | else |
||
372 | IsSlotUsed = 1; |
||
373 | end |
||
374 | local checkBoxName = "Character"..Wardrobe.InventorySlots[j].."WardrobeCheckBox"; |
||
375 | getglobal(checkBoxName):SetChecked(IsSlotUsed); |
||
376 | end |
||
377 | break; |
||
378 | end |
||
379 | end |
||
380 | end |
||
381 | |||
382 | -- show the character paperdoll frame |
||
383 | Wardrobe.ToggleCharacterPanel(); |
||
384 | |||
385 | end |
||
386 | |||
387 | |||
388 | --------------------------------------------------------------------------------- |
||
389 | -- Toggle the visibility of the character panel |
||
390 | --------------------------------------------------------------------------------- |
||
391 | function Wardrobe.ToggleCharacterPanel(dontToggleChar) |
||
392 | if (not Wardrobe.InToggleCharacterPanel) then |
||
393 | Wardrobe.InToggleCharacterPanel = true; |
||
394 | if (Wardrobe.ShowingCharacterPanel == false) then |
||
395 | if (not dontToggleChar and (not PaperDollFrame:IsVisible())) then |
||
396 | ToggleCharacter("PaperDollFrame"); |
||
397 | end |
||
398 | Wardrobe.CheckboxesFrame:Show(); |
||
399 | Wardrobe.Orig_HideUIPanel = HideUIPanel; |
||
400 | HideUIPanel = Wardrobe.HideUIPanel; |
||
401 | Wardrobe.RefreshCharacterPanel(); |
||
402 | Wardrobe.ColorCycle_CharacterFrame(true); |
||
403 | Wardrobe.ShowingCharacterPanel = true; |
||
404 | else |
||
405 | Wardrobe.CheckboxesFrame:Hide(); |
||
406 | CharacterNameText:SetText(UnitPVPName("player")); |
||
407 | Wardrobe.ColorCycle_CharacterFrame(false); |
||
408 | CharacterNameText:SetTextColor(1,1,1); |
||
409 | Wardrobe.ShowingCharacterPanel = false; |
||
410 | if (not dontToggleChar) then |
||
411 | ToggleCharacter("PaperDollFrame"); |
||
412 | end |
||
413 | end |
||
414 | |||
415 | Wardrobe.InToggleCharacterPanel = false; |
||
416 | end |
||
417 | end |
||
418 | |||
419 | |||
420 | --------------------------------------------------------------------------------- |
||
421 | -- Refresh the character panel |
||
422 | --------------------------------------------------------------------------------- |
||
423 | function Wardrobe.RefreshCharacterPanel() |
||
424 | CharacterNameText:SetText(Wardrobe.NewWardrobeName); |
||
425 | CharacterNameText:SetTextColor(WARDROBE_TEXTCOLORS[Wardrobe.CurrentOutfitButtonColor][1],WARDROBE_TEXTCOLORS[Wardrobe.CurrentOutfitButtonColor][2],WARDROBE_TEXTCOLORS[Wardrobe.CurrentOutfitButtonColor][3]); |
||
426 | end |
||
427 | |||
428 | |||
429 | --------------------------------------------------------------------------------- |
||
430 | -- Turn on or off color cycling on the character panel |
||
431 | --------------------------------------------------------------------------------- |
||
432 | function Wardrobe.ColorCycle_CharacterFrame(toggle) |
||
433 | if (ColorCycle_AddTableEntry) then |
||
434 | if (toggle) then |
||
435 | for i = 1, table.getn(Wardrobe.InventorySlots) do |
||
436 | ColorCycle_PulseWhite( |
||
437 | { |
||
438 | ID = "Character"..Wardrobe.InventorySlots[i].."WardrobeCheckBoxGlow"; |
||
439 | globalName = "Character"..Wardrobe.InventorySlots[i].."WardrobeCheckBoxGlow"; |
||
440 | cycleType = "Texture"; |
||
441 | color = {0.0, 0.0, 0.0}; |
||
442 | speed = 0.05; |
||
443 | pause = 0.25; |
||
444 | } |
||
445 | ); |
||
446 | end |
||
447 | else |
||
448 | for i = 1, table.getn(Wardrobe.InventorySlots) do |
||
449 | ColorCycle_PulseWhite( |
||
450 | { |
||
451 | ID = "Character"..Wardrobe.InventorySlots[i].."WardrobeCheckBoxGlow"; |
||
452 | remove = true; |
||
453 | } |
||
454 | ); |
||
455 | end |
||
456 | end |
||
457 | end |
||
458 | end |
||
459 | |||
460 | --------------------------------------------------------------------------------- |
||
461 | -- Hook the HideUIPanel function so that we can trap when the user closes the character panel |
||
462 | --------------------------------------------------------------------------------- |
||
463 | function Wardrobe.HideUIPanel(theFrame) |
||
464 | |||
465 | Wardrobe.Orig_HideUIPanel(theFrame); |
||
466 | |||
467 | if (theFrame == getglobal("CharacterFrame")) then |
||
468 | Wardrobe.CheckboxesFrame:Hide(); |
||
469 | Wardrobe.ToggleCharacterPanel(true); |
||
470 | HideUIPanel = Wardrobe.Orig_HideUIPanel; |
||
471 | if (not Wardrobe.PressedAcceptButton) then |
||
472 | UIErrorsFrame:AddMessage(TEXT("TXT_CHANGECANCELED"), 1.0, 0.0, 0.0, 1.0, UIERRORS_HOLD_TIME); |
||
473 | end |
||
474 | |||
475 | -- check to see if we should re-equip our previous outfit |
||
476 | Wardrobe.CheckForEquipVirtualOutfit(WARDROBE_TEMP_OUTFIT_NAME); |
||
477 | end |
||
478 | |||
479 | Wardrobe.PressedAcceptButton = false; |
||
480 | end |
||
481 | |||
482 | |||
483 | --------------------------------------------------------------------------------- |
||
484 | -- Handle when the user clicks the button to toggle all the checkboxes |
||
485 | --------------------------------------------------------------------------------- |
||
486 | function Wardrobe.ToggleCheckboxes() |
||
487 | if (Wardrobe.CheckboxToggleState == 1) then |
||
488 | Wardrobe.CheckboxToggleState = 0; |
||
489 | else |
||
490 | Wardrobe.CheckboxToggleState = 1; |
||
491 | end |
||
492 | for i, slotName in Wardrobe.InventorySlots do |
||
493 | getglobal("Character"..slotName.."WardrobeCheckBox"):SetChecked(Wardrobe.CheckboxToggleState); |
||
494 | end |
||
495 | end |
||
496 | |||
497 | |||
498 | --------------------------------------------------------------------------------- |
||
499 | -- When the user accepts the wardrobe confirmation screen |
||
500 | --------------------------------------------------------------------------------- |
||
501 | function Wardrobe.ConfirmWardrobeConfigurationScreen() |
||
502 | |||
503 | -- remember which items were checked and unchecked for this outfit |
||
504 | Wardrobe.ItemCheckState = { }; |
||
505 | for i, slotName in Wardrobe.InventorySlots do |
||
506 | if (getglobal("Character"..slotName.."WardrobeCheckBox"):GetChecked()) then |
||
507 | Wardrobe.ItemCheckState[i] = 1; |
||
508 | end |
||
509 | end |
||
510 | |||
511 | if (CharacterMainHandSlotWardrobeCheckBox:GetChecked() == 1) and (CharacterSecondaryHandSlotWardrobeCheckBox:GetChecked() == 1) then |
||
512 | --Check for 2h in Main slot and dissable offhand |
||
513 | end |
||
514 | |||
515 | if (Wardrobe.PopupFunction == "[Add]") then |
||
516 | Wardrobe.AddNewOutfit(Wardrobe.NewWardrobeName, Wardrobe.CurrentOutfitButtonColor); |
||
517 | Wardrobe.PopupFunction = ""; |
||
518 | elseif (Wardrobe.PopupFunction == "[Update]") then |
||
519 | Wardrobe.UpdateOutfit(Wardrobe.NewWardrobeName, Wardrobe.CurrentOutfitButtonColor); |
||
520 | Wardrobe.PopupFunction = ""; |
||
521 | |||
522 | -- check to see if we should re-equip our previous outfit |
||
523 | Wardrobe.CheckForEquipVirtualOutfit(WARDROBE_TEMP_OUTFIT_NAME); |
||
524 | end |
||
525 | |||
526 | Wardrobe.PressedAcceptButton = true; |
||
527 | Wardrobe.ToggleCharacterPanel(); |
||
528 | end |
||
529 | |||
530 | |||
531 | --------------------------------------------------------------------------------- |
||
532 | -- When the user rejects the wardrobe confirmation screen |
||
533 | --------------------------------------------------------------------------------- |
||
534 | function Wardrobe.CancelWardrobe_ConfigurationScreen() |
||
535 | -- check to see if we should re-equip our previous outfit |
||
536 | Wardrobe.CheckForEquipVirtualOutfit(WARDROBE_TEMP_OUTFIT_NAME); |
||
537 | end |
||
538 | |||
539 | |||
540 | --=============================================================================== |
||
541 | -- |
||
542 | -- Main menu |
||
543 | -- |
||
544 | --=============================================================================== |
||
545 | |||
546 | --------------------------------------------------------------------------------- |
||
547 | -- Show the main menu |
||
548 | --------------------------------------------------------------------------------- |
||
549 | function Wardrobe.ShowMainMenu() |
||
550 | |||
551 | Wardrobe.CheckForOurWardrobeID(); |
||
552 | |||
553 | -- clear any selected outfits |
||
554 | for i, outfit in Wardrobe_Config[WD_realmID][WD_charID].Outfit do |
||
555 | outfit.Selected = false; |
||
556 | end |
||
557 | |||
558 | Wardrobe.ToggleMainMenuFrameVisibility(true); |
||
559 | Wardrobe.PopulateMainMenu(); |
||
560 | end |
||
561 | |||
562 | |||
563 | --------------------------------------------------------------------------------- |
||
564 | -- Toggle the main menu visibility and color cycling |
||
565 | --------------------------------------------------------------------------------- |
||
566 | function Wardrobe.ToggleMainMenuFrameVisibility(toggle) |
||
567 | if (toggle) then |
||
568 | Wardrobe.MainMenuFrame:Show(); |
||
569 | else |
||
570 | Wardrobe.MainMenuFrame:Hide(); |
||
571 | end |
||
572 | |||
573 | -- toggle color cycling |
||
574 | Wardrobe.ColorCycle_MainMenuFrame(toggle); |
||
575 | end |
||
576 | |||
577 | |||
578 | --------------------------------------------------------------------------------- |
||
579 | -- Start or stop color cycling on the modification frame |
||
580 | --------------------------------------------------------------------------------- |
||
581 | function Wardrobe.ColorCycle_MainMenuFrame(toggle) |
||
582 | if (ColorCycle_AddTableEntry) then |
||
583 | if (toggle) then |
||
584 | ColorCycle_AddTableEntry( |
||
585 | { |
||
586 | ID = "Wardrobe_MainMenuFrameTitle"; |
||
587 | cycleType = "FontText"; |
||
588 | globalName = "Wardrobe_MainMenuFrameTitle"; |
||
589 | cycleSpeed = 0.01; |
||
590 | okToWait = {true, true, true}; |
||
591 | } |
||
592 | ); |
||
593 | else |
||
594 | |||
595 | -- turn off color cycling on the selected outfit |
||
596 | for i = 1, WARDROBE_MAX_SCROLL_ENTRIES do |
||
597 | local fs = Wardrobe["MainMenuFrameEntry"..i.."Outfit"]; |
||
598 | if (frameName ~= "Wardrobe_MainMenuFrameEntry"..i) then |
||
599 | if (Wardrobe_Config[WD_realmID][WD_charID].Outfit[fs.OutfitNum]) then |
||
600 | Wardrobe.SetSelectionColor(false, "Wardrobe_MainMenuFrameEntry"..i.."Outfit", fs) |
||
601 | end |
||
602 | end |
||
603 | end |
||
604 | ColorCycle_RemoveEntry("Wardrobe_MainMenuFrameTitle"); |
||
605 | end |
||
606 | end |
||
607 | end |
||
608 | |||
609 | |||
610 | --------------------------------------------------------------------------------- |
||
611 | -- Populate the main menu |
||
612 | --------------------------------------------------------------------------------- |
||
613 | function Wardrobe.PopulateMainMenu(maintainSelected) |
||
614 | Wardrobe.Debug("PopulateMainMenu"); |
||
615 | |||
616 | Wardrobe.CheckForOurWardrobeID(); |
||
617 | |||
618 | Wardrobe.SortOutfits(); |
||
619 | |||
620 | -- clear any selected item |
||
621 | for rowCount = 1, WARDROBE_MAX_SCROLL_ENTRIES do |
||
622 | Wardrobe.SetSelectionColor(false, "Wardrobe_MainMenuFrameEntry"..rowCount.."Outfit", Wardrobe["MainMenuFrameEntry"..rowCount.."Outfit"]); |
||
623 | end |
||
624 | |||
625 | local fs, totalExistingEntries, totalEntriesShown; |
||
626 | local rowCount = 1; |
||
627 | local entryCount = 1; |
||
628 | local offset = FauxScrollFrame_GetOffset(Wardrobe.SortScrollFrame); |
||
629 | Wardrobe.Debug("offset = "..offset); |
||
630 | |||
631 | for i = 1, 21 do |
||
632 | Wardrobe["MainMenuFrameEntry"..i.."Icon"]:Hide(); |
||
633 | end |
||
634 | |||
635 | while rowCount <= WARDROBE_MAX_SCROLL_ENTRIES do |
||
636 | |||
637 | Wardrobe.Debug("rowCount = "..rowCount); |
||
638 | Wardrobe.Debug("entryCount = "..entryCount); |
||
639 | fs = Wardrobe["MainMenuFrameEntry"..rowCount.."Outfit"]; |
||
640 | local outfit = Wardrobe_Config[WD_realmID][WD_charID].Outfit[entryCount + offset]; |
||
641 | if (not outfit) then |
||
642 | fs:SetText(""); |
||
643 | fs.r = 0; |
||
644 | fs.g = 0; |
||
645 | fs.b = 0; |
||
646 | Wardrobe["MainMenuFrameEntry"..rowCount.."Icon"]:Hide(); |
||
647 | rowCount = rowCount + 1; |
||
648 | |||
649 | -- if this isn't a virtual outfit |
||
650 | elseif (not outfit.Virtual) then |
||
651 | Wardrobe.Debug("Wasn't Virtual. Setting text to: "..outfit.OutfitName); |
||
652 | fs:SetText(outfit.OutfitName); |
||
653 | local buttonColor = outfit.ButtonColor; |
||
654 | fs.r = WARDROBE_TEXTCOLORS[buttonColor][1]; |
||
655 | fs.g = WARDROBE_TEXTCOLORS[buttonColor][2]; |
||
656 | fs.b = WARDROBE_TEXTCOLORS[buttonColor][3]; |
||
657 | if (not maintainSelected) then |
||
658 | --Wardrobe_Config[WD_realmID][WD_charID].Outfit[entryCount + offset].Selected = false; |
||
659 | end; |
||
660 | |||
661 | -- if this outfit is selected, highlight it |
||
662 | if (outfit.Selected) then |
||
663 | Wardrobe.SetSelectionColor(true, "Wardrobe_MainMenuFrameEntry"..rowCount.."Outfit", fs); |
||
664 | else |
||
665 | fs:SetTextColor(fs.r, fs.g, fs.b); |
||
666 | end |
||
667 | |||
668 | -- check to see if we should show the mounted icon |
||
669 | if (outfit.Special == "mounted") then |
||
670 | -- set the texture |
||
671 | Wardrobe["MainMenuFrameEntry"..rowCount.."Icon"]:SetNormalTexture("Interface\\AddOns\\Wardrobe\\Images\\Paw"); |
||
672 | Wardrobe["MainMenuFrameEntry"..rowCount.."Icon"]:Show(); |
||
673 | |||
674 | -- check to see if we should show the plaguelands icon |
||
675 | elseif (outfit.Special == "plague") then |
||
676 | -- set the texture |
||
677 | Wardrobe["MainMenuFrameEntry"..rowCount.."Icon"]:SetNormalTexture("Interface\\AddOns\\Wardrobe\\Images\\Sword"); |
||
678 | Wardrobe["MainMenuFrameEntry"..rowCount.."Icon"]:Show(); |
||
679 | |||
680 | -- check to see if we should show the while-eating icon |
||
681 | elseif (outfit.Special == "chowing") then |
||
682 | -- set the texture |
||
683 | Wardrobe["MainMenuFrameEntry"..rowCount.."Icon"]:SetNormalTexture("Interface\\AddOns\\Wardrobe\\Images\\Food"); |
||
684 | Wardrobe["MainMenuFrameEntry"..rowCount.."Icon"]:Show(); |
||
685 | |||
686 | else |
||
687 | Wardrobe["MainMenuFrameEntry"..rowCount.."Icon"]:Hide(); |
||
688 | end |
||
689 | rowCount = rowCount + 1; |
||
690 | else |
||
691 | Wardrobe.Debug("Was Virtual"); |
||
692 | Wardrobe["MainMenuFrameEntry"..rowCount.."Icon"]:Hide(); |
||
693 | end |
||
694 | fs.OutfitNum = entryCount + offset; |
||
695 | entryCount = entryCount + 1; |
||
696 | end |
||
697 | |||
698 | FauxScrollFrame_Update(Wardrobe.SortScrollFrame, table.getn(Wardrobe_Config[WD_realmID][WD_charID].Outfit), WARDROBE_MAX_SCROLL_ENTRIES, WARDROBE_MAX_SCROLL_ENTRIES); |
||
699 | |||
700 | return entryCount, rowCount; |
||
701 | end |
||
702 | |||
703 | |||
704 | --------------------------------------------------------------------------------- |
||
705 | -- when mousing over an entry in the outfit menu, highlight it |
||
706 | --------------------------------------------------------------------------------- |
||
707 | function Wardrobe.MainMenuFrameEntry_OnEnter() |
||
708 | local frameName, number = string.gsub(this:GetName(), "^Wardrobe_", ""); |
||
709 | Wardrobe[frameName.."Outfit"]:SetTextColor(1.0, 1.0, 1.0); |
||
710 | end |
||
711 | |||
712 | |||
713 | --------------------------------------------------------------------------------- |
||
714 | -- when the mouse leaves an entry in the outfit menu, return it to its normal color (unless it's selected) |
||
715 | --------------------------------------------------------------------------------- |
||
716 | function Wardrobe.MainMenuFrameEntry_OnLeave() |
||
717 | local frameName, number = string.gsub(this:GetName(), "^Wardrobe_", ""); |
||
718 | local fs = Wardrobe[frameName.."Outfit"]; |
||
719 | if (fs.OutfitNum) and (Wardrobe_Config[WD_realmID][WD_charID].Outfit[fs.OutfitNum]) and (not Wardrobe_Config[WD_realmID][WD_charID].Outfit[fs.OutfitNum].Selected) then |
||
720 | fs:SetTextColor(fs.r, fs.g, fs.b); |
||
721 | end |
||
722 | end |
||
723 | |||
724 | |||
725 | --------------------------------------------------------------------------------- |
||
726 | -- when clicking on an entry in the outfit menu |
||
727 | --------------------------------------------------------------------------------- |
||
728 | function Wardrobe.MainMenuFrameEntry_OnClick() |
||
729 | |||
730 | --local frameName = this:GetName(); |
||
731 | local frameName, number = string.gsub(this:GetName(), "^Wardrobe_", ""); |
||
732 | |||
733 | -- unselect all items |
||
734 | Wardrobe.UnselectAllMainMenuItems(); |
||
735 | |||
736 | -- select this item |
||
737 | local fs = Wardrobe[frameName.."Outfit"]; |
||
738 | if (fs) and (fs.OutfitNum) then |
||
739 | local outfit = Wardrobe_Config[WD_realmID][WD_charID].Outfit[fs.OutfitNum]; |
||
740 | if (outfit) then |
||
741 | if (not outfit.Selected) then |
||
742 | outfit.Selected = true; |
||
743 | Wardrobe.SetSelectionColor(true, "Wardrobe_"..frameName.."Outfit", fs); |
||
744 | else |
||
745 | outfit.Selected = false; |
||
746 | end |
||
747 | end |
||
748 | end |
||
749 | end |
||
750 | |||
751 | |||
752 | --------------------------------------------------------------------------------- |
||
753 | -- unselect all the outfits in the main menu |
||
754 | --------------------------------------------------------------------------------- |
||
755 | function Wardrobe.UnselectAllMainMenuItems() |
||
756 | |||
757 | -- unselect all the other buttons |
||
758 | for i = 1, WARDROBE_MAX_SCROLL_ENTRIES do |
||
759 | Wardrobe.SetSelectionColor(false, "Wardrobe_MainMenuFrameEntry"..i.."Outfit", Wardrobe["MainMenuFrameEntry"..i.."Outfit"]); |
||
760 | end |
||
761 | |||
762 | for i, outfit in Wardrobe_Config[WD_realmID][WD_charID].Outfit do |
||
763 | outfit.Selected = false; |
||
764 | end |
||
765 | end |
||
766 | |||
767 | |||
768 | --------------------------------------------------------------------------------- |
||
769 | -- set or unset the color of the selected outfit text in the main menu |
||
770 | --------------------------------------------------------------------------------- |
||
771 | function Wardrobe.SetSelectionColor(toggle, theGlobal, fs) |
||
772 | if (toggle) then |
||
773 | if (ColorCycle_AddTableEntry) then |
||
774 | ColorCycle_FlashWhite( |
||
775 | { |
||
776 | ID = theGlobal; |
||
777 | cycleType = "FontText"; |
||
778 | globalName = theGlobal; |
||
779 | color = {fs.r, fs.g, fs.b}; |
||
780 | } |
||
781 | ); |
||
782 | else |
||
783 | fs:SetTextColor(1, 1, 1); |
||
784 | end |
||
785 | else |
||
786 | if (ColorCycle_AddTableEntry) then |
||
787 | ColorCycle_FlashWhite( |
||
788 | { |
||
789 | ID = theGlobal; |
||
790 | remove = true; |
||
791 | } |
||
792 | ); |
||
793 | end |
||
794 | fs:SetTextColor(fs.r, fs.g, fs.b); |
||
795 | end |
||
796 | end |
||
797 | |||
798 | |||
799 | --=============================================================================== |
||
800 | -- |
||
801 | -- Main menu buttons |
||
802 | -- |
||
803 | --=============================================================================== |
||
804 | |||
805 | --------------------------------------------------------------------------------- |
||
806 | -- when clicking on the new outfit button |
||
807 | --------------------------------------------------------------------------------- |
||
808 | function Wardrobe.NewOutfitButtonClick() |
||
809 | Wardrobe.NamePopupText:SetText(TEXT("TXT_NEWOUTFITNAME")); |
||
810 | Wardrobe.PopupFunction = "[Add]"; |
||
811 | Wardrobe.UnselectAllMainMenuItems(); |
||
812 | Wardrobe.ToggleMainMenuFrameVisibility(false); |
||
813 | Wardrobe.NamePopup:Show(); |
||
814 | end |
||
815 | |||
816 | |||
817 | --------------------------------------------------------------------------------- |
||
818 | -- when clicking on the close button |
||
819 | --------------------------------------------------------------------------------- |
||
820 | function Wardrobe.MainMenuCloseButton() |
||
821 | Wardrobe.ColorCycle_MainMenuFrame(false); |
||
822 | this:GetParent():Hide(); |
||
823 | end |
||
824 | |||
825 | |||
826 | --------------------------------------------------------------------------------- |
||
827 | -- when clicking on the edit outfit button |
||
828 | --------------------------------------------------------------------------------- |
||
829 | function Wardrobe.EditOutfitButtonClick() |
||
830 | local selectedOutfit = Wardrobe.FindSelectedOutfit(); |
||
831 | |||
832 | if (selectedOutfit) then |
||
833 | Wardrobe.NewWardrobeName = Wardrobe_Config[WD_realmID][WD_charID].Outfit[selectedOutfit].OutfitName; |
||
834 | Wardrobe.Rename_OldName = Wardrobe.NewWardrobeName; |
||
835 | Wardrobe.NamePopupText:SetText("New Name"); |
||
836 | Wardrobe.NamePopupEditBox:SetText(Wardrobe.NewWardrobeName); |
||
837 | Wardrobe.PopupFunction = "[Edit]"; |
||
838 | Wardrobe.ToggleMainMenuFrameVisibility(false); |
||
839 | Wardrobe.NamePopup:Show(); |
||
840 | end |
||
841 | end |
||
842 | |||
843 | |||
844 | --------------------------------------------------------------------------------- |
||
845 | -- when clicking on the update outfit button |
||
846 | --------------------------------------------------------------------------------- |
||
847 | function Wardrobe.UpdateOutfitButtonClick() |
||
848 | local selectedOutfit = Wardrobe.FindSelectedOutfit(); |
||
849 | |||
850 | if (selectedOutfit) then |
||
851 | Wardrobe.NewWardrobeName = Wardrobe_Config[WD_realmID][WD_charID].Outfit[selectedOutfit].OutfitName; |
||
852 | Wardrobe.PopupFunction = "[Update]"; |
||
853 | Wardrobe.ShowWardrobe_ConfigurationScreen(); |
||
854 | end |
||
855 | end |
||
856 | |||
857 | |||
858 | |||
859 | --------------------------------------------------------------------------------- |
||
860 | -- When clicking the special buttons |
||
861 | --------------------------------------------------------------------------------- |
||
862 | local WARDROBE_TXT_NOLONGERWORN = { |
||
863 | mounted = function() return TEXT("TXT_NOLONGERWORNMOUNTERR") end; |
||
864 | plague = function() return TEXT("TXT_NOLONGERWORNPLAGUEERR") end; |
||
865 | chowing = function() return TEXT("TXT_NOLONGERWORNEATERR") end; |
||
866 | swimming = function() return TEXT("TXT_NOLONGERWORNSWIMR") end; |
||
867 | }; |
||
868 | |||
869 | local WARDROBE_TXT_WORNWHEN = { |
||
870 | mounted = function() return TEXT("TXT_WORNWHENMOUNTERR") end; |
||
871 | plague = function() return TEXT("TXT_WORNPLAGUEERR") end; |
||
872 | chowing = function() return TEXT("TXT_WORNEATERR") end; |
||
873 | swimming = function() return TEXT("TXT_WORNSWIMR") end; |
||
874 | }; |
||
875 | |||
876 | function Wardrobe.SpecialButtonClick(specialType) |
||
877 | local outfitNum = Wardrobe.FindSelectedOutfit(); |
||
878 | local alreadyUsingThisOutfitForSpecial = false; |
||
879 | |||
880 | if (outfitNum) then |
||
881 | local outfit = Wardrobe_Config[WD_realmID][WD_charID].Outfit[outfitNum]; |
||
882 | if (outfit.Special == specialType) then |
||
883 | UIErrorsFrame:AddMessage(outfit.OutfitName.." "..WARDROBE_TXT_NOLONGERWORN[specialType](), 0.0, 1.0, 0.0, 1.0, UIERRORS_HOLD_TIME); |
||
884 | alreadyUsingThisOutfitForSpecial = true; |
||
885 | end |
||
886 | |||
887 | -- Clear other special outfits of this type |
||
888 | for i, outfitI in Wardrobe_Config[WD_realmID][WD_charID].Outfit do |
||
889 | if (outfitI.Special == specialType) then |
||
890 | outfitI.Special = nil; |
||
891 | end |
||
892 | end |
||
893 | |||
894 | if (not alreadyUsingThisOutfitForSpecial) then |
||
895 | outfit.Special = specialType; |
||
896 | UIErrorsFrame:AddMessage(outfit.OutfitName.." "..WARDROBE_TXT_WORNWHEN[specialType](), 0.0, 1.0, 0.0, 1.0, UIERRORS_HOLD_TIME); |
||
897 | end |
||
898 | |||
899 | Wardrobe.PopulateMainMenu(true); |
||
900 | end |
||
901 | end |
||
902 | |||
903 | function Wardrobe.MountButtonClick() |
||
904 | Wardrobe.SpecialButtonClick("mounted"); |
||
905 | end |
||
906 | |||
907 | function Wardrobe.PlaguelandsButtonClick() |
||
908 | Wardrobe.SpecialButtonClick("plague"); |
||
909 | end |
||
910 | |||
911 | function Wardrobe.ChowingButtonClick() |
||
912 | Wardrobe.SpecialButtonClick("chowing"); |
||
913 | end |
||
914 | |||
915 | |||
916 | --------------------------------------------------------------------------------- |
||
917 | -- When clicking the move up or move down buttons |
||
918 | --------------------------------------------------------------------------------- |
||
919 | function Wardrobe.MoveOutfit_OnClick(direction) |
||
920 | local outfitNum = Wardrobe.FindSelectedOutfit(); |
||
921 | |||
922 | if (outfitNum) then |
||
923 | local swapNum = Wardrobe.OrderOutfit(outfitNum, direction); |
||
924 | Wardrobe.SortOutfits(); |
||
925 | Wardrobe.PopulateMainMenu(true); |
||
926 | end |
||
927 | end |
||
928 | |||
929 | |||
930 | --------------------------------------------------------------------------------- |
||
931 | -- When clicking the delete outfit button |
||
932 | --------------------------------------------------------------------------------- |
||
933 | function Wardrobe.DeleteOutfit_OnClick() |
||
934 | selectedOutfit = nil; |
||
935 | for i, outfit in Wardrobe_Config[WD_realmID][WD_charID].Outfit do |
||
936 | if (outfit.Selected) then |
||
937 | selectedOutfit = i; |
||
938 | break; |
||
939 | end |
||
940 | end |
||
941 | |||
942 | if (selectedOutfit) then |
||
943 | Wardrobe.PopupFunction = "DeleteFromSort"; |
||
944 | Wardrobe.NamePopupEditBox:SetText(Wardrobe_Config[WD_realmID][WD_charID].Outfit[selectedOutfit].OutfitName); |
||
945 | Wardrobe.PopupConfirm:Show(); |
||
946 | Wardrobe.ToggleMainMenuFrameVisibility(false); |
||
947 | Wardrobe.PopupConfirmText:SetText(TEXT("TXT_REALLYDELETEOUTFIT").."\n\n"..Wardrobe_Config[WD_realmID][WD_charID].Outfit[selectedOutfit].OutfitName); |
||
948 | else |
||
949 | UIErrorsFrame:AddMessage(TEXT("TXT_PLEASESELECTDELETE"), 1.0, 0.0, 0.0, 1.0, UIERRORS_HOLD_TIME); |
||
950 | end |
||
951 | end |
||
952 | |||
953 | |||
954 | --=============================================================================== |
||
955 | -- |
||
956 | -- Color picker |
||
957 | -- |
||
958 | --=============================================================================== |
||
959 | |||
960 | --------------------------------------------------------------------------------- |
||
961 | -- when clicking on a color in the color picker |
||
962 | --------------------------------------------------------------------------------- |
||
963 | function Wardrobe.ColorPickFrameColor_OnClick() |
||
964 | local selectedOutfit = Wardrobe.FindSelectedOutfit(); |
||
965 | local buttonName = this:GetName(); |
||
966 | local x, y = string.find(buttonName, "%d+"); |
||
967 | Wardrobe.ColorPickFrame.buttonNum = tonumber(string.sub(buttonName, x, y)); |
||
968 | Wardrobe.ColorPickFrameExampleText:SetTextColor(WARDROBE_TEXTCOLORS[Wardrobe.ColorPickFrame.buttonNum][1], |
||
969 | WARDROBE_TEXTCOLORS[Wardrobe.ColorPickFrame.buttonNum][2], |
||
970 | WARDROBE_TEXTCOLORS[Wardrobe.ColorPickFrame.buttonNum][3]); |
||
971 | |||
972 | if (Wardrobe.EnteredColorPickerFromPaperdollFrame) then |
||
973 | Wardrobe.CurrentOutfitButtonColor = Wardrobe.ColorPickFrame.buttonNum; |
||
974 | end |
||
975 | end |
||
976 | |||
977 | |||
978 | --------------------------------------------------------------------------------- |
||
979 | -- Show the color selection menu |
||
980 | --------------------------------------------------------------------------------- |
||
981 | function Wardrobe.ShowColorPickFrame() |
||
982 | |||
983 | -- figure out where we were called from |
||
984 | if (Wardrobe.MainMenuFrame:IsVisible()) then |
||
985 | Wardrobe.EnteredColorPickerFromPaperdollFrame = false; |
||
986 | else |
||
987 | Wardrobe.EnteredColorPickerFromPaperdollFrame = true; |
||
988 | end |
||
989 | |||
990 | local selectedOutfit = Wardrobe.FindSelectedOutfit(); |
||
991 | |||
992 | if (selectedOutfit or Wardrobe.EnteredColorPickerFromPaperdollFrame) then |
||
993 | |||
994 | Wardrobe.ColorPickFrame:SetAlpha(1.0); |
||
995 | Wardrobe.ColorPickFrame:Show(); |
||
996 | Wardrobe.ColorPickFrameGrid:SetFrameLevel(Wardrobe.ColorPickFrameGrid:GetFrameLevel() + 1); |
||
997 | for i = 1, 24 do |
||
998 | Wardrobe["ColorPickFrameBox"..tostring(i).."Texture"]:SetVertexColor(WARDROBE_TEXTCOLORS[i][1],WARDROBE_TEXTCOLORS[i][2],WARDROBE_TEXTCOLORS[i][3],1.0); |
||
999 | Wardrobe["ColorPickFrameBox"..tostring(i)]:SetFrameLevel(Wardrobe.ColorPickFrameGrid:GetFrameLevel() - 1); |
||
1000 | end |
||
1001 | |||
1002 | if (Wardrobe.EnteredColorPickerFromPaperdollFrame) then |
||
1003 | Wardrobe.ColorPickFrameExampleText:SetText(Wardrobe.NewWardrobeName); |
||
1004 | Wardrobe.ColorPickFrameExampleText:SetTextColor(WARDROBE_TEXTCOLORS[Wardrobe.CurrentOutfitButtonColor][1], WARDROBE_TEXTCOLORS[Wardrobe.CurrentOutfitButtonColor][2], WARDROBE_TEXTCOLORS[Wardrobe.CurrentOutfitButtonColor][3]); |
||
1005 | else |
||
1006 | Wardrobe.ColorPickFrameExampleText:SetText(Wardrobe_Config[WD_realmID][WD_charID].Outfit[selectedOutfit].OutfitName); |
||
1007 | local colorNum = Wardrobe_Config[WD_realmID][WD_charID].Outfit[selectedOutfit].ButtonColor; |
||
1008 | Wardrobe.ColorPickFrameExampleText:SetTextColor(WARDROBE_TEXTCOLORS[colorNum][1], WARDROBE_TEXTCOLORS[colorNum][2], WARDROBE_TEXTCOLORS[colorNum][3]); |
||
1009 | end |
||
1010 | |||
1011 | if (not Wardrobe.EnteredColorPickerFromPaperdollFrame) then Wardrobe.ToggleMainMenuFrameVisibility(false); end |
||
1012 | |||
1013 | end |
||
1014 | end |
||
1015 | |||
1016 | |||
1017 | --------------------------------------------------------------------------------- |
||
1018 | -- Accept the color selection menu |
||
1019 | --------------------------------------------------------------------------------- |
||
1020 | function Wardrobe.AcceptColorPickFrame() |
||
1021 | if (Wardrobe.EnteredColorPickerFromPaperdollFrame) then |
||
1022 | Wardrobe.RefreshCharacterPanel(); |
||
1023 | end |
||
1024 | if (Wardrobe.ColorPickFrame.buttonNum) then |
||
1025 | Wardrobe.SetSelectedOutfitColor(Wardrobe.ColorPickFrame.buttonNum); |
||
1026 | Wardrobe.PopulateMainMenu(); |
||
1027 | end |
||
1028 | Wardrobe.HideColorPickFrame(); |
||
1029 | end |
||
1030 | |||
1031 | |||
1032 | --------------------------------------------------------------------------------- |
||
1033 | -- set the color of the selected outfit based on which button was clicked in the color selector |
||
1034 | --------------------------------------------------------------------------------- |
||
1035 | function Wardrobe.SetSelectedOutfitColor(num) |
||
1036 | local selectedOutfit = Wardrobe.FindSelectedOutfit(); |
||
1037 | |||
1038 | if (selectedOutfit) then |
||
1039 | Wardrobe_Config[WD_realmID][WD_charID].Outfit[selectedOutfit].ButtonColor = num; |
||
1040 | Wardrobe.PopulateMainMenu(); |
||
1041 | end |
||
1042 | end |
||
1043 | |||
1044 | --------------------------------------------------------------------------------- |
||
1045 | -- Hide the color selection menu |
||
1046 | --------------------------------------------------------------------------------- |
||
1047 | function Wardrobe.HideColorPickFrame() |
||
1048 | if (not Wardrobe.EnteredColorPickerFromPaperdollFrame) then |
||
1049 | Wardrobe.ToggleMainMenuFrameVisibility(true); |
||
1050 | end |
||
1051 | Wardrobe.ColorPickFrame.buttonNum = nil; |
||
1052 | Wardrobe.ColorPickFrame:Hide(); |
||
1053 | end |
||
1054 | |||
1055 | |||
1056 | --------------------------------------------------------------------------------- |
||
1057 | -- Show the tooltip text |
||
1058 | --------------------------------------------------------------------------------- |
||
1059 | function Wardrobe.ShowButtonTooltip(theText1, theText2, theText3, theText4, theText5) |
||
1060 | |||
1061 | -- Set the anchor and text for the tooltip. |
||
1062 | GameTooltip:ClearLines(); |
||
1063 | GameTooltip:SetOwner(this, "ANCHOR_BOTTOMLEFT"); |
||
1064 | GameTooltip:SetText(theText1, 0.39, 0.77, 0.16); |
||
1065 | |||
1066 | -- add description lines to the tooltip |
||
1067 | if (theText2) then |
||
1068 | GameTooltip:AddLine(theText2, 0.82, 0.24, 0.79); |
||
1069 | end |
||
1070 | if (theText3) then |
||
1071 | GameTooltip:AddLine(theText3, 0.82, 0.24, 0.79); |
||
1072 | end |
||
1073 | if (theText4) then |
||
1074 | GameTooltip:AddLine(theText4, 0.82, 0.24, 0.79); |
||
1075 | end |
||
1076 | if (theText5) then |
||
1077 | GameTooltip:AddLine(theText5, 0.82, 0.24, 0.79); |
||
1078 | end |
||
1079 | |||
1080 | -- Adjust width and height to account for new lines and show the tooltip |
||
1081 | -- (the Show() command automatically adjusts the width/height) |
||
1082 | GameTooltip:Show(); |
||
1083 | end |