diff --git a/KkthnxUI/Modules/Auras/Core.lua b/KkthnxUI/Modules/Auras/Core.lua index 4c6168db..5f521198 100644 --- a/KkthnxUI/Modules/Auras/Core.lua +++ b/KkthnxUI/Modules/Auras/Core.lua @@ -1,16 +1,22 @@ local K, C, L = KkthnxUI[1], KkthnxUI[2], KkthnxUI[3] local Module = K:NewModule("Auras") --- Cache WoW API and Lua functions -local math_floor, select, string_format = math.floor, select, string.format -local CreateFrame, GetTime, GetWeaponEnchantInfo = CreateFrame, GetTime, GetWeaponEnchantInfo -local DebuffTypeColor, RegisterAttributeDriver, RegisterStateDriver = DebuffTypeColor, RegisterAttributeDriver, RegisterStateDriver -local GameTooltip, GetInventoryItemQuality, GetInventoryItemTexture = GameTooltip, GetInventoryItemQuality, GetInventoryItemTexture +-- Cache Lua and WoW API functions +local math_floor, string_format, select, tonumber, unpack = math.floor, string.format, select, tonumber, unpack +local CreateFrame, DebuffTypeColor, GameTooltip, GetInventoryItemQuality, GetInventoryItemTexture = CreateFrame, DebuffTypeColor, GameTooltip, GetInventoryItemQuality, GetInventoryItemTexture +local GetTime, GetWeaponEnchantInfo, RegisterAttributeDriver, RegisterStateDriver, SecureHandlerSetFrameRef = GetTime, GetWeaponEnchantInfo, RegisterAttributeDriver, RegisterStateDriver, SecureHandlerSetFrameRef +local UIParent, IsAltKeyDown, IsControlKeyDown = UIParent, IsAltKeyDown, IsControlKeyDown local day, hour, minute = 86400, 3600, 60 function Module:OnEnable() - local loadAuraModules = { "HideBlizBuff", "BuildBuffFrame", "CreateTotems", "CreateReminder" } + local loadAuraModules = { + "HideBlizBuff", + "BuildBuffFrame", + "CreateTotems", + "CreateReminder", + } + for _, funcName in ipairs(loadAuraModules) do local func = self[funcName] if type(func) == "function" then @@ -26,11 +32,12 @@ function Module:HideBlizBuff() if not C["Auras"].Enable and not C["Auras"].HideBlizBuff then return end + K:RegisterEvent("PLAYER_ENTERING_WORLD", function(_, isLogin, isReload) if isLogin or isReload then K.HideInterfaceOption(_G.BuffFrame) K.HideInterfaceOption(_G.DebuffFrame) - BuffFrame.numHideableBuffs = 0 -- Prevent error in edit mode + BuffFrame.numHideableBuffs = 0 -- fix error when on editmode end end) end @@ -40,29 +47,42 @@ function Module:BuildBuffFrame() return end - -- Buff and Debuff settings + -- Config Module.settings = { - Buffs = { offset = 12, size = C["Auras"].BuffSize, wrapAfter = C["Auras"].BuffsPerRow, maxWraps = 3, reverseGrow = C["Auras"].ReverseBuffs }, - Debuffs = { offset = 12, size = C["Auras"].DebuffSize, wrapAfter = C["Auras"].DebuffsPerRow, maxWraps = 1, reverseGrow = C["Auras"].ReverseDebuffs }, + Buffs = { + offset = 12, + size = C["Auras"].BuffSize, + wrapAfter = C["Auras"].BuffsPerRow, + maxWraps = 3, + reverseGrow = C["Auras"].ReverseBuffs, + }, + Debuffs = { + offset = 12, + size = C["Auras"].DebuffSize, + wrapAfter = C["Auras"].DebuffsPerRow, + maxWraps = 1, + reverseGrow = C["Auras"].ReverseDebuffs, + }, } - -- Create Buff Header + -- Movers Module.BuffFrame = Module:CreateAuraHeader("HELPFUL") Module.BuffFrame.mover = K.Mover(Module.BuffFrame, "Buffs", "BuffAnchor", { "TOPRIGHT", _G.Minimap, "TOPLEFT", -6, 0 }) + Module.BuffFrame:ClearAllPoints() Module.BuffFrame:SetPoint("TOPRIGHT", Module.BuffFrame.mover) - -- Create Debuff Header Module.DebuffFrame = Module:CreateAuraHeader("HARMFUL") Module.DebuffFrame.mover = K.Mover(Module.DebuffFrame, "Debuffs", "DebuffAnchor", { "TOPRIGHT", Module.BuffFrame.mover, "BOTTOMRIGHT", 0, -12 }) + Module.DebuffFrame:ClearAllPoints() Module.DebuffFrame:SetPoint("TOPRIGHT", Module.DebuffFrame.mover) end function Module:FormatAuraTime(s) if s >= day then return string_format("%d" .. K.MyClassColor .. "d", s / day), s % day - elseif s >= hour * 2 then + elseif s >= 2 * hour then return string_format("%d" .. K.MyClassColor .. "h", s / hour), s % hour - elseif s >= minute * 10 then + elseif s >= 10 * minute then return string_format("%d" .. K.MyClassColor .. "m", s / minute), s % minute elseif s >= minute then return string_format("%d:%.2d", s / minute, s % minute), s - math_floor(s) @@ -77,6 +97,7 @@ end function Module:UpdateTimer(elapsed) local onTooltip = GameTooltip:IsOwned(self) + if not (self.timeLeft or self.expiration or onTooltip) then self:SetScript("OnUpdate", nil) return @@ -84,29 +105,32 @@ function Module:UpdateTimer(elapsed) if self.timeLeft then self.timeLeft = self.timeLeft - elapsed - elseif self.expiration then - self.timeLeft = (self.expiration / 1e3) - (GetTime() - self.oldTime) end - if self.timeLeft and self.timeLeft >= 0 then - if self.nextUpdate > 0 then - self.nextUpdate = self.nextUpdate - elapsed - return - end + if self.nextUpdate > 0 then + self.nextUpdate = self.nextUpdate - elapsed + return + end + + if self.expiration then + self.timeLeft = self.expiration / 1e3 - (GetTime() - self.oldTime) + end + if self.timeLeft and self.timeLeft >= 0 then local timer, nextUpdate = Module:FormatAuraTime(self.timeLeft) self.nextUpdate = nextUpdate self.timer:SetText(timer) - else - self.timer:SetText("") -- Clear the timer if timeLeft is invalid end - -- If the tooltip is showing, update it if onTooltip then Module:Button_SetTooltip(self) end end +function Module:GetSpellStat(arg16, arg17, arg18) + return (arg16 > 0 and L["Versa"]) or (arg17 > 0 and L["Mastery"]) or (arg18 > 0 and L["Haste"]) or L["Crit"] +end + function Module:UpdateAuras(button, index) local unit, filter = button.header:GetAttribute("unit"), button.filter local auraData = C_UnitAuras.GetAuraDataByIndex(unit, index, filter) @@ -114,17 +138,28 @@ function Module:UpdateAuras(button, index) return end - button.timeLeft = auraData.duration > 0 and (auraData.expirationTime - GetTime()) or nil - if button.timeLeft then + if auraData.duration > 0 and auraData.expirationTime then + local timeLeft = auraData.expirationTime - GetTime() + if not button.timeLeft then + button.nextUpdate = -1 + button.timeLeft = timeLeft + button:SetScript("OnUpdate", Module.UpdateTimer) + else + button.timeLeft = timeLeft + end button.nextUpdate = -1 - button:SetScript("OnUpdate", Module.UpdateTimer) Module.UpdateTimer(button, 0) else + button.timeLeft = nil button.timer:SetText("") end - button.count:SetText(auraData.applications and auraData.applications > 1 and auraData.applications or "") - button.icon:SetTexture(auraData.icon) + local count = auraData.applications + if count and count > 1 then + button.count:SetText(count) + else + button.count:SetText("") + end if filter == "HARMFUL" then local color = DebuffTypeColor[auraData.dispelName or "none"] @@ -133,23 +168,33 @@ function Module:UpdateAuras(button, index) K.SetBorderColor(button.KKUI_Border) end + -- Show spell stat for 'Soleahs Secret Technique' + if auraData.spellId == 368512 then + button.count:SetText(Module:GetSpellStat(unpack(auraData.points))) + end + button.spellID = auraData.spellId + button.icon:SetTexture(auraData.icon) + button.expiration = nil end function Module:UpdateTempEnchant(button, index) local expirationTime = select(button.enchantOffset, GetWeaponEnchantInfo()) if expirationTime then local quality = GetInventoryItemQuality("player", index) - button.KKUI_Border:SetVertexColor(K.QualityColors[quality or 1].r, K.QualityColors[quality or 1].g, K.QualityColors[quality or 1].b) + local color = K.QualityColors[quality or 1] + button.KKUI_Border:SetVertexColor(color.r, color.g, color.b) button.icon:SetTexture(GetInventoryItemTexture("player", index)) + button.expiration = expirationTime button.oldTime = GetTime() button:SetScript("OnUpdate", Module.UpdateTimer) button.nextUpdate = -1 Module.UpdateTimer(button, 0) else + button.expiration = nil + button.timeLeft = nil button.timer:SetText("") - button.expiration, button.timeLeft = nil, nil end end @@ -162,46 +207,85 @@ function Module:OnAttributeChanged(attribute, value) end function Module:UpdateHeader(header) - local cfg = Module.settings[header.filter == "HELPFUL" and "Buffs" or "Debuffs"] + local cfg = Module.settings.Debuffs + if header.filter == "HELPFUL" then + cfg = Module.settings.Buffs + header:SetAttribute("consolidateTo", 0) + header:SetAttribute("weaponTemplate", string_format("KKUI_AuraTemplate%d", cfg.size)) + end + + local margin = 6 + + header:SetAttribute("separateOwn", 1) + header:SetAttribute("sortMethod", "INDEX") + header:SetAttribute("sortDirection", "+") header:SetAttribute("wrapAfter", cfg.wrapAfter) header:SetAttribute("maxWraps", cfg.maxWraps) header:SetAttribute("point", cfg.reverseGrow and "TOPLEFT" or "TOPRIGHT") - header:SetAttribute("xOffset", (cfg.reverseGrow and 1 or -1) * (cfg.size + 6)) + header:SetAttribute("minWidth", (cfg.size + margin) * cfg.wrapAfter) + header:SetAttribute("minHeight", (cfg.size + cfg.offset) * cfg.maxWraps) + header:SetAttribute("xOffset", (cfg.reverseGrow and 1 or -1) * (cfg.size + margin)) + header:SetAttribute("yOffset", 0) + header:SetAttribute("wrapXOffset", 0) header:SetAttribute("wrapYOffset", -(cfg.size + cfg.offset)) header:SetAttribute("template", string_format("KKUI_AuraTemplate%d", cfg.size)) - header:SetAttribute("minWidth", (cfg.size + 6) * cfg.wrapAfter) - header:SetAttribute("minHeight", (cfg.size + cfg.offset) * cfg.maxWraps) - header:SetAttribute("sortMethod", "INDEX") - header:SetAttribute("sortDirection", "+") - -- Update child aura frames local fontSize = math_floor(cfg.size / 30 * 12 + 0.5) - for i, child in ipairs({ header:GetChildren() }) do - if i <= (cfg.maxWraps * cfg.wrapAfter) then + local index = 1 + local child = select(index, header:GetChildren()) + while child do + if (math_floor(child:GetWidth() * 100 + 0.5) / 100) ~= cfg.size then child:SetSize(cfg.size, cfg.size) - child.count:SetFontObject(K.UIFontOutline) - child.count:SetFont(select(1, child.count:GetFont()), fontSize, select(3, child.count:GetFont())) - child.timer:SetFontObject(K.UIFontOutline) - child.timer:SetFont(select(1, child.timer:GetFont()), fontSize, select(3, child.timer:GetFont())) - else - child:Hide() -- Hide extra frames beyond wrap limit end + + child.count:SetFontObject(K.UIFontOutline) + child.count:SetFont(select(1, child.count:GetFont()), fontSize, select(3, child.count:GetFont())) + + child.timer:SetFontObject(K.UIFontOutline) + child.timer:SetFont(select(1, child.timer:GetFont()), fontSize, select(3, child.timer:GetFont())) + + -- Blizzard bug fix, icons arent being hidden when you reduce the amount of maximum buttons + if index > (cfg.maxWraps * cfg.wrapAfter) and child:IsShown() then + child:Hide() + end + + index = index + 1 + child = select(index, header:GetChildren()) end end function Module:CreateAuraHeader(filter) - local header = CreateFrame("Frame", "KKUI_Player" .. (filter == "HELPFUL" and "Buffs" or "Debuffs"), UIParent, "SecureAuraHeaderTemplate") + local name = "KKUI_PlayerDebuffs" + if filter == "HELPFUL" then + name = "KKUI_PlayerBuffs" + end + + local header = CreateFrame("Frame", name, UIParent, "SecureAuraHeaderTemplate") header:SetClampedToScreen(true) + header:UnregisterEvent("UNIT_AURA") -- we only need to watch player and vehicle header:RegisterUnitEvent("UNIT_AURA", "player", "vehicle") header:SetAttribute("unit", "player") header:SetAttribute("filter", filter) + header.filter = filter RegisterAttributeDriver(header, "unit", "[vehicleui] vehicle; player") header.visibility = CreateFrame("Frame", nil, UIParent, "SecureHandlerStateTemplate") header.visibility:RegisterEvent("WEAPON_ENCHANT_CHANGED") - RegisterStateDriver(header.visibility, "customVisibility", "[petbattle] 0;1") - header.visibility:SetAttribute("_onstate-customVisibility", [[local header = self:GetFrameRef("AuraHeader") if newstate == 0 then header:Hide() else header:Show() end]]) SecureHandlerSetFrameRef(header.visibility, "AuraHeader", header) + RegisterStateDriver(header.visibility, "customVisibility", "[petbattle] 0;1") + header.visibility:SetAttribute( + "_onstate-customVisibility", + [[ + local header = self:GetFrameRef("AuraHeader") + local hide, shown = newstate == 0, header:IsShown() + if hide and shown then header:Hide() elseif not hide and not shown then header:Show() end + ]] + ) + + if filter == "HELPFUL" then + header:SetAttribute("consolidateDuration", -1) + header:SetAttribute("includeWeapons", 1) + end Module:UpdateHeader(header) header:Show() @@ -210,7 +294,7 @@ function Module:CreateAuraHeader(filter) end function Module:RemoveSpellFromIgnoreList() - if IsAltKeyDown() and IsControlKeyDown() and self.spellID then + if IsAltKeyDown() and IsControlKeyDown() and self.spellID and KkthnxUIDB.Variables[K.Realm][K.Name].AuraWatchList.IgnoreSpells[self.spellID] then KkthnxUIDB.Variables[K.Realm][K.Name].AuraWatchList.IgnoreSpells[self.spellID] = nil K.Print(string_format(L["RemoveFromIgnoreList"], "", self.spellID)) end @@ -230,10 +314,19 @@ function Module:Button_OnEnter() self:SetScript("OnUpdate", Module.UpdateTimer) end +local indexToOffset = { 2, 6, 10 } function Module:CreateAuraIcon(button) button.header = button:GetParent() button.filter = button.header.filter - local fontSize = math_floor(Module.settings[button.filter == "HELPFUL" and "Buffs" or "Debuffs"].size / 30 * 12 + 0.5) + button.name = button:GetName() + local enchantIndex = tonumber(strmatch(button.name, "TempEnchant(%d)$")) + button.enchantOffset = indexToOffset[enchantIndex] + + local cfg = Module.settings.Debuffs + if button.filter == "HELPFUL" then + cfg = Module.settings.Buffs + end + local fontSize = math_floor(cfg.size / 30 * 12 + 0.5) button.icon = button:CreateTexture(nil, "BORDER") button.icon:SetAllPoints() diff --git a/KkthnxUI/Modules/Blizzard/Elements/AlertFrames.lua b/KkthnxUI/Modules/Blizzard/Elements/AlertFrames.lua index 0a02bc5f..6a760a76 100644 --- a/KkthnxUI/Modules/Blizzard/Elements/AlertFrames.lua +++ b/KkthnxUI/Modules/Blizzard/Elements/AlertFrames.lua @@ -1,11 +1,13 @@ local K, C = KkthnxUI[1], KkthnxUI[2] local Module = K:GetModule("Blizzard") +-- Cache global references local _G = getfenv(0) local ipairs, tremove = ipairs, table.remove -local UIParent = _G.UIParent -local AlertFrame = _G.AlertFrame -local GroupLootContainer = _G.GroupLootContainer +local CreateFrame, UIParent = CreateFrame, _G.UIParent +local AlertFrame, GroupLootContainer = _G.AlertFrame, _G.GroupLootContainer +local select = select +local hooksecurefunc = hooksecurefunc local POSITION, ANCHOR_POINT, YOFFSET = "TOP", "BOTTOM", -6 local parentFrame @@ -96,20 +98,23 @@ local function NoTalkingHeads() return end - _G.TalkingHeadFrame:UnregisterAllEvents() -- needs review + _G.TalkingHeadFrame:UnregisterAllEvents() -- Disable Talking Head Frame events hooksecurefunc(_G.TalkingHeadFrame, "Show", function(self) self:Hide() end) end function Module:CreateAlertFrames() + -- Create parent frame parentFrame = CreateFrame("Frame", nil, UIParent) parentFrame:SetSize(200, 30) K.Mover(parentFrame, "AlertFrameMover", "AlertFrameMover", { "TOP", UIParent, 0, -40 }) + -- Configure GroupLootContainer GroupLootContainer:EnableMouse(false) GroupLootContainer.ignoreFramePositionManager = true + -- Adjust position of alert frames, excluding TalkingHeadFrame for index, alertFrameSubSystem in ipairs(AlertFrame.alertFrameSubSystems) do if alertFrameSubSystem.anchorFrame and alertFrameSubSystem.anchorFrame == _G.TalkingHeadFrame then tremove(_G.AlertFrame.alertFrameSubSystems, index) @@ -118,6 +123,7 @@ function Module:CreateAlertFrames() end end + -- Hook alert frame functions for adjusting positions hooksecurefunc(AlertFrame, "AddAlertFrameSubSystem", function(_, alertFrameSubSystem) Module.AlertFrame_AdjustPosition(alertFrameSubSystem) end) @@ -125,7 +131,8 @@ function Module:CreateAlertFrames() hooksecurefunc(AlertFrame, "UpdateAnchors", Module.AlertFrame_UpdateAnchor) hooksecurefunc("GroupLootContainer_Update", Module.UpdatGroupLootContainer) - if TalkingHeadFrame then + -- Disable Talking Head Frame if necessary + if _G.TalkingHeadFrame then NoTalkingHeads() end end diff --git a/KkthnxUI/Modules/Blizzard/Elements/AltPowerBar.lua b/KkthnxUI/Modules/Blizzard/Elements/AltPowerBar.lua index 9976dc8e..73121d3d 100644 --- a/KkthnxUI/Modules/Blizzard/Elements/AltPowerBar.lua +++ b/KkthnxUI/Modules/Blizzard/Elements/AltPowerBar.lua @@ -1,15 +1,17 @@ local K, C = KkthnxUI[1], KkthnxUI[2] local Module = K:GetModule("Blizzard") +-- Cache globals +local _G = _G local math_floor = math.floor local string_format = string.format - local CreateFrame = CreateFrame local UnitPowerMax = UnitPowerMax local UnitPower = UnitPower local GetUnitPowerBarInfo = GetUnitPowerBarInfo local GetUnitPowerBarStrings = GetUnitPowerBarStrings local GameTooltip = GameTooltip +local UIParent = UIParent local AltPowerWidth = 250 local AltPowerHeight = 20 @@ -21,13 +23,13 @@ local function updateTooltip(self) if self.powerName and self.powerTooltip then GameTooltip:SetText(self.powerName, 1, 1, 1) - GameTooltip:AddLine(self.powerTooltip, nil, nil, nil, 1) + GameTooltip:AddLine(self.powerTooltip, nil, nil, nil, true) GameTooltip:Show() end end local function onEnter(self) - if (not self:IsVisible()) or GameTooltip:IsForbidden() then + if not self:IsVisible() or GameTooltip:IsForbidden() then return end @@ -66,32 +68,30 @@ function Module:PositionAltPowerBar() holder:SetPoint("TOP", UIParent, "TOP", -1, -108) holder:SetSize(128, 50) - _G.PlayerPowerBarAlt:ClearAllPoints() - _G.PlayerPowerBarAlt:SetPoint("CENTER", holder, "CENTER") - _G.PlayerPowerBarAlt:SetParent(holder) - _G.PlayerPowerBarAlt:SetMovable(true) - _G.PlayerPowerBarAlt:SetUserPlaced(true) - _G.PlayerPowerBarAlt.ignoreFramePositionManager = true + local PlayerPowerBarAlt = _G.PlayerPowerBarAlt + PlayerPowerBarAlt:ClearAllPoints() + PlayerPowerBarAlt:SetPoint("CENTER", holder, "CENTER") + PlayerPowerBarAlt:SetParent(holder) + PlayerPowerBarAlt:SetMovable(true) + PlayerPowerBarAlt:SetUserPlaced(true) + PlayerPowerBarAlt.ignoreFramePositionManager = true - K.Mover(holder, "PlayerPowerBarAlt", "Alternative Power", { "TOP", UIParent, "TOP", -1, -108 }, AltPowerWidth or 250, AltPowerHeight or 20) + K.Mover(holder, "PlayerPowerBarAlt", "Alternative Power", { "TOP", UIParent, "TOP", -1, -108 }, AltPowerWidth, AltPowerHeight) end function Module:UpdateAltPowerBarColors() local bar = KKUI_AltPowerBar - local color = { r = 0.2, g = 0.4, b = 0.8 } bar:SetStatusBarColor(color.r, color.g, color.b) end function Module:UpdateAltPowerBarSettings() local bar = KKUI_AltPowerBar - - bar:SetSize(AltPowerWidth or 250, AltPowerHeight or 20) + bar:SetSize(AltPowerWidth, AltPowerHeight) bar:SetStatusBarTexture(K.GetTexture(C["General"].Texture)) bar.text:SetFontObject(K.UIFont) _G.AltPowerBarHolder:SetSize(bar:GetSize()) - K:SmoothBar(bar) Module:SetAltPowerBarText(bar.text, bar.powerName or "", bar.powerValue or 0, bar.powerMaxValue or 0, bar.powerPercent or 0) @@ -106,7 +106,7 @@ function Module:UpdateAltPowerBar() if barInfo then local power = UnitPower("player", _G.ALTERNATE_POWER_INDEX) local maxPower = UnitPowerMax("player", _G.ALTERNATE_POWER_INDEX) or 0 - local perc = (maxPower > 0 and math_floor(power / maxPower * 100)) or 0 + local perc = maxPower > 0 and math_floor(power / maxPower * 100) or 0 self.powerMaxValue = maxPower self.powerName = powerName diff --git a/KkthnxUI/Modules/Blizzard/Elements/ColorPicker.lua b/KkthnxUI/Modules/Blizzard/Elements/ColorPicker.lua index 98e6fa36..4f01922c 100644 --- a/KkthnxUI/Modules/Blizzard/Elements/ColorPicker.lua +++ b/KkthnxUI/Modules/Blizzard/Elements/ColorPicker.lua @@ -1,41 +1,45 @@ local K, C = KkthnxUI[1], KkthnxUI[2] local Module = K:GetModule("Blizzard") +-- Cache global references local string_format = string.format local string_match = string.match +local tonumber = tonumber +local CreateFrame = CreateFrame +local ColorPickerFrame = ColorPickerFrame +local pairs = pairs +local _G = _G --- Enhanced ColorPickerFrame +-- Utility function to translate color local function translateColor(r) if not r then r = "ff" end - return tonumber(r, 16) / 255 end +-- Enhanced ColorPickerFrame functions function Module:EnhancedPicker_UpdateColor() local r, g, b = string_match(self.colorStr, "(%x%x)(%x%x)(%x%x)$") r = translateColor(r) g = translateColor(g) b = translateColor(b) - _G.ColorPickerFrame:SetColorRGB(r, g, b) + ColorPickerFrame:SetColorRGB(r, g, b) end local function GetBoxColor(box) - local r = box:GetText() - r = tonumber(r) + local r = tonumber(box:GetText()) if not r or r < 0 or r > 255 then r = 255 end - return r end local function updateColorRGB(self) - local r = GetBoxColor(_G.ColorPickerFrame.__boxR) - local g = GetBoxColor(_G.ColorPickerFrame.__boxG) - local b = GetBoxColor(_G.ColorPickerFrame.__boxB) + local r = GetBoxColor(ColorPickerFrame.__boxR) + local g = GetBoxColor(ColorPickerFrame.__boxG) + local b = GetBoxColor(ColorPickerFrame.__boxB) self.colorStr = string_format("%02x%02x%02x", r, g, b) Module.EnhancedPicker_UpdateColor(self) @@ -51,19 +55,18 @@ local function editBoxClearFocus(self) end local function createCodeBox(width, index, text) - local box = CreateFrame("EditBox", nil, _G.ColorPickerFrame) + local box = CreateFrame("EditBox", nil, ColorPickerFrame) box:SetSize(width, 20) box:SetAutoFocus(false) box:SetTextInsets(5, 5, 0, 0) box:SetMaxLetters(index == 4 and 6 or 3) - box:SetTextInsets(0, 0, 0, 0) box:SetPoint("TOPLEFT", _G.ColorSwatch, "BOTTOMLEFT", 0, -index * 26) box:SetFontObject(K.UIFont) - box.bg = CreateFrame("Button", nil, box) - box.bg:SetAllPoints() - box.bg:SetFrameLevel(box:GetFrameLevel()) - box.bg:CreateBorder() + local bg = CreateFrame("Button", nil, box) + bg:SetAllPoints() + bg:SetFrameLevel(box:GetFrameLevel()) + bg:CreateBorder() box:SetScript("OnEscapePressed", editBoxClearFocus) box:SetScript("OnEnterPressed", editBoxClearFocus) @@ -75,11 +78,10 @@ local function createCodeBox(width, index, text) box:HookScript("OnEnterPressed", updateColorRGB) end - -- box.Type = "EditBox" - return box end +-- Create enhanced color picker frame function Module:CreateColorPicker() if C_AddOns.IsAddOnLoaded("ColorPickerPlus") or C["Misc"].ColorPicker ~= true then return @@ -87,8 +89,7 @@ function Module:CreateColorPicker() local pickerFrame = ColorPickerFrame pickerFrame:SetHeight(250) - K.CreateMoverFrame(pickerFrame.Header, pickerFrame) -- movable by header - --_G.OpacitySliderFrame:SetPoint("TOPLEFT", _G.ColorSwatch, "TOPRIGHT", 50, 0) + K.CreateMoverFrame(pickerFrame.Header, pickerFrame) local colorBar = CreateFrame("Frame", nil, pickerFrame) colorBar:SetSize(1, 20) @@ -101,10 +102,10 @@ function Module:CreateColorPicker() local bu = CreateFrame("Button", nil, colorBar) bu:SetSize(20, 20) - bu.Icon = bu:CreateTexture(nil, "ARTWORK") - bu.Icon:SetAllPoints() - bu.Icon:SetTexCoord(K.TexCoords[1], K.TexCoords[2], K.TexCoords[3], K.TexCoords[4]) - bu.Icon:SetColorTexture(value.r, value.g, value.b) + local icon = bu:CreateTexture(nil, "ARTWORK") + icon:SetAllPoints() + icon:SetTexCoord(K.TexCoords[1], K.TexCoords[2], K.TexCoords[3], K.TexCoords[4]) + icon:SetColorTexture(value.r, value.g, value.b) bu:SetPoint("LEFT", count * 25, 0) bu:CreateBorder() diff --git a/KkthnxUI/Modules/Blizzard/Elements/ObjectiveFrame.lua b/KkthnxUI/Modules/Blizzard/Elements/ObjectiveFrame.lua index 917db181..f89fcea6 100644 --- a/KkthnxUI/Modules/Blizzard/Elements/ObjectiveFrame.lua +++ b/KkthnxUI/Modules/Blizzard/Elements/ObjectiveFrame.lua @@ -1,89 +1,4 @@ local K, C = KkthnxUI[1], KkthnxUI[2] local Module = K:GetModule("Blizzard") -local CreateFrame = CreateFrame -local GetInstanceInfo = GetInstanceInfo -local IsInJailersTower = IsInJailersTower -local hooksecurefunc = hooksecurefunc - -local function IsFramePositionedLeft(frame) - local x = frame:GetCenter() - return x and x < (K.ScreenWidth * 0.5) -- positioned on left side -end - -local function RewardsFrame_SetPosition(block) - local rewards = ObjectiveTrackerBonusRewardsFrame - rewards:ClearAllPoints() - - if IsFramePositionedLeft(_G.ObjectiveTrackerFrame) then - rewards:SetPoint("TOPLEFT", block, "TOPRIGHT", -10, -4) - else - rewards:SetPoint("TOPRIGHT", block, "TOPLEFT", 10, -4) - end -end - -local function AutoHider_OnHide() - if not _G.ObjectiveTrackerFrame.collapsed then - local _, _, difficultyID = GetInstanceInfo() - if difficultyID ~= 8 then -- ignore hide in keystone runs - _G.ObjectiveTracker_Collapse() - end - end -end - -local function AutoHider_OnShow() - if _G.ObjectiveTrackerFrame.collapsed then - _G.ObjectiveTracker_Expand() - end -end - -local function MawBuffsList_OnShow(list) - list.button:SetHighlightAtlas("jailerstower-animapowerbutton-highlight", true) - list.button:SetPushedAtlas("jailerstower-animapowerbutton-normalpressed", true) - list.button:SetButtonState("PUSHED", true) - list.button:SetButtonState("NORMAL") -end - -function Module:HandleMawBuffsFrame() - if not IsInJailersTower() then - return - end - - local container = ScenarioBlocksFrame.MawBuffsBlock.Container - container.List:ClearAllPoints() - - if IsFramePositionedLeft(_G.ScenarioBlocksFrame) then - container.List:SetPoint("TOPLEFT", container, "TOPRIGHT", 15, 1) - container.List:SetScript("OnShow", MawBuffsList_OnShow) - else - container.List:SetPoint("TOPRIGHT", container, "TOPLEFT", 15, 1) - end -end - -function Module:SetObjectiveFrameAutoHide() - if not _G.ObjectiveTrackerFrame.AutoHider then - return -- Kaliel's Tracker prevents Module:MoveObjectiveFrame() from executing - end - - if C["Automation"].AutoCollapse then - RegisterStateDriver(_G.ObjectiveTrackerFrame.AutoHider, "objectiveHider", "[@arena1,exists][@arena2,exists][@arena3,exists][@arena4,exists][@arena5,exists][@boss1,exists][@boss2,exists][@boss3,exists][@boss4,exists][@boss5,exists] 1;0") - else - UnregisterStateDriver(_G.ObjectiveTrackerFrame.AutoHider, "objectiveHider") - end -end - --- keeping old name, not used to move just to handle the objective things --- wrath has it's own file, which actually has the mover on that client -function Module:CreateObjectiveFrame() - -- local tracker = ObjectiveTrackerFrame - -- tracker.AutoHider = CreateFrame("Frame", nil, tracker, "SecureHandlerStateTemplate") - -- tracker.AutoHider:SetAttribute("_onstate-objectiveHider", "if newstate == 1 then self:Hide() else self:Show() end") - -- tracker.AutoHider:SetScript("OnHide", AutoHider_OnHide) - -- tracker.AutoHider:SetScript("OnShow", AutoHider_OnShow) - -- Module:SetObjectiveFrameAutoHide() - - -- hooksecurefunc("BonusObjectiveTracker_AnimateReward", RewardsFrame_SetPosition) -- What was this changed to? Bugged! - - -- K:RegisterEvent("ZONE_CHANGED_NEW_AREA", Module.HandleMawBuffsFrame) - -- Module:HandleMawBuffsFrame() -end +function Module:CreateObjectiveFrame() end