· 6 years ago · Aug 14, 2019, 12:32 PM
1----------------------------------------------------------------------
2-- Leatrix Plus 1.13.23 (14th August 2019, www.leatrix.com)
3----------------------------------------------------------------------
4
5-- 01:Functions 20:Live 50:RunOnce 70:Logout
6-- 02:Locks 30:Isolated 60:Events 80:Commands
7-- 03:Restarts 40:Player 62:Profile 90:Panel
8
9----------------------------------------------------------------------
10-- Leatrix Plus
11----------------------------------------------------------------------
12
13-- Create global table
14 _G.LeaPlusDB = _G.LeaPlusDB or {}
15
16-- Create locals
17 local LeaPlusLC, LeaPlusCB, LeaDropList, LeaConfigList = {}, {}, {}, {}
18 local ClientVersion = GetBuildInfo()
19 local GameLocale = GetLocale()
20 local void
21
22-- Version
23 LeaPlusLC["AddonVer"] = "1.13.23"
24 LeaPlusLC["RestartReq"] = nil
25
26-- If client restart is required and has not been done, show warning and quit
27 if LeaPlusLC["RestartReq"] then
28 local metaVer = GetAddOnMetadata("Leatrix_Plus", "Version")
29 if metaVer and metaVer ~= LeaPlusLC["AddonVer"] then
30 C_Timer.After(1, function()
31 print("NOTICE!|nYou must fully restart your game client before you can use this version of Leatrix Plus.")
32 end)
33 return
34 end
35 end
36
37----------------------------------------------------------------------
38-- L00: Leatrix Plus
39----------------------------------------------------------------------
40
41-- Get locale table
42 local void, Leatrix_Plus = ...
43 local L = Leatrix_Plus.L
44
45-- Initialise variables
46 LeaPlusLC["ShowErrorsFlag"] = 1
47 LeaPlusLC["NumberOfPages"] = 9
48 LeaPlusLC["RaidColors"] = RAID_CLASS_COLORS
49
50-- Create event frame
51 local LpEvt = CreateFrame("FRAME")
52 LpEvt:RegisterEvent("ADDON_LOADED")
53 LpEvt:RegisterEvent("PLAYER_LOGIN")
54
55----------------------------------------------------------------------
56-- L01: Functions
57----------------------------------------------------------------------
58
59 -- Print text
60 function LeaPlusLC:Print(text)
61 DEFAULT_CHAT_FRAME:AddMessage(L[text], 1.0, 0.85, 0.0)
62 end
63
64 -- Lock and unlock an item
65 function LeaPlusLC:LockItem(item, lock)
66 if lock then
67 item:Disable()
68 item:SetAlpha(0.3)
69 else
70 item:Enable()
71 item:SetAlpha(1.0)
72 end
73 end
74
75 -- Hide configuration panels
76 function LeaPlusLC:HideConfigPanels()
77 for k, v in pairs(LeaConfigList) do
78 v:Hide()
79 end
80 end
81
82 -- Load a string variable or set it to default if it's not set to "On" or "Off"
83 function LeaPlusLC:LoadVarChk(var, def)
84 if LeaPlusDB[var] and type(LeaPlusDB[var]) == "string" and LeaPlusDB[var] == "On" or LeaPlusDB[var] == "Off" then
85 LeaPlusLC[var] = LeaPlusDB[var]
86 else
87 LeaPlusLC[var] = def
88 LeaPlusDB[var] = def
89 end
90 end
91
92 -- Load a numeric variable and set it to default if it's not within a given range
93 function LeaPlusLC:LoadVarNum(var, def, valmin, valmax)
94 if LeaPlusDB[var] and type(LeaPlusDB[var]) == "number" and LeaPlusDB[var] >= valmin and LeaPlusDB[var] <= valmax then
95 LeaPlusLC[var] = LeaPlusDB[var]
96 else
97 LeaPlusLC[var] = def
98 LeaPlusDB[var] = def
99 end
100 end
101
102 -- Load an anchor point variable and set it to default if the anchor point is invalid
103 function LeaPlusLC:LoadVarAnc(var, def)
104 if LeaPlusDB[var] and type(LeaPlusDB[var]) == "string" and LeaPlusDB[var] == "CENTER" or LeaPlusDB[var] == "TOP" or LeaPlusDB[var] == "BOTTOM" or LeaPlusDB[var] == "LEFT" or LeaPlusDB[var] == "RIGHT" or LeaPlusDB[var] == "TOPLEFT" or LeaPlusDB[var] == "TOPRIGHT" or LeaPlusDB[var] == "BOTTOMLEFT" or LeaPlusDB[var] == "BOTTOMRIGHT" then
105 LeaPlusLC[var] = LeaPlusDB[var]
106 else
107 LeaPlusLC[var] = def
108 LeaPlusDB[var] = def
109 end
110 end
111
112 -- Show tooltips for checkboxes
113 function LeaPlusLC:TipSee()
114 GameTooltip:SetOwner(self, "ANCHOR_NONE")
115 local parent = self:GetParent()
116 local pscale = parent:GetEffectiveScale()
117 local gscale = UIParent:GetEffectiveScale()
118 local tscale = GameTooltip:GetEffectiveScale()
119 local gap = ((UIParent:GetRight() * gscale) - (parent:GetRight() * pscale))
120 if gap < (250 * tscale) then
121 GameTooltip:SetPoint("TOPRIGHT", parent, "TOPLEFT", 0, 0)
122 else
123 GameTooltip:SetPoint("TOPLEFT", parent, "TOPRIGHT", 0, 0)
124 end
125 GameTooltip:SetText(self.tiptext, nil, nil, nil, nil, true)
126 end
127
128 -- Show tooltips for configuration buttons and dropdown menus
129 function LeaPlusLC:ShowTooltip()
130 GameTooltip:SetOwner(self, "ANCHOR_NONE")
131 local parent = LeaPlusLC["PageF"]
132 local pscale = parent:GetEffectiveScale()
133 local gscale = UIParent:GetEffectiveScale()
134 local tscale = GameTooltip:GetEffectiveScale()
135 local gap = ((UIParent:GetRight() * gscale) - (LeaPlusLC["PageF"]:GetRight() * pscale))
136 if gap < (250 * tscale) then
137 GameTooltip:SetPoint("TOPRIGHT", parent, "TOPLEFT", 0, 0)
138 else
139 GameTooltip:SetPoint("TOPLEFT", parent, "TOPRIGHT", 0, 0)
140 end
141 GameTooltip:SetText(self.tiptext, nil, nil, nil, nil, true)
142 end
143
144 -- Create configuration button
145 function LeaPlusLC:CfgBtn(name, parent)
146 local CfgBtn = CreateFrame("BUTTON", nil, parent)
147 LeaPlusCB[name] = CfgBtn
148 CfgBtn:SetWidth(20)
149 CfgBtn:SetHeight(20)
150 CfgBtn:SetPoint("LEFT", parent.f, "RIGHT", 0, 0)
151
152 CfgBtn.t = CfgBtn:CreateTexture(nil, "BORDER")
153 CfgBtn.t:SetAllPoints()
154 CfgBtn.t:SetTexture("Interface\\WorldMap\\Gear_64.png")
155 CfgBtn.t:SetTexCoord(0, 0.50, 0, 0.50);
156 CfgBtn.t:SetVertexColor(1.0, 0.82, 0, 1.0)
157
158 CfgBtn:SetHighlightTexture("Interface\\WorldMap\\Gear_64.png")
159 CfgBtn:GetHighlightTexture():SetTexCoord(0, 0.50, 0, 0.50);
160
161 CfgBtn.tiptext = L["Click to configure the settings for this option."]
162 CfgBtn:SetScript("OnEnter", LeaPlusLC.ShowTooltip)
163 CfgBtn:SetScript("OnLeave", GameTooltip_Hide)
164 end
165
166 -- Capitalise first character in a string
167 function LeaPlusLC:CapFirst(str)
168 return gsub(string.lower(str), "^%l", strupper)
169 end
170
171 -- Toggle Zygor addon
172 function LeaPlusLC:ZygorToggle()
173 if select(2, GetAddOnInfo("ZygorGuidesViewer")) then
174 if not IsAddOnLoaded("ZygorGuidesViewer") then
175 if LeaPlusLC:PlayerInCombat() then
176 return
177 else
178 EnableAddOn("ZygorGuidesViewer")
179 ReloadUI();
180 end
181 else
182 DisableAddOn("ZygorGuidesViewer")
183 ReloadUI();
184 end
185 else
186 -- Zygor cannot be found
187 LeaPlusLC:Print("Zygor addon not found.");
188 end
189 return
190 end
191
192 -- Show memory usage stat
193 function LeaPlusLC:ShowMemoryUsage(frame, anchor, x, y)
194
195 -- Create frame
196 local memframe = CreateFrame("FRAME", nil, frame)
197 memframe:ClearAllPoints()
198 memframe:SetPoint(anchor, x, y)
199 memframe:SetWidth(100)
200 memframe:SetHeight(20)
201
202 -- Create labels
203 local pretext = memframe:CreateFontString(nil, 'ARTWORK', 'GameFontNormal')
204 pretext:SetPoint("TOPLEFT", 0, 0)
205 pretext:SetText(L["Memory Usage"])
206
207 local memtext = memframe:CreateFontString(nil, 'ARTWORK', 'GameFontNormal')
208 memtext:SetPoint("TOPLEFT", 0, 0 - 30)
209
210 -- Create stat
211 local memstat = memframe:CreateFontString(nil, 'ARTWORK', 'GameFontNormal')
212 memstat:SetPoint("BOTTOMLEFT", memtext, "BOTTOMRIGHT")
213 memstat:SetText("(calculating...)")
214
215 -- Create update script
216 local memtime = -1
217 memframe:SetScript("OnUpdate", function(self, elapsed)
218 if memtime > 2 or memtime == -1 then
219 UpdateAddOnMemoryUsage();
220 memtext = GetAddOnMemoryUsage("Leatrix_Plus")
221 memtext = math.floor(memtext + .5) .. " KB"
222 memstat:SetText(memtext);
223 memtime = 0;
224 end
225 memtime = memtime + elapsed;
226 end)
227
228 -- Release memory
229 LeaPlusLC.ShowMemoryUsage = nil
230
231 end
232
233 -- Check if player is in combat
234 function LeaPlusLC:PlayerInCombat()
235 if (UnitAffectingCombat("player")) then
236 LeaPlusLC:Print("You cannot do that in combat.")
237 return true
238 end
239 end
240
241 -- Hide panel and pages
242 function LeaPlusLC:HideFrames()
243
244 -- Hide option pages
245 for i = 0, LeaPlusLC["NumberOfPages"] do
246 if LeaPlusLC["Page"..i] then
247 LeaPlusLC["Page"..i]:Hide();
248 end;
249 end
250
251 -- Hide options panel
252 LeaPlusLC["PageF"]:Hide();
253
254 end
255
256 -- Find out if Leatrix Plus is showing (main panel or config panel)
257 function LeaPlusLC:IsPlusShowing()
258 if LeaPlusLC["PageF"]:IsShown() then return true end
259 for k, v in pairs(LeaConfigList) do
260 if v:IsShown() then
261 return true
262 end
263 end
264 end
265
266 -- Check if a name is in your friends list or guild
267 function LeaPlusLC:FriendCheck(name)
268
269 -- Update friends list
270 C_FriendList.ShowFriends()
271
272 -- Check character friends
273 for i = 1, C_FriendList.GetNumOnlineFriends() do
274 -- Return true if name matches with or without realm
275 local charFriendName = C_FriendList.GetFriendInfoByIndex(i).name
276 if name == charFriendName or name == strsplit("-", charFriendName, 2) then
277 return true
278 end
279 end
280
281 -- Get realm name or set to player's own realm (same realm does not return realm)
282 local void, myRealm = UnitFullName(name)
283 if not myRealm or myRealm == "" then void, myRealm = UnitFullName("player") end
284
285 -- Add realm name to character name
286 if not string.find(name, "-") then
287 name = name .. "-" .. myRealm
288 end
289
290 -- Check Battle.net friends
291 local numfriends = BNGetNumFriends()
292 for i = 1, numfriends do
293 local numtoons = BNGetNumFriendGameAccounts(i)
294 for j = 1, numtoons do
295 local void, toon, client, realm = BNGetFriendGameAccountInfo(i, j)
296 local toonname = toon .. "-" ..realm
297 if client == "WoW" and toonname == name then
298 return true
299 end
300 end
301 end
302
303 -- Check guild roster (new members may need to press J to refresh roster)
304 local gCount = GetNumGuildMembers()
305 for i = 1, gCount do
306 local gName, void, void, void, void, void, void, void, gOnline, void, void, void, void, gMobile = GetGuildRosterInfo(i)
307 if gOnline and not gMobile then
308 local gCompare = gName
309 if not string.find(gName, "-") then
310 gCompare = gName .. "-" .. myRealm
311 end
312 if gCompare == name then
313 return true
314 end
315 end
316 end
317
318 end
319
320----------------------------------------------------------------------
321-- L02: Locks
322----------------------------------------------------------------------
323
324 -- Function to set lock state for configuration buttons
325 function LeaPlusLC:LockOption(option, item, reloadreq)
326 if reloadreq then
327 -- Option change requires UI reload
328 if LeaPlusLC[option] ~= LeaPlusDB[option] or LeaPlusLC[option] == "Off" then
329 LeaPlusLC:LockItem(LeaPlusCB[item], true)
330 else
331 LeaPlusLC:LockItem(LeaPlusCB[item], false)
332 end
333 else
334 -- Option change does not require UI reload
335 if LeaPlusLC[option] == "Off" then
336 LeaPlusLC:LockItem(LeaPlusCB[item], true)
337 else
338 LeaPlusLC:LockItem(LeaPlusCB[item], false)
339 end
340 end
341 end
342
343-- Set lock state for configuration buttons
344 function LeaPlusLC:SetDim()
345 LeaPlusLC:LockOption("MailFontChange", "MailTextBtn", true) -- Resize mail text
346 LeaPlusLC:LockOption("QuestFontChange", "QuestTextBtn", true) -- Resize quest text
347 LeaPlusLC:LockOption("MinimapMod", "ModMinimapBtn", true) -- Customise minimap
348 LeaPlusLC:LockOption("TipModEnable", "MoveTooltipButton", true) -- Manage tooltip
349 LeaPlusLC:LockOption("ShowCooldowns", "CooldownsButton", true) -- Show cooldowns
350 LeaPlusLC:LockOption("FrmEnabled", "MoveFramesButton", true) -- Manage frames
351 LeaPlusLC:LockOption("ShowPlayerChain", "ModPlayerChain", true) -- Show player chain
352 LeaPlusLC:LockOption("ViewPortEnable", "ModViewportBtn", true) -- Enable viewport
353 end
354
355----------------------------------------------------------------------
356-- L03: Restarts
357----------------------------------------------------------------------
358
359 -- Set the reload button state
360 function LeaPlusLC:ReloadCheck()
361
362 -- Chat
363 if (LeaPlusLC["UseEasyChatResizing"] ~= LeaPlusDB["UseEasyChatResizing"]) -- Use easy resizing
364 or (LeaPlusLC["NoCombatLogTab"] ~= LeaPlusDB["NoCombatLogTab"]) -- Hide the combat log
365 or (LeaPlusLC["NoChatButtons"] ~= LeaPlusDB["NoChatButtons"]) -- Hide chat buttons
366 or (LeaPlusLC["UnclampChat"] ~= LeaPlusDB["UnclampChat"]) -- Unclamp chat frame
367 or (LeaPlusLC["MoveChatEditBoxToTop"] ~= LeaPlusDB["MoveChatEditBoxToTop"]) -- Move editbox to top
368 or (LeaPlusLC["NoStickyChat"] ~= LeaPlusDB["NoStickyChat"]) -- Disable sticky chat
369 or (LeaPlusLC["UseArrowKeysInChat"] ~= LeaPlusDB["UseArrowKeysInChat"]) -- Use arrow keys in chat
370 or (LeaPlusLC["NoChatFade"] ~= LeaPlusDB["NoChatFade"]) -- Disable chat fade
371 or (LeaPlusLC["RecentChatWindow"] ~= LeaPlusDB["RecentChatWindow"]) -- Recent chat window
372 or (LeaPlusLC["MaxChatHstory"] ~= LeaPlusDB["MaxChatHstory"]) -- Increase chat history
373
374 -- Text
375 or (LeaPlusLC["HideErrorMessages"] ~= LeaPlusDB["HideErrorMessages"]) -- Hide error messages
376 or (LeaPlusLC["NoHitIndicators"] ~= LeaPlusDB["NoHitIndicators"]) -- Hide portrait text
377 or (LeaPlusLC["HideZoneText"] ~= LeaPlusDB["HideZoneText"]) -- Hide zone text
378 or (LeaPlusLC["MailFontChange"] ~= LeaPlusDB["MailFontChange"]) -- Resize mail text
379 or (LeaPlusLC["QuestFontChange"] ~= LeaPlusDB["QuestFontChange"]) -- Resize quest text
380
381 -- Interface
382 or (LeaPlusLC["MinimapMod"] ~= LeaPlusDB["MinimapMod"]) -- Customise minimap
383 or (LeaPlusLC["TipModEnable"] ~= LeaPlusDB["TipModEnable"]) -- Manage tooltip
384 or (LeaPlusLC["EnhanceDressup"] ~= LeaPlusDB["EnhanceDressup"]) -- Enhance dressup
385 or (LeaPlusLC["ShowVolume"] ~= LeaPlusDB["ShowVolume"]) -- Show volume slider
386 or (LeaPlusLC["AhExtras"] ~= LeaPlusDB["AhExtras"]) -- Show auction controls
387 or (LeaPlusLC["ShowCooldowns"] ~= LeaPlusDB["ShowCooldowns"]) -- Show cooldowns
388 or (LeaPlusLC["DurabilityStatus"] ~= LeaPlusDB["DurabilityStatus"]) -- Show durability status
389 or (LeaPlusLC["ShowVanityControls"] ~= LeaPlusDB["ShowVanityControls"]) -- Show vanity controls
390 or (LeaPlusLC["ShowWowheadLinks"] ~= LeaPlusDB["ShowWowheadLinks"]) -- Show Wowhead links
391
392 -- Frames
393 or (LeaPlusLC["FrmEnabled"] ~= LeaPlusDB["FrmEnabled"]) -- Manage frames
394 or (LeaPlusLC["ClassColFrames"] ~= LeaPlusDB["ClassColFrames"]) -- Class colored frames
395 or (LeaPlusLC["ShowPlayerChain"] ~= LeaPlusDB["ShowPlayerChain"]) -- Show player chain
396 or (LeaPlusLC["ShowRaidToggle"] ~= LeaPlusDB["ShowRaidToggle"]) -- Show raid toggle button
397 or (LeaPlusLC["CombatPlates"] ~= LeaPlusDB["CombatPlates"]) -- Combat plates
398 or (LeaPlusLC["NoGryphons"] ~= LeaPlusDB["NoGryphons"]) -- Hide gryphons
399 or (LeaPlusLC["NoClassBar"] ~= LeaPlusDB["NoClassBar"]) -- Hide stance bar
400
401 -- System
402 or (LeaPlusLC["ViewPortEnable"] ~= LeaPlusDB["ViewPortEnable"]) -- Enable viewport
403 or (LeaPlusLC["NoRestedEmotes"] ~= LeaPlusDB["NoRestedEmotes"]) -- Silence rested emotes
404 or (LeaPlusLC["NoBagAutomation"] ~= LeaPlusDB["NoBagAutomation"]) -- Disable bag automation
405 or (LeaPlusLC["CharAddonList"] ~= LeaPlusDB["CharAddonList"]) -- Show character addons
406 or (LeaPlusLC["FasterLooting"] ~= LeaPlusDB["FasterLooting"]) -- Faster auto loot
407 or (LeaPlusLC["FasterMovieSkip"] ~= LeaPlusDB["FasterMovieSkip"]) -- Faster movie skip
408 or (LeaPlusLC["StandAndDismount"] ~= LeaPlusDB["StandAndDismount"]) -- Stand and dismount
409 or (LeaPlusLC["ShowVendorPrice"] ~= LeaPlusDB["ShowVendorPrice"]) -- Show vendor price
410
411 -- Settings
412 or (LeaPlusLC["EnableHotkey"] ~= LeaPlusDB["EnableHotkey"]) -- Enable hotkey
413
414 then
415 -- Enable the reload button
416 LeaPlusLC:LockItem(LeaPlusCB["ReloadUIButton"], false)
417 LeaPlusCB["ReloadUIButton"].f:Show()
418 else
419 -- Disable the reload button
420 LeaPlusLC:LockItem(LeaPlusCB["ReloadUIButton"], true)
421 LeaPlusCB["ReloadUIButton"].f:Hide()
422 end
423
424 end
425
426----------------------------------------------------------------------
427-- L20: Live
428----------------------------------------------------------------------
429
430 function LeaPlusLC:Live()
431
432 ----------------------------------------------------------------------
433 -- Invite from whispers
434 ----------------------------------------------------------------------
435
436 if LeaPlusLC["InviteFromWhisper"] == "On" then
437 LpEvt:RegisterEvent("CHAT_MSG_WHISPER");
438 LpEvt:RegisterEvent("CHAT_MSG_BN_WHISPER");
439 else
440 LpEvt:UnregisterEvent("CHAT_MSG_WHISPER");
441 LpEvt:UnregisterEvent("CHAT_MSG_BN_WHISPER");
442 end
443
444 ----------------------------------------------------------------------
445 -- Block duels
446 ----------------------------------------------------------------------
447
448 if LeaPlusLC["NoDuelRequests"] == "On" then
449 LpEvt:RegisterEvent("DUEL_REQUESTED");
450 else
451 LpEvt:UnregisterEvent("DUEL_REQUESTED");
452 end
453
454 ----------------------------------------------------------------------
455 -- Block party invites and Party from friends
456 ----------------------------------------------------------------------
457
458 if LeaPlusLC["NoPartyInvites"] == "On" or LeaPlusLC["AcceptPartyFriends"] == "On" then
459 LpEvt:RegisterEvent("PARTY_INVITE_REQUEST");
460 else
461 LpEvt:UnregisterEvent("PARTY_INVITE_REQUEST");
462 end
463
464 ----------------------------------------------------------------------
465 -- Release in PvP
466 ----------------------------------------------------------------------
467
468 if LeaPlusLC["AutoReleasePvP"] == "On" then
469 LpEvt:RegisterEvent("PLAYER_DEAD");
470 else
471 LpEvt:UnregisterEvent("PLAYER_DEAD");
472 end
473
474 ----------------------------------------------------------------------
475 -- Accept resurrection
476 ----------------------------------------------------------------------
477
478 if LeaPlusLC["AutoAcceptRes"] == "On" then
479 LpEvt:RegisterEvent("RESURRECT_REQUEST");
480 else
481 LpEvt:UnregisterEvent("RESURRECT_REQUEST");
482 end
483
484 ----------------------------------------------------------------------
485 -- Automatic summon
486 ----------------------------------------------------------------------
487
488 if LeaPlusLC["AutoAcceptSummon"] == "On" then
489 LpEvt:RegisterEvent("CONFIRM_SUMMON");
490 else
491 LpEvt:UnregisterEvent("CONFIRM_SUMMON");
492 end
493
494 ----------------------------------------------------------------------
495 -- Disable loot warnings
496 ----------------------------------------------------------------------
497
498 if LeaPlusLC["NoConfirmLoot"] == "On" then
499 LpEvt:RegisterEvent("CONFIRM_LOOT_ROLL")
500 LpEvt:RegisterEvent("LOOT_BIND_CONFIRM")
501 LpEvt:RegisterEvent("MERCHANT_CONFIRM_TRADE_TIMER_REMOVAL")
502 LpEvt:RegisterEvent("MAIL_LOCK_SEND_ITEMS")
503 else
504 LpEvt:UnregisterEvent("CONFIRM_LOOT_ROLL")
505 LpEvt:UnregisterEvent("LOOT_BIND_CONFIRM")
506 LpEvt:UnregisterEvent("MERCHANT_CONFIRM_TRADE_TIMER_REMOVAL")
507 LpEvt:UnregisterEvent("MAIL_LOCK_SEND_ITEMS")
508 end
509
510 end
511
512----------------------------------------------------------------------
513-- L30: Isolated
514----------------------------------------------------------------------
515
516 function LeaPlusLC:Isolated()
517
518 ----------------------------------------------------------------------
519 -- Faster movie skip
520 ----------------------------------------------------------------------
521
522 if LeaPlusLC["FasterMovieSkip"] == "On" then
523
524 -- Allow space bar, escape key and enter key to cancel cinematic without confirmation
525 CinematicFrame:HookScript("OnKeyDown", function(self, key)
526 if key == "ESCAPE" then
527 if CinematicFrame:IsShown() and CinematicFrame.closeDialog and CinematicFrameCloseDialogConfirmButton then
528 CinematicFrameCloseDialog:Hide()
529 end
530 end
531 end)
532 CinematicFrame:HookScript("OnKeyUp", function(self, key)
533 if key == "SPACE" or key == "ESCAPE" or key == "ENTER" then
534 if CinematicFrame:IsShown() and CinematicFrame.closeDialog and CinematicFrameCloseDialogConfirmButton then
535 CinematicFrameCloseDialogConfirmButton:Click()
536 end
537 end
538 end)
539 MovieFrame:HookScript("OnKeyUp", function(self, key)
540 if key == "SPACE" or key == "ESCAPE" or key == "ENTER" then
541 if MovieFrame:IsShown() and MovieFrame.CloseDialog and MovieFrame.CloseDialog.ConfirmButton then
542 MovieFrame.CloseDialog.ConfirmButton:Click()
543 end
544 end
545 end)
546
547 end
548
549 ----------------------------------------------------------------------
550 -- Unclamp chat frame
551 ----------------------------------------------------------------------
552
553 if LeaPlusLC["UnclampChat"] == "On" then
554
555 -- Process normal and existing chat frames on startup
556 for i = 1, 50 do
557 if _G["ChatFrame" .. i] then
558 _G["ChatFrame" .. i]:SetClampRectInsets(0, 0, 0, 0);
559 end
560 end
561
562 -- Process new chat frames and combat log
563 hooksecurefunc("FloatingChatFrame_UpdateBackgroundAnchors", function(self)
564 self:SetClampRectInsets(0, 0, 0, 0);
565 end)
566
567 -- Process temporary chat frames
568 hooksecurefunc("FCF_OpenTemporaryWindow", function()
569 local cf = FCF_GetCurrentChatFrame():GetName() or nil
570 if cf then
571 _G[cf]:SetClampRectInsets(0, 0, 0, 0);
572 end
573 end)
574
575 end
576
577 ----------------------------------------------------------------------
578 -- Wowhead Links
579 ----------------------------------------------------------------------
580
581 if LeaPlusLC["ShowWowheadLinks"] == "On" then
582
583 -- Get localised Wowhead URL
584 local wowheadLoc
585 if GameLocale == "deDE" then wowheadLoc = "de.classic.wowhead.com"
586 elseif GameLocale == "esMX" then wowheadLoc = "es.classic.wowhead.com"
587 elseif GameLocale == "esES" then wowheadLoc = "es.classic.wowhead.com"
588 elseif GameLocale == "frFR" then wowheadLoc = "fr.classic.wowhead.com"
589 elseif GameLocale == "itIT" then wowheadLoc = "it.classic.wowhead.com"
590 elseif GameLocale == "ptBR" then wowheadLoc = "pt.classic.wowhead.com"
591 elseif GameLocale == "ruRU" then wowheadLoc = "ru.classic.wowhead.com"
592 elseif GameLocale == "koKR" then wowheadLoc = "ko.classic.wowhead.com"
593 elseif GameLocale == "zhCN" then wowheadLoc = "cn.classic.wowhead.com"
594 elseif GameLocale == "zhTW" then wowheadLoc = "cn.classic.wowhead.com"
595 else wowheadLoc = "classic.wowhead.com"
596 end
597
598 -- Create editbox
599 local mEB = CreateFrame("EditBox", nil, QuestLogFrame)
600 mEB:ClearAllPoints()
601 mEB:SetPoint("TOPLEFT", 70, 4)
602 mEB:SetHeight(16)
603 mEB:SetFontObject("GameFontNormal")
604 mEB:SetBlinkSpeed(0)
605 mEB:SetAutoFocus(false)
606 mEB:EnableKeyboard(false)
607 mEB:SetHitRectInsets(0, 90, 0, 0)
608 mEB:SetScript("OnKeyDown", function() end)
609 mEB:SetScript("OnMouseUp", function()
610 if mEB:IsMouseOver() then
611 mEB:HighlightText()
612 else
613 mEB:HighlightText(0, 0)
614 end
615 end)
616
617 -- Set the background color
618 mEB.t = mEB:CreateTexture(nil, "BACKGROUND")
619 mEB.t:SetPoint(mEB:GetPoint())
620 mEB.t:SetSize(mEB:GetSize())
621 mEB.t:SetColorTexture(0.05, 0.05, 0.05, 1.0)
622
623 -- Create hidden font string (used for setting width of editbox)
624 mEB.z = mEB:CreateFontString(nil, 'ARTWORK', 'GameFontNormal')
625 mEB.z:Hide()
626
627 -- Function to set editbox value
628 local function SetQuestInBox(questListID)
629
630 local questTitle, void, void, isHeader, void, void, void, questID = GetQuestLogTitle(questListID)
631 if questID and not isHeader then
632
633 -- Hide editbox if quest ID is invalid
634 if questID == 0 then mEB:Hide() else mEB:Show() end
635
636 -- Set editbox text
637 mEB:SetText("https://" .. wowheadLoc .. "/quest=" .. questID)
638
639 -- Set hidden fontstring then resize editbox to match
640 mEB.z:SetText(mEB:GetText())
641 mEB:SetWidth(mEB.z:GetStringWidth() + 90)
642 mEB.t:SetWidth(mEB.z:GetStringWidth())
643
644 -- Get quest title for tooltip
645 if questTitle then
646 mEB.tiptext = questTitle .. "|n" .. L["Press CTRL/C to copy."]
647 else
648 mEB.tiptext = ""
649 if mEB:IsMouseOver() and GameTooltip:IsShown() then GameTooltip:Hide() end
650 end
651
652 end
653 end
654
655 -- Set URL when quest is selected
656 hooksecurefunc("QuestLog_SetSelection", function(questListID)
657 SetQuestInBox(questListID)
658 end)
659
660 -- Create tooltip
661 mEB:HookScript("OnEnter", function()
662 mEB:HighlightText()
663 mEB:SetFocus()
664 GameTooltip:SetOwner(mEB, "ANCHOR_BOTTOM", 0, -10)
665 GameTooltip:SetText(mEB.tiptext, nil, nil, nil, nil, true)
666 GameTooltip:Show()
667 end)
668
669 mEB:HookScript("OnLeave", function()
670 mEB:HighlightText(0, 0)
671 mEB:ClearFocus()
672 GameTooltip:Hide()
673 end)
674
675 end
676
677 ----------------------------------------------------------------------
678 -- Enhance dressup
679 ----------------------------------------------------------------------
680
681 if LeaPlusLC["EnhanceDressup"] == "On" then
682
683 ----------------------------------------------------------------------
684 -- Nude and tabard buttons
685 ----------------------------------------------------------------------
686
687 -- Add buttons to main dressup frames
688 LeaPlusLC:CreateButton("DressUpNudeBtn", DressUpFrame, "Nude", "BOTTOMLEFT", 106, 79, 80, 22, false, "")
689 LeaPlusCB["DressUpNudeBtn"]:SetFrameLevel(3)
690 LeaPlusCB["DressUpNudeBtn"]:ClearAllPoints()
691 LeaPlusCB["DressUpNudeBtn"]:SetPoint("RIGHT", DressUpFrameResetButton, "LEFT", 0, 0)
692 LeaPlusCB["DressUpNudeBtn"]:SetScript("OnClick", function()
693 DressUpFrameResetButton:Click() -- Done first in case any slots refuse to clear
694 DressUpFrame.DressUpModel:Undress()
695 end)
696
697 LeaPlusLC:CreateButton("DressUpTabBtn", DressUpFrame, "Tabard", "BOTTOMLEFT", 26, 79, 80, 22, false, "")
698 LeaPlusCB["DressUpTabBtn"]:SetFrameLevel(3)
699 LeaPlusCB["DressUpTabBtn"]:ClearAllPoints()
700 LeaPlusCB["DressUpTabBtn"]:SetPoint("RIGHT", LeaPlusCB["DressUpNudeBtn"], "LEFT", 0, 0)
701 LeaPlusCB["DressUpTabBtn"]:SetScript("OnClick", function()
702 DressUpFrame.DressUpModel:UndressSlot(19)
703 end)
704
705 -- Only show dressup buttons if its a player (reset button will show too)
706 hooksecurefunc(DressUpFrameResetButton, "Show", function()
707 LeaPlusCB["DressUpNudeBtn"]:Show()
708 LeaPlusCB["DressUpTabBtn"]:Show()
709 end)
710
711 hooksecurefunc(DressUpFrameResetButton, "Hide", function()
712 LeaPlusCB["DressUpNudeBtn"]:Hide()
713 LeaPlusCB["DressUpTabBtn"]:Hide()
714 end)
715
716 local BtnStrata, BtnLevel = SideDressUpModelResetButton:GetFrameStrata(), SideDressUpModelResetButton:GetFrameLevel()
717
718 -- Add buttons to auction house dressup frame
719 LeaPlusLC:CreateButton("DressUpSideBtn", SideDressUpFrame, "Tabard", "BOTTOMLEFT", 14, 20, 60, 22, false, "")
720 LeaPlusCB["DressUpSideBtn"]:SetFrameStrata(BtnStrata);
721 LeaPlusCB["DressUpSideBtn"]:SetFrameLevel(BtnLevel);
722 LeaPlusCB["DressUpSideBtn"]:SetScript("OnClick", function()
723 SideDressUpModel:UndressSlot(19)
724 end)
725
726 LeaPlusLC:CreateButton("DressUpSideNudeBtn", SideDressUpFrame, "Nude", "BOTTOMRIGHT", -18, 20, 60, 22, false, "")
727 LeaPlusCB["DressUpSideNudeBtn"]:SetFrameStrata(BtnStrata);
728 LeaPlusCB["DressUpSideNudeBtn"]:SetFrameLevel(BtnLevel);
729 LeaPlusCB["DressUpSideNudeBtn"]:SetScript("OnClick", function()
730 SideDressUpModelResetButton:Click() -- Done first in case any slots refuse to clear
731 for i = 1, 19 do
732 SideDressUpModel:UndressSlot(i) -- Done this way to prevent issues with Undress
733 end
734 end)
735
736 -- Only show side dressup buttons if its a player (reset button will show too)
737 hooksecurefunc(SideDressUpModelResetButton, "Show", function()
738 LeaPlusCB["DressUpSideBtn"]:Show()
739 LeaPlusCB["DressUpSideNudeBtn"]:Show()
740 end)
741
742 hooksecurefunc(SideDressUpModelResetButton, "Hide", function()
743 LeaPlusCB["DressUpSideBtn"]:Hide()
744 LeaPlusCB["DressUpSideNudeBtn"]:Hide()
745 end)
746
747 ----------------------------------------------------------------------
748 -- Controls
749 ----------------------------------------------------------------------
750
751 -- Hide model rotation controls
752 CharacterModelFrameRotateLeftButton:HookScript("OnShow", CharacterModelFrameRotateLeftButton.Hide)
753 CharacterModelFrameRotateRightButton:HookScript("OnShow", CharacterModelFrameRotateRightButton.Hide)
754 DressUpModelFrameRotateLeftButton:HookScript("OnShow", DressUpModelFrameRotateLeftButton.Hide)
755 DressUpModelFrameRotateRightButton:HookScript("OnShow", DressUpModelFrameRotateRightButton.Hide)
756 SideDressUpModelControlFrame:HookScript("OnShow", SideDressUpModelControlFrame.Hide)
757
758 ----------------------------------------------------------------------
759 -- Inspect system
760 ----------------------------------------------------------------------
761
762 -- Inspect System
763 local function DoInspectSystemFunc()
764 -- Hide model rotation controls
765 InspectModelFrameRotateLeftButton:Hide()
766 InspectModelFrameRotateRightButton:Hide()
767 end
768
769 if IsAddOnLoaded("Blizzard_InspectUI") then
770 DoInspectSystemFunc()
771 else
772 local waitFrame = CreateFrame("FRAME")
773 waitFrame:RegisterEvent("ADDON_LOADED")
774 waitFrame:SetScript("OnEvent", function(self, event, arg1)
775 if arg1 == "Blizzard_InspectUI" then
776 DoInspectSystemFunc()
777 waitFrame:UnregisterAllEvents()
778 end
779 end)
780 end
781
782 end
783
784 ----------------------------------------------------------------------
785 -- Automate gossip (no reload required)
786 ----------------------------------------------------------------------
787
788 do
789
790 -- Function to skip gossip
791 local function SkipGossip()
792 if IsShiftKeyDown() then return end
793 local void, gossipType = GetGossipOptions()
794 if gossipType then
795 -- Completely automate gossip
796 if gossipType == "banker"
797 or gossipType == "taxi"
798 or gossipType == "trainer"
799 or gossipType == "vendor"
800 then
801 SelectGossipOption(1)
802 if gossipType == "taxi" and LeaPlusLC["StandAndDismount"] == "On" and IsMounted() then
803 Dismount()
804 end
805 end
806 -- Automate gossip with ALT key
807 if IsAltKeyDown() then
808 if gossipType == "gossip"
809 then
810 SelectGossipOption(1)
811 end
812 end
813 end
814 end
815
816 -- Create gossip event frame
817 local gossipFrame = CreateFrame("FRAME")
818
819 -- Function to setup events
820 local function SetupEvents()
821 if LeaPlusLC["AutomateGossip"] == "On" then
822 gossipFrame:RegisterEvent("GOSSIP_SHOW")
823 else
824 gossipFrame:UnregisterEvent("GOSSIP_SHOW")
825 end
826 end
827
828 -- Setup events when option is clicked and on startup (if option is enabled)
829 LeaPlusCB["AutomateGossip"]:HookScript("OnClick", SetupEvents)
830 if LeaPlusLC["AutomateGossip"] == "On" then SetupEvents() end
831
832 -- Event handler
833 gossipFrame:SetScript("OnEvent", function()
834 -- Special treatment for specific NPCs
835 local npcGuid = UnitGUID("target") or nil
836 if npcGuid then
837 local void, void, void, void, void, npcID = strsplit("-", npcGuid)
838 if npcID then
839 if npcID == "9999999999" -- Reserved for future use
840 then
841 SkipGossip()
842 return
843 end
844 end
845 end
846
847 -- Process gossip
848 if GetNumGossipOptions() == 1 and GetNumGossipAvailableQuests() == 0 and GetNumGossipActiveQuests() == 0 then
849 SkipGossip()
850 end
851 end)
852
853 end
854
855 ----------------------------------------------------------------------
856 -- Enable hotkey
857 ----------------------------------------------------------------------
858
859 if LeaPlusLC["EnableHotkey"] == "On" then
860
861 -- Create global binding function
862 local BindBtn = CreateFrame("Button", "LeaPlusGlobalBinding", LeaPlusGlobalPanel)
863 BindBtn:SetScript("OnClick", function() LeaPlusLC:SlashFunc() end)
864
865 -- Clear all bindings bound to panel and set hotkey
866 ClearOverrideBindings(LeaPlusGlobalPanel)
867 SetOverrideBindingClick(LeaPlusGlobalPanel, true, "CTRL-Z", "LeaPlusGlobalBinding")
868
869 end
870
871 ----------------------------------------------------------------------
872 -- Faster looting
873 ----------------------------------------------------------------------
874
875 if LeaPlusLC["FasterLooting"] == "On" then
876
877 -- Time delay
878 local tDelay = 0
879
880 -- Fast loot function
881 local function FastLoot()
882 if GetTime() - tDelay >= 0.3 then
883 tDelay = GetTime()
884 if GetCVarBool("autoLootDefault") ~= IsModifiedClick("AUTOLOOTTOGGLE") then
885 for i = GetNumLootItems(), 1, -1 do
886 LootSlot(i)
887 end
888 tDelay = GetTime()
889 end
890 end
891 end
892
893 -- Event frame
894 local faster = CreateFrame("Frame")
895 faster:RegisterEvent("LOOT_READY")
896 faster:SetScript("OnEvent", FastLoot)
897
898 end
899
900 ----------------------------------------------------------------------
901 -- Disable bag automation
902 ----------------------------------------------------------------------
903
904 if LeaPlusLC["NoBagAutomation"] == "On" then
905 RunScript("hooksecurefunc('OpenAllBags', CloseAllBags)")
906 end
907
908 ----------------------------------------------------------------------
909 -- Automate quests (no reload required)
910 ----------------------------------------------------------------------
911
912 do
913
914 -- Funcion to ignore specific NPCs
915 local function isNpcBlocked(actionType)
916 local npcGuid = UnitGUID("target") or nil
917 if npcGuid then
918 local void, void, void, void, void, npcID = strsplit("-", npcGuid)
919 if npcID then
920 -- Ignore specific NPCs for selecting, accepting and turning-in quests (required if automation has consequences)
921 if npcID == "15192" -- Anachronos (Caverns of Time)
922 or npcID == "3430" -- Mangletooth (Blood Shard quests, Barrens)
923 then
924 return true
925 end
926 -- Ignore specific NPCs for selecting quests only (only used for items that have no other purpose)
927 if actionType == "Select" then
928 if npcID == "12944" -- Lokhtos Darkbargainer (Thorium Brotherhood, Blackrock Depths)
929 -- Ahn'Qiraj War Effort (Alliance, Ironforge)
930 or npcID == "15446" -- Bonnie Stoneflayer (Light Leather Collector)
931 or npcID == "15458" -- Commander Stronghammer (Alliance Ambassador)
932 or npcID == "15431" -- Corporal Carnes (Iron Bar Collector)
933 or npcID == "15432" -- Dame Twinbraid (Thorium Bar Collector)
934 or npcID == "15453" -- Keeper Moonshade (Runecloth Bandage Collector)
935 or npcID == "15457" -- Huntress Swiftriver (Spotted Yellowtail Collector)
936 or npcID == "15450" -- Marta Finespindle (Thick Leather Collector)
937 or npcID == "15437" -- Master Nightsong (Purple Lotus Collector)
938 or npcID == "15452" -- Nurse Stonefield (Silk Bandage Collector)
939 or npcID == "15434" -- Private Draxlegauge (Stranglekelp Collector)
940 or npcID == "15448" -- Private Porter (Medium Leather Collector)
941 or npcID == "15456" -- Sarah Sadwhistle (Roast Raptor Collector)
942 or npcID == "15451" -- Sentinel Silversky (Linen Bandage Collector)
943 or npcID == "15445" -- Sergeant Major Germaine (Arthas' Tears Collector)
944 or npcID == "15383" -- Sergeant Stonebrow (Copper Bar Collector)
945 or npcID == "15455" -- Slicky Gastronome (Rainbow Fin Albacore Collector)
946 -- Ahn'Qiraj War Effort (Horde, Orgrimmar)
947 or npcID == "15512" -- Apothecary Jezel (Purple Lotus Collector)
948 or npcID == "15508" -- Batrider Pele'keiki (Firebloom Collector)
949 or npcID == "15533" -- Bloodguard Rawtar (Lean Wolf Steak Collector)
950 or npcID == "15535" -- Chief Sharpclaw (Baked Salmon Collector)
951 or npcID == "15525" -- Doctor Serratus (Rugged Leather Collector)
952 or npcID == "15534" -- Fisherman Lin'do (Spotted Yellowtail Collector)
953 or npcID == "15539" -- General Zog (Horde Ambassador)
954 or npcID == "15460" -- Grunt Maug (Tin Bar Collector)
955 or npcID == "15528" -- Healer Longrunner (Wool Bandage Collector)
956 or npcID == "15477" -- Herbalist Proudfeather (Peacebloom Collector)
957 or npcID == "15529" -- Lady Callow (Mageweave Bandage Collector)
958 or npcID == "15459" -- Miner Cromwell (Copper Bar Collector)
959 or npcID == "15469" -- Senior Sergeant T'kelah (Mithril Bar Collector)
960 or npcID == "15522" -- Sergeant Umala (Thick Leather Collector)
961 or npcID == "15515" -- Skinner Jamani (Heavy Leather Collector)
962 or npcID == "15532" -- Stoneguard Clayhoof (Runecloth Bandage Collector)
963 -- Alliance Cloth Quartermasters
964 or npcID == "14724" -- Bubulo Acerbus (Ironforge)
965 or npcID == "14722" -- Clavicus Knavingham (Stormwind)
966 or npcID == "14723" -- Mistina Steelshield (Ironforge)
967 or npcID == "14725" -- Raedon Duskstriker (Darnassus)
968 -- Horde Cloth Quartermasters
969 or npcID == "14729" -- Ralston Farnsley (Undercity)
970 or npcID == "14728" -- Rumstag Proudstrider (Thunder Bluff)
971 or npcID == "14726" -- Rashona Straglash (Orgrimmar)
972 or npcID == "14727" -- Vehena (Orgrimmar)
973 -- Alliance Commendations
974 or npcID == "15764" -- Officer Ironbeard (Ironforge Commendations)
975 or npcID == "15762" -- Officer Lunalight (Darnassus Commendations)
976 or npcID == "15766" -- Officer Maloof (Stormwind Commendations)
977 or npcID == "15763" -- Officer Porterhouse (Gnomeregan Commendations)
978 -- Horde Commendations
979 or npcID == "15768" -- Officer Gothena (Undercity Commendations)
980 or npcID == "15765" -- Officer Redblade (Orgrimmar Commendations)
981 or npcID == "15767" -- Officer Thunderstrider (Thunder Bluff Commendations)
982 or npcID == "15761" -- Officer Vu'Shalay (Darkspear Commendations)
983 then
984 return true
985 end
986 end
987 end
988 end
989 end
990
991 -- Function to check if quest requires a blocked item
992 local function QuestRequiresBlockedItem()
993 for i = 1, 6 do
994 local progItem = _G["QuestProgressItem" ..i] or nil
995 if progItem and progItem:IsShown() and progItem.type == "required" then
996 if progItem.objectType == "item" then
997 local name, texture, numItems = GetQuestItemInfo("required", i)
998 if name then
999 local itemID = GetItemInfoInstant(name)
1000 if itemID then
1001 if itemID == 9999999999 then -- Reserved for future use
1002 return true
1003 end
1004 end
1005 end
1006 end
1007 end
1008 end
1009 end
1010
1011 -- Function to check if quest requires gold
1012 local function QuestRequiresGold()
1013 local goldRequiredAmount = GetQuestMoneyToGet()
1014 if goldRequiredAmount and goldRequiredAmount > 0 then
1015 return true
1016 end
1017 end
1018
1019 -- Create event frame
1020 local qFrame = CreateFrame("FRAME")
1021
1022 -- Function to setup events
1023 local function SetupEvents()
1024 if LeaPlusLC["AutomateQuests"] == "On" then
1025 qFrame:RegisterEvent("QUEST_DETAIL")
1026 qFrame:RegisterEvent("QUEST_ACCEPT_CONFIRM")
1027 qFrame:RegisterEvent("QUEST_PROGRESS")
1028 qFrame:RegisterEvent("QUEST_COMPLETE")
1029 qFrame:RegisterEvent("QUEST_GREETING")
1030 qFrame:RegisterEvent("QUEST_AUTOCOMPLETE")
1031 qFrame:RegisterEvent("GOSSIP_SHOW")
1032 qFrame:RegisterEvent("QUEST_FINISHED")
1033 else
1034 qFrame:UnregisterAllEvents()
1035 end
1036 end
1037
1038 -- Setup events when option is clicked and on startup (if option is enabled)
1039 LeaPlusCB["AutomateQuests"]:HookScript("OnClick", SetupEvents)
1040 if LeaPlusLC["AutomateQuests"] == "On" then SetupEvents() end
1041
1042 -- Event handler
1043 qFrame:SetScript("OnEvent", function(self, event, arg1)
1044
1045 -- Clear progress items when quest interaction has ceased
1046 if event == "QUEST_FINISHED" then
1047 for i = 1, 6 do
1048 local progItem = _G["QuestProgressItem" ..i] or nil
1049 if progItem and progItem:IsShown() then
1050 progItem:Hide()
1051 end
1052 end
1053 return
1054 end
1055
1056 -- Do nothing if SHIFT key is being held
1057 if IsShiftKeyDown() then return end
1058
1059 ----------------------------------------------------------------------
1060 -- Accept quests automatically
1061 ----------------------------------------------------------------------
1062
1063 -- Accept quests with a quest detail window
1064 if event == "QUEST_DETAIL" then
1065 -- Don't accept blocked quests
1066 if isNpcBlocked("Accept") then return end
1067 -- Accept quest
1068 AcceptQuest()
1069 HideUIPanel(QuestFrame)
1070 end
1071
1072 -- Accept quests which require confirmation (such as sharing escort quests)
1073 if event == "QUEST_ACCEPT_CONFIRM" then
1074 ConfirmAcceptQuest()
1075 StaticPopup_Hide("QUEST_ACCEPT")
1076 end
1077
1078 ----------------------------------------------------------------------
1079 -- Turn-in quests automatically
1080 ----------------------------------------------------------------------
1081
1082 -- Turn-in progression quests
1083 if event == "QUEST_PROGRESS" and IsQuestCompletable() then
1084 -- Don't continue quests for blocked NPCs
1085 if isNpcBlocked("Complete") then return end
1086 -- Don't continue if quest requires blocked item
1087 if QuestRequiresBlockedItem() then return end
1088 -- Don't continue if quest requires gold
1089 if QuestRequiresGold() then return end
1090 -- Continue quest
1091 CompleteQuest()
1092 end
1093
1094 -- Turn in completed quests if only one reward item is being offered
1095 if event == "QUEST_COMPLETE" then
1096 -- Don't complete quests for blocked NPCs
1097 if isNpcBlocked("Complete") then return end
1098 -- Don't complete if quest requires blocked item
1099 if QuestRequiresBlockedItem() then return end
1100 -- Don't complete if quest requires gold
1101 if QuestRequiresGold() then return end
1102 -- Complete quest
1103 if GetNumQuestChoices() <= 1 then
1104 GetQuestReward(GetNumQuestChoices())
1105 end
1106 end
1107
1108 -- Show quest dialog for quests that use the objective tracker (it will be completed automatically)
1109 if event == "QUEST_AUTOCOMPLETE" then
1110 local index = GetQuestLogIndexByID(arg1)
1111 if GetQuestLogIsAutoComplete(index) then
1112 ShowQuestComplete(index)
1113 end
1114 end
1115
1116 ----------------------------------------------------------------------
1117 -- Select quests automatically
1118 ----------------------------------------------------------------------
1119
1120 if event == "GOSSIP_SHOW" or event == "QUEST_GREETING" then
1121
1122 -- Select quests
1123 if UnitExists("npc") or QuestFrameGreetingPanel:IsShown() or GossipFrameGreetingPanel:IsShown() then
1124
1125 -- Don't select quests for blocked NPCs
1126 if isNpcBlocked("Select") then return end
1127
1128 -- Select quests
1129 if event == "QUEST_GREETING" then
1130 -- Select quest greeting completed quests
1131 for i = 1, GetNumActiveQuests() do
1132 local title, isComplete = GetActiveTitle(i)
1133 if title and isComplete then
1134 return SelectActiveQuest(i)
1135 end
1136 end
1137 -- Select quest greeting available quests
1138 for i = 1, GetNumAvailableQuests() do
1139 local title, isComplete = GetAvailableTitle(i)
1140 if title and not isComplete then
1141 return SelectAvailableQuest(i)
1142 end
1143 end
1144 else
1145 -- Select gossip completed quests
1146 for i = 1, GetNumGossipActiveQuests() do
1147 local title, level, isTrivial, isComplete, isLegendary, isIgnored = select(i * 6 - 5, GetGossipActiveQuests())
1148 if title and isComplete then
1149 return SelectGossipActiveQuest(i)
1150 end
1151 end
1152 -- Select gossip available quests
1153 for i = 1, GetNumGossipAvailableQuests() do
1154 local title, level, isTrivial, isDaily, isRepeatable, isLegendary, isIgnored = select(i * 7 - 6, GetGossipAvailableQuests())
1155 if title then
1156 return SelectGossipAvailableQuest(i)
1157 end
1158 end
1159 end
1160 end
1161 end
1162
1163 end)
1164
1165 end
1166
1167 ----------------------------------------------------------------------
1168 -- Sort game options addon list
1169 ----------------------------------------------------------------------
1170
1171 if LeaPlusLC["CharAddonList"] == "On" then
1172 -- Set the addon list to character by default
1173 if AddonCharacterDropDown and AddonCharacterDropDown.selectedValue then
1174 AddonCharacterDropDown.selectedValue = UnitName("player");
1175 AddonCharacterDropDownText:SetText(UnitName("player"))
1176 end
1177 end
1178
1179 ----------------------------------------------------------------------
1180 -- Sell junk automatically (no reload required)
1181 ----------------------------------------------------------------------
1182
1183 do
1184
1185 -- Create sell junk banner
1186 local StartMsg = CreateFrame("FRAME", nil, MerchantFrame)
1187 StartMsg:ClearAllPoints()
1188 StartMsg:SetPoint("BOTTOMLEFT", 4, 4)
1189 StartMsg:SetSize(160, 22)
1190 StartMsg:SetToplevel(true)
1191 StartMsg:Hide()
1192
1193 StartMsg.s = StartMsg:CreateTexture(nil, "BACKGROUND")
1194 StartMsg.s:SetAllPoints()
1195 StartMsg.s:SetColorTexture(0.1, 0.1, 0.1, 1.0)
1196
1197 StartMsg.f = StartMsg:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
1198 StartMsg.f:SetAllPoints();
1199 StartMsg.f:SetText(L["SELLING JUNK"])
1200
1201 -- Declarations
1202 local IterationCount, totalPrice = 500, 0
1203 local SellJunkFrame = CreateFrame("FRAME")
1204 local SellJunkTicker, mBagID, mBagSlot
1205
1206 -- Function to stop selling
1207 local function StopSelling()
1208 if SellJunkTicker then SellJunkTicker:Cancel() end
1209 StartMsg:Hide()
1210 SellJunkFrame:UnregisterEvent("ITEM_LOCKED")
1211 SellJunkFrame:UnregisterEvent("ITEM_UNLOCKED")
1212 end
1213
1214 -- Vendor function
1215 local function SellJunkFunc()
1216
1217 -- Variables
1218 local SoldCount, Rarity, ItemPrice = 0, 0, 0
1219 local CurrentItemLink, void
1220
1221 -- Traverse bags and sell grey items
1222 for BagID = 0, 4 do
1223 for BagSlot = 1, GetContainerNumSlots(BagID) do
1224 CurrentItemLink = GetContainerItemLink(BagID, BagSlot)
1225 if CurrentItemLink then
1226 void, void, Rarity, void, void, void, void, void, void, void, ItemPrice = GetItemInfo(CurrentItemLink)
1227 local void, itemCount = GetContainerItemInfo(BagID, BagSlot)
1228 if Rarity == 0 and ItemPrice ~= 0 then
1229 SoldCount = SoldCount + 1
1230 if MerchantFrame:IsShown() then
1231 -- If merchant frame is open, vendor the item
1232 UseContainerItem(BagID, BagSlot)
1233 -- Perform actions on first iteration
1234 if SellJunkTicker._remainingIterations == IterationCount then
1235 -- Calculate total price
1236 totalPrice = totalPrice + (ItemPrice * itemCount)
1237 -- Store first sold bag slot for analysis
1238 if SoldCount == 1 then
1239 mBagID, mBagSlot = BagID, BagSlot
1240 end
1241 end
1242 else
1243 -- If merchant frame is not open, stop selling
1244 StopSelling()
1245 return
1246 end
1247 end
1248 end
1249 end
1250 end
1251
1252 -- Stop selling if no items were sold for this iteration or iteration limit was reached
1253 if SoldCount == 0 or SellJunkTicker and SellJunkTicker._remainingIterations == 1 then
1254 StopSelling()
1255 if totalPrice > 0 then
1256 LeaPlusLC:Print(L["Sold junk for"] .. " " .. GetCoinText(totalPrice) .. ".")
1257 end
1258 end
1259
1260 end
1261
1262 -- Function to setup events
1263 local function SetupEvents()
1264 if LeaPlusLC["AutoSellJunk"] == "On" then
1265 SellJunkFrame:RegisterEvent("MERCHANT_SHOW");
1266 SellJunkFrame:RegisterEvent("MERCHANT_CLOSED");
1267 else
1268 SellJunkFrame:UnregisterEvent("MERCHANT_SHOW")
1269 SellJunkFrame:UnregisterEvent("MERCHANT_CLOSED")
1270 end
1271 end
1272
1273 -- Setup events when option is clicked and on startup (if option is enabled)
1274 LeaPlusCB["AutoSellJunk"]:HookScript("OnClick", SetupEvents)
1275 if LeaPlusLC["AutoSellJunk"] == "On" then SetupEvents() end
1276
1277 -- Event handler
1278 SellJunkFrame:SetScript("OnEvent", function(self, event)
1279 if event == "MERCHANT_SHOW" then
1280 -- Reset variables
1281 totalPrice, mBagID, mBagSlot = 0, -1, -1
1282 -- Do nothing if shift key is held down
1283 if IsShiftKeyDown() then return end
1284 -- Cancel existing ticker if present
1285 if SellJunkTicker then SellJunkTicker:Cancel() end
1286 -- Sell grey items using ticker (ends when all grey items are sold or iteration count reached)
1287 SellJunkTicker = C_Timer.NewTicker(0.2, SellJunkFunc, IterationCount)
1288 SellJunkFrame:RegisterEvent("ITEM_LOCKED")
1289 SellJunkFrame:RegisterEvent("ITEM_UNLOCKED")
1290 elseif event == "ITEM_LOCKED" then
1291 StartMsg:Show()
1292 SellJunkFrame:UnregisterEvent("ITEM_LOCKED")
1293 elseif event == "ITEM_UNLOCKED" then
1294 SellJunkFrame:UnregisterEvent("ITEM_UNLOCKED")
1295 -- Check whether vendor refuses to buy items
1296 if mBagID and mBagSlot and mBagID ~= -1 and mBagSlot ~= -1 then
1297 local texture, count, locked = GetContainerItemInfo(mBagID, mBagSlot)
1298 if count and not locked then
1299 -- Item has been unlocked but still not sold so stop selling
1300 StopSelling()
1301 end
1302 end
1303 elseif event == "MERCHANT_CLOSED" then
1304 -- If merchant frame is closed, stop selling
1305 StopSelling()
1306 end
1307 end)
1308
1309 end
1310
1311 ----------------------------------------------------------------------
1312 -- Repair automatically (no reload required)
1313 ----------------------------------------------------------------------
1314
1315 do
1316
1317 -- Repair when suitable merchant frame is shown
1318 local function RepairFunc()
1319 if IsShiftKeyDown() then return end
1320 if CanMerchantRepair() then -- If merchant is capable of repair
1321 -- Process repair
1322 local RepairCost, CanRepair = GetRepairAllCost()
1323 if CanRepair then -- If merchant is offering repair
1324 if GetMoney() >= RepairCost then
1325 RepairAllItems()
1326 -- Show cost summary
1327 LeaPlusLC:Print(L["Repaired for"] .. " " .. GetCoinText(RepairCost) .. ".")
1328 end
1329 end
1330 end
1331 end
1332
1333 -- Create event frame
1334 local RepairFrame = CreateFrame("FRAME")
1335
1336 -- Function to setup event
1337 local function SetupEvent()
1338 if LeaPlusLC["AutoRepairGear"] == "On" then
1339 RepairFrame:RegisterEvent("MERCHANT_SHOW")
1340 else
1341 RepairFrame:UnregisterEvent("MERCHANT_SHOW")
1342 end
1343 end
1344
1345 -- Setup event when option is clicked and on startup (if option is enabled)
1346 LeaPlusCB["AutoRepairGear"]:HookScript("OnClick", SetupEvent)
1347 if LeaPlusLC["AutoRepairGear"] == "On" then SetupEvent() end
1348
1349 -- Event handler
1350 RepairFrame:SetScript("OnEvent", RepairFunc)
1351
1352 end
1353
1354 ----------------------------------------------------------------------
1355 -- Hide the combat log
1356 ----------------------------------------------------------------------
1357
1358 if LeaPlusLC["NoCombatLogTab"] == "On" then
1359 -- Ensure combat log is docked
1360 if ChatFrame2.isDocked then
1361 -- Set combat log attributes when chat windows are updated
1362 LpEvt:RegisterEvent("UPDATE_CHAT_WINDOWS")
1363 -- Set combat log tab placement when tabs are assigned by the client
1364 hooksecurefunc("FCF_SetTabPosition", function()
1365 ChatFrame2Tab:SetPoint("BOTTOMLEFT", ChatFrame1Tab, "BOTTOMRIGHT", 0, 0)
1366 end)
1367 else
1368 -- If combat log is undocked, do nothing but show warning
1369 C_Timer.After(1, function()
1370 LeaPlusLC:Print("Combat log cannot be hidden while undocked.")
1371 end)
1372 end
1373 end
1374
1375 ----------------------------------------------------------------------
1376 -- Show player chain
1377 ----------------------------------------------------------------------
1378
1379 if LeaPlusLC["ShowPlayerChain"] == "On" then
1380
1381 -- Create configuration panel
1382 local ChainPanel = LeaPlusLC:CreatePanel("Player Chain", "ChainPanel")
1383
1384 -- Add dropdown menu
1385 LeaPlusLC:CreateDropDown("PlayerChainMenu", "Chain style", ChainPanel, 146, "TOPLEFT", 16, -112, {L["RARE"], L["ELITE"], L["RARE ELITE"]}, "")
1386
1387 -- Set chain style
1388 local function SetChainStyle()
1389 -- Get dropdown menu value
1390 local chain = LeaPlusLC["PlayerChainMenu"] -- Numeric value
1391 -- Set chain style according to value
1392 if chain == 1 then -- Rare
1393 PlayerFrameTexture:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame-Rare.blp");
1394 elseif chain == 2 then -- Elite
1395 PlayerFrameTexture:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame-Elite.blp");
1396 elseif chain == 3 then -- Rare Elite
1397 PlayerFrameTexture:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame-Rare-Elite.blp");
1398 end
1399 end
1400
1401 -- Set style on startup
1402 SetChainStyle()
1403
1404 -- Set style when a drop menu is selected (procs when the list is hidden)
1405 LeaPlusCB["ListFramePlayerChainMenu"]:HookScript("OnHide", SetChainStyle)
1406
1407 -- Help button hidden
1408 ChainPanel.h:Hide()
1409
1410 -- Back button handler
1411 ChainPanel.b:SetScript("OnClick", function()
1412 LeaPlusCB["ListFramePlayerChainMenu"]:Hide(); -- Hide the dropdown list
1413 ChainPanel:Hide();
1414 LeaPlusLC["PageF"]:Show();
1415 LeaPlusLC["Page6"]:Show();
1416 return
1417 end)
1418
1419 -- Reset button handler
1420 ChainPanel.r:SetScript("OnClick", function()
1421 LeaPlusCB["ListFramePlayerChainMenu"]:Hide(); -- Hide the dropdown list
1422 LeaPlusLC["PlayerChainMenu"] = 2
1423 ChainPanel:Hide(); ChainPanel:Show();
1424 SetChainStyle()
1425 end)
1426
1427 -- Show the panel when the configuration button is clicked
1428 LeaPlusCB["ModPlayerChain"]:SetScript("OnClick", function()
1429 if IsShiftKeyDown() and IsControlKeyDown() then
1430 LeaPlusLC["PlayerChainMenu"] = 3;
1431 SetChainStyle();
1432 else
1433 LeaPlusLC:HideFrames();
1434 ChainPanel:Show();
1435 end
1436 end)
1437
1438 end
1439
1440 ----------------------------------------------------------------------
1441 -- Show raid frame toggle button
1442 ----------------------------------------------------------------------
1443
1444 if LeaPlusLC["ShowRaidToggle"] == "On" then
1445
1446 -- Check to make sure raid toggle button exists
1447 if CompactRaidFrameManagerDisplayFrameHiddenModeToggle then
1448
1449 -- Create a border for the button
1450 CompactRaidFrameManagerDisplayFrameHiddenModeToggle:SetBackdrop({
1451 edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
1452 tile = false, tileSize = 0, edgeSize = 16,
1453 insets = { left = 0, right = 0, top = 0, bottom = 0 }})
1454
1455 -- Move the button (function runs after PLAYER_ENTERING_WORLD and PARTY_LEADER_CHANGED)
1456 hooksecurefunc("CompactRaidFrameManager_UpdateOptionsFlowContainer", function()
1457 if CompactRaidFrameManager and CompactRaidFrameManagerDisplayFrameHiddenModeToggle then
1458 local void, void, void, void, y = CompactRaidFrameManager:GetPoint()
1459 CompactRaidFrameManagerDisplayFrameHiddenModeToggle:SetWidth(40)
1460 CompactRaidFrameManagerDisplayFrameHiddenModeToggle:ClearAllPoints()
1461 CompactRaidFrameManagerDisplayFrameHiddenModeToggle:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 0, y + 22)
1462 CompactRaidFrameManagerDisplayFrameHiddenModeToggle:SetParent(UIParent)
1463 end
1464 end)
1465
1466 end
1467
1468 end
1469
1470 ----------------------------------------------------------------------
1471 -- Hide hit indicators (portrait text)
1472 ----------------------------------------------------------------------
1473
1474 if LeaPlusLC["NoHitIndicators"] == "On" then
1475 hooksecurefunc(PlayerHitIndicator, "Show", PlayerHitIndicator.Hide)
1476 hooksecurefunc(PetHitIndicator, "Show", PetHitIndicator.Hide)
1477 end
1478
1479 ----------------------------------------------------------------------
1480 -- Class colored frames
1481 ----------------------------------------------------------------------
1482
1483 if LeaPlusLC["ClassColFrames"] == "On" then
1484
1485 -- Create background frame for player frame
1486 local PlayFN = CreateFrame("FRAME", nil, PlayerFrame)
1487 PlayFN:SetWidth(TargetFrameNameBackground:GetWidth())
1488 PlayFN:SetHeight(TargetFrameNameBackground:GetHeight())
1489
1490 local void, void, void, x, y = TargetFrameNameBackground:GetPoint()
1491 PlayFN:SetPoint("TOPLEFT", PlayerFrame, "TOPLEFT", -x, y)
1492
1493 PlayFN.t = PlayFN:CreateTexture(nil, "BORDER")
1494 PlayFN.t:SetAllPoints()
1495 PlayFN.t:SetTexture("Interface\\TargetingFrame\\UI-TargetingFrame-LevelBackground")
1496
1497 local c = LeaPlusLC["RaidColors"][select(2, UnitClass("player"))]
1498 if c then PlayFN.t:SetVertexColor(c.r, c.g, c.b) end
1499
1500 -- Create color function for target frame
1501 local function TargetFrameCol()
1502 if UnitIsPlayer("target") then
1503 local c = LeaPlusLC["RaidColors"][select(2, UnitClass("target"))]
1504 if c then TargetFrameNameBackground:SetVertexColor(c.r, c.g, c.b) end
1505 end
1506 end
1507
1508 -- Set target frame on startup and when events fire
1509 local ColTar = CreateFrame("FRAME")
1510 ColTar:RegisterEvent("GROUP_ROSTER_UPDATE")
1511 ColTar:RegisterEvent("PLAYER_TARGET_CHANGED")
1512 ColTar:RegisterEvent("UNIT_FACTION")
1513 ColTar:SetScript("OnEvent", TargetFrameCol)
1514 TargetFrameCol()
1515
1516 end
1517
1518 ----------------------------------------------------------------------
1519 -- Minimap customisation
1520 ----------------------------------------------------------------------
1521
1522 if LeaPlusLC["MinimapMod"] == "On" then
1523
1524 ----------------------------------------------------------------------
1525 -- Configuration panel
1526 ----------------------------------------------------------------------
1527
1528 -- Create configuration panel
1529 local SideMinimap = LeaPlusLC:CreatePanel("Minimap", "SideMinimap")
1530
1531 -- Hide panel during combat
1532 SideMinimap:RegisterEvent("PLAYER_REGEN_DISABLED")
1533 SideMinimap:SetScript("OnEvent", SideMinimap.Hide)
1534
1535 -- Add checkboxes
1536 LeaPlusLC:MakeTx(SideMinimap, "Settings", 16, -72)
1537 LeaPlusLC:MakeCB(SideMinimap, "HideZoneTextBar", "Hide the zone text bar", 16, -92, false, "If checked, the zone text bar will be hidden. The tracking button tooltip will show zone information.")
1538 LeaPlusLC:MakeCB(SideMinimap, "HideMiniZoomBtns", "Hide the zoom buttons", 16, -112, false, "If checked, the zoom buttons will be hidden. You can use the mousewheel to zoom regardless of this setting.")
1539
1540 -- Add slider control
1541 LeaPlusLC:MakeTx(SideMinimap, "Scale", 356, -72)
1542 LeaPlusLC:MakeSL(SideMinimap, "MinimapScale", "Drag to set the minimap scale.|n|nNote that if you are using the default action bars, rescaling the minimap will also rescale the right action bars at startup so you may want to leave this at 100%.", 1, 2, 0.1, 356, -92, "%.2f")
1543
1544 ----------------------------------------------------------------------
1545 -- Hide the zone text bar
1546 ----------------------------------------------------------------------
1547
1548 -- Store Blizzard handler
1549 local zonta, zontp, zontr, zontx, zonty = MinimapZoneTextButton:GetPoint()
1550
1551 -- Function to show zone tooltip
1552 local function ShowZoneTip(doNotShow)
1553 if LeaPlusLC["HideZoneTextBar"] == "On" then
1554 -- Show zone information in tooltip
1555 local zoneName = GetZoneText()
1556 local subzoneName = GetSubZoneText()
1557 if subzoneName == zoneName then subzoneName = "" end
1558 -- Change the owner and position (needed for Minimap_SetTooltip)
1559 GameTooltip:SetOwner(MinimapZoneTextButton, "ANCHOR_LEFT")
1560 MinimapZoneTextButton:SetAllPoints(MiniMapTrackingButton)
1561 -- Show the tooltip
1562 local pvpType, isSubZonePvP, factionName = GetZonePVPInfo()
1563 Minimap_SetTooltip(pvpType, factionName)
1564 GameTooltip:Show()
1565 if doNotShow == true then GameTooltip:Hide() end
1566 else
1567 MinimapZoneTextButton:ClearAllPoints()
1568 MinimapZoneTextButton:SetPoint(zonta, zontp, zontr, zontx, zonty)
1569 end
1570 end
1571
1572 -- Function to set the zone text bar position
1573 local function SetTitleBarPos()
1574 if OrderHallCommandBar then
1575 if OrderHallCommandBar:IsShown() then
1576 -- Order hall command bar is showing so move minimap cluster to top
1577 MinimapCluster:ClearAllPoints()
1578 MinimapCluster:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 0)
1579 if LeaPlusLC["HideZoneTextBar"] == "Off" then
1580 -- Zone text bar is showing so hide it as it will be behind the order hall command bar
1581 MinimapBorderTop:SetTexture("")
1582 MinimapZoneTextButton:Hide()
1583 MiniMapWorldMapButton:Hide()
1584 end
1585 else
1586 -- Order hall command bar is not showing
1587 if LeaPlusLC["HideZoneTextBar"] == "On" then
1588 -- Zone text bar is being hidden so move minimap cluster down below the order hall command bar
1589 MinimapCluster:ClearAllPoints()
1590 MinimapCluster:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 20)
1591 else
1592 -- Zone text bar is not being hidden so move order hall command bar to top
1593 MinimapCluster:ClearAllPoints()
1594 MinimapCluster:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 0)
1595 -- Show zone text bar
1596 MinimapZoneTextButton:Show()
1597 MiniMapWorldMapButton:Show()
1598 MinimapBorderTop:SetTexture("Interface\\Minimap\\UI-Minimap-Border")
1599 end
1600 end
1601 else
1602 -- Order hall command bar has not been loaded by the game yet
1603 if LeaPlusLC["HideZoneTextBar"] == "On" then
1604 MinimapCluster:ClearAllPoints()
1605 MinimapCluster:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 20)
1606 else
1607 MinimapCluster:ClearAllPoints()
1608 MinimapCluster:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 0)
1609 end
1610 end
1611 end
1612
1613 -- Function to toggle the zone text bar
1614 local function SetMiniZoneText()
1615 if LeaPlusLC["HideZoneTextBar"] == "On" then
1616 -- Hide the zone text bar
1617 MinimapZoneTextButton:Hide()
1618 MiniMapWorldMapButton:Hide()
1619 MinimapBorderTop:SetTexture("")
1620 -- Move the minimap up to the top
1621 SetTitleBarPos()
1622 else
1623 -- Show the zone text bar
1624 MinimapZoneTextButton:Show()
1625 MiniMapWorldMapButton:Show()
1626 MinimapBorderTop:SetTexture("Interface\\Minimap\\UI-Minimap-Border")
1627 -- Move the minimap to its original position
1628 SetTitleBarPos()
1629 end
1630 end
1631
1632 -- Set the zone text bar layout and tooltip position when option is clicked
1633 LeaPlusCB["HideZoneTextBar"]:HookScript("OnClick", function()
1634 SetMiniZoneText()
1635 ShowZoneTip(true)
1636 end)
1637
1638 -- Set the zone text bar layout on startup
1639 SetMiniZoneText()
1640
1641 ----------------------------------------------------------------------
1642 -- Hide the zoom buttons
1643 ----------------------------------------------------------------------
1644
1645 -- Function to toggle the zoom buttons
1646 local function ToggleZoomButtons()
1647 if LeaPlusLC["HideMiniZoomBtns"] == "On" then
1648 MinimapZoomIn:Hide()
1649 MinimapZoomOut:Hide()
1650 else
1651 MinimapZoomIn:Show()
1652 MinimapZoomOut:Show()
1653 end
1654 end
1655
1656 -- Set the zoom buttons when the option is clicked and on startup
1657 LeaPlusCB["HideMiniZoomBtns"]:HookScript("OnClick", ToggleZoomButtons)
1658 ToggleZoomButtons()
1659
1660 ----------------------------------------------------------------------
1661 -- Enable mousewheel zoom
1662 ----------------------------------------------------------------------
1663
1664 -- Function to control mousewheel zoom
1665 local function MiniZoom(self, arg1)
1666 if arg1 > 0 and self:GetZoom() < 5 then
1667 -- Zoom in
1668 MinimapZoomOut:Enable()
1669 self:SetZoom(self:GetZoom() + 1)
1670 if(Minimap:GetZoom() == (Minimap:GetZoomLevels() - 1)) then
1671 MinimapZoomIn:Disable()
1672 end
1673 elseif arg1 < 0 and self:GetZoom() > 0 then
1674 -- Zoom out
1675 MinimapZoomIn:Enable()
1676 self:SetZoom(self:GetZoom() - 1)
1677 if(Minimap:GetZoom() == 0) then
1678 MinimapZoomOut:Disable()
1679 end
1680 end
1681 end
1682
1683 -- Enable mousewheel zoom
1684 Minimap:EnableMouseWheel(true)
1685 Minimap:SetScript("OnMouseWheel", MiniZoom)
1686
1687 ----------------------------------------------------------------------
1688 -- Minimap scale
1689 ----------------------------------------------------------------------
1690
1691 -- Function to set the minimap scale
1692 local function SetMiniScale()
1693 MinimapCluster:SetScale(LeaPlusLC["MinimapScale"])
1694 -- Set slider formatted text
1695 LeaPlusCB["MinimapScale"].f:SetFormattedText("%.0f%%", LeaPlusLC["MinimapScale"] * 100)
1696 end
1697
1698 -- Set minimap scale when slider is changed and on startup
1699 LeaPlusCB["MinimapScale"]:HookScript("OnValueChanged", SetMiniScale)
1700 SetMiniScale()
1701
1702 ----------------------------------------------------------------------
1703 -- Buttons
1704 ----------------------------------------------------------------------
1705
1706 -- Help button tooltip
1707 SideMinimap.h.tiptext = L["This panel will close automatically if you enter combat."]
1708
1709 -- Back button handler
1710 SideMinimap.b:SetScript("OnClick", function()
1711 SideMinimap:Hide(); LeaPlusLC["PageF"]:Show(); LeaPlusLC["Page5"]:Show()
1712 return
1713 end)
1714
1715 -- Reset button handler
1716 SideMinimap.r:SetScript("OnClick", function()
1717 LeaPlusLC["HideZoneTextBar"] = "Off"; SetMiniZoneText(); ShowZoneTip(true)
1718 LeaPlusLC["HideMiniZoomBtns"] = "Off"; ToggleZoomButtons()
1719 LeaPlusLC["MinimapScale"] = 1; SetMiniScale()
1720 SideMinimap:Hide(); SideMinimap:Show()
1721 end)
1722
1723 -- Configuration button handler
1724 LeaPlusCB["ModMinimapBtn"]:SetScript("OnClick", function()
1725 if LeaPlusLC:PlayerInCombat() then
1726 return
1727 else
1728 if IsShiftKeyDown() and IsControlKeyDown() then
1729 -- Preset profile
1730 LeaPlusLC["HideZoneTextBar"] = "On"; SetMiniZoneText(); ShowZoneTip(true)
1731 LeaPlusLC["HideMiniZoomBtns"] = "Off"; ToggleZoomButtons()
1732 LeaPlusLC["MinimapScale"] = 1.30; SetMiniScale()
1733 else
1734 -- Show configuration panel
1735 SideMinimap:Show()
1736 LeaPlusLC:HideFrames()
1737 end
1738 end
1739 end)
1740
1741 end
1742
1743 ----------------------------------------------------------------------
1744 -- Quest text size
1745 ----------------------------------------------------------------------
1746
1747 if LeaPlusLC["QuestFontChange"] == "On" then
1748
1749 -- Create configuration panel
1750 local QuestTextPanel = LeaPlusLC:CreatePanel("Quest Text", "QuestTextPanel")
1751
1752 LeaPlusLC:MakeTx(QuestTextPanel, "Text size", 16, -72)
1753 LeaPlusLC:MakeSL(QuestTextPanel, "LeaPlusQuestFontSize", "Drag to set the font size of quest text.", 10, 36, 1, 16, -92, "%.0f")
1754
1755 -- Function to update the font size
1756 local function QuestSizeUpdate()
1757 QuestTitleFont:SetFont(QuestFont:GetFont(), LeaPlusLC["LeaPlusQuestFontSize"] + 3, nil)
1758 QuestFont:SetFont(QuestFont:GetFont(), LeaPlusLC["LeaPlusQuestFontSize"] + 1, nil)
1759 QuestFontNormalSmall:SetFont(QuestFontNormalSmall:GetFont(), LeaPlusLC["LeaPlusQuestFontSize"], nil)
1760 end
1761
1762 -- Set text size when slider changes and on startup
1763 LeaPlusCB["LeaPlusQuestFontSize"]:HookScript("OnValueChanged", QuestSizeUpdate)
1764 QuestSizeUpdate()
1765
1766 -- Help button hidden
1767 QuestTextPanel.h:Hide()
1768
1769 -- Back button handler
1770 QuestTextPanel.b:SetScript("OnClick", function()
1771 QuestTextPanel:Hide(); LeaPlusLC["PageF"]:Show(); LeaPlusLC["Page4"]:Show()
1772 return
1773 end)
1774
1775 -- Reset button handler
1776 QuestTextPanel.r:SetScript("OnClick", function()
1777
1778 -- Reset slider
1779 LeaPlusLC["LeaPlusQuestFontSize"] = 12
1780 QuestSizeUpdate()
1781
1782 -- Refresh side panel
1783 QuestTextPanel:Hide(); QuestTextPanel:Show()
1784
1785 end)
1786
1787 -- Show configuration panal when options panel button is clicked
1788 LeaPlusCB["QuestTextBtn"]:SetScript("OnClick", function()
1789 if IsShiftKeyDown() and IsControlKeyDown() then
1790 -- Preset profile
1791 LeaPlusLC["LeaPlusQuestFontSize"] = 18
1792 QuestSizeUpdate()
1793 else
1794 QuestTextPanel:Show()
1795 LeaPlusLC:HideFrames()
1796 end
1797 end)
1798
1799 end
1800
1801 ----------------------------------------------------------------------
1802 -- Resize mail text
1803 ----------------------------------------------------------------------
1804
1805 if LeaPlusLC["MailFontChange"] == "On" then
1806
1807 -- Create configuration panel
1808 local MailTextPanel = LeaPlusLC:CreatePanel("Mail Text", "MailTextPanel")
1809
1810 LeaPlusLC:MakeTx(MailTextPanel, "Text size", 16, -72)
1811 LeaPlusLC:MakeSL(MailTextPanel, "LeaPlusMailFontSize", "Drag to set the font size of mail text.", 10, 36, 1, 16, -92, "%.0f")
1812
1813 -- Function to set the text size
1814 local function MailSizeUpdate()
1815 local MailFont = QuestFont:GetFont();
1816 OpenMailBodyText:SetFont(MailFont, LeaPlusLC["LeaPlusMailFontSize"])
1817 SendMailBodyEditBox:SetFont(MailFont, LeaPlusLC["LeaPlusMailFontSize"])
1818 end
1819
1820 -- Set text size after changing slider and on startup
1821 LeaPlusCB["LeaPlusMailFontSize"]:HookScript("OnValueChanged", MailSizeUpdate)
1822 MailSizeUpdate()
1823
1824 -- Help button hidden
1825 MailTextPanel.h:Hide()
1826
1827 -- Back button handler
1828 MailTextPanel.b:SetScript("OnClick", function()
1829 MailTextPanel:Hide(); LeaPlusLC["PageF"]:Show(); LeaPlusLC["Page4"]:Show()
1830 return
1831 end)
1832
1833 -- Reset button handler
1834 MailTextPanel.r:SetScript("OnClick", function()
1835
1836 -- Reset slider
1837 LeaPlusLC["LeaPlusMailFontSize"] = 15
1838
1839 -- Refresh side panel
1840 MailTextPanel:Hide(); MailTextPanel:Show()
1841
1842 end)
1843
1844 -- Show configuration panal when options panel button is clicked
1845 LeaPlusCB["MailTextBtn"]:SetScript("OnClick", function()
1846 if IsShiftKeyDown() and IsControlKeyDown() then
1847 -- Preset profile
1848 LeaPlusLC["LeaPlusMailFontSize"] = 22
1849 MailSizeUpdate()
1850 else
1851 MailTextPanel:Show()
1852 LeaPlusLC:HideFrames()
1853 end
1854 end)
1855
1856 end
1857
1858 ----------------------------------------------------------------------
1859 -- Show durability status
1860 ----------------------------------------------------------------------
1861
1862 if LeaPlusLC["DurabilityStatus"] == "On" then
1863
1864 -- Create durability button
1865 local cButton = CreateFrame("BUTTON", nil, PaperDollFrame)
1866 cButton:ClearAllPoints()
1867 cButton:SetPoint("BOTTOMRIGHT", CharacterFrame, "BOTTOMRIGHT", -40, 80)
1868 cButton:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Up")
1869 cButton:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight")
1870 cButton:SetSize(32, 32)
1871
1872 -- Create durability tables
1873 local Slots = {"HeadSlot", "ShoulderSlot", "ChestSlot", "WristSlot", "HandsSlot", "WaistSlot", "LegsSlot", "FeetSlot", "MainHandSlot", "SecondaryHandSlot"}
1874 local SlotsFriendly = {INVTYPE_HEAD, INVTYPE_SHOULDER, INVTYPE_CHEST, INVTYPE_WRIST, INVTYPE_HAND, INVTYPE_WAIST, INVTYPE_LEGS, INVTYPE_FEET, INVTYPE_WEAPONMAINHAND, INVTYPE_WEAPONOFFHAND}
1875
1876 -- Show durability status in tooltip or status line (tip or status)
1877 local function ShowDuraStats(where)
1878
1879 local duravaltotal, duramaxtotal, durapercent = 0, 0, 0
1880 local valcol, id, duraval, duramax
1881
1882 if where == "tip" then
1883 -- Creare layout
1884 GameTooltip:AddLine("|cffffffff")
1885 GameTooltip:AddLine("|cffffffff")
1886 GameTooltip:AddLine("|cffffffff")
1887 _G["GameTooltipTextLeft1"]:SetText("|cffffffff"); _G["GameTooltipTextRight1"]:SetText("|cffffffff")
1888 _G["GameTooltipTextLeft2"]:SetText("|cffffffff"); _G["GameTooltipTextRight2"]:SetText("|cffffffff")
1889 _G["GameTooltipTextLeft3"]:SetText("|cffffffff"); _G["GameTooltipTextRight3"]:SetText("|cffffffff")
1890 end
1891
1892 local validItems = false
1893
1894 -- Traverse equipment slots
1895 for k, slotName in ipairs(Slots) do
1896 if GetInventorySlotInfo(slotName) then
1897 id = GetInventorySlotInfo(slotName)
1898 duraval, duramax = GetInventoryItemDurability(id)
1899 if duraval ~= nil then
1900
1901 -- At least one item has durability stat
1902 validItems = true
1903
1904 -- Add to tooltip
1905 if where == "tip" then
1906 durapercent = tonumber(format("%.0f", duraval / duramax * 100))
1907 valcol = (durapercent >= 80 and "|cff00FF00") or (durapercent >= 60 and "|cff99FF00") or (durapercent >= 40 and "|cffFFFF00") or (durapercent >= 20 and "|cffFF9900") or (durapercent >= 0 and "|cffFF2000") or ("|cffFFFFFF")
1908 _G["GameTooltipTextLeft1"]:SetText(L["Durability"])
1909 _G["GameTooltipTextLeft2"]:SetText(_G["GameTooltipTextLeft2"]:GetText() .. SlotsFriendly[k] .. "|n")
1910 _G["GameTooltipTextRight2"]:SetText(_G["GameTooltipTextRight2"]:GetText() .. valcol .. durapercent .. "%" .. "|n")
1911 end
1912
1913 duravaltotal = duravaltotal + duraval
1914 duramaxtotal = duramaxtotal + duramax
1915 end
1916 end
1917 end
1918 if duravaltotal > 0 and duramaxtotal > 0 then
1919 durapercent = duravaltotal / duramaxtotal * 100
1920 else
1921 durapercent = 0
1922 end
1923
1924 if where == "tip" then
1925
1926 if validItems == true then
1927 -- Show overall durability in the tooltip
1928 if durapercent >= 80 then valcol = "|cff00FF00" elseif durapercent >= 60 then valcol = "|cff99FF00" elseif durapercent >= 40 then valcol = "|cffFFFF00" elseif durapercent >= 20 then valcol = "|cffFF9900" elseif durapercent >= 0 then valcol = "|cffFF2000" else return end
1929 _G["GameTooltipTextLeft3"]:SetText(L["Overall"] .. " " .. valcol)
1930 _G["GameTooltipTextRight3"]:SetText(valcol .. string.format("%.0f", durapercent) .. "%")
1931
1932 -- Show lines of the tooltip
1933 GameTooltipTextLeft1:Show(); GameTooltipTextRight1:Show()
1934 GameTooltipTextLeft2:Show(); GameTooltipTextRight2:Show()
1935 GameTooltipTextLeft3:Show(); GameTooltipTextRight3:Show()
1936 GameTooltipTextRight2:SetJustifyH"RIGHT";
1937 GameTooltipTextRight3:SetJustifyH"RIGHT";
1938 GameTooltip:Show()
1939 else
1940 -- No items have durability stat
1941 GameTooltip:ClearLines()
1942 GameTooltip:AddLine("" .. L["Durability"],1.0, 0.85, 0.0)
1943 GameTooltip:AddLine("" .. L["No items with durability equipped."], 1, 1, 1)
1944 GameTooltip:Show()
1945 end
1946
1947 elseif where == "status" then
1948 if validItems == true then
1949 -- Show simple status line instead
1950 if tonumber(durapercent) >= 0 then -- Ensure character has some durability items equipped
1951 LeaPlusLC:Print(L["You have"] .. " " .. string.format("%.0f", durapercent) .. "%" .. " " .. L["durability"] .. ".")
1952 end
1953 end
1954
1955 end
1956 end
1957
1958 -- Hover over the durability button to show the durability tooltip
1959 cButton:SetScript("OnEnter", function()
1960 GameTooltip:SetOwner(cButton, "ANCHOR_RIGHT");
1961 ShowDuraStats("tip");
1962 end)
1963 cButton:SetScript("OnLeave", GameTooltip_Hide)
1964
1965 -- Create frame to watch events
1966 local DeathDura = CreateFrame("FRAME")
1967 DeathDura:RegisterEvent("PLAYER_DEAD")
1968 DeathDura:SetScript("OnEvent", function(self, event)
1969 ShowDuraStats("status")
1970 DeathDura:UnregisterEvent("PLAYER_DEAD")
1971 C_Timer.After(2, function()
1972 DeathDura:RegisterEvent("PLAYER_DEAD")
1973 end)
1974 end)
1975
1976 hooksecurefunc("AcceptResurrect", function()
1977 -- Player has ressed without releasing
1978 ShowDuraStats("status")
1979 end)
1980
1981 end
1982
1983 ----------------------------------------------------------------------
1984 -- Hide zone text
1985 ----------------------------------------------------------------------
1986
1987 if LeaPlusLC["HideZoneText"] == "On" then
1988 ZoneTextFrame:SetScript("OnShow", ZoneTextFrame.Hide);
1989 SubZoneTextFrame:SetScript("OnShow", SubZoneTextFrame.Hide);
1990 end
1991
1992 ----------------------------------------------------------------------
1993 -- Disable sticky chat
1994 ----------------------------------------------------------------------
1995
1996 if LeaPlusLC["NoStickyChat"] == "On" then
1997 -- These taint if set to anything other than nil
1998 ChatTypeInfo.WHISPER.sticky = nil
1999 ChatTypeInfo.BN_WHISPER.sticky = nil
2000 ChatTypeInfo.CHANNEL.sticky = nil
2001 end
2002
2003 ----------------------------------------------------------------------
2004 -- Hide stance bar
2005 ----------------------------------------------------------------------
2006
2007 if LeaPlusLC["NoClassBar"] == "On" then
2008 local stancebar = CreateFrame("FRAME")
2009 stancebar:Hide();
2010 UIPARENT_MANAGED_FRAME_POSITIONS["StanceBarFrame"] = nil;
2011 StanceBarFrame:SetParent(stancebar)
2012 end
2013
2014 ----------------------------------------------------------------------
2015 -- Hide gryphons
2016 ----------------------------------------------------------------------
2017
2018 if LeaPlusLC["NoGryphons"] == "On" then
2019 MainMenuBarLeftEndCap:Hide();
2020 MainMenuBarRightEndCap:Hide();
2021 end
2022
2023 ----------------------------------------------------------------------
2024 -- Disable chat fade
2025 ----------------------------------------------------------------------
2026
2027 if LeaPlusLC["NoChatFade"] == "On" then
2028 -- Process normal and existing chat frames
2029 for i = 1, 50 do
2030 if _G["ChatFrame" .. i] then
2031 _G["ChatFrame" .. i]:SetFading(false)
2032 end
2033 end
2034 -- Process temporary frames
2035 hooksecurefunc("FCF_OpenTemporaryWindow", function()
2036 local cf = FCF_GetCurrentChatFrame():GetName() or nil
2037 if cf then
2038 _G[cf]:SetFading(false)
2039 end
2040 end)
2041 end
2042
2043 ----------------------------------------------------------------------
2044 -- Use easy chat frame resizing
2045 ----------------------------------------------------------------------
2046
2047 if LeaPlusLC["UseEasyChatResizing"] == "On" then
2048 ChatFrame1Tab:HookScript("OnMouseDown", function(self,arg1)
2049 if arg1 == "LeftButton" then
2050 if select(8, GetChatWindowInfo(1)) then
2051 ChatFrame1:StartSizing("TOP")
2052 end
2053 end
2054 end)
2055 ChatFrame1Tab:SetScript("OnMouseUp", function(self,arg1)
2056 if arg1 == "LeftButton" then
2057 ChatFrame1:StopMovingOrSizing()
2058 FCF_SavePositionAndDimensions(ChatFrame1)
2059 end
2060 end)
2061 end
2062
2063 ----------------------------------------------------------------------
2064 -- Increase chat history
2065 ----------------------------------------------------------------------
2066
2067 if LeaPlusLC["MaxChatHstory"] == "On" then
2068 -- Process normal and existing chat frames
2069 for i = 1, 50 do
2070 if _G["ChatFrame" .. i] and _G["ChatFrame" .. i]:GetMaxLines() ~= 4096 then
2071 _G["ChatFrame" .. i]:SetMaxLines(4096);
2072 end
2073 end
2074 -- Process temporary chat frames
2075 hooksecurefunc("FCF_OpenTemporaryWindow", function()
2076 local cf = FCF_GetCurrentChatFrame():GetName() or nil
2077 if cf then
2078 if (_G[cf]:GetMaxLines() ~= 4096) then
2079 _G[cf]:SetMaxLines(4096);
2080 end
2081 end
2082 end)
2083 end
2084
2085 ----------------------------------------------------------------------
2086 -- Hide error messages
2087 ----------------------------------------------------------------------
2088
2089 if LeaPlusLC["HideErrorMessages"] == "On" then
2090
2091 -- Error message events
2092 local OrigErrHandler = UIErrorsFrame:GetScript('OnEvent')
2093 UIErrorsFrame:SetScript('OnEvent', function (self, event, id, err, ...)
2094 if event == "UI_ERROR_MESSAGE" then
2095 -- Hide error messages
2096 if LeaPlusLC["ShowErrorsFlag"] == 1 then
2097 if err == ERR_INV_FULL or
2098 err == ERR_QUEST_LOG_FULL or
2099 err == ERR_RAID_GROUP_ONLY or
2100 err == ERR_PET_SPELL_DEAD or
2101 err == ERR_PLAYER_DEAD then
2102 return OrigErrHandler(self, event, id, err, ...)
2103 end
2104 else
2105 return OrigErrHandler(self, event, id, err, ...)
2106 end
2107 elseif event == 'UI_INFO_MESSAGE' then
2108 -- Show information messages
2109 return OrigErrHandler(self, event, id, err, ...)
2110 end
2111 end)
2112
2113 end
2114
2115 -- Release memory
2116 LeaPlusLC.Isolated = nil
2117
2118 end
2119
2120----------------------------------------------------------------------
2121-- L40: Player
2122----------------------------------------------------------------------
2123
2124 function LeaPlusLC:Player()
2125
2126 ----------------------------------------------------------------------
2127 -- Show vendor price
2128 ----------------------------------------------------------------------
2129
2130 if LeaPlusLC["ShowVendorPrice"] == "On" then
2131
2132 -- Function to add vendor price to tooltips
2133 local function ShowVendorPrice(tooltip)
2134 local void, link = tooltip:GetItem()
2135 if not link then return end
2136 local void, void, void, void, void, void, void, void, void, void, itemSellPrice = GetItemInfo(link)
2137 if not itemSellPrice or itemSellPrice <= 0 then return end
2138 local container = GetMouseFocus()
2139 local buttonName = container:GetName() and (container:GetName() .. "Count")
2140 local count = container.count or (container.Count and container.Count:GetText()) or (container.Quantity and container.Quantity:GetText()) or (buttonName and _G[buttonName] and _G[buttonName]:GetText())
2141 count = tonumber(count) or 1
2142 if count <= 1 then count = 1 end
2143 SetTooltipMoney(tooltip, count * itemSellPrice, "STATIC", SELL_PRICE .. ":")
2144 end
2145
2146 -- Run function for regular tooltips and chat link tooltips
2147 GameTooltip:HookScript("OnTooltipSetItem", ShowVendorPrice)
2148 ItemRefTooltip:HookScript("OnTooltipSetItem", ShowVendorPrice)
2149
2150 end
2151
2152 ----------------------------------------------------------------------
2153 -- Stand and dismount
2154 ----------------------------------------------------------------------
2155
2156 if LeaPlusLC["StandAndDismount"] == "On" then
2157
2158 local eFrame = CreateFrame("FRAME")
2159 eFrame:RegisterEvent("UI_ERROR_MESSAGE")
2160 eFrame:SetScript("OnEvent", function(self, event, messageType, msg)
2161 -- Auto stand
2162 if msg == SPELL_FAILED_NOT_STANDING
2163 or msg == ERR_CANTATTACK_NOTSTANDING
2164 or msg == ERR_LOOT_NOTSTANDING
2165 or msg == ERR_TAXINOTSTANDING
2166 then
2167 DoEmote("stand")
2168 UIErrorsFrame:Clear()
2169 -- Auto dismount
2170 elseif msg == ERR_ATTACK_MOUNTED
2171 or msg == ERR_MOUNT_ALREADYMOUNTED
2172 or msg == ERR_NOT_WHILE_MOUNTED
2173 or msg == ERR_TAXIPLAYERALREADYMOUNTED
2174 or msg == SPELL_FAILED_NOT_MOUNTED
2175 then
2176 if IsMounted() then
2177 Dismount()
2178 UIErrorsFrame:Clear()
2179 end
2180 end
2181 end)
2182
2183 end
2184
2185 ----------------------------------------------------------------------
2186 -- Show vanity controls
2187 ----------------------------------------------------------------------
2188
2189 if LeaPlusLC["ShowVanityControls"] == "On" then
2190
2191 -- Create checkboxes
2192 LeaPlusLC:MakeCB(CharacterModelFrame, "ShowHelm", L["Helm"], 2, -192, false, "");
2193 LeaPlusLC:MakeCB(CharacterModelFrame, "ShowCloak", L["Cloak"], 281, -192, false, "");
2194 LeaPlusCB["ShowHelm"]:SetFrameStrata("HIGH")
2195 LeaPlusCB["ShowHelm"]:SetHitRectInsets(0, -LeaPlusCB["ShowHelm"].f:GetStringWidth() + 4, 0, 0)
2196
2197 LeaPlusCB["ShowCloak"]:SetFrameStrata("HIGH")
2198 LeaPlusCB["ShowCloak"]:SetHitRectInsets(0, -LeaPlusCB["ShowCloak"].f:GetStringWidth() + 4, 0, 0)
2199 LeaPlusCB["ShowCloak"]:ClearAllPoints()
2200 LeaPlusCB["ShowCloak"]:SetPoint("TOPLEFT", 210 - LeaPlusCB["ShowCloak"].f:GetStringWidth(), -192) -- 240
2201
2202 -- Toggle helm with click
2203 LeaPlusCB["ShowHelm"]:HookScript("OnClick", function()
2204 LeaPlusCB["ShowHelm"]:Disable()
2205 C_Timer.After(0.5, function()
2206 if ShowingHelm() then
2207 ShowHelm(false)
2208 else
2209 ShowHelm(true)
2210 end
2211 LeaPlusCB["ShowHelm"]:Enable()
2212 end)
2213 end)
2214
2215 -- Toggle cloak with click
2216 LeaPlusCB["ShowCloak"]:HookScript("OnClick", function()
2217 LeaPlusCB["ShowCloak"]:Disable()
2218 C_Timer.After(0.5, function()
2219 if ShowingCloak() then
2220 ShowCloak(false)
2221 else
2222 ShowCloak(true)
2223 end
2224 LeaPlusCB["ShowCloak"]:Enable()
2225 end)
2226 end)
2227
2228 -- Set checkbox state when checkboxes are shown
2229 LeaPlusCB["ShowCloak"]:HookScript("OnShow", function()
2230 if ShowingHelm() then
2231 LeaPlusCB["ShowHelm"]:SetChecked(true)
2232 else
2233 LeaPlusCB["ShowHelm"]:SetChecked(false)
2234 end
2235 if ShowingCloak() then
2236 LeaPlusCB["ShowCloak"]:SetChecked(true)
2237 else
2238 LeaPlusCB["ShowCloak"]:SetChecked(false)
2239 end
2240 end)
2241
2242 end
2243
2244 ----------------------------------------------------------------------
2245 -- Use class colors in chat
2246 ----------------------------------------------------------------------
2247
2248 do
2249
2250 -- Function to set class colors
2251 local function SetClassCol()
2252 if LeaPlusLC["ClassColorsInChat"] == "On" then
2253 SetCVar("chatClassColorOverride", "0")
2254 else
2255 SetCVar("chatClassColorOverride", "1")
2256 end
2257 end
2258
2259 -- Set class colors on startup and when option is clicked (if enabled)
2260 LeaPlusCB["ClassColorsInChat"]:HookScript("OnClick", SetClassCol)
2261 if LeaPlusLC["ClassColorsInChat"] == "On" then SetClassCol() end
2262
2263 end
2264
2265 ----------------------------------------------------------------------
2266 -- Disable screen glow (no reload required)
2267 ----------------------------------------------------------------------
2268
2269 do
2270
2271 -- Function to set screen glow
2272 local function SetGlow()
2273 if LeaPlusLC["NoScreenGlow"] == "On" then
2274 SetCVar("ffxGlow", "0")
2275 else
2276 SetCVar("ffxGlow", "1")
2277 end
2278 end
2279
2280 -- Set screen glow on startup and when option is clicked (if enabled)
2281 LeaPlusCB["NoScreenGlow"]:HookScript("OnClick", SetGlow)
2282 if LeaPlusLC["NoScreenGlow"] == "On" then SetGlow() end
2283
2284 end
2285
2286 ----------------------------------------------------------------------
2287 -- Disable screen effects (no reload required)
2288 ----------------------------------------------------------------------
2289
2290 do
2291
2292 -- Function to set screen effects
2293 local function SetEffects()
2294 if LeaPlusLC["NoScreenEffects"] == "On" then
2295 SetCVar("ffxDeath", "0")
2296 SetCVar("ffxNether", "0")
2297 else
2298 SetCVar("ffxDeath", "1")
2299 SetCVar("ffxNether", "1")
2300 end
2301 end
2302
2303 -- Set screen effects when option is clicked and on startup (if enabled)
2304 LeaPlusCB["NoScreenEffects"]:HookScript("OnClick", SetEffects)
2305 if LeaPlusLC["NoScreenEffects"] == "On" then SetEffects() end
2306
2307 end
2308
2309 ----------------------------------------------------------------------
2310 -- Max camera zoom (no reload required)
2311 ----------------------------------------------------------------------
2312
2313 do
2314
2315 -- Function to set camera zoom
2316 local function SetZoom()
2317 if LeaPlusLC["MaxCameraZoom"] == "On" then
2318 SetCVar("cameraDistanceMaxZoomFactor", 4.0)
2319 else
2320 SetCVar("cameraDistanceMaxZoomFactor", 1.9)
2321 end
2322 end
2323
2324 -- Set camera zoom when option is clicked and on startup (if enabled)
2325 LeaPlusCB["MaxCameraZoom"]:HookScript("OnClick", SetZoom)
2326 if LeaPlusLC["MaxCameraZoom"] == "On" then SetZoom() end
2327
2328 end
2329
2330 ----------------------------------------------------------------------
2331 -- Universal group chat color (no reload required)
2332 ----------------------------------------------------------------------
2333
2334 do
2335
2336 -- Function to set chat colors
2337 local function SetCol()
2338 if LeaPlusLC["UnivGroupColor"] == "On" then
2339 ChangeChatColor("RAID", 0.67, 0.67, 1)
2340 ChangeChatColor("RAID_LEADER", 0.46, 0.78, 1)
2341 ChangeChatColor("INSTANCE_CHAT", 0.67, 0.67, 1)
2342 ChangeChatColor("INSTANCE_CHAT_LEADER", 0.46, 0.78, 1)
2343 else
2344 ChangeChatColor("RAID", 1, 0.50, 0)
2345 ChangeChatColor("RAID_LEADER", 1, 0.28, 0.04)
2346 ChangeChatColor("INSTANCE_CHAT", 1, 0.50, 0)
2347 ChangeChatColor("INSTANCE_CHAT_LEADER", 1, 0.28, 0.04)
2348 end
2349 end
2350
2351 -- Set chat colors when option is clicked and on startup (if enabled)
2352 LeaPlusCB["UnivGroupColor"]:HookScript("OnClick", SetCol)
2353 if LeaPlusLC["UnivGroupColor"] == "On" then SetCol() end
2354
2355 end
2356
2357 ----------------------------------------------------------------------
2358 -- Minimap button (no reload required)
2359 ----------------------------------------------------------------------
2360
2361 do
2362
2363 -- Minimap button click function
2364 local function MiniBtnClickFunc(arg1)
2365
2366 -- Prevent options panel from showing if Blizzard options panel is showing
2367 if InterfaceOptionsFrame:IsShown() or VideoOptionsFrame:IsShown() or ChatConfigFrame:IsShown() then return end
2368 -- Prevent options panel from showing if Blizzard Store is showing
2369 if StoreFrame and StoreFrame:GetAttribute("isshown") then return end
2370 -- Left button down
2371 if arg1 == "LeftButton" then
2372
2373 -- Control key does nothing
2374 if IsControlKeyDown() and not IsShiftKeyDown() then
2375 return
2376 end
2377
2378 -- Shift key toggles music
2379 if IsShiftKeyDown() and not IsControlKeyDown() then
2380 Sound_ToggleMusic();
2381 return
2382 end
2383
2384 -- Shift key and control key toggles Zygor addon
2385 if IsShiftKeyDown() and IsControlKeyDown() then
2386 LeaPlusLC:ZygorToggle();
2387 return
2388 end
2389
2390 -- No modifier key toggles the options panel
2391 if LeaPlusLC:IsPlusShowing() then
2392 LeaPlusLC:HideFrames()
2393 LeaPlusLC:HideConfigPanels()
2394 else
2395 LeaPlusLC:HideFrames()
2396 LeaPlusLC["PageF"]:Show()
2397 end
2398 LeaPlusLC["Page"..LeaPlusLC["LeaStartPage"]]:Show()
2399 end
2400
2401 -- Right button down
2402 if arg1 == "RightButton" then
2403
2404 -- Control key toggles error messages
2405 if IsControlKeyDown() and not IsShiftKeyDown() then
2406 if LeaPlusDB["HideErrorMessages"] == "On" then -- Checks global
2407 if LeaPlusLC["ShowErrorsFlag"] == 1 then
2408 LeaPlusLC["ShowErrorsFlag"] = 0
2409 ActionStatus_DisplayMessage(L["Error messages will be shown"], true);
2410 else
2411 LeaPlusLC["ShowErrorsFlag"] = 1
2412 ActionStatus_DisplayMessage(L["Error messages will be hidden"], true);
2413 end
2414 return
2415 end
2416 return
2417 end
2418
2419 -- Shift key does nothing
2420 if IsShiftKeyDown() and not IsControlKeyDown() then
2421 return
2422 end
2423
2424 -- Shift key and control key toggles maximised window mode
2425 if IsShiftKeyDown() and IsControlKeyDown() then
2426 if LeaPlusLC:PlayerInCombat() then
2427 return
2428 else
2429 SetCVar("gxMaximize", tostring(1 - GetCVar("gxMaximize")));
2430 RestartGx();
2431 end
2432 return
2433 end
2434
2435 -- No modifier key toggles the options panel
2436 if LeaPlusLC:IsPlusShowing() then
2437 LeaPlusLC:HideFrames()
2438 LeaPlusLC:HideConfigPanels()
2439 else
2440 LeaPlusLC:HideFrames()
2441 LeaPlusLC["PageF"]:Show()
2442 end
2443 LeaPlusLC["Page" .. LeaPlusLC["LeaStartPage"]]:Show()
2444
2445 end
2446
2447 end
2448
2449 -- Create minimap button using LibDBIcon
2450 local ldb = LibStub("LibDataBroker-1.1", true)
2451 local miniButton = ldb:NewDataObject("Leatrix_Plus", {
2452 type = "launcher",
2453 icon = "Interface\\HELPFRAME\\ReportLagIcon-Movement",
2454 OnClick = function(self, btn)
2455 MiniBtnClickFunc(btn)
2456 end,
2457 OnTooltipShow = function(tooltip)
2458 if not tooltip or not tooltip.AddLine then return end
2459 tooltip:AddLine("Leatrix Plus")
2460 end,
2461 })
2462 local icon = LibStub("LibDBIcon-1.0", true)
2463 icon:Register("Leatrix_Plus", miniButton, LeaPlusDB)
2464
2465 -- Function to toggle LibDBIcon
2466 local function SetLibDBIconFunc()
2467 if LeaPlusLC["ShowMinimapIcon"] == "On" then
2468 icon:Show("Leatrix_Plus")
2469 else
2470 icon:Hide("Leatrix_Plus")
2471 end
2472 end
2473
2474 -- Set LibDBIcon when option is clicked and on startup
2475 LeaPlusCB["ShowMinimapIcon"]:HookScript("OnClick", SetLibDBIconFunc)
2476 SetLibDBIconFunc()
2477
2478 end
2479
2480 ----------------------------------------------------------------------
2481 -- Auction House Extras
2482 ----------------------------------------------------------------------
2483
2484 if LeaPlusLC["AhExtras"] == "On" then
2485
2486 local function AuctionFunc()
2487
2488 -- Set default auction duration value to saved settings or default settings
2489 AuctionFrameAuctions.duration = LeaPlusDB["AHDuration"] or 3
2490
2491 -- Update duration radio button
2492 AuctionsShortAuctionButton:SetChecked(false)
2493 AuctionsMediumAuctionButton:SetChecked(false)
2494 AuctionsLongAuctionButton:SetChecked(false)
2495 if AuctionFrameAuctions.duration == 1 then
2496 AuctionsShortAuctionButton:SetChecked(true)
2497 elseif AuctionFrameAuctions.duration == 2 then
2498 AuctionsMediumAuctionButton:SetChecked(true)
2499 elseif AuctionFrameAuctions.duration == 3 then
2500 AuctionsLongAuctionButton:SetChecked(true)
2501 end
2502
2503 -- Functions
2504 local function CreateAuctionCB(name, anchor, x, y, text)
2505 LeaPlusCB[name] = CreateFrame("CheckButton", nil, AuctionFrameAuctions, "OptionsCheckButtonTemplate")
2506 LeaPlusCB[name]:SetFrameStrata("HIGH")
2507 LeaPlusCB[name]:SetSize(20, 20)
2508 LeaPlusCB[name]:SetPoint(anchor, x, y)
2509 LeaPlusCB[name].f = LeaPlusCB[name]:CreateFontString(nil, 'OVERLAY', "GameFontNormal")
2510 LeaPlusCB[name].f:SetPoint("LEFT", 20, 0)
2511 LeaPlusCB[name].f:SetText(L[text])
2512 LeaPlusCB[name].f:Show();
2513 LeaPlusCB[name]:SetScript('OnClick', function()
2514 if LeaPlusCB[name]:GetChecked() then
2515 LeaPlusLC[name] = "On"
2516 else
2517 LeaPlusLC[name] = "Off"
2518 end
2519 end)
2520 LeaPlusCB[name]:SetScript('OnShow', function(self)
2521 if LeaPlusLC[name] == "On" then
2522 self:SetChecked(true)
2523 else
2524 self:SetChecked(false)
2525 end
2526 end)
2527 end
2528
2529 -- Show the correct fields in the AH frame and match prices
2530 local function SetupAh()
2531 if LeaPlusLC["AhBuyoutOnly"] == "On" then
2532 -- Hide the start price
2533 StartPrice:SetAlpha(0);
2534 -- Set start price to buyout price
2535 StartPriceGold:SetText(BuyoutPriceGold:GetText());
2536 StartPriceSilver:SetText(BuyoutPriceSilver:GetText());
2537 StartPriceCopper:SetText(BuyoutPriceCopper:GetText());
2538 else
2539 -- Show the start price
2540 StartPrice:SetAlpha(1);
2541 end
2542 -- If gold only is on, set copper and silver to 99
2543 if LeaPlusLC["AhGoldOnly"] == "On" then
2544 StartPriceCopper:SetText("99"); StartPriceCopper:Disable();
2545 StartPriceSilver:SetText("99"); StartPriceSilver:Disable();
2546 BuyoutPriceCopper:SetText("99"); BuyoutPriceCopper:Disable();
2547 BuyoutPriceSilver:SetText("99"); BuyoutPriceSilver:Disable();
2548 else
2549 StartPriceCopper:Enable();
2550 StartPriceSilver:Enable();
2551 BuyoutPriceCopper:Enable();
2552 BuyoutPriceSilver:Enable();
2553 end
2554 -- Validate the auction (mainly for the create auction button status)
2555 AuctionsFrameAuctions_ValidateAuction()
2556 end
2557
2558 -- Create checkboxes
2559 CreateAuctionCB("AhBuyoutOnly", "BOTTOMLEFT", 200, 16, "Buyout Only")
2560 CreateAuctionCB("AhGoldOnly", "BOTTOMLEFT", 320, 16, "Gold Only")
2561
2562 -- Reposition Gold Only checkbox so it does not overlap Buyout Only checkbox label
2563 LeaPlusCB["AhGoldOnly"]:ClearAllPoints()
2564 LeaPlusCB["AhGoldOnly"]:SetPoint("LEFT", LeaPlusCB["AhBuyoutOnly"].f, "RIGHT", 20, 0)
2565
2566 -- Set click boundaries
2567 LeaPlusCB["AhBuyoutOnly"]:SetHitRectInsets(0, -LeaPlusCB["AhBuyoutOnly"].f:GetStringWidth() + 6, 0, 0);
2568 LeaPlusCB["AhGoldOnly"]:SetHitRectInsets(0, -LeaPlusCB["AhGoldOnly"].f:GetStringWidth() + 6, 0, 0);
2569
2570 LeaPlusCB["AhBuyoutOnly"]:HookScript('OnClick', SetupAh);
2571 LeaPlusCB["AhBuyoutOnly"]:HookScript('OnShow', SetupAh);
2572
2573 AuctionFrameAuctions:HookScript("OnShow", SetupAh)
2574 BuyoutPriceGold:HookScript("OnTextChanged", SetupAh)
2575 BuyoutPriceSilver:HookScript("OnTextChanged", SetupAh)
2576 BuyoutPriceCopper:HookScript("OnTextChanged", SetupAh)
2577 StartPriceGold:HookScript("OnTextChanged", SetupAh)
2578 StartPriceSilver:HookScript("OnTextChanged", SetupAh)
2579 StartPriceCopper:HookScript("OnTextChanged", SetupAh)
2580
2581 -- Lock the create auction button if buyout gold box is empty (when using buyout only and gold only)
2582 AuctionsCreateAuctionButton:HookScript("OnEnable", function()
2583 -- Do nothing if wow token frame is showing
2584 if AuctionsWowTokenAuctionFrame:IsShown() then return end
2585 -- Lock the create auction button if both checkboxes are enabled and buyout gold price is empty
2586 if LeaPlusLC["AhGoldOnly"] == "On" and LeaPlusLC["AhBuyoutOnly"] == "On" then
2587 if BuyoutPriceGold:GetText() == "" then
2588 AuctionsCreateAuctionButton:Disable()
2589 end
2590 end
2591 end)
2592
2593 -- Clear copper and silver prices if gold only box is unchecked
2594 LeaPlusCB["AhGoldOnly"]:HookScript('OnClick', function()
2595 if LeaPlusCB["AhGoldOnly"]:GetChecked() == false then
2596 BuyoutPriceCopper:SetText("")
2597 BuyoutPriceSilver:SetText("")
2598 StartPriceCopper:SetText("")
2599 StartPriceSilver:SetText("")
2600 end
2601 SetupAh();
2602 end)
2603
2604 -- Create find button
2605 AuctionsItemText:Hide()
2606 LeaPlusLC:CreateButton("FindAuctionButton", AuctionsStackSizeMaxButton, "Find Item", "CENTER", 0, 68, 0, 21, false, "")
2607 LeaPlusCB["FindAuctionButton"]:SetParent(AuctionFrameAuctions)
2608
2609 -- Show find button when the auctions tab is shown
2610 AuctionFrameAuctions:HookScript("OnShow", function()
2611 LeaPlusCB["FindAuctionButton"]:SetEnabled(GetAuctionSellItemInfo() and true or false)
2612 end)
2613
2614 -- Show find button when a new item is added
2615 AuctionsItemButton:HookScript("OnEvent", function(self, event)
2616 if event == "NEW_AUCTION_UPDATE" then
2617 LeaPlusCB["FindAuctionButton"]:SetEnabled(GetAuctionSellItemInfo() and true or false)
2618 end
2619 end)
2620
2621 LeaPlusCB["FindAuctionButton"]:SetScript("OnClick", function()
2622 if GetAuctionSellItemInfo() then
2623 if BrowseWowTokenResults:IsShown() then
2624 -- Stop if Game Time filter is currently shown
2625 AuctionFrameTab1:Click()
2626 LeaPlusLC:Print("To use the Find Item button, you need to deselect the WoW Token category.")
2627 else
2628 -- Otherwise, search for the required item
2629 local name = GetAuctionSellItemInfo()
2630 BrowseName:SetText(name)
2631 QueryAuctionItems(name, 0, 0, 0, false, 0, false, true)
2632 AuctionFrameTab1:Click()
2633 end
2634 end
2635 end)
2636
2637 -- Clear the cursor and reset editboxes when a new item replaces an existing one
2638 hooksecurefunc("AuctionsFrameAuctions_ValidateAuction", function()
2639 if GetAuctionSellItemInfo() then
2640 -- Return anything you might be holding
2641 ClearCursor();
2642 -- Set copper and silver prices to 99 if gold mode is on
2643 if LeaPlusLC["AhGoldOnly"] == "On" then
2644 StartPriceCopper:SetText("99")
2645 StartPriceSilver:SetText("99")
2646 BuyoutPriceCopper:SetText("99")
2647 BuyoutPriceSilver:SetText("99")
2648 end
2649 end
2650 end)
2651
2652 -- Clear gold editbox after an auction has been created (to force user to enter something)
2653 AuctionsCreateAuctionButton:HookScript("OnClick", function()
2654 StartPriceGold:SetText("")
2655 BuyoutPriceGold:SetText("")
2656 end)
2657
2658 -- Set tab key actions (if different from defaults)
2659 StartPriceGold:HookScript("OnTabPressed", function()
2660 if not IsShiftKeyDown() then
2661 if LeaPlusLC["AhBuyoutOnly"] == "Off" and LeaPlusLC["AhGoldOnly"] == "On" then
2662 BuyoutPriceGold:SetFocus()
2663 end
2664 end
2665 end)
2666
2667 BuyoutPriceGold:HookScript("OnTabPressed", function()
2668 if IsShiftKeyDown() then
2669 if LeaPlusLC["AhBuyoutOnly"] == "Off" and LeaPlusLC["AhGoldOnly"] == "On" then
2670 StartPriceGold:SetFocus()
2671 end
2672 end
2673 end)
2674 end
2675
2676 -- Run function when Blizzard addon is loaded
2677 if IsAddOnLoaded("Blizzard_AuctionUI") then
2678 AuctionFunc()
2679 else
2680 local waitFrame = CreateFrame("FRAME")
2681 waitFrame:RegisterEvent("ADDON_LOADED")
2682 waitFrame:SetScript("OnEvent", function(self, event, arg1)
2683 if arg1 == "Blizzard_AuctionUI" then
2684 AuctionFunc()
2685 waitFrame:UnregisterAllEvents()
2686 end
2687 end)
2688 end
2689
2690 end
2691
2692 ----------------------------------------------------------------------
2693 -- Show volume control on character sheet
2694 ----------------------------------------------------------------------
2695
2696 if LeaPlusLC["ShowVolume"] == "On" then
2697
2698 -- Function to update master volume
2699 local function MasterVolUpdate()
2700 if LeaPlusLC["ShowVolume"] == "On" then
2701 -- Set the volume
2702 SetCVar("Sound_MasterVolume", LeaPlusLC["LeaPlusMaxVol"]);
2703 -- Format the slider text
2704 LeaPlusCB["LeaPlusMaxVol"].f:SetFormattedText("%.0f", LeaPlusLC["LeaPlusMaxVol"] * 20)
2705 end
2706 end
2707
2708 -- Create slider control
2709 LeaPlusLC["LeaPlusMaxVol"] = tonumber(GetCVar("Sound_MasterVolume"));
2710 LeaPlusLC:MakeSL(CharacterModelFrame, "LeaPlusMaxVol", "", 0, 1, 0.05, -42, -328, "%.2f")
2711 LeaPlusCB["LeaPlusMaxVol"]:SetWidth(64)
2712 LeaPlusCB["LeaPlusMaxVol"].f:ClearAllPoints()
2713 LeaPlusCB["LeaPlusMaxVol"].f:SetPoint("LEFT", LeaPlusCB["LeaPlusMaxVol"], "RIGHT", 6, 0)
2714
2715 -- Set slider control value when shown
2716 LeaPlusCB["LeaPlusMaxVol"]:SetScript("OnShow", function()
2717 LeaPlusCB["LeaPlusMaxVol"]:SetValue(GetCVar("Sound_MasterVolume"))
2718 end)
2719
2720 -- Update volume when slider control is changed
2721 LeaPlusCB["LeaPlusMaxVol"]:HookScript("OnValueChanged", function()
2722 if IsMouseButtonDown("RightButton") and IsShiftKeyDown() then
2723 -- Dual layout is active so don't adjust slider
2724 LeaPlusCB["LeaPlusMaxVol"].f:SetFormattedText("%.0f", LeaPlusLC["LeaPlusMaxVol"] * 20)
2725 LeaPlusCB["LeaPlusMaxVol"]:Hide()
2726 LeaPlusCB["LeaPlusMaxVol"]:Show()
2727 return
2728 else
2729 -- Set sound level and refresh slider
2730 MasterVolUpdate()
2731 end
2732 end)
2733
2734 end
2735
2736 ----------------------------------------------------------------------
2737 -- Use arrow keys in chat
2738 ----------------------------------------------------------------------
2739
2740 if LeaPlusLC["UseArrowKeysInChat"] == "On" then
2741 -- Enable arrow keys for normal and existing chat frames
2742 for i = 1, 50 do
2743 if _G["ChatFrame" .. i] then
2744 _G["ChatFrame" .. i .. "EditBox"]:SetAltArrowKeyMode(false)
2745 end
2746 end
2747 -- Enable arrow keys for temporary chat frames
2748 hooksecurefunc("FCF_OpenTemporaryWindow", function()
2749 local cf = FCF_GetCurrentChatFrame():GetName() or nil
2750 if cf then
2751 _G[cf .. "EditBox"]:SetAltArrowKeyMode(false)
2752 end
2753 end)
2754 end
2755
2756 ----------------------------------------------------------------------
2757 -- L42: Manage frames
2758 ----------------------------------------------------------------------
2759
2760 -- Frame Movement
2761 if LeaPlusLC["FrmEnabled"] == "On" then
2762
2763 -- Lock the player and target frames
2764 PlayerFrame_SetLocked(true)
2765 TargetFrame_SetLocked(true)
2766
2767 -- Remove integrated movement functions to avoid conflicts
2768 _G.PlayerFrame_ResetUserPlacedPosition = function() end
2769 _G.TargetFrame_ResetUserPlacedPosition = function() end
2770 _G.PlayerFrame_SetLocked = function() end
2771 _G.TargetFrame_SetLocked = function() end
2772
2773 -- Replace buff frame movement function
2774 local buffSetPos = BuffFrame.SetPoint
2775
2776 -- Create and manage container for UIWidgetTopCenterContainerFrame
2777 local topCenterHolder = CreateFrame("Frame", "LeaPlusTopCenterContainerHolder", UIParent)
2778 topCenterHolder:SetPoint("TOP", UIParent, "TOP", 0, -30)
2779 topCenterHolder:SetSize(10, 58)
2780
2781 local topCenterContainer = _G.UIWidgetTopCenterContainerFrame
2782 topCenterContainer:ClearAllPoints()
2783 topCenterContainer:SetPoint('CENTER', topCenterHolder)
2784
2785 hooksecurefunc(topCenterContainer, 'SetPoint', function(self, void, b)
2786 local holder = _G.LeaPlusTopCenterContainerHolder
2787 if b and (b ~= holder) then
2788 self:ClearAllPoints()
2789 self:SetPoint('CENTER', holder)
2790 self:SetParent(holder)
2791 end
2792 end)
2793
2794 -- Create frame table (used for local traversal)
2795 local FrameTable = {DragPlayerFrame = PlayerFrame, DragTargetFrame = TargetFrame, DragMirrorTimer1 = MirrorTimer1, DragLeaPlusTopCenterContainerHolder = LeaPlusTopCenterContainerHolder, DragBuffFrame = BuffFrame}
2796
2797 -- Create main table structure in saved variables if it doesn't exist
2798 if (LeaPlusDB["Frames"]) == nil then
2799 LeaPlusDB["Frames"] = {}
2800 end
2801
2802 -- Create frame based table structure in saved variables if it doesn't exist and set initial scales
2803 for k,v in pairs(FrameTable) do
2804 local vf = v:GetName()
2805 -- Create frame table structure if it doesn't exist
2806 if not LeaPlusDB["Frames"][vf] then
2807 LeaPlusDB["Frames"][vf] = {}
2808 end
2809 -- Set saved scale value to default if it doesn't exist
2810 if not LeaPlusDB["Frames"][vf]["Scale"] then
2811 LeaPlusDB["Frames"][vf]["Scale"] = 1.00
2812 end
2813 -- Set frame scale to saved value
2814 _G[vf]:SetScale(LeaPlusDB["Frames"][vf]["Scale"])
2815 end
2816
2817 -- Set cached status
2818 local function LeaPlusFramesSaveCache(frame)
2819 _G[frame]:SetMovable(true)
2820 if frame == "PlayerFrame" or frame == "TargetFrame" then
2821 _G[frame]:SetUserPlaced(true)
2822 else
2823 _G[frame]:SetUserPlaced(false)
2824 end
2825 end
2826
2827 -- Set frames to manual values
2828 local function LeaFramesSetPos(frame, point, parent, relative, xoff, yoff)
2829 frame:SetMovable(true)
2830 frame:ClearAllPoints()
2831 if frame:GetName() == "BuffFrame" then
2832 buffSetPos(BuffFrame, point, parent, relative, xoff, yoff)
2833 else
2834 frame:SetPoint(point, parent, relative, xoff, yoff)
2835 end
2836 end
2837
2838 -- Set frames to default values
2839 local function LeaPlusFramesDefaults()
2840 LeaFramesSetPos(PlayerFrame , "TOPLEFT" , UIParent, "TOPLEFT" , -19, -4)
2841 LeaFramesSetPos(TargetFrame , "TOPLEFT" , UIParent, "TOPLEFT" , 250, -4)
2842 LeaFramesSetPos(MirrorTimer1 , "TOP" , UIParent, "TOP" , -5, -96)
2843 LeaFramesSetPos(LeaPlusTopCenterContainerHolder , "TOP" , UIParent, "TOP" , 0, -15)
2844 LeaFramesSetPos(BuffFrame , "TOPRIGHT", UIParent, "TOPRIGHT" , -205, -13)
2845 end
2846
2847 -- Create configuration panel
2848 local SideFrames = LeaPlusLC:CreatePanel("Frames", "SideFrames")
2849
2850 -- Variable used to store currently selected frame
2851 local currentframe
2852
2853 -- Create scale title
2854 LeaPlusLC:MakeTx(SideFrames, "Scale", 16, -72)
2855
2856 -- Set initial slider value (will be changed when drag frames are selected)
2857 LeaPlusLC["FrameScale"] = 1.00
2858
2859 -- Create scale slider
2860 LeaPlusLC:MakeSL(SideFrames, "FrameScale", "Drag to set the scale of the selected frame.", 0.5, 3.0, 0.05, 16, -92, "%.2f")
2861 LeaPlusCB["FrameScale"]:HookScript("OnValueChanged", function(self, value)
2862 if currentframe then -- If a frame is selected
2863 -- Set real and drag frame scale
2864 LeaPlusDB["Frames"][currentframe]["Scale"] = value
2865 _G[currentframe]:SetScale(LeaPlusDB["Frames"][currentframe]["Scale"])
2866 LeaPlusLC["Drag" .. currentframe]:SetScale(LeaPlusDB["Frames"][currentframe]["Scale"])
2867 -- If target frame scale is changed, also change combo point frame
2868 if currentframe == "TargetFrame" then
2869 ComboFrame:SetScale(LeaPlusDB["Frames"]["TargetFrame"]["Scale"])
2870 end
2871 -- If buff frame scale is changed, also change temporary enchant frame
2872 if currentframe == "BuffFrame" then
2873 TemporaryEnchantFrame:SetScale(LeaPlusDB["Frames"]["BuffFrame"]["Scale"])
2874 end
2875 -- If widget top holder scale is changed, also change real widget top center frame
2876 if currentframe == "LeaPlusTopCenterContainerHolder" then
2877 UIWidgetTopCenterContainerFrame:SetScale(LeaPlusDB["Frames"]["LeaPlusTopCenterContainerHolder"]["Scale"])
2878 end
2879 -- Set slider formatted text
2880 LeaPlusCB["FrameScale"].f:SetFormattedText("%.0f%%", LeaPlusLC["FrameScale"] * 100)
2881 end
2882 end)
2883
2884 -- Set initial scale slider state and value
2885 LeaPlusCB["FrameScale"]:HookScript("OnShow", function()
2886 if not currentframe then
2887 -- No frame selected so select the player frame
2888 currentframe = PlayerFrame:GetName()
2889 LeaPlusLC["DragPlayerFrame"].t:SetColorTexture(0.0, 1.0, 0.0,0.5)
2890 end
2891 -- Set the scale slider value to the selected frame
2892 LeaPlusCB["FrameScale"]:SetValue(LeaPlusDB["Frames"][currentframe]["Scale"])
2893 -- Set slider formatted text
2894 LeaPlusCB["FrameScale"].f:SetFormattedText("%.0f%%", LeaPlusLC["FrameScale"] * 100)
2895 end)
2896
2897 -- Help button tooltip
2898 SideFrames.h.tiptext = L["Drag the frame overlays to position the frames.|n|nTo change the scale of a frame, click it to select it then adjust the scale slider.|n|nThis panel will close automatically if you enter combat."]
2899
2900 -- Back button handler
2901 SideFrames.b:SetScript("OnClick", function()
2902 -- Hide outer control frame
2903 SideFrames:Hide()
2904 -- Hide drag frames
2905 for k, void in pairs(FrameTable) do
2906 LeaPlusLC[k]:Hide()
2907 end
2908 -- Show options panel at frame section
2909 LeaPlusLC["PageF"]:Show()
2910 LeaPlusLC["Page6"]:Show()
2911 end)
2912
2913 -- Reset button handler
2914 SideFrames.r:SetScript("OnClick", function()
2915 if LeaPlusLC:PlayerInCombat() then
2916 -- If player is in combat, print error and stop
2917 return
2918 else
2919 -- Set frames to default positions (presets)
2920 LeaPlusFramesDefaults()
2921 for k,v in pairs(FrameTable) do
2922 local vf = v:GetName()
2923 -- Store frame locations
2924 LeaPlusDB["Frames"][vf]["Point"], void, LeaPlusDB["Frames"][vf]["Relative"], LeaPlusDB["Frames"][vf]["XOffset"], LeaPlusDB["Frames"][vf]["YOffset"] = _G[vf]:GetPoint()
2925 -- Reset real frame scales and save them
2926 LeaPlusDB["Frames"][vf]["Scale"] = 1.00
2927 _G[vf]:SetScale(LeaPlusDB["Frames"][vf]["Scale"])
2928 -- Reset drag frame scales
2929 LeaPlusLC[k]:SetScale(LeaPlusDB["Frames"][vf]["Scale"])
2930 end
2931 -- Set combo frame scale to match target frame scale
2932 ComboFrame:SetScale(LeaPlusDB["Frames"]["TargetFrame"]["Scale"])
2933 -- Set temporary enchant frame scale to match buff frame scale
2934 TemporaryEnchantFrame:SetScale(LeaPlusDB["Frames"]["BuffFrame"]["Scale"])
2935 -- Set real widget top center frame scale to match holder frame
2936 UIWidgetTopCenterContainerFrame:SetScale(LeaPlusDB["Frames"]["LeaPlusTopCenterContainerHolder"]["Scale"])
2937 LeaPlusTopCenterContainerHolder:SetScale(LeaPlusDB["Frames"]["LeaPlusTopCenterContainerHolder"]["Scale"])
2938 -- Set the scale slider value to the selected frame scale
2939 LeaPlusCB["FrameScale"]:SetValue(LeaPlusDB["Frames"][currentframe]["Scale"])
2940 -- Refresh the panel
2941 SideFrames:Hide(); SideFrames:Show()
2942 end
2943 end)
2944
2945 -- Show drag frames with configuration panel
2946 SideFrames:HookScript("OnShow", function()
2947 for k, void in pairs(FrameTable) do
2948 LeaPlusLC[k]:Show()
2949 end
2950 end)
2951 SideFrames:HookScript("OnHide", function()
2952 for k, void in pairs(FrameTable) do
2953 LeaPlusLC[k]:Hide()
2954 end
2955 end)
2956
2957 -- Save frame positions
2958 local function SaveAllFrames()
2959 for k, v in pairs(FrameTable) do
2960 local vf = v:GetName()
2961 -- Stop real frames from moving
2962 v:StopMovingOrSizing()
2963 -- Save frame positions
2964 LeaPlusDB["Frames"][vf]["Point"], void, LeaPlusDB["Frames"][vf]["Relative"], LeaPlusDB["Frames"][vf]["XOffset"], LeaPlusDB["Frames"][vf]["YOffset"] = v:GetPoint()
2965 v:SetMovable(true)
2966 v:ClearAllPoints()
2967 v:SetPoint(LeaPlusDB["Frames"][vf]["Point"], UIParent, LeaPlusDB["Frames"][vf]["Relative"], LeaPlusDB["Frames"][vf]["XOffset"], LeaPlusDB["Frames"][vf]["YOffset"])
2968 LeaPlusFramesSaveCache(vf)
2969 end
2970 end
2971
2972 -- Prevent changes during combat
2973 SideFrames:RegisterEvent("PLAYER_REGEN_DISABLED")
2974 SideFrames:SetScript("OnEvent", function()
2975 -- Hide controls frame
2976 SideFrames:Hide()
2977 -- Hide drag frames
2978 for k,void in pairs(FrameTable) do
2979 LeaPlusLC[k]:Hide()
2980 end
2981 -- Save frame positions
2982 SaveAllFrames()
2983 end)
2984
2985 -- Create drag frames
2986 local function LeaPlusMakeDrag(dragframe,realframe)
2987
2988 local dragframe = CreateFrame("Frame", nil)
2989 LeaPlusLC[dragframe] = dragframe
2990 dragframe:SetSize(realframe:GetSize())
2991 if realframe:GetName() == "BuffFrame" then
2992 dragframe:SetPoint("TOPRIGHT", realframe, "TOPRIGHT", 0, 2.5)
2993 else
2994 dragframe:SetPoint("TOP", realframe, "TOP", 0, 2.5)
2995 end
2996 dragframe:SetBackdropColor(0.0, 0.5, 1.0);
2997 dragframe:SetBackdrop({
2998 edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
2999 tile = false, tileSize = 0, edgeSize = 16,
3000 insets = { left = 0, right = 0, top = 0, bottom = 0 }})
3001 dragframe:SetToplevel(true)
3002 dragframe:SetFrameStrata("HIGH")
3003
3004 -- Set frame clamps
3005 if realframe:GetName() == "BuffFrame" then
3006 realframe:SetClampedToScreen(true)
3007 else
3008 realframe:SetClampedToScreen(false)
3009 end
3010
3011 -- Hide the drag frame and make real frame movable
3012 dragframe:Hide()
3013 realframe:SetMovable(true)
3014
3015 -- Click handler
3016 dragframe:SetScript("OnMouseDown", function(self, btn)
3017
3018 -- Start dragging if left clicked
3019 if btn == "LeftButton" then
3020 realframe:SetMovable(true)
3021 realframe:StartMoving()
3022 end
3023
3024 -- Set all drag frames to blue then tint the selected frame to green
3025 for k,v in pairs(FrameTable) do
3026 LeaPlusLC[k].t:SetColorTexture(0.0, 0.5, 1.0, 0.5)
3027 end
3028 dragframe.t:SetColorTexture(0.0, 1.0, 0.0, 0.5)
3029
3030 -- Set currentframe variable to selected frame and set the scale slider value
3031 currentframe = realframe:GetName()
3032 LeaPlusCB["FrameScale"]:SetValue(LeaPlusDB["Frames"][currentframe]["Scale"])
3033
3034 end)
3035
3036 dragframe:SetScript("OnMouseUp", function()
3037 -- Save frame positions
3038 SaveAllFrames()
3039 end)
3040
3041 dragframe.t = dragframe:CreateTexture()
3042 dragframe.t:SetAllPoints()
3043 dragframe.t:SetColorTexture(0.0, 0.5, 1.0, 0.5)
3044 dragframe.t:SetAlpha(0.5)
3045
3046 dragframe.f = dragframe:CreateFontString(nil, 'ARTWORK', 'GameFontNormalLarge')
3047 dragframe.f:SetPoint('CENTER', 0, 0)
3048
3049 -- Add titles
3050 if realframe:GetName() == "PlayerFrame" then dragframe.f:SetText(L["Player"]) end
3051 if realframe:GetName() == "TargetFrame" then dragframe.f:SetText(L["Target"]) end
3052 if realframe:GetName() == "MirrorTimer1" then dragframe.f:SetText(L["Timer"]) end
3053 if realframe:GetName() == "LeaPlusTopCenterContainerHolder" then dragframe.f:SetText(L["Widget"] .. "|n" .. L["Top Center"]) end
3054 if realframe:GetName() == "BuffFrame" then dragframe.f:SetText(L["Buffs"]) end
3055 return LeaPlusLC[dragframe]
3056
3057 end
3058
3059 for k,v in pairs(FrameTable) do
3060 LeaPlusLC[k] = LeaPlusMakeDrag(k,v)
3061 end
3062
3063 -- Set frame scales
3064 for k,v in pairs(FrameTable) do
3065 local vf = v:GetName()
3066 _G[vf]:SetScale(LeaPlusDB["Frames"][vf]["Scale"])
3067 LeaPlusLC[k]:SetScale(LeaPlusDB["Frames"][vf]["Scale"])
3068 end
3069 ComboFrame:SetScale(LeaPlusDB["Frames"]["TargetFrame"]["Scale"])
3070 TemporaryEnchantFrame:SetScale(LeaPlusDB["Frames"]["BuffFrame"]["Scale"])
3071 UIWidgetTopCenterContainerFrame:SetScale(LeaPlusDB["Frames"]["LeaPlusTopCenterContainerHolder"]["Scale"])
3072 LeaPlusTopCenterContainerHolder:SetScale(LeaPlusDB["Frames"]["LeaPlusTopCenterContainerHolder"]["Scale"])
3073
3074 -- Load defaults first then overwrite with saved values if they exist
3075 LeaPlusFramesDefaults()
3076 if LeaPlusDB["Frames"] then
3077 for k,v in pairs(FrameTable) do
3078 local vf = v:GetName()
3079 if LeaPlusDB["Frames"][vf] then
3080 if LeaPlusDB["Frames"][vf]["Point"] and LeaPlusDB["Frames"][vf]["Relative"] and LeaPlusDB["Frames"][vf]["XOffset"] and LeaPlusDB["Frames"][vf]["YOffset"] then
3081 LeaPlusFramesSaveCache(vf)
3082 _G[vf]:SetMovable(true)
3083 _G[vf]:ClearAllPoints()
3084 _G[vf]:SetPoint(LeaPlusDB["Frames"][vf]["Point"], UIParent, LeaPlusDB["Frames"][vf]["Relative"], LeaPlusDB["Frames"][vf]["XOffset"], LeaPlusDB["Frames"][vf]["YOffset"])
3085 end
3086 end
3087 end
3088 end
3089
3090 -- Prevent changes to buff frame position
3091 hooksecurefunc(BuffFrame, "SetPoint", function()
3092 if LeaPlusDB["Frames"]["BuffFrame"]["Point"] and LeaPlusDB["Frames"]["BuffFrame"]["Relative"] and LeaPlusDB["Frames"]["BuffFrame"]["XOffset"] and LeaPlusDB["Frames"]["BuffFrame"]["YOffset"] then
3093 BuffFrame:SetMovable(true)
3094 BuffFrame:ClearAllPoints()
3095 buffSetPos(BuffFrame, LeaPlusDB["Frames"]["BuffFrame"]["Point"], UIParent, LeaPlusDB["Frames"]["BuffFrame"]["Relative"], LeaPlusDB["Frames"]["BuffFrame"]["XOffset"], LeaPlusDB["Frames"]["BuffFrame"]["YOffset"])
3096 end
3097 end)
3098
3099 -- Add move button
3100 LeaPlusCB["MoveFramesButton"]:SetScript("OnClick", function()
3101 if LeaPlusLC:PlayerInCombat() then
3102 return
3103 else
3104 if IsShiftKeyDown() and IsControlKeyDown() then
3105 -- Preset profile
3106 LeaFramesSetPos(PlayerFrame , "TOPLEFT" , UIParent, "TOPLEFT" , "-35" , "-14")
3107 LeaFramesSetPos(TargetFrame , "TOPLEFT" , UIParent, "TOPLEFT" , "190" , "-14")
3108 LeaFramesSetPos(MirrorTimer1 , "TOP" , UIParent, "TOP" , "0" , "-120")
3109 LeaFramesSetPos(LeaPlusTopCenterContainerHolder , "TOP" , UIParent, "TOP" , "0" , "-432")
3110 LeaFramesSetPos(BuffFrame , "TOPRIGHT", UIParent, "TOPRIGHT" , "-271" , "0")
3111 -- Player
3112 LeaPlusDB["Frames"]["PlayerFrame"]["Scale"] = 1.20
3113 PlayerFrame:SetScale(LeaPlusDB["Frames"]["PlayerFrame"]["Scale"])
3114 LeaPlusLC["DragPlayerFrame"]:SetScale(LeaPlusDB["Frames"]["PlayerFrame"]["Scale"])
3115 -- Target
3116 LeaPlusDB["Frames"]["TargetFrame"]["Scale"] = 1.20
3117 TargetFrame:SetScale(LeaPlusDB["Frames"]["TargetFrame"]["Scale"])
3118 LeaPlusLC["DragTargetFrame"]:SetScale(LeaPlusDB["Frames"]["TargetFrame"]["Scale"])
3119 -- LeaPlusTopCenterContainerHolder
3120 LeaPlusDB["Frames"]["LeaPlusTopCenterContainerHolder"]["Scale"] = 1.25
3121 UIWidgetTopCenterContainerFrame:SetScale(LeaPlusDB["Frames"]["LeaPlusTopCenterContainerHolder"]["Scale"])
3122 LeaPlusTopCenterContainerHolder:SetScale(LeaPlusDB["Frames"]["LeaPlusTopCenterContainerHolder"]["Scale"])
3123 LeaPlusLC["DragLeaPlusTopCenterContainerHolder"]:SetScale(LeaPlusDB["Frames"]["LeaPlusTopCenterContainerHolder"]["Scale"])
3124 -- Buff
3125 LeaPlusDB["Frames"]["BuffFrame"]["Scale"] = 0.80
3126 BuffFrame:SetScale(LeaPlusDB["Frames"]["BuffFrame"]["Scale"])
3127 LeaPlusLC["DragBuffFrame"]:SetScale(LeaPlusDB["Frames"]["BuffFrame"]["Scale"])
3128 -- Set the slider to the selected frame (if there is one)
3129 if currentframe then LeaPlusCB["FrameScale"]:SetValue(LeaPlusDB["Frames"][currentframe]["Scale"]); end
3130 -- Save locations
3131 for k,v in pairs(FrameTable) do
3132 local vf = v:GetName()
3133 LeaPlusDB["Frames"][vf]["Point"], void, LeaPlusDB["Frames"][vf]["Relative"], LeaPlusDB["Frames"][vf]["XOffset"], LeaPlusDB["Frames"][vf]["YOffset"] = _G[vf]:GetPoint()
3134 LeaPlusFramesSaveCache(vf)
3135 end
3136 else
3137 -- Show mover frame
3138 SideFrames:Show()
3139 LeaPlusLC:HideFrames()
3140
3141 -- Find out if the UI has a non-standard scale
3142 if GetCVar("useuiscale") == "1" then
3143 LeaPlusLC["gscale"] = GetCVar("uiscale")
3144 else
3145 LeaPlusLC["gscale"] = 1
3146 end
3147
3148 -- Set all scaled sizes
3149 for k,v in pairs(FrameTable) do
3150 LeaPlusLC[k]:SetWidth(v:GetWidth() * LeaPlusLC["gscale"])
3151 LeaPlusLC[k]:SetHeight(v:GetHeight() * LeaPlusLC["gscale"])
3152 end
3153
3154 -- Set specific scaled sizes for stubborn frames
3155 LeaPlusLC["DragMirrorTimer1"]:SetSize(206 * LeaPlusLC["gscale"], 50 * LeaPlusLC["gscale"]);
3156 LeaPlusLC["DragLeaPlusTopCenterContainerHolder"]:SetSize(160 * LeaPlusLC["gscale"], 79 * LeaPlusLC["gscale"]);
3157 LeaPlusLC["DragBuffFrame"]:SetSize(280 * LeaPlusLC["gscale"], 225 * LeaPlusLC["gscale"]);
3158 end
3159 end
3160 end)
3161
3162 end
3163
3164 ----------------------------------------------------------------------
3165 -- Hide chat buttons
3166 ----------------------------------------------------------------------
3167
3168 if LeaPlusLC["NoChatButtons"] == "On" then
3169
3170 -- Create hidden frame to store unwanted frames (more efficient than creating functions)
3171 local tframe = CreateFrame("FRAME")
3172 tframe:Hide()
3173
3174 -- Function to enable mouse scrolling with CTRL and SHIFT key modifiers
3175 local function AddMouseScroll(chtfrm)
3176 if _G[chtfrm] then
3177 _G[chtfrm]:SetScript("OnMouseWheel", function(self, direction)
3178 if direction == 1 then
3179 if IsControlKeyDown() then
3180 self:ScrollToTop()
3181 elseif IsShiftKeyDown() then
3182 self:PageUp()
3183 else
3184 self:ScrollUp()
3185 end
3186 else
3187 if IsControlKeyDown() then
3188 self:ScrollToBottom()
3189 elseif IsShiftKeyDown() then
3190 self:PageDown()
3191 else
3192 self:ScrollDown()
3193 end
3194 end
3195 end)
3196 _G[chtfrm]:EnableMouseWheel(true)
3197 end
3198 end
3199
3200 -- Function to hide chat buttons
3201 local function HideButtons(chtfrm)
3202 _G[chtfrm .. "ButtonFrameUpButton"]:SetParent(tframe)
3203 _G[chtfrm .. "ButtonFrameDownButton"]:SetParent(tframe)
3204 _G[chtfrm .. "ButtonFrameMinimizeButton"]:SetParent(tframe)
3205 _G[chtfrm .. "ButtonFrameUpButton"]:Hide();
3206 _G[chtfrm .. "ButtonFrameDownButton"]:Hide();
3207 _G[chtfrm .. "ButtonFrameMinimizeButton"]:Hide();
3208 _G[chtfrm .. "ButtonFrame"]:SetSize(0.1,0.1)
3209 end
3210
3211 -- Function to highlight chat tabs and click to scroll to bottom
3212 local function HighlightTabs(chtfrm)
3213 -- Set position of bottom button
3214 _G[chtfrm .. "ButtonFrameBottomButtonFlash"]:SetTexture("Interface/BUTTONS/GRADBLUE.png")
3215 _G[chtfrm .. "ButtonFrameBottomButton"]:ClearAllPoints()
3216 _G[chtfrm .. "ButtonFrameBottomButton"]:SetPoint("BOTTOM",_G[chtfrm .. "Tab"],0,-6)
3217 _G[chtfrm .. "ButtonFrameBottomButton"]:Show()
3218 _G[chtfrm .. "ButtonFrameBottomButtonFlash"]:SetAlpha(0.5)
3219 _G[chtfrm .. "ButtonFrameBottomButton"]:SetWidth(_G[chtfrm .. "Tab"]:GetWidth()-10)
3220 _G[chtfrm .. "ButtonFrameBottomButton"]:SetHeight(24)
3221
3222 -- Resize bottom button according to tab size
3223 _G[chtfrm .. "Tab"]:SetScript("OnSizeChanged", function()
3224 for j = 1, 50 do
3225 -- Resize bottom button to tab width
3226 if _G["ChatFrame" .. j .. "ButtonFrameBottomButton"] then
3227 _G["ChatFrame" .. j .. "ButtonFrameBottomButton"]:SetWidth(_G["ChatFrame" .. j .. "Tab"]:GetWidth()-10)
3228 end
3229 end
3230 -- If combat log is hidden, resize it's bottom button
3231 if LeaPlusLC["NoCombatLogTab"] == "On" then
3232 if _G["ChatFrame2ButtonFrameBottomButton"] then
3233 -- Resize combat log bottom button
3234 _G["ChatFrame2ButtonFrameBottomButton"]:SetWidth(0.1);
3235 end
3236 end
3237 end)
3238
3239 -- Remove click from the bottom button
3240 _G[chtfrm .. "ButtonFrameBottomButton"]:SetScript("OnClick", nil)
3241
3242 -- Remove textures
3243 _G[chtfrm .. "ButtonFrameBottomButton"]:SetNormalTexture("")
3244 _G[chtfrm .. "ButtonFrameBottomButton"]:SetHighlightTexture("")
3245 _G[chtfrm .. "ButtonFrameBottomButton"]:SetPushedTexture("")
3246
3247 -- Always scroll to bottom when clicking a tab
3248 _G[chtfrm .. "Tab"]:HookScript("OnClick", function(self,arg1)
3249 if arg1 == "LeftButton" then
3250 _G[chtfrm]:ScrollToBottom();
3251 end
3252 end)
3253
3254 end
3255
3256 -- Hide chat menu buttons
3257 ChatFrameMenuButton:SetParent(tframe)
3258 ChatFrameChannelButton:SetParent(tframe)
3259
3260 -- Set options for normal and existing chat frames
3261 for i = 1, 50 do
3262 if _G["ChatFrame" .. i] then
3263 AddMouseScroll("ChatFrame" .. i);
3264 HideButtons("ChatFrame" .. i);
3265 HighlightTabs("ChatFrame" .. i)
3266 end
3267 end
3268
3269 -- Do the functions above for temporary chat frames
3270 hooksecurefunc("FCF_OpenTemporaryWindow", function(chatType)
3271 local cf = FCF_GetCurrentChatFrame():GetName() or nil
3272 if cf then
3273 -- Set options for temporary frame
3274 AddMouseScroll(cf)
3275 HideButtons(cf)
3276 HighlightTabs(cf)
3277 -- Resize flashing alert to match tab width
3278 _G[cf .. "Tab"]:SetScript("OnSizeChanged", function()
3279 _G[cf .. "ButtonFrameBottomButton"]:SetWidth(_G[cf .. "Tab"]:GetWidth()-10)
3280 end)
3281 end
3282 end)
3283
3284 end
3285
3286 ----------------------------------------------------------------------
3287 -- Recent chat window
3288 ----------------------------------------------------------------------
3289
3290 if LeaPlusLC["RecentChatWindow"] == "On" then
3291
3292 -- Create recent chat frame (not parenting to UIParent due to editbox scaling issue)
3293 local editFrame = CreateFrame("ScrollFrame", nil, nil, "InputScrollFrameTemplate")
3294
3295 -- Toggle frame with UIParent
3296 local hideUI = false
3297 local function HideRecentChatFrame() if editFrame:IsShown() then hideUI = true editFrame:Hide() end end
3298 local function ShowRecentChatFrame() if hideUI and not PetBattleFrame:IsShown() then editFrame:Show() hideUI = false end end
3299 hooksecurefunc(UIParent, "Hide", HideRecentChatFrame)
3300 hooksecurefunc(UIParent, "Show", ShowRecentChatFrame)
3301
3302 -- Set frame parameters
3303 editFrame:ClearAllPoints()
3304 editFrame:SetPoint("BOTTOM", 0, 130)
3305 editFrame:SetSize(470, 170)
3306 editFrame:SetFrameStrata("MEDIUM")
3307 editFrame:SetToplevel(true)
3308 editFrame:Hide()
3309 editFrame.CharCount:Hide()
3310
3311 -- Add background color
3312 editFrame.t = editFrame:CreateTexture(nil, "BACKGROUND")
3313 editFrame.t:SetAllPoints()
3314 editFrame.t:SetColorTexture(0.00, 0.00, 0.0, 0.6)
3315
3316 -- Set textures
3317 editFrame.LeftTex:SetTexture(editFrame.RightTex:GetTexture()); editFrame.LeftTex:SetTexCoord(1, 0, 0, 1)
3318 editFrame.BottomTex:SetTexture(editFrame.TopTex:GetTexture()); editFrame.BottomTex:SetTexCoord(0, 1, 1, 0)
3319 editFrame.BottomRightTex:SetTexture(editFrame.TopRightTex:GetTexture()); editFrame.BottomRightTex:SetTexCoord(0, 1, 1, 0)
3320 editFrame.BottomLeftTex:SetTexture(editFrame.TopRightTex:GetTexture()); editFrame.BottomLeftTex:SetTexCoord(1, 0, 1, 0)
3321 editFrame.TopLeftTex:SetTexture(editFrame.TopRightTex:GetTexture()); editFrame.TopLeftTex:SetTexCoord(1, 0, 0, 1)
3322
3323 -- Create editbox
3324 local editBox = editFrame.EditBox
3325 editBox:SetAltArrowKeyMode(false)
3326 editBox:SetTextInsets(4, 4, 4, 4)
3327 editBox:SetWidth(editFrame:GetWidth() - 30)
3328
3329 -- Close frame with right-click of editframe or editbox
3330 local function CloseRecentChatWindow()
3331 editBox:SetText("")
3332 editBox:ClearFocus()
3333 editFrame:Hide()
3334 end
3335
3336 editFrame:SetScript("OnMouseDown", function(self, btn)
3337 if btn == "RightButton" then CloseRecentChatWindow() end
3338 end)
3339
3340 editBox:SetScript("OnMouseDown", function(self, btn)
3341 if btn == "RightButton" then CloseRecentChatWindow() end
3342 end)
3343
3344 -- Disable text changes while still allowing editing controls to work
3345 editBox:EnableKeyboard(false)
3346 editBox:SetScript("OnKeyDown", function() end)
3347
3348 --- Clear highlighted text if escape key is pressed
3349 editBox:HookScript("OnEscapePressed", function()
3350 editBox:HighlightText(0, 0)
3351 editBox:ClearFocus()
3352 end)
3353
3354 -- Clear highlighted text and clear focus if enter key is pressed
3355 editBox:SetScript("OnEnterPressed", function()
3356 editBox:HighlightText(0, 0)
3357 editBox:ClearFocus()
3358 end)
3359
3360 -- Populate recent chat frame with chat messages
3361 local function ShowChatbox(chtfrm)
3362 editBox:SetText("")
3363 local NumMsg = chtfrm:GetNumMessages()
3364 local StartMsg = 1
3365 if NumMsg > 128 then StartMsg = NumMsg - 127 end
3366 local totalMsgCount = 0
3367 for iMsg = StartMsg, NumMsg do
3368 local chatMessage = chtfrm:GetMessageInfo(iMsg)
3369 if chatMessage then
3370 --chatMessage = gsub(chatMessage, "|T.-|t", "") -- Remove textures
3371 --chatMessage = gsub(chatMessage, "{.-}", "") -- Remove ellipsis
3372 editBox:Insert(chatMessage .. "|n")
3373 end
3374 totalMsgCount = totalMsgCount + 1
3375 end
3376 if totalMsgCount == 1 then
3377 editBox:Insert("|cff88aabb" .. totalMsgCount .. " " .. L["message shown."] .. " ")
3378 else
3379 editBox:Insert("|cff88aabb" .. totalMsgCount .. " " .. L["messages shown."] .. " ")
3380 end
3381 editBox:Insert(L["Right-click to close."])
3382 editFrame:SetVerticalScroll(0)
3383 C_Timer.After(0.1, function() editFrame.ScrollBar.ScrollDownButton:Click() end)
3384 editFrame:Show()
3385 editBox:ClearFocus()
3386 end
3387
3388 -- Hook normal chat frame tab clicks
3389 for i = 1, 50 do
3390 if _G["ChatFrame" .. i] then
3391 _G["ChatFrame" .. i .. "Tab"]:HookScript("OnClick", function()
3392 if IsControlKeyDown() then
3393 ShowChatbox(_G["ChatFrame" .. i])
3394 end
3395 end)
3396 end
3397 end
3398
3399 -- Hook temporary chat frame tab clicks
3400 hooksecurefunc("FCF_OpenTemporaryWindow", function()
3401 local cf = FCF_GetCurrentChatFrame():GetName() or nil
3402 if cf then
3403 _G[cf .. "Tab"]:HookScript("OnClick", function()
3404 if IsControlKeyDown() then
3405 ShowChatbox(_G[cf])
3406 end
3407 end)
3408 end
3409 end)
3410
3411 end
3412
3413 ----------------------------------------------------------------------
3414 -- Show cooldowns
3415 ----------------------------------------------------------------------
3416
3417 if LeaPlusLC["ShowCooldowns"] == "On" then
3418
3419 -- Create main table structure in saved variables if it doesn't exist
3420 if LeaPlusDB["Cooldowns"] == nil then
3421 LeaPlusDB["Cooldowns"] = {}
3422 end
3423
3424 -- Create class tables if they don't exist
3425 local classList = {"WARRIOR", "PALADIN", "HUNTER", "SHAMAN", "ROGUE", "DRUID", "MAGE", "WARLOCK", "PRIEST"}
3426 for index = 1, #classList do
3427 if LeaPlusDB["Cooldowns"][classList[index]] == nil then
3428 LeaPlusDB["Cooldowns"][classList[index]] = {}
3429 end
3430 end
3431
3432 -- Get current class
3433 local PlayerClass = select(2, UnitClass("player"))
3434 local activeSpec = 1 -- Fixed to 1 for Classic
3435
3436 -- Create local tables to store cooldown frames and editboxes
3437 local icon = {} -- Used to store cooldown frames
3438 local SpellEB = {} -- Used to store editbox values
3439 local iCount = 5 -- Number of cooldowns
3440
3441 -- Create cooldown frames
3442 for i = 1, iCount do
3443
3444 -- Create cooldown frame
3445 icon[i] = CreateFrame("Frame", nil, UIParent)
3446 icon[i]:SetFrameStrata("BACKGROUND")
3447 icon[i]:SetWidth(20)
3448 icon[i]:SetHeight(20)
3449
3450 -- Create cooldown icon
3451 icon[i].c = CreateFrame("Cooldown", nil, icon[i], "CooldownFrameTemplate")
3452 icon[i].c:SetAllPoints()
3453 icon[i].c:SetReverse(true)
3454
3455 -- Create blank texture (will be assigned a cooldown texture later)
3456 icon[i].t = icon[i]:CreateTexture(nil,"BACKGROUND")
3457 icon[i].t:SetAllPoints()
3458
3459 -- Show icon above target frame and set initial scale
3460 icon[i]:ClearAllPoints()
3461 icon[i]:SetPoint("TOPLEFT", TargetFrame, "TOPLEFT", 6 + (22 * (i - 1)), 5)
3462 icon[i]:SetScale(TargetFrame:GetScale())
3463
3464 -- Show tooltip
3465 icon[i]:SetScript("OnEnter", function(self)
3466 GameTooltip:SetOwner(self, "ANCHOR_BOTTOMRIGHT", 15, -25)
3467 GameTooltip:SetText(GetSpellInfo(LeaPlusCB["Spell" .. i]:GetText()))
3468 end)
3469
3470 -- Hide tooltip
3471 icon[i]:SetScript("OnLeave", GameTooltip_Hide)
3472
3473 end
3474
3475 -- Change cooldown icon scale when target frame scale changes
3476 TargetFrame:HookScript("OnSizeChanged", function()
3477 for i = 1, iCount do
3478 icon[i]:SetScale(TargetFrame:GetScale())
3479 end
3480 end)
3481
3482 -- Function to show cooldown textures in the cooldown frames (run when icons are loaded or changed)
3483 local function ShowIcon(i, id, owner)
3484
3485 local void
3486
3487 -- Get spell information
3488 local spell, void, path = GetSpellInfo(id)
3489 if spell and path then
3490
3491 -- Set icon texture to the spell texture
3492 icon[i].t:SetTexture(path)
3493
3494 -- Set top level and raise frame strata (ensures tooltips show properly)
3495 icon[i]:SetToplevel(true)
3496 icon[i]:SetFrameStrata("LOW")
3497
3498 -- Handle events
3499 icon[i]:RegisterUnitEvent("UNIT_AURA", owner)
3500 icon[i]:RegisterUnitEvent("UNIT_PET", "player")
3501 icon[i]:SetScript("OnEvent", function(self, event, arg1)
3502
3503 -- If pet was dismissed (or otherwise disappears such as when flying), hide pet cooldowns
3504 if event == "UNIT_PET" then
3505 if not UnitExists("pet") then
3506 if LeaPlusDB["Cooldowns"][PlayerClass]["S" .. activeSpec .. "R" .. i .. "Pet"] then
3507 icon[i]:Hide()
3508 end
3509 end
3510
3511 -- Ensure cooldown belongs to the owner we are watching (player or pet)
3512 elseif arg1 == owner then
3513
3514 -- Hide the cooldown frame (required for cooldowns to disappear after the duration)
3515 icon[i]:Hide()
3516
3517 -- If buff matches cooldown we want, start the cooldown
3518 for q = 1, 40 do
3519 local void, void, void, void, length, expire, void, void, void, spellID = UnitBuff(owner, q)
3520 if spellID and id == spellID then
3521 icon[i]:Show()
3522 local start = expire - length
3523 CooldownFrame_Set(icon[i].c, start, length, 1)
3524 end
3525 end
3526
3527 end
3528 end)
3529
3530 else
3531
3532 -- Spell does not exist so stop watching it
3533 icon[i]:SetScript("OnEvent", nil)
3534 icon[i]:Hide()
3535
3536 end
3537
3538 end
3539
3540 -- Create configuration panel
3541 local CooldownPanel = LeaPlusLC:CreatePanel("Cooldowns", "CooldownPanel")
3542
3543 -- Function to refresh the editbox tooltip with the spell name
3544 local function RefSpellTip(self,elapsed)
3545 local spellinfo, void, icon = GetSpellInfo(self:GetText())
3546 if spellinfo and spellinfo ~= "" and icon ~= "" then
3547 GameTooltip:SetOwner(self, "ANCHOR_NONE")
3548 GameTooltip:ClearAllPoints()
3549 GameTooltip:SetPoint("RIGHT", self, "LEFT", -10, 0)
3550 GameTooltip:SetText("|T" .. icon .. ":0|t " .. spellinfo, nil, nil, nil, nil, true)
3551 else
3552 GameTooltip:Hide()
3553 end
3554 end
3555
3556 -- Function to create spell ID editboxes and pet checkboxes
3557 local function MakeSpellEB(num, x, y, tab, shifttab)
3558
3559 -- Create editbox for spell ID
3560 SpellEB[num] = LeaPlusLC:CreateEditBox("Spell" .. num, CooldownPanel, 70, 6, "TOPLEFT", x, y - 20, "Spell" .. tab, "Spell" .. shifttab)
3561 SpellEB[num]:SetNumeric(true)
3562
3563 -- Set initial value (for current spec)
3564 SpellEB[num]:SetText(LeaPlusDB["Cooldowns"][PlayerClass]["S" .. activeSpec .. "R" .. num .. "Idn"] or "")
3565
3566 -- Refresh tooltip when mouse is hovering over the editbox
3567 SpellEB[num]:SetScript("OnEnter", function()
3568 SpellEB[num]:SetScript("OnUpdate", RefSpellTip)
3569 end)
3570 SpellEB[num]:SetScript("OnLeave", function()
3571 SpellEB[num]:SetScript("OnUpdate", nil)
3572 GameTooltip:Hide()
3573 end)
3574
3575 -- Create checkbox for pet cooldown
3576 LeaPlusLC:MakeCB(CooldownPanel, "Spell" .. num .."Pet", "", 462, y - 20, false, "")
3577 LeaPlusCB["Spell" .. num .."Pet"]:SetHitRectInsets(0, 0, 0, 0)
3578
3579 end
3580
3581 -- Add titles
3582 LeaPlusLC:MakeTx(CooldownPanel, "Spell ID", 384, -92)
3583 LeaPlusLC:MakeTx(CooldownPanel, "Pet", 462, -92)
3584
3585 -- Add editboxes and checkboxes
3586 MakeSpellEB(1, 386, -92, "2", "5")
3587 MakeSpellEB(2, 386, -122, "3", "1")
3588 MakeSpellEB(3, 386, -152, "4", "2")
3589 MakeSpellEB(4, 386, -182, "5", "3")
3590 MakeSpellEB(5, 386, -212, "1", "4")
3591
3592 -- Add checkboxes
3593 LeaPlusLC:MakeTx(CooldownPanel, "Settings", 16, -72)
3594 LeaPlusLC:MakeCB(CooldownPanel, "ShowCooldownID", "Show the spell ID in buff icon tooltips", 16, -92, false, "If checked, spell IDs will be shown in buff icon tooltips located in the buff frame and under the target frame.");
3595 LeaPlusLC:MakeCB(CooldownPanel, "NoCooldownDuration", "Hide cooldown duration numbers (if enabled)", 16, -112, false, "If checked, cooldown duration numbers will not be shown over the cooldowns.|n|nIf unchecked, cooldown duration numbers will be shown over the cooldowns if they are enabled in the game options panel ('ActionBars' menu).")
3596
3597 -- Function to save the panel control settings and refresh the cooldown icons
3598 local function SavePanelControls()
3599 for i = 1, iCount do
3600
3601 -- Refresh the cooldown texture
3602 icon[i].c:SetCooldown(0,0)
3603
3604 -- Save control states to globals
3605 LeaPlusDB["Cooldowns"][PlayerClass]["S" .. activeSpec .. "R" .. i .. "Idn"] = SpellEB[i]:GetText()
3606 LeaPlusDB["Cooldowns"][PlayerClass]["S" .. activeSpec .. "R" .. i .. "Pet"] = LeaPlusCB["Spell" .. i .."Pet"]:GetChecked()
3607
3608 -- Set cooldowns
3609 if LeaPlusCB["Spell" .. i .."Pet"]:GetChecked() then
3610 ShowIcon(i, tonumber(SpellEB[i]:GetText()), "pet")
3611 else
3612 ShowIcon(i, tonumber(SpellEB[i]:GetText()), "player")
3613 end
3614
3615 -- Show or hide cooldown duration
3616 if LeaPlusLC["NoCooldownDuration"] == "On" then
3617 icon[i].c:SetHideCountdownNumbers(true)
3618 else
3619 icon[i].c:SetHideCountdownNumbers(false)
3620 end
3621
3622 -- Show or hide cooldown icons depending on current buffs
3623 local newowner
3624 local newspell = tonumber(SpellEB[i]:GetText())
3625
3626 if newspell then
3627 if LeaPlusDB["Cooldowns"][PlayerClass]["S" .. activeSpec .. "R" .. i .. "Pet"] then
3628 newowner = "pet"
3629 else
3630 newowner = "player"
3631 end
3632 -- Hide cooldown icon
3633 icon[i]:Hide()
3634
3635 -- If buff matches spell we want, show cooldown icon
3636 for q = 1, 40 do
3637 local void, void, void, void, length, expire, void, void, void, spellID = UnitBuff(newowner, q)
3638 if spellID and newspell == spellID then
3639 icon[i]:Show()
3640 -- Set the cooldown to the buff cooldown
3641 CooldownFrame_Set(icon[i].c, expire - length, length, 1)
3642 end
3643 end
3644 end
3645
3646 end
3647
3648 end
3649
3650 -- Update cooldown icons when checkboxes are clicked
3651 LeaPlusCB["NoCooldownDuration"]:HookScript("OnClick", SavePanelControls)
3652
3653 -- Help button tooltip
3654 CooldownPanel.h.tiptext = L["Enter the spell IDs for the cooldown icons that you want to see.|n|nIf a cooldown icon normally appears under the pet frame, check the pet checkbox.|n|nCooldown icons are saved to your class."]
3655
3656 -- Back button handler
3657 CooldownPanel.b:SetScript("OnClick", function()
3658 CooldownPanel:Hide(); LeaPlusLC["PageF"]:Show(); LeaPlusLC["Page5"]:Show()
3659 return
3660 end)
3661
3662 -- Reset button handler
3663 CooldownPanel.r:SetScript("OnClick", function()
3664 -- Reset the checkboxes
3665 LeaPlusLC["ShowCooldownID"] = "On"
3666 LeaPlusLC["NoCooldownDuration"] = "On"
3667 for i = 1, iCount do
3668 -- Reset the panel controls
3669 SpellEB[i]:SetText("");
3670 LeaPlusDB["Cooldowns"][PlayerClass]["S" .. activeSpec .. "R" .. i .. "Pet"] = false
3671 -- Hide cooldowns and clear scripts
3672 icon[i]:Hide()
3673 icon[i]:SetScript("OnEvent", nil)
3674 end
3675 CooldownPanel:Hide(); CooldownPanel:Show()
3676 end)
3677
3678 -- Save settings when changed
3679 for i = 1, iCount do
3680 -- Set initial checkbox states
3681 LeaPlusCB["Spell" .. i .."Pet"]:SetChecked(LeaPlusDB["Cooldowns"][PlayerClass]["S" .. activeSpec .. "R" .. i .. "Pet"])
3682 -- Set checkbox states when shown
3683 LeaPlusCB["Spell" .. i .."Pet"]:SetScript("OnShow", function()
3684 LeaPlusCB["Spell" .. i .."Pet"]:SetChecked(LeaPlusDB["Cooldowns"][PlayerClass]["S" .. activeSpec .. "R" .. i .. "Pet"])
3685 end)
3686 -- Set states when changed
3687 SpellEB[i]:SetScript("OnTextChanged", SavePanelControls)
3688 LeaPlusCB["Spell" .. i .."Pet"]:SetScript("OnClick", SavePanelControls)
3689 end
3690
3691 -- Show cooldowns on startup
3692 SavePanelControls()
3693
3694 -- Show panel when configuration button is clicked
3695 LeaPlusCB["CooldownsButton"]:SetScript("OnClick", function()
3696 if IsShiftKeyDown() and IsControlKeyDown() then
3697 -- No preset profile
3698 else
3699 -- Show panel
3700 CooldownPanel:Show()
3701 LeaPlusLC:HideFrames()
3702 end
3703 end)
3704
3705 -- Create class tag banner fontstring
3706 local classTagBanner = CooldownPanel:CreateFontString(nil, 'ARTWORK', 'GameFontNormal')
3707 local myClassName = UnitClass("player")
3708 classTagBanner:SetPoint("TOPLEFT", 384, -72)
3709 classTagBanner:SetText(myClassName)
3710
3711 -- Function to show spell ID in tooltips
3712 local function CooldownIDFunc(unit, target, index)
3713 if LeaPlusLC["ShowCooldownID"] == "On" then
3714 local spellid = select(10, UnitAura(target, index))
3715 if spellid then
3716 GameTooltip:AddLine(L["Spell ID"] .. ": " .. spellid)
3717 GameTooltip:Show()
3718 end
3719 end
3720 end
3721
3722 -- Add spell ID to tooltip when buff frame buffs are hovered
3723 hooksecurefunc(GameTooltip, 'SetUnitAura', CooldownIDFunc)
3724
3725 -- Add spell ID to tooltip when target frame buffs are hovered
3726 hooksecurefunc(GameTooltip, 'SetUnitBuff', CooldownIDFunc)
3727
3728 end
3729
3730 ----------------------------------------------------------------------
3731 -- Combat plates
3732 ----------------------------------------------------------------------
3733
3734 if LeaPlusLC["CombatPlates"] == "On" then
3735
3736 -- Toggle nameplates with combat
3737 local f = CreateFrame("Frame")
3738 f:RegisterEvent("PLAYER_REGEN_DISABLED")
3739 f:RegisterEvent("PLAYER_REGEN_ENABLED")
3740 f:SetScript("OnEvent", function(self, event)
3741 SetCVar("nameplateShowEnemies", event == "PLAYER_REGEN_DISABLED" and 1 or 0)
3742 end)
3743
3744 -- Run combat check on startup
3745 SetCVar("nameplateShowEnemies", UnitAffectingCombat("player") and 1 or 0)
3746
3747 end
3748
3749 ----------------------------------------------------------------------
3750 -- Manage tooltip
3751 ----------------------------------------------------------------------
3752
3753 if LeaPlusLC["TipModEnable"] == "On" then
3754
3755 ----------------------------------------------------------------------
3756 -- Position the tooltip
3757 ----------------------------------------------------------------------
3758
3759 -- Position general tooltip
3760 hooksecurefunc("GameTooltip_SetDefaultAnchor", function(tooltip, parent)
3761 if LeaPlusLC["TipMoveTip"] == "On" then
3762 if (not tooltip or not parent) then
3763 return
3764 end
3765 local a,b,c,d,e = tooltip:GetPoint()
3766 if a ~= "BOTTOMRIGHT" or c ~= "BOTTOMRIGHT" then
3767 tooltip:ClearAllPoints()
3768 end
3769 tooltip:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", LeaPlusLC["TipOffsetX"], LeaPlusLC["TipOffsetY"]);
3770 end
3771 end)
3772
3773 ----------------------------------------------------------------------
3774 -- Tooltip Configuration
3775 ----------------------------------------------------------------------
3776
3777 local LT = {}
3778
3779 -- Create locale specific level string
3780 LT["LevelLocale"] = strtrim(strtrim(string.gsub(TOOLTIP_UNIT_LEVEL, "%%s", "")))
3781
3782 -- Tooltip
3783 LT["ColorBlind"] = GetCVar("colorblindMode")
3784
3785 -- Create drag frame
3786 local TipDrag = CreateFrame("Frame", nil, UIParent)
3787 TipDrag:SetToplevel(true);
3788 TipDrag:SetClampedToScreen(false);
3789 TipDrag:SetSize(130, 64);
3790 TipDrag:Hide();
3791 TipDrag:SetFrameStrata("TOOLTIP")
3792 TipDrag:SetMovable(true)
3793 TipDrag:SetBackdropColor(0.0, 0.5, 1.0);
3794 TipDrag:SetBackdrop({
3795 edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
3796 tile = false, tileSize = 0, edgeSize = 16,
3797 insets = { left = 0, right = 0, top = 0, bottom = 0 }});
3798
3799 -- Show text in drag frame
3800 TipDrag.f = TipDrag:CreateFontString(nil, 'ARTWORK', 'GameFontNormalLarge')
3801 TipDrag.f:SetPoint("CENTER", 0, 0)
3802 TipDrag.f:SetText(L["Tooltip"])
3803
3804 -- Create texture
3805 TipDrag.t = TipDrag:CreateTexture();
3806 TipDrag.t:SetAllPoints();
3807 TipDrag.t:SetColorTexture(0.0, 0.5, 1.0, 0.5);
3808 TipDrag.t:SetAlpha(0.5);
3809
3810 ---------------------------------------------------------------------------------------------------------
3811 -- Tooltip movement settings
3812 ---------------------------------------------------------------------------------------------------------
3813
3814 -- Create tooltip customisation side panel
3815 local SideTip = LeaPlusLC:CreatePanel("Tooltip", "SideTip")
3816
3817 -- Add controls
3818 LeaPlusLC:MakeTx(SideTip, "Settings", 16, -72)
3819 LeaPlusLC:MakeCB(SideTip, "TipMoveTip", "Reposition the tooltip", 16, -92, false, "If checked, you will be able to reposition the tooltip.")
3820 LeaPlusLC:MakeCB(SideTip, "TipShowGuild", "Show guild names", 16, -112, false, "If checked, guild names will be shown. Guild ranks will also be shown for players in your guild.")
3821 LeaPlusLC:MakeCB(SideTip, "TipShowTarget", "Show the unit's target", 16, -132, false, "If checked, unit targets will be shown.")
3822 LeaPlusLC:MakeCB(SideTip, "TipBackSimple", "Color the backdrops based on faction", 16, -152, false, "If checked, backdrops will be tinted blue (friendly) or red (hostile).")
3823 LeaPlusLC:MakeCB(SideTip, "TipHideInCombat", "Hide tooltips for world units during combat", 16, -172, false, "If checked, tooltips for world units will be hidden during combat.|n|nYou can hold the shift key down to override this setting.")
3824
3825 LeaPlusLC:MakeTx(SideTip, "Scale", 356, -72)
3826 LeaPlusLC:MakeSL(SideTip, "LeaPlusTipSize", "Drag to set the tooltip scale.", 0.50, 2.00, 0.05, 356, -92, "%.2f")
3827
3828 -- Help button hidden
3829 SideTip.h:Hide()
3830
3831 -- Back button handler
3832 SideTip.b:SetScript("OnClick", function()
3833 SideTip:Hide();
3834 if TipDrag:IsShown() then
3835 TipDrag:Hide();
3836 end
3837 LeaPlusLC["PageF"]:Show();
3838 LeaPlusLC["Page5"]:Show();
3839 return
3840 end)
3841
3842 -- Reset button handler
3843 SideTip.r:SetScript("OnClick", function()
3844 LeaPlusLC["TipMoveTip"] = "On";
3845 LeaPlusLC["TipShowGuild"] = "On";
3846 LeaPlusLC["TipShowTarget"] = "On";
3847 LeaPlusLC["TipBackSimple"] = "Off";
3848 LeaPlusLC["TipHideInCombat"] = "Off";
3849 LeaPlusLC["LeaPlusTipSize"] = 1.00
3850 LeaPlusLC["TipOffsetX"] = -13
3851 LeaPlusLC["TipOffsetY"] = 94
3852 TipDrag:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", LeaPlusLC["TipOffsetX"], LeaPlusLC["TipOffsetY"]);
3853 LeaPlusLC:SetTipScale()
3854 SideTip:Hide(); SideTip:Show();
3855 end)
3856
3857 -- Show tooltip overlay only if reposition checkbox is checked
3858 LeaPlusCB["TipMoveTip"]:HookScript("OnClick", function()
3859 if LeaPlusLC["TipMoveTip"] == "On" then
3860 TipDrag:Show()
3861 else
3862 TipDrag:Hide()
3863 end
3864 end)
3865
3866 -- Show drag frame with configuration panel
3867 SideTip:HookScript("OnShow", function()
3868 if LeaPlusLC["TipMoveTip"] == "On" then
3869 TipDrag:Show()
3870 end
3871 end)
3872 SideTip:HookScript("OnHide", function() TipDrag:Hide() end)
3873
3874 -- Control movement functions
3875 local void, LTax, LTay, LTbx, LTby, LTcx, LTcy
3876 TipDrag:SetScript("OnMouseDown", function(self, btn)
3877 if btn == "LeftButton" then
3878 void, void, void, LTax, LTay = TipDrag:GetPoint()
3879 TipDrag:StartMoving()
3880 void, void, void, LTbx, LTby = TipDrag:GetPoint()
3881 end
3882 end)
3883 TipDrag:SetScript("OnMouseUp", function(self, btn)
3884 if btn == "LeftButton" then
3885 void, void, void, LTcx, LTcy = TipDrag:GetPoint()
3886 TipDrag:StopMovingOrSizing();
3887 LeaPlusLC["TipOffsetX"], LeaPlusLC["TipOffsetY"] = LTcx - LTbx + LTax, LTcy - LTby + LTay
3888 TipDrag:ClearAllPoints()
3889 TipDrag:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", LeaPlusLC["TipOffsetX"], LeaPlusLC["TipOffsetY"])
3890 end
3891 end)
3892
3893 -- Move the tooltip
3894 LeaPlusCB["MoveTooltipButton"]:SetScript("OnClick", function()
3895 if IsShiftKeyDown() and IsControlKeyDown() then
3896 -- Preset profile
3897 LeaPlusLC["TipMoveTip"] = "On";
3898 LeaPlusLC["TipShowGuild"] = "On";
3899 LeaPlusLC["TipShowTarget"] = "On";
3900 LeaPlusLC["TipBackSimple"] = "On";
3901 LeaPlusLC["TipHideInCombat"] = "Off";
3902 LeaPlusLC["LeaPlusTipSize"] = 1.25
3903 LeaPlusLC["TipOffsetX"] = -13
3904 LeaPlusLC["TipOffsetY"] = 94
3905 TipDrag:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", LeaPlusLC["TipOffsetX"], LeaPlusLC["TipOffsetY"]);
3906 LeaPlusLC:SetTipScale()
3907 LeaPlusLC:SetDim();
3908 LeaPlusLC:ReloadCheck();
3909 SideTip:Show(); SideTip:Hide(); -- Needed to update tooltip scale
3910 LeaPlusLC["PageF"]:Hide(); LeaPlusLC["PageF"]:Show();
3911 else
3912 -- Show tooltip configuration panel
3913 LeaPlusLC:HideFrames();
3914 SideTip:Show();
3915
3916 -- Set scale
3917 TipDrag:SetScale(LeaPlusLC["LeaPlusTipSize"])
3918
3919 -- Set position of the drag frame
3920 TipDrag:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", LeaPlusLC["TipOffsetX"], LeaPlusLC["TipOffsetY"])
3921 end
3922
3923 end)
3924
3925 ---------------------------------------------------------------------------------------------------------
3926 -- Tooltip scale settings
3927 ---------------------------------------------------------------------------------------------------------
3928
3929 -- Function to set the tooltip scale
3930 local function SetTipScale()
3931 if LeaPlusLC["TipModEnable"] == "On" then
3932
3933 -- General tooltip
3934 if GameTooltip then GameTooltip:SetScale(LeaPlusLC["LeaPlusTipSize"]) end
3935
3936 -- Friends
3937 if FriendsTooltip then FriendsTooltip:SetScale(LeaPlusLC["LeaPlusTipSize"]) end
3938
3939 -- AutoCompleteBox
3940 if AutoCompleteBox then AutoCompleteBox:SetScale(LeaPlusLC["LeaPlusTipSize"]) end
3941
3942 -- Items (links, comparisons)
3943 if ItemRefTooltip then ItemRefTooltip:SetScale(LeaPlusLC["LeaPlusTipSize"]) end
3944 if ItemRefShoppingTooltip1 then ItemRefShoppingTooltip1:SetScale(LeaPlusLC["LeaPlusTipSize"]) end
3945 if ItemRefShoppingTooltip2 then ItemRefShoppingTooltip2:SetScale(LeaPlusLC["LeaPlusTipSize"]) end
3946 if ShoppingTooltip1 then ShoppingTooltip1:SetScale(LeaPlusLC["LeaPlusTipSize"]) end
3947 if ShoppingTooltip2 then ShoppingTooltip2:SetScale(LeaPlusLC["LeaPlusTipSize"]) end
3948
3949 -- Embedded item tooltip (as used in PVP UI)
3950 if EmbeddedItemTooltip then EmbeddedItemTooltip:SetScale(LeaPlusLC["LeaPlusTipSize"]) end
3951
3952 -- Nameplate tooltip
3953 if NamePlateTooltip then NamePlateTooltip:SetScale(LeaPlusLC["LeaPlusTipSize"]) end
3954
3955 -- Leatrix Plus
3956 TipDrag:SetScale(LeaPlusLC["LeaPlusTipSize"])
3957
3958 -- Set slider formatted text
3959 LeaPlusCB["LeaPlusTipSize"].f:SetFormattedText("%.0f%%", LeaPlusLC["LeaPlusTipSize"] * 100)
3960
3961 end
3962 return
3963 end
3964
3965 -- Give function a file level scope
3966 LeaPlusLC.SetTipScale = SetTipScale
3967
3968 -- Set tooltip scale when slider or checkbox changes and on startup
3969 LeaPlusCB["LeaPlusTipSize"]:HookScript("OnValueChanged", SetTipScale)
3970 SetTipScale()
3971
3972 ---------------------------------------------------------------------------------------------------------
3973 -- Other tooltip code
3974 ---------------------------------------------------------------------------------------------------------
3975
3976 -- Colorblind setting change
3977 TipDrag:RegisterEvent("CVAR_UPDATE");
3978 TipDrag:SetScript("OnEvent", function(self, event, arg1, arg2)
3979 if (arg1 == "USE_COLORBLIND_MODE") then
3980 LT["ColorBlind"] = arg2;
3981 end
3982 end)
3983
3984 -- Store locals
3985 local TipMClass = LOCALIZED_CLASS_NAMES_MALE
3986 local TipFClass = LOCALIZED_CLASS_NAMES_FEMALE
3987
3988 -- Level string
3989 local LevelString, LevelString2
3990 if GameLocale == "ruRU" then
3991 -- Level string for ruRU
3992 LevelString = "уровня"
3993 LevelString2 = "уровень"
3994 else
3995 -- Level string for all other locales
3996 LevelString = string.lower(TOOLTIP_UNIT_LEVEL:gsub("%%s",".+"))
3997 LevelString2 = ""
3998 end
3999
4000 -- Tag locale (code construction from tiplang)
4001 local ttYou, ttLevel, ttBoss, ttElite, ttRare, ttRareElite, ttRareBoss, ttTarget
4002 if GameLocale == "zhCN" then ttYou = "您" ; ttLevel = "等级" ; ttBoss = "首领" ; ttElite = "精英" ; ttRare = "精良" ; ttRareElite = "精良 精英" ; ttRareBoss = "精良 首领" ; ttTarget = "目标"
4003 elseif GameLocale == "zhTW" then ttYou = "您" ; ttLevel = "等級" ; ttBoss = "首領" ; ttElite = "精英" ; ttRare = "精良" ; ttRareElite = "精良 精英" ; ttRareBoss = "精良 首領" ; ttTarget = "目標"
4004 elseif GameLocale == "ruRU" then ttYou = "ВЫ" ; ttLevel = "Уровень" ; ttBoss = "босс" ; ttElite = "элита" ; ttRare = "Редкое" ; ttRareElite = "Редкое элита" ; ttRareBoss = "Редкое босс" ; ttTarget = "Цель"
4005 elseif GameLocale == "koKR" then ttYou = "당신" ; ttLevel = "레벨" ; ttBoss = "우두머리" ; ttElite = "정예" ; ttRare = "희귀" ; ttRareElite = "희귀 정예" ; ttRareBoss = "희귀 우두머리" ; ttTarget = "대상"
4006 elseif GameLocale == "esMX" then ttYou = "TÚ" ; ttLevel = "Nivel" ; ttBoss = "Jefe" ; ttElite = "Élite" ; ttRare = "Raro" ; ttRareElite = "Raro Élite" ; ttRareBoss = "Raro Jefe" ; ttTarget = "Objetivo"
4007 elseif GameLocale == "ptBR" then ttYou = "VOCÊ" ; ttLevel = "Nível" ; ttBoss = "Chefe" ; ttElite = "Elite" ; ttRare = "Raro" ; ttRareElite = "Raro Elite" ; ttRareBoss = "Raro Chefe" ; ttTarget = "Alvo"
4008 elseif GameLocale == "deDE" then ttYou = "SIE" ; ttLevel = "Stufe" ; ttBoss = "Boss" ; ttElite = "Elite" ; ttRare = "Selten" ; ttRareElite = "Selten Elite" ; ttRareBoss = "Selten Boss" ; ttTarget = "Ziel"
4009 elseif GameLocale == "esES" then ttYou = "TÚ" ; ttLevel = "Nivel" ; ttBoss = "Jefe" ; ttElite = "Élite" ; ttRare = "Raro" ; ttRareElite = "Raro Élite" ; ttRareBoss = "Raro Jefe" ; ttTarget = "Objetivo"
4010 elseif GameLocale == "frFR" then ttYou = "TOI" ; ttLevel = "Niveau" ; ttBoss = "Boss" ; ttElite = "Élite" ; ttRare = "Rare" ; ttRareElite = "Rare Élite" ; ttRareBoss = "Rare Boss" ; ttTarget = "Cible"
4011 elseif GameLocale == "itIT" then ttYou = "TU" ; ttLevel = "Livello" ; ttBoss = "Boss" ; ttElite = "Élite" ; ttRare = "Raro" ; ttRareElite = "Raro Élite" ; ttRareBoss = "Raro Boss" ; ttTarget = "Bersaglio"
4012 else ttYou = "YOU" ; ttLevel = "Level" ; ttBoss = "Boss" ; ttElite = "Elite" ; ttRare = "Rare" ; ttRareElite = "Rare Elite" ; ttRareBoss = "Rare Boss" ; ttTarget = "Target"
4013 end
4014
4015 -- Show tooltip
4016 local function ShowTip()
4017
4018 -- Do nothing if CTRL, SHIFT and ALT are being held
4019 if IsControlKeyDown() and IsAltKeyDown() and IsShiftKeyDown() then
4020 return
4021 end
4022
4023 -- Get unit information
4024 if GetMouseFocus() == WorldFrame then
4025 LT["Unit"] = "mouseover"
4026 -- Hide and quit if tips should be hidden during combat
4027 if LeaPlusLC["TipHideInCombat"] == "On" and UnitAffectingCombat("player") and not IsShiftKeyDown() then
4028 GameTooltip:Hide()
4029 return
4030 end
4031 else
4032 LT["Unit"] = select(2, GameTooltip:GetUnit())
4033 if not (LT["Unit"]) then return end
4034 end
4035
4036 -- Quit if unit has no reaction to player
4037 LT["Reaction"] = UnitReaction(LT["Unit"], "player") or nil
4038 if not LT["Reaction"] then
4039 return
4040 end
4041
4042 -- Setup variables
4043 LT["TipUnitName"], LT["TipUnitRealm"] = UnitName(LT["Unit"])
4044 LT["TipIsPlayer"] = UnitIsPlayer(LT["Unit"])
4045 LT["UnitLevel"] = UnitLevel(LT["Unit"])
4046 LT["UnitClass"] = UnitClassBase(LT["Unit"])
4047 LT["PlayerControl"] = UnitPlayerControlled(LT["Unit"])
4048 LT["PlayerRace"] = UnitRace(LT["Unit"])
4049
4050 -- Get colorblind information
4051 if LT["TipIsPlayer"] then
4052 if LT["ColorBlind"] == "1" then
4053 LT["InfoLine"] = 3
4054 else
4055 LT["InfoLine"] = 2
4056 end
4057 -- Lower information line if unit is charmed
4058 if UnitIsCharmed(LT["Unit"]) then
4059 LT["InfoLine"] = LT["InfoLine"] + 1
4060 end
4061 end
4062
4063 -- Determine class color
4064 if LT["UnitClass"] then
4065 -- Define male or female (for certain locales)
4066 LT["Sex"] = UnitSex(LT["Unit"])
4067 if LT["Sex"] == 2 then
4068 LT["Class"] = TipMClass[LT["UnitClass"]]
4069 else
4070 LT["Class"] = TipFClass[LT["UnitClass"]]
4071 end
4072 -- Define class color
4073 LT["ClassCol"] = LeaPlusLC["RaidColors"][LT["UnitClass"]]
4074 LT["LpTipClassColor"] = "|cff" .. string.format("%02x%02x%02x", LT["ClassCol"].r * 255, LT["ClassCol"].g * 255, LT["ClassCol"].b * 255)
4075 end
4076
4077 ----------------------------------------------------------------------
4078 -- Name line
4079 ----------------------------------------------------------------------
4080
4081 if ((LT["TipIsPlayer"]) or (LT["PlayerControl"])) or LT["Reaction"] > 4 then
4082
4083 -- If it's a player show name in class color
4084 if LT["TipIsPlayer"] then
4085 LT["NameColor"] = LT["LpTipClassColor"]
4086 else
4087 -- If not, set to green or blue depending on PvP status
4088 if UnitIsPVP(LT["Unit"]) then
4089 LT["NameColor"] = "|cff00ff00"
4090 else
4091 LT["NameColor"] = "|cff00aaff"
4092 end
4093 end
4094
4095 -- Show name
4096 LT["NameText"] = UnitPVPName(LT["Unit"]) or LT["TipUnitName"]
4097
4098 -- Show realm
4099 if LT["TipUnitRealm"] then
4100 LT["NameText"] = LT["NameText"] .. " - " .. LT["TipUnitRealm"]
4101 end
4102
4103 -- Show dead units in grey
4104 if UnitIsDeadOrGhost(LT["Unit"]) then
4105 LT["NameColor"] = "|c88888888"
4106 end
4107
4108 -- Show name line
4109 _G["GameTooltipTextLeft1"]:SetText(LT["NameColor"] .. LT["NameText"] .. "|cffffffff|r")
4110
4111 elseif UnitIsDeadOrGhost(LT["Unit"]) then
4112
4113 -- Show grey name for other dead units
4114 _G["GameTooltipTextLeft1"]:SetText("|c88888888" .. (_G["GameTooltipTextLeft1"]:GetText() or "") .. "|cffffffff|r")
4115 return
4116
4117 end
4118
4119 ----------------------------------------------------------------------
4120 -- Information line (level, class, race)
4121 ----------------------------------------------------------------------
4122
4123 if LT["TipIsPlayer"] then
4124
4125 -- Show level
4126 if LT["Reaction"] < 5 then
4127 if LT["UnitLevel"] == -1 then
4128 LT["InfoText"] = ("|cffff3333" .. ttLevel .. " ??|cffffffff")
4129 else
4130 LT["LevelColor"] = GetCreatureDifficultyColor(LT["UnitLevel"])
4131 LT["LevelColor"] = string.format('%02x%02x%02x', LT["LevelColor"].r * 255, LT["LevelColor"].g * 255, LT["LevelColor"].b * 255)
4132 LT["InfoText"] = ("|cff" .. LT["LevelColor"] .. LT["LevelLocale"] .. " " .. LT["UnitLevel"] .. "|cffffffff")
4133 end
4134 else
4135 LT["InfoText"] = LT["LevelLocale"] .. " " .. LT["UnitLevel"]
4136 end
4137
4138 -- Show race
4139 if LT["PlayerRace"] then
4140 LT["InfoText"] = LT["InfoText"] .. " " .. LT["PlayerRace"]
4141 end
4142
4143 -- Show class
4144 LT["InfoText"] = LT["InfoText"] .. " " .. LT["LpTipClassColor"] .. LT["Class"] or LT["InfoText"]
4145
4146 -- Show information line
4147 _G["GameTooltipTextLeft" .. LT["InfoLine"]]:SetText(LT["InfoText"] .. "|cffffffff|r")
4148
4149 end
4150
4151 ----------------------------------------------------------------------
4152 -- Mob name in brighter red (alive) and steel blue (tap denied)
4153 ----------------------------------------------------------------------
4154
4155 if not (LT["TipIsPlayer"]) and LT["Reaction"] < 4 and not (LT["PlayerControl"]) then
4156 if UnitIsTapDenied(LT["Unit"]) then
4157 LT["NameText"] = "|c8888bbbb" .. LT["TipUnitName"] .. "|r"
4158 else
4159 LT["NameText"] = "|cffff3333" .. LT["TipUnitName"] .. "|r"
4160 end
4161 _G["GameTooltipTextLeft1"]:SetText(LT["NameText"])
4162 end
4163
4164 ----------------------------------------------------------------------
4165 -- Mob level in color (neutral or lower)
4166 ----------------------------------------------------------------------
4167
4168 if UnitCanAttack(LT["Unit"], "player") and not (LT["TipIsPlayer"]) and LT["Reaction"] < 5 and not (LT["PlayerControl"]) then
4169
4170 -- Find the level line
4171 LT["MobInfoLine"] = 0
4172 local line2, line3, line4
4173 if _G["GameTooltipTextLeft2"] then line2 = _G["GameTooltipTextLeft2"]:GetText() end
4174 if _G["GameTooltipTextLeft3"] then line3 = _G["GameTooltipTextLeft3"]:GetText() end
4175 if _G["GameTooltipTextLeft4"] then line4 = _G["GameTooltipTextLeft4"]:GetText() end
4176 if GameLocale == "ruRU" then -- Additional check for ruRU
4177 if line2 and string.lower(line2):find(LevelString2) then LT["MobInfoLine"] = 2 end
4178 if line3 and string.lower(line3):find(LevelString2) then LT["MobInfoLine"] = 3 end
4179 if line4 and string.lower(line4):find(LevelString2) then LT["MobInfoLine"] = 4 end
4180 end
4181 if line2 and string.lower(line2):find(LevelString) then LT["MobInfoLine"] = 2 end
4182 if line3 and string.lower(line3):find(LevelString) then LT["MobInfoLine"] = 3 end
4183 if line4 and string.lower(line4):find(LevelString) then LT["MobInfoLine"] = 4 end
4184
4185 -- Show level line
4186 if LT["MobInfoLine"] > 1 then
4187
4188 -- Level ?? mob
4189 if LT["UnitLevel"] == -1 then
4190 LT["InfoText"] = "|cffff3333" .. ttLevel .. " ??|cffffffff "
4191
4192 -- Mobs within level range
4193 else
4194 LT["MobColor"] = GetCreatureDifficultyColor(LT["UnitLevel"])
4195 LT["MobColor"] = string.format('%02x%02x%02x', LT["MobColor"].r * 255, LT["MobColor"].g * 255, LT["MobColor"].b * 255)
4196 LT["InfoText"] = "|cff" .. LT["MobColor"] .. LT["LevelLocale"] .. " " .. LT["UnitLevel"] .. "|cffffffff "
4197 end
4198
4199 -- Show creature type and classification
4200 LT["CreatureType"] = UnitCreatureType(LT["Unit"])
4201 if (LT["CreatureType"]) and not (LT["CreatureType"] == "Not specified") then
4202 LT["InfoText"] = LT["InfoText"] .. "|cffffffff" .. LT["CreatureType"] .. "|cffffffff "
4203 end
4204
4205 -- Rare, elite and boss mobs
4206 LT["Special"] = UnitClassification(LT["Unit"])
4207 if LT["Special"] then
4208 if LT["Special"] == "elite" then
4209 if strfind(_G["GameTooltipTextLeft" .. LT["MobInfoLine"]]:GetText(), "(" .. ttBoss .. ")") then
4210 LT["Special"] = "(" .. ttBoss .. ")"
4211 else
4212 LT["Special"] = "(" .. ttElite .. ")"
4213 end
4214 elseif LT["Special"] == "rare" then
4215 LT["Special"] = "|c00e066ff(" .. ttRare .. ")"
4216 elseif LT["Special"] == "rareelite" then
4217 if strfind(_G["GameTooltipTextLeft" .. LT["MobInfoLine"]]:GetText(), "(" .. ttBoss .. ")") then
4218 LT["Special"] = "|c00e066ff(" .. ttRareBoss .. ")"
4219 else
4220 LT["Special"] = "|c00e066ff(" .. ttRareElite .. ")"
4221 end
4222 elseif LT["Special"] == "worldboss" then
4223 LT["Special"] = "(" .. ttBoss .. ")"
4224 elseif LT["UnitLevel"] == -1 and LT["Special"] == "normal" and strfind(_G["GameTooltipTextLeft" .. LT["MobInfoLine"]]:GetText(), "(" .. ttBoss .. ")") then
4225 LT["Special"] = "(" .. ttBoss .. ")"
4226 else
4227 LT["Special"] = nil
4228 end
4229
4230 if (LT["Special"]) then
4231 LT["InfoText"] = LT["InfoText"] .. LT["Special"]
4232 end
4233 end
4234
4235 -- Show mob info line
4236 _G["GameTooltipTextLeft" .. LT["MobInfoLine"]]:SetText(LT["InfoText"])
4237
4238 end
4239
4240 end
4241
4242 ----------------------------------------------------------------------
4243 -- Backdrop color
4244 ----------------------------------------------------------------------
4245
4246 LT["TipFaction"] = UnitFactionGroup(LT["Unit"])
4247
4248 if UnitCanAttack("player", LT["Unit"]) and not (UnitIsDeadOrGhost(LT["Unit"])) and not (LT["TipFaction"] == nil) and not (LT["TipFaction"] == UnitFactionGroup("player")) then
4249 -- Hostile faction
4250 if LeaPlusLC["TipBackSimple"] == "On" then
4251 GameTooltip:SetBackdropColor(0.5, 0.0, 0.0);
4252 else
4253 GameTooltip:SetBackdropColor(0.0, 0.0, 0.0);
4254 end
4255 else
4256 -- Friendly faction
4257 if LeaPlusLC["TipBackSimple"] == "On" then
4258 GameTooltip:SetBackdropColor(0.0, 0.0, 0.5);
4259 else
4260 GameTooltip:SetBackdropColor(0.0, 0.0, 0.0);
4261 end
4262 end
4263
4264 ----------------------------------------------------------------------
4265 -- Show guild
4266 ----------------------------------------------------------------------
4267
4268 if LeaPlusLC["TipShowGuild"] == "On" and LT["TipIsPlayer"] then
4269 local unitGuild, unitRank = GetGuildInfo(LT["Unit"])
4270 if unitGuild and unitRank then
4271 if UnitIsInMyGuild(LT["Unit"]) then
4272 GameTooltip:AddLine("|c00aaaaff" .. unitGuild .. " - " .. unitRank .. "|r")
4273 else
4274 GameTooltip:AddLine("|c00aaaaff" .. unitGuild .. "|cffffffff|r")
4275 end
4276 end
4277 end
4278
4279 ----------------------------------------------------------------------
4280 -- Show target
4281 ----------------------------------------------------------------------
4282
4283 if LeaPlusLC["TipShowTarget"] == "On" then
4284
4285 -- Get target
4286 LT["Target"] = UnitName(LT["Unit"] .. "target");
4287
4288 -- If target doesn't exist, quit
4289 if LT["Target"] == nil or LT["Target"] == "" then return end
4290
4291 -- If target is you, set target to YOU
4292 if (UnitIsUnit(LT["Target"], "player")) then
4293 LT["Target"] = ("|c12ff4400" .. ttYou)
4294
4295 -- If it's not you, but it's a player, show target in class color
4296 elseif UnitIsPlayer(LT["Unit"] .. "target") then
4297 LT["TargetBase"] = UnitClassBase(LT["Unit"] .. "target")
4298 LT["TargetCol"] = LeaPlusLC["RaidColors"][LT["TargetBase"]]
4299 LT["TargetCol"] = "|cff" .. string.format('%02x%02x%02x', LT["TargetCol"].r * 255, LT["TargetCol"].g * 255, LT["TargetCol"].b * 255)
4300 LT["Target"] = (LT["TargetCol"] .. LT["Target"])
4301
4302 end
4303
4304 -- Add target line
4305 GameTooltip:AddLine(ttTarget .. ": " .. LT["Target"])
4306
4307 end
4308
4309 end
4310
4311 GameTooltip:HookScript("OnTooltipSetUnit", ShowTip)
4312
4313 end
4314
4315 ----------------------------------------------------------------------
4316 -- Move chat editbox to top
4317 ----------------------------------------------------------------------
4318
4319 if LeaPlusLC["MoveChatEditBoxToTop"] == "On" then
4320
4321 -- Set options for normal chat frames
4322 for i = 1, 50 do
4323 if _G["ChatFrame" .. i] then
4324 -- Position the editbox
4325 _G["ChatFrame" .. i .. "EditBox"]:ClearAllPoints();
4326 _G["ChatFrame" .. i .. "EditBox"]:SetPoint("TOPLEFT", _G["ChatFrame" .. i], 0, 0);
4327 _G["ChatFrame" .. i .. "EditBox"]:SetWidth(_G["ChatFrame" .. i]:GetWidth());
4328 -- Ensure editbox width matches chatframe width
4329 _G["ChatFrame" .. i]:HookScript("OnSizeChanged", function()
4330 _G["ChatFrame" .. i .. "EditBox"]:SetWidth(_G["ChatFrame" .. i]:GetWidth())
4331 end)
4332 end
4333 end
4334
4335 -- Do the functions above for other chat frames (pet battles, whispers, etc)
4336 hooksecurefunc("FCF_OpenTemporaryWindow", function()
4337
4338 local cf = FCF_GetCurrentChatFrame():GetName() or nil
4339 if cf then
4340
4341 -- Position the editbox
4342 _G[cf .. "EditBox"]:ClearAllPoints();
4343 _G[cf .. "EditBox"]:SetPoint("TOPLEFT", cf, "TOPLEFT", 0, 0);
4344 _G[cf .. "EditBox"]:SetWidth(_G[cf]:GetWidth());
4345
4346 -- Ensure editbox width matches chatframe width
4347 _G[cf]:HookScript("OnSizeChanged", function()
4348 _G[cf .. "EditBox"]:SetWidth(_G[cf]:GetWidth())
4349 end)
4350
4351 end
4352 end)
4353
4354 end
4355
4356 ----------------------------------------------------------------------
4357 -- Viewport
4358 ----------------------------------------------------------------------
4359
4360 if LeaPlusLC["ViewPortEnable"] == "On" then
4361
4362 -- Create border textures
4363 local BordTop = WorldFrame:CreateTexture(nil, "ARTWORK"); BordTop:SetColorTexture(0, 0, 0, 1); BordTop:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 0, 0); BordTop:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 0)
4364 local BordBot = WorldFrame:CreateTexture(nil, "ARTWORK"); BordBot:SetColorTexture(0, 0, 0, 1); BordBot:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 0, 0); BordBot:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", 0, 0)
4365 local BordLeft = WorldFrame:CreateTexture(nil, "ARTWORK"); BordLeft:SetColorTexture(0, 0, 0, 1); BordLeft:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 0, 0); BordLeft:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 0, 0)
4366 local BordRight = WorldFrame:CreateTexture(nil, "ARTWORK"); BordRight:SetColorTexture(0, 0, 0, 1); BordRight:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 0); BordRight:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", 0, 0)
4367
4368 -- Create viewport configuration panel
4369 local SideViewport = LeaPlusLC:CreatePanel("Viewport", "SideViewport")
4370
4371 -- Create resize screen button
4372 local resizeScreenBtn = LeaPlusLC:CreateButton("resizeScreenBtn", SideViewport, "Resize Screen", "BOTTOMRIGHT", -16, 10, 0, 25, true, "Click to resize the screen to fit between the top and bottom borders.")
4373 resizeScreenBtn:ClearAllPoints()
4374 resizeScreenBtn:SetPoint("LEFT", SideViewport.h, "RIGHT", 10, 0)
4375 resizeScreenBtn:SetScript("OnClick", function()
4376 LeaPlusLC["ViewPortResizeTop"] = LeaPlusLC["ViewPortTop"]
4377 LeaPlusLC["ViewPortResizeBottom"] = LeaPlusLC["ViewPortBottom"]
4378 WorldFrame:SetPoint("TOPLEFT", 0, -LeaPlusLC["ViewPortResizeTop"])
4379 WorldFrame:SetPoint("BOTTOMRIGHT", 0, LeaPlusLC["ViewPortResizeBottom"])
4380 -- Disable lock button if borders match viewport size
4381 if LeaPlusLC["ViewPortTop"] == LeaPlusLC["ViewPortResizeTop"] and LeaPlusLC["ViewPortBottom"] == LeaPlusLC["ViewPortResizeBottom"] then
4382 LeaPlusLC:LockItem(resizeScreenBtn, true)
4383 else
4384 LeaPlusLC:LockItem(resizeScreenBtn, false)
4385 end
4386 end)
4387
4388 -- Function to set viewport parameters
4389 local function RefreshViewport()
4390
4391 -- Set border size and transparency
4392 BordTop:SetHeight(LeaPlusLC["ViewPortTop"]); BordTop:SetAlpha(1 - LeaPlusLC["ViewPortAlpha"])
4393 BordBot:SetHeight(LeaPlusLC["ViewPortBottom"]); BordBot:SetAlpha(1 - LeaPlusLC["ViewPortAlpha"])
4394 BordLeft:SetWidth(LeaPlusLC["ViewPortLeft"]); BordLeft:SetAlpha(1 - LeaPlusLC["ViewPortAlpha"])
4395 BordRight:SetWidth(LeaPlusLC["ViewPortRight"]); BordRight:SetAlpha(1 - LeaPlusLC["ViewPortAlpha"])
4396
4397 -- Show formatted slider value
4398 LeaPlusCB["ViewPortAlpha"].f:SetFormattedText("%.0f%%", LeaPlusLC["ViewPortAlpha"] * 100)
4399
4400 -- Disable lock button if borders match viewport size
4401 if LeaPlusLC["ViewPortTop"] == LeaPlusLC["ViewPortResizeTop"] and LeaPlusLC["ViewPortBottom"] == LeaPlusLC["ViewPortResizeBottom"] then
4402 LeaPlusLC:LockItem(resizeScreenBtn, true)
4403 else
4404 LeaPlusLC:LockItem(resizeScreenBtn, false)
4405 end
4406
4407 end
4408
4409 -- Create slider controls
4410 LeaPlusLC:MakeTx(SideViewport, "Top", 16, -72)
4411 LeaPlusLC:MakeSL(SideViewport, "ViewPortTop", "Drag to set the size of the top border.", 0, 300, 5, 16, -92, "%.0f")
4412 LeaPlusCB["ViewPortTop"]:HookScript("OnValueChanged", RefreshViewport)
4413
4414 LeaPlusLC:MakeTx(SideViewport, "Bottom", 16, -132)
4415 LeaPlusLC:MakeSL(SideViewport, "ViewPortBottom", "Drag to set the size of the bottom border.", 0, 300, 5, 16, -152, "%.0f")
4416 LeaPlusCB["ViewPortBottom"]:HookScript("OnValueChanged", RefreshViewport)
4417
4418 LeaPlusLC:MakeTx(SideViewport, "Left", 186, -72)
4419 LeaPlusLC:MakeSL(SideViewport, "ViewPortLeft", "Drag to set the size of the left border.", 0, 300, 5, 186, -92, "%.0f")
4420 LeaPlusCB["ViewPortLeft"]:HookScript("OnValueChanged", RefreshViewport)
4421
4422 LeaPlusLC:MakeTx(SideViewport, "Right", 186, -132)
4423 LeaPlusLC:MakeSL(SideViewport, "ViewPortRight", "Drag to set the size of the right border.", 0, 300, 5, 186, -152, "%.0f")
4424 LeaPlusCB["ViewPortRight"]:HookScript("OnValueChanged", RefreshViewport)
4425
4426 LeaPlusLC:MakeTx(SideViewport, "Transparency", 356, -132)
4427 LeaPlusLC:MakeSL(SideViewport, "ViewPortAlpha", "Drag to set the transparency of the borders.", 0, 0.9, 0.1, 356, -152, "%.1f")
4428 LeaPlusCB["ViewPortAlpha"]:HookScript("OnValueChanged", RefreshViewport)
4429
4430 -- Help button tooltip
4431 SideViewport.h.tiptext = L["This panel will close automatically if you enter combat."]
4432
4433 -- Back button handler
4434 SideViewport.b:SetScript("OnClick", function()
4435 SideViewport:Hide()
4436 LeaPlusLC["PageF"]:Show()
4437 LeaPlusLC["Page7"]:Show()
4438 return
4439 end)
4440
4441 -- Reset button handler
4442 SideViewport.r:SetScript("OnClick", function()
4443 LeaPlusLC["ViewPortTop"] = 0
4444 LeaPlusLC["ViewPortBottom"] = 0
4445 LeaPlusLC["ViewPortLeft"] = 0
4446 LeaPlusLC["ViewPortRight"] = 0
4447 LeaPlusLC["ViewPortResizeTop"] = 0
4448 LeaPlusLC["ViewPortResizeBottom"] = 0
4449 LeaPlusLC["ViewPortAlpha"] = 0
4450 SideViewport:Hide(); SideViewport:Show()
4451 RefreshViewport()
4452 WorldFrame:SetPoint("TOPLEFT", 0, -LeaPlusLC["ViewPortResizeTop"])
4453 WorldFrame:SetPoint("BOTTOMRIGHT", 0, LeaPlusLC["ViewPortResizeBottom"])
4454 end)
4455
4456 -- Configuration button handler
4457 LeaPlusCB["ModViewportBtn"]:SetScript("OnClick", function()
4458 if LeaPlusLC:PlayerInCombat() then
4459 return
4460 else
4461 if IsShiftKeyDown() and IsControlKeyDown() then
4462 -- Preset profile
4463 LeaPlusLC["ViewPortTop"] = 0
4464 LeaPlusLC["ViewPortBottom"] = 0
4465 LeaPlusLC["ViewPortLeft"] = 0
4466 LeaPlusLC["ViewPortRight"] = 0
4467 LeaPlusLC["ViewPortResizeTop"] = 0
4468 LeaPlusLC["ViewPortResizeBottom"] = 0
4469 LeaPlusLC["ViewPortAlpha"] = 0.7
4470 RefreshViewport()
4471 WorldFrame:SetPoint("TOPLEFT", 0, -LeaPlusLC["ViewPortResizeTop"])
4472 WorldFrame:SetPoint("BOTTOMRIGHT", 0, LeaPlusLC["ViewPortResizeBottom"])
4473 else
4474 SideViewport:Show()
4475 LeaPlusLC:HideFrames()
4476 end
4477 end
4478 end)
4479
4480 -- Set viewport on startup
4481 RefreshViewport()
4482 WorldFrame:SetPoint("TOPLEFT", 0, -LeaPlusLC["ViewPortResizeTop"])
4483 WorldFrame:SetPoint("BOTTOMRIGHT", 0, LeaPlusLC["ViewPortResizeBottom"])
4484
4485 -- Hide the configuration panel if combat starts
4486 SideViewport:RegisterEvent("PLAYER_REGEN_DISABLED")
4487 SideViewport:SetScript("OnEvent", SideViewport.Hide)
4488
4489 -- Hide borders when cinematic is shown
4490 hooksecurefunc(CinematicFrame, "Hide", function()
4491 BordTop:Show(); BordBot:Show(); BordLeft:Show(); BordRight:Show()
4492 end)
4493 hooksecurefunc(CinematicFrame, "Show", function()
4494 BordTop:Hide(); BordBot:Hide(); BordLeft:Hide(); BordRight:Hide()
4495 end)
4496
4497 end
4498
4499 ----------------------------------------------------------------------
4500 -- Silence rested emotes
4501 ----------------------------------------------------------------------
4502
4503 -- Manage emotes
4504 if LeaPlusLC["NoRestedEmotes"] == "On" then
4505
4506 -- Zone table English , French , German , Italian , Russian , S Chinese , Spanish , T Chinese ,
4507 local zonetable = { "The Grim Guzzler" , "Le Sinistre écluseur" , "Zum Grimmigen Säufer" , "Torvo Beone" , "Трактир Угрюмый обжора" , "黑铁酒吧" , "Tragapenas" , "黑鐵酒吧" ,}
4508
4509 -- Function to set rested state
4510 local function UpdateEmoteSound()
4511
4512 -- Find character's current zone
4513 local szone = GetSubZoneText() or "None"
4514
4515 -- Find out if emote sounds are disabled or enabled
4516 local emoset = GetCVar("Sound_EnableEmoteSounds")
4517
4518 if IsResting() then
4519 -- Character is resting so silence emotes
4520 if emoset ~= "0" then
4521 SetCVar("Sound_EnableEmoteSounds", "0")
4522 end
4523 return
4524 end
4525
4526 -- Traverse zone table and silence emotes if character is in a designated zone
4527 for k, v in next, zonetable do
4528 if szone == zonetable[k] then
4529 if emoset ~= "0" then
4530 SetCVar("Sound_EnableEmoteSounds", "0")
4531 end
4532 return
4533 end
4534 end
4535
4536 -- If the above didn't return, emote sounds should be enabled
4537 if emoset ~= "1" then
4538 SetCVar("Sound_EnableEmoteSounds", "1")
4539 end
4540 return
4541
4542 end
4543
4544 -- Set emote sound when rest state or zone changes
4545 local RestEvent = CreateFrame("FRAME")
4546 RestEvent:RegisterEvent("PLAYER_UPDATE_RESTING")
4547 RestEvent:RegisterEvent("ZONE_CHANGED_NEW_AREA")
4548 RestEvent:RegisterEvent("ZONE_CHANGED")
4549 RestEvent:RegisterEvent("ZONE_CHANGED_INDOORS")
4550 RestEvent:SetScript("OnEvent", UpdateEmoteSound)
4551
4552 -- Set sound setting at startup
4553 UpdateEmoteSound()
4554
4555 end
4556
4557 ----------------------------------------------------------------------
4558 -- Final code for Player
4559 ----------------------------------------------------------------------
4560
4561 -- Register logout event to save settings
4562 LpEvt:RegisterEvent("PLAYER_LOGOUT")
4563
4564 -- Release memory
4565 LeaPlusLC.Player = nil
4566
4567 end
4568
4569----------------------------------------------------------------------
4570-- L50: RunOnce
4571----------------------------------------------------------------------
4572
4573 function LeaPlusLC:RunOnce()
4574
4575 ----------------------------------------------------------------------
4576 -- Media player
4577 ----------------------------------------------------------------------
4578
4579 function LeaPlusLC:MediaFunc()
4580
4581 -- Create tables for list data and zone listing
4582 local ListData, playlist = {}, {}, {}
4583 local scrollFrame, willPlay, musicHandle, ZonePage, LastPlayed, LastFolder, TempFolder, HeadingOfClickedTrack, LastMusicHandle
4584 local numButtons = 15
4585 local uframe = CreateFrame("FRAME")
4586
4587 -- Create a table for each heading
4588 local ZoneList = {L["Music"], L["Random"], L["Search"], L["Movies"]}
4589 for k, v in ipairs(ZoneList) do
4590 ZoneList[v] = {}
4591 end
4592
4593 -- Music table
4594 ZoneList[L["Music"]] = Leatrix_Plus["Music"]
4595 tinsert(ZoneList[L["Music"]], 1, "|cffffd800" .. L["Music"])
4596 tinsert(ZoneList[L["Music"]], 2, "|cffffd800")
4597 tinsert(ZoneList[L["Music"]], 3, "|cffffd800")
4598
4599 -- Movies table
4600 ZoneList[L["Movies"]] = {L["Ten Years of Warcraft"] .. " |r(1)", L["World of Warcraft"] .. " |r(2)"}
4601 tinsert(ZoneList[L["Movies"]], 1, "|cffffd800" .. L["Movies"])
4602 tinsert(ZoneList[L["Movies"]], 2, "|cffffd800")
4603 tinsert(ZoneList[L["Movies"]], 3, "|cffffd800")
4604
4605 -- Debug
4606 -- ZoneList[L["Music"]] = {"|cffffd800" .. L["Music"], "|cffffd800", "|cffffd800", "citymusic/darnassus/darnassus intro.mp3#53183#3", "citymusic/darnassus/darnassus walking 1.mp3#53184#3", "citymusic/darnassus/darnassus walking 2.mp3#53185#3"}
4607
4608 -- Give zone table a file level scope so slash command function can access it
4609 LeaPlusLC["ZoneList"] = ZoneList
4610
4611 -- Show relevant list items
4612 local function UpdateList()
4613 FauxScrollFrame_Update(scrollFrame, #ListData, numButtons, 16)
4614 for index = 1, numButtons do
4615 local offset = index + FauxScrollFrame_GetOffset(scrollFrame)
4616 local button = scrollFrame.buttons[index]
4617 button.index = offset
4618 if offset <= #ListData then
4619 -- Show track listing
4620 button:SetText(ListData[offset])
4621 -- Set width of highlight texture
4622 if button:GetTextWidth() > 290 then
4623 button.t:SetSize(290, 16)
4624 else
4625 button.t:SetSize(button:GetTextWidth(), 16)
4626 end
4627 -- Show the button
4628 button:Show()
4629 -- Hide highlight bar texture by default
4630 button.s:Hide()
4631 -- Hide highlight bar if the button is a heading
4632 if strfind(button:GetText(), "|c") then button.t:Hide() end
4633 -- Show last played track highlight bar texture
4634 if LastPlayed == button:GetText() then
4635 local HeadingOfCurrentFolder = ListData[1]
4636 if HeadingOfCurrentFolder == HeadingOfClickedTrack then
4637 button.s:Show()
4638 end
4639 end
4640 -- Set width of highlight bar
4641 if button:GetTextWidth() > 290 then
4642 button.s:SetSize(290, 16)
4643 else
4644 button.s:SetSize(button:GetTextWidth(), 16)
4645 end
4646 -- Limit click to label width
4647 local bWidth = button:GetFontString():GetStringWidth() or 0
4648 if bWidth > 290 then bWidth = 290 end
4649 button:SetHitRectInsets(0, 454 - bWidth, 0, 0)
4650 -- Disable label click movement
4651 button:SetPushedTextOffset(0, 0)
4652 -- Disable word wrap and set width
4653 button:GetFontString():SetWidth(290)
4654 button:GetFontString():SetWordWrap(false)
4655 else
4656 button:Hide()
4657 end
4658 end
4659 end
4660
4661 -- Give function file level scope (it's used in SetPlusScale to set the highlight bar scale)
4662 LeaPlusLC.UpdateList = UpdateList
4663
4664 -- Function to make navigation menu buttons
4665 local function MakeButton(where, y)
4666 local mbtn = CreateFrame("Button", nil, LeaPlusLC["Page9"])
4667 mbtn:Show()
4668 mbtn:SetAlpha(1.0)
4669 mbtn:SetPoint("TOPLEFT", 146, y)
4670
4671 -- Create hover texture
4672 mbtn.t = mbtn:CreateTexture(nil, "BACKGROUND")
4673 mbtn.t:SetColorTexture(0.3, 0.3, 0.00, 0.8)
4674 mbtn.t:SetAlpha(0.7)
4675 mbtn.t:SetAllPoints()
4676 mbtn.t:Hide()
4677
4678 -- Create highlight texture
4679 mbtn.s = mbtn:CreateTexture(nil, "BACKGROUND")
4680 mbtn.s:SetColorTexture(0.3, 0.3, 0.00, 0.8)
4681 mbtn.s:SetAlpha(1.0)
4682 mbtn.s:SetAllPoints()
4683 mbtn.s:Hide()
4684
4685 -- Create fontstring
4686 mbtn.f = mbtn:CreateFontString(nil, 'ARTWORK', 'GameFontNormal')
4687 mbtn.f:SetPoint('LEFT', 1, 0)
4688 mbtn.f:SetText(L[where])
4689
4690 mbtn:SetScript("OnEnter", function()
4691 mbtn.t:Show()
4692 end)
4693
4694 mbtn:SetScript("OnLeave", function()
4695 mbtn.t:Hide()
4696 end)
4697
4698 -- Set button size when shown
4699 mbtn:SetScript("OnShow", function()
4700 mbtn:SetSize(mbtn.f:GetStringWidth() + 1, 16)
4701 end)
4702
4703 mbtn:SetScript("OnClick", function()
4704 -- Show zone listing for clicked item
4705 ListData = ZoneList[where]
4706 -- Show results count for Music and Movies
4707 if where == L["Music"] or where == L["Movies"] then
4708 ListData[2] = "|cffffffaa{" .. #ZoneList[where] - 3 .. " " .. L["results"] .. "}"
4709 end
4710 UpdateList()
4711 end)
4712
4713 return mbtn, mbtn.s
4714
4715 end
4716
4717 -- Create a table for each button
4718 local conbtn = {}
4719 for q, w in pairs(ZoneList) do
4720 conbtn[q] = {}
4721 end
4722
4723 -- Create buttons
4724 local function MakeButtonNow(title, anchor)
4725 conbtn[title], conbtn[title].s = MakeButton(title, height)
4726 conbtn[title]:ClearAllPoints()
4727 if title == L["Music"] then
4728 -- Set first button position
4729 conbtn[title]:SetPoint("TOPLEFT", LeaPlusLC["Page9"], "TOPLEFT", 145, -70)
4730 elseif anchor then
4731 -- Set subsequent button positions
4732 conbtn[title]:SetPoint("TOPLEFT", conbtn[anchor], "BOTTOMLEFT", 0, 0)
4733 conbtn[title].f:SetText(L[title])
4734 end
4735 end
4736
4737 MakeButtonNow(L["Music"])
4738 MakeButtonNow(L["Movies"], L["Music"])
4739 MakeButtonNow(L["Random"], L["Movies"])
4740 MakeButtonNow(L["Search"]) -- Positioned when search editbox is created
4741
4742 -- Show button highlight for clicked button
4743 for q, w in pairs(ZoneList) do
4744 if type(w) == "string" and conbtn[w] then
4745 conbtn[w]:HookScript("OnClick", function()
4746 -- Hide all button highlights
4747 for k, v in pairs(ZoneList) do
4748 if type(v) == "string" and conbtn[v] then
4749 conbtn[v].s:Hide()
4750 end
4751 end
4752 -- Show clicked button highlight
4753 conbtn[w].s:Show()
4754 LeaPlusDB["MusicContinent"] = w
4755 scrollFrame:SetVerticalScroll(0)
4756 -- Set TempFolder to clicked button
4757 TempFolder = L[w]
4758 end)
4759 end
4760 end
4761
4762 -- Create scroll bar
4763 scrollFrame = CreateFrame("ScrollFrame", "LeaPlusScrollFrame", LeaPlusLC["Page9"], "FauxScrollFrameTemplate")
4764 scrollFrame:SetPoint("TOPLEFT", 0, -32)
4765 scrollFrame:SetPoint("BOTTOMRIGHT", -30, 50)
4766 scrollFrame:SetFrameLevel(10)
4767 scrollFrame:SetScript("OnVerticalScroll", function(self, offset)
4768 FauxScrollFrame_OnVerticalScroll(self, offset, 16, UpdateList)
4769 end)
4770
4771 -- Add stop button
4772 local stopBtn = LeaPlusLC:CreateButton("StopMusicBtn", LeaPlusLC["Page9"], "Stop", "TOPLEFT", 146, -292, 0, 25, true, "")
4773 stopBtn:Hide(); stopBtn:Show()
4774 LeaPlusLC:LockItem(stopBtn, true)
4775 stopBtn:SetScript("OnClick", function()
4776 if musicHandle then
4777 StopSound(musicHandle)
4778 musicHandle = nil
4779 -- Hide highlight bars
4780 LastPlayed = ""
4781 LastFolder = ""
4782 UpdateList()
4783 end
4784 -- Cancel sound file music timer
4785 if LeaPlusLC.TrackTimer then LeaPlusLC.TrackTimer:Cancel() end
4786 -- Lock button and unregister next track events
4787 LeaPlusLC:LockItem(stopBtn, true)
4788 uframe:UnregisterEvent("SOUNDKIT_FINISHED")
4789 uframe:UnregisterEvent("LOADING_SCREEN_DISABLED")
4790 end)
4791
4792 -- Store currently playing track number
4793 local tracknumber = 1
4794
4795 -- Function to play a track and show the static highlight bar
4796 local function PlayTrack()
4797 -- Play tracks
4798 if musicHandle then StopSound(musicHandle) end
4799 local file, soundID, trackTime
4800 if playlist[tracknumber]:match("([^,]+)%#([^,]+)%#([^,]+)") then
4801 -- Music file with track time
4802 file, soundID, trackTime = playlist[tracknumber]:match("([^,]+)%#([^,]+)%#([^,]+)")
4803 --willPlay, musicHandle = PlaySoundFile(soundID, "Master", false, true)
4804 -- Play the track (adds the sound/music/ prefix removed in sounds file)
4805 willPlay, musicHandle = PlaySoundFile(gsub("sound/music/" .. file, "|C.-|r", ""), "Master", false, true)
4806 else
4807 -- Sound kit without track time
4808 file, soundID = playlist[tracknumber]:match("([^,]+)%#([^,]+)")
4809 willPlay, musicHandle = PlaySound(soundID, "Master", false, true)
4810 end
4811 -- Cancel existing music timer for a sound file
4812 if LeaPlusLC.TrackTimer then LeaPlusLC.TrackTimer:Cancel() end
4813 if playlist[tracknumber]:match("([^,]+)%#([^,]+)%#([^,]+)") then
4814 -- Track is a sound file with track time so create track timer
4815 LeaPlusLC.TrackTimer = C_Timer.NewTimer(trackTime + 1, function()
4816 if musicHandle then StopSound(musicHandle) end
4817 if tracknumber == #playlist then
4818 -- Playlist is at the end, restart from first track
4819 tracknumber = 1
4820 end
4821 PlayTrack()
4822 end)
4823 end
4824 -- Store its handle for later use
4825 LastMusicHandle = musicHandle
4826 LastPlayed = playlist[tracknumber]
4827 tracknumber = tracknumber + 1
4828 -- Show static highlight bar
4829 for index = 1, numButtons do
4830 local button = scrollFrame.buttons[index]
4831 local item = button:GetText()
4832 if item then
4833 if item:match("([^,]+)%#([^,]+)%#([^,]+)") then
4834 -- Music file with track time
4835 local item, void, void = item:match("([^,]+)%#([^,]+)%#([^,]+)")
4836 if item then
4837 if item == file and LastFolder == TempFolder then
4838 button.s:Show()
4839 else
4840 button.s:Hide()
4841 end
4842 end
4843 else
4844 -- Sound kit without track time
4845 local item, void = item:match("([^,]+)%#([^,]+)")
4846 if item then
4847 if item == file and LastFolder == TempFolder then
4848 button.s:Show()
4849 else
4850 button.s:Hide()
4851 end
4852 end
4853 end
4854 end
4855 end
4856 end
4857
4858 -- Create editbox for search
4859 local sBox = LeaPlusLC:CreateEditBox("MusicSearchBox", LeaPlusLC["Page9"], 78, 10, "TOPLEFT", 150, -260, "MusicSearchBox", "MusicSearchBox")
4860 sBox:SetMaxLetters(50)
4861
4862 -- Position search button above editbox
4863 conbtn[L["Search"]]:ClearAllPoints()
4864 conbtn[L["Search"]]:SetPoint("BOTTOMLEFT", sBox, "TOPLEFT", -4, 0)
4865
4866 -- Set initial search data
4867 for q, w in pairs(ZoneList) do
4868 if conbtn[w] then
4869 conbtn[w]:HookScript("OnClick", function()
4870 if w == L["Search"] then
4871 ListData[1] = "|cffffd800" .. L["Search"]
4872 if #ListData == 1 then
4873 ListData[2] = "|cffffffaa{" .. L["enter music or movie name"] .. "}"
4874 end
4875 UpdateList()
4876 else
4877 sBox:ClearFocus()
4878 end
4879 end)
4880 end
4881 end
4882
4883 -- Function to show search results
4884 local function ShowSearchResults()
4885 -- Get unescaped editbox text
4886 local searchText = gsub(strlower(sBox:GetText()), '(['..("%^$().[]*+-?"):gsub("(.)", "%%%1")..'])', "%%%1")
4887 -- Wipe the track listing
4888 wipe(ListData)
4889 -- Set the track list heading
4890 ListData[1] = "|cffffd800" .. L["Search"]
4891 -- Show the subheading only if no search results are being shown
4892 if searchText == "" then
4893 ListData[2] = "|cffffffaa{" .. L["enter music or movie name"] .. "}"
4894 else
4895 ListData[2] = ""
4896 end
4897 -- Traverse music listing and populate ListData
4898 if searchText ~= "" then
4899 local word1, word2, word3, word4, word5 = strsplit(" ", (strtrim(searchText):gsub("%s+", " ")))
4900 RunScript('LeaPlusGlobalHash = {}')
4901 local hash = LeaPlusGlobalHash
4902 local trackCount = 0
4903 for a, b in pairs({L["Music"], L["Movies"]}) do
4904 for k, v in pairs(ZoneList[b]) do
4905 if (strfind(v, "#") or strfind(v, "|r")) and (strfind(strlower(v), word1) or strfind(strlower(b), word1)) then
4906 if not word2 or word2 ~= "" and (strfind(strlower(v), word2) or strfind(strlower(b), word2)) then
4907 if not word3 or word3 ~= "" and (strfind(strlower(v), word3) or strfind(strlower(b), word3)) then
4908 if not word4 or word4 ~= "" and (strfind(strlower(v), word4) or strfind(strlower(b), word4)) then
4909 if not word5 or word5 ~= "" and (strfind(strlower(v), word5) or strfind(strlower(b), word5)) then
4910 -- Show category
4911 if not hash[b] then
4912 tinsert(ListData, "|cffffffff")
4913 tinsert(ListData, "|cffffd800" .. b)
4914 hash[b] = true
4915 end
4916 -- Show track
4917 tinsert(ListData, v)
4918 trackCount = trackCount + 1
4919 hash[v] = true
4920 end
4921 end
4922 end
4923 end
4924 end
4925 end
4926 end
4927
4928 -- Set results tag
4929 if trackCount == 1 then
4930 ListData[2] = "|cffffffaa{" .. trackCount .. " " .. L["result"] .. "}"
4931 else
4932 ListData[2] = "|cffffffaa{" .. trackCount .. " " .. L["results"] .. "}"
4933 end
4934 end
4935 -- Refresh the track listing
4936 UpdateList()
4937 -- Set track listing to top
4938 scrollFrame:SetVerticalScroll(0)
4939 end
4940
4941 -- Populate ListData when editbox is changed by user
4942 sBox:HookScript("OnTextChanged", function(self, userInput)
4943 if userInput then
4944 -- Show search page
4945 conbtn[L["Search"]]:Click()
4946 -- If search results are currently playing, stop playback since search results will be changed
4947 if LastFolder == L["Search"] then stopBtn:Click() end
4948 -- Show search results
4949 ShowSearchResults()
4950 end
4951 end)
4952
4953 -- Populate ListData when editbox enter key is pressed
4954 sBox:HookScript("OnEnterPressed", function()
4955 -- Show search page
4956 conbtn[L["Search"]]:Click()
4957 -- If search results are currently playing, stop playback since search results will be changed
4958 if LastFolder == L["Search"] then stopBtn:Click() end
4959 -- Show search results
4960 ShowSearchResults()
4961 end)
4962
4963 -- Function to show random track listing
4964 local function ShowRandomList()
4965 -- If random track is currently playing, stop playback since random track list will be changed
4966 if LastFolder == L["Random"] then
4967 stopBtn:Click()
4968 end
4969 -- Wipe the track listing for random
4970 wipe(ListData)
4971 -- Set the track list heading
4972 ListData[1] = "|cffffd800" .. L["Random"]
4973 ListData[2] = "|Cffffffaa{" .. L["click here to shuffle music"] .. "}" -- Must be capital |C
4974 ListData[3] = "|cffffd800"
4975 ListData[4] = "|cffffd800" .. L["Music"] -- Must be lower case |c
4976 -- Populate list data until it contains desired number of tracks
4977 while #ListData < #ZoneList[L["Music"]] do
4978 -- Get random category
4979 local rCategory = GetRandomArgument(L["Music"])
4980 -- Get random track within zone
4981 local rTrack = ZoneList[rCategory][random(1, #ZoneList[L["Music"]])]
4982 -- Insert track into ListData if it's not a duplicate
4983 if rTrack and rTrack ~= "" and strfind(rTrack, "#") and not tContains(ListData, rTrack) then
4984 tinsert(ListData, rTrack)
4985 end
4986 end
4987 -- Refresh the track listing
4988 UpdateList()
4989 -- Set track listing to top
4990 scrollFrame:SetVerticalScroll(0)
4991 end
4992
4993 -- Show random track listing on startup when random button is clicked
4994 for q, w in pairs(ZoneList) do
4995 if conbtn[w] then
4996 conbtn[w]:HookScript("OnClick", function()
4997 if w == L["Random"] then
4998 -- Generate initial playlist for first run
4999 if #ListData == 0 then
5000 ShowRandomList()
5001 end
5002 end
5003 end)
5004 end
5005 end
5006
5007 -- Create list items
5008 scrollFrame.buttons = {}
5009 for i = 1, numButtons do
5010 scrollFrame.buttons[i] = CreateFrame("Button", nil, LeaPlusLC["Page9"])
5011 local button = scrollFrame.buttons[i]
5012
5013 button:SetSize(470 - 14, 16)
5014 button:SetNormalFontObject("GameFontHighlightLeft")
5015 button:SetPoint("TOPLEFT", 246, -62+ -(i - 1) * 16 - 8)
5016
5017 -- Create highlight bar texture
5018 button.t = button:CreateTexture(nil, "BACKGROUND")
5019 button.t:SetPoint("TOPLEFT", button, 0, 0)
5020 button.t:SetSize(516, 16)
5021
5022 button.t:SetColorTexture(0.3, 0.3, 0.0, 0.8)
5023 button.t:SetAlpha(0.7)
5024 button.t:Hide()
5025
5026 -- Create last playing highlight bar texture
5027 button.s = button:CreateTexture(nil, "BACKGROUND")
5028 button.s:SetPoint("TOPLEFT", button, 0, 0)
5029 button.s:SetSize(516, 16)
5030
5031 button.s:SetColorTexture(0.3, 0.4, 0.00, 0.6)
5032 button.s:Hide()
5033
5034 button:SetScript("OnEnter", function()
5035 -- Highlight links only
5036 if not string.match(button:GetText() or "", "|c") then
5037 button.t:Show()
5038 end
5039 end)
5040
5041 button:SetScript("OnLeave", function()
5042 button.t:Hide()
5043 end)
5044
5045 button:RegisterForClicks("LeftButtonUp", "RightButtonUp")
5046
5047 -- Handler for playing next SoundKit track in playlist
5048 uframe:SetScript("OnEvent", function(self, event, stoppedHandle)
5049 if event == "SOUNDKIT_FINISHED" then
5050 -- Do nothing if stopped sound kit handle doesnt match last played track handle
5051 if LastMusicHandle and LastMusicHandle ~= stoppedHandle then return end
5052 -- Reset track number if playlist has reached the end
5053 if tracknumber == #playlist then tracknumber = 1 end
5054 -- Play next track
5055 PlayTrack()
5056 elseif event == "LOADING_SCREEN_DISABLED" then
5057 -- Restart player if it stopped between tracks during loading screen
5058 if playlist and tracknumber and playlist[tracknumber] and not willPlay and not musicHandle then
5059 tracknumber = tracknumber - 1
5060 C_Timer.After(0.1, PlayTrack)
5061 end
5062 end
5063 end)
5064
5065 -- Click handler for track, zone and back button
5066 button:SetScript("OnClick", function(self, btn)
5067 if btn == "LeftButton" then
5068 -- Remove focus from search box
5069 sBox:ClearFocus()
5070 -- Get clicked track text
5071 local item = self:GetText()
5072 -- Do nothing if its a blank line or informational heading
5073 if not item or strfind(item, "|c") then return end
5074 if item == "|Cffffffaa{" .. L["click here to shuffle music"] .. "}" then -- must be capital |C
5075 -- Create new random track listing
5076 ShowRandomList()
5077 return
5078 elseif strfind(item, "#") then
5079 -- Enable sound if required
5080 if GetCVar("Sound_EnableAllSound") == "0" then SetCVar("Sound_EnableAllSound", "1") end
5081 -- Disable music if it's currently enabled
5082 if GetCVar("Sound_EnableMusic") == "1" then SetCVar("Sound_EnableMusic", "0") end
5083 -- Add all tracks to playlist
5084 wipe(playlist)
5085 local StartItem = 0
5086 -- Get item clicked row number
5087 for index = 1, #ListData do
5088 local item = ListData[index]
5089 if self:GetText() == item then StartItem = index end
5090 end
5091 -- Add all items from clicked item onwards to playlist
5092 for index = StartItem, #ListData do
5093 local item = ListData[index]
5094 if item then
5095 if strfind(item, "#") then
5096 tinsert(playlist, item)
5097 end
5098 end
5099 end
5100 -- Add all items up to clicked item to playlist
5101 for index = 1, StartItem do
5102 local item = ListData[index]
5103 if item then
5104 if strfind(item, "#") then
5105 tinsert(playlist, item)
5106 end
5107 end
5108 end
5109 -- Enable the stop button
5110 LeaPlusLC:LockItem(stopBtn, false)
5111 -- Set Temp Folder to currently playing folder
5112 TempFolder = L[gsub(ListData[1], "|cffffd800", "")]
5113 -- Store information about the track we are about to play
5114 tracknumber = 1
5115 LastPlayed = item
5116 LastFolder = TempFolder
5117 HeadingOfClickedTrack = ListData[1]
5118 -- Play first track
5119 PlayTrack()
5120 -- Play subsequent tracks (commented out for now because sound kits are not used)
5121 -- uframe:RegisterEvent("SOUNDKIT_FINISHED")
5122 -- uframe:RegisterEvent("LOADING_SCREEN_DISABLED")
5123 return
5124 elseif strfind(item, "|r") then
5125 -- A movie was clicked
5126 local movieName, movieID = item:match("([^,]+)%|r([^,]+)")
5127 movieID = strtrim(movieID, "()")
5128 if IsMoviePlayable(movieID) then
5129 stopBtn:Click()
5130 MovieFrame_PlayMovie(MovieFrame, movieID)
5131 else
5132 LeaPlusLC:Print("Movie not playable.")
5133 end
5134 return
5135 end
5136 end
5137 end)
5138
5139 end
5140
5141 -- Delete the global scroll frame pointer
5142 _G.LeaPlusScrollFrame = nil
5143
5144 -- Set zone listing on startup
5145 if LeaPlusDB["MusicContinent"] and LeaPlusDB["MusicContinent"] ~= "" then
5146 -- Saved music continent exists
5147 if conbtn[LeaPlusDB["MusicContinent"]] then
5148 -- Saved continent is valid button so click it
5149 conbtn[LeaPlusDB["MusicContinent"]]:Click()
5150 else
5151 -- Saved continent is not valid button so click default button
5152 conbtn[L["Music"]]:Click()
5153 end
5154 else
5155 -- Saved music continent does not exist so click default button
5156 conbtn[L["Music"]]:Click()
5157 end
5158 UpdateList()
5159
5160 -- Manage events
5161 LeaPlusLC["Page9"]:RegisterEvent("PLAYER_LOGOUT")
5162 LeaPlusLC["Page9"]:RegisterEvent("UI_SCALE_CHANGED")
5163 LeaPlusLC["Page9"]:SetScript("OnEvent", function(self, event)
5164 if event == "PLAYER_LOGOUT" then
5165 -- Stop playing at reload or logout
5166 if musicHandle then
5167 StopSound(musicHandle)
5168 end
5169 elseif event == "UI_SCALE_CHANGED" then
5170 -- Refresh list
5171 UpdateList()
5172 end
5173 end)
5174
5175 end
5176
5177 -- Run on startup
5178 LeaPlusLC:MediaFunc()
5179
5180 -- Release memory
5181 LeaPlusLC.MediaFunc = nil
5182
5183 ----------------------------------------------------------------------
5184 -- Panel alpha
5185 ----------------------------------------------------------------------
5186
5187 -- Function to set panel alpha
5188 local function SetPlusAlpha()
5189 -- Set panel alpha
5190 LeaPlusLC["PageF"].t:SetAlpha(1 - LeaPlusLC["PlusPanelAlpha"])
5191 -- Show formatted value
5192 LeaPlusCB["PlusPanelAlpha"].f:SetFormattedText("%.0f%%", LeaPlusLC["PlusPanelAlpha"] * 100)
5193 end
5194
5195 -- Set alpha on startup
5196 SetPlusAlpha()
5197
5198 -- Set alpha after changing slider
5199 LeaPlusCB["PlusPanelAlpha"]:HookScript("OnValueChanged", SetPlusAlpha)
5200
5201 ----------------------------------------------------------------------
5202 -- Panel scale
5203 ----------------------------------------------------------------------
5204
5205 -- Function to set panel scale
5206 local function SetPlusScale()
5207 -- Reset panel position
5208 LeaPlusLC["MainPanelA"], LeaPlusLC["MainPanelR"], LeaPlusLC["MainPanelX"], LeaPlusLC["MainPanelY"] = "CENTER", "CENTER", 0, 0
5209 if LeaPlusLC["PageF"]:IsShown() then
5210 LeaPlusLC["PageF"]:Hide()
5211 LeaPlusLC["PageF"]:Show()
5212 end
5213 -- Set panel scale
5214 LeaPlusLC["PageF"]:SetScale(LeaPlusLC["PlusPanelScale"])
5215 -- Update music player highlight bar scale
5216 LeaPlusLC:UpdateList()
5217 end
5218
5219 -- Set scale on startup
5220 LeaPlusLC["PageF"]:SetScale(LeaPlusLC["PlusPanelScale"])
5221
5222 -- Set scale and reset panel position after changing slider
5223 LeaPlusCB["PlusPanelScale"]:HookScript("OnMouseUp", SetPlusScale)
5224 LeaPlusCB["PlusPanelScale"]:HookScript("OnMouseWheel", SetPlusScale)
5225
5226 -- Show formatted slider value
5227 LeaPlusCB["PlusPanelScale"]:HookScript("OnValueChanged", function()
5228 LeaPlusCB["PlusPanelScale"].f:SetFormattedText("%.0f%%", LeaPlusLC["PlusPanelScale"] * 100)
5229 end)
5230
5231 ----------------------------------------------------------------------
5232 -- Options panel
5233 ----------------------------------------------------------------------
5234
5235 -- Hide Leatrix Plus if game options panel is shown
5236 InterfaceOptionsFrame:HookScript("OnShow", LeaPlusLC.HideFrames);
5237 VideoOptionsFrame:HookScript("OnShow", LeaPlusLC.HideFrames);
5238
5239 ----------------------------------------------------------------------
5240 -- Block friend requests
5241 ----------------------------------------------------------------------
5242
5243 -- Function to decline friend requests
5244 local function DeclineReqs()
5245 if LeaPlusLC["NoFriendRequests"] == "On" then
5246 for i = BNGetNumFriendInvites(), 1, -1 do
5247 local id, player = BNGetFriendInviteInfo(i)
5248 if id and player then
5249 BNDeclineFriendInvite(id)
5250 C_Timer.After(0.1, function()
5251 LeaPlusLC:Print(L["A friend request from"] .. " " .. player .. " " .. L["was automatically declined."])
5252 end)
5253 end
5254 end
5255 end
5256 end
5257
5258 -- Event frame for incoming friend requests
5259 local DecEvt = CreateFrame("FRAME")
5260 DecEvt:SetScript("OnEvent", DeclineReqs)
5261
5262 -- Function to register or unregister the event
5263 local function ControlEvent()
5264 if LeaPlusLC["NoFriendRequests"] == "On" then
5265 DecEvt:RegisterEvent("BN_FRIEND_INVITE_ADDED")
5266 DeclineReqs()
5267 else
5268 DecEvt:UnregisterEvent("BN_FRIEND_INVITE_ADDED")
5269 end
5270 end
5271
5272 -- Set event status when option is enabled
5273 LeaPlusCB["NoFriendRequests"]:HookScript("OnClick", ControlEvent)
5274
5275 -- Set event status on startup
5276 ControlEvent()
5277
5278 ----------------------------------------------------------------------
5279 -- Final code for RunOnce
5280 ----------------------------------------------------------------------
5281
5282 -- Update addon memory usage (speeds up initial value)
5283 UpdateAddOnMemoryUsage();
5284
5285 -- Release memory
5286 LeaPlusLC.RunOnce = nil
5287
5288 end
5289
5290----------------------------------------------------------------------
5291-- L60: Default events
5292----------------------------------------------------------------------
5293
5294 local function eventHandler(self, event, arg1, arg2, ...)
5295
5296 ----------------------------------------------------------------------
5297 -- Invite from whisper
5298 ----------------------------------------------------------------------
5299
5300 if event == "CHAT_MSG_WHISPER" or event == "CHAT_MSG_BN_WHISPER" then
5301 if (not UnitExists("party1") or UnitIsGroupLeader("player")) and strlower(arg1) == "inv" then
5302 if event == "CHAT_MSG_WHISPER" then
5303 InviteUnit(arg2)
5304 elseif event == "CHAT_MSG_BN_WHISPER" then
5305 local presenceID = select(11, ...)
5306 if presenceID and BNIsFriend(presenceID) then
5307 local index = BNGetFriendIndex(presenceID);
5308 if index then
5309 local presenceID, presenceName, battleTag, isBattleTagPresence, toonName, toonID = BNGetFriendInfo(index);
5310 if toonID then
5311 BNInviteFriend(toonID);
5312 end
5313 end
5314 end
5315 end
5316 end
5317 return
5318 end
5319
5320 ----------------------------------------------------------------------
5321 -- Block duel requests
5322 ----------------------------------------------------------------------
5323
5324 if event == "DUEL_REQUESTED" and not LeaPlusLC:FriendCheck(arg1) then
5325 CancelDuel();
5326 StaticPopup_Hide("DUEL_REQUESTED");
5327 return
5328 end
5329
5330 ----------------------------------------------------------------------
5331 -- Automatically accept resurrection requests
5332 ----------------------------------------------------------------------
5333
5334 if event == "RESURRECT_REQUEST" then
5335
5336 -- Resurrect automatically if not in combat
5337 if not UnitAffectingCombat(arg1) then
5338 AcceptResurrect()
5339 StaticPopup_Hide("RESURRECT_NO_TIMER")
5340 end
5341 return
5342
5343 end
5344
5345 ----------------------------------------------------------------------
5346 -- Accept summon
5347 ----------------------------------------------------------------------
5348
5349 if event == "CONFIRM_SUMMON" then
5350 if not UnitAffectingCombat("player") then
5351 ConfirmSummon()
5352 StaticPopup_Hide("CONFIRM_SUMMON")
5353 end
5354 return
5355 end
5356
5357 ----------------------------------------------------------------------
5358 -- Block party invites
5359 ----------------------------------------------------------------------
5360
5361 if event == "PARTY_INVITE_REQUEST" then
5362
5363 -- If a friend, accept if you're accepting friends
5364 if (LeaPlusLC["AcceptPartyFriends"] == "On" and LeaPlusLC:FriendCheck(arg1)) then
5365 AcceptGroup();
5366 for i=1, STATICPOPUP_NUMDIALOGS do
5367 if _G["StaticPopup"..i].which == "PARTY_INVITE" then
5368 _G["StaticPopup"..i].inviteAccepted = 1
5369 StaticPopup_Hide("PARTY_INVITE");
5370 break
5371 elseif _G["StaticPopup"..i].which == "PARTY_INVITE_XREALM" then
5372 _G["StaticPopup"..i].inviteAccepted = 1
5373 StaticPopup_Hide("PARTY_INVITE_XREALM");
5374 break
5375 end
5376 end
5377 return
5378 end
5379
5380 -- If not a friend and you're blocking invites, decline
5381 if LeaPlusLC["NoPartyInvites"] == "On" then
5382 if LeaPlusLC:FriendCheck(arg1) then
5383 return
5384 else
5385 DeclineGroup();
5386 StaticPopup_Hide("PARTY_INVITE");
5387 StaticPopup_Hide("PARTY_INVITE_XREALM");
5388 return
5389 end
5390 end
5391
5392 return
5393 end
5394
5395 ----------------------------------------------------------------------
5396 -- Disable loot warnings
5397 ----------------------------------------------------------------------
5398
5399 -- Disable warnings for attempting to roll Need on loot
5400 if event == "CONFIRM_LOOT_ROLL" then
5401 ConfirmLootRoll(arg1, arg2)
5402 StaticPopup_Hide("CONFIRM_LOOT_ROLL")
5403 return
5404 end
5405
5406 -- Disable warning for attempting to loot a Bind on Pickup item
5407 if event == "LOOT_BIND_CONFIRM" then
5408 ConfirmLootSlot(arg1, arg2)
5409 StaticPopup_Hide("LOOT_BIND",...)
5410 return
5411 end
5412
5413 -- Disable warning for attempting to vendor an item within its refund window
5414 if event == "MERCHANT_CONFIRM_TRADE_TIMER_REMOVAL" then
5415 SellCursorItem()
5416 return
5417 end
5418
5419 -- Disable warning for attempting to mail an item within its refund window
5420 if event == "MAIL_LOCK_SEND_ITEMS" then
5421 RespondMailLockSendItem(arg1, true)
5422 return
5423 end
5424
5425 ----------------------------------------------------------------------
5426 -- Automatically release in battlegrounds
5427 ----------------------------------------------------------------------
5428
5429 if event == "PLAYER_DEAD" then
5430
5431 -- If player has ability to self-resurrect (soulstone, reincarnation, etc), do nothing and quit
5432 if C_DeathInfo.GetSelfResurrectOptions() and #C_DeathInfo.GetSelfResurrectOptions() > 0 then return end
5433
5434 -- Resurrect if player is in a battleground
5435 local InstStat, InstType = IsInInstance()
5436 if InstStat and InstType == "pvp" then
5437 RepopMe()
5438 return
5439 end
5440
5441 return
5442
5443 end
5444
5445 ----------------------------------------------------------------------
5446 -- Hide the combat log
5447 ----------------------------------------------------------------------
5448
5449 if event == "UPDATE_CHAT_WINDOWS" then
5450 ChatFrame2Tab:EnableMouse(false)
5451 ChatFrame2Tab:SetText(" ") -- Needs to be something for chat settings to function
5452 ChatFrame2Tab:SetScale(0.01)
5453 ChatFrame2Tab:SetWidth(0.01)
5454 ChatFrame2Tab:SetHeight(0.01)
5455 end
5456
5457 ----------------------------------------------------------------------
5458 -- L62: Profile events
5459 ----------------------------------------------------------------------
5460
5461 if event == "ADDON_LOADED" then
5462 if arg1 == "Leatrix_Plus" then
5463
5464 -- Automation
5465 LeaPlusLC:LoadVarChk("AutomateQuests", "On") -- Automate quests
5466 LeaPlusLC:LoadVarChk("AutomateGossip", "On") -- Automate gossip
5467 LeaPlusLC:LoadVarChk("AutoAcceptSummon", "Off") -- Accept summon
5468 LeaPlusLC:LoadVarChk("AutoAcceptRes", "Off") -- Accept resurrection
5469 LeaPlusLC:LoadVarChk("AutoReleasePvP", "Off") -- Release in PvP
5470
5471 LeaPlusLC:LoadVarChk("AutoSellJunk", "On") -- Sell junk automatically
5472 LeaPlusLC:LoadVarChk("AutoRepairGear", "Off") -- Repair automatically
5473
5474 -- Social
5475 LeaPlusLC:LoadVarChk("NoDuelRequests", "Off") -- Block duels
5476 LeaPlusLC:LoadVarChk("NoPartyInvites", "Off") -- Block party invites
5477 LeaPlusLC:LoadVarChk("NoFriendRequests", "Off") -- Block friend requests
5478
5479 LeaPlusLC:LoadVarChk("AcceptPartyFriends", "Off") -- Party from friends
5480 LeaPlusLC:LoadVarChk("InviteFromWhisper", "Off") -- Invite from whispers
5481
5482 -- Chat
5483 LeaPlusLC:LoadVarChk("UseEasyChatResizing", "Off") -- Use easy resizing
5484 LeaPlusLC:LoadVarChk("NoCombatLogTab", "Off") -- Hide the combat log
5485 LeaPlusLC:LoadVarChk("NoChatButtons", "Off") -- Hide chat buttons
5486 LeaPlusLC:LoadVarChk("UnclampChat", "Off") -- Unclamp chat frame
5487 LeaPlusLC:LoadVarChk("MoveChatEditBoxToTop", "Off") -- Move editbox to top
5488
5489 LeaPlusLC:LoadVarChk("NoStickyChat", "Off") -- Disable sticky chat
5490 LeaPlusLC:LoadVarChk("UseArrowKeysInChat", "Off") -- Use arrow keys in chat
5491 LeaPlusLC:LoadVarChk("NoChatFade", "Off") -- Disable chat fade
5492 LeaPlusLC:LoadVarChk("UnivGroupColor", "Off") -- Universal group color
5493 LeaPlusLC:LoadVarChk("ClassColorsInChat", "Off") -- Use class colors in chat
5494 LeaPlusLC:LoadVarChk("RecentChatWindow", "Off") -- Recent chat window
5495 LeaPlusLC:LoadVarChk("MaxChatHstory", "Off") -- Increase chat history
5496
5497 -- Text
5498 LeaPlusLC:LoadVarChk("HideErrorMessages", "Off") -- Hide error messages
5499 LeaPlusLC:LoadVarChk("NoHitIndicators", "Off") -- Hide portrait text
5500 LeaPlusLC:LoadVarChk("HideZoneText", "Off") -- Hide zone text
5501
5502 LeaPlusLC:LoadVarChk("MailFontChange", "Off") -- Resize mail text
5503 LeaPlusLC:LoadVarNum("LeaPlusMailFontSize", 15, 10, 36) -- Mail text slider
5504
5505 LeaPlusLC:LoadVarChk("QuestFontChange", "Off") -- Resize quest text
5506 LeaPlusLC:LoadVarNum("LeaPlusQuestFontSize", 12, 10, 36) -- Quest text slider
5507
5508 -- Interface
5509 LeaPlusLC:LoadVarChk("MinimapMod", "Off") -- Customise minimap
5510 LeaPlusLC:LoadVarChk("HideZoneTextBar", "Off") -- Hide zone text bar
5511 LeaPlusLC:LoadVarChk("HideMiniZoomBtns", "Off") -- Hide zoom buttons
5512 LeaPlusLC:LoadVarNum("MinimapScale", 1, 1, 2) -- Minimap scale slider
5513
5514 LeaPlusLC:LoadVarChk("TipModEnable", "Off") -- Manage tooltip
5515 LeaPlusLC:LoadVarChk("TipMoveTip", "On") -- Reposition the tooltip
5516 LeaPlusLC:LoadVarChk("TipShowGuild", "On") -- Show guild
5517 LeaPlusLC:LoadVarChk("TipShowTarget", "On") -- Show target
5518 LeaPlusLC:LoadVarChk("TipBackSimple", "Off") -- Color backdrops
5519 LeaPlusLC:LoadVarChk("TipHideInCombat", "Off") -- Hide tooltips during combat
5520 LeaPlusLC:LoadVarNum("LeaPlusTipSize", 1.00, 0.50, 2.00) -- Tooltip scale slider
5521 LeaPlusLC:LoadVarNum("TipOffsetX", -13, -5000, 5000) -- Tooltip X offset
5522 LeaPlusLC:LoadVarNum("TipOffsetY", 94, -5000, 5000) -- Tooltip Y offset
5523
5524 LeaPlusLC:LoadVarChk("EnhanceDressup", "Off") -- Enhance dressup
5525 LeaPlusLC:LoadVarChk("ShowVolume", "Off") -- Show volume slider
5526 LeaPlusLC:LoadVarChk("AhExtras", "Off") -- Show auction controls
5527 LeaPlusLC:LoadVarChk("AhBuyoutOnly", "Off") -- Auction buyout only
5528 LeaPlusLC:LoadVarChk("AhGoldOnly", "Off") -- Auction gold only
5529
5530 LeaPlusLC:LoadVarChk("ShowCooldowns", "Off") -- Show cooldowns
5531 LeaPlusLC:LoadVarChk("ShowCooldownID", "On") -- Show cooldown ID in tips
5532 LeaPlusLC:LoadVarChk("NoCooldownDuration", "On") -- Hide cooldown duration
5533 LeaPlusLC:LoadVarChk("DurabilityStatus", "Off") -- Show durability status
5534 LeaPlusLC:LoadVarChk("ShowVanityControls", "Off") -- Show vanity controls
5535 LeaPlusLC:LoadVarChk("ShowWowheadLinks", "Off") -- Show Wowhead links
5536
5537 -- Frames
5538 LeaPlusLC:LoadVarChk("FrmEnabled", "Off") -- Manage frames
5539 LeaPlusLC:LoadVarChk("ClassColFrames", "Off") -- Class colored frames
5540 LeaPlusLC:LoadVarChk("ShowPlayerChain", "Off") -- Show player chain
5541 LeaPlusLC:LoadVarNum("PlayerChainMenu", 2, 1, 3) -- Player chain dropdown value
5542 LeaPlusLC:LoadVarChk("ShowRaidToggle", "Off") -- Show raid toggle button
5543 LeaPlusLC:LoadVarChk("CombatPlates", "Off") -- Combat plates
5544
5545 LeaPlusLC:LoadVarChk("NoGryphons", "Off") -- Hide gryphons
5546 LeaPlusLC:LoadVarChk("NoClassBar", "Off") -- Hide stance bar
5547
5548 -- System
5549 LeaPlusLC:LoadVarChk("NoScreenGlow", "Off") -- Disable screen glow
5550 LeaPlusLC:LoadVarChk("NoScreenEffects", "Off") -- Disable screen effects
5551 LeaPlusLC:LoadVarChk("MaxCameraZoom", "Off") -- Max camera zoom
5552 LeaPlusLC:LoadVarChk("ViewPortEnable", "Off") -- Enable viewport
5553 LeaPlusLC:LoadVarNum("ViewPortTop", 0, 0, 300) -- Top border
5554 LeaPlusLC:LoadVarNum("ViewPortBottom", 0, 0, 300) -- Bottom border
5555 LeaPlusLC:LoadVarNum("ViewPortLeft", 0, 0, 300) -- Left border
5556 LeaPlusLC:LoadVarNum("ViewPortRight", 0, 0, 300) -- Right border
5557 LeaPlusLC:LoadVarNum("ViewPortResizeTop", 0, 0, 300) -- Resize top border
5558 LeaPlusLC:LoadVarNum("ViewPortResizeBottom", 0, 0, 300) -- Resize bottom border
5559 LeaPlusLC:LoadVarNum("ViewPortAlpha", 0, 0, 0.9) -- Border alpha
5560
5561 LeaPlusLC:LoadVarChk("NoRestedEmotes", "Off") -- Silence rested emotes
5562
5563 LeaPlusLC:LoadVarChk("NoBagAutomation", "Off") -- Disable bag automation
5564 LeaPlusLC:LoadVarChk("CharAddonList", "Off") -- Show character addons
5565 LeaPlusLC:LoadVarChk("NoConfirmLoot", "Off") -- Disable loot warnings
5566 LeaPlusLC:LoadVarChk("FasterLooting", "Off") -- Faster auto loot
5567 LeaPlusLC:LoadVarChk("FasterMovieSkip", "Off") -- Faster movie skip
5568 LeaPlusLC:LoadVarChk("StandAndDismount", "On") -- Stand and dismount
5569 LeaPlusLC:LoadVarChk("ShowVendorPrice", "Off") -- Show vendor price
5570
5571 -- Settings
5572 LeaPlusLC:LoadVarChk("ShowMinimapIcon", "On") -- Show minimap button
5573 LeaPlusLC:LoadVarChk("EnableHotkey", "Off") -- Enable hotkey
5574
5575 LeaPlusLC:LoadVarNum("PlusPanelScale", 1, 1, 2) -- Panel scale
5576 LeaPlusLC:LoadVarNum("PlusPanelAlpha", 0, 0, 1) -- Panel alpha
5577
5578 -- Panel position
5579 LeaPlusLC:LoadVarAnc("MainPanelA", "CENTER") -- Panel anchor
5580 LeaPlusLC:LoadVarAnc("MainPanelR", "CENTER") -- Panel relative
5581 LeaPlusLC:LoadVarNum("MainPanelX", 0, -5000, 5000) -- Panel X axis
5582 LeaPlusLC:LoadVarNum("MainPanelY", 0, -5000, 5000) -- Panel Y axis
5583
5584 -- Start page
5585 LeaPlusLC:LoadVarNum("LeaStartPage", 0, 0, LeaPlusLC["NumberOfPages"])
5586
5587 -- Run other startup items
5588 LeaPlusLC:Live()
5589 LeaPlusLC:Isolated()
5590 LeaPlusLC:RunOnce()
5591 LeaPlusLC:SetDim()
5592
5593 end
5594 return
5595 end
5596
5597 if event == "PLAYER_LOGIN" then
5598 LeaPlusLC:Player()
5599 collectgarbage()
5600 return
5601 end
5602
5603 -- Save locals back to globals on logout
5604 if event == "PLAYER_LOGOUT" then
5605
5606 -- Run the logout function without wipe flag
5607 LeaPlusLC:PlayerLogout(false)
5608
5609 -- Automation
5610 LeaPlusDB["AutomateQuests"] = LeaPlusLC["AutomateQuests"]
5611 LeaPlusDB["AutomateGossip"] = LeaPlusLC["AutomateGossip"]
5612 LeaPlusDB["AutoAcceptSummon"] = LeaPlusLC["AutoAcceptSummon"]
5613 LeaPlusDB["AutoAcceptRes"] = LeaPlusLC["AutoAcceptRes"]
5614 LeaPlusDB["AutoReleasePvP"] = LeaPlusLC["AutoReleasePvP"]
5615
5616 LeaPlusDB["AutoSellJunk"] = LeaPlusLC["AutoSellJunk"]
5617 LeaPlusDB["AutoRepairGear"] = LeaPlusLC["AutoRepairGear"]
5618
5619 -- Social
5620 LeaPlusDB["NoDuelRequests"] = LeaPlusLC["NoDuelRequests"]
5621 LeaPlusDB["NoPartyInvites"] = LeaPlusLC["NoPartyInvites"]
5622 LeaPlusDB["NoFriendRequests"] = LeaPlusLC["NoFriendRequests"]
5623
5624 LeaPlusDB["AcceptPartyFriends"] = LeaPlusLC["AcceptPartyFriends"]
5625 LeaPlusDB["InviteFromWhisper"] = LeaPlusLC["InviteFromWhisper"]
5626
5627 -- Chat
5628 LeaPlusDB["UseEasyChatResizing"] = LeaPlusLC["UseEasyChatResizing"]
5629 LeaPlusDB["NoCombatLogTab"] = LeaPlusLC["NoCombatLogTab"]
5630 LeaPlusDB["NoChatButtons"] = LeaPlusLC["NoChatButtons"]
5631 LeaPlusDB["UnclampChat"] = LeaPlusLC["UnclampChat"]
5632 LeaPlusDB["MoveChatEditBoxToTop"] = LeaPlusLC["MoveChatEditBoxToTop"]
5633
5634 LeaPlusDB["NoStickyChat"] = LeaPlusLC["NoStickyChat"]
5635 LeaPlusDB["UseArrowKeysInChat"] = LeaPlusLC["UseArrowKeysInChat"]
5636 LeaPlusDB["NoChatFade"] = LeaPlusLC["NoChatFade"]
5637 LeaPlusDB["UnivGroupColor"] = LeaPlusLC["UnivGroupColor"]
5638 LeaPlusDB["ClassColorsInChat"] = LeaPlusLC["ClassColorsInChat"]
5639 LeaPlusDB["RecentChatWindow"] = LeaPlusLC["RecentChatWindow"]
5640 LeaPlusDB["MaxChatHstory"] = LeaPlusLC["MaxChatHstory"]
5641
5642 -- Text
5643 LeaPlusDB["HideErrorMessages"] = LeaPlusLC["HideErrorMessages"]
5644 LeaPlusDB["NoHitIndicators"] = LeaPlusLC["NoHitIndicators"]
5645 LeaPlusDB["HideZoneText"] = LeaPlusLC["HideZoneText"]
5646
5647 LeaPlusDB["MailFontChange"] = LeaPlusLC["MailFontChange"]
5648 LeaPlusDB["LeaPlusMailFontSize"] = LeaPlusLC["LeaPlusMailFontSize"]
5649
5650 LeaPlusDB["QuestFontChange"] = LeaPlusLC["QuestFontChange"]
5651 LeaPlusDB["LeaPlusQuestFontSize"] = LeaPlusLC["LeaPlusQuestFontSize"]
5652
5653 -- Interface
5654 LeaPlusDB["MinimapMod"] = LeaPlusLC["MinimapMod"]
5655 LeaPlusDB["HideZoneTextBar"] = LeaPlusLC["HideZoneTextBar"]
5656 LeaPlusDB["HideMiniZoomBtns"] = LeaPlusLC["HideMiniZoomBtns"]
5657 LeaPlusDB["MinimapScale"] = LeaPlusLC["MinimapScale"]
5658
5659 LeaPlusDB["TipModEnable"] = LeaPlusLC["TipModEnable"]
5660 LeaPlusDB["TipMoveTip"] = LeaPlusLC["TipMoveTip"]
5661 LeaPlusDB["TipShowGuild"] = LeaPlusLC["TipShowGuild"]
5662 LeaPlusDB["TipShowTarget"] = LeaPlusLC["TipShowTarget"]
5663 LeaPlusDB["TipBackSimple"] = LeaPlusLC["TipBackSimple"]
5664 LeaPlusDB["TipHideInCombat"] = LeaPlusLC["TipHideInCombat"]
5665 LeaPlusDB["LeaPlusTipSize"] = LeaPlusLC["LeaPlusTipSize"]
5666 LeaPlusDB["TipOffsetX"] = LeaPlusLC["TipOffsetX"]
5667 LeaPlusDB["TipOffsetY"] = LeaPlusLC["TipOffsetY"]
5668
5669 LeaPlusDB["EnhanceDressup"] = LeaPlusLC["EnhanceDressup"]
5670 LeaPlusDB["ShowVolume"] = LeaPlusLC["ShowVolume"]
5671 LeaPlusDB["AhExtras"] = LeaPlusLC["AhExtras"]
5672 LeaPlusDB["AhBuyoutOnly"] = LeaPlusLC["AhBuyoutOnly"]
5673 LeaPlusDB["AhGoldOnly"] = LeaPlusLC["AhGoldOnly"]
5674
5675 LeaPlusDB["ShowCooldowns"] = LeaPlusLC["ShowCooldowns"]
5676 LeaPlusDB["ShowCooldownID"] = LeaPlusLC["ShowCooldownID"]
5677 LeaPlusDB["NoCooldownDuration"] = LeaPlusLC["NoCooldownDuration"]
5678 LeaPlusDB["DurabilityStatus"] = LeaPlusLC["DurabilityStatus"]
5679 LeaPlusDB["ShowVanityControls"] = LeaPlusLC["ShowVanityControls"]
5680 LeaPlusDB["ShowWowheadLinks"] = LeaPlusLC["ShowWowheadLinks"]
5681
5682 -- Frames
5683 LeaPlusDB["FrmEnabled"] = LeaPlusLC["FrmEnabled"]
5684 LeaPlusDB["ClassColFrames"] = LeaPlusLC["ClassColFrames"]
5685 LeaPlusDB["ShowPlayerChain"] = LeaPlusLC["ShowPlayerChain"]
5686 LeaPlusDB["PlayerChainMenu"] = LeaPlusLC["PlayerChainMenu"]
5687 LeaPlusDB["ShowRaidToggle"] = LeaPlusLC["ShowRaidToggle"]
5688 LeaPlusDB["CombatPlates"] = LeaPlusLC["CombatPlates"]
5689
5690 LeaPlusDB["NoGryphons"] = LeaPlusLC["NoGryphons"]
5691 LeaPlusDB["NoClassBar"] = LeaPlusLC["NoClassBar"]
5692
5693 -- System
5694 LeaPlusDB["NoScreenGlow"] = LeaPlusLC["NoScreenGlow"]
5695 LeaPlusDB["NoScreenEffects"] = LeaPlusLC["NoScreenEffects"]
5696 LeaPlusDB["MaxCameraZoom"] = LeaPlusLC["MaxCameraZoom"]
5697 LeaPlusDB["ViewPortEnable"] = LeaPlusLC["ViewPortEnable"]
5698 LeaPlusDB["ViewPortTop"] = LeaPlusLC["ViewPortTop"]
5699 LeaPlusDB["ViewPortBottom"] = LeaPlusLC["ViewPortBottom"]
5700 LeaPlusDB["ViewPortLeft"] = LeaPlusLC["ViewPortLeft"]
5701 LeaPlusDB["ViewPortRight"] = LeaPlusLC["ViewPortRight"]
5702 LeaPlusDB["ViewPortResizeTop"] = LeaPlusLC["ViewPortResizeTop"]
5703 LeaPlusDB["ViewPortResizeBottom"] = LeaPlusLC["ViewPortResizeBottom"]
5704 LeaPlusDB["ViewPortAlpha"] = LeaPlusLC["ViewPortAlpha"]
5705
5706 LeaPlusDB["NoRestedEmotes"] = LeaPlusLC["NoRestedEmotes"]
5707
5708 LeaPlusDB["NoBagAutomation"] = LeaPlusLC["NoBagAutomation"]
5709 LeaPlusDB["CharAddonList"] = LeaPlusLC["CharAddonList"]
5710 LeaPlusDB["NoConfirmLoot"] = LeaPlusLC["NoConfirmLoot"]
5711 LeaPlusDB["FasterLooting"] = LeaPlusLC["FasterLooting"]
5712 LeaPlusDB["FasterMovieSkip"] = LeaPlusLC["FasterMovieSkip"]
5713 LeaPlusDB["StandAndDismount"] = LeaPlusLC["StandAndDismount"]
5714 LeaPlusDB["ShowVendorPrice"] = LeaPlusLC["ShowVendorPrice"]
5715
5716 -- Settings
5717 LeaPlusDB["ShowMinimapIcon"] = LeaPlusLC["ShowMinimapIcon"]
5718 LeaPlusDB["EnableHotkey"] = LeaPlusLC["EnableHotkey"]
5719
5720 LeaPlusDB["PlusPanelScale"] = LeaPlusLC["PlusPanelScale"]
5721 LeaPlusDB["PlusPanelAlpha"] = LeaPlusLC["PlusPanelAlpha"]
5722
5723 -- Panel position
5724 LeaPlusDB["MainPanelA"] = LeaPlusLC["MainPanelA"]
5725 LeaPlusDB["MainPanelR"] = LeaPlusLC["MainPanelR"]
5726 LeaPlusDB["MainPanelX"] = LeaPlusLC["MainPanelX"]
5727 LeaPlusDB["MainPanelY"] = LeaPlusLC["MainPanelY"]
5728
5729 -- Start page
5730 LeaPlusDB["LeaStartPage"] = LeaPlusLC["LeaStartPage"]
5731
5732 end
5733
5734 end
5735
5736-- Register event handler
5737 LpEvt:SetScript("OnEvent", eventHandler);
5738
5739----------------------------------------------------------------------
5740-- L70: Player logout
5741----------------------------------------------------------------------
5742
5743 -- Player Logout
5744 function LeaPlusLC:PlayerLogout(wipe)
5745
5746 ----------------------------------------------------------------------
5747 -- Restore default values for options that do not require reloads
5748 ----------------------------------------------------------------------
5749
5750 -- Disable screen glow (LeaPlusLC["NoScreenGlow"])
5751 if wipe then
5752
5753 -- Disable screen glow (LeaPlusLC["NoScreenGlow"])
5754 SetCVar("ffxGlow", "1")
5755
5756 -- Disable screen effects (LeaPlusLC["NoScreenEffects"])
5757 SetCVar("ffxDeath", "1")
5758 SetCVar("ffxNether", "1")
5759
5760 -- Max camera zoom (LeaPlusLC["MaxCameraZoom"])
5761 SetCVar("cameraDistanceMaxZoomFactor", 1.9)
5762
5763 -- Universal group color (LeaPlusLC["UnivGroupColor"])
5764 ChangeChatColor("RAID", 1, 0.50, 0)
5765 ChangeChatColor("RAID_LEADER", 1, 0.28, 0.04)
5766 ChangeChatColor("INSTANCE_CHAT", 1, 0.50, 0)
5767 ChangeChatColor("INSTANCE_CHAT_LEADER", 1, 0.28, 0.04)
5768
5769 -- Use class colors in chat (LeaPlusLC["ClassColorsInChat"])
5770 SetCVar("chatClassColorOverride", "1")
5771
5772 end
5773
5774 ----------------------------------------------------------------------
5775 -- Restore default values for options that require reloads
5776 ----------------------------------------------------------------------
5777
5778 -- Silence rested emotes
5779 if LeaPlusDB["NoRestedEmotes"] == "On" then
5780 if wipe or (not wipe and LeaPlusLC["NoRestedEmotes"] == "Off") then
5781 SetCVar("Sound_EnableEmoteSounds", "1")
5782 end
5783 end
5784
5785 ----------------------------------------------------------------------
5786 -- Do other stuff during logout
5787 ----------------------------------------------------------------------
5788
5789 -- Prevent frame caching if frame customisation is enabled
5790 if LeaPlusDB["FrmEnabled"] == "On" then
5791 PlayerFrame:SetMovable(true)
5792 PlayerFrame:SetUserPlaced(false)
5793 TargetFrame:SetMovable(true)
5794 TargetFrame:SetUserPlaced(false)
5795 end
5796
5797 -- Store the auction house duration and price type values if auction house option is enabled
5798 if LeaPlusDB["AhExtras"] == "On" then
5799 if AuctionFrameAuctions then
5800 if AuctionFrameAuctions.duration then
5801 LeaPlusDB["AHDuration"] = AuctionFrameAuctions.duration
5802 end
5803 end
5804 end
5805
5806 end
5807
5808----------------------------------------------------------------------
5809-- Options panel functions
5810----------------------------------------------------------------------
5811
5812 -- Function to add textures to panels
5813 function LeaPlusLC:CreateBar(name, parent, width, height, anchor, r, g, b, alp, tex)
5814 local ft = parent:CreateTexture(nil, "BORDER")
5815 ft:SetTexture(tex)
5816 ft:SetSize(width, height)
5817 ft:SetPoint(anchor)
5818 ft:SetVertexColor(r ,g, b, alp)
5819 if name == "MainTexture" then
5820 ft:SetTexCoord(0.09, 1, 0, 1);
5821 end
5822 end
5823
5824 -- Create a configuration panel
5825 function LeaPlusLC:CreatePanel(title, globref)
5826
5827 -- Create the panel
5828 local Side = CreateFrame("Frame", nil, UIParent)
5829
5830 -- Make it a system frame
5831 _G["LeaPlusGlobalPanel_" .. globref] = Side
5832 table.insert(UISpecialFrames, "LeaPlusGlobalPanel_" .. globref)
5833
5834 -- Store it in the configuration panel table
5835 tinsert(LeaConfigList, Side)
5836
5837 -- Set frame parameters
5838 Side:Hide();
5839 Side:SetSize(570, 370);
5840 Side:SetClampedToScreen(true)
5841 Side:SetClampRectInsets(500, -500, -300, 300)
5842 Side:SetFrameStrata("FULLSCREEN_DIALOG")
5843
5844 -- Set the background color
5845 Side.t = Side:CreateTexture(nil, "BACKGROUND")
5846 Side.t:SetAllPoints()
5847 Side.t:SetColorTexture(0.05, 0.05, 0.05, 0.9)
5848
5849 -- Add a close Button
5850 Side.c = CreateFrame("Button", nil, Side, "UIPanelCloseButton")
5851 Side.c:SetSize(30, 30)
5852 Side.c:SetPoint("TOPRIGHT", 0, 0)
5853 Side.c:SetScript("OnClick", function() Side:Hide() end)
5854
5855 -- Add reset, help and back buttons
5856 Side.r = LeaPlusLC:CreateButton("ResetButton", Side, "Reset", "TOPLEFT", 16, -292, 0, 25, true, "Click to reset the settings on this page.")
5857 Side.h = LeaPlusLC:CreateButton("HelpButton", Side, "Help", "TOPLEFT", 76, -292, 0, 25, true, "No help is available for this page.")
5858 Side.b = LeaPlusLC:CreateButton("BackButton", Side, "Back to Main Menu", "TOPRIGHT", -16, -292, 0, 25, true, "Click to return to the main menu.")
5859
5860 -- Reposition help button so it doesn't overlap reset button
5861 Side.h:ClearAllPoints()
5862 Side.h:SetPoint("LEFT", Side.r, "RIGHT", 10, 0)
5863
5864 -- Remove the click texture from the help button
5865 Side.h:SetPushedTextOffset(0, 0)
5866
5867 -- Add a reload button and syncronise it with the main panel reload button
5868 local reloadb = LeaPlusLC:CreateButton("ConfigReload", Side, "Reload", "BOTTOMRIGHT", -16, 10, 0, 25, true, LeaPlusCB["ReloadUIButton"].tiptext)
5869 LeaPlusLC:LockItem(reloadb,true)
5870 reloadb:SetScript("OnClick", ReloadUI)
5871
5872 reloadb.f = reloadb:CreateFontString(nil, 'ARTWORK', 'GameFontNormalSmall')
5873 reloadb.f:SetHeight(32);
5874 reloadb.f:SetPoint('RIGHT', reloadb, 'LEFT', -10, 0)
5875 reloadb.f:SetText(LeaPlusCB["ReloadUIButton"].f:GetText())
5876 reloadb.f:Hide()
5877
5878 LeaPlusCB["ReloadUIButton"]:HookScript("OnEnable", function()
5879 LeaPlusLC:LockItem(reloadb, false)
5880 reloadb.f:Show()
5881 end)
5882
5883 LeaPlusCB["ReloadUIButton"]:HookScript("OnDisable", function()
5884 LeaPlusLC:LockItem(reloadb, true)
5885 reloadb.f:Hide()
5886 end)
5887
5888 -- Set textures
5889 LeaPlusLC:CreateBar("FootTexture", Side, 570, 48, "BOTTOM", 0.5, 0.5, 0.5, 1.0, "Interface\\ACHIEVEMENTFRAME\\UI-GuildAchievement-Parchment-Horizontal-Desaturated.png")
5890 LeaPlusLC:CreateBar("MainTexture", Side, 570, 323, "TOPRIGHT", 0.7, 0.7, 0.7, 0.7, "Interface\\ACHIEVEMENTFRAME\\UI-GuildAchievement-Parchment-Horizontal-Desaturated.png")
5891
5892 -- Allow movement
5893 Side:EnableMouse(true)
5894 Side:SetMovable(true)
5895 Side:RegisterForDrag("LeftButton")
5896 Side:SetScript("OnDragStart", Side.StartMoving)
5897 Side:SetScript("OnDragStop", function ()
5898 Side:StopMovingOrSizing();
5899 Side:SetUserPlaced(false);
5900 -- Save panel position
5901 LeaPlusLC["MainPanelA"], void, LeaPlusLC["MainPanelR"], LeaPlusLC["MainPanelX"], LeaPlusLC["MainPanelY"] = Side:GetPoint()
5902 end)
5903
5904 -- Set panel attributes when shown
5905 Side:SetScript("OnShow", function()
5906 Side:ClearAllPoints()
5907 Side:SetPoint(LeaPlusLC["MainPanelA"], UIParent, LeaPlusLC["MainPanelR"], LeaPlusLC["MainPanelX"], LeaPlusLC["MainPanelY"])
5908 Side:SetScale(LeaPlusLC["PlusPanelScale"])
5909 Side.t:SetAlpha(1 - LeaPlusLC["PlusPanelAlpha"])
5910 end)
5911
5912 -- Add title
5913 Side.f = Side:CreateFontString(nil, 'ARTWORK', 'GameFontNormalLarge')
5914 Side.f:SetPoint('TOPLEFT', 16, -16);
5915 Side.f:SetText(L[title])
5916
5917 -- Add description
5918 Side.v = Side:CreateFontString(nil, 'ARTWORK', 'GameFontHighlightSmall')
5919 Side.v:SetHeight(32);
5920 Side.v:SetPoint('TOPLEFT', Side.f, 'BOTTOMLEFT', 0, -8);
5921 Side.v:SetPoint('RIGHT', Side, -32, 0)
5922 Side.v:SetJustifyH('LEFT'); Side.v:SetJustifyV('TOP');
5923 Side.v:SetText(L["Configuration Panel"])
5924
5925 -- Prevent options panel from showing while side panel is showing
5926 LeaPlusLC["PageF"]:HookScript("OnShow", function()
5927 if Side:IsShown() then LeaPlusLC["PageF"]:Hide(); end
5928 end)
5929
5930 -- Return the frame
5931 return Side
5932
5933 end
5934
5935 -- Define subheadings
5936 function LeaPlusLC:MakeTx(frame, title, x, y)
5937 local text = frame:CreateFontString(nil, 'ARTWORK', 'GameFontNormal')
5938 text:SetPoint("TOPLEFT", x, y)
5939 text:SetText(L[title])
5940 end
5941
5942 -- Define text
5943 function LeaPlusLC:MakeWD(frame, title, x, y)
5944 local text = frame:CreateFontString(nil, 'ARTWORK', 'GameFontHighlight')
5945 text:SetPoint("TOPLEFT", x, y)
5946 text:SetText(L[title])
5947 text:SetJustifyH"LEFT";
5948 end
5949
5950 -- Create a slider control (uses standard template)
5951 function LeaPlusLC:MakeSL(frame, field, caption, low, high, step, x, y, form)
5952
5953 -- Create slider control
5954 local Slider = CreateFrame("Slider", "LeaPlusGlobalSlider" .. field, frame, "OptionssliderTemplate")
5955 LeaPlusCB[field] = Slider;
5956 Slider:SetMinMaxValues(low, high)
5957 Slider:SetValueStep(step)
5958 Slider:EnableMouseWheel(true)
5959 Slider:SetPoint('TOPLEFT', x,y)
5960 Slider:SetWidth(100)
5961 Slider:SetHeight(20)
5962 Slider:SetHitRectInsets(0, 0, 0, 0);
5963 Slider.tiptext = caption
5964 Slider:SetScript("OnEnter", LeaPlusLC.TipSee)
5965 Slider:SetScript("OnLeave", GameTooltip_Hide)
5966
5967 -- Remove slider text
5968 _G[Slider:GetName().."Low"]:SetText('');
5969 _G[Slider:GetName().."High"]:SetText('');
5970
5971 -- Create slider label
5972 Slider.f = Slider:CreateFontString(nil, 'BACKGROUND')
5973 Slider.f:SetFontObject('GameFontHighlight')
5974 Slider.f:SetPoint('LEFT', Slider, 'RIGHT', 12, 0)
5975 Slider.f:SetFormattedText("%.2f", Slider:GetValue())
5976
5977 -- Process mousewheel scrolling
5978 Slider:SetScript("OnMouseWheel", function(self, arg1)
5979 if Slider:IsEnabled() then
5980 local step = step * arg1
5981 local value = self:GetValue()
5982 if step > 0 then
5983 self:SetValue(min(value + step, high))
5984 else
5985 self:SetValue(max(value + step, low))
5986 end
5987 end
5988 end)
5989
5990 -- Process value changed
5991 Slider:SetScript("OnValueChanged", function(self, value)
5992 local value = floor((value - low) / step + 0.5) * step + low
5993 Slider.f:SetFormattedText(form, value)
5994 LeaPlusLC[field] = value
5995 end)
5996
5997 -- Set slider value when shown
5998 Slider:SetScript("OnShow", function(self)
5999 self:SetValue(LeaPlusLC[field])
6000 end)
6001
6002 end
6003
6004 -- Create a checkbox control (uses standard template)
6005 function LeaPlusLC:MakeCB(parent, field, caption, x, y, reload, tip, tipstyle)
6006
6007 -- Create the checkbox
6008 local Cbox = CreateFrame('CheckButton', nil, parent, "ChatConfigCheckButtonTemplate")
6009 LeaPlusCB[field] = Cbox
6010 Cbox:SetPoint("TOPLEFT",x, y)
6011 Cbox:SetScript("OnEnter", LeaPlusLC.TipSee)
6012 Cbox:SetScript("OnLeave", GameTooltip_Hide)
6013
6014 -- Add label and tooltip
6015 Cbox.f = Cbox:CreateFontString(nil, 'ARTWORK', 'GameFontHighlight')
6016 Cbox.f:SetPoint('LEFT', 20, 0)
6017 if reload then
6018 -- Checkbox requires UI reload
6019 Cbox.f:SetText(L[caption] .. "*")
6020 Cbox.tiptext = L[tip] .. "|n|n* " .. L["Requires UI reload."]
6021 else
6022 -- Checkbox does not require UI reload
6023 Cbox.f:SetText(L[caption])
6024 Cbox.tiptext = L[tip]
6025 end
6026
6027 -- Set label parameters
6028 Cbox.f:SetJustifyH("LEFT")
6029 Cbox.f:SetWordWrap(false)
6030
6031 -- Set maximum label width
6032 if parent:GetParent() == LeaPlusLC["PageF"] then
6033 -- Main panel checkbox labels
6034 if Cbox.f:GetWidth() > 152 then
6035 Cbox.f:SetWidth(152)
6036 LeaPlusLC["TruncatedLabelsList"] = LeaPlusLC["TruncatedLabelsList"] or {}
6037 LeaPlusLC["TruncatedLabelsList"][Cbox.f] = L[caption]
6038 end
6039 -- Set checkbox click width
6040 if Cbox.f:GetStringWidth() > 152 then
6041 Cbox:SetHitRectInsets(0, -142, 0, 0)
6042 else
6043 Cbox:SetHitRectInsets(0, -Cbox.f:GetStringWidth() + 4, 0, 0)
6044 end
6045 else
6046 -- Configuration panel checkbox labels (other checkboxes either have custom functions or blank labels)
6047 if Cbox.f:GetWidth() > 302 then
6048 Cbox.f:SetWidth(302)
6049 LeaPlusLC["TruncatedLabelsList"] = LeaPlusLC["TruncatedLabelsList"] or {}
6050 LeaPlusLC["TruncatedLabelsList"][Cbox.f] = L[caption]
6051 end
6052 -- Set checkbox click width
6053 if Cbox.f:GetStringWidth() > 302 then
6054 Cbox:SetHitRectInsets(0, -292, 0, 0)
6055 else
6056 Cbox:SetHitRectInsets(0, -Cbox.f:GetStringWidth() + 4, 0, 0)
6057 end
6058 end
6059
6060 -- Set default checkbox state and click area
6061 Cbox:SetScript('OnShow', function(self)
6062 if LeaPlusLC[field] == "On" then
6063 self:SetChecked(true)
6064 else
6065 self:SetChecked(false)
6066 end
6067 end)
6068
6069 -- Process clicks
6070 Cbox:SetScript('OnClick', function()
6071 if Cbox:GetChecked() then
6072 LeaPlusLC[field] = "On"
6073 else
6074 LeaPlusLC[field] = "Off"
6075 end
6076 LeaPlusLC:SetDim(); -- Lock invalid options
6077 LeaPlusLC:ReloadCheck(); -- Show reload button if needed
6078 LeaPlusLC:Live(); -- Run live code
6079 end)
6080 end
6081
6082 -- Create an editbox (uses standard template)
6083 function LeaPlusLC:CreateEditBox(frame, parent, width, maxchars, anchor, x, y, tab, shifttab)
6084
6085 -- Create editbox
6086 local eb = CreateFrame("EditBox", nil, parent, "InputBoxTemplate")
6087 LeaPlusCB[frame] = eb
6088 eb:SetPoint(anchor, x, y)
6089 eb:SetWidth(width)
6090 eb:SetHeight(24)
6091 eb:SetFontObject("GameFontNormal")
6092 eb:SetTextColor(1.0, 1.0, 1.0)
6093 eb:SetAutoFocus(false)
6094 eb:SetMaxLetters(maxchars)
6095 eb:SetScript("OnEscapePressed", eb.ClearFocus)
6096 eb:SetScript("OnEnterPressed", eb.ClearFocus)
6097
6098 -- Add editbox border and backdrop
6099 eb.f = CreateFrame("FRAME", nil, eb)
6100 eb.f:SetBackdrop({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", tile = false, tileSize = 16, edgeSize = 16, insets = { left = 5, right = 5, top = 5, bottom = 5 }})
6101 eb.f:SetPoint("LEFT", -6, 0)
6102 eb.f:SetWidth(eb:GetWidth()+6)
6103 eb.f:SetHeight(eb:GetHeight())
6104 eb.f:SetBackdropColor(1.0, 1.0, 1.0, 0.3)
6105
6106 -- Move onto next editbox when tab key is pressed
6107 eb:SetScript("OnTabPressed", function(self)
6108 self:ClearFocus()
6109 if IsShiftKeyDown() then
6110 LeaPlusCB[shifttab]:SetFocus()
6111 else
6112 LeaPlusCB[tab]:SetFocus()
6113 end
6114 end)
6115
6116 return eb
6117
6118 end
6119
6120 -- Create a standard button (using standard button template)
6121 function LeaPlusLC:CreateButton(name, frame, label, anchor, x, y, width, height, reskin, tip)
6122 local mbtn = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate")
6123 LeaPlusCB[name] = mbtn
6124 mbtn:SetSize(width, height)
6125 mbtn:SetPoint(anchor, x, y)
6126 mbtn:SetHitRectInsets(0, 0, 0, 0)
6127 mbtn:SetText(L[label])
6128
6129 -- Create fontstring so the button can be sized correctly
6130 mbtn.f = mbtn:CreateFontString(nil, 'ARTWORK', 'GameFontNormal')
6131 mbtn.f:SetText(L[label])
6132 if width > 0 then
6133 -- Button should have static width
6134 mbtn:SetWidth(width)
6135 else
6136 -- Button should have variable width
6137 mbtn:SetWidth(mbtn.f:GetStringWidth() + 20)
6138 end
6139
6140 -- Tooltip handler
6141 mbtn.tiptext = L[tip]
6142 mbtn:SetScript("OnEnter", LeaPlusLC.TipSee)
6143 mbtn:SetScript("OnLeave", GameTooltip_Hide)
6144
6145 -- Texture the button
6146 if reskin then
6147
6148 -- Set skinned button textures
6149 mbtn:SetNormalTexture("Interface\\AddOns\\Leatrix_Plus\\Leatrix_Plus.blp")
6150 mbtn:GetNormalTexture():SetTexCoord(0.5, 1, 0, 1)
6151 mbtn:SetHighlightTexture("Interface\\AddOns\\Leatrix_Plus\\Leatrix_Plus.blp")
6152 mbtn:GetHighlightTexture():SetTexCoord(0, 0.5, 0, 1)
6153
6154 -- Hide the default textures
6155 mbtn:HookScript("OnShow", function() mbtn.Left:Hide(); mbtn.Middle:Hide(); mbtn.Right:Hide() end)
6156 mbtn:HookScript("OnEnable", function() mbtn.Left:Hide(); mbtn.Middle:Hide(); mbtn.Right:Hide() end)
6157 mbtn:HookScript("OnDisable", function() mbtn.Left:Hide(); mbtn.Middle:Hide(); mbtn.Right:Hide() end)
6158 mbtn:HookScript("OnMouseDown", function() mbtn.Left:Hide(); mbtn.Middle:Hide(); mbtn.Right:Hide() end)
6159 mbtn:HookScript("OnMouseUp", function() mbtn.Left:Hide(); mbtn.Middle:Hide(); mbtn.Right:Hide() end)
6160
6161 end
6162
6163 return mbtn
6164 end
6165
6166 -- Create a dropdown menu (using custom function to avoid taint)
6167 function LeaPlusLC:CreateDropDown(ddname, label, parent, width, anchor, x, y, items, tip)
6168
6169 -- Add the dropdown name to a table
6170 tinsert(LeaDropList, ddname)
6171
6172 -- Populate variable with item list
6173 LeaPlusLC[ddname.."Table"] = items
6174
6175 -- Create outer frame
6176 local frame = CreateFrame("FRAME", nil, parent); frame:SetWidth(width); frame:SetHeight(42); frame:SetPoint("BOTTOMLEFT", parent, anchor, x, y);
6177
6178 -- Create dropdown inside outer frame
6179 local dd = CreateFrame("Frame", nil, frame); dd:SetPoint("BOTTOMLEFT", -16, -8); dd:SetPoint("BOTTOMRIGHT", 15, -4); dd:SetHeight(32);
6180
6181 -- Create dropdown textures
6182 local lt = dd:CreateTexture(nil, "ARTWORK"); lt:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame"); lt:SetTexCoord(0, 0.1953125, 0, 1); lt:SetPoint("TOPLEFT", dd, 0, 17); lt:SetWidth(25); lt:SetHeight(64);
6183 local rt = dd:CreateTexture(nil, "BORDER"); rt:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame"); rt:SetTexCoord(0.8046875, 1, 0, 1); rt:SetPoint("TOPRIGHT", dd, 0, 17); rt:SetWidth(25); rt:SetHeight(64);
6184 local mt = dd:CreateTexture(nil, "BORDER"); mt:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame"); mt:SetTexCoord(0.1953125, 0.8046875, 0, 1); mt:SetPoint("LEFT", lt, "RIGHT"); mt:SetPoint("RIGHT", rt, "LEFT"); mt:SetHeight(64);
6185
6186 -- Create dropdown label
6187 local lf = dd:CreateFontString(nil, "OVERLAY", "GameFontNormal"); lf:SetPoint("TOPLEFT", frame, 0, 0); lf:SetPoint("TOPRIGHT", frame, -5, 0); lf:SetJustifyH("LEFT"); lf:SetText(L[label])
6188
6189 -- Create dropdown placeholder for value (set it using OnShow)
6190 local value = dd:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
6191 value:SetPoint("LEFT", lt, 26, 2); value:SetPoint("RIGHT", rt, -43, 0); value:SetJustifyH("LEFT")
6192 dd:SetScript("OnShow", function() value:SetText(LeaPlusLC[ddname.."Table"][LeaPlusLC[ddname]]) end)
6193
6194 -- Create dropdown button (clicking it opens the dropdown list)
6195 local dbtn = CreateFrame("Button", nil, dd)
6196 dbtn:SetPoint("TOPRIGHT", rt, -16, -18); dbtn:SetWidth(24); dbtn:SetHeight(24)
6197 dbtn:SetNormalTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Up"); dbtn:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Down"); dbtn:SetDisabledTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Disabled"); dbtn:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight"); dbtn:GetHighlightTexture():SetBlendMode("ADD")
6198 dbtn.tiptext = tip; dbtn:SetScript("OnEnter", LeaPlusLC.ShowTooltip);
6199 dbtn:SetScript("OnLeave", GameTooltip_Hide)
6200
6201 -- Create dropdown list
6202 local ddlist = CreateFrame("Frame",nil,frame);
6203 LeaPlusCB["ListFrame"..ddname] = ddlist;
6204 ddlist:SetPoint("TOP",0,-42);
6205 ddlist:SetWidth(frame:GetWidth());
6206 ddlist:SetHeight((#items * 17) + 17 + 17);
6207 ddlist:SetFrameStrata("FULLSCREEN_DIALOG");
6208 ddlist:SetFrameLevel(12);
6209 ddlist:SetBackdrop({bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background-Dark", edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", tile = false, tileSize = 0, edgeSize = 32, insets = { left = 4, right = 4, top = 4, bottom = 4 }});
6210 ddlist:Hide();
6211
6212 -- Hide list if parent is closed
6213 parent:HookScript("OnHide", function() ddlist:Hide() end)
6214
6215 -- Create checkmark (it marks the currently selected item)
6216 local ddlistchk = CreateFrame("FRAME", nil, ddlist)
6217 ddlistchk:SetHeight(16); ddlistchk:SetWidth(16);
6218 ddlistchk.t = ddlistchk:CreateTexture(nil, "ARTWORK"); ddlistchk.t:SetAllPoints(); ddlistchk.t:SetTexture("Interface\\Common\\UI-DropDownRadioChecks"); ddlistchk.t:SetTexCoord(0, 0.5, 0.5, 1.0);
6219
6220 -- Create dropdown list items
6221 for k, v in pairs(items) do
6222
6223 local dditem = CreateFrame("Button", nil, LeaPlusCB["ListFrame"..ddname])
6224 LeaPlusCB["Drop"..ddname..k] = dditem;
6225 dditem:Show();
6226 dditem:SetWidth(ddlist:GetWidth()-22)
6227 dditem:SetHeight(20)
6228 dditem:SetPoint("TOPLEFT", 12, -k*16)
6229
6230 dditem.f = dditem:CreateFontString(nil, 'ARTWORK', 'GameFontHighlight');
6231 dditem.f:SetPoint('LEFT', 16, 0)
6232 dditem.f:SetText(items[k])
6233
6234 dditem.t = dditem:CreateTexture(nil, "BACKGROUND")
6235 dditem.t:SetAllPoints()
6236 dditem.t:SetColorTexture(0.3, 0.3, 0.00, 0.8)
6237 dditem.t:Hide();
6238
6239 dditem:SetScript("OnEnter", function() dditem.t:Show() end)
6240 dditem:SetScript("OnLeave", function() dditem.t:Hide() end)
6241 dditem:SetScript("OnClick", function()
6242 LeaPlusLC[ddname] = k
6243 value:SetText(LeaPlusLC[ddname.."Table"][k])
6244 ddlist:Hide(); -- Must be last in click handler as other functions hook it
6245 end)
6246
6247 -- Show list when button is clicked
6248 dbtn:SetScript("OnClick", function()
6249 -- Show the dropdown
6250 if ddlist:IsShown() then ddlist:Hide() else
6251 ddlist:Show();
6252 ddlistchk:SetPoint("TOPLEFT",10,select(5,LeaPlusCB["Drop"..ddname..LeaPlusLC[ddname]]:GetPoint()))
6253 ddlistchk:Show();
6254 end;
6255 -- Hide all other dropdowns except the one we're dealing with
6256 for void,v in pairs(LeaDropList) do
6257 if v ~= ddname then
6258 LeaPlusCB["ListFrame"..v]:Hide();
6259 end
6260 end
6261 end)
6262
6263 -- Expand the clickable area of the button to include the entire menu width
6264 dbtn:SetHitRectInsets(-width+28, 0, 0, 0);
6265
6266 end
6267
6268 return frame
6269
6270 end
6271
6272----------------------------------------------------------------------
6273-- Create main options panel frame
6274----------------------------------------------------------------------
6275
6276 function LeaPlusLC:CreateMainPanel()
6277
6278 -- Create the panel
6279 local PageF = CreateFrame("Frame", nil, UIParent);
6280
6281 -- Make it a system frame
6282 _G["LeaPlusGlobalPanel"] = PageF
6283 table.insert(UISpecialFrames, "LeaPlusGlobalPanel")
6284
6285 -- Set frame parameters
6286 LeaPlusLC["PageF"] = PageF
6287 PageF:SetSize(570,370)
6288 PageF:Hide();
6289 PageF:SetFrameStrata("FULLSCREEN_DIALOG")
6290 PageF:SetClampedToScreen(true)
6291 PageF:SetClampRectInsets(500, -500, -300, 300)
6292 PageF:EnableMouse(true)
6293 PageF:SetMovable(true)
6294 PageF:RegisterForDrag("LeftButton")
6295 PageF:SetScript("OnDragStart", PageF.StartMoving)
6296 PageF:SetScript("OnDragStop", function ()
6297 PageF:StopMovingOrSizing();
6298 PageF:SetUserPlaced(false);
6299 -- Save panel position
6300 LeaPlusLC["MainPanelA"], void, LeaPlusLC["MainPanelR"], LeaPlusLC["MainPanelX"], LeaPlusLC["MainPanelY"] = PageF:GetPoint()
6301 end)
6302
6303 -- Add background color
6304 PageF.t = PageF:CreateTexture(nil, "BACKGROUND")
6305 PageF.t:SetAllPoints()
6306 PageF.t:SetColorTexture(0.05, 0.05, 0.05, 0.9)
6307
6308 -- Add textures
6309 LeaPlusLC:CreateBar("FootTexture", PageF, 570, 48, "BOTTOM", 0.5, 0.5, 0.5, 1.0, "Interface\\ACHIEVEMENTFRAME\\UI-GuildAchievement-Parchment-Horizontal-Desaturated.png")
6310 LeaPlusLC:CreateBar("MainTexture", PageF, 440, 323, "TOPRIGHT", 0.7, 0.7, 0.7, 0.7, "Interface\\ACHIEVEMENTFRAME\\UI-GuildAchievement-Parchment-Horizontal-Desaturated.png")
6311 LeaPlusLC:CreateBar("MenuTexture", PageF, 130, 323, "TOPLEFT", 0.7, 0.7, 0.7, 0.7, "Interface\\ACHIEVEMENTFRAME\\UI-GuildAchievement-Parchment-Horizontal-Desaturated.png")
6312
6313 -- Set panel position when shown
6314 PageF:SetScript("OnShow", function()
6315 PageF:ClearAllPoints()
6316 PageF:SetPoint(LeaPlusLC["MainPanelA"], UIParent, LeaPlusLC["MainPanelR"], LeaPlusLC["MainPanelX"], LeaPlusLC["MainPanelY"])
6317 end)
6318
6319 -- Add main title (shown above menu in the corner)
6320 PageF.mt = PageF:CreateFontString(nil, 'ARTWORK', 'GameFontNormalLarge')
6321 PageF.mt:SetPoint('TOPLEFT', 16, -16)
6322 PageF.mt:SetText("Leatrix Plus")
6323
6324 -- Add version text (shown underneath main title)
6325 PageF.v = PageF:CreateFontString(nil, 'ARTWORK', 'GameFontHighlightSmall')
6326 PageF.v:SetHeight(32);
6327 PageF.v:SetPoint('TOPLEFT', PageF.mt, 'BOTTOMLEFT', 0, -8);
6328 PageF.v:SetPoint('RIGHT', PageF, -32, 0)
6329 PageF.v:SetJustifyH('LEFT'); PageF.v:SetJustifyV('TOP');
6330 PageF.v:SetNonSpaceWrap(true); PageF.v:SetText(L["Classic"] .. " " .. LeaPlusLC["AddonVer"])
6331
6332 -- Add reload UI Button
6333 local reloadb = LeaPlusLC:CreateButton("ReloadUIButton", PageF, "Reload", "BOTTOMRIGHT", -16, 10, 0, 25, true, "Your UI needs to be reloaded for some of the changes to take effect.|n|nYou don't have to click the reload button immediately but you do need to click it when you are done making changes and you want the changes to take effect.")
6334 LeaPlusLC:LockItem(reloadb,true)
6335 reloadb:SetScript("OnClick", ReloadUI)
6336
6337 reloadb.f = reloadb:CreateFontString(nil, 'ARTWORK', 'GameFontNormalSmall')
6338 reloadb.f:SetHeight(32);
6339 reloadb.f:SetPoint('RIGHT', reloadb, 'LEFT', -10, 0)
6340 reloadb.f:SetText(L["Your UI needs to be reloaded."])
6341 reloadb.f:Hide()
6342
6343 -- Add close Button
6344 local CloseB = CreateFrame("Button", nil, PageF, "UIPanelCloseButton")
6345 CloseB:SetSize(30, 30)
6346 CloseB:SetPoint("TOPRIGHT", 0, 0)
6347 CloseB:SetScript("OnClick", LeaPlusLC.HideFrames)
6348
6349 -- Release memory
6350 LeaPlusLC.CreateMainPanel = nil
6351
6352 end
6353
6354 LeaPlusLC:CreateMainPanel();
6355
6356----------------------------------------------------------------------
6357-- L80: Commands
6358----------------------------------------------------------------------
6359
6360 -- Slash command function
6361 function LeaPlusLC:SlashFunc(str)
6362 if str and str ~= "" then
6363 -- Get parameters in lower case with duplicate spaces removed
6364 local str, arg1, arg2, arg3 = strsplit(" ", string.lower(str:gsub("%s+", " ")))
6365 -- Traverse parameters
6366 if str == "wipe" then
6367 -- Wipe settings
6368 LeaPlusLC:PlayerLogout(true) -- Run logout function with wipe parameter
6369 wipe(LeaPlusDB)
6370 LpEvt:UnregisterAllEvents(); -- Don't save any settings
6371 ReloadUI();
6372 elseif str == "nosave" then
6373 -- Prevent Leatrix Plus from overwriting LeaPlusDB at next logout
6374 LpEvt:UnregisterEvent("PLAYER_LOGOUT")
6375 LeaPlusLC:Print("Leatrix Plus will not overwrite LeaPlusDB at next logout.")
6376 return
6377 elseif str == "reset" then
6378 -- Reset panel positions
6379 LeaPlusLC["MainPanelA"], LeaPlusLC["MainPanelR"], LeaPlusLC["MainPanelX"], LeaPlusLC["MainPanelY"] = "CENTER", "CENTER", 0, 0
6380 LeaPlusLC["PlusPanelScale"] = 1
6381 LeaPlusLC["PlusPanelAlpha"] = 0
6382 LeaPlusLC["PageF"]:SetScale(1)
6383 LeaPlusLC["PageF"].t:SetAlpha(1 - LeaPlusLC["PlusPanelAlpha"])
6384 -- Refresh panels
6385 LeaPlusLC["PageF"]:ClearAllPoints()
6386 LeaPlusLC["PageF"]:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
6387 -- Reset currently showing configuration panel
6388 for k, v in pairs(LeaConfigList) do
6389 if v:IsShown() then
6390 v:ClearAllPoints()
6391 v:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
6392 v:SetScale(1)
6393 v.t:SetAlpha(1 - LeaPlusLC["PlusPanelAlpha"])
6394 end
6395 end
6396 -- Refresh Leatrix Plus settings menu only
6397 if LeaPlusLC["Page8"]:IsShown() then
6398 LeaPlusLC["Page8"]:Hide()
6399 LeaPlusLC["Page8"]:Show()
6400 end
6401 return
6402 elseif str == "taint" then
6403 -- Set taint log level
6404 if arg1 and arg1 ~= "" then
6405 arg1 = tonumber(arg1)
6406 if arg1 and arg1 >= 0 and arg1 <= 2 then
6407 if arg1 == 0 then
6408 -- Disable taint log
6409 ConsoleExec("taintLog 0")
6410 LeaPlusLC:Print("Taint level: Disabled (0).")
6411 elseif arg1 == 1 then
6412 -- Basic taint log
6413 ConsoleExec("taintLog 1")
6414 LeaPlusLC:Print("Taint level: Basic (1).")
6415 elseif arg1 == 2 then
6416 -- Full taint log
6417 ConsoleExec("taintLog 2")
6418 LeaPlusLC:Print("Taint level: Full (2).")
6419 end
6420 else
6421 LeaPlusLC:Print("Invalid taint level.")
6422 end
6423 else
6424 -- Show current taint level
6425 local taintCurrent = GetCVar("taintLog")
6426 if taintCurrent == "0" then
6427 LeaPlusLC:Print("Taint level: Disabled (0).")
6428 elseif taintCurrent == "1" then
6429 LeaPlusLC:Print("Taint level: Basic (1).")
6430 elseif taintCurrent == "2" then
6431 LeaPlusLC:Print("Taint level: Full (2).")
6432 end
6433 end
6434 return
6435 elseif str == "quest" then
6436 -- Show quest completed status
6437 if arg1 and arg1 ~= "" then
6438 if tonumber(arg1) then
6439 local questCompleted = IsQuestFlaggedCompleted(arg1)
6440 if questCompleted then
6441 LeaPlusLC:Print(arg1 .. ": " .. L["Quest completed."])
6442 else
6443 LeaPlusLC:Print(arg1 .. ": " .. L["Quest not completed."])
6444 end
6445 else
6446 LeaPlusLC:Print("Invalid quest ID.")
6447 end
6448 else
6449 LeaPlusLC:Print("Missing quest ID.")
6450 end
6451 return
6452 elseif str == "rest" then
6453 -- Show rested bubbles
6454 LeaPlusLC:Print(L["Rested bubbles"] .. ": |cffffffff" .. (math.floor(20 * (GetXPExhaustion() or 0) / UnitXPMax("player") + 0.5)))
6455 return
6456 elseif str == "zygor" then
6457 -- Toggle Zygor addon
6458 LeaPlusLC:ZygorToggle()
6459 return
6460 elseif str == "id" then
6461 -- Print NPC ID
6462 local npcName = UnitName("target")
6463 local npcGuid = UnitGUID("target") or nil
6464 if npcName and npcGuid then
6465 local void, void, void, void, void, npcID = strsplit("-", npcGuid)
6466 if npcID then
6467 LeaPlusLC:Print(npcName .. ": |cffffffff" .. npcID)
6468 end
6469 end
6470 return
6471 elseif str == "tooltip" then
6472 -- Print tooltip frame name
6473 local enumf = EnumerateFrames()
6474 while enumf do
6475 if (enumf:GetObjectType() == "GameTooltip" or strfind((enumf:GetName() or ""):lower(),"tip")) and enumf:IsVisible() and enumf:GetPoint() then
6476 print(enumf:GetName())
6477 end
6478 enumf = EnumerateFrames(enumf)
6479 end
6480 collectgarbage()
6481 return
6482 elseif str == "rsnd" then
6483 -- Restart sound system
6484 if LeaPlusCB["StopMusicBtn"] then LeaPlusCB["StopMusicBtn"]:Click() end
6485 Sound_GameSystem_RestartSoundSystem()
6486 LeaPlusLC:Print("Sound system restarted.")
6487 return
6488 elseif str == "event" then
6489 -- List events (used for debug)
6490 LeaPlusLC["DbF"] = LeaPlusLC["DbF"] or CreateFrame("FRAME")
6491 if not LeaPlusLC["DbF"]:GetScript("OnEvent") then
6492 LeaPlusLC:Print("Tracing started.")
6493 LeaPlusLC["DbF"]:RegisterAllEvents()
6494 LeaPlusLC["DbF"]:SetScript("OnEvent", function(self, event)
6495 if event == "ACTIONBAR_UPDATE_COOLDOWN"
6496 or event == "BAG_UPDATE_COOLDOWN"
6497 or event == "CHAT_MSG_TRADESKILLS"
6498 or event == "COMBAT_LOG_EVENT_UNFILTERED"
6499 or event == "SPELL_UPDATE_COOLDOWN"
6500 or event == "SPELL_UPDATE_USABLE"
6501 or event == "UNIT_POWER_FREQUENT"
6502 or event == "UPDATE_INVENTORY_DURABILITY"
6503 then return
6504 else
6505 print(event)
6506 end
6507 end)
6508 else
6509 LeaPlusLC["DbF"]:UnregisterAllEvents()
6510 LeaPlusLC["DbF"]:SetScript("OnEvent", nil)
6511 LeaPlusLC:Print("Tracing stopped.")
6512 end
6513 return
6514 elseif str == "config" then
6515 -- Show maximum camera distance
6516 LeaPlusLC:Print(L["Camera distance"] .. ": |cffffffff" .. GetCVar("cameraDistanceMaxZoomFactor"))
6517 -- Show screen effects
6518 LeaPlusLC:Print(L["Shaders"] .. ": |cffffffff" .. GetCVar("ffxGlow") .. ", " .. GetCVar("ffxDeath") .. ", " .. GetCVar("ffxNether"))
6519 -- Show particle density
6520 LeaPlusLC:Print(L["Particle density"] .. ": |cffffffff" .. GetCVar("particleDensity"))
6521 LeaPlusLC:Print(L["Weather density"] .. ": |cffffffff" .. GetCVar("weatherDensity"))
6522 -- Show config
6523 LeaPlusLC:Print("SynchroniseConfig: |cffffffff" .. GetCVar("synchronizeConfig"))
6524 -- Show raid restrictions
6525 local unRaid = GetAllowLowLevelRaid()
6526 if unRaid and unRaid == true then
6527 LeaPlusLC:Print("GetAllowLowLevelRaid: |cffffffff" .. "True")
6528 else
6529 LeaPlusLC:Print("GetAllowLowLevelRaid: |cffffffff" .. "False")
6530 end
6531 return
6532 elseif str == "move" then
6533 -- Move minimap
6534 MinimapZoneTextButton:Hide()
6535 MinimapBorderTop:SetTexture("")
6536 MiniMapWorldMapButton:Hide()
6537 MinimapBackdrop:ClearAllPoints()
6538 MinimapBackdrop:SetPoint("CENTER", UIParent, "CENTER", -330, -75)
6539 Minimap:SetPoint("CENTER", UIParent, "CENTER", -320, -50)
6540 return
6541 elseif str == "tipcol" then
6542 -- Show default tooltip title color
6543 if GameTooltipTextLeft1:IsShown() then
6544 local r, g, b, a = GameTooltipTextLeft1:GetTextColor()
6545 r = r <= 1 and r >= 0 and r or 0
6546 g = g <= 1 and g >= 0 and g or 0
6547 b = b <= 1 and b >= 0 and b or 0
6548 LeaPlusLC:Print(L["Tooltip title color"] .. ": " .. strupper(string.format("%02x%02x%02x", r * 255, g * 255, b * 255) .. "."))
6549 else
6550 LeaPlusLC:Print("No tooltip showing.")
6551 end
6552 return
6553 elseif str == "list" then
6554 -- Enumerate frames
6555 local frame = EnumerateFrames()
6556 while frame do
6557 if (frame:IsVisible() and MouseIsOver(frame)) then
6558 LeaPlusLC:Print(frame:GetName() or string.format("[Unnamed Frame: %s]", tostring(frame)))
6559 end
6560 frame = EnumerateFrames(frame)
6561 end
6562 return
6563 elseif str == "grid" then
6564 -- Create grid for first use
6565 if not LeaPlusLC.grid then
6566 LeaPlusLC.grid = CreateFrame('FRAME')
6567 LeaPlusLC.grid:Hide()
6568 LeaPlusLC.grid:SetAllPoints(UIParent)
6569 local w, h = GetScreenWidth() * UIParent:GetEffectiveScale(), GetScreenHeight() * UIParent:GetEffectiveScale()
6570 local ratio = w / h
6571 local sqsize = w / 20
6572 local wline = floor(sqsize - (sqsize % 2))
6573 local hline = floor(sqsize / ratio - ((sqsize / ratio) % 2))
6574 -- Plot vertical lines
6575 for i = 0, wline do
6576 local t = LeaPlusLC.grid:CreateTexture(nil, 'BACKGROUND')
6577 if i == wline / 2 then t:SetColorTexture(1, 0, 0, 0.5) else t:SetColorTexture(0, 0, 0, 0.5) end
6578 t:SetPoint('TOPLEFT', LeaPlusLC.grid, 'TOPLEFT', i * w / wline - 1, 0)
6579 t:SetPoint('BOTTOMRIGHT', LeaPlusLC.grid, 'BOTTOMLEFT', i * w / wline + 1, 0)
6580 end
6581 -- Plot horizontal lines
6582 for i = 0, hline do
6583 local t = LeaPlusLC.grid:CreateTexture(nil, 'BACKGROUND')
6584 if i == hline / 2 then t:SetColorTexture(1, 0, 0, 0.5) else t:SetColorTexture(0, 0, 0, 0.5) end
6585 t:SetPoint('TOPLEFT', LeaPlusLC.grid, 'TOPLEFT', 0, -i * h / hline + 1)
6586 t:SetPoint('BOTTOMRIGHT', LeaPlusLC.grid, 'TOPRIGHT', 0, -i * h / hline - 1)
6587 end
6588 end
6589 -- Show or hide grid
6590 if LeaPlusLC.grid:IsShown() then
6591 LeaPlusLC.grid:Hide()
6592 else
6593 LeaPlusLC.grid:Show()
6594 end
6595 return
6596 elseif str == "chk" then
6597 -- List truncated checkbox labels
6598 if LeaPlusLC["TruncatedLabelsList"] then
6599 for i, v in pairs(LeaPlusLC["TruncatedLabelsList"]) do
6600 LeaPlusLC:Print(LeaPlusLC["TruncatedLabelsList"][i])
6601 end
6602 else
6603 LeaPlusLC:Print("Checkbox labels are Ok.")
6604 end
6605 return
6606 elseif str == "cv" then
6607 -- Print and set console variable setting
6608 if arg1 and arg1 ~= "" then
6609 if GetCVar(arg1) then
6610 if arg2 and arg2 ~= "" then
6611 if tonumber(arg2) then
6612 SetCVar(arg1, arg2)
6613 else
6614 LeaPlusLC:Print("Value must be a number.")
6615 return
6616 end
6617 end
6618 LeaPlusLC:Print(arg1 .. ": |cffffffff" .. GetCVar(arg1))
6619 else
6620 LeaPlusLC:Print("Invalid console variable.")
6621 end
6622 else
6623 LeaPlusLC:Print("Missing console variable.")
6624 end
6625 return
6626 elseif str == "play" then
6627 -- Play sound ID
6628 if arg1 and arg1 ~= "" then
6629 if tonumber(arg1) then
6630 -- Stop last played sound ID
6631 if LeaPlusLC.SNDcanitHandle then
6632 StopSound(LeaPlusLC.SNDcanitHandle)
6633 end
6634 -- Play sound ID
6635 LeaPlusLC.SNDcanitPlay, LeaPlusLC.SNDcanitHandle = PlaySound(arg1, "Master", false, false)
6636 if not LeaPlusLC.SNDcanitPlay then LeaPlusLC:Print(L["Invalid sound ID"] .. ": |cffffffff" .. arg1) end
6637 else
6638 LeaPlusLC:Print(L["Invalid sound ID"] .. ": |cffffffff" .. arg1)
6639 end
6640 else
6641 LeaPlusLC:Print("Missing sound ID.")
6642 end
6643 return
6644 elseif str == "stop" then
6645 -- Stop last played sound ID
6646 if LeaPlusLC.SNDcanitHandle then
6647 StopSound(LeaPlusLC.SNDcanitHandle)
6648 end
6649 return
6650 elseif str == "wipecds" then
6651 -- Wipe cooldowns
6652 LeaPlusDB["Cooldowns"] = nil
6653 ReloadUI()
6654 return
6655 elseif str == "tipchat" then
6656 -- Print tooltip contents in chat
6657 local numLines = GameTooltip:NumLines()
6658 if numLines then
6659 for i = 1, numLines do
6660 print(_G["GameTooltipTextLeft" .. i]:GetText() or "")
6661 end
6662 end
6663 return
6664 elseif str == "tiplang" then
6665 -- Tooltip tag locale code constructor
6666 local msg = ""
6667 msg = msg .. 'if GameLocale == "' .. GameLocale .. '" then '
6668 msg = msg .. 'ttLevel = "' .. LEVEL .. '"; '
6669 msg = msg .. 'ttBoss = "' .. BOSS .. '"; '
6670 msg = msg .. 'ttElite = "' .. ELITE .. '"; '
6671 msg = msg .. 'ttRare = "' .. ITEM_QUALITY3_DESC .. '"; '
6672 msg = msg .. 'ttRareElite = "' .. ITEM_QUALITY3_DESC .. " " .. ELITE .. '"; '
6673 msg = msg .. 'ttRareBoss = "' .. ITEM_QUALITY3_DESC .. " " .. BOSS .. '"; '
6674 msg = msg .. 'ttTarget = "' .. TARGET .. '"; '
6675 msg = msg .. "end"
6676 print(msg)
6677 return
6678 elseif str == "con" then
6679 -- Show the developer console
6680 C_Console.SetFontHeight(28)
6681 DeveloperConsole:Toggle(true)
6682 return
6683 elseif str == "movlist" then
6684 -- List playable movie IDs
6685 local count = 0
6686 for i = 1, 1000 do
6687 if IsMoviePlayable(i) then
6688 print(i)
6689 count = count + 1
6690 end
6691 end
6692 LeaPlusLC:Print("Total movies: |cffffffff" .. count)
6693 return
6694 elseif str == "movie" then
6695 -- Playback movie by ID
6696 arg1 = tonumber(arg1)
6697 if arg1 and arg1 ~= "" then
6698 if IsMoviePlayable(arg1) then
6699 MovieFrame_PlayMovie(MovieFrame, arg1)
6700 else
6701 LeaPlusLC:Print("Movie not playable.")
6702 end
6703 else
6704 LeaPlusLC:Print("Missing movie ID.")
6705 end
6706 return
6707 elseif str == "cin" then
6708 -- Play opening cinematic (only works if character has never gained XP) (used for testing)
6709 OpeningCinematic()
6710 return
6711 elseif str == "skit" then
6712 -- Play a test sound kit
6713 PlaySound("1020", "Master", false, true)
6714 return
6715 elseif str == "marker" then
6716 -- Prevent showing raid target markers on self
6717 if not LeaPlusLC.MarkerFrame then
6718 LeaPlusLC.MarkerFrame = CreateFrame("FRAME")
6719 LeaPlusLC.MarkerFrame:RegisterEvent("RAID_TARGET_UPDATE")
6720 end
6721 LeaPlusLC.MarkerFrame.Update = true
6722 if LeaPlusLC.MarkerFrame.Toggle == false then
6723 -- Show markers
6724 LeaPlusLC.MarkerFrame:SetScript("OnEvent", nil)
6725 ActionStatus_DisplayMessage(L["Self Markers Allowed"], true)
6726 LeaPlusLC.MarkerFrame.Toggle = true
6727 else
6728 -- Hide markers
6729 SetRaidTarget("player", 0)
6730 LeaPlusLC.MarkerFrame:SetScript("OnEvent", function()
6731 if LeaPlusLC.MarkerFrame.Update == true then
6732 LeaPlusLC.MarkerFrame.Update = false
6733 SetRaidTarget("player", 0)
6734 end
6735 LeaPlusLC.MarkerFrame.Update = true
6736 end)
6737 ActionStatus_DisplayMessage(L["Self Markers Blocked"], true)
6738 LeaPlusLC.MarkerFrame.Toggle = false
6739 end
6740 return
6741 elseif str == "af" then
6742 -- Automatically follow player target using ticker
6743 if LeaPlusLC.followTick then
6744 -- Existing ticker is active so cancel it
6745 LeaPlusLC.followTick:Cancel()
6746 LeaPlusLC.followTick = nil
6747 FollowUnit("player")
6748 LeaPlusLC:Print("AutoFollow disabled.")
6749 else
6750 -- No ticker is active so create one
6751 local targetName, targetRealm = UnitName("target")
6752 if not targetName or not UnitIsPlayer("target") or UnitIsUnit("player", "target") then
6753 LeaPlusLC:Print("Invalid target.")
6754 return
6755 end
6756 if targetRealm then targetName = targetName .. "-" .. targetRealm end
6757 if LeaPlusLC.followTick then
6758 LeaPlusLC.followTick:Cancel()
6759 end
6760 FollowUnit(targetName, true)
6761 LeaPlusLC.followTick = C_Timer.NewTicker(0.5, function()
6762 FollowUnit(targetName, true)
6763 end)
6764 LeaPlusLC:Print(L["AutoFollow"] .. ": |cffffffff" .. targetName .. "|r.")
6765 end
6766 return
6767 elseif str == "mapid" then
6768 -- Print map ID
6769 if WorldMapFrame:IsShown() then
6770 -- Show world map ID
6771 local mapID = WorldMapFrame.mapID or nil
6772 local artID = C_Map.GetMapArtID(mapID) or nil
6773 local mapName = C_Map.GetMapInfo(mapID).name or nil
6774 if mapID and artID and mapName then
6775 LeaPlusLC:Print(mapID .. " (" .. artID .. "): " .. mapName .. " (map)")
6776 end
6777 else
6778 -- Show character map ID
6779 local mapID = C_Map.GetBestMapForUnit("player") or nil
6780 local artID = C_Map.GetMapArtID(mapID) or nil
6781 local mapName = C_Map.GetMapInfo(mapID).name or nil
6782 if mapID and artID and mapName then
6783 LeaPlusLC:Print(mapID .. " (" .. artID .. "): " .. mapName .. " (player)")
6784 end
6785 end
6786 return
6787 elseif str == "pos" then
6788 -- Map POI code builder
6789 local mapID = C_Map.GetBestMapForUnit("player") or nil
6790 local mapName = C_Map.GetMapInfo(mapID).name or nil
6791 local mapRects = {}
6792 local tempVec2D = CreateVector2D(0, 0)
6793 local void
6794 -- Get player map position
6795 tempVec2D.x, tempVec2D.y = UnitPosition("player")
6796 if not tempVec2D.x then return end
6797 local mapRect = mapRects[mapID]
6798 if not mapRect then
6799 mapRect = {}
6800 void, mapRect[1] = C_Map.GetWorldPosFromMapPos(mapID, CreateVector2D(0, 0))
6801 void, mapRect[2] = C_Map.GetWorldPosFromMapPos(mapID, CreateVector2D(1, 1))
6802 mapRect[2]:Subtract(mapRect[1])
6803 mapRects[mapID] = mapRect
6804 end
6805 tempVec2D:Subtract(mapRects[mapID][1])
6806 local pX, pY = tempVec2D.y/mapRects[mapID][2].y, tempVec2D.x/mapRects[mapID][2].x
6807 pX = string.format("%0.1f", 100 * pX)
6808 pY = string.format("%0.1f", 100 * pY)
6809 if mapID and mapName and pX and pY then
6810 ChatFrame1:Clear()
6811 local dnType, dnTex = "Dungeon", "dnTex"
6812 if arg1 == "raid" then dnType, dnTex = "Raid", "rdTex" end
6813 if arg1 == "portal" then dnType = "Portal" end
6814 print('[' .. mapID .. '] = --[[' .. mapName .. ']] {{' .. pX .. ', ' .. pY .. ', L[' .. '"Name"' .. '], L[' .. '"' .. dnType .. '"' .. '], ' .. dnTex .. '},},')
6815 end
6816 return
6817 elseif str == "mapref" then
6818 -- Print map reveal structure code
6819 if not WorldMapFrame:IsShown() then
6820 LeaPlusLC:Print("Open the map first!")
6821 return
6822 end
6823 ChatFrame1:Clear()
6824 local msg = ""
6825 local mapID = WorldMapFrame.mapID
6826 local mapName = C_Map.GetMapInfo(mapID).name
6827 local mapArt = C_Map.GetMapArtID(mapID)
6828 msg = msg .. "--[[" .. mapName .. "]] [" .. mapArt .. "] = {"
6829 local exploredMapTextures = C_MapExplorationInfo.GetExploredMapTextures(mapID);
6830 if exploredMapTextures then
6831 for i, exploredTextureInfo in ipairs(exploredMapTextures) do
6832 local twidth = exploredTextureInfo.textureWidth or 0
6833 if twidth > 0 then
6834 local theight = exploredTextureInfo.textureHeight or 0
6835 local offsetx = exploredTextureInfo.offsetX
6836 local offsety = exploredTextureInfo.offsetY
6837 local filedataIDS = exploredTextureInfo.fileDataIDs
6838 msg = msg .. "[" .. '"' .. twidth .. ":" .. theight .. ":" .. offsetx .. ":" .. offsety .. '"' .. "] = " .. '"'
6839 for fileData = 1, #filedataIDS do
6840 msg = msg .. filedataIDS[fileData]
6841 if fileData < #filedataIDS then
6842 msg = msg .. ", "
6843 else
6844 msg = msg .. '",'
6845 if i < #exploredMapTextures then
6846 msg = msg .. " "
6847 end
6848 end
6849 end
6850 end
6851 end
6852 msg = msg .. "},"
6853 print(msg)
6854 end
6855 return
6856 elseif str == "mk" then
6857 -- Print a map key
6858 if not arg1 then LeaPlusLC:Print("Key missing!") return end
6859 if not tonumber(arg1) then LeaPlusLC:Print("Must be a number!") return end
6860 local key = arg1
6861 ChatFrame1:Clear()
6862 print('"' .. mod(floor(key / 2^36), 2^12) .. ":" .. mod(floor(key / 2^24), 2^12) .. ":" .. mod(floor(key / 2^12), 2^12) .. ":" .. mod(key, 2^12) .. '"')
6863 return
6864 elseif str == "map" then
6865 -- Set map by ID
6866 if not arg1 or not tonumber(arg1) or not C_Map.GetMapInfo(arg1) then
6867 LeaPlusLC:Print("Invalid map ID.")
6868 else
6869 WorldMapFrame:SetMapID(arg1)
6870 end
6871 return
6872 elseif str == "cls" then
6873 -- Clear chat frame
6874 ChatFrame1:Clear()
6875 return
6876 elseif str == "al" then
6877 -- Enable auto loot
6878 SetCVar("autoLootDefault", "1")
6879 LeaPlusLC:Print("Auto loot is now enabled.")
6880 return
6881 elseif str == "realm" then
6882 -- Show list of connected realms
6883 local titleRealm = GetRealmName()
6884 local userRealm = GetNormalizedRealmName()
6885 local connectedServers = GetAutoCompleteRealms()
6886 if titleRealm and userRealm and connectedServers then
6887 LeaPlusLC:Print(L["Connections for"] .. "|cffffffff " .. titleRealm)
6888 if #connectedServers > 0 then
6889 local count = 1
6890 for i = 1, #connectedServers do
6891 if userRealm ~= connectedServers[i] then
6892 LeaPlusLC:Print(count .. ". " .. connectedServers[i])
6893 count = count + 1
6894 end
6895 end
6896 else
6897 LeaPlusLC:Print("None")
6898 end
6899 end
6900 return
6901 elseif str == "admin" then
6902 -- Preset profile (used for testing)
6903 LpEvt:UnregisterAllEvents() -- Prevent changes
6904 wipe(LeaPlusDB) -- Wipe settings
6905 LeaPlusLC:PlayerLogout(true) -- Reset permanent settings
6906 -- Automation
6907 LeaPlusDB["AutomateQuests"] = "On" -- Automate quests
6908 LeaPlusDB["AutomateGossip"] = "On" -- Automate gossip
6909 LeaPlusDB["AutoAcceptSummon"] = "On" -- Accept summon
6910 LeaPlusDB["AutoAcceptRes"] = "On" -- Accept resurrection
6911 LeaPlusDB["AutoReleasePvP"] = "On" -- Release in PvP
6912 LeaPlusDB["AutoSellJunk"] = "On" -- Sell junk automatically
6913 LeaPlusDB["AutoRepairGear"] = "On" -- Repair automatically
6914
6915 -- Social
6916 LeaPlusDB["NoDuelRequests"] = "On" -- Block duels
6917 LeaPlusDB["NoPartyInvites"] = "Off" -- Block party invites
6918 LeaPlusDB["NoFriendRequests"] = "Off" -- Block friend requests
6919 LeaPlusDB["AcceptPartyFriends"] = "On" -- Party from friends
6920 LeaPlusDB["InviteFromWhisper"] = "On" -- Invite from whispers
6921
6922 -- Chat
6923 LeaPlusDB["UseEasyChatResizing"] = "On" -- Use easy resizing
6924 LeaPlusDB["NoCombatLogTab"] = "On" -- Hide the combat log
6925 LeaPlusDB["NoChatButtons"] = "On" -- Hide chat buttons
6926 LeaPlusDB["UnclampChat"] = "On" -- Unclamp chat frame
6927 LeaPlusDB["MoveChatEditBoxToTop"] = "On" -- Move editbox to top
6928 LeaPlusDB["NoStickyChat"] = "On" -- Disable sticky chat
6929 LeaPlusDB["UseArrowKeysInChat"] = "On" -- Use arrow keys in chat
6930 LeaPlusDB["NoChatFade"] = "On" -- Disable chat fade
6931 LeaPlusDB["UnivGroupColor"] = "On" -- Universal group color
6932 LeaPlusDB["ClassColorsInChat"] = "On" -- Use class colors in chat
6933 LeaPlusDB["RecentChatWindow"] = "On" -- Recent chat window
6934 LeaPlusDB["MaxChatHstory"] = "Off" -- Increase chat history
6935
6936 -- Text
6937 LeaPlusDB["HideErrorMessages"] = "On" -- Hide error messages
6938 LeaPlusDB["NoHitIndicators"] = "On" -- Hide portrait text
6939 LeaPlusDB["MailFontChange"] = "On" -- Resize mail text
6940 LeaPlusDB["LeaPlusMailFontSize"] = 22 -- Mail font size
6941 LeaPlusDB["QuestFontChange"] = "On" -- Resize quest text
6942 LeaPlusDB["LeaPlusQuestFontSize"] = 18 -- Quest font size
6943
6944 -- Interface
6945 LeaPlusDB["MinimapMod"] = "On" -- Customise minimap
6946 LeaPlusDB["HideZoneTextBar"] = "On" -- Hide zone text bar
6947 LeaPlusDB["MinimapScale"] = 1.30 -- Minimap scale slider
6948 LeaPlusDB["TipModEnable"] = "On" -- Manage tooltip
6949 LeaPlusDB["TipBackSimple"] = "On" -- Color backdrops
6950 LeaPlusDB["LeaPlusTipSize"] = 1.25 -- Tooltip scale slider
6951 LeaPlusDB["EnhanceDressup"] = "On" -- Enhance dressup
6952 LeaPlusDB["ShowVolume"] = "On" -- Show volume slider
6953 LeaPlusDB["AhExtras"] = "On" -- Show auction controls
6954 LeaPlusDB["ShowCooldowns"] = "On" -- Show cooldowns
6955 LeaPlusDB["DurabilityStatus"] = "On" -- Show durability status
6956 LeaPlusDB["ShowVanityControls"] = "On" -- Show vanity controls
6957 LeaPlusDB["ShowWowheadLinks"] = "On" -- Show Wowhead links
6958
6959 -- Interface: Manage frames
6960 LeaPlusDB["FrmEnabled"] = "On"
6961
6962 LeaPlusDB["Frames"] = {}
6963 LeaPlusDB["Frames"]["PlayerFrame"] = {}
6964 LeaPlusDB["Frames"]["PlayerFrame"]["Point"] = "TOPLEFT"
6965 LeaPlusDB["Frames"]["PlayerFrame"]["Relative"] = "TOPLEFT"
6966 LeaPlusDB["Frames"]["PlayerFrame"]["XOffset"] = -35
6967 LeaPlusDB["Frames"]["PlayerFrame"]["YOffset"] = -14
6968 LeaPlusDB["Frames"]["PlayerFrame"]["Scale"] = 1.20
6969
6970 LeaPlusDB["Frames"]["TargetFrame"] = {}
6971 LeaPlusDB["Frames"]["TargetFrame"]["Point"] = "TOPLEFT"
6972 LeaPlusDB["Frames"]["TargetFrame"]["Relative"] = "TOPLEFT"
6973 LeaPlusDB["Frames"]["TargetFrame"]["XOffset"] = 190
6974 LeaPlusDB["Frames"]["TargetFrame"]["YOffset"] = -14
6975 LeaPlusDB["Frames"]["TargetFrame"]["Scale"] = 1.20
6976
6977 LeaPlusDB["Frames"]["MirrorTimer1"] = {}
6978 LeaPlusDB["Frames"]["MirrorTimer1"]["Point"] = "TOP"
6979 LeaPlusDB["Frames"]["MirrorTimer1"]["Relative"] = "TOP"
6980 LeaPlusDB["Frames"]["MirrorTimer1"]["XOffset"] = 0
6981 LeaPlusDB["Frames"]["MirrorTimer1"]["YOffset"] = -120
6982
6983 LeaPlusDB["Frames"]["LeaPlusTopCenterContainerHolder"] = {}
6984 LeaPlusDB["Frames"]["LeaPlusTopCenterContainerHolder"]["Point"] = "TOP"
6985 LeaPlusDB["Frames"]["LeaPlusTopCenterContainerHolder"]["Relative"] = "TOP"
6986 LeaPlusDB["Frames"]["LeaPlusTopCenterContainerHolder"]["XOffset"] = 0
6987 LeaPlusDB["Frames"]["LeaPlusTopCenterContainerHolder"]["YOffset"] = -432
6988 LeaPlusDB["Frames"]["LeaPlusTopCenterContainerHolder"]["Scale"] = 1.25
6989
6990 LeaPlusDB["Frames"]["BuffFrame"] = {}
6991 LeaPlusDB["Frames"]["BuffFrame"]["Point"] = "TOPRIGHT"
6992 LeaPlusDB["Frames"]["BuffFrame"]["Relative"] = "TOPRIGHT"
6993 LeaPlusDB["Frames"]["BuffFrame"]["XOffset"] = -271
6994 LeaPlusDB["Frames"]["BuffFrame"]["YOffset"] = 0
6995 LeaPlusDB["Frames"]["BuffFrame"]["Scale"] = 0.80
6996
6997 LeaPlusDB["ClassColFrames"] = "On" -- Class colored frames
6998 LeaPlusDB["ShowPlayerChain"] = "On" -- Show player chain
6999 LeaPlusDB["PlayerChainMenu"] = 3 -- Player chain style
7000 LeaPlusDB["ShowRaidToggle"] = "On" -- Show raid toggle button
7001 LeaPlusDB["CombatPlates"] = "On" -- Combat plates
7002
7003 LeaPlusDB["NoGryphons"] = "On" -- Hide gryphons
7004 LeaPlusDB["NoClassBar"] = "On" -- Hide stance bar
7005
7006 -- System
7007 LeaPlusDB["NoScreenGlow"] = "On" -- Disable screen glow
7008 LeaPlusDB["NoScreenEffects"] = "On" -- Disable screen effects
7009 LeaPlusDB["MaxCameraZoom"] = "On" -- Max camera zoom
7010 LeaPlusDB["ViewPortEnable"] = "On" -- Enable viewport
7011 LeaPlusDB["NoRestedEmotes"] = "On" -- Silence rested emotes
7012
7013 LeaPlusDB["NoBagAutomation"] = "On" -- Disable bag automation
7014 LeaPlusDB["CharAddonList"] = "On" -- Show character addons
7015 LeaPlusDB["NoConfirmLoot"] = "On" -- Disable loot warnings
7016 LeaPlusDB["FasterLooting"] = "On" -- Faster auto loot
7017 LeaPlusDB["FasterMovieSkip"] = "On" -- Faster movie skip
7018 LeaPlusDB["StandAndDismount"] = "On" -- Stand and dismount
7019 LeaPlusDB["ShowVendorPrice"] = "On" -- Show vendor price
7020
7021 -- Settings
7022 LeaPlusDB["EnableHotkey"] = "On" -- Enable hotkey
7023
7024 -- Function to assign cooldowns
7025 local function setIcon(pclass, pspec, sp1, pt1, sp2, pt2, sp3, pt3, sp4, pt4, sp5, pt5)
7026 -- Set spell ID
7027 if sp1 == 0 then LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R1Idn"] = "" else LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R1Idn"] = sp1 end
7028 if sp2 == 0 then LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R2Idn"] = "" else LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R2Idn"] = sp2 end
7029 if sp3 == 0 then LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R3Idn"] = "" else LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R3Idn"] = sp3 end
7030 if sp4 == 0 then LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R4Idn"] = "" else LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R4Idn"] = sp4 end
7031 if sp5 == 0 then LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R5Idn"] = "" else LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R5Idn"] = sp5 end
7032 -- Set pet checkbox
7033 if pt1 == 0 then LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R1Pet"] = false else LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R1Pet"] = true end
7034 if pt2 == 0 then LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R2Pet"] = false else LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R2Pet"] = true end
7035 if pt3 == 0 then LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R3Pet"] = false else LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R3Pet"] = true end
7036 if pt4 == 0 then LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R4Pet"] = false else LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R4Pet"] = true end
7037 if pt5 == 0 then LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R5Pet"] = false else LeaPlusDB["Cooldowns"][pclass]["S" .. pspec .. "R5Pet"] = true end
7038 end
7039
7040 -- Create main table
7041 LeaPlusDB["Cooldowns"] = {}
7042
7043 -- Create class tables
7044 local classList = {"WARRIOR", "PALADIN", "HUNTER", "SHAMAN", "ROGUE", "DRUID", "MAGE", "WARLOCK", "PRIEST"}
7045 for index = 1, #classList do
7046 if LeaPlusDB["Cooldowns"][classList[index]] == nil then
7047 LeaPlusDB["Cooldowns"][classList[index]] = {}
7048 end
7049 end
7050
7051 -- Assign cooldowns
7052 setIcon("WARRIOR", 1, --[[1]] 0, 0, --[[2]] 0, 0, --[[3]] 0, 0, --[[4]] 0, 0, --[[5]] 0, 0)
7053 setIcon("PALADIN", 1, --[[1]] 0, 0, --[[2]] 0, 0, --[[3]] 0, 0, --[[4]] 0, 0, --[[5]] 19740, 0) -- nil, nil, nil, nil, Might
7054 setIcon("HUNTER", 1, --[[1]] 136, 1, --[[2]] 118455, 1, --[[3]] 0, 0, --[[4]] 0, 0, --[[5]] 5384, 0) -- Mend Pet, nil, nil, nil, Feign Death
7055 setIcon("SHAMAN", 1, --[[1]] 0, 0, --[[2]] 0, 0, --[[3]] 0, 0, --[[4]] 215864, 0, --[[5]] 546, 0) -- nil, nil, nil, Rainfall, Water Walking
7056 setIcon("ROGUE", 1, --[[1]] 1784, 0, --[[2]] 0, 0, --[[3]] 0, 0, --[[4]] 2823, 0, --[[5]] 3408, 0) -- Stealth, nil, nil, Deadly Poison, Crippling Poison
7057 setIcon("DRUID", 1, --[[1]] 0, 0, --[[2]] 0, 0, --[[3]] 0, 0, --[[4]] 0, 0, --[[5]] 0, 0)
7058 setIcon("MAGE", 1, --[[1]] 235450, 0, --[[2]] 0, 0, --[[3]] 0, 0, --[[4]] 0, 0, --[[5]] 0, 0) -- Prismatic Barrier
7059 setIcon("WARLOCK", 1, --[[1]] 0, 0, --[[2]] 0, 0, --[[3]] 0, 0, --[[4]] 0, 0, --[[5]] 0, 0)
7060 setIcon("PRIEST", 1, --[[1]] 17, 0, --[[2]] 0, 0, --[[3]] 0, 0, --[[4]] 0, 0, --[[5]] 0, 0) -- Power Word: Shield
7061
7062 -- Reload
7063 ReloadUI()
7064 else
7065 LeaPlusLC:Print("Invalid parameter.")
7066 end
7067 return
7068 else
7069 -- Prevent options panel from showing if a game options panel is showing
7070 if InterfaceOptionsFrame:IsShown() or VideoOptionsFrame:IsShown() or ChatConfigFrame:IsShown() then return end
7071 -- Prevent options panel from showing if Blizzard Store is showing
7072 if StoreFrame and StoreFrame:GetAttribute("isshown") then return end
7073 -- Toggle the options panel if game options panel is not showing
7074 if LeaPlusLC:IsPlusShowing() then
7075 LeaPlusLC:HideFrames()
7076 LeaPlusLC:HideConfigPanels()
7077 else
7078 LeaPlusLC:HideFrames()
7079 LeaPlusLC["PageF"]:Show()
7080 end
7081 LeaPlusLC["Page"..LeaPlusLC["LeaStartPage"]]:Show()
7082 end
7083 end
7084
7085 -- Slash command for global function
7086 _G.SLASH_Leatrix_Plus1 = "/ltp"
7087 _G.SLASH_Leatrix_Plus2 = "/leaplus"
7088 SlashCmdList["Leatrix_Plus"] = function(self)
7089 -- Run slash command function
7090 LeaPlusLC:SlashFunc(self)
7091 -- Redirect tainted variables
7092 RunScript('ACTIVE_CHAT_EDIT_BOX = ACTIVE_CHAT_EDIT_BOX')
7093 RunScript('LAST_ACTIVE_CHAT_EDIT_BOX = LAST_ACTIVE_CHAT_EDIT_BOX')
7094 end
7095
7096 -- Slash command for UI reload
7097 _G.SLASH_LEATRIX_PLUS_RL1 = "/rl"
7098 SlashCmdList["LEATRIX_PLUS_RL"] = function()
7099 ReloadUI()
7100 end
7101
7102----------------------------------------------------------------------
7103-- L90: Create options panel pages (no content yet)
7104----------------------------------------------------------------------
7105
7106 -- Function to add menu button
7107 function LeaPlusLC:MakeMN(name, text, parent, anchor, x, y, width, height)
7108
7109 local mbtn = CreateFrame("Button", nil, parent)
7110 LeaPlusLC[name] = mbtn
7111 mbtn:Show();
7112 mbtn:SetSize(width, height)
7113 mbtn:SetAlpha(1.0)
7114 mbtn:SetPoint(anchor, x, y)
7115
7116 mbtn.t = mbtn:CreateTexture(nil, "BACKGROUND")
7117 mbtn.t:SetAllPoints()
7118 mbtn.t:SetColorTexture(0.3, 0.3, 0.00, 0.8)
7119 mbtn.t:SetAlpha(0.7)
7120 mbtn.t:Hide()
7121
7122 mbtn.s = mbtn:CreateTexture(nil, "BACKGROUND")
7123 mbtn.s:SetAllPoints()
7124 mbtn.s:SetColorTexture(0.3, 0.3, 0.00, 0.8)
7125 mbtn.s:Hide()
7126
7127 mbtn.f = mbtn:CreateFontString(nil, 'ARTWORK', 'GameFontNormal')
7128 mbtn.f:SetPoint('LEFT', 16, 0)
7129 mbtn.f:SetText(L[text])
7130
7131 mbtn:SetScript("OnEnter", function()
7132 mbtn.t:Show()
7133 end)
7134
7135 mbtn:SetScript("OnLeave", function()
7136 mbtn.t:Hide()
7137 end)
7138
7139 return mbtn, mbtn.s
7140
7141 end
7142
7143 -- Function to create individual options panel pages
7144 function LeaPlusLC:MakePage(name, title, menu, menuname, menuparent, menuanchor, menux, menuy, menuwidth, menuheight)
7145
7146 -- Create frame
7147 local oPage = CreateFrame("Frame", nil, LeaPlusLC["PageF"]);
7148 LeaPlusLC[name] = oPage
7149 oPage:SetAllPoints(LeaPlusLC["PageF"])
7150 oPage:Hide();
7151
7152 -- Add page title
7153 oPage.s = oPage:CreateFontString(nil, 'ARTWORK', 'GameFontNormalLarge')
7154 oPage.s:SetPoint('TOPLEFT', 146, -16)
7155 oPage.s:SetText(L[title])
7156
7157 -- Add menu item if needed
7158 if menu then
7159 LeaPlusLC[menu], LeaPlusLC[menu .. ".s"] = LeaPlusLC:MakeMN(menu, menuname, menuparent, menuanchor, menux, menuy, menuwidth, menuheight)
7160 LeaPlusLC[name]:SetScript("OnShow", function() LeaPlusLC[menu .. ".s"]:Show(); end)
7161 LeaPlusLC[name]:SetScript("OnHide", function() LeaPlusLC[menu .. ".s"]:Hide(); end)
7162 end
7163
7164 return oPage;
7165
7166 end
7167
7168 -- Create options pages
7169 LeaPlusLC["Page0"] = LeaPlusLC:MakePage("Page0", "Home" , "LeaPlusNav0", "Home" , LeaPlusLC["PageF"], "TOPLEFT", 16, -72, 112, 20)
7170 LeaPlusLC["Page1"] = LeaPlusLC:MakePage("Page1", "Automation" , "LeaPlusNav1", "Automation" , LeaPlusLC["PageF"], "TOPLEFT", 16, -112, 112, 20)
7171 LeaPlusLC["Page2"] = LeaPlusLC:MakePage("Page2", "Social" , "LeaPlusNav2", "Social" , LeaPlusLC["PageF"], "TOPLEFT", 16, -132, 112, 20)
7172 LeaPlusLC["Page3"] = LeaPlusLC:MakePage("Page3", "Chat" , "LeaPlusNav3", "Chat" , LeaPlusLC["PageF"], "TOPLEFT", 16, -152, 112, 20)
7173 LeaPlusLC["Page4"] = LeaPlusLC:MakePage("Page4", "Text" , "LeaPlusNav4", "Text" , LeaPlusLC["PageF"], "TOPLEFT", 16, -172, 112, 20)
7174 LeaPlusLC["Page5"] = LeaPlusLC:MakePage("Page5", "Interface" , "LeaPlusNav5", "Interface" , LeaPlusLC["PageF"], "TOPLEFT", 16, -192, 112, 20)
7175 LeaPlusLC["Page6"] = LeaPlusLC:MakePage("Page6", "Frames" , "LeaPlusNav6", "Frames" , LeaPlusLC["PageF"], "TOPLEFT", 16, -212, 112, 20)
7176 LeaPlusLC["Page7"] = LeaPlusLC:MakePage("Page7", "System" , "LeaPlusNav7", "System" , LeaPlusLC["PageF"], "TOPLEFT", 16, -232, 112, 20)
7177 LeaPlusLC["Page8"] = LeaPlusLC:MakePage("Page8", "Settings" , "LeaPlusNav8", "Settings" , LeaPlusLC["PageF"], "TOPLEFT", 16, -272, 112, 20)
7178 LeaPlusLC["Page9"] = LeaPlusLC:MakePage("Page9", "Media" , "LeaPlusNav9", "Media" , LeaPlusLC["PageF"], "TOPLEFT", 16, -292, 112, 20)
7179
7180 -- Page navigation mechanism
7181 for i = 0, LeaPlusLC["NumberOfPages"] do
7182 LeaPlusLC["LeaPlusNav"..i]:SetScript("OnClick", function()
7183 LeaPlusLC:HideFrames()
7184 LeaPlusLC["PageF"]:Show();
7185 LeaPlusLC["Page"..i]:Show();
7186 LeaPlusLC["LeaStartPage"] = i
7187 end)
7188 end
7189
7190 -- Use a variable to contain the page number (makes it easier to move options around)
7191 local pg;
7192
7193----------------------------------------------------------------------
7194-- LC0: Welcome
7195----------------------------------------------------------------------
7196
7197 pg = "Page0";
7198
7199 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Welcome to Leatrix Plus.", 146, -72);
7200 LeaPlusLC:MakeWD(LeaPlusLC[pg], "To begin, choose an options page.", 146, -92);
7201
7202 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Support", 146, -132);
7203 LeaPlusLC:MakeWD(LeaPlusLC[pg], "www.leatrix.com", 146, -152);
7204
7205----------------------------------------------------------------------
7206-- LC1: Automation
7207----------------------------------------------------------------------
7208
7209 pg = "Page1";
7210
7211 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Character" , 146, -72);
7212 LeaPlusLC:MakeCB(LeaPlusLC[pg], "AutomateQuests" , "Automate quests" , 146, -92, false, "If checked, quests will be selected, accepted and turned-in automatically.|n|nQuests which have a gold requirement will not be turned-in automatically.|n|nYou can hold the shift key down when you talk to a quest giver to override this setting.")
7213 LeaPlusLC:MakeCB(LeaPlusLC[pg], "AutomateGossip" , "Automate gossip" , 146, -112, false, "If checked, you can hold down the alt key while opening a gossip window to automatically select a single gossip item.\n\nIf the gossip item type is banker, taxi, trainer or vendor, gossip will be skipped without needing to hold the alt key. You can hold the shift key down to prevent this.")
7214 LeaPlusLC:MakeCB(LeaPlusLC[pg], "AutoAcceptSummon" , "Accept summon" , 146, -132, false, "If checked, summon requests will be accepted automatically unless you are in combat.")
7215 LeaPlusLC:MakeCB(LeaPlusLC[pg], "AutoAcceptRes" , "Accept resurrection" , 146, -152, false, "If checked, resurrection requests will be accepted automatically as long as the player resurrecting you is not in combat.")
7216 LeaPlusLC:MakeCB(LeaPlusLC[pg], "AutoReleasePvP" , "Release in PvP" , 146, -172, false, "If checked, you will release automatically after you die in a battleground.|n|nYou will not release automatically if you have the ability to self-resurrect.")
7217
7218 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Vendors" , 340, -72);
7219 LeaPlusLC:MakeCB(LeaPlusLC[pg], "AutoSellJunk" , "Sell junk automatically" , 340, -92, false, "If checked, all grey items in your bags will be sold automatically when you visit a merchant.|n|nYou can hold the shift key down when you talk to a merchant to override this setting.")
7220 LeaPlusLC:MakeCB(LeaPlusLC[pg], "AutoRepairGear" , "Repair automatically" , 340, -112, false, "If checked, your gear will be repaired automatically when you visit a suitable merchant.|n|nYou can hold the shift key down when you talk to a merchant to override this setting.")
7221
7222----------------------------------------------------------------------
7223-- LC2: Social
7224----------------------------------------------------------------------
7225
7226 pg = "Page2";
7227
7228 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Blocks" , 146, -72);
7229 LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoDuelRequests" , "Block duels" , 146, -92, false, "If checked, duel requests will be blocked unless the player requesting the duel is in your friends list or guild.")
7230 LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoPartyInvites" , "Block party invites" , 146, -112, false, "If checked, party invitations will be blocked unless the player inviting you is in your friends list or guild.")
7231 LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoFriendRequests" , "Block friend requests" , 146, -132, false, "If checked, BattleTag and Real ID friend requests will be automatically declined.|n|nEnabling this option will automatically decline any pending requests.")
7232
7233 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Groups" , 340, -72);
7234 LeaPlusLC:MakeCB(LeaPlusLC[pg], "AcceptPartyFriends" , "Party from friends" , 340, -92, false, "If checked, party invitations from friends or guild members will be automatically accepted.")
7235 LeaPlusLC:MakeCB(LeaPlusLC[pg], "InviteFromWhisper" , "Invite from whispers" , 340, -112, false, "If checked, a group invite will be sent to anyone who whispers you with the keyword INV.|n|nYou need to be either ungrouped or party leader in your own group for this to work.")
7236
7237----------------------------------------------------------------------
7238-- LC3: Chat
7239----------------------------------------------------------------------
7240
7241 pg = "Page3";
7242
7243 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Chat Frame" , 146, -72);
7244 LeaPlusLC:MakeCB(LeaPlusLC[pg], "UseEasyChatResizing" , "Use easy resizing" , 146, -92, true, "If checked, dragging the General chat tab while the chat frame is locked will expand the chat frame upwards.|n|n\If the chat frame is unlocked, dragging the General chat tab will move the chat frame.")
7245 LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoCombatLogTab" , "Hide the combat log" , 146, -112, true, "If checked, the combat log will be hidden.|n|nThe combat log must be docked in order for this option to work.|n|nIf the combat log is undocked, you can dock it by dragging the tab (and reloading your UI) or by resetting the chat windows (from the chat menu).")
7246 LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoChatButtons" , "Hide chat buttons" , 146, -132, true, "If checked, chat frame buttons will be hidden.|n|nClicking chat tabs will automatically show the latest messages.|n|nUse the mouse wheel to scroll through the chat history. Hold down SHIFT for page jump or CTRL to jump to the top or bottom of the chat history.")
7247 LeaPlusLC:MakeCB(LeaPlusLC[pg], "UnclampChat" , "Unclamp chat frame" , 146, -152, true, "If checked, you will be able to drag the chat frame to the edge of the screen.")
7248 LeaPlusLC:MakeCB(LeaPlusLC[pg], "MoveChatEditBoxToTop" , "Move editbox to top" , 146, -172, true, "If checked, the editbox will be moved to the top of the chat frame.")
7249
7250 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Mechanics" , 340, -72);
7251 LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoStickyChat" , "Disable sticky chat" , 340, -92, true, "If checked, sticky chat will be disabled.|n|nNote that this does not apply to temporary chat windows.")
7252 LeaPlusLC:MakeCB(LeaPlusLC[pg], "UseArrowKeysInChat" , "Use arrow keys in chat" , 340, -112, true, "If checked, you can press the arrow keys to move the insertion point left and right in the chat frame.|n|nIf unchecked, the arrow keys will use the default keybind setting.")
7253 LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoChatFade" , "Disable chat fade" , 340, -132, true, "If checked, chat text will not fade out after a time period.")
7254 LeaPlusLC:MakeCB(LeaPlusLC[pg], "UnivGroupColor" , "Universal group color" , 340, -152, false, "If checked, raid chat and instance chat will both be colored blue (to match the default party chat color).")
7255 LeaPlusLC:MakeCB(LeaPlusLC[pg], "ClassColorsInChat" , "Use class colors in chat" , 340, -172, false, "If checked, class colors will be used in the chat frame.")
7256 LeaPlusLC:MakeCB(LeaPlusLC[pg], "RecentChatWindow" , "Recent chat window" , 340, -192, true, "If checked, you can hold down the control key and click a chat tab to view recent chat in a copy-friendly window.")
7257 LeaPlusLC:MakeCB(LeaPlusLC[pg], "MaxChatHstory" , "Increase chat history" , 340, -212, true, "If checked, your chat history will increase to 4096 lines. If unchecked, the default will be used (128 lines).|n|nEnabling this option may prevent some chat text from showing during login.")
7258
7259----------------------------------------------------------------------
7260-- LC4: Text
7261----------------------------------------------------------------------
7262
7263 pg = "Page4";
7264
7265 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Visibility" , 146, -72);
7266 LeaPlusLC:MakeCB(LeaPlusLC[pg], "HideErrorMessages" , "Hide error messages" , 146, -92, true, "If checked, most error messages (such as 'Not enough rage') will not be shown. Some important errors are excluded.|n|nIf you have the minimap button enabled, you can hold down the control key and right-click it to toggle error messages without affecting this setting.")
7267 LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoHitIndicators" , "Hide portrait numbers" , 146, -112, true, "If checked, damage and healing numbers in the player and pet portrait frames will be hidden.")
7268 LeaPlusLC:MakeCB(LeaPlusLC[pg], "HideZoneText" , "Hide zone text" , 146, -132, true, "If checked, zone text will not be shown (eg. 'Ironforge').")
7269
7270 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Text Size" , 340, -72);
7271 LeaPlusLC:MakeCB(LeaPlusLC[pg], "MailFontChange" , "Resize mail text" , 340, -92, true, "If checked, you will be able to change the font size of standard mail text.|n|nThis does not affect mail created using templates (such as auction house invoices).")
7272 LeaPlusLC:MakeCB(LeaPlusLC[pg], "QuestFontChange" , "Resize quest text" , 340, -112, true, "If checked, you will be able to change the font size of quest text.")
7273
7274 LeaPlusLC:CfgBtn("MailTextBtn", LeaPlusCB["MailFontChange"])
7275 LeaPlusLC:CfgBtn("QuestTextBtn", LeaPlusCB["QuestFontChange"])
7276
7277----------------------------------------------------------------------
7278-- LC5: Interface
7279----------------------------------------------------------------------
7280
7281 pg = "Page5";
7282
7283 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Enhancements" , 146, -72);
7284 LeaPlusLC:MakeCB(LeaPlusLC[pg], "MinimapMod" , "Customise minimap" , 146, -92, true, "If checked, you will be able to customise the minimap.")
7285 LeaPlusLC:MakeCB(LeaPlusLC[pg], "TipModEnable" , "Manage tooltip" , 146, -112, true, "If checked, the tooltip will be color coded and you will be able to modify the tooltip layout and scale.")
7286 LeaPlusLC:MakeCB(LeaPlusLC[pg], "EnhanceDressup" , "Enhance dressup" , 146, -132, true, "If checked, nude and tabard toggle buttons will be added to the dressup frame and model rotation controls will be removed.")
7287
7288 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Extras" , 340, -72);
7289 LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowVolume" , "Show volume slider" , 340, -92, true, "If checked, a master volume slider will be shown in the character sheet.")
7290 LeaPlusLC:MakeCB(LeaPlusLC[pg], "AhExtras" , "Show auction controls" , 340, -112, true, "If checked, additional functionality will be added to the auction house.|n|nBuyout only - create buyout auctions without filling in the starting price.|n|nGold only - set the copper and silver prices at 99 to speed up new auctions.|n|nFind item - search the auction house for the item you are selling.|n|nIn addition, the auction duration setting will be saved account-wide.")
7291 LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowCooldowns" , "Show cooldowns" , 340, -132, true, "If checked, you will be able to place up to five beneficial cooldown icons above the target frame.")
7292 LeaPlusLC:MakeCB(LeaPlusLC[pg], "DurabilityStatus" , "Show durability status" , 340, -152, true, "If checked, a button will be added to the character sheet which will show your equipped item durability when you hover the pointer over it.|n|nIn addition, an overall percentage will be shown in the chat frame when you die.")
7293 LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowVanityControls" , "Show vanity controls" , 340, -172, true, "If checked, helm and cloak toggle checkboxes will be shown in the character sheet.")
7294 LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowWowheadLinks" , "Show Wowhead links" , 340, -192, true, "If checked, Wowhead links will be shown above the quest log frame.")
7295
7296 LeaPlusLC:CfgBtn("ModMinimapBtn", LeaPlusCB["MinimapMod"])
7297 LeaPlusLC:CfgBtn("MoveTooltipButton", LeaPlusCB["TipModEnable"])
7298 LeaPlusLC:CfgBtn("CooldownsButton", LeaPlusCB["ShowCooldowns"])
7299
7300----------------------------------------------------------------------
7301-- LC6: Frames
7302----------------------------------------------------------------------
7303
7304 pg = "Page6";
7305
7306 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Features" , 146, -72);
7307 LeaPlusLC:MakeCB(LeaPlusLC[pg], "FrmEnabled" , "Manage frames" , 146, -92, true, "If checked, you will be able to change the position and scale of the following frames:|n|n- Player frame|n- Target frame|n- Buffs frame|n- Widget top center frame|n- Timer bar")
7308 LeaPlusLC:MakeCB(LeaPlusLC[pg], "ClassColFrames" , "Class colored frames" , 146, -112, true, "If checked, class coloring will be used in the player frame and target frame.")
7309 LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowPlayerChain" , "Show player chain" , 146, -132, true, "If checked, you will be able to show a rare, elite or rare elite chain around the player frame.")
7310 LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowRaidToggle" , "Raid frame toggle" , 146, -152, true, "If checked, the button to toggle the raid container frame will be shown just above the raid management frame (left side of the screen) instead of in the raid management frame itself.|n|nThis allows you to toggle the raid container frame without needing to open the raid management frame.")
7311 LeaPlusLC:MakeCB(LeaPlusLC[pg], "CombatPlates" , "Combat plates" , 146, -172, true, "If checked, enemy nameplates will be shown during combat and hidden when combat ends.")
7312
7313 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Visibility" , 340, -72);
7314 LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoGryphons" , "Hide gryphons" , 340, -92, true, "If checked, the main bar gryphons will not be shown.")
7315 LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoClassBar" , "Hide stance bar" , 340, -112, true, "If checked, the stance bar will not be shown.")
7316
7317 LeaPlusLC:CfgBtn("MoveFramesButton", LeaPlusCB["FrmEnabled"])
7318 LeaPlusLC:CfgBtn("ModPlayerChain", LeaPlusCB["ShowPlayerChain"])
7319
7320----------------------------------------------------------------------
7321-- LC7: System
7322----------------------------------------------------------------------
7323
7324 pg = "Page7";
7325
7326 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Graphics and Sound" , 146, -72);
7327 LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoScreenGlow" , "Disable screen glow" , 146, -92, false, "If checked, the screen glow will be disabled.|n|nEnabling this option will also disable the drunken haze effect.")
7328 LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoScreenEffects" , "Disable screen effects" , 146, -112, false, "If checked, the grey screen of death and the netherworld effect will be disabled.")
7329 LeaPlusLC:MakeCB(LeaPlusLC[pg], "MaxCameraZoom" , "Max camera zoom" , 146, -132, false, "If checked, you will be able to zoom out to a greater distance.")
7330 LeaPlusLC:MakeCB(LeaPlusLC[pg], "ViewPortEnable" , "Enable viewport" , 146, -152, true, "If checked, you will be able to create a viewport. A viewport adds adjustable black borders around the game world.|n|nThe borders are placed on top of the game world but under the UI so you can place UI elements over them.")
7331 LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoRestedEmotes" , "Silence rested emotes" , 146, -172, true, "If checked, emote sounds will be silenced while your character is resting or at the Grim Guzzler.|n|nEmote sounds will be enabled at all other times.")
7332
7333 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Game Options" , 340, -72);
7334 LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoBagAutomation" , "Disable bag automation" , 340, -92, true, "If checked, your bags will not be opened or closed automatically when you interact with a merchant, bank or mailbox.")
7335 LeaPlusLC:MakeCB(LeaPlusLC[pg], "CharAddonList" , "Show character addons" , 340, -112, true, "If checked, the addon list (accessible from the game menu) will show character based addons by default.")
7336 LeaPlusLC:MakeCB(LeaPlusLC[pg], "NoConfirmLoot" , "Disable loot warnings" , 340, -132, false, "If checked, confirmations will no longer appear when you choose a loot roll option or attempt to sell or mail a tradable item.")
7337 LeaPlusLC:MakeCB(LeaPlusLC[pg], "FasterLooting" , "Faster auto loot" , 340, -152, true, "If checked, the amount of time it takes to auto loot creatures will be significantly reduced.")
7338 LeaPlusLC:MakeCB(LeaPlusLC[pg], "FasterMovieSkip" , "Faster movie skip" , 340, -172, true, "If checked, you will be able to cancel cinematics without being prompted for confirmation.")
7339 LeaPlusLC:MakeCB(LeaPlusLC[pg], "StandAndDismount" , "Stand and dismount" , 340, -192, true, "If checked, your character will automatically stand or dismount when an action is prevented because you are either seated or mounted.")
7340 LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowVendorPrice" , "Show vendor price" , 340, -212, true, "If checked, the vendor price will be shown in item tooltips.")
7341
7342 LeaPlusLC:CfgBtn("ModViewportBtn", LeaPlusCB["ViewPortEnable"])
7343
7344----------------------------------------------------------------------
7345-- LC8: Settings
7346----------------------------------------------------------------------
7347
7348 pg = "Page8";
7349
7350 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Addon" , 146, -72);
7351 LeaPlusLC:MakeCB(LeaPlusLC[pg], "ShowMinimapIcon" , "Show minimap button" , 146, -92, false, "If checked, a minimap button will be available.|n|nClick - Toggle options panel.|n|nSHIFT/Left-click - Toggle music.|n|nCTRL/Right-click - Toggle errors (if enabled).|n|nCTRL/SHIFT/Left-click - Toggle Zygor (if installed).|n|nCTRL/SHIFT/Right-click - Toggle windowed mode.")
7352 LeaPlusLC:MakeCB(LeaPlusLC[pg], "EnableHotkey" , "Enable hotkey" , 146, -112, true, "If checked, you can open Leatrix Plus by pressing CTRL/Z.")
7353
7354 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Scale", 340, -72);
7355 LeaPlusLC:MakeSL(LeaPlusLC[pg], "PlusPanelScale", "Drag to set the scale of the Leatrix Plus panel.", 1, 2, 0.1, 340, -92, "%.1f")
7356
7357 LeaPlusLC:MakeTx(LeaPlusLC[pg], "Transparency", 340, -132);
7358 LeaPlusLC:MakeSL(LeaPlusLC[pg], "PlusPanelAlpha", "Drag to set the transparency of the Leatrix Plus panel.", 0, 1, 0.1, 340, -152, "%.1f")
7359
7360 LeaPlusLC:ShowMemoryUsage(LeaPlusLC[pg], "TOPLEFT", 146, -262)