diff --git a/Interface/AddOns/SVUI/SVUI.toc b/Interface/AddOns/SVUI/SVUI.toc index 3891746..f31043e 100644 --- a/Interface/AddOns/SVUI/SVUI.toc +++ b/Interface/AddOns/SVUI/SVUI.toc @@ -1,6 +1,6 @@ ## Interface: 50400 ## Author: Munglunch -## Version: 4.0662 +## Version: 4.073 ## Title: |cffFF9900SVUI|r ## Notes: Supervillain UI [|cff9911FFCore Framework|r]. ## SavedVariables: SVUI_Global, SVUI_AuraFilters diff --git a/Interface/AddOns/SVUI/packages/_load.xml b/Interface/AddOns/SVUI/packages/_load.xml index febec3d..2236c23 100644 --- a/Interface/AddOns/SVUI/packages/_load.xml +++ b/Interface/AddOns/SVUI/packages/_load.xml @@ -1,16 +1,17 @@ <Ui xmlns="http://www.blizzard.com/wow/ui/"> - <Include file='stats\SVStats.xml'/> - <Include file="dock\SVDock.xml"/> + <Include file="stats\SVStats.xml"/> + <Script file="dock\SVDock.lua"/> <Include file="aura\SVAura.xml"/> <Include file="plates\SVPlate.xml"/> - <Include file="tip\SVTip.xml"/> - <Include file="actionbar\SVBar.xml"/> - <Include file='unit\SVUnit.xml'/> - <Include file="map\SVMap.xml"/> - <Include file="chat\SVChat.xml"/> + <Script file="tip\SVTip.lua"/> + <Script file="actionbar\SVBar.lua"/> + <Script file="actionbar\KeyBind.lua"/> + <Include file="unit\SVUnit.xml"/> + <Script file="map\SVMap.lua"/> + <Script file="chat\SVChat.lua"/> <Include file="bag\SVBag.xml"/> - <Include file="override\SVOverride.xml"/> - <Include file='gear\SVGear.xml'/> - <Include file='henchmen\SVHenchmen.xml'/> + <Script file="override\SVOverride.lua"/> + <Script file="gear\SVGear.lua"/> + <Script file="henchmen\SVHenchmen.lua"/> <Include file="laborer\SVLaborer.xml"/> </Ui> \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/actionbar/KeyBind.lua b/Interface/AddOns/SVUI/packages/actionbar/KeyBind.lua new file mode 100644 index 0000000..c44bf2e --- /dev/null +++ b/Interface/AddOns/SVUI/packages/actionbar/KeyBind.lua @@ -0,0 +1,513 @@ +--[[ +############################################################################## +_____/\\\\\\\\\\\____/\\\________/\\\__/\\\________/\\\__/\\\\\\\\\\\_ # + ___/\\\/////////\\\_\/\\\_______\/\\\_\/\\\_______\/\\\_\/////\\\///__ # + __\//\\\______\///__\//\\\______/\\\__\/\\\_______\/\\\_____\/\\\_____ # + ___\////\\\__________\//\\\____/\\\___\/\\\_______\/\\\_____\/\\\_____ # + ______\////\\\________\//\\\__/\\\____\/\\\_______\/\\\_____\/\\\_____ # + _________\////\\\______\//\\\/\\\_____\/\\\_______\/\\\_____\/\\\_____ # + __/\\\______\//\\\______\//\\\\\______\//\\\______/\\\______\/\\\_____ # + _\///\\\\\\\\\\\/________\//\\\________\///\\\\\\\\\/____/\\\\\\\\\\\_# + ___\///////////___________\///___________\/////////_____\///////////_# +############################################################################## +S U P E R - V I L L A I N - U I By: Munglunch # +############################################################################## +########################################################## +LOCALIZED LUA FUNCTIONS +########################################################## +]]-- +--[[ GLOBALS ]]-- +local _G = _G; +local select = _G.select; +local pairs = _G.pairs; +local ipairs = _G.ipairs; +local type = _G.type; +local string = _G.string; +local math = _G.math; +local table = _G.table; +local GetTime = _G.GetTime; +--[[ STRING METHODS ]]-- +local format, find = string.format, string.find; +--[[ MATH METHODS ]]-- +local floor = math.floor; +local tonumber = tonumber; +--[[ +########################################################## +GET ADDON DATA +########################################################## +]]-- +local SuperVillain, L = unpack(select(2, ...)); +local MOD = SuperVillain.Registry:Expose('SVBar'); +local LibAB = LibStub("LibActionButton-1.0") + +local _G = getfenv(0); + +local RefreshBindings +local NewFrame = CreateFrame; +local NewHook = hooksecurefunc; + +local Binder = NewFrame("Frame", nil, UIParent); +--[[ +########################################################## +BINDING UPDATES +########################################################## +]]-- +do + --[[ HANDLERS ]]-- + local GameTooltip_OnHide = function(self) + self:SetOwner(Binder, "ANCHOR_TOP") + self:SetPoint("BOTTOM", Binder, "TOP", 0, 1) + self:AddLine(Binder.button.name, 1, 1, 1) + Binder.button.bindings = {GetBindingKey(Binder.button.bindstring)} + local count = #Binder.button.bindings + if(count == 0) then + self:AddLine(L["No bindings set."], .6, .6, .6) + else + self:AddDoubleLine(L["Binding"], L["Key"], .6, .6, .6, .6, .6, .6) + for i = 1, count do + self:AddDoubleLine(i, Binder.button.bindings[i]) + end + end; + self:Show() + self:SetScript("OnHide", nil) + end + --[[ END OF HANDLERS ]]-- + + function RefreshBindings(bindTarget, bindType) + if(not Binder.active or InCombatLockdown()) then return end; + Binder.button = bindTarget; + Binder.spellmacro = bindType; + Binder:ClearAllPoints() + Binder:SetAllPoints(bindTarget) + Binder:Show() + ShoppingTooltip1:Hide() + if(bindTarget.FlyoutArrow and bindTarget.FlyoutArrow:IsShown()) then + Binder:EnableMouse(false) + elseif(not Binder:IsMouseEnabled()) then + Binder:EnableMouse(true) + end; + local keyBindID, keyBindName, keyBindString; + if bindType == "FLYOUT" then + keyBindName = GetSpellInfo(bindTarget.spellID); + keyBindString = "SPELL " .. keyBindName; + Binder.button.name = keyBindName + Binder.button.bindstring = keyBindString; + GameTooltip:AddLine(L["Trigger"]) + GameTooltip:Show() + GameTooltip:SetScript("OnHide", GameTooltip_OnHide) + elseif bindType == "SPELL" then + keyBindID = SpellBook_GetSpellBookSlot(bindTarget) + keyBindName = GetSpellBookItemName(keyBindID, SpellBookFrame.bookType); + keyBindString = "SPELL " .. keyBindName; + Binder.button.id = keyBindID + Binder.button.name = keyBindName + Binder.button.bindstring = keyBindString; + GameTooltip:AddLine(L["Trigger"]) + GameTooltip:Show() + GameTooltip:SetScript("OnHide", GameTooltip_OnHide) + elseif bindType == "MACRO" then + keyBindID = bindTarget:GetID() + if(floor(.5 + select(2, MacroFrameTab1Text:GetTextColor()) * 10) / 10 == .8) then + keyBindID = keyBindID + 36 + end; + keyBindName = GetMacroInfo(keyBindID) + keyBindString = "MACRO " .. keyBindName; + Binder.button.id = keyBindID + Binder.button.name = keyBindName + Binder.button.bindstring = keyBindString; + Binder.button.bindings = {GetBindingKey(keyBindString)} + GameTooltip:SetOwner(Binder, "ANCHOR_TOP") + GameTooltip:SetPoint("BOTTOM", Binder, "TOP", 0, 1) + GameTooltip:AddLine(keyBindName, 1, 1, 1) + if #Binder.button.bindings == 0 then + GameTooltip:AddLine(L["No bindings set."], .6, .6, .6) + else + GameTooltip:AddDoubleLine(L["Binding"], L["Key"], .6, .6, .6, .6, .6, .6) + for i = 1, #Binder.button.bindings do + GameTooltip:AddDoubleLine(L["Binding"]..i, Binder.button.bindings[i], 1, 1, 1) + end + end; + GameTooltip:Show() + elseif bindType == "STANCE" or bindType == "PET" then + keyBindID = tonumber(bindTarget:GetID()) + keyBindName = bindTarget:GetName() + if(not keyBindName) then return end; + if ((not keyBindID) or (keyBindID < 1) or (keyBindID > (bindType == "STANCE" and 10 or 12))) then + keyBindString = "CLICK "..keyBindName..":LeftButton" + else + keyBindString = (bindType == "STANCE" and "StanceButton" or "BONUSACTIONBUTTON")..keyBindID + end; + Binder.button.id = keyBindID + Binder.button.name = keyBindName + Binder.button.bindstring = keyBindString + GameTooltip:AddLine(L["Trigger"]) + GameTooltip:Show() + GameTooltip:SetScript("OnHide", GameTooltip_OnHide) + else + keyBindID = tonumber(bindTarget.action) + keyBindName = bindTarget:GetName() + if(not keyBindName) then return end; + if(not bindTarget.keyBoundTarget and ((not keyBindID) or (keyBindID < 1) or (keyBindID > 132))) then + keyBindString = "CLICK "..keyBindName..":LeftButton" + elseif(bindTarget.keyBoundTarget) then + keyBindString = bindTarget.keyBoundTarget + else + local slotID = 1 + (keyBindID - 1) % 12; + if((keyBindID < 25) or (keyBindID > 72)) then + keyBindString = "ACTIONBUTTON"..slotID; + elseif((keyBindID < 73) and (keyBindID > 60)) then + keyBindString = "MULTIACTIONBAR1BUTTON"..slotID; + elseif(keyBindID < 61 and keyBindID > 48) then + keyBindString = "MULTIACTIONBAR2BUTTON"..slotID; + elseif(keyBindID < 49 and keyBindID > 36) then + keyBindString = "MULTIACTIONBAR4BUTTON"..slotID; + elseif(keyBindID < 37 and keyBindID > 24) then + keyBindString = "MULTIACTIONBAR3BUTTON"..slotID; + end + end; + Binder.button.action = keyBindID + Binder.button.name = keyBindName + Binder.button.bindstring = keyBindString + GameTooltip:AddLine(L["Trigger"]) + GameTooltip:Show() + GameTooltip:SetScript("OnHide", GameTooltip_OnHide) + end + end; +end +--[[ +########################################################## +PACKAGE PLUGIN +########################################################## +]]-- +function MOD:ToggleKeyBindingMode(deactivate, saveRequested) + if not deactivate then + Binder.active = true; + SuperVillain:StaticPopupSpecial_Show(SVUI_KeyBindPopup) + MOD:RegisterEvent('PLAYER_REGEN_DISABLED','ToggleKeyBindingMode',true,false) + else + if saveRequested then + SaveBindings(GetCurrentBindingSet()) + SuperVillain:AddonMessage(L["Binding Changes Stored"]) + else + LoadBindings(GetCurrentBindingSet()) + SuperVillain:AddonMessage(L["Binding Changes Discarded"]) + end; + Binder.active = false; + Binder:ClearAllPoints() + Binder:Hide() + GameTooltip:Hide() + MOD:UnregisterEvent("PLAYER_REGEN_DISABLED") + SuperVillain:StaticPopupSpecial_Hide(SVUI_KeyBindPopup) + MOD.bindingsChanged = false + end +end; + +blockedButtons = { LSHIFT = true, RSHIFT = true, LCTRL = true, RCTRL = true, LALT = true, RALT = true, UNKNOWN = true, LeftButton = true} + +--[[ HANDLERS ]]-- +local tipTimeLapse = 0; +local GameTooltip_OnUpdate = function(self, elapsed) + tipTimeLapse = (tipTimeLapse + elapsed); + if tipTimeLapse < .2 then + return + else + tipTimeLapse = 0 + end; + if(not self.comparing and IsModifiedClick("COMPAREITEMS")) then + GameTooltip_ShowCompareItem(self) + self.comparing = true + elseif(self.comparing and not IsModifiedClick("COMPAREITEMS")) then + for _,tip in pairs(self.shoppingTooltips)do + tip:Hide() + end; + self.comparing = false + end +end; + +local GameTooltip_OnHide = function(self) + for _, tip in pairs(self.shoppingTooltips)do + tip:Hide() + end +end; + +local GameTooltip_OnHide = function(self) + for _, tip in pairs(self.shoppingTooltips)do + tip:Hide() + end +end; + +local SpellButton_OnEnter = function(self) + RefreshBindings(self, "SPELL") +end + +local Button_Proxy = function(self) + RefreshBindings(self) +end +local Stance_Proxy = function(self) + RefreshBindings(self,"STANCE") +end +local Pet_Proxy = function(self) + RefreshBindings(self,"PET") +end +local Flyout_Proxy = function(self) + RefreshBindings(self,"FLYOUT") +end +local Macro_Proxy = function(self) + RefreshBindings(self, "MACRO") +end + +local BinderButton_OnEnter = function(self) + local parent = self.button:GetParent() + if parent and parent._fade then + SuperVillain:SecureFadeIn(parent, 0.2, parent:GetAlpha(), parent._alpha) + end +end; + +local BinderButton_OnLeave = function(self) + local parent = self.button:GetParent() + self:ClearAllPoints() + self:Hide() + GameTooltip:Hide() + if parent and parent._fade then + SuperVillain:SecureFadeOut(parent, 1, parent:GetAlpha(), 0) + end +end; + +local Binder_OnBinding = function(self, event) + MOD.bindingsChanged = true; + if(event == "ESCAPE" or event == "RightButton") then + local count = #Binder.button.bindings + for i=1, count do + SetBinding(Binder.button.bindings[i]) + end; + SuperVillain:AddonMessage(format(L["All keybindings cleared for |cff00ff00%s|r."], Binder.button.name)) + RefreshBindings(Binder.button, Binder.spellmacro) + if(Binder.spellmacro ~= "MACRO") then + GameTooltip:Hide() + end; + return + end; + + if(blockedButtons[event]) then return end; + if(event == "MiddleButton") then + event = "BUTTON3" + end; + if(event:find('Button%d')) then + event = event:upper() + end; + + local altText = IsAltKeyDown() and "ALT-" or ""; + local ctrlText = IsControlKeyDown() and "CTRL-" or ""; + local shiftText = IsShiftKeyDown() and "SHIFT-" or ""; + + if(not Binder.spellmacro or Binder.spellmacro == "PET" or Binder.spellmacro == "STANCE" or Binder.spellmacro == "FLYOUT") then + SetBinding(altText..ctrlText..shiftText..event, Binder.button.bindstring) + else + SetBinding(altText..ctrlText..shiftText..event, Binder.spellmacro.." "..Binder.button.name) + end; + + SuperVillain:AddonMessage(altText..ctrlText..shiftText..event..L[" |cff00ff00bound to |r"]..Binder.button.name..".") + RefreshBindings(Binder.button, Binder.spellmacro) + + if Binder.spellmacro~="MACRO" then + GameTooltip:Hide() + end +end; + +local BinderButton_OnMouseWheel = function(self, delta) + if delta > 0 then + Binder_OnBinding(self, "MOUSEWHEELUP") + else + Binder_OnBinding(self, "MOUSEWHEELDOWN") + end +end; + +local SetBindingMacro = function(self, arg) + if(arg == "Blizzard_MacroUI") then + for i=1,36 do + local btn = _G["MacroButton"..i] + btn:HookScript("OnEnter", MacroBinding_OnEnter) + end + end +end; + +local Check_OnShow = function(self) + self:SetChecked(GetCurrentBindingSet() == 2) +end; + +local Check_OnEnter = function(self) + GameTooltip:SetOwner(self, "ANCHOR_RIGHT") + GameTooltip:SetText(CHARACTER_SPECIFIC_KEYBINDING_TOOLTIP, nil, nil, nil, nil, 1) +end; + +local Check_OnClick = function(self) + if(MOD.bindingsChanged) then + SuperVillain:StaticPopup_Show("CONFIRM_LOSE_BINDING_CHANGES") + else + if SVUI_KeyBindPopupCheckButton:GetChecked() then + LoadBindings(2) + SaveBindings(2) + else + LoadBindings(1) + SaveBindings(1) + end + end +end; + +local Save_OnClick = function(self) + MOD:ToggleKeyBindingMode(true, true) +end; + +local Discard_OnClick = function(self) + MOD:ToggleKeyBindingMode(true, false) +end; +--[[ END OF HANDLERS ]]-- + +local function SetBindingButton(button, force) + local click1 = StanceButton1:GetScript("OnClick") + local click2 = PetActionButton1:GetScript("OnClick") + local click3 = SecureActionButton_OnClick; + local button_OnClick = button:GetScript("OnClick") + if button_OnClick == click3 or force then + button:HookScript("OnEnter", Button_Proxy) + elseif button_OnClick == click1 then + button:HookScript("OnEnter", Stance_Proxy) + elseif button_OnClick == click2 then + button:HookScript("OnEnter", Pet_Proxy) + end +end; + +local function RefreshAllFlyouts() + local count = GetNumFlyouts() + for i = 1, count do + local id = GetFlyoutID(i) + local _,_,numSlots,isKnown = GetFlyoutInfo(id) + if isKnown then + for x = 1, numSlots do + local btn = _G["SpellFlyoutButton"..x] + if(SpellFlyout:IsShown() and btn and btn:IsShown()) then + if(not btn.hookedFlyout) then + btn:HookScript("OnEnter", Flyout_Proxy) + btn.hookedFlyout = true + end + end + end + end + end +end; + +function MOD:LoadKeyBinder() + self:RefreshActionBars() + Binder:SetParent(SuperVillain.UIParent) + Binder:SetFrameStrata("DIALOG") + Binder:SetFrameLevel(99) + Binder:EnableMouse(true) + Binder:EnableKeyboard(true) + Binder:EnableMouseWheel(true) + Binder.texture = Binder:CreateTexture() + Binder.texture:SetAllPoints(a) + Binder.texture:SetTexture(0, 0, 0, .25) + Binder:Hide() + + GameTooltip:HookScript("OnUpdate", GameTooltip_OnUpdate) + NewHook(GameTooltip, "Hide", GameTooltip_OnHide) + + Binder:SetScript("OnEnter", BinderButton_OnEnter) + Binder:SetScript("OnLeave", BinderButton_OnLeave) + Binder:SetScript("OnKeyUp", Binder_OnBinding) + Binder:SetScript("OnMouseUp", Binder_OnBinding) + Binder:SetScript("OnMouseWheel", BinderButton_OnMouseWheel) + + local OBJECT = EnumerateFrames() + while OBJECT do + if(OBJECT.IsProtected and OBJECT:IsProtected() and OBJECT.GetObjectType and OBJECT:GetObjectType() == "CheckButton" and OBJECT.GetScript) then + SetBindingButton(OBJECT) + end + OBJECT = EnumerateFrames(OBJECT) + end; + + for OBJECT, _ in pairs(self.Storage.Cache)do + if(OBJECT.IsProtected and OBJECT:IsProtected() and OBJECT.GetObjectType and OBJECT:GetObjectType() == "CheckButton" and OBJECT.GetScript) then + SetBindingButton(OBJECT, true) + end + end; + + for l = 1, 12 do + local spellButton = _G["SpellButton"..l] + spellButton:HookScript("OnEnter", SpellButton_OnEnter) + end; + + if not IsAddOnLoaded("Blizzard_MacroUI")then + NewHook("LoadAddOn", SetBindingMacro) + else + for i=1,36 do + local btn = _G["MacroButton"..i] + btn:HookScript("OnEnter", Macro_Proxy) + end + end; + + NewHook("ActionButton_UpdateFlyout", RefreshAllFlyouts) + RefreshAllFlyouts() + + local pop = NewFrame("Frame", "SVUI_KeyBindPopup", UIParent) + pop:SetFrameStrata("DIALOG") + pop:SetToplevel(true) + pop:EnableMouse(true) + pop:SetMovable(true) + pop:SetFrameLevel(99) + pop:SetClampedToScreen(true) + pop:SetWidth(360) + pop:SetHeight(130) + pop:SetFixedPanelTemplate("Transparent") + pop:Hide() + + local moveHandle = NewFrame("Button", nil, pop) + moveHandle:SetFixedPanelTemplate("Button", true) + moveHandle:SetWidth(100) + moveHandle:SetHeight(25) + moveHandle:SetPoint("CENTER", pop, "TOP") + moveHandle:SetFrameLevel(moveHandle:GetFrameLevel() + 2) + moveHandle:EnableMouse(true) + moveHandle:RegisterForClicks("AnyUp", "AnyDown") + local onMouseDown = function() pop:StartMoving() end + moveHandle:SetScript("OnMouseDown", onMouseDown) + local onMouseUp = function() pop:StopMovingOrSizing() end + moveHandle:SetScript("OnMouseUp", onMouseUp) + + local moveText = moveHandle:CreateFontString("OVERLAY") + moveText:SetFontTemplate() + moveText:SetPoint("CENTER", moveHandle, "CENTER") + moveText:SetText("Key Binds") + + local moveDesc = pop:CreateFontString("ARTWORK") + moveDesc:SetFontObject("GameFontHighlight") + moveDesc:SetJustifyV("TOP") + moveDesc:SetJustifyH("LEFT") + moveDesc:SetPoint("TOPLEFT", 18, -32) + moveDesc:SetPoint("BOTTOMRIGHT", -18, 48) + moveDesc:SetText(L["Hover your mouse over any actionbutton or spellbook button to bind it. Press the escape key or right click to clear the current actionbutton's keybinding."]) + + local checkButton = NewFrame("CheckButton", "SVUI_KeyBindPopupCheckButton", pop, "OptionsCheckButtonTemplate") + checkButton:SetCheckboxTemplate(true) + _G["SVUI_KeyBindPopupCheckButtonText"]:SetText(CHARACTER_SPECIFIC_KEYBINDINGS) + checkButton:SetScript("OnShow", Check_OnShow) + checkButton:SetScript("OnClick", Check_OnClick) + checkButton:SetScript("OnEnter", Check_OnEnter) + checkButton:SetScript("OnLeave", GameTooltip_Hide) + + local saveButton = NewFrame("Button", "SVUI_KeyBindPopupSaveButton", pop, "OptionsButtonTemplate") + saveButton:Width(150) + saveButton:SetButtonTemplate() + _G["SVUI_KeyBindPopupSaveButtonText"]:SetText(L["Save"]) + saveButton:SetScript("OnClick", Save_OnClick) + + local discardButton = NewFrame("Button", "SVUI_KeyBindPopupDiscardButton", pop, "OptionsButtonTemplate") + discardButton:Width(150) + discardButton:SetButtonTemplate() + _G["SVUI_KeyBindPopupDiscardButtonText"]:SetText(L["Discard"]) + discardButton:SetScript("OnClick", Discard_OnClick) + + checkButton:SetPoint("BOTTOMLEFT", discardButton, "TOPLEFT", 0, 2) + saveButton:SetPoint("BOTTOMRIGHT", -14, 10) + discardButton:SetPoint("BOTTOMLEFT", 14, 10) +end \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/actionbar/SVBar.xml b/Interface/AddOns/SVUI/packages/actionbar/SVBar.xml deleted file mode 100644 index d9ab5f5..0000000 --- a/Interface/AddOns/SVUI/packages/actionbar/SVBar.xml +++ /dev/null @@ -1,4 +0,0 @@ -<Ui xmlns="http://www.blizzard.com/wow/ui/"> - <Script file='SVBar.lua'/> - <Script file='SVBar_KeyBind.lua'/> -</Ui> \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/actionbar/SVBar_KeyBind.lua b/Interface/AddOns/SVUI/packages/actionbar/SVBar_KeyBind.lua deleted file mode 100644 index c44bf2e..0000000 --- a/Interface/AddOns/SVUI/packages/actionbar/SVBar_KeyBind.lua +++ /dev/null @@ -1,513 +0,0 @@ ---[[ -############################################################################## -_____/\\\\\\\\\\\____/\\\________/\\\__/\\\________/\\\__/\\\\\\\\\\\_ # - ___/\\\/////////\\\_\/\\\_______\/\\\_\/\\\_______\/\\\_\/////\\\///__ # - __\//\\\______\///__\//\\\______/\\\__\/\\\_______\/\\\_____\/\\\_____ # - ___\////\\\__________\//\\\____/\\\___\/\\\_______\/\\\_____\/\\\_____ # - ______\////\\\________\//\\\__/\\\____\/\\\_______\/\\\_____\/\\\_____ # - _________\////\\\______\//\\\/\\\_____\/\\\_______\/\\\_____\/\\\_____ # - __/\\\______\//\\\______\//\\\\\______\//\\\______/\\\______\/\\\_____ # - _\///\\\\\\\\\\\/________\//\\\________\///\\\\\\\\\/____/\\\\\\\\\\\_# - ___\///////////___________\///___________\/////////_____\///////////_# -############################################################################## -S U P E R - V I L L A I N - U I By: Munglunch # -############################################################################## -########################################################## -LOCALIZED LUA FUNCTIONS -########################################################## -]]-- ---[[ GLOBALS ]]-- -local _G = _G; -local select = _G.select; -local pairs = _G.pairs; -local ipairs = _G.ipairs; -local type = _G.type; -local string = _G.string; -local math = _G.math; -local table = _G.table; -local GetTime = _G.GetTime; ---[[ STRING METHODS ]]-- -local format, find = string.format, string.find; ---[[ MATH METHODS ]]-- -local floor = math.floor; -local tonumber = tonumber; ---[[ -########################################################## -GET ADDON DATA -########################################################## -]]-- -local SuperVillain, L = unpack(select(2, ...)); -local MOD = SuperVillain.Registry:Expose('SVBar'); -local LibAB = LibStub("LibActionButton-1.0") - -local _G = getfenv(0); - -local RefreshBindings -local NewFrame = CreateFrame; -local NewHook = hooksecurefunc; - -local Binder = NewFrame("Frame", nil, UIParent); ---[[ -########################################################## -BINDING UPDATES -########################################################## -]]-- -do - --[[ HANDLERS ]]-- - local GameTooltip_OnHide = function(self) - self:SetOwner(Binder, "ANCHOR_TOP") - self:SetPoint("BOTTOM", Binder, "TOP", 0, 1) - self:AddLine(Binder.button.name, 1, 1, 1) - Binder.button.bindings = {GetBindingKey(Binder.button.bindstring)} - local count = #Binder.button.bindings - if(count == 0) then - self:AddLine(L["No bindings set."], .6, .6, .6) - else - self:AddDoubleLine(L["Binding"], L["Key"], .6, .6, .6, .6, .6, .6) - for i = 1, count do - self:AddDoubleLine(i, Binder.button.bindings[i]) - end - end; - self:Show() - self:SetScript("OnHide", nil) - end - --[[ END OF HANDLERS ]]-- - - function RefreshBindings(bindTarget, bindType) - if(not Binder.active or InCombatLockdown()) then return end; - Binder.button = bindTarget; - Binder.spellmacro = bindType; - Binder:ClearAllPoints() - Binder:SetAllPoints(bindTarget) - Binder:Show() - ShoppingTooltip1:Hide() - if(bindTarget.FlyoutArrow and bindTarget.FlyoutArrow:IsShown()) then - Binder:EnableMouse(false) - elseif(not Binder:IsMouseEnabled()) then - Binder:EnableMouse(true) - end; - local keyBindID, keyBindName, keyBindString; - if bindType == "FLYOUT" then - keyBindName = GetSpellInfo(bindTarget.spellID); - keyBindString = "SPELL " .. keyBindName; - Binder.button.name = keyBindName - Binder.button.bindstring = keyBindString; - GameTooltip:AddLine(L["Trigger"]) - GameTooltip:Show() - GameTooltip:SetScript("OnHide", GameTooltip_OnHide) - elseif bindType == "SPELL" then - keyBindID = SpellBook_GetSpellBookSlot(bindTarget) - keyBindName = GetSpellBookItemName(keyBindID, SpellBookFrame.bookType); - keyBindString = "SPELL " .. keyBindName; - Binder.button.id = keyBindID - Binder.button.name = keyBindName - Binder.button.bindstring = keyBindString; - GameTooltip:AddLine(L["Trigger"]) - GameTooltip:Show() - GameTooltip:SetScript("OnHide", GameTooltip_OnHide) - elseif bindType == "MACRO" then - keyBindID = bindTarget:GetID() - if(floor(.5 + select(2, MacroFrameTab1Text:GetTextColor()) * 10) / 10 == .8) then - keyBindID = keyBindID + 36 - end; - keyBindName = GetMacroInfo(keyBindID) - keyBindString = "MACRO " .. keyBindName; - Binder.button.id = keyBindID - Binder.button.name = keyBindName - Binder.button.bindstring = keyBindString; - Binder.button.bindings = {GetBindingKey(keyBindString)} - GameTooltip:SetOwner(Binder, "ANCHOR_TOP") - GameTooltip:SetPoint("BOTTOM", Binder, "TOP", 0, 1) - GameTooltip:AddLine(keyBindName, 1, 1, 1) - if #Binder.button.bindings == 0 then - GameTooltip:AddLine(L["No bindings set."], .6, .6, .6) - else - GameTooltip:AddDoubleLine(L["Binding"], L["Key"], .6, .6, .6, .6, .6, .6) - for i = 1, #Binder.button.bindings do - GameTooltip:AddDoubleLine(L["Binding"]..i, Binder.button.bindings[i], 1, 1, 1) - end - end; - GameTooltip:Show() - elseif bindType == "STANCE" or bindType == "PET" then - keyBindID = tonumber(bindTarget:GetID()) - keyBindName = bindTarget:GetName() - if(not keyBindName) then return end; - if ((not keyBindID) or (keyBindID < 1) or (keyBindID > (bindType == "STANCE" and 10 or 12))) then - keyBindString = "CLICK "..keyBindName..":LeftButton" - else - keyBindString = (bindType == "STANCE" and "StanceButton" or "BONUSACTIONBUTTON")..keyBindID - end; - Binder.button.id = keyBindID - Binder.button.name = keyBindName - Binder.button.bindstring = keyBindString - GameTooltip:AddLine(L["Trigger"]) - GameTooltip:Show() - GameTooltip:SetScript("OnHide", GameTooltip_OnHide) - else - keyBindID = tonumber(bindTarget.action) - keyBindName = bindTarget:GetName() - if(not keyBindName) then return end; - if(not bindTarget.keyBoundTarget and ((not keyBindID) or (keyBindID < 1) or (keyBindID > 132))) then - keyBindString = "CLICK "..keyBindName..":LeftButton" - elseif(bindTarget.keyBoundTarget) then - keyBindString = bindTarget.keyBoundTarget - else - local slotID = 1 + (keyBindID - 1) % 12; - if((keyBindID < 25) or (keyBindID > 72)) then - keyBindString = "ACTIONBUTTON"..slotID; - elseif((keyBindID < 73) and (keyBindID > 60)) then - keyBindString = "MULTIACTIONBAR1BUTTON"..slotID; - elseif(keyBindID < 61 and keyBindID > 48) then - keyBindString = "MULTIACTIONBAR2BUTTON"..slotID; - elseif(keyBindID < 49 and keyBindID > 36) then - keyBindString = "MULTIACTIONBAR4BUTTON"..slotID; - elseif(keyBindID < 37 and keyBindID > 24) then - keyBindString = "MULTIACTIONBAR3BUTTON"..slotID; - end - end; - Binder.button.action = keyBindID - Binder.button.name = keyBindName - Binder.button.bindstring = keyBindString - GameTooltip:AddLine(L["Trigger"]) - GameTooltip:Show() - GameTooltip:SetScript("OnHide", GameTooltip_OnHide) - end - end; -end ---[[ -########################################################## -PACKAGE PLUGIN -########################################################## -]]-- -function MOD:ToggleKeyBindingMode(deactivate, saveRequested) - if not deactivate then - Binder.active = true; - SuperVillain:StaticPopupSpecial_Show(SVUI_KeyBindPopup) - MOD:RegisterEvent('PLAYER_REGEN_DISABLED','ToggleKeyBindingMode',true,false) - else - if saveRequested then - SaveBindings(GetCurrentBindingSet()) - SuperVillain:AddonMessage(L["Binding Changes Stored"]) - else - LoadBindings(GetCurrentBindingSet()) - SuperVillain:AddonMessage(L["Binding Changes Discarded"]) - end; - Binder.active = false; - Binder:ClearAllPoints() - Binder:Hide() - GameTooltip:Hide() - MOD:UnregisterEvent("PLAYER_REGEN_DISABLED") - SuperVillain:StaticPopupSpecial_Hide(SVUI_KeyBindPopup) - MOD.bindingsChanged = false - end -end; - -blockedButtons = { LSHIFT = true, RSHIFT = true, LCTRL = true, RCTRL = true, LALT = true, RALT = true, UNKNOWN = true, LeftButton = true} - ---[[ HANDLERS ]]-- -local tipTimeLapse = 0; -local GameTooltip_OnUpdate = function(self, elapsed) - tipTimeLapse = (tipTimeLapse + elapsed); - if tipTimeLapse < .2 then - return - else - tipTimeLapse = 0 - end; - if(not self.comparing and IsModifiedClick("COMPAREITEMS")) then - GameTooltip_ShowCompareItem(self) - self.comparing = true - elseif(self.comparing and not IsModifiedClick("COMPAREITEMS")) then - for _,tip in pairs(self.shoppingTooltips)do - tip:Hide() - end; - self.comparing = false - end -end; - -local GameTooltip_OnHide = function(self) - for _, tip in pairs(self.shoppingTooltips)do - tip:Hide() - end -end; - -local GameTooltip_OnHide = function(self) - for _, tip in pairs(self.shoppingTooltips)do - tip:Hide() - end -end; - -local SpellButton_OnEnter = function(self) - RefreshBindings(self, "SPELL") -end - -local Button_Proxy = function(self) - RefreshBindings(self) -end -local Stance_Proxy = function(self) - RefreshBindings(self,"STANCE") -end -local Pet_Proxy = function(self) - RefreshBindings(self,"PET") -end -local Flyout_Proxy = function(self) - RefreshBindings(self,"FLYOUT") -end -local Macro_Proxy = function(self) - RefreshBindings(self, "MACRO") -end - -local BinderButton_OnEnter = function(self) - local parent = self.button:GetParent() - if parent and parent._fade then - SuperVillain:SecureFadeIn(parent, 0.2, parent:GetAlpha(), parent._alpha) - end -end; - -local BinderButton_OnLeave = function(self) - local parent = self.button:GetParent() - self:ClearAllPoints() - self:Hide() - GameTooltip:Hide() - if parent and parent._fade then - SuperVillain:SecureFadeOut(parent, 1, parent:GetAlpha(), 0) - end -end; - -local Binder_OnBinding = function(self, event) - MOD.bindingsChanged = true; - if(event == "ESCAPE" or event == "RightButton") then - local count = #Binder.button.bindings - for i=1, count do - SetBinding(Binder.button.bindings[i]) - end; - SuperVillain:AddonMessage(format(L["All keybindings cleared for |cff00ff00%s|r."], Binder.button.name)) - RefreshBindings(Binder.button, Binder.spellmacro) - if(Binder.spellmacro ~= "MACRO") then - GameTooltip:Hide() - end; - return - end; - - if(blockedButtons[event]) then return end; - if(event == "MiddleButton") then - event = "BUTTON3" - end; - if(event:find('Button%d')) then - event = event:upper() - end; - - local altText = IsAltKeyDown() and "ALT-" or ""; - local ctrlText = IsControlKeyDown() and "CTRL-" or ""; - local shiftText = IsShiftKeyDown() and "SHIFT-" or ""; - - if(not Binder.spellmacro or Binder.spellmacro == "PET" or Binder.spellmacro == "STANCE" or Binder.spellmacro == "FLYOUT") then - SetBinding(altText..ctrlText..shiftText..event, Binder.button.bindstring) - else - SetBinding(altText..ctrlText..shiftText..event, Binder.spellmacro.." "..Binder.button.name) - end; - - SuperVillain:AddonMessage(altText..ctrlText..shiftText..event..L[" |cff00ff00bound to |r"]..Binder.button.name..".") - RefreshBindings(Binder.button, Binder.spellmacro) - - if Binder.spellmacro~="MACRO" then - GameTooltip:Hide() - end -end; - -local BinderButton_OnMouseWheel = function(self, delta) - if delta > 0 then - Binder_OnBinding(self, "MOUSEWHEELUP") - else - Binder_OnBinding(self, "MOUSEWHEELDOWN") - end -end; - -local SetBindingMacro = function(self, arg) - if(arg == "Blizzard_MacroUI") then - for i=1,36 do - local btn = _G["MacroButton"..i] - btn:HookScript("OnEnter", MacroBinding_OnEnter) - end - end -end; - -local Check_OnShow = function(self) - self:SetChecked(GetCurrentBindingSet() == 2) -end; - -local Check_OnEnter = function(self) - GameTooltip:SetOwner(self, "ANCHOR_RIGHT") - GameTooltip:SetText(CHARACTER_SPECIFIC_KEYBINDING_TOOLTIP, nil, nil, nil, nil, 1) -end; - -local Check_OnClick = function(self) - if(MOD.bindingsChanged) then - SuperVillain:StaticPopup_Show("CONFIRM_LOSE_BINDING_CHANGES") - else - if SVUI_KeyBindPopupCheckButton:GetChecked() then - LoadBindings(2) - SaveBindings(2) - else - LoadBindings(1) - SaveBindings(1) - end - end -end; - -local Save_OnClick = function(self) - MOD:ToggleKeyBindingMode(true, true) -end; - -local Discard_OnClick = function(self) - MOD:ToggleKeyBindingMode(true, false) -end; ---[[ END OF HANDLERS ]]-- - -local function SetBindingButton(button, force) - local click1 = StanceButton1:GetScript("OnClick") - local click2 = PetActionButton1:GetScript("OnClick") - local click3 = SecureActionButton_OnClick; - local button_OnClick = button:GetScript("OnClick") - if button_OnClick == click3 or force then - button:HookScript("OnEnter", Button_Proxy) - elseif button_OnClick == click1 then - button:HookScript("OnEnter", Stance_Proxy) - elseif button_OnClick == click2 then - button:HookScript("OnEnter", Pet_Proxy) - end -end; - -local function RefreshAllFlyouts() - local count = GetNumFlyouts() - for i = 1, count do - local id = GetFlyoutID(i) - local _,_,numSlots,isKnown = GetFlyoutInfo(id) - if isKnown then - for x = 1, numSlots do - local btn = _G["SpellFlyoutButton"..x] - if(SpellFlyout:IsShown() and btn and btn:IsShown()) then - if(not btn.hookedFlyout) then - btn:HookScript("OnEnter", Flyout_Proxy) - btn.hookedFlyout = true - end - end - end - end - end -end; - -function MOD:LoadKeyBinder() - self:RefreshActionBars() - Binder:SetParent(SuperVillain.UIParent) - Binder:SetFrameStrata("DIALOG") - Binder:SetFrameLevel(99) - Binder:EnableMouse(true) - Binder:EnableKeyboard(true) - Binder:EnableMouseWheel(true) - Binder.texture = Binder:CreateTexture() - Binder.texture:SetAllPoints(a) - Binder.texture:SetTexture(0, 0, 0, .25) - Binder:Hide() - - GameTooltip:HookScript("OnUpdate", GameTooltip_OnUpdate) - NewHook(GameTooltip, "Hide", GameTooltip_OnHide) - - Binder:SetScript("OnEnter", BinderButton_OnEnter) - Binder:SetScript("OnLeave", BinderButton_OnLeave) - Binder:SetScript("OnKeyUp", Binder_OnBinding) - Binder:SetScript("OnMouseUp", Binder_OnBinding) - Binder:SetScript("OnMouseWheel", BinderButton_OnMouseWheel) - - local OBJECT = EnumerateFrames() - while OBJECT do - if(OBJECT.IsProtected and OBJECT:IsProtected() and OBJECT.GetObjectType and OBJECT:GetObjectType() == "CheckButton" and OBJECT.GetScript) then - SetBindingButton(OBJECT) - end - OBJECT = EnumerateFrames(OBJECT) - end; - - for OBJECT, _ in pairs(self.Storage.Cache)do - if(OBJECT.IsProtected and OBJECT:IsProtected() and OBJECT.GetObjectType and OBJECT:GetObjectType() == "CheckButton" and OBJECT.GetScript) then - SetBindingButton(OBJECT, true) - end - end; - - for l = 1, 12 do - local spellButton = _G["SpellButton"..l] - spellButton:HookScript("OnEnter", SpellButton_OnEnter) - end; - - if not IsAddOnLoaded("Blizzard_MacroUI")then - NewHook("LoadAddOn", SetBindingMacro) - else - for i=1,36 do - local btn = _G["MacroButton"..i] - btn:HookScript("OnEnter", Macro_Proxy) - end - end; - - NewHook("ActionButton_UpdateFlyout", RefreshAllFlyouts) - RefreshAllFlyouts() - - local pop = NewFrame("Frame", "SVUI_KeyBindPopup", UIParent) - pop:SetFrameStrata("DIALOG") - pop:SetToplevel(true) - pop:EnableMouse(true) - pop:SetMovable(true) - pop:SetFrameLevel(99) - pop:SetClampedToScreen(true) - pop:SetWidth(360) - pop:SetHeight(130) - pop:SetFixedPanelTemplate("Transparent") - pop:Hide() - - local moveHandle = NewFrame("Button", nil, pop) - moveHandle:SetFixedPanelTemplate("Button", true) - moveHandle:SetWidth(100) - moveHandle:SetHeight(25) - moveHandle:SetPoint("CENTER", pop, "TOP") - moveHandle:SetFrameLevel(moveHandle:GetFrameLevel() + 2) - moveHandle:EnableMouse(true) - moveHandle:RegisterForClicks("AnyUp", "AnyDown") - local onMouseDown = function() pop:StartMoving() end - moveHandle:SetScript("OnMouseDown", onMouseDown) - local onMouseUp = function() pop:StopMovingOrSizing() end - moveHandle:SetScript("OnMouseUp", onMouseUp) - - local moveText = moveHandle:CreateFontString("OVERLAY") - moveText:SetFontTemplate() - moveText:SetPoint("CENTER", moveHandle, "CENTER") - moveText:SetText("Key Binds") - - local moveDesc = pop:CreateFontString("ARTWORK") - moveDesc:SetFontObject("GameFontHighlight") - moveDesc:SetJustifyV("TOP") - moveDesc:SetJustifyH("LEFT") - moveDesc:SetPoint("TOPLEFT", 18, -32) - moveDesc:SetPoint("BOTTOMRIGHT", -18, 48) - moveDesc:SetText(L["Hover your mouse over any actionbutton or spellbook button to bind it. Press the escape key or right click to clear the current actionbutton's keybinding."]) - - local checkButton = NewFrame("CheckButton", "SVUI_KeyBindPopupCheckButton", pop, "OptionsCheckButtonTemplate") - checkButton:SetCheckboxTemplate(true) - _G["SVUI_KeyBindPopupCheckButtonText"]:SetText(CHARACTER_SPECIFIC_KEYBINDINGS) - checkButton:SetScript("OnShow", Check_OnShow) - checkButton:SetScript("OnClick", Check_OnClick) - checkButton:SetScript("OnEnter", Check_OnEnter) - checkButton:SetScript("OnLeave", GameTooltip_Hide) - - local saveButton = NewFrame("Button", "SVUI_KeyBindPopupSaveButton", pop, "OptionsButtonTemplate") - saveButton:Width(150) - saveButton:SetButtonTemplate() - _G["SVUI_KeyBindPopupSaveButtonText"]:SetText(L["Save"]) - saveButton:SetScript("OnClick", Save_OnClick) - - local discardButton = NewFrame("Button", "SVUI_KeyBindPopupDiscardButton", pop, "OptionsButtonTemplate") - discardButton:Width(150) - discardButton:SetButtonTemplate() - _G["SVUI_KeyBindPopupDiscardButtonText"]:SetText(L["Discard"]) - discardButton:SetScript("OnClick", Discard_OnClick) - - checkButton:SetPoint("BOTTOMLEFT", discardButton, "TOPLEFT", 0, 2) - saveButton:SetPoint("BOTTOMRIGHT", -14, 10) - discardButton:SetPoint("BOTTOMLEFT", 14, 10) -end \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/bag/common/sorting.lua b/Interface/AddOns/SVUI/packages/bag/common/sorting.lua index 33af4ca..012cf90 100644 --- a/Interface/AddOns/SVUI/packages/bag/common/sorting.lua +++ b/Interface/AddOns/SVUI/packages/bag/common/sorting.lua @@ -830,5 +830,6 @@ function MOD:RunSortingProcess(func, groupsDefaults) end twipe(bagGroups) SortUpdateTimer:StartStacking() + collectgarbage("collect") end end \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/chat/SVChat.xml b/Interface/AddOns/SVUI/packages/chat/SVChat.xml deleted file mode 100644 index 4e412b7..0000000 --- a/Interface/AddOns/SVUI/packages/chat/SVChat.xml +++ /dev/null @@ -1,3 +0,0 @@ -<Ui xmlns="http://www.blizzard.com/wow/ui/"> - <Script file='SVChat.lua'/> -</Ui> \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/dock/SVDock.xml b/Interface/AddOns/SVUI/packages/dock/SVDock.xml deleted file mode 100644 index bba6efc..0000000 --- a/Interface/AddOns/SVUI/packages/dock/SVDock.xml +++ /dev/null @@ -1,3 +0,0 @@ -<Ui xmlns="http://www.blizzard.com/wow/ui/"> - <Script file='SVDock.lua'/> -</Ui> \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/gear/SVGear.xml b/Interface/AddOns/SVUI/packages/gear/SVGear.xml deleted file mode 100644 index 448f04f..0000000 --- a/Interface/AddOns/SVUI/packages/gear/SVGear.xml +++ /dev/null @@ -1,3 +0,0 @@ -<Ui xmlns="http://www.blizzard.com/wow/ui/"> - <Script file='SVGear.lua'/> -</Ui> \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/henchmen/SVHenchmen.lua b/Interface/AddOns/SVUI/packages/henchmen/SVHenchmen.lua index 8a91f8d..2f9e1ca 100644 --- a/Interface/AddOns/SVUI/packages/henchmen/SVHenchmen.lua +++ b/Interface/AddOns/SVUI/packages/henchmen/SVHenchmen.lua @@ -767,9 +767,9 @@ REP AUTOMATONS ]]-- function MOD:CHAT_MSG_COMBAT_FACTION_CHANGE(event, msg) if not self.db.autorepchange then return end - local _, _, faction, amount = find(msg, incpat) + local _, _, faction, amount = msg:find(incpat) if not faction then - _, _, faction, amount = find(msg, changedpat) or find(msg, decpat) + _, _, faction, amount = msg:find(changedpat) or msg:find(decpat) end if faction and faction ~= GUILD_REPUTATION then local active = GetWatchedFactionInfo() diff --git a/Interface/AddOns/SVUI/packages/henchmen/SVHenchmen.xml b/Interface/AddOns/SVUI/packages/henchmen/SVHenchmen.xml deleted file mode 100644 index 9ae82f1..0000000 --- a/Interface/AddOns/SVUI/packages/henchmen/SVHenchmen.xml +++ /dev/null @@ -1,3 +0,0 @@ -<Ui xmlns="http://www.blizzard.com/wow/ui/"> - <Script file='SVHenchmen.lua'/> -</Ui> \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/map/SVMap.lua b/Interface/AddOns/SVUI/packages/map/SVMap.lua index 7292b5f..e9d8f95 100644 --- a/Interface/AddOns/SVUI/packages/map/SVMap.lua +++ b/Interface/AddOns/SVUI/packages/map/SVMap.lua @@ -260,7 +260,7 @@ do function MOD:UpdateMinimapButtonSettings() if(not self.db.minimapbar.enable) then return end - SuperVillain:ExecuteTimer(StyleMinimapButtons, 5) + SuperVillain:ExecuteTimer(StyleMinimapButtons, 4) end end @@ -349,31 +349,54 @@ local function CheckMovement() end end -local function UpdateWorldMapCoords() - if(not WorldMapFrame:IsShown() or not SVUI_WorldMapCoords) then return end - local a, b = IsInInstance() +local function UpdateMapCoords() + local xF, yF = "|cffffffffx: |r%.1f", "|cffffffffy: |r%.1f" + local skip = IsInInstance() local c, d = GetPlayerMapPosition("player") - c = parsefloat(100 * c, 2) - d = parsefloat(100 * d, 2) - if c ~= 0 and d ~= 0 then - SVUI_WorldMapCoords.playerCoords:SetText(PLAYER..": "..c..", "..d) - else - SVUI_WorldMapCoords.playerCoords:SetText("") - end - local e = WorldMapDetailFrame:GetEffectiveScale() - local f = WorldMapDetailFrame:GetWidth() - local g = WorldMapDetailFrame:GetHeight() - local h, i = WorldMapDetailFrame:GetCenter() - local c, d = GetCursorPosition() - local j = (c / e - (h - (f / 2))) / f; - local k = (i + (g / 2)-d / e) / g; - if j >= 0 and k >= 0 and j <= 1 and k <= 1 then - j = parsefloat(100 * j, 2) - k = parsefloat(100 * k, 2) - SVUI_WorldMapCoords.mouseCoords:SetText(MOUSE_LABEL..": "..j..", "..k) - else - SVUI_WorldMapCoords.mouseCoords:SetText("") - end + if(not skip and not IsIndoors() and c ~= 0 and d ~= 0) then + c = parsefloat(100 * c, 2) + d = parsefloat(100 * d, 2) + if(MOD.db.playercoords == "SIMPLE") then + xF, yF = "%.1f", "%.1f"; + end + if c ~= 0 and d ~= 0 then + SVUI_MiniMapCoords.playerXCoords:SetFormattedText(xF, c) + SVUI_MiniMapCoords.playerYCoords:SetFormattedText(yF, d) + if(SVUI_WorldMapCoords and WorldMapFrame:IsShown()) then + SVUI_WorldMapCoords.playerCoords:SetText(PLAYER..": "..c..", "..d) + end + else + SVUI_MiniMapCoords.playerXCoords:SetText("") + SVUI_MiniMapCoords.playerYCoords:SetText("") + if(SVUI_WorldMapCoords and WorldMapFrame:IsShown()) then + SVUI_WorldMapCoords.playerCoords:SetText("") + end + end + if(not WorldMapFrame:IsShown() or not SVUI_WorldMapCoords) then return end + local e = WorldMapDetailFrame:GetEffectiveScale() + local f = WorldMapDetailFrame:GetWidth() + local g = WorldMapDetailFrame:GetHeight() + local h, i = WorldMapDetailFrame:GetCenter() + local c, d = GetCursorPosition() + local j = (c / e - (h - (f / 2))) / f; + local k = (i + (g / 2)-d / e) / g; + if j >= 0 and k >= 0 and j <= 1 and k <= 1 then + j = parsefloat(100 * j, 2) + k = parsefloat(100 * k, 2) + SVUI_WorldMapCoords.mouseCoords:SetText(MOUSE_LABEL..": "..j..", "..k) + else + SVUI_WorldMapCoords.mouseCoords:SetText("") + end + else + SVUI_MiniMapCoords.playerXCoords:SetText("") + SVUI_MiniMapCoords.playerYCoords:SetText("") + if(SVUI_WorldMapCoords and WorldMapFrame:IsShown()) then + SVUI_WorldMapCoords.playerCoords:SetText("") + end + end + if(MOD.db.mapAlpha < 100) then + CheckMovement() + end end local function UpdateWorldMapConfig() @@ -385,14 +408,20 @@ local function UpdateWorldMapConfig() NewHook("WorldMapFrame_SetQuestMapView", SetQuestWorldMap) MOD.WorldMapHooked = true end - if(MOD.db.mapAlpha == 100) then - if MOD.MovingTimer then - SuperVillain:RemoveLoop(MOD.MovingTimer) - MOD.MovingTimer = nil + + if(not MOD.db.playercoords or MOD.db.playercoords == "HIDE") then + if MOD.CoordTimer then + SuperVillain:RemoveLoop(MOD.CoordTimer) + MOD.CoordTimer = nil; end - elseif(not MOD.MovingTimer) then - MOD.MovingTimer = SuperVillain:ExecuteLoop(CheckMovement, 0.2) - end + SVUI_MiniMapCoords.playerXCoords:SetText("") + SVUI_MiniMapCoords.playerYCoords:SetText("") + SVUI_MiniMapCoords:Hide() + else + SVUI_MiniMapCoords:Show() + MOD.CoordTimer = SuperVillain:ExecuteLoop(UpdateMapCoords, 0.8) + UpdateMapCoords() + end AdjustMapSize() end @@ -417,24 +446,6 @@ CORE FUNCTIONS MOD.narrative = ""; MOD.locationPrefix = ""; do - local function _updateCoords() - local a, b = IsInInstance() - local c, d = GetPlayerMapPosition("player") - local xF, yF = "|cffffffffx: |r%.1f", "|cffffffffy: |r%.1f" - if(MOD.db.playercoords == "SIMPLE") then - xF, yF = "%.1f", "%.1f"; - end; - c = parsefloat(100 * c, 2) - d = parsefloat(100 * d, 2) - if c ~= 0 and d ~= 0 then - SVUI_MiniMapCoords.playerXCoords:SetFormattedText(xF, c) - SVUI_MiniMapCoords.playerYCoords:SetFormattedText(yF, d) - else - SVUI_MiniMapCoords.playerXCoords:SetText("") - SVUI_MiniMapCoords.playerYCoords:SetText("") - end; - end - local function _createCoords() local x, y = GetPlayerMapPosition("player") x = tonumber(parsefloat(100 * x, 0)) @@ -506,20 +517,6 @@ do CoordsHolder.playerYCoords:SetHeight(17) CoordsHolder.playerYCoords:SetFontTemplate(SuperVillain.Media.font.numbers, 12, "OUTLINE") CoordsHolder.playerYCoords:SetTextColor(cColor.r, cColor.g, cColor.b) - end - - if(not MOD.db.playercoords or MOD.db.playercoords == "HIDE") then - if MOD.CoordTimer then - SuperVillain:RemoveLoop(MOD.CoordTimer) - MOD.CoordTimer = nil; - end - SVUI_MiniMapCoords.playerXCoords:SetText("") - SVUI_MiniMapCoords.playerYCoords:SetText("") - SVUI_MiniMapCoords:Hide() - else - SVUI_MiniMapCoords:Show() - MOD.CoordTimer = SuperVillain:ExecuteLoop(_updateCoords, 0.05) - _updateCoords() end end end @@ -605,8 +602,8 @@ function MOD:RefreshMiniMap() TimeManagerClockButton:MUNG() end - UpdateWorldMapConfig() SetMiniMapCoords() + UpdateWorldMapConfig() end local function CreateMiniMapElements() @@ -775,7 +772,6 @@ local function LoadWorldMap() CoordsHolder.mouseCoords:SetPoint("BOTTOMLEFT",CoordsHolder.playerCoords,"TOPLEFT",0,5) CoordsHolder.mouseCoords:SetText(MOUSE_LABEL..": 0, 0") - MOD.CoordsTimer = SuperVillain:ExecuteLoop(UpdateWorldMapCoords, 0.05) DropDownList1:HookScript('OnShow',function(self) if(DropDownList1:GetScale() ~= UIParent:GetScale() and SuperVillain.db.SVMap.tinyWorldMap) then DropDownList1:SetScale(UIParent:GetScale()) diff --git a/Interface/AddOns/SVUI/packages/map/SVMap.xml b/Interface/AddOns/SVUI/packages/map/SVMap.xml deleted file mode 100644 index 29163e9..0000000 --- a/Interface/AddOns/SVUI/packages/map/SVMap.xml +++ /dev/null @@ -1,3 +0,0 @@ -<Ui xmlns="http://www.blizzard.com/wow/ui/"> - <Script file='SVMap.lua'/> -</Ui> \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/override/SVOverride.lua b/Interface/AddOns/SVUI/packages/override/SVOverride.lua index e34e96b..b910b38 100644 --- a/Interface/AddOns/SVUI/packages/override/SVOverride.lua +++ b/Interface/AddOns/SVUI/packages/override/SVOverride.lua @@ -43,7 +43,55 @@ LOCAL VARS ]]-- local UIErrorsFrame = UIErrorsFrame; local interruptMsg = INTERRUPTED.." %s's \124cff71d5ff\124Hspell:%d\124h[%s]\124h\124r!"; +local POSITION, ANCHOR_POINT, YOFFSET = "TOP", "BOTTOM", -10 +local FORCE_POSITION = false; local NewHook = hooksecurefunc; +local mirrorYOffset={ + ["BREATH"] = 96, + ["EXHAUSTION"] = 119, + ["FEIGNDEATH"] = 142 +} +local mirrorTypeColor={ + EXHAUSTION = {1,.9,0}, + BREATH = {0.31,0.45,0.63}, + DEATH = {1,.7,0}, + FEIGNDEATH = {1,.7,0} +} +local RegisteredMirrorBars = {} +local lastQuality,lastID,lastName; +local dead_rollz = {} +local RollTypePresets = { + [0] = { + "Interface\\Buttons\\UI-GroupLoot-Pass-Up", + "", + "Interface\\Buttons\\UI-GroupLoot-Pass-Down", + [[0]], + [[2]] + }, + [1] = { + "Interface\\Buttons\\UI-GroupLoot-Dice-Up", + "Interface\\Buttons\\UI-GroupLoot-Dice-Highlight", + "Interface\\Buttons\\UI-GroupLoot-Dice-Down", + [[5]], + [[-1]] + }, + [2] = { + "Interface\\Buttons\\UI-GroupLoot-Coin-Up", + "Interface\\Buttons\\UI-GroupLoot-Coin-Highlight", + "Interface\\Buttons\\UI-GroupLoot-Coin-Down", + [[0]], + [[-1]] + }, + [3] = { + "Interface\\Buttons\\UI-GroupLoot-DE-Up", + "Interface\\Buttons\\UI-GroupLoot-DE-Highlight", + "Interface\\Buttons\\UI-GroupLoot-DE-Down", + [[0]], + [[-1]] + } +}; +local LootRollType = {[1] = "need", [2] = "greed", [3] = "disenchant", [0] = "pass"}; +local LOOT_WIDTH, LOOT_HEIGHT = 328, 28 --[[ ########################################################## CORE FUNCTIONS @@ -54,7 +102,7 @@ local PVPRaidNoticeHandler = function(self, event, msg) if instanceType == 'pvp' or instanceType == 'arena' then RaidNotice_AddMessage(RaidBossEmoteFrame, msg, ChatTypeInfo["RAID_BOSS_EMOTE"]); end -end; +end local CaptureBarHandler = function() if NUM_EXTENDED_UI_FRAMES then @@ -92,10 +140,11 @@ local Vehicle_OnSetPoint = function(self,_,parent) else VehicleSeatIndicator:Point("TOPLEFT", SuperVillain.UIParent, "TOPLEFT", 22, -45) SuperVillain:SetSVMovable(VehicleSeatIndicator, L["Vehicle Seat Frame"]) - end; + end VehicleSeatIndicator:SetScale(0.8) end end + local Dura_OnSetPoint = function(_, _, anchor) if anchor == "MinimapCluster"or anchor == _G["MinimapCluster"] then DurabilityFrame:ClearAllPoints() @@ -123,7 +172,827 @@ function MOD:DisbandRaidGroup() end LeaveParty() end +--[[ +########################################################## +ALERTS +########################################################## +]]-- +local _hook_AlertFrame_SetLootAnchors = function(self) + if MissingLootFrame:IsShown() then + MissingLootFrame:ClearAllPoints() + MissingLootFrame:SetPoint(POSITION, self, ANCHOR_POINT) + if GroupLootContainer:IsShown() then + GroupLootContainer:ClearAllPoints() + GroupLootContainer:SetPoint(POSITION, MissingLootFrame, ANCHOR_POINT, 0, YOFFSET) + end + elseif GroupLootContainer:IsShown() or FORCE_POSITION then + GroupLootContainer:ClearAllPoints() + GroupLootContainer:SetPoint(POSITION, self, ANCHOR_POINT) + end +end + +local _hook_AlertFrame_SetLootWonAnchors = function(self) + for i = 1, #LOOT_WON_ALERT_FRAMES do + local frame = LOOT_WON_ALERT_FRAMES[i] + if frame:IsShown() then + frame:ClearAllPoints() + frame:SetPoint(POSITION, self, ANCHOR_POINT, 0, YOFFSET) + self = frame + end + end +end + +local _hook_AlertFrame_SetMoneyWonAnchors = function(self) + for i = 1, #MONEY_WON_ALERT_FRAMES do + local frame = MONEY_WON_ALERT_FRAMES[i] + if frame:IsShown() then + frame:ClearAllPoints() + frame:SetPoint(POSITION, self, ANCHOR_POINT, 0, YOFFSET) + self = frame + end + end +end + +local _hook_AlertFrame_SetAchievementAnchors = function(self) + if AchievementAlertFrame1 then + for i = 1, MAX_ACHIEVEMENT_ALERTS do + local frame = _G["AchievementAlertFrame"..i] + if frame and frame:IsShown() then + frame:ClearAllPoints() + frame:SetPoint(POSITION, self, ANCHOR_POINT, 0, YOFFSET) + self = frame + end + end + end +end + +local _hook_AlertFrame_SetCriteriaAnchors = function(self) + if CriteriaAlertFrame1 then + for i = 1, MAX_ACHIEVEMENT_ALERTS do + local frame = _G["CriteriaAlertFrame"..i] + if frame and frame:IsShown() then + frame:ClearAllPoints() + frame:SetPoint(POSITION, self, ANCHOR_POINT, 0, YOFFSET) + self = frame + end + end + end +end + +local _hook_AlertFrame_SetChallengeModeAnchors = function(self) + local frame = ChallengeModeAlertFrame1; + if frame:IsShown() then + frame:ClearAllPoints() + frame:SetPoint(POSITION, self, ANCHOR_POINT, 0, YOFFSET) + end +end + +local _hook_AlertFrame_SetDungeonCompletionAnchors = function(self) + local frame = DungeonCompletionAlertFrame1; + if frame:IsShown() then + frame:ClearAllPoints() + frame:SetPoint(POSITION, self, ANCHOR_POINT, 0, YOFFSET) + end +end + +local _hook_AlertFrame_SetStorePurchaseAnchors = function(self) + local frame = StorePurchaseAlertFrame; + if frame:IsShown() then + frame:ClearAllPoints() + frame:SetPoint(POSITION, self, ANCHOR_POINT, 0, YOFFSET) + end +end + +local _hook_AlertFrame_SetScenarioAnchors = function(self) + local frame = ScenarioAlertFrame1; + if frame:IsShown() then + frame:ClearAllPoints() + frame:SetPoint(POSITION, self, ANCHOR_POINT, 0, YOFFSET) + end +end + +local _hook_AlertFrame_SetGuildChallengeAnchors = function(self) + local frame = GuildChallengeAlertFrame; + if frame:IsShown() then + frame:ClearAllPoints() + frame:SetPoint(POSITION, self, ANCHOR_POINT, 0, YOFFSET) + end +end + +local afrm = CreateFrame("Frame", "SVUI_AlertFrame", UIParent); +afrm:SetWidth(180); +afrm:SetHeight(20); + +local AlertFramePostMove_Hook = function(forced) + local b, c = SVUI_AlertFrame_MOVE:GetCenter() + local d = SuperVillain.UIParent:GetTop() + if(c > (d / 2)) then + POSITION = "TOP" + ANCHOR_POINT = "BOTTOM" + YOFFSET = -10; + SVUI_AlertFrame_MOVE:SetText(SVUI_AlertFrame_MOVE.textString.." (Grow Down)") + else + POSITION = "BOTTOM" + ANCHOR_POINT = "TOP" + YOFFSET = 10; + SVUI_AlertFrame_MOVE:SetText(SVUI_AlertFrame_MOVE.textString.." (Grow Up)") + end + if MOD.db.lootRoll then + local f, g; + for h, i in pairs(MOD.LewtRollz) do + i:ClearAllPoints() + if h ~= 1 then + if POSITION == "TOP" then + i:Point("TOP", f, "BOTTOM", 0, -4) + else + i:Point("BOTTOM", f, "TOP", 0, 4) + end + else + if POSITION == "TOP" then + i:Point("TOP", SVUI_AlertFrame, "BOTTOM", 0, -4) + else + i:Point("BOTTOM", SVUI_AlertFrame, "TOP", 0, 4) + end + end + f = i; + if i:IsShown() then + g = i + end + end + AlertFrame:ClearAllPoints() + if g then + AlertFrame:SetAllPoints(g) + else + AlertFrame:SetAllPoints(SVUI_AlertFrame) + end + else + AlertFrame:ClearAllPoints() + AlertFrame:SetAllPoints(SVUI_AlertFrame) + end + if forced then + FORCE_POSITION = true; + AlertFrame_FixAnchors() + FORCE_POSITION = false + end +end +--[[ +########################################################## +MIRROR BARS +########################################################## +]]-- +local SetMirrorPosition = function(bar) + local yOffset = mirrorYOffset[bar.type] + return bar:Point("TOP", SuperVillain.UIParent, "TOP", 0, -yOffset) +end + +local MirrorBar_OnUpdate = function(self, elapsed) + if self.paused then + return + end + self.lastupdate = (self.lastupdate or 0) + elapsed; + if self.lastupdate < .1 then + return + end + self.lastupdate = 0; + self:SetValue(GetMirrorTimerProgress(self.type) / 1e3) +end + +local MirrorBar_Start = function(self, min, max, s, t, text) + if t > 0 then + self.paused = 1 + elseif self.paused then + self.paused = nil + end + self.text:SetText(text) + self:SetMinMaxValues(0, max / 1e3) + self:SetValue(min / 1e3) + if not self:IsShown() then + self:Show() + end +end + + +local function MirrorBarRegistry(barType) + if RegisteredMirrorBars[barType] then + return RegisteredMirrorBars[barType] + end + local bar = CreateFrame('StatusBar', nil, SuperVillain.UIParent) + bar:SetPanelTemplate("Bar", false, 3, 3, 3) + bar:SetScript("OnUpdate", MirrorBar_OnUpdate) + local r, g, b = unpack(mirrorTypeColor[barType]) + bar.text = bar:CreateFontString(nil, 'OVERLAY') + bar.text:SetFontTemplate(SuperVillain.Media.font.roboto, 12, 'OUTLINE') + bar.text:SetJustifyH('CENTER') + bar.text:SetTextColor(1, 1, 1) + bar.text:SetPoint('LEFT', bar) + bar.text:SetPoint('RIGHT', bar) + bar.text:Point('TOP', bar, 0, 2) + bar.text:SetPoint('BOTTOM', bar) + bar:Size(222, 18) + bar:SetStatusBarTexture([[Interface\AddOns\SVUI\assets\artwork\Template\DEFAULT]]) + bar:SetStatusBarColor(r, g, b) + bar.type = barType; + bar.Start = MirrorBar_Start; + bar.Stop = Stop; + SetMirrorPosition(bar) + RegisteredMirrorBars[barType] = bar; + return bar +end + +local function SetTimerStyle(bar) + for i=1, bar:GetNumRegions()do + local child = select(i, bar:GetRegions()) + if child:GetObjectType() == "Texture"then + child:SetTexture(nil) + elseif child:GetObjectType() == "FontString" then + child:SetFontTemplate(SuperVillain.Media.font.roboto, 12, 'OUTLINE') + end + end + bar:SetStatusBarTexture([[Interface\AddOns\SVUI\assets\artwork\Template\DEFAULT]]) + bar:SetStatusBarColor(0.37, 0.92, 0.08) + bar:SetPanelTemplate("Bar", false, 3, 3, 3) +end + +local MirrorBarToggleHandler = function(_, event, arg, ...) + if(event == "START_TIMER") then + for _,timer in pairs(TimerTracker.timerList)do + if timer["bar"] and not timer["bar"].styled then + SetTimerStyle(timer["bar"]) + timer["bar"].styled = true + end + end + elseif(event == "MIRROR_TIMER_START") then + return MirrorBarRegistry(arg):Start(...) + elseif(event == "MIRROR_TIMER_STOP") then + return MirrorBarRegistry(arg):Hide() + elseif(event == "MIRROR_TIMER_PAUSE") then + local pausedValue = (arg > 0 and arg or nil); + for barType,bar in next,RegisteredMirrorBars do + bar.paused = pausedValue; + end + end +end + +local MirrorBarUpdateHandler = function(_, event) + if not GetCVarBool("lockActionBars") and SuperVillain.db.SVBar.enable then + SetCVar("lockActionBars", 1) + end + if(event == "PLAYER_ENTERING_WORLD") then + for i = 1, MIRRORTIMER_NUMTIMERS do + local v, q, r, s, t, u = GetMirrorTimerInfo(i) + if v ~= "UNKNOWN"then + MirrorBarRegistry(v):Start(q, r, s, t, u) + end + end + end +end +--[[ +########################################################## +LOOTING +########################################################## +]]-- +local function UpdateLootUpvalues() + LOOT_WIDTH = MOD.db.lootRollWidth + LOOT_HEIGHT = MOD.db.lootRollHeight +end + +local Loot_OnHide = function(self) + SuperVillain:StaticPopup_Hide("CONFIRM_LOOT_DISTRIBUTION"); + CloseLoot() +end + +local SVUI_LootFrameHolder = CreateFrame("Frame","SVUI_LootFrameHolder",SuperVillain.UIParent); +local SVUI_LootFrame = CreateFrame('Button', 'SVUI_LootFrame', SVUI_LootFrameHolder); +SVUI_LootFrameHolder:Point("TOPLEFT",36,-195); +SVUI_LootFrameHolder:Width(150); +SVUI_LootFrameHolder:Height(22); + +SVUI_LootFrame:SetClampedToScreen(true); +SVUI_LootFrame:SetPoint('TOPLEFT'); +SVUI_LootFrame:Size(256,64); +SVUI_LootFrame:SetFrameStrata("FULLSCREEN"); +SVUI_LootFrame:SetToplevel(true); +SVUI_LootFrame.title = SVUI_LootFrame:CreateFontString(nil,'OVERLAY'); +SVUI_LootFrame.title:Point('BOTTOMLEFT',SVUI_LootFrame,'TOPLEFT',0,1); +SVUI_LootFrame.slots = {}; +SVUI_LootFrame:SetScript("OnHide", Loot_OnHide); + +local function HideItemTip() + GameTooltip:Hide() +end + +local function HideRollTip() + GameTooltip:Hide() + ResetCursor() +end + +local function LootRoll_SetTooltip(self) + GameTooltip:SetOwner(self, "ANCHOR_RIGHT") + GameTooltip:SetText(self.tiptext) + if self:IsEnabled() == 0 then + GameTooltip:AddLine("|cffff3333"..L["Can't Roll"]) + end + for r, s in pairs(self.parent.rolls)do + if LootRollType[s] == LootRollType[self.rolltype] then + GameTooltip:AddLine(r, 1, 1, 1) + end + end + GameTooltip:Show() +end + +local function LootItem_SetTooltip(self) + if not self.link then + return + end + GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT") + GameTooltip:SetHyperlink(self.link) + if IsShiftKeyDown() then + GameTooltip_ShowCompareItem() + end + if IsModifiedClick("DRESSUP") then + ShowInspectCursor() + else + ResetCursor() + end +end + +local function LootItem_OnUpdate(v) + if IsShiftKeyDown() then + GameTooltip_ShowCompareItem() + end + CursorOnUpdate(v) +end + +local function LootRoll_OnClick(self) + if IsControlKeyDown() then + DressUpItemLink(self.link) + elseif IsShiftKeyDown() then + ChatEdit_InsertLink(self.link) + end +end + +local function LootRoll_OnEvent(self, event, value) + dead_rollz[value] = true; + if self.rollID ~= value then + return + end + self.rollID = nil; + self.time = nil; + self:Hide() +end + +local function LootRoll_OnUpdate(self) + if not self.parent.rollID then return end + local remaining = GetLootRollTimeLeft(self.parent.rollID) + local mu = remaining / self.parent.time; + self.spark:Point("CENTER", self, "LEFT", mu * self:GetWidth(), 0) + self:SetValue(remaining) + if remaining > 1000000000 then + self:GetParent():Hide() + end +end + +local DoDaRoll = function(self) + RollOnLoot(self.parent.rollID, self.rolltype) +end + +local LootSlot_OnEnter = function(self) + local slotID = self:GetID() + if LootSlotHasItem(slotID) then + GameTooltip:SetOwner(self, "ANCHOR_RIGHT") + GameTooltip:SetLootItem(slotID) + CursorUpdate(self) + end + self.drop:Show() + self.drop:SetVertexColor(1, 1, 0) +end + +local LootSlot_OnLeave = function(self) + if self.quality and self.quality > 1 then + local color = ITEM_QUALITY_COLORS[self.quality] + self.drop:SetVertexColor(color.r, color.g, color.b) + else + self.drop:Hide() + end + GameTooltip:Hide() + ResetCursor() +end + +local LootSlot_OnClick = function(self) + LootFrame.selectedQuality = self.quality; + LootFrame.selectedItemName = self.name:GetText() + LootFrame.selectedSlot = self:GetID() + LootFrame.selectedLootButton = self:GetName() + LootFrame.selectedTexture = self.icon:GetTexture() + if IsModifiedClick() then + HandleModifiedItemClick(GetLootSlotLink(self:GetID())) + else + StaticPopup_Hide("CONFIRM_LOOT_DISTRIBUTION") + lastID = self:GetID() + lastQuality = self.quality; + lastName = self.name:GetText() + LootSlot(lastID) + end +end + +local LootSlot_OnShow = function(self) + if GameTooltip:IsOwned(self) then + GameTooltip:SetOwner(self, "ANCHOR_RIGHT") + GameTooltip:SetLootItem(self:GetID()) + CursorOnUpdate(self) + end +end + +local function HandleSlots(frame) + local scale = 30; + local counter = 0; + for i = 1, #frame.slots do + local slot = frame.slots[i] + if slot:IsShown() then + counter = counter + 1; + slot:Point("TOP", SVUI_LootFrame, 4, (-8 + scale) - (counter * scale)) + end + end + frame:Height(max(counter * scale + 16, 20)) +end + +local function MakeSlots(id) + local size = LOOT_HEIGHT; + local slot = CreateFrame("Button", "SVUI_LootSlot"..id, SVUI_LootFrame) + slot:Point("LEFT", 8, 0) + slot:Point("RIGHT", -8, 0) + slot:Height(size) + slot:SetID(id) + slot:RegisterForClicks("LeftButtonUp", "RightButtonUp") + slot:SetScript("OnEnter", LootSlot_OnEnter) + slot:SetScript("OnLeave", LootSlot_OnLeave) + slot:SetScript("OnClick", LootSlot_OnClick) + slot:SetScript("OnShow", LootSlot_OnShow) + + slot.iconFrame = CreateFrame("Frame", nil, slot) + slot.iconFrame:Height(size) + slot.iconFrame:Width(size) + slot.iconFrame:SetPoint("RIGHT", slot) + slot.iconFrame:SetFixedPanelTemplate("Default") + + slot.icon = slot.iconFrame:CreateTexture(nil, "ARTWORK") + slot.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9) + slot.icon:FillInner() + + slot.count = slot.iconFrame:CreateFontString(nil, "OVERLAY") + slot.count:SetJustifyH("RIGHT") + slot.count:Point("BOTTOMRIGHT", slot.iconFrame, -2, 2) + slot.count:SetFont(SuperVillain.Shared:Fetch("font", "Roboto"), 12, "OUTLINE") + slot.count:SetText(1) + + slot.name = slot:CreateFontString(nil, "OVERLAY") + slot.name:SetJustifyH("LEFT") + slot.name:SetPoint("LEFT", slot) + slot.name:SetPoint("RIGHT", slot.icon, "LEFT") + slot.name:SetNonSpaceWrap(true) + slot.name:SetFont(SuperVillain.Shared:Fetch("font", "Roboto"), 12, "OUTLINE") + + slot.drop = slot:CreateTexture(nil, "ARTWORK") + slot.drop:SetTexture("Interface\\QuestFrame\\UI-QuestLogTitleHighlight") + slot.drop:SetPoint("LEFT", slot.icon, "RIGHT", 0, 0) + slot.drop:SetPoint("RIGHT", slot) + slot.drop:SetAllPoints(slot) + slot.drop:SetAlpha(.3) + + slot.questTexture = slot.iconFrame:CreateTexture(nil, "OVERLAY") + slot.questTexture:FillInner() + slot.questTexture:SetTexture(TEXTURE_ITEM_QUEST_BANG) + slot.questTexture:SetTexCoord(0.1, 0.9, 0.1, 0.9) + + SVUI_LootFrame.slots[id] = slot; + return slot +end + +local function CreateRollButton(rollFrame, type, locale, anchor) + local preset = RollTypePresets[type]; + local rollButton = CreateFrame("Button", nil, rollFrame) + rollButton:Point("LEFT", anchor, "RIGHT", tonumber(preset[4]), tonumber(preset[5])) + rollButton:Size(LOOT_HEIGHT - 4) + rollButton:SetNormalTexture(preset[1]) + if preset[2] and preset[2] ~= "" then + rollButton:SetPushedTexture(preset[2]) + end + rollButton:SetHighlightTexture(preset[3]) + rollButton.rolltype = type; + rollButton.parent = rollFrame; + rollButton.tiptext = locale; + rollButton:SetScript("OnEnter", LootRoll_SetTooltip) + rollButton:SetScript("OnLeave", HideItemTip) + rollButton:SetScript("OnClick", DoDaRoll) + rollButton:SetMotionScriptsWhileDisabled(true) + local text = rollButton:CreateFontString(nil, nil) + text:SetFont(SuperVillain.Shared:Fetch("font", "Roboto"),14,"OUTLINE") + text:Point("CENTER", 0, ((type == 2 and 1) or (type == 0 and -1.2) or 0)) + return rollButton, text +end + +local function CreateRollFrame() + UpdateLootUpvalues() + local rollFrame = CreateFrame("Frame",nil,SuperVillain.UIParent) + rollFrame:Size(LOOT_WIDTH,LOOT_HEIGHT) + rollFrame:SetFixedPanelTemplate('Default') + rollFrame:SetScript("OnEvent",LootRoll_OnEvent) + rollFrame:RegisterEvent("CANCEL_LOOT_ROLL") + rollFrame:Hide() + rollFrame.button = CreateFrame("Button",nil,rollFrame) + rollFrame.button:Point("RIGHT",rollFrame,'LEFT',0,0) + rollFrame.button:Size(LOOT_HEIGHT - 2) + rollFrame.button:SetPanelTemplate('Default') + rollFrame.button:SetScript("OnEnter",LootItem_SetTooltip) + rollFrame.button:SetScript("OnLeave",HideRollTip) + rollFrame.button:SetScript("OnUpdate",LootItem_OnUpdate) + rollFrame.button:SetScript("OnClick",LootRoll_OnClick) + rollFrame.button.icon = rollFrame.button:CreateTexture(nil,'OVERLAY') + rollFrame.button.icon:SetAllPoints() + rollFrame.button.icon:SetTexCoord(0.1,0.9,0.1,0.9 ) + local border = rollFrame:CreateTexture(nil,"BORDER") + border:Point("TOPLEFT",rollFrame,"TOPLEFT",4,0) + border:Point("BOTTOMRIGHT",rollFrame,"BOTTOMRIGHT",-4,0) + border:SetTexture("Interface\\ChatFrame\\ChatFrameBackground") + border:SetBlendMode("ADD") + border:SetGradientAlpha("VERTICAL",.1,.1,.1,0,.1,.1,.1,0) + rollFrame.status=CreateFrame("StatusBar",nil,rollFrame) + rollFrame.status:FillInner() + rollFrame.status:SetScript("OnUpdate",LootRoll_OnUpdate) + rollFrame.status:SetFrameLevel(rollFrame.status:GetFrameLevel() - 1) + rollFrame.status:SetStatusBarTexture([[Interface\AddOns\SVUI\assets\artwork\Template\DEFAULT]]) + rollFrame.status:SetStatusBarColor(.8,.8,.8,.9) + rollFrame.status.parent = rollFrame; + rollFrame.status.bg = rollFrame.status:CreateTexture(nil,'BACKGROUND') + rollFrame.status.bg:SetAlpha(0.1) + rollFrame.status.bg:SetAllPoints() + rollFrame.status.bg:SetDrawLayer('BACKGROUND',2) + rollFrame.status.spark = rollFrame:CreateTexture(nil,"OVERLAY") + rollFrame.status.spark:Size(LOOT_HEIGHT * 0.5, LOOT_HEIGHT) + rollFrame.status.spark:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark") + rollFrame.status.spark:SetBlendMode("ADD") + + local needButton,needText = CreateRollButton(rollFrame,1,NEED,rollFrame.button) + local greedButton,greedText = CreateRollButton(rollFrame,2,GREED,needButton,"RIGHT") + local deButton,deText = CreateRollButton(rollFrame,3,ROLL_DISENCHANT,greedButton) + local passButton,passText = CreateRollButton(rollFrame,0,PASS,deButton or greedButton) + rollFrame.NeedIt,rollFrame.WantIt,rollFrame.BreakIt = needButton,greedButton,deButton; + rollFrame.need,rollFrame.greed,rollFrame.pass,rollFrame.disenchant = needText,greedText,passText,deText; + rollFrame.bindText = rollFrame:CreateFontString() + rollFrame.bindText:Point("LEFT",passButton,"RIGHT",3,1) + rollFrame.bindText:SetFont(SuperVillain.Shared:Fetch("font", "SVUI Number Font"),14,"OUTLINE") + rollFrame.lootText = rollFrame:CreateFontString(nil,"ARTWORK") + rollFrame.lootText:SetFont(SuperVillain.Shared:Fetch("font", "SVUI Number Font"),14,"OUTLINE") + rollFrame.lootText:Point("LEFT",rollFrame.bindText,"RIGHT",0,0) + rollFrame.lootText:Point("RIGHT",rollFrame,"RIGHT",-5,0) + rollFrame.lootText:Size(200,10) + rollFrame.lootText:SetJustifyH("LEFT") + + rollFrame.yourRoll = rollFrame:CreateFontString(nil,"ARTWORK") + rollFrame.yourRoll:SetFont(SuperVillain.Shared:Fetch("font", "SVUI Number Font"),18,"OUTLINE") + rollFrame.yourRoll:Size(22,22) + rollFrame.yourRoll:Point("LEFT",rollFrame,"RIGHT",5,0) + rollFrame.yourRoll:SetJustifyH("CENTER") + + rollFrame.rolls = {} + return rollFrame +end +--[[ +########################################################## +CORE FUNCTIONS +########################################################## +]]-- +local AutoConfirmLoot = function(_, event, ...) + if event == 'CONFIRM_LOOT_ROLL' or event == 'CONFIRM_DISENCHANT_ROLL' then + local arg1, arg2 = ... + ConfirmLootRoll(arg1, arg2) + elseif event == 'LOOT_OPENED' or event == 'LOOT_BIND_CONFIRM' then + local count = GetNumLootItems() + if count == 0 then CloseLoot() return end + for slot = 1, count do + ConfirmLootSlot(slot) + end + end +end + +local LootSimpleEventsHandler = function(_, event, slot) + if(event == 'LOOT_SLOT_CLEARED') then + if not SVUI_LootFrame:IsShown() then return; end + SVUI_LootFrame.slots[slot]:Hide() + HandleSlots(SVUI_LootFrame) + elseif(event == 'LOOT_CLOSED') then + StaticPopup_Hide("LOOT_BIND") + SVUI_LootFrame:Hide() + for _,slot in pairs(SVUI_LootFrame.slots)do + slot:Hide() + end + elseif(event == 'OPEN_MASTER_LOOT_LIST') then + ToggleDropDownMenu(1, nil, GroupLootDropDown, SVUI_LootFrame.slots[lastID], 0, 0) + elseif(event == 'UPDATE_MASTER_LOOT_LIST') then + MasterLooterFrame_UpdatePlayers() + end +end + +local OpenedLootHandler = function(_, event, autoLoot) + SVUI_LootFrame:Show() + if not SVUI_LootFrame:IsShown() then CloseLoot(autoLoot == 0) end + local drops = GetNumLootItems() + if IsFishingLoot() then + SVUI_LootFrame.title:SetText(L["Fishy Loot"]) + elseif not UnitIsFriend("player", "target") and UnitIsDead"target" then + SVUI_LootFrame.title:SetText(UnitName("target")) + else + SVUI_LootFrame.title:SetText(LOOT) + end + + if GetCVar("lootUnderMouse") == "1" then + local cursorX,cursorY = GetCursorPosition() + cursorX = cursorX / SVUI_LootFrame:GetEffectiveScale() + cursorY = (cursorY / (SVUI_LootFrame:GetEffectiveScale())); + SVUI_LootFrame:ClearAllPoints() + SVUI_LootFrame:Point("TOPLEFT", nil, "BOTTOMLEFT", cursorX - 40, cursorY + 20) + SVUI_LootFrame:GetCenter() + SVUI_LootFrame:Raise() + else + SVUI_LootFrame:ClearAllPoints() + SVUI_LootFrame:SetPoint("TOPLEFT", SVUI_LootFrameHolder, "TOPLEFT") + end + + local iQuality, nameWidth, titleWidth = 0, 0, SVUI_LootFrame.title:GetStringWidth() + UpdateLootUpvalues() + if drops > 0 then + for i = 1, drops do + local slot = SVUI_LootFrame.slots[i] or MakeSlots(i) + local texture, item, quantity, quality, locked, isQuestItem, questId, isActive = GetLootSlotInfo(i) + local color = ITEM_QUALITY_COLORS[quality] + if texture and texture:find("INV_Misc_Coin") then + item = item:gsub("\n", ", ") + end + if quantity and quantity > 1 then + slot.count:SetText(quantity) + slot.count:Show() + else + slot.count:Hide() + end + if quality and quality > 1 then + slot.drop:SetVertexColor(color.r, color.g, color.b) + slot.drop:Show() + else + slot.drop:Hide() + end + slot.quality = quality; + slot.name:SetText(item) + if color then + slot.name:SetTextColor(color.r, color.g, color.b) + end + slot.icon:SetTexture(texture) + if quality then + iQuality = max(iQuality, quality) + end + nameWidth = max(nameWidth, slot.name:GetStringWidth()) + local qTex = slot.questTexture; + if questId and not isActive then + qTex:Show() + ActionButton_ShowOverlayGlow(slot.iconFrame) + elseif questId or isQuestItem then + qTex:Hide() + ActionButton_ShowOverlayGlow(slot.iconFrame) + else + qTex:Hide() + ActionButton_HideOverlayGlow(slot.iconFrame) + end + slot:Enable() + slot:Show() + ConfirmLootSlot(i) + end + else + local slot = SVUI_LootFrame.slots[1] or MakeSlots(1) + local color = ITEM_QUALITY_COLORS[0] + slot.name:SetText(L["Empty Slot"]) + if color then + slot.name:SetTextColor(color.r, color.g, color.b) + end + slot.icon:SetTexture[[Interface\Icons\INV_Misc_Herb_AncientLichen]] + drops = 1; + nameWidth = max(nameWidth, slot.name:GetStringWidth()) + slot.count:Hide() + slot.drop:Hide() + slot:Disable() + slot:Show() + end + + HandleSlots(SVUI_LootFrame) + nameWidth = nameWidth + 60; + titleWidth = titleWidth + 5; + local color = ITEM_QUALITY_COLORS[iQuality] + SVUI_LootFrame:SetBackdropBorderColor(color.r, color.g, color.b, .8) + SVUI_LootFrame:Width(max(nameWidth, titleWidth)) +end + +local function rollz() + for _,roll in ipairs(MOD.LewtRollz)do + if not roll.rollID then + return roll + end + end + local roll = CreateRollFrame() + roll:Point("TOP", next(MOD.LewtRollz) and MOD.LewtRollz[#MOD.LewtRollz] or SVUI_AlertFrame, "BOTTOM", 0, -4); + tinsert(MOD.LewtRollz, roll) + return roll +end + +local LootComplexEventsHandler = function(_, event, arg1, arg2) + if(event == "START_LOOT_ROLL") then + if dead_rollz[arg1] then return end + local texture,name,count,quality,bindOnPickUp,canNeed,canGreed,canBreak = GetLootRollItemInfo(arg1); + local color = ITEM_QUALITY_COLORS[quality]; + local rollFrame = rollz(); + rollFrame.rollID = arg1; + rollFrame.time = arg2; + for i in pairs(rollFrame.rolls)do + rollFrame.rolls[i] = nil + end + rollFrame.need:SetText(0) + rollFrame.greed:SetText(0) + rollFrame.pass:SetText(0) + rollFrame.disenchant:SetText(0) + rollFrame.button.icon:SetTexture(texture) + rollFrame.button.link = GetLootRollItemLink(arg1) + if canNeed then + rollFrame.NeedIt:Enable() + rollFrame.NeedIt:SetAlpha(1) + else + rollFrame.NeedIt:SetAlpha(0.2) + rollFrame.NeedIt:Disable() + end + if canGreed then + rollFrame.WantIt:Enable() + rollFrame.WantIt:SetAlpha(1) + else + rollFrame.WantIt:SetAlpha(0.2) + rollFrame.WantIt:Disable() + end + if canBreak then + rollFrame.BreakIt:Enable() + rollFrame.BreakIt:SetAlpha(1) + else + rollFrame.BreakIt:SetAlpha(0.2) + rollFrame.BreakIt:Disable() + end + SetDesaturation(rollFrame.NeedIt:GetNormalTexture(),not canNeed) + SetDesaturation(rollFrame.WantIt:GetNormalTexture(),not canGreed) + SetDesaturation(rollFrame.BreakIt:GetNormalTexture(),not canBreak) + rollFrame.bindText:SetText(bindOnPickUp and "BoP" or "BoE") + rollFrame.bindText:SetVertexColor(bindOnPickUp and 1 or 0.3, bindOnPickUp and 0.3 or 1, bindOnPickUp and 0.1 or 0.3) + rollFrame.lootText:SetText(name) + rollFrame.yourRoll:SetText("") + rollFrame.status:SetStatusBarColor(color.r,color.g,color.b,0.7) + rollFrame.status.bg:SetTexture(color.r,color.g,color.b) + rollFrame.status:SetMinMaxValues(0,arg2) + rollFrame.status:SetValue(arg2) + rollFrame:SetPoint("CENTER",WorldFrame,"CENTER") + rollFrame:Show() + AlertFrame_FixAnchors() + if SuperVillain.db.SVHenchmen.autoRoll and UnitLevel('player') == MAX_PLAYER_LEVEL and quality == 2 and not bindOnPickUp then + if canBreak then + RollOnLoot(arg1,3) + else + RollOnLoot(arg1,2) + end + end + elseif(event == "LOOT_HISTORY_ROLL_CHANGED") then + local rollID,_,_,_,_,_ = C_LootHistory.GetItem(arg1); + local name,_,rollType,rollResult,_ = C_LootHistory.GetPlayerInfo(arg1,arg2); + if name and rollType then + for _,roll in ipairs(MOD.LewtRollz)do + if roll.rollID == rollID then + roll.rolls[name] = rollType; + roll[LootRollType[rollType]]:SetText(tonumber(roll[LootRollType[rollType]]:GetText()) + 1); + return + end + if rollResult then + roll.yourRoll:SetText(tostring(rollResult)) + end + end + end + end +end +local GroupLootDropDown_GiveLoot = function(self) + if lastQuality >= MASTER_LOOT_THREHOLD then + local confirmed = SuperVillain:StaticPopup_Show("CONFIRM_LOOT_DISTRIBUTION",ITEM_QUALITY_COLORS[lastQuality].hex..lastName..FONT_COLOR_CODE_CLOSE,self:GetText()); + if confirmed then confirmed.data = self.value end + else + GiveMasterLoot(lastID, self.value) + end + CloseDropDownMenus() + SuperVillain.SystemAlert["CONFIRM_LOOT_DISTRIBUTION"].OnAccept = function(self,index) GiveMasterLoot(lastID,index) end +end +--[[ +########################################################## +LOAD / UPDATE +########################################################## +]]-- function MOD:Load() HelpOpenTicketButtonTutorial:MUNG() TalentMicroButtonAlert:MUNG() @@ -151,9 +1020,54 @@ function MOD:Load() self:RegisterEvent('PLAYER_REGEN_DISABLED', ErrorFrameHandler) self:RegisterEvent('PLAYER_REGEN_ENABLED', ErrorFrameHandler) - self:OverrideAlerts() - self:OverrideLootFrame() - self:OverrideMirrorBars() + SVUI_AlertFrame:SetParent(SuperVillain.UIParent) + SVUI_AlertFrame:SetPoint("TOP", SuperVillain.UIParent, "TOP", 0, -18); + SuperVillain:SetSVMovable(SVUI_AlertFrame, L["Loot / Alert Frames"], nil, nil, AlertFramePostMove_Hook) + NewHook('AlertFrame_FixAnchors', AlertFramePostMove_Hook) + NewHook('AlertFrame_SetLootAnchors', _hook_AlertFrame_SetLootAnchors) + NewHook('AlertFrame_SetLootWonAnchors', _hook_AlertFrame_SetLootWonAnchors) + NewHook('AlertFrame_SetMoneyWonAnchors', _hook_AlertFrame_SetMoneyWonAnchors) + NewHook('AlertFrame_SetAchievementAnchors', _hook_AlertFrame_SetAchievementAnchors) + NewHook('AlertFrame_SetCriteriaAnchors', _hook_AlertFrame_SetCriteriaAnchors) + NewHook('AlertFrame_SetChallengeModeAnchors', _hook_AlertFrame_SetChallengeModeAnchors) + NewHook('AlertFrame_SetDungeonCompletionAnchors', _hook_AlertFrame_SetDungeonCompletionAnchors) + NewHook('AlertFrame_SetScenarioAnchors', _hook_AlertFrame_SetScenarioAnchors) + NewHook('AlertFrame_SetGuildChallengeAnchors', _hook_AlertFrame_SetGuildChallengeAnchors) + NewHook('AlertFrame_SetStorePurchaseAnchors', _hook_AlertFrame_SetStorePurchaseAnchors) + + LootFrame:UnregisterAllEvents(); + SVUI_LootFrame:SetFixedPanelTemplate('Transparent'); + SVUI_LootFrame.title:SetFont(SuperVillain.Shared:Fetch("font", "SVUI Number Font"),18,"OUTLINE") + SuperVillain:SetSVMovable(SVUI_LootFrameHolder, L["Loot Frame"], nil, nil, nil, nil, "SVUI_LootFrame"); + tinsert(UISpecialFrames, "SVUI_LootFrame"); + + UIParent:UnregisterEvent("LOOT_BIND_CONFIRM") + UIParent:UnregisterEvent("CONFIRM_DISENCHANT_ROLL") + UIParent:UnregisterEvent("CONFIRM_LOOT_ROLL") + self:RegisterEvent("CONFIRM_DISENCHANT_ROLL", AutoConfirmLoot) + self:RegisterEvent("CONFIRM_LOOT_ROLL", AutoConfirmLoot) + self:RegisterEvent("LOOT_BIND_CONFIRM", AutoConfirmLoot) + self:RegisterEvent("LOOT_OPENED", OpenedLootHandler); + self:RegisterEvent("LOOT_SLOT_CLEARED", LootSimpleEventsHandler); + self:RegisterEvent("LOOT_CLOSED", LootSimpleEventsHandler); + self:RegisterEvent("OPEN_MASTER_LOOT_LIST", LootSimpleEventsHandler); + self:RegisterEvent("UPDATE_MASTER_LOOT_LIST", LootSimpleEventsHandler); + if self.db.lootRoll then + self:RegisterEvent("LOOT_HISTORY_ROLL_CHANGED", LootComplexEventsHandler); + self:RegisterEvent("START_LOOT_ROLL", LootComplexEventsHandler); + UIParent:UnregisterEvent("START_LOOT_ROLL"); + UIParent:UnregisterEvent("CANCEL_LOOT_ROLL"); + end + + _G.GroupLootDropDown_GiveLoot = GroupLootDropDown_GiveLoot + + UIParent:UnregisterEvent("MIRROR_TIMER_START") + self:RegisterEvent("CVAR_UPDATE", MirrorBarUpdateHandler) + self:RegisterEvent("PLAYER_ENTERING_WORLD", MirrorBarUpdateHandler) + self:RegisterEvent("MIRROR_TIMER_START", MirrorBarToggleHandler) + self:RegisterEvent("MIRROR_TIMER_STOP", MirrorBarToggleHandler) + self:RegisterEvent("MIRROR_TIMER_PAUSE", MirrorBarToggleHandler) + self:RegisterEvent("START_TIMER", MirrorBarToggleHandler) local exit = CreateFrame("Button", "SVUI_BailOut", SuperVillain.UIParent, "SecureHandlerClickTemplate") exit:Size(40, 40) diff --git a/Interface/AddOns/SVUI/packages/override/SVOverride.xml b/Interface/AddOns/SVUI/packages/override/SVOverride.xml deleted file mode 100644 index 6762d90..0000000 --- a/Interface/AddOns/SVUI/packages/override/SVOverride.xml +++ /dev/null @@ -1,4 +0,0 @@ -<Ui xmlns="http://www.blizzard.com/wow/ui/"> - <Script file='SVOverride.lua'/> - <Include file='common\_load.xml'/> -</Ui> \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/override/common/_load.xml b/Interface/AddOns/SVUI/packages/override/common/_load.xml deleted file mode 100644 index 6645910..0000000 --- a/Interface/AddOns/SVUI/packages/override/common/_load.xml +++ /dev/null @@ -1,5 +0,0 @@ -<Ui xmlns="http://www.blizzard.com/wow/ui/"> - <Script file='alert.lua'/> - <Script file='looting.lua'/> - <Script file='mirror.lua'/> -</Ui> \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/override/common/alert.lua b/Interface/AddOns/SVUI/packages/override/common/alert.lua deleted file mode 100644 index eea635c..0000000 --- a/Interface/AddOns/SVUI/packages/override/common/alert.lua +++ /dev/null @@ -1,230 +0,0 @@ ---[[ -############################################################################## -_____/\\\\\\\\\\\____/\\\________/\\\__/\\\________/\\\__/\\\\\\\\\\\_ # - ___/\\\/////////\\\_\/\\\_______\/\\\_\/\\\_______\/\\\_\/////\\\///__ # - __\//\\\______\///__\//\\\______/\\\__\/\\\_______\/\\\_____\/\\\_____ # - ___\////\\\__________\//\\\____/\\\___\/\\\_______\/\\\_____\/\\\_____ # - ______\////\\\________\//\\\__/\\\____\/\\\_______\/\\\_____\/\\\_____ # - _________\////\\\______\//\\\/\\\_____\/\\\_______\/\\\_____\/\\\_____ # - __/\\\______\//\\\______\//\\\\\______\//\\\______/\\\______\/\\\_____ # - _\///\\\\\\\\\\\/________\//\\\________\///\\\\\\\\\/____/\\\\\\\\\\\_# - ___\///////////___________\///___________\/////////_____\///////////_# -############################################################################## -S U P E R - V I L L A I N - U I By: Munglunch # -############################################################################## -########################################################## -LOCALIZED LUA FUNCTIONS -########################################################## -]]-- ---[[ GLOBALS ]]-- -local _G = _G; -local unpack = _G.unpack; -local select = _G.select; -local pairs = _G.pairs; -local tinsert = _G.tinsert; -local string = _G.string; -local math = _G.math; ---[[ STRING METHODS ]]-- -local find, format, len, split = string.find, string.format, string.len, string.split; ---[[ MATH METHODS ]]-- -local abs, ceil, floor, round = math.abs, math.ceil, math.floor, math.round; ---[[ -########################################################## -GET ADDON DATA -########################################################## -]]-- -local SuperVillain, L = unpack(select(2, ...)); -local MOD = SuperVillain.Registry:Expose('SVOverride'); ---[[ -########################################################## -LOCAL VARS -########################################################## -]]-- -local NewHook = hooksecurefunc; -local POSITION, ANCHOR_POINT, YOFFSET = "TOP", "BOTTOM", -10 -local FORCE_POSITION = false; ---[[ -########################################################## -HOOKS -########################################################## -]]-- -local _hook_AlertFrame_SetLootAnchors = function(self) - if MissingLootFrame:IsShown() then - MissingLootFrame:ClearAllPoints() - MissingLootFrame:SetPoint(POSITION, self, ANCHOR_POINT) - if GroupLootContainer:IsShown() then - GroupLootContainer:ClearAllPoints() - GroupLootContainer:SetPoint(POSITION, MissingLootFrame, ANCHOR_POINT, 0, YOFFSET) - end - elseif GroupLootContainer:IsShown() or FORCE_POSITION then - GroupLootContainer:ClearAllPoints() - GroupLootContainer:SetPoint(POSITION, self, ANCHOR_POINT) - end -end; - -local _hook_AlertFrame_SetLootWonAnchors = function(self) - for i = 1, #LOOT_WON_ALERT_FRAMES do - local frame = LOOT_WON_ALERT_FRAMES[i] - if frame:IsShown() then - frame:ClearAllPoints() - frame:SetPoint(POSITION, self, ANCHOR_POINT, 0, YOFFSET) - self = frame - end - end -end; - -local _hook_AlertFrame_SetMoneyWonAnchors = function(self) - for i = 1, #MONEY_WON_ALERT_FRAMES do - local frame = MONEY_WON_ALERT_FRAMES[i] - if frame:IsShown() then - frame:ClearAllPoints() - frame:SetPoint(POSITION, self, ANCHOR_POINT, 0, YOFFSET) - self = frame - end - end -end; - -local _hook_AlertFrame_SetAchievementAnchors = function(self) - if AchievementAlertFrame1 then - for i = 1, MAX_ACHIEVEMENT_ALERTS do - local frame = _G["AchievementAlertFrame"..i] - if frame and frame:IsShown() then - frame:ClearAllPoints() - frame:SetPoint(POSITION, self, ANCHOR_POINT, 0, YOFFSET) - self = frame - end - end - end -end; - -local _hook_AlertFrame_SetCriteriaAnchors = function(self) - if CriteriaAlertFrame1 then - for i = 1, MAX_ACHIEVEMENT_ALERTS do - local frame = _G["CriteriaAlertFrame"..i] - if frame and frame:IsShown() then - frame:ClearAllPoints() - frame:SetPoint(POSITION, self, ANCHOR_POINT, 0, YOFFSET) - self = frame - end - end - end -end; - -local _hook_AlertFrame_SetChallengeModeAnchors = function(self) - local frame = ChallengeModeAlertFrame1; - if frame:IsShown() then - frame:ClearAllPoints() - frame:SetPoint(POSITION, self, ANCHOR_POINT, 0, YOFFSET) - end -end; - -local _hook_AlertFrame_SetDungeonCompletionAnchors = function(self) - local frame = DungeonCompletionAlertFrame1; - if frame:IsShown() then - frame:ClearAllPoints() - frame:SetPoint(POSITION, self, ANCHOR_POINT, 0, YOFFSET) - end -end; - -local _hook_AlertFrame_SetStorePurchaseAnchors = function(self) - local frame = StorePurchaseAlertFrame; - if frame:IsShown() then - frame:ClearAllPoints() - frame:SetPoint(POSITION, self, ANCHOR_POINT, 0, YOFFSET) - end -end; - -local _hook_AlertFrame_SetScenarioAnchors = function(self) - local frame = ScenarioAlertFrame1; - if frame:IsShown() then - frame:ClearAllPoints() - frame:SetPoint(POSITION, self, ANCHOR_POINT, 0, YOFFSET) - end -end; - -local _hook_AlertFrame_SetGuildChallengeAnchors = function(self) - local frame = GuildChallengeAlertFrame; - if frame:IsShown() then - frame:ClearAllPoints() - frame:SetPoint(POSITION, self, ANCHOR_POINT, 0, YOFFSET) - end -end; ---[[ -########################################################## -TEMP LOADER -########################################################## -]]-- -local afrm = CreateFrame("Frame", "SVUI_AlertFrame", UIParent); -afrm:SetWidth(180); -afrm:SetHeight(20); - -local AlertFramePostMove_Hook = function(forced) - local b, c = SVUI_AlertFrame_MOVE:GetCenter() - local d = SuperVillain.UIParent:GetTop() - if(c > (d / 2)) then - POSITION = "TOP" - ANCHOR_POINT = "BOTTOM" - YOFFSET = -10; - SVUI_AlertFrame_MOVE:SetText(SVUI_AlertFrame_MOVE.textString.." (Grow Down)") - else - POSITION = "BOTTOM" - ANCHOR_POINT = "TOP" - YOFFSET = 10; - SVUI_AlertFrame_MOVE:SetText(SVUI_AlertFrame_MOVE.textString.." (Grow Up)") - end; - if SuperVillain.db.SVOverride.lootRoll then - local f, g; - for h, i in pairs(MOD.LewtRollz) do - i:ClearAllPoints() - if h ~= 1 then - if POSITION == "TOP" then - i:Point("TOP", f, "BOTTOM", 0, -4) - else - i:Point("BOTTOM", f, "TOP", 0, 4) - end - else - if POSITION == "TOP" then - i:Point("TOP", SVUI_AlertFrame, "BOTTOM", 0, -4) - else - i:Point("BOTTOM", SVUI_AlertFrame, "TOP", 0, 4) - end - end; - f = i; - if i:IsShown() then - g = i - end - end; - AlertFrame:ClearAllPoints() - if g then - AlertFrame:SetAllPoints(g) - else - AlertFrame:SetAllPoints(SVUI_AlertFrame) - end - else - AlertFrame:ClearAllPoints() - AlertFrame:SetAllPoints(SVUI_AlertFrame) - end; - if forced then - FORCE_POSITION = true; - AlertFrame_FixAnchors() - FORCE_POSITION = false - end -end; - -function MOD:OverrideAlerts() - SVUI_AlertFrame:SetParent(SuperVillain.UIParent) - SVUI_AlertFrame:SetPoint("TOP", SuperVillain.UIParent, "TOP", 0, -18); - SuperVillain:SetSVMovable(SVUI_AlertFrame, L["Loot / Alert Frames"], nil, nil, AlertFramePostMove_Hook) - - NewHook('AlertFrame_FixAnchors', AlertFramePostMove_Hook) - NewHook('AlertFrame_SetLootAnchors', _hook_AlertFrame_SetLootAnchors) - NewHook('AlertFrame_SetLootWonAnchors', _hook_AlertFrame_SetLootWonAnchors) - NewHook('AlertFrame_SetMoneyWonAnchors', _hook_AlertFrame_SetMoneyWonAnchors) - NewHook('AlertFrame_SetAchievementAnchors', _hook_AlertFrame_SetAchievementAnchors) - NewHook('AlertFrame_SetCriteriaAnchors', _hook_AlertFrame_SetCriteriaAnchors) - NewHook('AlertFrame_SetChallengeModeAnchors', _hook_AlertFrame_SetChallengeModeAnchors) - NewHook('AlertFrame_SetDungeonCompletionAnchors', _hook_AlertFrame_SetDungeonCompletionAnchors) - NewHook('AlertFrame_SetScenarioAnchors', _hook_AlertFrame_SetScenarioAnchors) - NewHook('AlertFrame_SetGuildChallengeAnchors', _hook_AlertFrame_SetGuildChallengeAnchors) - NewHook('AlertFrame_SetStorePurchaseAnchors', _hook_AlertFrame_SetStorePurchaseAnchors) -end \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/override/common/looting.lua b/Interface/AddOns/SVUI/packages/override/common/looting.lua deleted file mode 100644 index fdcdcc6..0000000 --- a/Interface/AddOns/SVUI/packages/override/common/looting.lua +++ /dev/null @@ -1,647 +0,0 @@ ---[[ -############################################################################## -_____/\\\\\\\\\\\____/\\\________/\\\__/\\\________/\\\__/\\\\\\\\\\\_ # - ___/\\\/////////\\\_\/\\\_______\/\\\_\/\\\_______\/\\\_\/////\\\///__ # - __\//\\\______\///__\//\\\______/\\\__\/\\\_______\/\\\_____\/\\\_____ # - ___\////\\\__________\//\\\____/\\\___\/\\\_______\/\\\_____\/\\\_____ # - ______\////\\\________\//\\\__/\\\____\/\\\_______\/\\\_____\/\\\_____ # - _________\////\\\______\//\\\/\\\_____\/\\\_______\/\\\_____\/\\\_____ # - __/\\\______\//\\\______\//\\\\\______\//\\\______/\\\______\/\\\_____ # - _\///\\\\\\\\\\\/________\//\\\________\///\\\\\\\\\/____/\\\\\\\\\\\_# - ___\///////////___________\///___________\/////////_____\///////////_# -############################################################################## -S U P E R - V I L L A I N - U I By: Munglunch # -############################################################################## -########################################################## -LOCALIZED LUA FUNCTIONS -########################################################## -]]-- ---[[ GLOBALS ]]-- -local _G = _G; -local unpack = _G.unpack; -local select = _G.select; -local pairs = _G.pairs; -local tonumber = _G.tonumber; -local tinsert = _G.tinsert; -local string = _G.string; -local math = _G.math; ---[[ STRING METHODS ]]-- -local find, format, len, split = string.find, string.format, string.len, string.split; ---[[ MATH METHODS ]]-- -local abs, ceil, floor, round = math.abs, math.ceil, math.floor, math.round; ---[[ -########################################################## -GET ADDON DATA -########################################################## -]]-- -local SuperVillain, L = unpack(select(2, ...)); -local MOD = SuperVillain.Registry:Expose('SVOverride'); ---[[ -########################################################## -LOCAL VARS -########################################################## -]]-- -local lastQuality,lastID,lastName; -local dead_rollz={} -local RollTypePresets = { - [0] = { - "Interface\\Buttons\\UI-GroupLoot-Pass-Up", - "", - "Interface\\Buttons\\UI-GroupLoot-Pass-Down", - [[0]], - [[2]] - }, - [1] = { - "Interface\\Buttons\\UI-GroupLoot-Dice-Up", - "Interface\\Buttons\\UI-GroupLoot-Dice-Highlight", - "Interface\\Buttons\\UI-GroupLoot-Dice-Down", - [[5]], - [[-1]] - }, - [2] = { - "Interface\\Buttons\\UI-GroupLoot-Coin-Up", - "Interface\\Buttons\\UI-GroupLoot-Coin-Highlight", - "Interface\\Buttons\\UI-GroupLoot-Coin-Down", - [[0]], - [[-1]] - }, - [3] = { - "Interface\\Buttons\\UI-GroupLoot-DE-Up", - "Interface\\Buttons\\UI-GroupLoot-DE-Highlight", - "Interface\\Buttons\\UI-GroupLoot-DE-Down", - [[0]], - [[-1]] - } -}; -local LootRollType = {[1] = "need", [2] = "greed", [3] = "disenchant", [0] = "pass"}; -local LOOT_WIDTH, LOOT_HEIGHT = 328, 28 ---[[ -########################################################## -PRE VARS/FUNCTIONS -########################################################## -]]-- -local function UpdateLootUpvalues() - LOOT_WIDTH = MOD.db.lootRollWidth - LOOT_HEIGHT = MOD.db.lootRollHeight -end - -local Loot_OnHide = function(self) - SuperVillain:StaticPopup_Hide("CONFIRM_LOOT_DISTRIBUTION"); - CloseLoot() -end - -local SVUI_LootFrameHolder = CreateFrame("Frame","SVUI_LootFrameHolder",SuperVillain.UIParent); -local SVUI_LootFrame = CreateFrame('Button', 'SVUI_LootFrame', SVUI_LootFrameHolder); -SVUI_LootFrameHolder:Point("TOPLEFT",36,-195); -SVUI_LootFrameHolder:Width(150); -SVUI_LootFrameHolder:Height(22); - -SVUI_LootFrame:SetClampedToScreen(true); -SVUI_LootFrame:SetPoint('TOPLEFT'); -SVUI_LootFrame:Size(256,64); -SVUI_LootFrame:SetFrameStrata("FULLSCREEN"); -SVUI_LootFrame:SetToplevel(true); -SVUI_LootFrame.title = SVUI_LootFrame:CreateFontString(nil,'OVERLAY'); -SVUI_LootFrame.title:Point('BOTTOMLEFT',SVUI_LootFrame,'TOPLEFT',0,1); -SVUI_LootFrame.slots = {}; -SVUI_LootFrame:SetScript("OnHide", Loot_OnHide); - -local function HideItemTip() - GameTooltip:Hide() -end - -local function HideRollTip() - GameTooltip:Hide() - ResetCursor() -end - -local function LootRoll_SetTooltip(self) - GameTooltip:SetOwner(self, "ANCHOR_RIGHT") - GameTooltip:SetText(self.tiptext) - if self:IsEnabled() == 0 then - GameTooltip:AddLine("|cffff3333"..L["Can't Roll"]) - end - for r, s in pairs(self.parent.rolls)do - if LootRollType[s] == LootRollType[self.rolltype] then - GameTooltip:AddLine(r, 1, 1, 1) - end - end - GameTooltip:Show() -end - -local function LootItem_SetTooltip(self) - if not self.link then - return - end - GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT") - GameTooltip:SetHyperlink(self.link) - if IsShiftKeyDown() then - GameTooltip_ShowCompareItem() - end - if IsModifiedClick("DRESSUP") then - ShowInspectCursor() - else - ResetCursor() - end -end - -local function LootItem_OnUpdate(v) - if IsShiftKeyDown() then - GameTooltip_ShowCompareItem() - end - CursorOnUpdate(v) -end - -local function LootRoll_OnClick(self) - if IsControlKeyDown() then - DressUpItemLink(self.link) - elseif IsShiftKeyDown() then - ChatEdit_InsertLink(self.link) - end -end - -local function LootRoll_OnEvent(self, event, value) - dead_rollz[value] = true; - if self.rollID ~= value then - return - end - self.rollID = nil; - self.time = nil; - self:Hide() -end - -local function LootRoll_OnUpdate(self) - if not self.parent.rollID then return end - local remaining = GetLootRollTimeLeft(self.parent.rollID) - local mu = remaining / self.parent.time; - self.spark:Point("CENTER", self, "LEFT", mu * self:GetWidth(), 0) - self:SetValue(remaining) - if remaining > 1000000000 then - self:GetParent():Hide() - end -end - -local DoDaRoll = function(self) - RollOnLoot(self.parent.rollID,self.rolltype) -end - -local LootSlot_OnEnter = function(self) - local slotID = self:GetID() - if LootSlotHasItem(slotID) then - GameTooltip:SetOwner(self, "ANCHOR_RIGHT") - GameTooltip:SetLootItem(slotID) - CursorUpdate(self) - end - self.drop:Show() - self.drop:SetVertexColor(1, 1, 0) -end - -local LootSlot_OnLeave = function(self) - if self.quality and self.quality > 1 then - local color = ITEM_QUALITY_COLORS[self.quality] - self.drop:SetVertexColor(color.r, color.g, color.b) - else - self.drop:Hide() - end - GameTooltip:Hide() - ResetCursor() -end - -local LootSlot_OnClick = function(self) - LootFrame.selectedQuality = self.quality; - LootFrame.selectedItemName = self.name:GetText() - LootFrame.selectedSlot = self:GetID() - LootFrame.selectedLootButton = self:GetName() - LootFrame.selectedTexture = self.icon:GetTexture() - if IsModifiedClick() then - HandleModifiedItemClick(GetLootSlotLink(self:GetID())) - else - StaticPopup_Hide("CONFIRM_LOOT_DISTRIBUTION") - lastID = self:GetID() - lastQuality = self.quality; - lastName = self.name:GetText() - LootSlot(lastID) - end -end - -local LootSlot_OnShow = function(self) - if GameTooltip:IsOwned(self) then - GameTooltip:SetOwner(self, "ANCHOR_RIGHT") - GameTooltip:SetLootItem(self:GetID()) - CursorOnUpdate(self) - end -end - -local function HandleSlots(frame) - local scale = 30; - local counter = 0; - for i = 1, #frame.slots do - local slot = frame.slots[i] - if slot:IsShown() then - counter = counter + 1; - slot:Point("TOP", SVUI_LootFrame, 4, (-8 + scale) - (counter * scale)) - end - end - frame:Height(max(counter * scale + 16, 20)) -end - -local function MakeSlots(id) - local size = LOOT_HEIGHT; - local slot = CreateFrame("Button", "SVUI_LootSlot"..id, SVUI_LootFrame) - slot:Point("LEFT", 8, 0) - slot:Point("RIGHT", -8, 0) - slot:Height(size) - slot:SetID(id) - slot:RegisterForClicks("LeftButtonUp", "RightButtonUp") - slot:SetScript("OnEnter", LootSlot_OnEnter) - slot:SetScript("OnLeave", LootSlot_OnLeave) - slot:SetScript("OnClick", LootSlot_OnClick) - slot:SetScript("OnShow", LootSlot_OnShow) - - slot.iconFrame = CreateFrame("Frame", nil, slot) - slot.iconFrame:Height(size) - slot.iconFrame:Width(size) - slot.iconFrame:SetPoint("RIGHT", slot) - slot.iconFrame:SetFixedPanelTemplate("Default") - - slot.icon = slot.iconFrame:CreateTexture(nil, "ARTWORK") - slot.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9) - slot.icon:FillInner() - - slot.count = slot.iconFrame:CreateFontString(nil, "OVERLAY") - slot.count:SetJustifyH("RIGHT") - slot.count:Point("BOTTOMRIGHT", slot.iconFrame, -2, 2) - slot.count:SetFont(SuperVillain.Shared:Fetch("font", "Roboto"), 12, "OUTLINE") - slot.count:SetText(1) - - slot.name = slot:CreateFontString(nil, "OVERLAY") - slot.name:SetJustifyH("LEFT") - slot.name:SetPoint("LEFT", slot) - slot.name:SetPoint("RIGHT", slot.icon, "LEFT") - slot.name:SetNonSpaceWrap(true) - slot.name:SetFont(SuperVillain.Shared:Fetch("font", "Roboto"), 12, "OUTLINE") - - slot.drop = slot:CreateTexture(nil, "ARTWORK") - slot.drop:SetTexture("Interface\\QuestFrame\\UI-QuestLogTitleHighlight") - slot.drop:SetPoint("LEFT", slot.icon, "RIGHT", 0, 0) - slot.drop:SetPoint("RIGHT", slot) - slot.drop:SetAllPoints(slot) - slot.drop:SetAlpha(.3) - - slot.questTexture = slot.iconFrame:CreateTexture(nil, "OVERLAY") - slot.questTexture:FillInner() - slot.questTexture:SetTexture(TEXTURE_ITEM_QUEST_BANG) - slot.questTexture:SetTexCoord(0.1, 0.9, 0.1, 0.9) - - SVUI_LootFrame.slots[id] = slot; - return slot -end - -local function CreateRollButton(rollFrame, type, locale, anchor) - local preset = RollTypePresets[type]; - local rollButton = CreateFrame("Button", nil, rollFrame) - rollButton:Point("LEFT", anchor, "RIGHT", tonumber(preset[4]), tonumber(preset[5])) - rollButton:Size(LOOT_HEIGHT - 4) - rollButton:SetNormalTexture(preset[1]) - if preset[2] and preset[2] ~= "" then - rollButton:SetPushedTexture(preset[2]) - end - rollButton:SetHighlightTexture(preset[3]) - rollButton.rolltype = type; - rollButton.parent = rollFrame; - rollButton.tiptext = locale; - rollButton:SetScript("OnEnter", LootRoll_SetTooltip) - rollButton:SetScript("OnLeave", HideItemTip) - rollButton:SetScript("OnClick", DoDaRoll) - rollButton:SetMotionScriptsWhileDisabled(true) - local text = rollButton:CreateFontString(nil, nil) - text:SetFont(SuperVillain.Shared:Fetch("font", "Roboto"),14,"OUTLINE") - text:Point("CENTER", 0, ((type == 2 and 1) or (type == 0 and -1.2) or 0)) - return rollButton, text -end - -local function CreateRollFrame() - UpdateLootUpvalues() - local rollFrame = CreateFrame("Frame",nil,SuperVillain.UIParent) - rollFrame:Size(LOOT_WIDTH,LOOT_HEIGHT) - rollFrame:SetFixedPanelTemplate('Default') - rollFrame:SetScript("OnEvent",LootRoll_OnEvent) - rollFrame:RegisterEvent("CANCEL_LOOT_ROLL") - rollFrame:Hide() - rollFrame.button = CreateFrame("Button",nil,rollFrame) - rollFrame.button:Point("RIGHT",rollFrame,'LEFT',0,0) - rollFrame.button:Size(LOOT_HEIGHT - 2) - rollFrame.button:SetPanelTemplate('Default') - rollFrame.button:SetScript("OnEnter",LootItem_SetTooltip) - rollFrame.button:SetScript("OnLeave",HideRollTip) - rollFrame.button:SetScript("OnUpdate",LootItem_OnUpdate) - rollFrame.button:SetScript("OnClick",LootRoll_OnClick) - rollFrame.button.icon = rollFrame.button:CreateTexture(nil,'OVERLAY') - rollFrame.button.icon:SetAllPoints() - rollFrame.button.icon:SetTexCoord(0.1,0.9,0.1,0.9 ) - local border = rollFrame:CreateTexture(nil,"BORDER") - border:Point("TOPLEFT",rollFrame,"TOPLEFT",4,0) - border:Point("BOTTOMRIGHT",rollFrame,"BOTTOMRIGHT",-4,0) - border:SetTexture("Interface\\ChatFrame\\ChatFrameBackground") - border:SetBlendMode("ADD") - border:SetGradientAlpha("VERTICAL",.1,.1,.1,0,.1,.1,.1,0) - rollFrame.status=CreateFrame("StatusBar",nil,rollFrame) - rollFrame.status:FillInner() - rollFrame.status:SetScript("OnUpdate",LootRoll_OnUpdate) - rollFrame.status:SetFrameLevel(rollFrame.status:GetFrameLevel() - 1) - rollFrame.status:SetStatusBarTexture([[Interface\AddOns\SVUI\assets\artwork\Template\DEFAULT]]) - rollFrame.status:SetStatusBarColor(.8,.8,.8,.9) - rollFrame.status.parent = rollFrame; - rollFrame.status.bg = rollFrame.status:CreateTexture(nil,'BACKGROUND') - rollFrame.status.bg:SetAlpha(0.1) - rollFrame.status.bg:SetAllPoints() - rollFrame.status.bg:SetDrawLayer('BACKGROUND',2) - rollFrame.status.spark = rollFrame:CreateTexture(nil,"OVERLAY") - rollFrame.status.spark:Size(LOOT_HEIGHT * 0.5, LOOT_HEIGHT) - rollFrame.status.spark:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark") - rollFrame.status.spark:SetBlendMode("ADD") - - local needButton,needText = CreateRollButton(rollFrame,1,NEED,rollFrame.button) - local greedButton,greedText = CreateRollButton(rollFrame,2,GREED,needButton,"RIGHT") - local deButton,deText = CreateRollButton(rollFrame,3,ROLL_DISENCHANT,greedButton) - local passButton,passText = CreateRollButton(rollFrame,0,PASS,deButton or greedButton) - rollFrame.NeedIt,rollFrame.WantIt,rollFrame.BreakIt = needButton,greedButton,deButton; - rollFrame.need,rollFrame.greed,rollFrame.pass,rollFrame.disenchant = needText,greedText,passText,deText; - rollFrame.bindText = rollFrame:CreateFontString() - rollFrame.bindText:Point("LEFT",passButton,"RIGHT",3,1) - rollFrame.bindText:SetFont(SuperVillain.Shared:Fetch("font", "SVUI Number Font"),14,"OUTLINE") - rollFrame.lootText = rollFrame:CreateFontString(nil,"ARTWORK") - rollFrame.lootText:SetFont(SuperVillain.Shared:Fetch("font", "SVUI Number Font"),14,"OUTLINE") - rollFrame.lootText:Point("LEFT",rollFrame.bindText,"RIGHT",0,0) - rollFrame.lootText:Point("RIGHT",rollFrame,"RIGHT",-5,0) - rollFrame.lootText:Size(200,10) - rollFrame.lootText:SetJustifyH("LEFT") - - rollFrame.yourRoll = rollFrame:CreateFontString(nil,"ARTWORK") - rollFrame.yourRoll:SetFont(SuperVillain.Shared:Fetch("font", "SVUI Number Font"),18,"OUTLINE") - rollFrame.yourRoll:Size(22,22) - rollFrame.yourRoll:Point("LEFT",rollFrame,"RIGHT",5,0) - rollFrame.yourRoll:SetJustifyH("CENTER") - - rollFrame.rolls = {} - return rollFrame -end ---[[ -########################################################## -CORE FUNCTIONS -########################################################## -]]-- -local AutoConfirmLoot = function(_, event, ...) - if event == 'CONFIRM_LOOT_ROLL' or event == 'CONFIRM_DISENCHANT_ROLL' then - local arg1, arg2 = ... - ConfirmLootRoll(arg1, arg2) - elseif event == 'LOOT_OPENED' or event == 'LOOT_BIND_CONFIRM' then - local count = GetNumLootItems() - if count == 0 then CloseLoot() return end - for slot = 1, count do - ConfirmLootSlot(slot) - end - end -end - -local LootSimpleEventsHandler = function(_, event, slot) - if(event == 'LOOT_SLOT_CLEARED') then - if not SVUI_LootFrame:IsShown() then return; end - SVUI_LootFrame.slots[slot]:Hide() - HandleSlots(SVUI_LootFrame) - elseif(event == 'LOOT_CLOSED') then - StaticPopup_Hide("LOOT_BIND") - SVUI_LootFrame:Hide() - for _,slot in pairs(SVUI_LootFrame.slots)do - slot:Hide() - end - elseif(event == 'OPEN_MASTER_LOOT_LIST') then - ToggleDropDownMenu(1, nil, GroupLootDropDown, SVUI_LootFrame.slots[lastID], 0, 0) - elseif(event == 'UPDATE_MASTER_LOOT_LIST') then - MasterLooterFrame_UpdatePlayers() - end -end - -local OpenedLootHandler = function(_, event, autoLoot) - SVUI_LootFrame:Show() - if not SVUI_LootFrame:IsShown() then CloseLoot(autoLoot == 0) end - local drops = GetNumLootItems() - if IsFishingLoot() then - SVUI_LootFrame.title:SetText(L["Fishy Loot"]) - elseif not UnitIsFriend("player", "target") and UnitIsDead"target" then - SVUI_LootFrame.title:SetText(UnitName("target")) - else - SVUI_LootFrame.title:SetText(LOOT) - end - - if GetCVar("lootUnderMouse") == "1" then - local cursorX,cursorY = GetCursorPosition() - cursorX = cursorX / SVUI_LootFrame:GetEffectiveScale() - cursorY = (cursorY / (SVUI_LootFrame:GetEffectiveScale())); - SVUI_LootFrame:ClearAllPoints() - SVUI_LootFrame:Point("TOPLEFT", nil, "BOTTOMLEFT", cursorX - 40, cursorY + 20) - SVUI_LootFrame:GetCenter() - SVUI_LootFrame:Raise() - else - SVUI_LootFrame:ClearAllPoints() - SVUI_LootFrame:SetPoint("TOPLEFT", SVUI_LootFrameHolder, "TOPLEFT") - end - - local iQuality, nameWidth, titleWidth = 0, 0, SVUI_LootFrame.title:GetStringWidth() - UpdateLootUpvalues() - if drops > 0 then - for i = 1, drops do - local slot = SVUI_LootFrame.slots[i] or MakeSlots(i) - local texture, item, quantity, quality, locked, isQuestItem, questId, isActive = GetLootSlotInfo(i) - local color = ITEM_QUALITY_COLORS[quality] - if texture and texture:find("INV_Misc_Coin") then - item = item:gsub("\n", ", ") - end - if quantity and quantity > 1 then - slot.count:SetText(quantity) - slot.count:Show() - else - slot.count:Hide() - end - if quality and quality > 1 then - slot.drop:SetVertexColor(color.r, color.g, color.b) - slot.drop:Show() - else - slot.drop:Hide() - end - slot.quality = quality; - slot.name:SetText(item) - if color then - slot.name:SetTextColor(color.r, color.g, color.b) - end - slot.icon:SetTexture(texture) - if quality then - iQuality = max(iQuality, quality) - end - nameWidth = max(nameWidth, slot.name:GetStringWidth()) - local qTex = slot.questTexture; - if questId and not isActive then - qTex:Show() - ActionButton_ShowOverlayGlow(slot.iconFrame) - elseif questId or isQuestItem then - qTex:Hide() - ActionButton_ShowOverlayGlow(slot.iconFrame) - else - qTex:Hide() - ActionButton_HideOverlayGlow(slot.iconFrame) - end - slot:Enable() - slot:Show() - ConfirmLootSlot(i) - end - else - local slot = SVUI_LootFrame.slots[1] or MakeSlots(1) - local color = ITEM_QUALITY_COLORS[0] - slot.name:SetText(L["Empty Slot"]) - if color then - slot.name:SetTextColor(color.r, color.g, color.b) - end - slot.icon:SetTexture[[Interface\Icons\INV_Misc_Herb_AncientLichen]] - drops = 1; - nameWidth = max(nameWidth, slot.name:GetStringWidth()) - slot.count:Hide() - slot.drop:Hide() - slot:Disable() - slot:Show() - end - - HandleSlots(SVUI_LootFrame) - nameWidth = nameWidth + 60; - titleWidth = titleWidth + 5; - local color = ITEM_QUALITY_COLORS[iQuality] - SVUI_LootFrame:SetBackdropBorderColor(color.r, color.g, color.b, .8) - SVUI_LootFrame:Width(max(nameWidth, titleWidth)) -end - -local function rollz() - for _,roll in ipairs(MOD.LewtRollz)do - if not roll.rollID then - return roll - end - end - local roll = CreateRollFrame() - roll:Point("TOP", next(MOD.LewtRollz) and MOD.LewtRollz[#MOD.LewtRollz] or SVUI_AlertFrame, "BOTTOM", 0, -4); - tinsert(MOD.LewtRollz, roll) - return roll -end - -local LootComplexEventsHandler = function(_, event, arg1, arg2) - if(event == "START_LOOT_ROLL") then - if dead_rollz[arg1] then return end - local texture,name,count,quality,bindOnPickUp,canNeed,canGreed,canBreak = GetLootRollItemInfo(arg1); - local color = ITEM_QUALITY_COLORS[quality]; - local rollFrame = rollz(); - rollFrame.rollID = arg1; - rollFrame.time = arg2; - for i in pairs(rollFrame.rolls)do - rollFrame.rolls[i] = nil - end - rollFrame.need:SetText(0) - rollFrame.greed:SetText(0) - rollFrame.pass:SetText(0) - rollFrame.disenchant:SetText(0) - rollFrame.button.icon:SetTexture(texture) - rollFrame.button.link = GetLootRollItemLink(arg1) - if canNeed then - rollFrame.NeedIt:Enable() - rollFrame.NeedIt:SetAlpha(1) - else - rollFrame.NeedIt:SetAlpha(0.2) - rollFrame.NeedIt:Disable() - end - if canGreed then - rollFrame.WantIt:Enable() - rollFrame.WantIt:SetAlpha(1) - else - rollFrame.WantIt:SetAlpha(0.2) - rollFrame.WantIt:Disable() - end - if canBreak then - rollFrame.BreakIt:Enable() - rollFrame.BreakIt:SetAlpha(1) - else - rollFrame.BreakIt:SetAlpha(0.2) - rollFrame.BreakIt:Disable() - end - SetDesaturation(rollFrame.NeedIt:GetNormalTexture(),not canNeed) - SetDesaturation(rollFrame.WantIt:GetNormalTexture(),not canGreed) - SetDesaturation(rollFrame.BreakIt:GetNormalTexture(),not canBreak) - rollFrame.bindText:SetText(bindOnPickUp and "BoP" or "BoE") - rollFrame.bindText:SetVertexColor(bindOnPickUp and 1 or 0.3, bindOnPickUp and 0.3 or 1, bindOnPickUp and 0.1 or 0.3) - rollFrame.lootText:SetText(name) - rollFrame.yourRoll:SetText("") - rollFrame.status:SetStatusBarColor(color.r,color.g,color.b,0.7) - rollFrame.status.bg:SetTexture(color.r,color.g,color.b) - rollFrame.status:SetMinMaxValues(0,arg2) - rollFrame.status:SetValue(arg2) - rollFrame:SetPoint("CENTER",WorldFrame,"CENTER") - rollFrame:Show() - AlertFrame_FixAnchors() - if SuperVillain.db.SVHenchmen.autoRoll and UnitLevel('player') == MAX_PLAYER_LEVEL and quality == 2 and not bindOnPickUp then - if canBreak then - RollOnLoot(arg1,3) - else - RollOnLoot(arg1,2) - end - end - elseif(event == "LOOT_HISTORY_ROLL_CHANGED") then - local rollID,_,_,_,_,_ = C_LootHistory.GetItem(arg1); - local name,_,rollType,rollResult,_ = C_LootHistory.GetPlayerInfo(arg1,arg2); - if name and rollType then - for _,roll in ipairs(MOD.LewtRollz)do - if roll.rollID == rollID then - roll.rolls[name] = rollType; - roll[LootRollType[rollType]]:SetText(tonumber(roll[LootRollType[rollType]]:GetText()) + 1); - return - end - if rollResult then - roll.yourRoll:SetText(tostring(rollResult)) - end - end - end - end -end - -local GroupLootDropDown_GiveLoot = function(self) - if lastQuality >= MASTER_LOOT_THREHOLD then - local confirmed = SuperVillain:StaticPopup_Show("CONFIRM_LOOT_DISTRIBUTION",ITEM_QUALITY_COLORS[lastQuality].hex..lastName..FONT_COLOR_CODE_CLOSE,self:GetText()); - if confirmed then confirmed.data = self.value end - else - GiveMasterLoot(lastID, self.value) - end - CloseDropDownMenus() - SuperVillain.SystemAlert["CONFIRM_LOOT_DISTRIBUTION"].OnAccept = function(self,index) GiveMasterLoot(lastID,index) end -end - -function MOD:OverrideLootFrame() - LootFrame:UnregisterAllEvents(); - SVUI_LootFrame:SetFixedPanelTemplate('Transparent'); - SVUI_LootFrame.title:SetFont(SuperVillain.Shared:Fetch("font", "SVUI Number Font"),18,"OUTLINE") - SuperVillain:SetSVMovable(SVUI_LootFrameHolder, L["Loot Frame"], nil, nil, nil, nil, "SVUI_LootFrame"); - tinsert(UISpecialFrames, "SVUI_LootFrame"); - - UIParent:UnregisterEvent("LOOT_BIND_CONFIRM") - UIParent:UnregisterEvent("CONFIRM_DISENCHANT_ROLL") - UIParent:UnregisterEvent("CONFIRM_LOOT_ROLL") - self:RegisterEvent("CONFIRM_DISENCHANT_ROLL", AutoConfirmLoot) - self:RegisterEvent("CONFIRM_LOOT_ROLL", AutoConfirmLoot) - self:RegisterEvent("LOOT_BIND_CONFIRM", AutoConfirmLoot) - self:RegisterEvent("LOOT_OPENED", OpenedLootHandler); - self:RegisterEvent("LOOT_SLOT_CLEARED", LootSimpleEventsHandler); - self:RegisterEvent("LOOT_CLOSED", LootSimpleEventsHandler); - self:RegisterEvent("OPEN_MASTER_LOOT_LIST", LootSimpleEventsHandler); - self:RegisterEvent("UPDATE_MASTER_LOOT_LIST", LootSimpleEventsHandler); - if SuperVillain.db.SVOverride.lootRoll then - self:RegisterEvent("LOOT_HISTORY_ROLL_CHANGED", LootComplexEventsHandler); - self:RegisterEvent("START_LOOT_ROLL", LootComplexEventsHandler); - UIParent:UnregisterEvent("START_LOOT_ROLL"); - UIParent:UnregisterEvent("CANCEL_LOOT_ROLL"); - end - - _G.GroupLootDropDown_GiveLoot = GroupLootDropDown_GiveLoot -end \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/override/common/mirror.lua b/Interface/AddOns/SVUI/packages/override/common/mirror.lua deleted file mode 100644 index 76d6a17..0000000 --- a/Interface/AddOns/SVUI/packages/override/common/mirror.lua +++ /dev/null @@ -1,180 +0,0 @@ ---[[ -############################################################################## -_____/\\\\\\\\\\\____/\\\________/\\\__/\\\________/\\\__/\\\\\\\\\\\_ # - ___/\\\/////////\\\_\/\\\_______\/\\\_\/\\\_______\/\\\_\/////\\\///__ # - __\//\\\______\///__\//\\\______/\\\__\/\\\_______\/\\\_____\/\\\_____ # - ___\////\\\__________\//\\\____/\\\___\/\\\_______\/\\\_____\/\\\_____ # - ______\////\\\________\//\\\__/\\\____\/\\\_______\/\\\_____\/\\\_____ # - _________\////\\\______\//\\\/\\\_____\/\\\_______\/\\\_____\/\\\_____ # - __/\\\______\//\\\______\//\\\\\______\//\\\______/\\\______\/\\\_____ # - _\///\\\\\\\\\\\/________\//\\\________\///\\\\\\\\\/____/\\\\\\\\\\\_# - ___\///////////___________\///___________\/////////_____\///////////_# -############################################################################## -S U P E R - V I L L A I N - U I By: Munglunch # -############################################################################## -########################################################## -LOCALIZED LUA FUNCTIONS -########################################################## -]]-- ---[[ GLOBALS ]]-- -local _G = _G; -local unpack = _G.unpack; -local select = _G.select; -local pairs = _G.pairs; -local tonumber = _G.tonumber; -local tinsert = _G.tinsert; -local string = _G.string; -local math = _G.math; ---[[ STRING METHODS ]]-- -local find, format, len, split = string.find, string.format, string.len, string.split; ---[[ MATH METHODS ]]-- -local abs, ceil, floor, round = math.abs, math.ceil, math.floor, math.round; ---[[ -########################################################## -GET ADDON DATA -########################################################## -]]-- -local SuperVillain, L = unpack(select(2, ...)); -local MOD = SuperVillain.Registry:Expose('SVOverride'); ---[[ -########################################################## -LOCAL VARS -########################################################## -]]-- -local mirrorYOffset={ - ["BREATH"] = 96, - ["EXHAUSTION"] = 119, - ["FEIGNDEATH"] = 142 -} -local mirrorTypeColor={ - EXHAUSTION = {1,.9,0}, - BREATH = {0.31,0.45,0.63}, - DEATH = {1,.7,0}, - FEIGNDEATH = {1,.7,0} -} -local RegisteredMirrorBars={} ---[[ -########################################################## -PRE VARS/FUNCTIONS -########################################################## -]]-- -local SetMirrorPosition = function(bar) - local yOffset = mirrorYOffset[bar.type] - return bar:Point("TOP", SuperVillain.UIParent, "TOP", 0, -yOffset) -end; - -local MirrorBar_OnUpdate = function(self, elapsed) - if self.paused then - return - end; - self.lastupdate = (self.lastupdate or 0) + elapsed; - if self.lastupdate < .1 then - return - end; - self.lastupdate = 0; - self:SetValue(GetMirrorTimerProgress(self.type) / 1e3) -end; - -local MirrorBar_Start = function(self, min, max, s, t, text) - if t > 0 then - self.paused = 1 - elseif self.paused then - self.paused = nil - end; - self.text:SetText(text) - self:SetMinMaxValues(0, max / 1e3) - self:SetValue(min / 1e3) - if not self:IsShown() then - self:Show() - end -end; - - -local function MirrorBarRegistry(barType) - if RegisteredMirrorBars[barType] then - return RegisteredMirrorBars[barType] - end; - local bar = CreateFrame('StatusBar', nil, SuperVillain.UIParent) - bar:SetPanelTemplate("Bar", false, 3, 3, 3) - bar:SetScript("OnUpdate", MirrorBar_OnUpdate) - local r, g, b = unpack(mirrorTypeColor[barType]) - bar.text = bar:CreateFontString(nil, 'OVERLAY') - bar.text:SetFontTemplate(SuperVillain.Media.font.roboto, 12, 'OUTLINE') - bar.text:SetJustifyH('CENTER') - bar.text:SetTextColor(1, 1, 1) - bar.text:SetPoint('LEFT', bar) - bar.text:SetPoint('RIGHT', bar) - bar.text:Point('TOP', bar, 0, 2) - bar.text:SetPoint('BOTTOM', bar) - bar:Size(222, 18) - bar:SetStatusBarTexture([[Interface\AddOns\SVUI\assets\artwork\Template\DEFAULT]]) - bar:SetStatusBarColor(r, g, b) - bar.type = barType; - bar.Start = MirrorBar_Start; - bar.Stop = Stop; - SetMirrorPosition(bar) - RegisteredMirrorBars[barType] = bar; - return bar -end; - -local function SetTimerStyle(bar) - for i=1, bar:GetNumRegions()do - local child = select(i, bar:GetRegions()) - if child:GetObjectType() == "Texture"then - child:SetTexture(nil) - elseif child:GetObjectType() == "FontString" then - child:SetFontTemplate(SuperVillain.Media.font.roboto, 12, 'OUTLINE') - end - end; - bar:SetStatusBarTexture([[Interface\AddOns\SVUI\assets\artwork\Template\DEFAULT]]) - bar:SetStatusBarColor(0.37, 0.92, 0.08) - bar:SetPanelTemplate("Bar", false, 3, 3, 3) -end; ---[[ -########################################################## -CORE FUNCTIONS -########################################################## -]]-- -local MirrorBarToggleHandler = function(_, event, arg, ...) - if(event == "START_TIMER") then - for _,timer in pairs(TimerTracker.timerList)do - if timer["bar"] and not timer["bar"].styled then - SetTimerStyle(timer["bar"]) - timer["bar"].styled = true - end - end - elseif(event == "MIRROR_TIMER_START") then - return MirrorBarRegistry(arg):Start(...) - elseif(event == "MIRROR_TIMER_STOP") then - return MirrorBarRegistry(arg):Hide() - elseif(event == "MIRROR_TIMER_PAUSE") then - local pausedValue = (arg > 0 and arg or nil); - for barType,bar in next,RegisteredMirrorBars do - bar.paused = pausedValue; - end - end -end - -local MirrorBarUpdateHandler = function(_, event) - if not GetCVarBool("lockActionBars") and SuperVillain.db.SVBar.enable then - SetCVar("lockActionBars", 1) - end - if(event == "PLAYER_ENTERING_WORLD") then - for i = 1, MIRRORTIMER_NUMTIMERS do - local v, q, r, s, t, u = GetMirrorTimerInfo(i) - if v ~= "UNKNOWN"then - MirrorBarRegistry(v):Start(q, r, s, t, u) - end - end - end -end - -function MOD:OverrideMirrorBars() - UIParent:UnregisterEvent("MIRROR_TIMER_START") - self:RegisterEvent("CVAR_UPDATE", MirrorBarUpdateHandler) - self:RegisterEvent("PLAYER_ENTERING_WORLD", MirrorBarUpdateHandler) - self:RegisterEvent("MIRROR_TIMER_START", MirrorBarToggleHandler) - self:RegisterEvent("MIRROR_TIMER_STOP", MirrorBarToggleHandler) - self:RegisterEvent("MIRROR_TIMER_PAUSE", MirrorBarToggleHandler) - self:RegisterEvent("START_TIMER", MirrorBarToggleHandler) -end \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/plates/SVPlate.lua b/Interface/AddOns/SVUI/packages/plates/SVPlate.lua index c906693..1d3a50e 100644 --- a/Interface/AddOns/SVUI/packages/plates/SVPlate.lua +++ b/Interface/AddOns/SVUI/packages/plates/SVPlate.lua @@ -140,12 +140,28 @@ local AuraFSize = 10; local AuraFOutline = "MONOCHROME"; local AuraMaxCount = 5; +local AuraFont = SuperVillain.Media.font.numbers; +local AuraFSize = 7; +local AuraFOutline = "OUTLINE"; +local AuraFilterName, AuraFilter; +local AuraMaxCount = 5; + local BlockedPlates = { ["Army of the Dead Ghoul"] = true, ["Venomous Snake"] = true, ["Healing Tide Totem"] = true, ["Dragonmaw War Banner"] = true }; +local RIconData = {["STAR"] = 0x00000001, ["CIRCLE"] = 0x00000002, ["DIAMOND"] = 0x00000004, ["TRIANGLE"] = 0x00000008, ["MOON"] = 0x00000010, ["SQUARE"] = 0x00000020, ["CROSS"] = 0x00000040, ["SKULL"] = 0x00000080}; +local RIconNames = {"STAR", "CIRCLE", "DIAMOND", "TRIANGLE", "MOON", "SQUARE", "CROSS", "SKULL"} +local UnitPlateAuras = {}; +local AuraByRaidIcon = {}; +local AuraByName = {}; +local CachedAuraDurations = {}; +local AurasCache = {}; +local AuraClocks = {}; +local ClockIsTicking = false; +local TickTock = 0; --[[ ########################################################## UTILITY FRAMES @@ -153,6 +169,7 @@ UTILITY FRAMES ]]-- local NPGrip = _G.SVUI_PlateParentFrame local NPGlow = _G.SVUI_PlateGlowFrame +local AuraClockManager = CreateFrame("Frame") --[[ ########################################################## PRE VARS/FUNCTIONS @@ -335,6 +352,251 @@ local function CheckRaidIcon(plate) end --[[ ########################################################## +AURA HELPERS +########################################################## +]]-- +local ClockUpdateHandler = function(self, elapsed) + local curTime = GetTime() + if curTime < TickTock then return end + local deactivate = true; + TickTock = curTime + 0.1 + for frame, expiration in pairs(AuraClocks) do + local calc = 0; + local expires = expiration - curTime; + if expiration < curTime then + frame:Hide(); + AuraClocks[frame] = nil + else + if expires < 60 then + calc = floor(expires) + if expires >= 4 then + frame.TimeLeft:SetFormattedText("|cffffff00%d|r", calc) + elseif expires >= 1 then + frame.TimeLeft:SetFormattedText("|cffff0000%d|r", calc) + else + frame.TimeLeft:SetFormattedText("|cffff0000%.1f|r", expires) + end + elseif expires < 3600 then + calc = ceil(expires / 60); + frame.TimeLeft:SetFormattedText("|cffffffff%.1f|r", calc) + elseif expires < 86400 then + calc = ceil(expires / 3600); + frame.TimeLeft:SetFormattedText("|cff66ffff%.1f|r", calc) + else + calc = ceil(expires / 86400); + frame.TimeLeft:SetFormattedText("|cff6666ff%.1f|r", calc) + end + deactivate = false + end + end + if deactivate then + self:SetScript("OnUpdate", nil); + ClockIsTicking = false + end +end + +local function RegisterAuraClock(frame, expiration) + if(not frame) then return end + if expiration == 0 then + frame:Hide() + AuraClocks[frame] = nil + else + AuraClocks[frame] = expiration + frame:Show() + if(not ClockIsTicking) then + AuraClockManager:SetScript("OnUpdate", ClockUpdateHandler) + ClockIsTicking = true + end + end +end + +local function GetUnitPlateAuras(guid) + if guid and UnitPlateAuras[guid] then return UnitPlateAuras[guid] end +end + +local function SetAuraInstance(guid, spellID, expiration, stacks, caster, duration, texture) + if(spellID == 65148) then return end + local filter = true; + if (caster == UnitGUID('player')) then + filter = nil; + end + if AuraFilterName and AuraFilter then + local name = GetSpellInfo(spellID) + if AuraFilterName == 'Blocked' then + if AuraFilter[name] and AuraFilter[name].enable then + filter = true; + end + elseif AuraFilterName == 'Strict' then + if AuraFilter[name].spellID and not AuraFilter[name].spellID == spellID then + filter = true; + end + else + if AuraFilter[name] and AuraFilter[name].enable then + filter = nil; + end + end + end + if(not filter and (guid and spellID and caster and texture)) then + local auraID = spellID..(tostring(caster or "UNKNOWN_CASTER")) + UnitPlateAuras[guid] = UnitPlateAuras[guid] or {} + UnitPlateAuras[guid][auraID] = { + spellID = spellID, + expiration = expiration or 0, + stacks = stacks, + duration = duration, + texture = texture + } + end +end + +local function UpdateAuraIcon(aura, texture, expiration, stacks, test) + if aura and texture and expiration then + aura.Icon:SetTexture(texture) + if stacks > 1 then + aura.Stacks:SetText(stacks) + else + aura.Stacks:SetText("") + end + aura:Show() + RegisterAuraClock(aura, expiration) + else + RegisterAuraClock(aura, 0) + end +end + +local function SortExpires(t) + tsort(t, function(a,b) return a.expiration < b.expiration end) + return t +end + +local function UpdateAuraIconGrid(plate) + local frame = plate.frame; + local guid = plate.guid; + local iconCache = frame.auraicons; + local AurasOnUnit = GetUnitPlateAuras(guid); + local AuraSlotIndex = 1; + local auraID; + if AurasOnUnit then + frame.auras:Show() + local auraCount = 1 + for auraID,aura in pairs(AurasOnUnit) do + if tonumber(aura.spellID) then + aura.name = GetSpellInfo(tonumber(aura.spellID)) + aura.unit = plate.unit + if(aura.expiration > GetTime()) then + AurasCache[auraCount] = aura + auraCount = auraCount + 1 + end + end + end + end + AurasCache = SortExpires(AurasCache) + for index = 1, #AurasCache do + local cachedaura = AurasCache[index] + local gridaura = iconCache[AuraSlotIndex] + if gridaura and cachedaura.spellID and cachedaura.expiration then + UpdateAuraIcon(gridaura, cachedaura.texture, cachedaura.expiration, cachedaura.stacks) + AuraSlotIndex = AuraSlotIndex + 1 + end + if(AuraSlotIndex > AuraMaxCount) then + break + end + end + if(iconCache[AuraSlotIndex]) then + RegisterAuraClock(iconCache[AuraSlotIndex], 0) + end + twipe(AurasCache) +end + +local function LoadDuration(spellID) + if spellID then + return CachedAuraDurations[spellID] or 0 + end + return 0 +end + +local function SaveDuration(spellID, duration) + duration = duration or 0 + if spellID then CachedAuraDurations[spellID] = duration end +end + +local function CleanUnitPlateAurass() + local currentTime = GetTime() + for guid, instanceList in pairs(UnitPlateAuras) do + local auracount = 0 + for auraID, instanceID in pairs(instanceList) do + local expiration = Aura_Expiration[instanceID] + if expiration and expiration < currentTime then + UnitPlateAuras[guid][auraID] = nil + else + auracount = auracount + 1 + end + end + if auracount == 0 then + UnitPlateAuras[guid] = nil + end + end +end + +function MOD:UpdateAuras(plate) + if plate.setting.tiny then return end; + local guid = plate.guid + local frame = plate.frame + if not guid then + if RAID_CLASS_COLORS[plate.setting.unitcategory] then + local pn = plate.name:GetText() + local name = pn:gsub("%s%(%*%)", "") + guid = AuraByName[name] + elseif plate.ref.raidicon:IsShown() then + guid = AuraByRaidIcon[plate.ref.raidicontype] + end + if guid then + plate.guid = guid + else + frame.auras:Hide() + return + end + end + UpdateAuraIconGrid(plate) + if(self.UseCombo) then + local numPoints = GetComboPoints(UnitHasVehicleUI("player") and "vehicle" or "player", "target") + for i = 1, MAX_COMBO_POINTS do + if(i <= numPoints) then + frame.combo[i]:Show() + else + frame.combo[i]:Hide() + end + end + end +end + +function MOD:UpdateAurasByUnitID(unitid) + local guid = UnitGUID(unitid) + if(guid and UnitPlateAuras[guid]) then + local auras = UnitPlateAuras[guid] + for auraID, _ in pairs(auras) do + UnitPlateAuras[guid][auraID] = nil + end + end + for i = 1, 40 do + local spellname , _, texture, count, dispelType, duration, expirationTime, unitCaster, _, _, spellid, _, isBossDebuff = UnitAura(unitid, i, "HARMFUL") + if(not spellname) then break end + SaveDuration(spellid, duration) + SetAuraInstance(guid, spellid, expirationTime, count, UnitGUID(unitCaster or ""), duration, texture) + end + local name; + if UnitPlayerControlled(unitid) then + name = UnitName(unitid) + AuraByName[name] = guid + end + local raidIcon = RIconNames[GetRaidTargetIndex(unitid) or ""]; + if(raidIcon) then + AuraByRaidIcon[raidIcon] = guid + end + self:RequestScanUpdate(guid, raidIcon, name, "UpdateAuras") +end +--[[ +########################################################## PLATE UPDATE HANDLERS ########################################################## ]]-- @@ -379,7 +641,7 @@ do end MOD:UpdateAurasByUnitID('target') if MOD.UseCombo then - MOD:UpdateComboPointsByUnitID('target') + MOD:UNIT_COMBO_POINTS("player") end PLATE_ARGS.allowed = nil end @@ -389,7 +651,7 @@ do SVUI_PLATE.highlight:Show() MOD:UpdateAurasByUnitID('mouseover') if MOD.UseCombo then - MOD:UpdateComboPointsByUnitID('mouseover') + MOD:UNIT_COMBO_POINTS("player") end PLATE_ARGS.allowed = nil end @@ -611,6 +873,34 @@ SCRIPT HANDLERS ########################################################## ]]-- do + local function CreateAuraIcon(auras, plate) + local noscalemult = 2 * UIParent:GetScale() + local button = CreateFrame("Frame", nil, auras) + button:SetScript('OnHide', function() + if plate.guid then + UpdateAuraIconGrid(plate) + end + end) + button.bord = button:CreateTexture(nil, "BACKGROUND") + button.bord:SetDrawLayer('BACKGROUND', 2) + button.bord:SetTexture(0,0,0,1) + button.bord:SetPoint("TOPLEFT", button, "TOPLEFT", -noscalemult, noscalemult) + button.bord:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", noscalemult, -noscalemult) + button.Icon = button:CreateTexture(nil, "BORDER") + button.Icon:SetPoint("TOPLEFT",button,"TOPLEFT") + button.Icon:SetPoint("BOTTOMRIGHT",button,"BOTTOMRIGHT") + button.Icon:SetTexCoord(.1, .9, .2, .8) + button.TimeLeft = button:CreateFontString(nil, 'OVERLAY') + button.TimeLeft:SetFont(AuraFont, AuraFSize, AuraFOutline) + button.TimeLeft:SetPoint("BOTTOMLEFT",button,"TOPLEFT",-3,-1) + button.TimeLeft:SetJustifyH('CENTER') + button.Stacks = button:CreateFontString(nil,"OVERLAY") + button.Stacks:SetFont(AuraFont, AuraFSize + 2, AuraFOutline) + button.Stacks:SetPoint("BOTTOMRIGHT",button,"BOTTOMRIGHT",3,-3) + button:Hide() + return button + end + local function HealthBarSizeChanged(self, width, height) if(not ProxyThisPlate(self.sync)) then return; end width = floor(width + 0.5) @@ -619,7 +909,7 @@ do local auraHeight = (auraWidth * 0.7) for index = 1, numAuras do if not PLATE_AURAICONS[index] then - PLATE_AURAICONS[index] = MOD:CreateAuraIcon(PLATE_AURAS, SVUI_PLATE); + PLATE_AURAICONS[index] = CreateAuraIcon(PLATE_AURAS, SVUI_PLATE); end PLATE_AURAICONS[index]:SetWidth(auraWidth) PLATE_AURAICONS[index]:SetHeight(auraHeight) @@ -632,7 +922,7 @@ do end if(numAuras > #PLATE_AURAICONS) then for index = (numAuras + 1), #PLATE_AURAICONS do - MOD.RegisterAuraClock(PLATE_AURAICONS[index], 0) + RegisterAuraClock(PLATE_AURAICONS[index], 0) end end end @@ -754,7 +1044,7 @@ do end if PLATE_AURAS then for index = 1, #PLATE_AURAICONS do - MOD.RegisterAuraClock(PLATE_AURAICONS[index], 0) + RegisterAuraClock(PLATE_AURAICONS[index], 0) end end if MOD.UseCombo then @@ -1008,7 +1298,6 @@ do function MOD:UpdateAllPlates() self:UpdateDataLocals() - self:UpdateAuraLocals() for plate, _ in pairs(VisiblePlates) do if(plate) then UpdateThisPlate(plate) @@ -1021,15 +1310,15 @@ end SCANNER ########################################################## ]]-- -do - local function ParseByGUID(guid) - for plate, _ in pairs(VisiblePlates) do - if plate and plate:IsShown() and plate.guid == guid then - return plate - end +local function ParseByGUID(guid) + for plate, _ in pairs(VisiblePlates) do + if plate and plate:IsShown() and plate.guid == guid then + return plate end end +end +do local function ParseByName(sourceName) if not sourceName then return; end local SearchFor = split("-", sourceName) @@ -1049,13 +1338,13 @@ do end end - function MOD:RequestScanUpdate(guid, raidIcon, name, callbackFunc) + function MOD:RequestScanUpdate(guid, raidIcon, name, callbackFunc, ...) local plate if guid then plate = ParseByGUID(guid) end if (not plate) and name then plate = ParseByName(name) end if (not plate) and raidIcon then plate = ParseByIconName(raidIcon) end if(plate) then - MOD[callbackFunc](MOD, plate) + MOD[callbackFunc](MOD, plate, ...) end end end @@ -1065,13 +1354,21 @@ EVENTS ########################################################## ]]-- function MOD:PLAYER_ENTERING_WORLD() - MOD:UpdateDataLocals(); + self:UpdateDataLocals(); end function MOD:UPDATE_MOUSEOVER_UNIT() WorldFrame.elapsed = 0.1 end +function MOD:PLAYER_REGEN_DISABLED() + SetCVar("nameplateShowEnemies", 1) +end + +function MOD:PLAYER_REGEN_ENABLED() + SetCVar("nameplateShowEnemies", 0) +end + function MOD:PLAYER_TARGET_CHANGED() if(UnitExists("target")) then CURRENT_TARGET_NAME = UnitName("target") @@ -1083,12 +1380,81 @@ function MOD:PLAYER_TARGET_CHANGED() end end -function MOD:PLAYER_REGEN_DISABLED() - SetCVar("nameplateShowEnemies", 1) +function MOD:UNIT_AURA(event, unit) + if(unit == "target" or unit == "focus") then + self:UpdateAurasByUnitID(unit) + end end -function MOD:PLAYER_REGEN_ENABLED() - SetCVar("nameplateShowEnemies", 0) +function MOD:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, combatevent, hideCaster, ...) + local _, sourceGUID, sourceName, destGUID, destName, destFlags, destRaidFlag, spellID, spellname + if(not destGUID or not spellID) then return end + if(combatevent == SPELL_AURA_APPLIED or combatevent == SPELL_AURA_REFRESH or combatevent == SPELL_AURA_APPLIED_DOSE or combatevent == SPELL_AURA_REMOVED_DOSE) then + sourceGUID, sourceName, _, _, destGUID, destName, destFlags, destRaidFlag, spellID, spellname = ... + local stackCount = 1 + local duration = LoadDuration(spellID) + local texture = GetSpellTexture(spellID) + if(combatevent == SPELL_AURA_APPLIED_DOSE or combatevent == SPELL_AURA_REMOVED_DOSE) then + stackCount = select(16, ...) + end + SetAuraInstance(destGUID, spellID, (GetTime() + duration), stackCount, sourceGUID, duration, texture) + elseif(combatevent == SPELL_AURA_BROKEN or combatevent == SPELL_AURA_BROKEN_SPELL or combatevent == SPELL_AURA_REMOVED) then + sourceGUID, sourceName, _, _, destGUID, destName, destFlags, destRaidFlag, spellID, spellname = ... + local auraID = spellID..(tostring(sourceName or "UNKNOWN_CASTER")) + if UnitPlateAuras[destGUID][auraID] then + UnitPlateAuras[destGUID][auraID] = nil + end + else + return + end + + local rawName, raidIcon + if(destName and (band(destFlags, COMBATLOG_OBJECT_CONTROL_PLAYER) > 0)) then + rawName = split("-", destName) + AuraByName[rawName] = destGUID + end + for iconName, bitmask in pairs(RIconData) do + if band(destRaidFlag, bitmask) > 0 then + raidIcon = iconName + AuraByRaidIcon[raidIcon] = destGUID + break + end + end + self:RequestScanUpdate(destGUID, raidIcon, rawName, "UpdateAuras") +end + +do + local LastKnownTarget; + + function MOD:UNIT_COMBO_POINTS(unit) + if(unit == "player" or unit == "vehicle") then + local guid = UnitGUID("target") + if (not guid) then return end + local numPoints = GetComboPoints(UnitHasVehicleUI('player') and 'vehicle' or 'player', 'target') + numPoints = numPoints or 0 + if(numPoints > 0) then + if(LastKnownTarget and LastKnownTarget.guid and LastKnownTarget.guid ~= guid) then + LastKnownTarget.frame.combo[1]:Hide() + LastKnownTarget.frame.combo[2]:Hide() + LastKnownTarget.frame.combo[3]:Hide() + LastKnownTarget.frame.combo[4]:Hide() + LastKnownTarget.frame.combo[5]:Hide() + LastKnownTarget = nil + end + end + local plate = ParseByGUID(guid) + if(plate) then + for i=1, MAX_COMBO_POINTS do + if(i <= numPoints) then + plate.frame.combo[i]:Show() + else + plate.frame.combo[i]:Hide() + end + end + LastKnownTarget = plate + end + end + end end --[[ ########################################################## @@ -1152,10 +1518,19 @@ function MOD:UpdateDataLocals() NPReactNeutral = {rc.neutral[1], rc.neutral[2], rc.neutral[3]} NPReactEnemy = {rc.enemy[1], rc.enemy[2], rc.enemy[3]} + AuraFont = SuperVillain.Shared:Fetch("font", db.auras.font); + AuraFSize = db.auras.fontSize; + AuraFOutline = db.auras.fontOutline; + AuraMaxCount = db.auras.numAuras; + AuraFilterName = db.auras.additionalFilter + AuraFilter = SuperVillain.Filters[AuraFilterName] + if (db.comboPoints and (SuperVillain.class == 'ROGUE' or SuperVillain.class == 'DRUID')) then MOD.UseCombo = true + self:RegisterEvent("UNIT_COMBO_POINTS") else MOD.UseCombo = false + self:UnregisterEvent("UNIT_COMBO_POINTS") end end @@ -1185,15 +1560,13 @@ end; function MOD:Load() if SuperVillain.db["SVPlate"].enable ~= true then return end - self.UseCombo = false; self:UpdateDataLocals() - WorldFrame:HookScript('OnUpdate', WorldFrameUpdateHook) self:RegisterEvent("PLAYER_ENTERING_WORLD") self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") self:RegisterEvent("UNIT_AURA") self:RegisterEvent("PLAYER_TARGET_CHANGED") self:RegisterEvent("UPDATE_MOUSEOVER_UNIT") - self:EnableTracking() + WorldFrame:HookScript('OnUpdate', WorldFrameUpdateHook) self:CombatToggle(true) end SuperVillain.Registry:NewPackage(MOD, "SVPlate") \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/plates/SVPlate.xml b/Interface/AddOns/SVUI/packages/plates/SVPlate.xml index 3cfdddb..9547082 100644 --- a/Interface/AddOns/SVUI/packages/plates/SVPlate.xml +++ b/Interface/AddOns/SVUI/packages/plates/SVPlate.xml @@ -22,5 +22,4 @@ </Frame> <Script file='SVPlate.lua'/> - <Include file='common\_load.xml'/> </Ui> \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/plates/common/_load.xml b/Interface/AddOns/SVUI/packages/plates/common/_load.xml deleted file mode 100644 index 03bf273..0000000 --- a/Interface/AddOns/SVUI/packages/plates/common/_load.xml +++ /dev/null @@ -1,4 +0,0 @@ -<Ui xmlns="http://www.blizzard.com/wow/ui/"> - <Script file='auras.lua'/> - <Script file='tracker.lua'/> -</Ui> \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/plates/common/auras.lua b/Interface/AddOns/SVUI/packages/plates/common/auras.lua deleted file mode 100644 index f576111..0000000 --- a/Interface/AddOns/SVUI/packages/plates/common/auras.lua +++ /dev/null @@ -1,517 +0,0 @@ ---[[ -############################################################################## -_____/\\\\\\\\\\\____/\\\________/\\\__/\\\________/\\\__/\\\\\\\\\\\_ # - ___/\\\/////////\\\_\/\\\_______\/\\\_\/\\\_______\/\\\_\/////\\\///__ # - __\//\\\______\///__\//\\\______/\\\__\/\\\_______\/\\\_____\/\\\_____ # - ___\////\\\__________\//\\\____/\\\___\/\\\_______\/\\\_____\/\\\_____ # - ______\////\\\________\//\\\__/\\\____\/\\\_______\/\\\_____\/\\\_____ # - _________\////\\\______\//\\\/\\\_____\/\\\_______\/\\\_____\/\\\_____ # - __/\\\______\//\\\______\//\\\\\______\//\\\______/\\\______\/\\\_____ # - _\///\\\\\\\\\\\/________\//\\\________\///\\\\\\\\\/____/\\\\\\\\\\\_# - ___\///////////___________\///___________\/////////_____\///////////_# -############################################################################## -S U P E R - V I L L A I N - U I By: Munglunch # -############################################################################## -########################################################## -LOCALIZED LUA FUNCTIONS -########################################################## -]]-- ---[[ GLOBALS ]]-- -local _G = _G; -local unpack = _G.unpack; -local select = _G.select; -local pairs = _G.pairs; -local ipairs = _G.ipairs; -local type = _G.type; -local error = _G.error; -local pcall = _G.pcall; -local tostring = _G.tostring; -local tonumber = _G.tonumber; -local tinsert = _G.tinsert; -local string = _G.string; -local math = _G.math; -local bit = _G.bit; -local table = _G.table; ---[[ STRING METHODS ]]-- -local lower, upper = string.lower, string.upper; -local find, format, split = string.find, string.format, string.split; -local match, gmatch, gsub = string.match, string.gmatch, string.gsub; ---[[ MATH METHODS ]]-- -local floor = math.floor; -- Basic ---[[ BINARY METHODS ]]-- -local band, bor = bit.band, bit.bor; ---[[ TABLE METHODS ]]-- -local tremove, tcopy, twipe, tsort, tconcat = table.remove, table.copy, table.wipe, table.sort, table.concat; ---[[ -########################################################## -GET ADDON DATA -########################################################## -]]-- -local SuperVillain, L = unpack(select(2, ...)); -local MOD = SuperVillain.Registry:Expose('SVPlate'); ---[[ -########################################################## -LOCALS AND TRACKER FRAME -########################################################## -]]-- -local AuraFont = SuperVillain.Media.font.numbers; -local AuraFSize = 7; -local AuraFOutline = "OUTLINE"; -local AuraExtraFilter = "CC"; -local AuraMaxCount = 5; - -local RIconData = {["STAR"] = 0x00000001, ["CIRCLE"] = 0x00000002, ["DIAMOND"] = 0x00000004, ["TRIANGLE"] = 0x00000008, ["MOON"] = 0x00000010, ["SQUARE"] = 0x00000020, ["CROSS"] = 0x00000040, ["SKULL"] = 0x00000080}; -local RIconNames = {"STAR", "CIRCLE", "DIAMOND", "TRIANGLE", "MOON", "SQUARE", "CROSS", "SKULL"} -local NPAuraType = { - ["Buff"] = 1, - ["Curse"] = 2, - ["Disease"] = 3, - ["Magic"] = 4, - ["Poison"] = 5, - ["Debuff"] = 6, -}; -local NPAuraEvents = { - ["SPELL_AURA_APPLIED"] = 1, - ["SPELL_AURA_REFRESH"] = 1, - ["SPELL_AURA_APPLIED_DOSE"] = 2, - ["SPELL_AURA_REMOVED_DOSE"] = 2, - ["SPELL_AURA_BROKEN"] = 3, - ["SPELL_AURA_BROKEN_SPELL"] = 3, - ["SPELL_AURA_REMOVED"] = 3 -}; -local HealSpecs = { - [L['Restoration']] = true, - [L['Holy']] = true, - [L['Discipline']] = true, - [L['Mistweaver']] = true -}; - -local AuraList = {} -local AuraSpellID = {} -local AuraExpiration = {} -local AuraStacks = {} -local AuraCaster = {} -local AuraDuration = {} -local AuraTexture = {} -local AuraType = {} -local AuraTarget = {} -local AuraByRaidIcon = {} -local AuraByName = {} -local CachedAuraDurations = {}; -local AurasCache = {}; -local AuraClockManager = CreateFrame("Frame"); -AuraClockManager.Clocks = {}; -AuraClockManager.Events = {}; -AuraClockManager.IsActive = false; -AuraClockManager.UpdateClock = 0; ---[[ -########################################################## -PARSE FUNCTIONS -########################################################## -]]-- ---SVUI_PlateClockHandler -local function ClockUpdateHandler(self) - local curTime = GetTime() - if curTime < self.UpdateClock then return end - local deactivate = true; - self.UpdateClock = curTime + 0.1 - for frame, expiration in pairs(self.Clocks) do - local calc = 0; - local expires = expiration - curTime; - if expiration < curTime then - frame:Hide(); - self.Clocks[frame] = nil - else - if expires < 60 then - calc = floor(expires) - if expires >= 4 then - frame.TimeLeft:SetFormattedText("|cffffff00%d|r", calc) - elseif expires >= 1 then - frame.TimeLeft:SetFormattedText("|cffff0000%d|r", calc) - else - frame.TimeLeft:SetFormattedText("|cffff0000%.1f|r", expires) - end - elseif expires < 3600 then - calc = ceil(expires / 60); - frame.TimeLeft:SetFormattedText("|cffffffff%.1f|r", calc) - elseif expires < 86400 then - calc = ceil(expires / 3600); - frame.TimeLeft:SetFormattedText("|cff66ffff%.1f|r", calc) - else - calc = ceil(expires / 86400); - frame.TimeLeft:SetFormattedText("|cff6666ff%.1f|r", calc) - end - deactivate = false - end - end - if deactivate then - self:SetScript("OnUpdate", nil); - self.IsActive = false - end -end - -local function RegisterAuraClock(frame, expiration) - if(not frame) then return end - if expiration == 0 then - frame:Hide() - AuraClockManager.Clocks[frame] = nil - else - AuraClockManager.Clocks[frame] = expiration - frame:Show() - if not AuraClockManager.IsActive then - AuraClockManager:SetScript("OnUpdate", ClockUpdateHandler) - AuraClockManager.IsActive = true - end - end -end - -local function DropAura(guid, spellID) - if guid and spellID and AuraList[guid] then - local instanceID = tostring(guid)..tostring(spellID)..(tostring(caster or "UNKNOWN_CASTER")) - local auraID = spellID..(tostring(caster or "UNKNOWN_CASTER")) - if AuraList[guid][auraID] then - AuraSpellID[instanceID] = nil - AuraExpiration[instanceID] = nil - AuraStacks[instanceID] = nil - AuraCaster[instanceID] = nil - AuraDuration[instanceID] = nil - AuraTexture[instanceID] = nil - AuraType[instanceID] = nil - AuraTarget[instanceID] = nil - AuraList[guid][auraID] = nil - end - end -end - -local function DropAllAuras(guid) - if guid and AuraList[guid] then - local unitAuraList = AuraList[guid] - for auraID, instanceID in pairs(unitAuraList) do - AuraSpellID[instanceID] = nil - AuraExpiration[instanceID] = nil - AuraStacks[instanceID] = nil - AuraCaster[instanceID] = nil - AuraDuration[instanceID] = nil - AuraTexture[instanceID] = nil - AuraType[instanceID] = nil - AuraTarget[instanceID] = nil - AuraList[guid][auraID] = nil - end - end -end - -local function GetAuraList(guid) - if guid and AuraList[guid] then return AuraList[guid] end -end - -local function GetAuraInstance(guid, auraID) - if guid and auraID then - local aura = {} - local aura_instance_id = guid..auraID - aura.spellID = AuraSpellID[aura_instance_id] - aura.expiration = AuraExpiration[aura_instance_id] or 0 - aura.stacks = AuraStacks[aura_instance_id] - aura.caster = AuraCaster[aura_instance_id] - aura.duration = AuraDuration[aura_instance_id] - aura.texture = AuraTexture[aura_instance_id] - aura.type = AuraType[aura_instance_id] - aura.target = AuraTarget[aura_instance_id] - return aura - end -end - -local function SetAuraInstance(guid, spellID, expiration, stacks, caster, duration, texture, auratype, auratarget) - local filter = true; - if (caster == UnitGUID('player')) then - filter = nil; - end - - local extraFilter = SuperVillain.Filters[AuraExtraFilter] - if AuraExtraFilter and extraFilter then - local name = GetSpellInfo(spellID) - if AuraExtraFilter == 'Blocked' then - if extraFilter[name] and extraFilter[name].enable then - filter = true; - end - elseif AuraExtraFilter == 'Strict' then - if extraFilter[name].spellID and not extraFilter[name].spellID == spellID then - filter = true; - end - else - if extraFilter[name] and extraFilter[name].enable then - filter = nil; - end - end - end - if(filter or (spellID == 65148)) then - return; - end - if guid and spellID and caster and texture then - local auraID = spellID..(tostring(caster or "UNKNOWN_CASTER")) - local instanceID = guid..auraID - AuraList[guid] = AuraList[guid] or {} - AuraList[guid][auraID] = instanceID - AuraSpellID[instanceID] = spellID - AuraExpiration[instanceID] = expiration or 0 - AuraStacks[instanceID] = stacks - AuraCaster[instanceID] = caster - AuraDuration[instanceID] = duration - AuraTexture[instanceID] = texture - AuraType[instanceID] = auratype - AuraTarget[instanceID] = auratarget - end -end - -local function UpdateAuraIcon(aura, texture, expiration, stacks, test) - if aura and texture and expiration then - aura.Icon:SetTexture(texture) - if stacks > 1 then - aura.Stacks:SetText(stacks) - else - aura.Stacks:SetText("") - end - aura:Show() - RegisterAuraClock(aura, expiration) - else - RegisterAuraClock(aura, 0) - end -end - -local function SortExpires(t) - tsort(t, function(a,b) return a.expiration < b.expiration end) - return t -end - -local function UpdateAuraIconGrid(plate) - local frame = plate.frame; - local guid = plate.guid; - local iconCache = frame.auraicons; - local AurasOnUnit = GetAuraList(guid); - local AuraSlotIndex = 1; - local auraID; - - if AurasOnUnit then - frame.auras:Show() - local auraCount = 1 - for auraID in pairs(AurasOnUnit) do - local aura = GetAuraInstance(guid, auraID) - if tonumber(aura.spellID) then - aura.name = GetSpellInfo(tonumber(aura.spellID)) - aura.unit = plate.unit - if aura.expiration > GetTime() then - AurasCache[auraCount] = aura - auraCount = auraCount + 1 - end - end - end - end - AurasCache = SortExpires(AurasCache) - for index = 1, #AurasCache do - local cachedaura = AurasCache[index] - local gridaura = iconCache[AuraSlotIndex] - if gridaura and cachedaura.spellID and cachedaura.expiration then - UpdateAuraIcon(gridaura, cachedaura.texture, cachedaura.expiration, cachedaura.stacks) - AuraSlotIndex = AuraSlotIndex + 1 - end - if(AuraSlotIndex > AuraMaxCount) then - break - end - end - if iconCache[AuraSlotIndex] then - RegisterAuraClock(iconCache[AuraSlotIndex], 0) - end - AurasCache = twipe(AurasCache) -end - -local function LoadDuration(spellID) - if spellID then - return CachedAuraDurations[spellID] or 0 - end - return 0 -end - -local function SaveDuration(spellID, duration) - duration = duration or 0 - if spellID then CachedAuraDurations[spellID] = duration end -end - -local function CleanAuraLists() - local currentTime = GetTime() - for guid, instanceList in pairs(AuraList) do - local auracount = 0 - for auraID, instanceID in pairs(instanceList) do - local expiration = Aura_Expiration[instanceID] - if expiration and expiration < currentTime then - AuraList[guid][auraID] = nil - AuraSpellID[instanceID] = nil - AuraExpiration[instanceID] = nil - AuraStacks[instanceID] = nil - AuraCaster[instanceID] = nil - AuraDuration[instanceID] = nil - AuraTexture[instanceID] = nil - AuraType[instanceID] = nil - AuraTarget[instanceID] = nil - else - auracount = auracount + 1 - end - end - if auracount == 0 then - AuraList[guid] = nil - end - end -end - -local function ClearClocks() - AuraClockManager.Clocks = twipe(AuraClockManager.Clocks) -end - -local function GetCombatEventResults(...) - local timestamp, combatevent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlag, spellid, spellname = ... - local auraType, stackCount = select(15, ...) - return timestamp, combatevent, sourceGUID, destGUID, destName, destFlags, destRaidFlag, auraType, spellid, spellname, stackCount -end ---[[ -########################################################## -EVENTS -########################################################## -]]-- -function MOD:UNIT_AURA(event, unit) - if unit == "target" then - self:UpdateAurasByUnitID("target") - elseif unit == "focus" then - self:UpdateAurasByUnitID("focus") - end -end --- guid, spellID, expiration, stacks, caster, duration, texture, auratype, auratarget -function MOD:COMBAT_LOG_EVENT_UNFILTERED(event, ...) - local timestamp, combatevent, sourceGUID, destGUID, destName, destFlags, destRaidFlag, auraType, spellID, spellName, stackCount = GetCombatEventResults(...) - if NPAuraEvents[combatevent] then - if NPAuraEvents[combatevent] == 1 then - local duration = LoadDuration(spellID) - local texture = GetSpellTexture(spellID) - SetAuraInstance(destGUID, spellID, (GetTime() + duration), 1, sourceGUID, duration, texture, auraType, AURA_TARGET_HOSTILE) - elseif NPAuraEvents[combatevent] == 2 then - local duration = LoadDuration(spellID) - local texture = GetSpellTexture(spellID) - SetAuraInstance(destGUID, spellID, (GetTime() + duration), stackCount, sourceGUID, duration, texture, auraType, AURA_TARGET_HOSTILE) - elseif NPAuraEvents[combatevent] == 3 then - DropAura(destGUID, spellID) - end - local rawName, raidIcon - if(destName and (band(destFlags, COMBATLOG_OBJECT_CONTROL_PLAYER) > 0)) then - rawName = split("-", destName) - AuraByName[rawName] = destGUID - end - for iconName, bitmask in pairs(RIconData) do - if band(destRaidFlag, bitmask) > 0 then - raidIcon = iconName - AuraByRaidIcon[raidIcon] = destGUID - break - end - end - MOD:RequestScanUpdate(destGUID, raidIcon, rawName, "UpdateAuras") - end -end ---[[ -########################################################## -MODULE FUNCTIONS -########################################################## -]]-- -function MOD:UpdateAuraLocals() - AuraFont = SuperVillain.Shared:Fetch("font", self.db.auras.font); - AuraFSize = self.db.auras.fontSize; - AuraFOutline = self.db.auras.fontOutline; - AuraExtraFilter = self.db.auras.additionalFilter; - AuraMaxCount = self.db.auras.numAuras; -end - -function MOD:UpdateAurasByUnitID(unitid) - local unitType - if UnitIsFriend("player", unitid) then unitType = AURA_TARGET_FRIENDLY else unitType = AURA_TARGET_HOSTILE end - local guid = UnitGUID(unitid) - DropAllAuras(guid) - - local index - - for index = 1, 40 do - local spellname , _, texture, count, dispelType, duration, expirationTime, unitCaster, _, _, spellid, _, isBossDebuff = UnitDebuff(unitid, index) - if not spellname then break end - SaveDuration(spellid, duration) - SetAuraInstance(guid, spellid, expirationTime, count, UnitGUID(unitCaster or ""), duration, texture, NPAuraType[dispelType or "Debuff"], unitType) - end - - if unitType == AURA_TARGET_FRIENDLY then - for index = 1, 40 do - local spellname , _, texture, count, dispelType, duration, expirationTime, unitCaster, _, _, spellid, _, isBossDebuff = UnitBuff(unitid, index) - if not spellname then break end - SaveDuration(spellid, duration) - SetAuraInstance(guid, spellid, expirationTime, count, UnitGUID(unitCaster or ""), duration, texture, AURA_TYPE_BUFF, AURA_TARGET_FRIENDLY) - - end - end - - local raidIcon, name; - if UnitPlayerControlled(unitid) then - name = UnitName(unitid) - AuraByName[name] = guid - end - raidIcon = RIconNames[GetRaidTargetIndex(unitid) or ""]; - if raidIcon then - AuraByRaidIcon[raidIcon] = guid - end - MOD:RequestScanUpdate(guid, raidIcon, name, "UpdateAuras") -end - -function MOD:UpdateAuras(plate) - if plate.setting.tiny then return end; - local guid = plate.guid - local frame = plate.frame - if not guid then - if RAID_CLASS_COLORS[plate.setting.unitcategory] then - local name = gsub(plate.name:GetText(), '%s%(%*%)','') - guid = AuraByName[name] - elseif plate.ref.raidicon:IsShown() then - guid = AuraByRaidIcon[plate.ref.raidicontype] - end - if guid then - plate.guid = guid - else - frame.auras:Hide() - return - end - end - UpdateAuraIconGrid(plate) - if(MOD.UseCombo) then - MOD:UpdateComboPoints(plate) - end -end - -function MOD:CreateAuraIcon(auras, plate) - local noscalemult = 2 * UIParent:GetScale() - local button = CreateFrame("Frame", nil, auras) - button:SetScript('OnHide', function() - if plate.guid then - UpdateAuraIconGrid(plate) - end - end) - button.bord = button:CreateTexture(nil, "BACKGROUND") - button.bord:SetDrawLayer('BACKGROUND', 2) - button.bord:SetTexture(0,0,0,1) - button.bord:SetPoint("TOPLEFT", button, "TOPLEFT", -noscalemult, noscalemult) - button.bord:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", noscalemult, -noscalemult) - button.Icon = button:CreateTexture(nil, "BORDER") - button.Icon:SetPoint("TOPLEFT",button,"TOPLEFT") - button.Icon:SetPoint("BOTTOMRIGHT",button,"BOTTOMRIGHT") - button.Icon:SetTexCoord(.1, .9, .2, .8) - button.TimeLeft = button:CreateFontString(nil, 'OVERLAY') - button.TimeLeft:SetFont(AuraFont, AuraFSize, AuraFOutline) - button.TimeLeft:SetPoint("BOTTOMLEFT",button,"TOPLEFT",-3,-1) - button.TimeLeft:SetJustifyH('CENTER') - button.Stacks = button:CreateFontString(nil,"OVERLAY") - button.Stacks:SetFont(AuraFont, AuraFSize + 2, AuraFOutline) - button.Stacks:SetPoint("BOTTOMRIGHT",button,"BOTTOMRIGHT",3,-3) - button:Hide() - return button -end - -MOD.RegisterAuraClock = RegisterAuraClock; \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/plates/common/tracker.lua b/Interface/AddOns/SVUI/packages/plates/common/tracker.lua deleted file mode 100644 index d074924..0000000 --- a/Interface/AddOns/SVUI/packages/plates/common/tracker.lua +++ /dev/null @@ -1,277 +0,0 @@ ---[[ -############################################################################## -_____/\\\\\\\\\\\____/\\\________/\\\__/\\\________/\\\__/\\\\\\\\\\\_ # - ___/\\\/////////\\\_\/\\\_______\/\\\_\/\\\_______\/\\\_\/////\\\///__ # - __\//\\\______\///__\//\\\______/\\\__\/\\\_______\/\\\_____\/\\\_____ # - ___\////\\\__________\//\\\____/\\\___\/\\\_______\/\\\_____\/\\\_____ # - ______\////\\\________\//\\\__/\\\____\/\\\_______\/\\\_____\/\\\_____ # - _________\////\\\______\//\\\/\\\_____\/\\\_______\/\\\_____\/\\\_____ # - __/\\\______\//\\\______\//\\\\\______\//\\\______/\\\______\/\\\_____ # - _\///\\\\\\\\\\\/________\//\\\________\///\\\\\\\\\/____/\\\\\\\\\\\_# - ___\///////////___________\///___________\/////////_____\///////////_# -############################################################################## -S U P E R - V I L L A I N - U I By: Munglunch # -############################################################################## -########################################################## -LOCALIZED LUA FUNCTIONS -########################################################## -]]-- ---[[ GLOBALS ]]-- -local _G = _G; -local unpack = _G.unpack; -local select = _G.select; -local pairs = _G.pairs; -local ipairs = _G.ipairs; -local type = _G.type; -local error = _G.error; -local pcall = _G.pcall; -local tostring = _G.tostring; -local tonumber = _G.tonumber; -local tinsert = _G.tinsert; -local string = _G.string; -local math = _G.math; -local bit = _G.bit; -local table = _G.table; ---[[ STRING METHODS ]]-- -local lower, upper = string.lower, string.upper; -local find, format, split = string.find, string.format, string.split; -local match, gmatch, gsub = string.match, string.gmatch, string.gsub; ---[[ MATH METHODS ]]-- -local floor = math.floor; -- Basic ---[[ BINARY METHODS ]]-- -local band, bor = bit.band, bit.bor; ---[[ TABLE METHODS ]]-- -local tremove, tcopy, twipe, tsort, tconcat = table.remove, table.copy, table.wipe, table.sort, table.concat; ---[[ -########################################################## -GET ADDON DATA -########################################################## -]]-- -local SuperVillain, L = unpack(select(2, ...)); -local MOD = SuperVillain.Registry:Expose('SVPlate'); ---[[ -########################################################## -LOCALS AND TRACKER FRAME -########################################################## -]]-- -local NextUpdate = 0 - -local SpellIDTest = { - [47540] = true, [88625] = true, [88684] = true, [88685] = true, - [89485] = true, [10060] = true, [33206] = true, [62618] = true, - [724] = true, [14751] = true, [34861] = true, [47788] = true, - [18562] = true, [17116] = true, [48438] = true, [33891] = true, - [974] = true, [17116] = true, [16190] = true, [61295] = true, - [20473] = true, [31842] = true, [53563] = true, [31821] = true, - [85222] = true, [115175] = true, [115294] = true, [115310] = true, - [116670] = true, [116680] = true, [116849] = true, [116995] = true, - [119611] = true, [132120] = true -} - -local HealerDetection = { - ["SPELL_HEAL"] = true, - ["SPELL_AURA_APPLIED"] = true, - ["SPELL_CAST_START"] = true, - ["SPELL_CAST_SUCCESS"] = true, - ["SPELL_PERIODIC_HEAL"] = true, - ["Restoration"] = true, - ["Holy"] = true, - ["Discipline"] = true, - ["Mistweaver"] = true -} - -local TrackingManager = CreateFrame("Frame") -local CPoints = {} -local TrackedPlatesCP = {} -local LastKnownTarget = false -local LastKnownPoints = 0 -local Healers = {} -local Events = {} ---[[ -########################################################## -PARSE FUNCTIONS -########################################################## -]]-- -local function TrackViaScores() - local curTime = GetTime() - if curTime > NextUpdate then - NextUpdate = curTime + 3 - else - return - end - local scores = GetNumBattlefieldScores() - if(scores > 0) then - local filter - for i = 1, scores do - local name, _, _, _, _, faction, _, class, _, _, _, _, _, _, _, talentSpec = GetBattlefieldScore(i) - if name and talentSpec then - filter = HealerDetection[talentSpec] - Healers[name] = filter - end - end - if(filter) then - MOD:RequestScanUpdate(false, false, name, "UpdateHealerIcon") - end - end -end - -local function PlateIsHealer(name) - if name then - if Healers[name] then - return true - else - RequestBattlefieldScoreData() - end - end -end - -local function PlateIsEnemy(flags) - if (band(flags, COMBATLOG_OBJECT_REACTION_FRIENDLY) == 0) and (band(flags, COMBATLOG_OBJECT_CONTROL_PLAYER) > 0) then - return true - end -end - -local function DetectHealer(event, id) - if (HealerDetection[event] and SpellIDTest[id]) then - return true - else - return false - end -end - -local function ClearTracking() - twipe(CPoints) - twipe(Healers) -end - -local function ClearExpiredPoints() - local saved - for plate,_ in pairs(TrackedPlatesCP) do - if(plate.guid ~= LastKnownTarget) then - for i=1, MAX_COMBO_POINTS do - plate.frame.combo[i]:Hide() - end - else - saved = plate - end - end - CPoints = {} - TrackedPlatesCP = {} - - if(saved) then - TrackedPlatesCP[saved] = true - end - - if(LastKnownTarget) then - CPoints[LastKnownTarget] = LastKnownPoints; - end -end - -local function TrackingEventHandler(self, event, ...) - local handler = Events[event] - if handler then handler(...) end -end ---[[ -########################################################## -EVENTS -########################################################## -]]-- -function Events.UNIT_COMBO_POINTS(unit) - MOD:UpdateComboPointsByUnitID(unit) -end - -function Events.PLAYER_ENTERING_WORLD() - ClearTracking() - return -end - -function Events.PLAYER_TARGET_CHANGED() - ClearExpiredPoints() - return -end - -function Events.UPDATE_BATTLEFIELD_SCORE() - TrackViaScores() - return -end - -function Events.COMBAT_LOG_EVENT_UNFILTERED(...) - local timestamp, combatevent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlag, spellid = ... - if PlateIsEnemy(sourceFlags) and sourceGUID and sourceName then - if DetectHealer(combatevent, spellid) then - local rawName = split("-", sourceName) - if not Healers[rawName] then - Healers[rawName] = true - MOD:RequestScanUpdate(destGUID, false, false, "UpdateHealerIcon") - end - end - end -end ---[[ -########################################################## -MODULE FUNCTIONS -########################################################## -]]-- -function MOD:EnableTracking() - TrackingManager:SetScript("OnEvent", TrackingEventHandler) - TrackingManager:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") - TrackingManager:RegisterEvent("PLAYER_ENTERING_WORLD") - TrackingManager:RegisterEvent("UPDATE_BATTLEFIELD_SCORE") - if (MOD.UseCombo) then - TrackingManager:RegisterEvent("UNIT_COMBO_POINTS") - TrackingManager:RegisterEvent("PLAYER_TARGET_CHANGED") - end - ClearTracking() -end - -function MOD:DisableTracking() - TrackingManager:UnregisterAllEvents() - TrackingManager:SetScript("OnEvent", nil) - ClearTracking() -end - -function MOD:UpdateHealerIcon(plate) - local rawName = plate.ref.nametext - if rawName then - local healerIcon = plate.frame.health.icon - if PlateIsHealer(rawName) then - healerIcon:Show() - else - healerIcon:Hide() - end - end -end - -function MOD:UpdateComboPoints(plate) - local frame = plate.frame - local numPoints = CPoints[plate.guid] or 0 - if(numPoints == 0) then - TrackedPlatesCP[plate] = nil - else - TrackedPlatesCP[plate] = true - end - for i=1, MAX_COMBO_POINTS do - if(i <= numPoints) then - frame.combo[i]:Show() - else - frame.combo[i]:Hide() - end - end -end - -function MOD:UpdateComboPointsByUnitID(unit) - if(unit == "player" or unit == "vehicle") then - local guid = UnitGUID("target") - if (not guid) then return end - local numPoints = GetComboPoints(UnitHasVehicleUI('player') and 'vehicle' or 'player', 'target') - if(numPoints > 0) then - if(LastKnownTarget ~= guid) then - CPoints[LastKnownTarget] = nil - end - end - LastKnownTarget = guid - LastKnownPoints = numPoints - CPoints[guid] = numPoints - MOD:RequestScanUpdate(guid, false, false, "UpdateComboPoints") - end -end \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/stats/SVStats.lua b/Interface/AddOns/SVUI/packages/stats/SVStats.lua index 3ec2b7a..d82b389 100644 --- a/Interface/AddOns/SVUI/packages/stats/SVStats.lua +++ b/Interface/AddOns/SVUI/packages/stats/SVStats.lua @@ -194,9 +194,7 @@ function MOD:NewAnchor(parent, maxCount, tipAnchor, isTop) parent.holders[this].text = parent.holders[this].textframe:CreateFontString(nil, "OVERLAY", nil, 7) parent.holders[this].text:SetAllPoints() if(MOD.db.showBackground) then - parent.holders[this].text:SetFontTemplate(SuperVillain.Shared:Fetch("font", MOD.db.font), MOD.db.fontSize, "NONE") - parent.holders[this].text:SetJustifyH("CENTER") - parent.holders[this].text:SetJustifyV("middle") + parent.holders[this].text:SetFontTemplate(SuperVillain.Shared:Fetch("font", MOD.db.font), MOD.db.fontSize, "NONE", "CENTER", "MIDDLE") parent.holders[this].text:SetShadowColor(0, 0, 0, 0.5) parent.holders[this].text:SetShadowOffset(2, -4) else diff --git a/Interface/AddOns/SVUI/packages/stats/common/reputation.lua b/Interface/AddOns/SVUI/packages/stats/common/reputation.lua index 5d797c3..4ea0fd3 100644 --- a/Interface/AddOns/SVUI/packages/stats/common/reputation.lua +++ b/Interface/AddOns/SVUI/packages/stats/common/reputation.lua @@ -64,18 +64,20 @@ local function TruncateString(value) return value end end - +-- name, description, standingID, barMin, barMax, barValue, _, _, _, _, hasRep, isWatched, isChild function MOD:CacheRepData() twipe(RepMenuList) for factionIndex = 1, GetNumFactions() do - local factionName = GetFactionInfo(factionIndex) - local fn = function() - local active = GetWatchedFactionInfo() - if factionName ~= active then - SetWatchedFactionIndex(factionIndex) - end - end; - tinsert(RepMenuList, {text = factionName, func = fn}); + local factionName, description, standingID, barMin, barMax, barValue, _, _, _, _, hasRep, isWatched, isChild = GetFactionInfo(factionIndex) + if(standingID) then + local fn = function() + local active = GetWatchedFactionInfo() + if factionName ~= active then + SetWatchedFactionIndex(factionIndex) + end + end; + tinsert(RepMenuList, {text = factionName, func = fn}) + end end end @@ -85,7 +87,6 @@ local function Reputation_OnEvent(self, ...) self.text:SetJustifyH("CENTER") self.barframe:Hide() self.text:SetAlpha(1) - self.text:SetFontTemplate(SuperVillain.Shared:Fetch("font",SuperVillain.db.SVStats.font),SuperVillain.db.SVStats.fontSize,SuperVillain.db.SVStats.fontOutline) end; local ID = 100 local isFriend, friendText @@ -93,12 +94,12 @@ local function Reputation_OnEvent(self, ...) local numFactions = GetNumFactions(); local txt = "" if not name then - txt = "No watched factions" + name = "No watched factions" else for i=1, numFactions do - local factionName, _, standingID,_,_,_,_,_,_,_,_,_,_, factionID = GetFactionInfo(i); - local friendID, friendRep, friendMaxRep, _, _, _, friendTextLevel = GetFriendshipReputation(factionID); - if factionName == name then + local factionName, description, standingID, barMin, barMax, barValue, _, _, _, _, hasRep, isWatched, isChild = GetFactionInfo(i); + local friendID, friendRep, friendMaxRep, _, _, _, friendTextLevel = GetFriendshipReputation(isChild); + if(not factionName or (name == "No watched factions") or (name == factionName)) then if friendID ~= nil then isFriend = true friendText = friendTextLevel @@ -116,18 +117,28 @@ local function ReputationBar_OnEvent(self, ...) if not self.barframe:IsShown()then self.barframe:Show() self.barframe.icon.texture:SetTexture("Interface\\Addons\\SVUI\\assets\\artwork\\Icons\\STAT-REP") - self.text:SetAlpha(0.5) - self.text:SetFontTemplate(SuperVillain.Shared:Fetch("font",SuperVillain.db.SVStats.font),SuperVillain.db.SVStats.fontSize,"NONE") + self.text:SetAlpha(1) end; local bar = self.barframe.bar; local name, reaction, min, max, value = GetWatchedFactionInfo() - local j = GetNumFactions() + local numFactions = GetNumFactions(); if not name then bar:SetStatusBarColor(0,0,0) bar:SetMinMaxValues(0,1) bar:SetValue(0) self.text:SetText("No Faction") - else + else + for i=1, numFactions do + local factionName, description, standingID, barMin, barMax, barValue, _, _, _, _, hasRep, isWatched, isChild = GetFactionInfo(i); + if(isChild) then + local friendID, friendRep, friendMaxRep, _, _, _, friendTextLevel, friendThreshold, nextFriendThreshold = GetFriendshipReputation(isChild); + if friendID ~= nil then + min = friendThreshold + max = friendMaxRep + value = friendRep + end + end + end local txt = standingName[reaction]; local color = FACTION_BAR_COLORS[reaction] bar:SetStatusBarColor(color.r, color.g, color.b) diff --git a/Interface/AddOns/SVUI/packages/tip/SVTip.xml b/Interface/AddOns/SVUI/packages/tip/SVTip.xml deleted file mode 100644 index b36a98d..0000000 --- a/Interface/AddOns/SVUI/packages/tip/SVTip.xml +++ /dev/null @@ -1,4 +0,0 @@ -<Ui xmlns="http://www.blizzard.com/wow/ui/"> - <Script file='SVTip.lua'/> - <!-- <Include file='common\_load.xml'/> --> -</Ui> \ No newline at end of file diff --git a/Interface/AddOns/SVUI/packages/unit/SVUnit.lua b/Interface/AddOns/SVUI/packages/unit/SVUnit.lua index d6220dd..2359bcf 100644 --- a/Interface/AddOns/SVUI/packages/unit/SVUnit.lua +++ b/Interface/AddOns/SVUI/packages/unit/SVUnit.lua @@ -1299,12 +1299,12 @@ BUILD FUNCTION / UPDATE ########################################################## ]]-- function MOD:ReLoad() - if(not SuperVillain.db.SVUnit.enable or SuperVillain.db.SVUnit.enable == false) then print("ReLoad Disabled") return end + if(not self.db.enable or self.db.enable == false) then return end self:RefreshUnitFrames() end function MOD:Load() - if(not SuperVillain.db.SVUnit.enable or SuperVillain.db.SVUnit.enable == false) then print("Load Disabled") return end + if(not self.db.enable or self.db.enable == false) then return end self:RefreshUnitColors() local SVUI_UnitFrameParent = CreateFrame("Frame", "SVUI_UnitFrameParent", SuperVillain.UIParent, "SecureHandlerStateTemplate") @@ -1314,7 +1314,7 @@ function MOD:Load() self:RegisterEvent("PLAYER_ENTERING_WORLD") self:RegisterEvent("PLAYER_REGEN_DISABLED") - if SuperVillain.db.SVUnit.disableBlizzard then + if(self.db.disableBlizzard) then self:Protect("KillBlizzardRaidFrames", true); NewHook("CompactUnitFrame_RegisterEvents", CompactUnitFrame_UnregisterEvents) NewHook("UnitFrameThreatIndicator_Initialize", UnitFrameThreatIndicator_Hook) diff --git a/Interface/AddOns/SVUI/system/system.lua b/Interface/AddOns/SVUI/system/system.lua index bb2d00a..dd0358a 100644 --- a/Interface/AddOns/SVUI/system/system.lua +++ b/Interface/AddOns/SVUI/system/system.lua @@ -120,6 +120,14 @@ THE CLEANING LADY ]]-- local LemonPledge = 0; local Consuela = CreateFrame("Frame") +Consuela:RegisterAllEvents() +Consuela:SetScript("OnEvent", function(self, event) + LemonPledge = LemonPledge + 1 + if (InCombatLockdown() and LemonPledge > 25000) or (not InCombatLockdown() and LemonPledge > 10000) then + collectgarbage("collect") + LemonPledge = 0; + end +end) --[[ ########################################################## DISPEL MECHANICS @@ -176,13 +184,15 @@ function SuperVillain:DefinePlayerRole() local spec = GetSpecialization() local role; if spec then + if(self.CurrentSpec == spec) then return end role = RefClassRoles[spec] if role == "T" and UnitLevel("player") == MAX_PLAYER_LEVEL then local bonus, pvp = GetCombatRatingBonus(COMBAT_RATING_RESILIENCE_PLAYER_DAMAGE_TAKEN), false; if bonus > GetDodgeChance() and bonus > GetParryChance() then role = "M" end - end + end + self.CurrentSpec = spec else local intellect = select(2, UnitStat("player", 4)) local agility = select(2, UnitStat("player", 2)) @@ -205,6 +215,7 @@ function SuperVillain:DefinePlayerRole() self.Dispellable["Magic"] = nil end end + self.RoleIsSet = true end --[[ ########################################################## @@ -410,19 +421,10 @@ local function FullLoad(self) _G["SVUI_Mentalo"]:SetFixedPanelTemplate("Component") _G["SVUI_Mentalo"]:SetPanelColor("yellow") _G["SVUI_MentaloPrecision"]:SetPanelTemplate("Transparent") - - Consuela:RegisterAllEvents() - Consuela:SetScript("OnEvent", function(self, event) - LemonPledge = LemonPledge + 1 - if (InCombatLockdown() and LemonPledge > 25000) or (not InCombatLockdown() and LemonPledge > 10000) or event == "PLAYER_ENTERING_WORLD" then - collectgarbage("collect"); - LemonPledge = 0; - end - end) if self.db.system.loginmessage then self:AddonMessage(format(L["LOGIN_MSG"], "|cffffcc1a", "|cffff801a", self.version)); - end + end end SVUISystemEventHandler:RegisterEvent("ADDON_LOADED") @@ -432,7 +434,7 @@ SVUISystemEventHandler:RegisterEvent("PLAYER_LOGIN") EVENT HANDLER ########################################################## ]]-- -local Registry_OnEvent = function(self, event, arg, ...) +local SVUISystem_OnEvent = function(self, event, arg, ...) if(event == "ADDON_LOADED" and arg ~= "Blizzard_DebugTools") then PreLoad(SuperVillain) self:UnregisterEvent("ADDON_LOADED") @@ -444,10 +446,11 @@ local Registry_OnEvent = function(self, event, arg, ...) elseif(event == "UI_SCALE_CHANGED") then SuperVillain:UIScale("UI_SCALE_CHANGED") elseif(event == "PLAYER_ENTERING_WORLD") then - SuperVillain:DefinePlayerRole() - if(not SuperVillain.MediaUpdated) then - SuperVillain:RefreshAllSystemMedia() - SuperVillain.MediaUpdated = true + if(not SuperVillain.RoleIsSet) then + SuperVillain:DefinePlayerRole() + end + if(not SuperVillain.MediaInitialized) then + SuperVillain:RefreshAllSystemMedia() end local a,b = IsInInstance() if(b == "pvp") then @@ -456,6 +459,7 @@ local Registry_OnEvent = function(self, event, arg, ...) SuperVillain:RemoveLoop(SuperVillain.BGTimer) SuperVillain.BGTimer = nil end + collectgarbage("collect") elseif(event == "SPELLS_CHANGED") then if (toonClass ~= "DRUID") then self:UnregisterEvent("SPELLS_CHANGED") @@ -473,7 +477,7 @@ local Registry_OnEvent = function(self, event, arg, ...) elseif(event == "ADDON_ACTION_BLOCKED" or event == "ADDON_ACTION_FORBIDDEN") then SuperVillain:TaintHandler(arg, ...) elseif(event == "PLAYER_REGEN_DISABLED") then - local forceClosed=false; + local forceClosed = false; if IsAddOnLoaded("SVUI_ConfigOMatic") then local aceConfig=LibStub("AceConfigDialog-3.0") if aceConfig.OpenFrames[SVUINameSpace] then @@ -495,7 +499,7 @@ local Registry_OnEvent = function(self, event, arg, ...) HenchmenFrameBG:Hide() forceClosed = true; end - if forceClosed==true then + if forceClosed == true then SuperVillain:AddonMessage(ERR_NOT_IN_COMBAT) end elseif(event == "PLAYER_REGEN_ENABLED") then @@ -503,4 +507,4 @@ local Registry_OnEvent = function(self, event, arg, ...) self:UnregisterEvent('PLAYER_REGEN_ENABLED') end end -SVUISystemEventHandler:SetScript("OnEvent", Registry_OnEvent) \ No newline at end of file +SVUISystemEventHandler:SetScript("OnEvent", SVUISystem_OnEvent) \ No newline at end of file diff --git a/Interface/AddOns/SVUI/system/timers.lua b/Interface/AddOns/SVUI/system/timers.lua index eb2b3cd..28e1bd5 100644 --- a/Interface/AddOns/SVUI/system/timers.lua +++ b/Interface/AddOns/SVUI/system/timers.lua @@ -53,7 +53,8 @@ ExecuteLoop: Create a timer that loops continuously and CAN be removed local QueuedForExeTimer = 0; local ExeTimerQueue = {}; local ExeTimerManager = CreateFrame("Frame"); -local ExeTimerManager_OnUpdate = function(self,elapsed) + +local ExeTimerManager_OnUpdate = function(self, elapsed) if(QueuedForExeTimer > 0) then for id,_ in pairs(ExeTimerQueue) do local callback = ExeTimerQueue[id] @@ -61,19 +62,27 @@ local ExeTimerManager_OnUpdate = function(self,elapsed) if callback.t > elapsed then local newTime = callback.t - elapsed ExeTimerQueue[id].t = newTime - else + else callback.f() if(callback.x) then ExeTimerQueue[id].t = callback.x else ExeTimerQueue[id] = nil + QueuedForExeTimer = QueuedForExeTimer - 1; end end end end end end -ExeTimerManager:SetScript("OnUpdate", ExeTimerManager_OnUpdate) + +local function ValidateTimer() + if(QueuedForExeTimer > 0 and (not ExeTimerManager:GetScript("OnUpdate"))) then + ExeTimerManager:SetScript("OnUpdate", ExeTimerManager_OnUpdate) + elseif(ExeTimerManager:GetScript("OnUpdate")) then + ExeTimerManager:SetScript("OnUpdate", nil) + end +end function SuperVillain:ExecuteTimer(timeOutFunction, duration, idCheck) if(type(duration) == "number" and type(timeOutFunction) == "function") then @@ -83,12 +92,13 @@ function SuperVillain:ExecuteTimer(timeOutFunction, duration, idCheck) else QueuedForExeTimer = QueuedForExeTimer + 1 local id = "LOOP" .. QueuedForExeTimer; - ExeTimerQueue[id] = {["t"] = duration, ["f"] = timeOutFunction} + ExeTimerQueue[id] = {t = duration, f = timeOutFunction} + ValidateTimer() return id end - end; + end return false -end; +end function SuperVillain:ExecuteLoop(timeOutFunction, duration, idCheck) if(type(duration) == "number" and type(timeOutFunction) == "function") then @@ -99,19 +109,21 @@ function SuperVillain:ExecuteLoop(timeOutFunction, duration, idCheck) else QueuedForExeTimer = QueuedForExeTimer + 1 local id = "LOOP" .. QueuedForExeTimer; - ExeTimerQueue[id] = {["x"] = duration, ["t"] = duration, ["f"] = timeOutFunction} + ExeTimerQueue[id] = {x = duration, t = duration, f = timeOutFunction} + ValidateTimer() return id end - end; + end return false -end; +end function SuperVillain:RemoveLoop(id) if(ExeTimerQueue[id]) then ExeTimerQueue[id] = nil QueuedForExeTimer = QueuedForExeTimer - 1; - end; -end; + ValidateTimer() + end +end --[[ ########################################################## TIMER FUNCTIONS @@ -120,18 +132,18 @@ TIMER FUNCTIONS local Cooldown_ForceUpdate = function(self) self.nextUpdate = 0; self:Show() -end; +end local Cooldown_StopTimer = function(self) self.enable = nil; self:Hide() -end; +end local Cooldown_OnUpdate = function(self, elapsed) if self.nextUpdate > 0 then self.nextUpdate = self.nextUpdate - elapsed; return - end; + end local expires = (self.duration - (GetTime() - self.start)); if expires > 0.05 then if (self.fontScale * self:GetEffectiveScale() / UIParent:GetScale()) < 0.5 then @@ -166,17 +178,17 @@ local Cooldown_OnUpdate = function(self, elapsed) else Cooldown_StopTimer(self) end -end; +end local function ModifyCoolSize(self, width, height, override) local newSize = floor(width + .5) / 36; override = override or self:GetParent():GetParent().SizeOverride; if override then newSize = override / 20 - end; + end if newSize == self.fontScale then return - end; + end self.fontScale = newSize; if newSize < 0.5 and not override then self:Hide() @@ -187,7 +199,7 @@ local function ModifyCoolSize(self, width, height, override) Cooldown_ForceUpdate(self) end end -end; +end local Cool_OnSize = function(self, width, height) ModifyCoolSize(self.timer, width, height, self.SizeOverride) @@ -210,7 +222,7 @@ local function CreateCoolTimer(self) self:SetScript('OnSizeChanged', Cool_OnSize) return self.timer -end; +end local Cooldown_OnLoad = function(self, start, duration, elapsed) if start > 0 and duration > 2.5 then @@ -228,7 +240,7 @@ local Cooldown_OnLoad = function(self, start, duration, elapsed) if timer then Cooldown_StopTimer(timer) end - end; + end if self.timer then if elapsed and elapsed > 0 then self.timer:SetAlpha(0) @@ -236,9 +248,9 @@ local Cooldown_OnLoad = function(self, start, duration, elapsed) self.timer:SetAlpha(1) end end -end; +end function SuperVillain:AddCD(cooldown) if not SuperVillain.db.system.cooldown then return end hooksecurefunc(cooldown, "SetCooldown", Cooldown_OnLoad) -end; \ No newline at end of file +end \ No newline at end of file diff --git a/Interface/AddOns/SVUI/system/updates.lua b/Interface/AddOns/SVUI/system/updates.lua index 3cb9bca..aedd293 100644 --- a/Interface/AddOns/SVUI/system/updates.lua +++ b/Interface/AddOns/SVUI/system/updates.lua @@ -83,13 +83,13 @@ function SuperVillain:MediaUpdate() self.Media.bg.unitsmall = self.Shared:Fetch("background", self.db.media.textures.unitsmall) local cColor1 = self.Media.color.special - local cColor2 = self.Media.color.default - local r1,g1,b1 = cColor1[1], cColor1[2], cColor1[3] - local r2,g2,b2 = cColor2[1], cColor2[2], cColor2[3] - - self.Media.gradient.special = {"VERTICAL",r1,g1,b1,r2,g2,b2} + local cColor2 = self.Media.color.default + local r1,g1,b1 = cColor1[1], cColor1[2], cColor1[3] + local r2,g2,b2 = cColor2[1], cColor2[2], cColor2[3] - self.Registry:RunCallbacks() + self.Media.gradient.special = {"VERTICAL",r1,g1,b1,r2,g2,b2} + + self.Registry:RunCallbacks() end function SuperVillain:RefreshSystemFonts() @@ -228,4 +228,5 @@ function SuperVillain:RefreshAllSystemMedia() SetFont(SystemFont_Tiny, UNICODE_FONT, unicodesize) self:MediaUpdate() + self.MediaInitialized = true end; \ No newline at end of file diff --git a/Interface/AddOns/SVUI_ConfigOMatic/SVUI_ConfigOMatic.toc b/Interface/AddOns/SVUI_ConfigOMatic/SVUI_ConfigOMatic.toc index 5a3783c..bbac951 100644 --- a/Interface/AddOns/SVUI_ConfigOMatic/SVUI_ConfigOMatic.toc +++ b/Interface/AddOns/SVUI_ConfigOMatic/SVUI_ConfigOMatic.toc @@ -1,6 +1,6 @@ ## Interface: 50400 ## Author: Munglunch, Elv -## Version: 4.0662 +## Version: 4.073 ## Title: |cffFF9900SVUI |r|cffFFEF00Config O Matic|r ## Notes: Supervillain UI [|cff9911FFConfig Options|r] ## RequiredDeps: SVUI diff --git a/Interface/AddOns/SVUI_ConfigOMatic/modules/units/core.lua b/Interface/AddOns/SVUI_ConfigOMatic/modules/units/core.lua index 1c9f044..612a6ea 100644 --- a/Interface/AddOns/SVUI_ConfigOMatic/modules/units/core.lua +++ b/Interface/AddOns/SVUI_ConfigOMatic/modules/units/core.lua @@ -1502,7 +1502,7 @@ SuperVillain.Options.args.SVUnit = { return SuperVillain.db.SVUnit.disableBlizzard end, set = function(key, value) - SuperVillain.db["SVUnit"].disableBlizzard = value; + MOD:ChangeDBVar(value, "disableBlizzard"); SuperVillain:StaticPopup_Show("RL_CLIENT") end }, diff --git a/Interface/AddOns/SVUI_StyleOMatic/SVUI_StyleOMatic.toc b/Interface/AddOns/SVUI_StyleOMatic/SVUI_StyleOMatic.toc index 1cea086..c03fdb1 100644 --- a/Interface/AddOns/SVUI_StyleOMatic/SVUI_StyleOMatic.toc +++ b/Interface/AddOns/SVUI_StyleOMatic/SVUI_StyleOMatic.toc @@ -1,6 +1,6 @@ ## Interface: 50400 ## Author: Munglunch, Azilroka, Sortokk -## Version: 4.0662 +## Version: 4.073 ## Title: |cffFF9900SVUI |r|cffFFEF00Style O Matic|r ## Notes: Supervillain UI [|cff9911FFAddon Skins|r]. ## RequiredDeps: SVUI