diff --git a/DarkMode.toc b/DarkMode.toc index 956b093..4a579f1 100644 --- a/DarkMode.toc +++ b/DarkMode.toc @@ -3,7 +3,7 @@ ## Interface-Wrath: 30402 ## Interface: 100107 -## Version: 0.3.25 +## Version: 0.3.26 ## Title: DarkMode by |cff3FC7EBD4KiR |T132115:16:16:0:0|t ## Notes: Improve Any Ui or Frame ## Author: D4KiR diff --git a/DarkMode_TBC.toc b/DarkMode_TBC.toc index c56f8b9..596a8ee 100644 --- a/DarkMode_TBC.toc +++ b/DarkMode_TBC.toc @@ -1,5 +1,5 @@ ## Interface: 20504 -## Version: 0.3.25 +## Version: 0.3.26 ## Title: DarkMode |T136122:16:16:0:0|t by |cff3FC7EBD4KiR |T132115:16:16:0:0|t ## Notes: Improve Any Ui or Frame ## Author: D4KiR diff --git a/DarkMode_Vanilla.toc b/DarkMode_Vanilla.toc index a555e15..fff885c 100644 --- a/DarkMode_Vanilla.toc +++ b/DarkMode_Vanilla.toc @@ -1,5 +1,5 @@ ## Interface: 11404 -## Version: 0.3.25 +## Version: 0.3.26 ## Title: DarkMode |T136122:16:16:0:0|t by |cff3FC7EBD4KiR |T132115:16:16:0:0|t ## Notes: Improve Any Ui or Frame ## Author: D4KiR diff --git a/DarkMode_Wrath.toc b/DarkMode_Wrath.toc index 53a3a54..9d8ec98 100644 --- a/DarkMode_Wrath.toc +++ b/DarkMode_Wrath.toc @@ -1,5 +1,5 @@ ## Interface: 30402 -## Version: 0.3.25 +## Version: 0.3.26 ## Title: DarkMode |T136122:16:16:0:0|t by |cff3FC7EBD4KiR |T132115:16:16:0:0|t ## Notes: Improve Any Ui or Frame ## Author: D4KiR diff --git a/core.lua b/core.lua index 10c00a8..80a59e5 100644 --- a/core.lua +++ b/core.lua @@ -2,32 +2,35 @@ local _, DarkMode = ... -- TAINTFREE SLASH COMMANDS -- local lastMessage = "" local cmds = {} - -hooksecurefunc("ChatEdit_ParseText", function(editBox, send, parseIfNoSpace) - if send == 0 then - lastMessage = editBox:GetText() +hooksecurefunc( + "ChatEdit_ParseText", + function(editBox, send, parseIfNoSpace) + if send == 0 then + lastMessage = editBox:GetText() + end end -end) - -hooksecurefunc("ChatFrame_DisplayHelpTextSimple", function(frame) - if lastMessage and lastMessage ~= "" then - local cmd = string.upper(lastMessage) - cmd = strsplit(" ", cmd) - - if cmds[cmd] ~= nil then - local count = 1 - local numMessages = frame:GetNumMessages() +) + +hooksecurefunc( + "ChatFrame_DisplayHelpTextSimple", + function(frame) + if lastMessage and lastMessage ~= "" then + local cmd = string.upper(lastMessage) + cmd = strsplit(" ", cmd) + if cmds[cmd] ~= nil then + local count = 1 + local numMessages = frame:GetNumMessages() + local function predicateFunction(entry) + if count == numMessages and entry == HELP_TEXT_SIMPLE then return true end + count = count + 1 + end - local function predicateFunction(entry) - if count == numMessages and entry == HELP_TEXT_SIMPLE then return true end - count = count + 1 + frame:RemoveMessagesByPredicate(predicateFunction) + cmds[cmd]() end - - frame:RemoveMessagesByPredicate(predicateFunction) - cmds[cmd]() end end -end) +) function DarkMode:InitSlash() cmds["/DM"] = DarkMode.ToggleSettings @@ -44,10 +47,8 @@ local DMTexturesUi = {} local DMTexturesUF = {} local DMTexturesTT = {} local DMTexturesFrames = {} - function DarkMode:UpdateColor(texture, typ) if not DarkMode:IsValidTexture(texture) then return false end - if texture == nil then print("INVALID TEXTURE OBJECT") @@ -55,18 +56,15 @@ function DarkMode:UpdateColor(texture, typ) end local textureId = nil - if texture.GetTexture ~= nil then textureId = texture:GetTexture() end if textureId and DarkMode:GetTextureBlockTable()[textureId] then return false end if texture:GetAlpha() == 0 then return false end - if textureId == nil and texture.SetColorTexture then if typ == "ui" then local r, g, b, a = DarkMode:GetUiColor() - if r ~= nil and g ~= nil and b ~= nil then if texture:GetAlpha() < 1 then a = texture:GetAlpha() @@ -76,7 +74,6 @@ function DarkMode:UpdateColor(texture, typ) end elseif typ == "uf" then local r, g, b, a = DarkMode:GetUFColor() - if r ~= nil and g ~= nil and b ~= nil then if texture:GetAlpha() < 1 then a = texture:GetAlpha() @@ -86,7 +83,6 @@ function DarkMode:UpdateColor(texture, typ) end elseif typ == "tt" then local r, g, b, a = DarkMode:GetTTColor() - if r ~= nil and g ~= nil and b ~= nil then if texture:GetAlpha() < 1 then a = texture:GetAlpha() @@ -96,7 +92,6 @@ function DarkMode:UpdateColor(texture, typ) end else local r, g, b, a = DarkMode:GetFrameColor() - if r ~= nil and g ~= nil and b ~= nil then if texture:GetAlpha() < 1 then a = texture:GetAlpha() @@ -109,65 +104,58 @@ function DarkMode:UpdateColor(texture, typ) return true elseif textureId and texture.SetVertexColor then if texture.SetText then return false end - if texture.dm_setup == nil then texture.dm_setup = true - - hooksecurefunc(texture, "SetVertexColor", function(sel, olr, olg, olb, ola) - if sel.dm_setvertexcolor then return end - sel.dm_setvertexcolor = true - - if typ == "ui" then - local r, g, b, a = DarkMode:GetUiColor() - - if r ~= nil and g ~= nil and b ~= nil then - sel:SetVertexColor(r, g, b, a) - end - elseif typ == "uf" then - local r, g, b, a = DarkMode:GetUFColor() - - if r ~= nil and g ~= nil and b ~= nil then - sel:SetVertexColor(r, g, b, a) + hooksecurefunc( + texture, + "SetVertexColor", + function(sel, olr, olg, olb, ola) + if sel.dm_setvertexcolor then return end + sel.dm_setvertexcolor = true + if typ == "ui" then + local r, g, b, a = DarkMode:GetUiColor() + if r ~= nil and g ~= nil and b ~= nil then + sel:SetVertexColor(r, g, b, a) + end + elseif typ == "uf" then + local r, g, b, a = DarkMode:GetUFColor() + if r ~= nil and g ~= nil and b ~= nil then + sel:SetVertexColor(r, g, b, a) + end + elseif typ == "tt" then + local r, g, b, a = DarkMode:GetTTColor() + if r ~= nil and g ~= nil and b ~= nil then + sel:SetVertexColor(r, g, b, a) + end + else + local r, g, b, a = DarkMode:GetFrameColor() + if r ~= nil and g ~= nil and b ~= nil then + sel:SetVertexColor(r, g, b, a) + end end - elseif typ == "tt" then - local r, g, b, a = DarkMode:GetTTColor() - if r ~= nil and g ~= nil and b ~= nil then - sel:SetVertexColor(r, g, b, a) - end - else - local r, g, b, a = DarkMode:GetFrameColor() - - if r ~= nil and g ~= nil and b ~= nil then - sel:SetVertexColor(r, g, b, a) - end + sel.dm_setvertexcolor = false end - - sel.dm_setvertexcolor = false - end) + ) end if typ == "ui" then local r, g, b, a = DarkMode:GetUiColor() - if r ~= nil and g ~= nil and b ~= nil then texture:SetVertexColor(r, g, b, a) end elseif typ == "uf" then local r, g, b, a = DarkMode:GetUFColor() - if r ~= nil and g ~= nil and b ~= nil then texture:SetVertexColor(r, g, b, a) end elseif typ == "tt" then local r, g, b, a = DarkMode:GetTTColor() - if r ~= nil and g ~= nil and b ~= nil then texture:SetVertexColor(r, g, b, a) end else local r, g, b, a = DarkMode:GetFrameColor() - if r ~= nil and g ~= nil and b ~= nil then texture:SetVertexColor(r, g, b, a) end @@ -199,7 +187,6 @@ end function DarkMode:GetFrame(name) local frame = _G[name] - if frame ~= nil and type(frame) == "table" then return frame elseif strfind(name, ".", 1, true) then @@ -240,32 +227,31 @@ local function RemoveColorCodes(text) end local DMFS = {} - function DarkMode:UpdateText(text, name, layer) if text and text.SetTextColor then if text.dm_setup == nil then text.dm_setup = true - - hooksecurefunc(text, "SetTextColor", function(sel, olr, olg, olb, ola) - if sel.dm_settextcolor then return end - sel.dm_settextcolor = true - local r, g, b, a = DarkMode:GetFrameColor() - - if r ~= nil and g ~= nil and b ~= nil then - local cr, cg, cb, ca = DarkMode:GetTextColor(r, g, b, a) - sel:SetTextColor(cr, cg, cb, ca) - - if sel:GetText() then - sel:SetText(RGBToHexC(cr, cg, cb) .. RemoveColorCodes(sel:GetText())) + hooksecurefunc( + text, + "SetTextColor", + function(sel, olr, olg, olb, ola) + if sel.dm_settextcolor then return end + sel.dm_settextcolor = true + local r, g, b, a = DarkMode:GetFrameColor() + if r ~= nil and g ~= nil and b ~= nil then + local cr, cg, cb, ca = DarkMode:GetTextColor(r, g, b, a) + sel:SetTextColor(cr, cg, cb, ca) + if sel:GetText() then + sel:SetText(RGBToHexC(cr, cg, cb) .. RemoveColorCodes(sel:GetText())) + end end - end - sel.dm_settextcolor = false - end) + sel.dm_settextcolor = false + end + ) end local r, g, b, a = DarkMode:GetFrameColor() - if r ~= nil and g ~= nil and b ~= nil then text:SetTextColor(DarkMode:GetTextColor(r, g, b, a)) end @@ -314,7 +300,6 @@ end function DarkMode:FindTextsByName(name) local frame = DarkMode:GetFrame(name) - if frame and DarkMode:GV("COLORMODEF", 1) ~= 7 then DarkMode:FindTexts(frame, name) end @@ -323,7 +308,6 @@ end function DarkMode:UpdateColors() for i, v in pairs(DMTexturesUi) do local r, g, b, a = DarkMode:GetUiColor() - if r ~= nil and g ~= nil and b ~= nil then v:SetVertexColor(r, g, b, a) end @@ -331,7 +315,6 @@ function DarkMode:UpdateColors() for i, v in pairs(DMTexturesUF) do local r, g, b, a = DarkMode:GetUFColor() - if r ~= nil and g ~= nil and b ~= nil then v:SetVertexColor(r, g, b, a) end @@ -339,7 +322,6 @@ function DarkMode:UpdateColors() for i, v in pairs(DMTexturesTT) do local r, g, b, a = DarkMode:GetTTColor() - if r ~= nil and g ~= nil and b ~= nil then v:SetVertexColor(r, g, b, a) end @@ -348,7 +330,6 @@ function DarkMode:UpdateColors() -- FONTSTRINGS for i, v in pairs(DMFS) do local r, g, b, a = DarkMode:GetFrameColor() - if r ~= nil and g ~= nil and b ~= nil then v:SetVertexColor(r, g, b, a) end @@ -356,7 +337,6 @@ function DarkMode:UpdateColors() for i, v in pairs(DMTexturesFrames) do local r, g, b, a = DarkMode:GetFrameColor() - if r ~= nil and g ~= nil and b ~= nil then v:SetVertexColor(r, g, b, a) end @@ -376,7 +356,6 @@ function DarkMode:FindTextures(frame, typ) local ignoreId1 = nil local ignoreId2 = nil local ignoreId3 = nil - if frame and frame.GetName and frame:GetName() ~= nil then if string.find(frame:GetName(), "SkillLineTab") then ignoreId1 = 2 @@ -388,7 +367,6 @@ function DarkMode:FindTextures(frame, typ) end local findName = "XX" - if frame.GetName and frame:GetName() then if DarkMode:GetIgnoreFrames(frame:GetName()) then return @@ -408,7 +386,6 @@ function DarkMode:FindTextures(frame, typ) if frame.GetRegions and getn({frame:GetRegions()}) > 0 then for i, v in pairs({frame:GetRegions()}) do local hasName = v.GetName ~= nil - if (ignoreId1 == nil or ignoreId1 ~= i) and (ignoreId2 == nil or ignoreId2 ~= i) and (ignoreId3 == nil or ignoreId3 ~= i) and ((hasName and not DarkMode:GetIgnoreFrames(v:GetName())) or (not hasName and v.SetVertexColor)) then if show and v.GetTexture then print(">>", frame:GetName(), v:GetName(), v:GetTextureFilePath(), v:GetTexture(), "Size:", v:GetSize()) @@ -424,7 +401,6 @@ function DarkMode:FindTextures(frame, typ) if frame.GetChildren and getn({frame:GetChildren()}) > 0 then for i, v in pairs({frame:GetChildren()}) do local hasName = v.GetName ~= nil - if (ignoreId1 == nil or ignoreId1 ~= i) and (ignoreId2 == nil or ignoreId2 ~= i) and (ignoreId3 == nil or ignoreId3 ~= i) and ((hasName and not DarkMode:GetIgnoreFrames(v:GetName())) or (not hasName and v.SetVertexColor)) then if show and v.GetTexture then print(">>>", frame:GetName(), v:GetName(), v:GetTextureFilePath(), v:GetTexture(), "Size:", v:GetSize()) @@ -441,7 +417,6 @@ end function DarkMode:FindTexturesByName(name, typ) local frame = DarkMode:GetFrame(name) - if name and strfind(name, "Container", 1, true) and strfind(name, "TopSection", 1, true) then show = true end @@ -453,9 +428,7 @@ end function DarkMode:InitGreetingPanel() local frame = DarkMode:GetFrame("GossipFrame.GreetingPanel.ScrollBox.ScrollTarget") - local frameTab = {"GossipFrame", "GossipFrame.GreetingPanel", "GossipFrame.GreetingPanel.ScrollBox", "GossipFrame.GreetingPanel.ScrollBar.Background",} - function DarkMode:UpdateGossipFrame() if frame == GossipFrame then DarkMode:FindTextsByName("GossipFrame") @@ -476,30 +449,46 @@ function DarkMode:InitGreetingPanel() if frame then if GossipFrame.GreetingPanel then - hooksecurefunc(GossipFrame.GreetingPanel.ScrollBox, "FullUpdate", function() - DarkMode:UpdateGossipFrame() - end) + hooksecurefunc( + GossipFrame.GreetingPanel.ScrollBox, + "FullUpdate", + function() + DarkMode:UpdateGossipFrame() + end + ) end - frame:HookScript("OnShow", function(sel, ...) - C_Timer.After(0.05, function() - DarkMode:UpdateGossipFrame() - end) - end) + frame:HookScript( + "OnShow", + function(sel, ...) + C_Timer.After( + 0.05, + function() + DarkMode:UpdateGossipFrame() + end + ) + end + ) if GossipFrame.OnEvent then - hooksecurefunc(GossipFrame, "OnEvent", function() - C_Timer.After(0.05, function() - DarkMode:UpdateGossipFrame() - end) - end) + hooksecurefunc( + GossipFrame, + "OnEvent", + function() + C_Timer.After( + 0.05, + function() + DarkMode:UpdateGossipFrame() + end + ) + end + ) end end end function DarkMode:InitQuestLogFrame() local frame = DarkMode:GetFrame("QuestLogFrame") - function DarkMode:UpdateQuestLogFrame() for index, name in pairs(DarkMode:GetFrameTextTable()) do DarkMode:FindTextsByName(name) @@ -507,23 +496,35 @@ function DarkMode:InitQuestLogFrame() end if frame then - frame:HookScript("OnShow", function(sel, ...) - C_Timer.After(0.05, function() - DarkMode:UpdateQuestLogFrame() - end) - end) + frame:HookScript( + "OnShow", + function(sel, ...) + C_Timer.After( + 0.05, + function() + DarkMode:UpdateQuestLogFrame() + end + ) + end + ) if frame.OnEvent then - hooksecurefunc(frame, "OnEvent", function() - C_Timer.After(0.05, function() - DarkMode:UpdateQuestLogFrame() - end) - end) + hooksecurefunc( + frame, + "OnEvent", + function() + C_Timer.After( + 0.05, + function() + DarkMode:UpdateQuestLogFrame() + end + ) + end + ) end end local frame2 = DarkMode:GetFrame("QuestMapFrame") - function DarkMode:UpdateQuestMapFrame() for index, name in pairs(DarkMode:GetFrameTextTable()) do DarkMode:FindTextsByName(name) @@ -531,20 +532,22 @@ function DarkMode:InitQuestLogFrame() end if frame2 then - hooksecurefunc(QuestMapFrame.DetailsFrame.SealMaterialBG, "SetVertexColor", function(sel, olr, olg, olb, ola) - if sel.dm_setvertexcolor then return end - sel.dm_setvertexcolor = true - local r, g, b, a = DarkMode:GetFrameColor() + hooksecurefunc( + QuestMapFrame.DetailsFrame.SealMaterialBG, + "SetVertexColor", + function(sel, olr, olg, olb, ola) + if sel.dm_setvertexcolor then return end + sel.dm_setvertexcolor = true + local r, g, b, a = DarkMode:GetFrameColor() + if r ~= nil and g ~= nil and b ~= nil then + sel:SetVertexColor(r, g, b, a) + end - if r ~= nil and g ~= nil and b ~= nil then - sel:SetVertexColor(r, g, b, a) + sel.dm_setvertexcolor = false end - - sel.dm_setvertexcolor = false - end) + ) local r, g, b, a = DarkMode:GetFrameColor() - if r ~= nil and g ~= nil and b ~= nil then QuestMapFrame.DetailsFrame.SealMaterialBG:SetVertexColor(r, g, b, a) end @@ -579,7 +582,6 @@ function DarkMode:SearchUi() if index == "ActionButtons" then for i, name in pairs(tab) do local max = 12 - --[[ Bar Addons ]] if name == "BT4Button" or name == "DominosActionButton" then max = 120 @@ -587,7 +589,6 @@ function DarkMode:SearchUi() for x = 1, max do local btnTexture = _G[name .. x .. "NormalTexture"] - if name == "BT4StanceButton" and _G[name .. x] and _G[name .. x .. "BorderFix"] == nil then local sw, sh = _G[name .. x]:GetSize() sw = DarkMode:MathR(sw) @@ -605,7 +606,6 @@ function DarkMode:SearchUi() end local btnTexture2 = _G[name .. x .. "FloatingBG"] - if btnTexture2 then DarkMode:UpdateColor(btnTexture2, "ui") end @@ -616,7 +616,6 @@ function DarkMode:SearchUi() if DarkMode:GetWoWBuild() ~= "RETAIL" and DarkMode:IsEnabled("MASKACTIONBUTTONS", true) then local icon = _G[name .. x .. "Icon"] - if icon then local br = 0.01 icon:SetTexCoord(br, 1 - br, br, 1 - br) @@ -669,7 +668,6 @@ function DarkMode:SearchUi() for i, name in pairs(MICRO_BUTTONS) do if name then local mbtn = _G[name] - if mbtn then local border = mbtn:CreateTexture(name .. "DMBorder", "OVERLAY") border:SetTexture("Interface\\AddOns\\DarkMode\\media\\mbtn_border") @@ -743,7 +741,6 @@ function DarkMode:SearchUi() if GameTimeFrame and DarkMode:GetWoWBuild() ~= "RETAIL" then local border = GameTimeFrame:CreateTexture("GameTimeFrame" .. "DMBorder", "OVERLAY") border:SetTexture("Interface\\AddOns\\DarkMode\\media\\gt_border") - if DarkMode:GetWoWBuild() == "WRATH" then border:SetPoint("TOPLEFT", -1, 1) border:SetScale(0.82) @@ -755,26 +752,39 @@ function DarkMode:SearchUi() DarkMode:UpdateColor(border, "ui") end - C_Timer.After(1.1, function() - if DMMMBTN then - for i, name in pairs(DMMMBTN:GetButtonList()) do - local btn = _G["LibDBIcon10_" .. name] - - if btn then - local border = btn:CreateTexture(name .. "DMBorder", "OVERLAY") - border:SetTexture("Interface\\AddOns\\DarkMode\\media\\mmicon_border") - border:SetPoint("TOPLEFT", 0, 1) - border:SetParent(btn) - border:SetScale(0.84) - border:SetDrawLayer("OVERLAY", 3) - DarkMode:UpdateColor(border, "ui") + C_Timer.After( + 1.1, + function() + if DMMMBTN then + for i, name in pairs(DMMMBTN:GetButtonList()) do + local btn = _G["LibDBIcon10_" .. name] + if btn then + local border = btn:CreateTexture(name .. "DMBorder", "OVERLAY") + border:SetTexture("Interface\\AddOns\\DarkMode\\media\\mmicon_border") + border:SetPoint("TOPLEFT", 0, 1) + border:SetParent(btn) + border:SetScale(0.84) + border:SetDrawLayer("OVERLAY", 3) + DarkMode:UpdateColor(border, "ui") + end + end + end + + if Lib_GPI_Minimap_LFGBulletinBoard then + for i, v in pairs({Lib_GPI_Minimap_LFGBulletinBoard:GetRegions()}) do + if i == 2 then + DarkMode:UpdateColor(v, "ui") + end end end + + if PeggledMinimapIcon and PeggledMinimapIcon.border then + DarkMode:UpdateColor(PeggledMinimapIcon.border, "ui") + end end - end) + ) local btwQ = _G["BtWQuestsMinimapButton"] - if btwQ then local border = btwQ:CreateTexture("BtWQuestsMinimapButton" .. "DMBorder", "OVERLAY") border:SetTexture("Interface\\AddOns\\DarkMode\\media\\mmicon_border") @@ -788,59 +798,83 @@ end local npf = CreateFrame("FRAME") npf:RegisterEvent("NAME_PLATE_UNIT_ADDED") - -npf:SetScript("OnEvent", function(self, event, name, ...) - local id = string.sub(name, 10) - - C_Timer.After(0.1, function() - DarkMode:FindTexturesByName("NamePlate" .. id .. ".UnitFrame.healthBar.border", "uf") - end) -end) +npf:SetScript( + "OnEvent", + function(self, event, name, ...) + local id = string.sub(name, 10) + C_Timer.After( + 0.1, + function() + DarkMode:FindTexturesByName("NamePlate" .. id .. ".UnitFrame.healthBar.border", "uf") + end + ) + end +) function DarkMode:InitQuestFrame() local frame = DarkMode:GetFrame("QuestFrameGreetingPanel") - function DarkMode:UpdateQuestFrameGreetingPanel() DarkMode:FindTextsByName("QuestFrameGreetingPanel") end if QuestFrame then - QuestFrame:HookScript("OnShow", function(sel, ...) - DarkMode:SearchFrames() - end) + QuestFrame:HookScript( + "OnShow", + function(sel, ...) + DarkMode:SearchFrames() + end + ) end if QuestFrameRewardPanel then - QuestFrameRewardPanel:HookScript("OnShow", function(sel, ...) - DarkMode:SearchFrames() - end) + QuestFrameRewardPanel:HookScript( + "OnShow", + function(sel, ...) + DarkMode:SearchFrames() + end + ) end if QuestFrameDetailPanel then - QuestFrameDetailPanel:HookScript("OnShow", function(sel, ...) - DarkMode:SearchFrames() - end) + QuestFrameDetailPanel:HookScript( + "OnShow", + function(sel, ...) + DarkMode:SearchFrames() + end + ) end if frame then - frame:HookScript("OnShow", function(sel, ...) - C_Timer.After(0.05, function() - DarkMode:UpdateQuestFrameGreetingPanel() - end) - end) + frame:HookScript( + "OnShow", + function(sel, ...) + C_Timer.After( + 0.05, + function() + DarkMode:UpdateQuestFrameGreetingPanel() + end + ) + end + ) if QuestFrame.OnEvent then - hooksecurefunc(QuestFrame, "OnEvent", function() - C_Timer.After(0.05, function() - DarkMode:UpdateQuestFrameGreetingPanel() - end) - end) + hooksecurefunc( + QuestFrame, + "OnEvent", + function() + C_Timer.After( + 0.05, + function() + DarkMode:UpdateQuestFrameGreetingPanel() + end + ) + end + ) end end end local BAGS = {"MainMenuBarBackpackButton", "CharacterBag0Slot", "CharacterBag1Slot", "CharacterBag2Slot", "CharacterBag3Slot"} - function DarkMode:Event(event, ...) if event == "PLAYER_LOGIN" then if DarkMode.Setup == nil then @@ -851,102 +885,116 @@ function DarkMode:Event(event, ...) DarkMode:InitGreetingPanel() DarkMode:InitQuestLogFrame() DarkMode:InitQuestFrame() - if DarkMode:GetWoWBuild() ~= "RETAIL" then -- delay for other addons changing - C_Timer.After(2, function() - for i, v in pairs(BAGS) do - local bagF = _G[v] - local NT = _G[v .. "NormalTexture"] - - if NT and bagF and NT.scalesetup == nil then - NT.scalesetup = true - - if NT:GetTexture() == 130841 then - local sw, sh = bagF:GetSize() - local scale = 1.66 - NT:SetSize(sw * scale, sh * scale) + C_Timer.After( + 2, + function() + for i, v in pairs(BAGS) do + local bagF = _G[v] + local NT = _G[v .. "NormalTexture"] + if NT and bagF and NT.scalesetup == nil then + NT.scalesetup = true + if NT:GetTexture() == 130841 then + local sw, sh = bagF:GetSize() + local scale = 1.66 + NT:SetSize(sw * scale, sh * scale) + end end end end - end) + ) end if AuraFrameMixin and AuraFrameMixin.Update then - hooksecurefunc(AuraFrameMixin, "Update", function(sel) - for index, bf in pairs(sel.auraFrames) do - if bf and _G["Buff" .. index .. "BorderDM"] == nil then - local _, sh = bf.Icon:GetSize() - sh = DarkMode:MathR(sh) - local scale = 1 - _G["Buff" .. index .. "BorderDM"] = bf:CreateTexture("Buff" .. index .. "BorderDM", "OVERLAY") - local border = _G["Buff" .. index .. "BorderDM"] - border:SetDrawLayer("OVERLAY", 3) - border:SetSize(sh * scale, sh * scale) - border:SetTexture("Interface\\AddOns\\DarkMode\\media\\default") - border:SetPoint("CENTER", bf.Icon, "CENTER", 0, 0) - DarkMode:UpdateColor(border, "ui") + hooksecurefunc( + AuraFrameMixin, + "Update", + function(sel) + for index, bf in pairs(sel.auraFrames) do + if bf and _G["Buff" .. index .. "BorderDM"] == nil then + local _, sh = bf.Icon:GetSize() + sh = DarkMode:MathR(sh) + local scale = 1 + _G["Buff" .. index .. "BorderDM"] = bf:CreateTexture("Buff" .. index .. "BorderDM", "OVERLAY") + local border = _G["Buff" .. index .. "BorderDM"] + border:SetDrawLayer("OVERLAY", 3) + border:SetSize(sh * scale, sh * scale) + border:SetTexture("Interface\\AddOns\\DarkMode\\media\\default") + border:SetPoint("CENTER", bf.Icon, "CENTER", 0, 0) + DarkMode:UpdateColor(border, "ui") + end end end - end) + ) elseif BuffFrame_UpdateAllBuffAnchors then - hooksecurefunc("BuffFrame_UpdateAllBuffAnchors", function() - local buttonName = "BuffButton" - - for index = 1, BUFF_ACTUAL_DISPLAY do - if _G[buttonName .. index] and _G[buttonName .. index .. "BorderDM"] == nil then - local sw, sh = _G[buttonName .. index]:GetSize() - sw = DarkMode:MathR(sw) - sh = DarkMode:MathR(sh) - local scale = 1.1 - _G[buttonName .. index .. "BorderDM"] = _G[buttonName .. index]:CreateTexture(buttonName .. index .. "BorderDM", "OVERLAY") - local border = _G[buttonName .. index .. "BorderDM"] - border:SetDrawLayer("OVERLAY", 3) - border:SetSize(sw * scale, sh * scale) - border:SetTexture("Interface\\AddOns\\DarkMode\\media\\default") - border:SetPoint("CENTER", _G[buttonName .. index], "CENTER", 0, 0) - DarkMode:UpdateColor(border, "ui") + hooksecurefunc( + "BuffFrame_UpdateAllBuffAnchors", + function() + local buttonName = "BuffButton" + for index = 1, BUFF_ACTUAL_DISPLAY do + if _G[buttonName .. index] and _G[buttonName .. index .. "BorderDM"] == nil then + local sw, sh = _G[buttonName .. index]:GetSize() + sw = DarkMode:MathR(sw) + sh = DarkMode:MathR(sh) + local scale = 1.1 + _G[buttonName .. index .. "BorderDM"] = _G[buttonName .. index]:CreateTexture(buttonName .. index .. "BorderDM", "OVERLAY") + local border = _G[buttonName .. index .. "BorderDM"] + border:SetDrawLayer("OVERLAY", 3) + border:SetSize(sw * scale, sh * scale) + border:SetTexture("Interface\\AddOns\\DarkMode\\media\\default") + border:SetPoint("CENTER", _G[buttonName .. index], "CENTER", 0, 0) + DarkMode:UpdateColor(border, "ui") + end end end - end) + ) end if TargetFrame_UpdateAuras then - hooksecurefunc("TargetFrame_UpdateAuras", function(frame) - local buttonName = frame:GetName() .. "Buff" - - for index = 1, BUFF_ACTUAL_DISPLAY do - if _G[buttonName .. index] and _G[buttonName .. index .. "BorderDM"] == nil then - local sw, sh = _G[buttonName .. index]:GetSize() - sw = DarkMode:MathR(sw) - sh = DarkMode:MathR(sh) - local scale = 1.1 - _G[buttonName .. index .. "BorderDM"] = _G[buttonName .. index]:CreateTexture(buttonName .. index .. "BorderDM", "OVERLAY") - local border = _G[buttonName .. index .. "BorderDM"] - border:SetDrawLayer("OVERLAY", 3) - border:SetSize(sw * scale, sh * scale) - border:SetTexture("Interface\\AddOns\\DarkMode\\media\\default") - border:SetPoint("CENTER", _G[buttonName .. index], "CENTER", 0, 0) - DarkMode:UpdateColor(border, "ui") + hooksecurefunc( + "TargetFrame_UpdateAuras", + function(frame) + local buttonName = frame:GetName() .. "Buff" + for index = 1, BUFF_ACTUAL_DISPLAY do + if _G[buttonName .. index] and _G[buttonName .. index .. "BorderDM"] == nil then + local sw, sh = _G[buttonName .. index]:GetSize() + sw = DarkMode:MathR(sw) + sh = DarkMode:MathR(sh) + local scale = 1.1 + _G[buttonName .. index .. "BorderDM"] = _G[buttonName .. index]:CreateTexture(buttonName .. index .. "BorderDM", "OVERLAY") + local border = _G[buttonName .. index .. "BorderDM"] + border:SetDrawLayer("OVERLAY", 3) + border:SetSize(sw * scale, sh * scale) + border:SetTexture("Interface\\AddOns\\DarkMode\\media\\default") + border:SetPoint("CENTER", _G[buttonName .. index], "CENTER", 0, 0) + DarkMode:UpdateColor(border, "ui") + end end end - end) + ) end - C_Timer.After(0.1, function() - DarkMode:SearchUi() - DarkMode:SearchFrames() - - for index, name in pairs(DarkMode:GetFrameTextTable()) do - DarkMode:FindTextsByName(name) + C_Timer.After( + 0.1, + function() + DarkMode:SearchUi() + DarkMode:SearchFrames() + for index, name in pairs(DarkMode:GetFrameTextTable()) do + DarkMode:FindTextsByName(name) + end end - end) + ) --[[ SPECIALS ]] if DarkMode:GetWoWBuild() ~= "RETAIL" and FriendsFramePortrait then - hooksecurefunc(FriendsFramePortrait, "Show", function() - FriendsFramePortrait:Hide() - end) + hooksecurefunc( + FriendsFramePortrait, + "Show", + function() + FriendsFramePortrait:Hide() + end + ) FriendsFramePortrait:Hide() end @@ -963,7 +1011,6 @@ function DarkMode:Event(event, ...) function DarkMode:ToggleMinimapButton() DarkMode:SetEnabled("SHOWMINIMAPBUTTON", not DarkMode:IsEnabled("SHOWMINIMAPBUTTON", true)) - if DMMMBTN then if DarkMode:IsEnabled("SHOWMINIMAPBUTTON", true) then DMMMBTN:Show("DarkModeMinimapIcon") @@ -975,7 +1022,6 @@ function DarkMode:Event(event, ...) function DarkMode:HideMinimapButton() DarkMode:SetEnabled("SHOWMINIMAPBUTTON", false) - if DMMMBTN then DMMMBTN:Hide("DarkModeMinimapIcon") end @@ -983,34 +1029,35 @@ function DarkMode:Event(event, ...) function DarkMode:ShowMinimapButton() DarkMode:SetEnabled("SHOWMINIMAPBUTTON", true) - if DMMMBTN then DMMMBTN:Show("DarkModeMinimapIcon") end end - local DarkModeMinimapIcon = LibStub("LibDataBroker-1.1"):NewDataObject("DarkModeMinimapIcon", { - type = "data source", - text = "DarkModeMinimapIcon", - icon = 136122, - OnClick = function(sel, btn) - if btn == "LeftButton" then - DarkMode:ToggleSettings() - elseif btn == "RightButton" then - DarkMode:HideMinimapButton() - end - end, - OnTooltipShow = function(tooltip) - if not tooltip or not tooltip.AddLine then return end - tooltip:AddLine("DarkMode") - tooltip:AddLine(DarkMode:GT("MMBTNLEFT")) - tooltip:AddLine(DarkMode:GT("MMBTNRIGHT")) - end, - }) + local DarkModeMinimapIcon = LibStub("LibDataBroker-1.1"):NewDataObject( + "DarkModeMinimapIcon", + { + type = "data source", + text = "DarkModeMinimapIcon", + icon = 136122, + OnClick = function(sel, btn) + if btn == "LeftButton" then + DarkMode:ToggleSettings() + elseif btn == "RightButton" then + DarkMode:HideMinimapButton() + end + end, + OnTooltipShow = function(tooltip) + if not tooltip or not tooltip.AddLine then return end + tooltip:AddLine("DarkMode") + tooltip:AddLine(DarkMode:GT("MMBTNLEFT")) + tooltip:AddLine(DarkMode:GT("MMBTNRIGHT")) + end, + } + ) if DarkModeMinimapIcon then DMMMBTN = LibStub("LibDBIcon-1.0", true) - if DMMMBTN then DMMMBTN:Register("DarkModeMinimapIcon", DarkModeMinimapIcon, DarkMode:GetMinimapTable()) end @@ -1025,43 +1072,45 @@ function DarkMode:Event(event, ...) end end elseif event == "ADDON_LOADED" then - C_Timer.After(0.1, function() - DarkMode:SearchAddons() - - if PlayerTalentFrame then - for i, v in pairs({"PlayerSpecTab1", "PlayerSpecTab2", "PlayerSpecTab3", "PlayerSpecTab4"}) do - local tab = _G[v] - - if tab then - for x, w in pairs({tab:GetRegions()}) do - if x == 1 then - DarkMode:UpdateColor(w, "frames") + C_Timer.After( + 0.1, + function() + DarkMode:SearchAddons() + if PlayerTalentFrame then + for i, v in pairs({"PlayerSpecTab1", "PlayerSpecTab2", "PlayerSpecTab3", "PlayerSpecTab4"}) do + local tab = _G[v] + if tab then + for x, w in pairs({tab:GetRegions()}) do + if x == 1 then + DarkMode:UpdateColor(w, "frames") + end end end end end - end - - if ClassTalentFrame and ClassTalentFrame.dm_setup == nil then - ClassTalentFrame.dm_setup = true - - function ClassTalentFrame:UpdateColors() - local tabs = {ClassTalentFrame.TabSystem:GetChildren()} - for i, v in pairs(tabs) do - for x, w in pairs({v:GetRegions()}) do - DarkMode:UpdateColor(w, "frames") + if ClassTalentFrame and ClassTalentFrame.dm_setup == nil then + ClassTalentFrame.dm_setup = true + function ClassTalentFrame:UpdateColors() + local tabs = {ClassTalentFrame.TabSystem:GetChildren()} + for i, v in pairs(tabs) do + for x, w in pairs({v:GetRegions()}) do + DarkMode:UpdateColor(w, "frames") + end end end - end - ClassTalentFrame:HookScript("OnShow", function(sel) - ClassTalentFrame:UpdateColors() - end) + ClassTalentFrame:HookScript( + "OnShow", + function(sel) + ClassTalentFrame:UpdateColors() + end + ) - ClassTalentFrame:UpdateColors() + ClassTalentFrame:UpdateColors() + end end - end) + ) end end diff --git a/data.lua b/data.lua index cf7285f..bfd4514 100644 --- a/data.lua +++ b/data.lua @@ -1,8 +1,6 @@ local _, DarkMode = ... - function DarkMode:GetColor(id, name) local colorMode = DarkMode:GetColorModes()[id] - if colorMode == "Dark" then return 0.180, 0.180, 0.180, 1 elseif colorMode == "Dark+" then @@ -35,7 +33,6 @@ function DarkMode:GetCustomColor(name) local g = DMTAB[name .. "_g"] local b = DMTAB[name .. "_b"] local a = DMTAB[name .. "_a"] - if r and g and b and a then return r, g, b, a else @@ -85,7 +82,6 @@ function DarkMode:GetTextColor(r, g, b, a) end local DMRepeatingFrames = {"", ".Background", ".Bg", ".Bg.TopSection", ".Bg.BottomEdge", "Inset", "Inset.Bg", "Inset.NineSlice", "Inset.NineSlice.TopEdge", "Inset.NineSlice.RightEdge", "Inset.NineSlice.LeftEdge", "Inset.NineSlice.BottomEdge", "Inset.NineSlice.TopRightCorner", "Inset.NineSlice.TopLeftCorner", "Inset.NineSlice.BottomRightCorner", "Inset.NineSlice.BottomLeftCorner", ".NineSlice", ".NineSlice.TopEdge", ".NineSlice.RightEdge", ".NineSlice.LeftEdge", ".NineSlice.BottomEdge", ".NineSlice.TopRightCorner", ".NineSlice.TopLeftCorner", ".NineSlice.BottomRightCorner", ".NineSlice.BottomLeftCorner", "ScrollFrame", ".Begin", ".Middle", ".End", ".ScrollBar.Background",} - function DarkMode:GetDMRepeatingFrames() return DMRepeatingFrames end @@ -95,7 +91,7 @@ local DMUi = { ["Minimap"] = {"MinimapBorder", "MinimapBorderTop", "TimeManagerClockButton", "MinimapCompassTexture", "MinimapCluster.BorderTop",}, ["UnitFrames"] = {"PlayerFrameTexture", "TargetFrameTextureFrameTexture", "FocusFrameTextureFrameTexture", "TargetFrameToTTextureFrameTexture", "PetFrameTexture", "PlayerFrame.PlayerFrameContainer.AlternatePowerFrameTexture", "PlayerFrame.PlayerFrameContainer.FrameTexture", "TargetFrame.TargetFrameContainer.FrameTexture", "FocusFrame.TargetFrameContainer.FrameTexture", "PartyMemberFrame1Texture", "PartyMemberFrame2Texture", "PartyMemberFrame3Texture", "PartyMemberFrame4Texture", "PartyFrame.MemberFrame1.Texture", "PartyFrame.MemberFrame2.Texture", "PartyFrame.MemberFrame3.Texture", "PartyFrame.MemberFrame4.Texture", "CompactRaidFrameContainerBorderFrame", "TargetFrameSpellBar", "FocusFrameSpellBar"}, ["Tooltips"] = {"GameTooltip.NineSlice", "ItemRefTooltip.NineSlice", "ShoppingTooltip1.NineSlice", "ShoppingTooltip2.NineSlice", "WhatsTrainingTooltip.NineSlice"}, - ["Artworks"] = {"MainMenuBarTexture0", "MainMenuBarTexture1", "MainMenuBarTexture2", "MainMenuBarTexture3", "MainMenuExpBar", "ReputationWatchBar.StatusBar", "MainStatusTrackingBarContainer.BarFrameTexture", "SecondaryStatusTrackingBarContainer.BarFrameTexture", "MainMenuBarMaxLevelBar", "BT4BarBlizzardArt", "BlizzardArtLeftCap", "BlizzardArtRightCap", "CompactRaidFrameManager", "CharacterReagentBag0SlotNormalTexture", "CharacterBag0SlotNormalTexture", "CharacterBag1SlotNormalTexture", "CharacterBag2SlotNormalTexture", "CharacterBag3SlotNormalTexture", "MainMenuBarBackpackButtonNormalTexture"}, + ["Artworks"] = {"GroupLootFrame1", "GroupLootFrame2", "GroupLootFrame3", "GroupLootFrame4", "GroupLootFrame5", "MainMenuBarTexture0", "MainMenuBarTexture1", "MainMenuBarTexture2", "MainMenuBarTexture3", "MainMenuExpBar", "ReputationWatchBar.StatusBar", "MainStatusTrackingBarContainer.BarFrameTexture", "SecondaryStatusTrackingBarContainer.BarFrameTexture", "MainMenuBarMaxLevelBar", "BT4BarBlizzardArt", "BlizzardArtLeftCap", "BlizzardArtRightCap", "CompactRaidFrameManager", "CharacterReagentBag0SlotNormalTexture", "CharacterBag0SlotNormalTexture", "CharacterBag1SlotNormalTexture", "CharacterBag2SlotNormalTexture", "CharacterBag3SlotNormalTexture", "MainMenuBarBackpackButtonNormalTexture"}, ["Gryphons"] = {"MA_LeftEndCap", "MA_RightEndCap", "MainMenuBar.EndCaps", "MainMenuBarLeftEndCap", "MainMenuBarRightEndCap"}, ["Chat"] = {"ChatFrame1Tab", "ChatFrame2Tab", "ChatFrame3Tab", "ChatFrame4Tab", "ChatFrame5Tab", "ChatFrame6Tab", "ChatFrame7Tab", "ChatFrame8Tab", "ChatFrame9Tab", "ChatFrame10Tab",}, ["Castbar"] = {"CastingBarFrame.Border"} @@ -114,25 +110,21 @@ function DarkMode:GetUiTable() end local DMUiAddons = {"FocusFrame.FocusFrameContainer.FrameTexture"} - function DarkMode:GetUiAddonsTable() return DMUiAddons end local DMFrames = {"SettingsPanel", "PaperDollFrame", "CharacterFrame", "CharacterStatsPane", "CharacterFrameTab1", "CharacterFrameTab2", "CharacterFrameTab3", "CharacterFrameTab4", "CharacterFrameTab5", "nwtab5", "nwtab6", "ReputationFrame", "ReputationListScrollFrame", "SkillFrame", "SkillListScrollFrame", "SkillDetailScrollFrame", "HonorFrame", "PetPaperDollFrame", "PetPaperDollFrameTab1", "PetPaperDollFrameTab2", "PetPaperDollFrameTab3", "PetPaperDollFrameExpBar", "TokenFrame", "SpellBookFrame", "SpellBookSkillLineTab1", "SpellBookSkillLineTab2", "SpellBookSkillLineTab3", "SpellBookSkillLineTab4", "SpellBookSkillLineTab5", "SpellBookSkillLineTab6", "SpellBookSkillLineTab7", "WhatsTrainingFrame", "SpellBookFrameTabButton1", "SpellBookFrameTabButton2", "QuestLogFrame", "QuestLogCollapseAllButton", "QuestScrollFrame.ScrollBar", "FriendsFrame", "FriendsFrameFriendsScrollFrame", "FriendsFrameTab1", "FriendsFrameTab2", "FriendsFrameTab3", "FriendsFrameTab4", "WhoFrameList", "WorldMapFrame", "WorldMapFrame.BorderFrame", "LFGParentFrame", "LFGParentFrameTab1", "LFGParentFrameTab2", "LFMFrame", "LFGBrowseFrame", "LFGListingFrame", "PVEFrame", "PVEFrameTab1", "PVEFrameTab2", "PVEFrameTab3", "PVEFrameTab4", "PVPFrame", "ChallengesFrame", "GameMenuFrame", "GameMenuFrame.Border", "GameMenuFrame.Header", "QuestFrame", "QuestFrameDetailPanel", "QuestDetailScrollFrame", "QuestDetailScrollChildFrame", "GossipFrameGreetingPanel", "GossipGreetingScrollFrame", "QuestFrameGreetingPanel", "QuestGreetingScrollFrame", "QuestFrameProgressPanel", "QuestProgressScrollFrame", "QuestRewardScrollFrame", "QuestFrameRewardPanel", "QuestInfoRewardsFrame", "GossipFrame", "GossipFrame.GreetingPanel", "GossipFrame.GreetingPanel.ScrollBox", "GossipFrame.GreetingPanel.ScrollBar.Background", "MerchantFrame", "MerchantBuyBackItem", "MerchantFrameTab1", "MerchantFrameTab2", "MerchantItem1", "MerchantItem2", "MerchantItem3", "MerchantItem4", "MerchantItem5", "MerchantItem6", "MerchantItem7", "MerchantItem8", "MerchantItem9", "MerchantItem10", "MerchantItem11", "MerchantItem12", "MerchantMoney", "MerchantMoneyBg", "PetStableFrame", "AddonList", "AddonListDisableAllButton_RightSeparator", "AddonListEnableAllButton_RightSeparator", "AddonListOkayButton_LeftSeparator", "AddonListOkayButton_RightSeparator", "AddonListCancelButton_LeftSeparator", "HelpFrame", "VideoOptionsFrame", "InterfaceOptionsFrame", "TimeManagerFrame", "MailFrame", "MailFrameTab1", "MailFrameTab2", "InboxFrame", "SendMailFrame", "SendMailMoney", "SendMailMoneyBg", "SendMailMoneyFrame", "SendMail", "MailEditBoxScrollBar", "BankFrame", "BankFrameTab1", "BankFrameTab2", "BankFrameMoneyFrame", "BankFrameMoneyFrameBorder", "BackpackTokenFrame", "ContainerFrame1", "ContainerFrame2", "ContainerFrame3", "ContainerFrame4", "ContainerFrame5", "ContainerFrame6", "ContainerFrame7", "ContainerFrame8", "ContainerFrame9", "ContainerFrame10", "ContainerFrame11", "ContainerFrame12", "ContainerFrameCombinedBags", "PVPFrame", "PVPParentFrame", "PVPParentFrameTab1", "PVPParentFrameTab2", "BattlefieldFrame", "BattlefieldFrameType", "TaxiFrame", "YourFrameName", "QuestMapFrame", "QuestMapFrame.DetailsFrame"} - function DarkMode:GetFrameTable() return DMFrames end local DMFramesAddons = {"ClassTrainerFrame", "ClassTrainerListScrollFrame", "ClassTrainerExpandButtonFrame", "KeyBindingFrame", "KeyBindingFrame.header", "MacroFrame", "MacroFrameTab1", "MacroFrameTab2", "MacroFrameTextBackground", "MacroButtonScrollFrame", "MacroFrame.MacroSelector.ScrollBar.Background", "TradeSkillFrame", "CraftFrame", "TradeSkillList", "AuctionFrame", "AuctionFrameTab1", "AuctionFrameTab2", "AuctionFrameTab3", "AuctionFrameTab4", "AuctionFrameTab5", "AuctionFrameTab6", "AuctionFrameTab7", "AuctionFrameTab8", "AuctionFrameTab9", "AuctionFrameTab10", "AuctionFrameTab11", "AuctionFrameTab12", "BrowseBidButton", "BrowseBuyoutButton", "BrowseCloseButton", "BidBidButton", "BidBuyoutButton", "BidCloseButton", "AuctionHouseFrame", "AuctionHouseFrameBuyTab", "AuctionHouseFrameSellTab", "AuctionHouseFrameAuctionsTab", "PlayerTalentFrame", "PlayerTalentFramePointsBar", "PlayerTalentFrameTab1", "PlayerTalentFrameTab2", "PlayerTalentFrameTab3", "PlayerTalentFrameTab4", "PlayerTalentFrameTab5", "ClassTalentFrame", "ClassTalentFrame.TabSystem", "ClassTalentFrame.TalentsTab.BottomBar", "AchievementFrame", "AchievementFrame.Header", "AchievementFrameTab1", "AchievementFrameTab2", "AchievementFrameTab3", "AchievementFrameTab4", "AchievementFrameHeader", "AchievementFrameCategories", "AchievementFrameSummary", "WeeklyRewardsFrame", "CommunitiesFrame", "CommunitiesFrameCommunitiesList", "CommunitiesFrame.MemberList", "CommunitiesFrame.Chat.MessageFrame.ScrollBar", "CollectionsJournal", "CollectionsJournalTab1", "CollectionsJournalTab2", "CollectionsJournalTab3", "CollectionsJournalTab4", "CollectionsJournalTab5", "CollectionsJournalTab6", "WardrobeCollectionFrame", "WardrobeCollectionFrame.ItemsCollectionFrame", "ToyBox", "ToyBox.iconsFrame", "HeirloomsJournal", "HeirloomsJournal.iconsFrame", "EncounterJournal", "EncounterJournalMonthlyActivitiesTab", "EncounterJournalSuggestTab", "EncounterJournalDungeonTab", "EncounterJournalRaidTab", "EncounterJournalLootJournalTab", "EncounterJournalInstanceSelect", "CalendarFrame",} - function DarkMode:GetFrameAddonsTable() return DMFramesAddons end local DMFrameTexts = {"GossipGreetingScrollChildFrame", "QuestGreetingScrollChildFrame", "QuestProgressScrollChildFrame", "QuestRewardScrollChildFrame", "QuestLogDetailScrollChildFrame", "QuestInfoTitleHeader", "QuestInfoQuestType", "QuestInfoObjective1", "QuestInfoObjective2", "QuestInfoObjective3", "QuestInfoObjective4", "QuestInfoObjective5", "QuestInfoObjective6", "QuestInfoDescriptionHeader", "QuestInfoDescriptionText", "QuestInfoObjectivesHeader", "QuestInfoObjectivesText", "QuestInfoRewardText", "QuestInfoRewardsFrame", "GossipGreetingText", "QuestTitleButton1", "QuestTitleButton2", "QuestTitleButton3", "QuestTitleButton4", "QuestTitleButton5", "QuestTitleButton6", "QuestTitleButton7", "QuestTitleButton8", "QuestTitleButton9", "QuestTitleButton10", "QuestTitleButton11", "QuestTitleButton12", "QuestTitleButton13", "QuestTitleButton14", "QuestTitleButton15", "GossipTitleButton1", "GossipTitleButton2", "GossipTitleButton3", "GossipTitleButton4", "GossipTitleButton5", "GossipTitleButton6", "GossipTitleButton7", "GossipTitleButton8", "GossipTitleButton9", "GossipTitleButton10", "GossipTitleButton11", "GossipTitleButton12", "GossipTitleButton13", "GossipTitleButton14", "GossipTitleButton15",} - function DarkMode:GetFrameTextTable() return DMFrameTexts end @@ -155,7 +147,6 @@ DMTextureBlock["Interface\\TargetingFrame\\UI-StatusBar"] = true DMTextureBlock["Interface\\MailFrame\\Mail-Icon"] = true DMTextureBlock["Interface\\ContainerFrame\\UI-Bag-1Slot"] = true DMTextureBlock["Interface\\SpellBook\\SpellBook-SkillLineTab-Glow"] = true - if DarkMode:GetWoWBuild() == "RETAIL" then DMTextureBlock[130724] = true -- Spellbook Tab Highlight Icon DMTextureBlock[136377] = true -- MacroFrame Portrai @@ -180,7 +171,6 @@ DMTextureBlock[374178] = true DMTextureBlock[374168] = true DMTextureBlock[374170] = true DMTextureBlock[374172] = true - -- CHAT Tabs -- ids: https://www.townlong-yak.com/framexml/live/Helix/ArtTextureID.lua function DarkMode:GetTextureBlockTable() @@ -188,7 +178,6 @@ function DarkMode:GetTextureBlockTable() end local DMIgnoreFrames = {} - if DarkMode:GetWoWBuild() ~= "RETAIL" then DMIgnoreFrames["FriendsFrameIcon"] = true DMIgnoreFrames["FriendsFramePortrait"] = true @@ -203,7 +192,6 @@ end local DMIgnoreTextureNames = {} DMIgnoreTextureNames["ContainerFrame1Portrait"] = true - function DarkMode:GetIgnoreTextureName(name) return DMIgnoreTextureNames[name] or false end \ No newline at end of file diff --git a/settings.lua b/settings.lua index da2d784..34eef4b 100644 --- a/settings.lua +++ b/settings.lua @@ -1,7 +1,6 @@ local _, DarkMode = ... - local config = { - ["title"] = format("DarkMode |T136122:16:16:0:0|t v|cff3FC7EB%s", "0.3.25") + ["title"] = format("DarkMode |T136122:16:16:0:0|t v|cff3FC7EB%s", "0.3.26") } local searchStr = "" @@ -10,9 +9,7 @@ local cas = {} local cbs = {} local sls = {} local cps = {} - local DMColorModes = {"Dark", "Dark+", "Darker", "Darker+", "Black", "ClassColor", "Default", "Custom", "Off"} - function DarkMode:GetColorModes() return DMColorModes end @@ -20,10 +17,8 @@ end local function DMSetPos(ele, key, x) if ele == nil then return false end ele:ClearAllPoints() - if strfind(strlower(key), strlower(searchStr)) then ele:Show() - if posy < -4 then posy = posy - 10 end @@ -60,18 +55,19 @@ local function AddCheckBox(x, key, val, func) local cb = cbs[key] cb:SetSize(24, 24) cb:SetChecked(DarkMode:IsEnabled(key, val)) + cb:SetScript( + "OnClick", + function(sel) + DarkMode:SetEnabled(key, sel:GetChecked()) + if func then + func(sel, sel:GetChecked()) + end - cb:SetScript("OnClick", function(sel) - DarkMode:SetEnabled(key, sel:GetChecked()) - - if func then - func(sel, sel:GetChecked()) - end - - if DMSettings.save then - DMSettings.save:Enable() + if DMSettings.save then + DMSettings.save:Enable() + end end - end) + ) cb.f = cb:CreateFontString(nil, nil, "GameFontNormal") cb.f:SetPoint("LEFT", cb, "RIGHT", 0, 0) @@ -79,7 +75,6 @@ local function AddCheckBox(x, key, val, func) end cbs[key]:ClearAllPoints() - if strfind(strlower(key), strlower(searchStr)) or strfind(strlower(DarkMode:GT(key)), strlower(searchStr)) then cbs[key]:Show() cbs[key]:SetPoint("TOPLEFT", DMSettings.SC, "TOPLEFT", x, posy) @@ -94,7 +89,6 @@ local function AddSlider(x, key, val, func, vmin, vmax, steps) sls[key] = CreateFrame("Slider", "sls[" .. key .. "]", DMSettings.SC, "OptionsSliderTemplate") sls[key]:SetWidth(DMSettings.SC:GetWidth() - 30 - x) sls[key]:SetPoint("TOPLEFT", DMSettings.SC, "TOPLEFT", x + 5, posy) - if type(vmin) == "number" then sls[key].Low:SetText(vmin) sls[key].High:SetText(vmax) @@ -108,37 +102,38 @@ local function AddSlider(x, key, val, func, vmin, vmax, steps) end sls[key]:SetObeyStepOnDrag(true) - if steps then sls[key]:SetValueStep(steps) end sls[key]:SetValue(DarkMode:GV(key, val)) - - sls[key]:SetScript("OnValueChanged", function(sel, valu) - --valu = valu - valu % steps - if steps then - valu = tonumber(string.format("%" .. steps .. "f", valu)) - end - - if valu and valu ~= DarkMode:GV(key) then - if type(vmin) == "number" then - DarkMode:SV(key, valu) - sls[key].Text:SetText(DarkMode:GT(key) .. ": " .. valu) - else - DarkMode:SV(key, valu) - sls[key].Text:SetText(DarkMode:GT(key) .. ": " .. vmin[valu]) - end - - if func then - func(sel, valu) + sls[key]:SetScript( + "OnValueChanged", + function(sel, valu) + --valu = valu - valu % steps + if steps then + valu = tonumber(string.format("%" .. steps .. "f", valu)) end - if DMSettings.save then - DMSettings.save:Enable() + if valu and valu ~= DarkMode:GV(key) then + if type(vmin) == "number" then + DarkMode:SV(key, valu) + sls[key].Text:SetText(DarkMode:GT(key) .. ": " .. valu) + else + DarkMode:SV(key, valu) + sls[key].Text:SetText(DarkMode:GT(key) .. ": " .. vmin[valu]) + end + + if func then + func(sel, valu) + end + + if DMSettings.save then + DMSettings.save:Enable() + end end end - end) + ) end posy = posy - 10 @@ -151,9 +146,7 @@ end function DarkMode:ShowColorPicker(r, g, b, a, changedCallback) ColorPickerFrame.func, ColorPickerFrame.opacityFunc = changedCallback, changedCallback ColorPickerFrame.hasOpacity, ColorPickerFrame.opacity = a ~= nil, 1 - a - ColorPickerFrame.previousValues = {r, g, b, a} - ColorPickerFrame:SetColorRGB(r, g, b) ColorPickerFrame.hasOpacity, ColorPickerFrame.opacity = a ~= nil, 1 - a ColorPickerFrame:Hide() -- Need to run the OnShow handler. @@ -167,22 +160,28 @@ function DarkMode:AddColorPicker(name, parent, x, y) btn:SetSize(300, 25) btn:SetPoint("TOPLEFT", parent, "TOPLEFT", x, posy) btn:SetText(DarkMode:GT(name)) - - btn:SetScript("OnClick", function() - local r, g, b, a = DarkMode:GetCustomColor(name) - - DarkMode:ShowColorPicker(r, g, b, a, function(restore) - local newR, newG, newB, newA - - if restore then - newR, newG, newB, newA = unpack(restore) - else - newA, newR, newG, newB = 1 - OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB() - end - - DarkMode:SetCustomColor(name, newR, newG, newB, newA) - end) - end) + btn:SetScript( + "OnClick", + function() + local r, g, b, a = DarkMode:GetCustomColor(name) + DarkMode:ShowColorPicker( + r, + g, + b, + a, + function(restore) + local newR, newG, newB, newA + if restore then + newR, newG, newB, newA = unpack(restore) + else + newA, newR, newG, newB = 1 - OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB() + end + + DarkMode:SetCustomColor(name, newR, newG, newB, newA) + end + ) + end + ) end DMSetPos(cps[name], name, x) @@ -193,7 +192,6 @@ end function DarkMode:ToggleSettings() DarkMode:SetEnabled("SETTINGS", not DarkMode:IsEnabled("SETTINGS", false)) - if DarkMode:IsEnabled("SETTINGS", false) then DMSettings:Show() DMSettings:UpdateShowErrors() @@ -214,12 +212,14 @@ function DarkMode:InitDMSettings() DMSettings:EnableMouse(true) DMSettings:RegisterForDrag("LeftButton") DMSettings:SetScript("OnDragStart", DMSettings.StartMoving) - - DMSettings:SetScript("OnDragStop", function() - DMSettings:StopMovingOrSizing() - local p1, _, p3, p4, p5 = DMSettings:GetPoint() - DarkMode:SetElePoint("DMSettings", p1, _, p3, p4, p5) - end) + DMSettings:SetScript( + "OnDragStop", + function() + DMSettings:StopMovingOrSizing() + local p1, _, p3, p4, p5 = DMSettings:GetPoint() + DarkMode:SetElePoint("DMSettings", p1, _, p3, p4, p5) + end + ) if DarkMode:IsEnabled("SETTINGS", false) then DMSettings:Show() @@ -228,50 +228,67 @@ function DarkMode:InitDMSettings() end DMSettings.TitleText:SetText(config.title) - - DMSettings.CloseButton:SetScript("OnClick", function() - DarkMode:ToggleSettings() - end) + DMSettings.CloseButton:SetScript( + "OnClick", + function() + DarkMode:ToggleSettings() + end + ) function DMUpdateElementList() posy = -8 AddCategory("GENERAL") AddCheckBox(4, "SHOWMINIMAPBUTTON", true, DarkMode.UpdateMinimapButton) - if DarkMode:GetWoWBuild() ~= "RETAIL" then AddCheckBox(4, "MASKACTIONBUTTONS", true) end AddCheckBox(4, "GRYPHONS", true) - - local sCM = AddSlider(4, "COLORMODE", DarkMode:GV("COLORMODE", 1), function(sel, val) - sel.Text:SetText(DarkMode:GT("COLORMODE") .. ": " .. DarkMode:GetColorModes()[val]) - DarkMode:UpdateColors() - end, 1, getn(DarkMode:GetColorModes()), 1) + local sCM = AddSlider( + 4, + "COLORMODE", + DarkMode:GV("COLORMODE", 1), + function(sel, val) + sel.Text:SetText(DarkMode:GT("COLORMODE") .. ": " .. DarkMode:GetColorModes()[val]) + DarkMode:UpdateColors() + end, 1, getn(DarkMode:GetColorModes()), 1 + ) sCM.Text:SetText(DarkMode:GT("COLORMODE") .. ": " .. DarkMode:GetColorModes()[DarkMode:GV("COLORMODE", 1)]) DarkMode:AddColorPicker("CUSTOMUIC", DMSettings.SC, 0, 0) - - local sCMUF = AddSlider(4, "COLORMODEUF", DarkMode:GV("COLORMODEUF", 7), function(sel, val) - sel.Text:SetText(DarkMode:GT("COLORMODEUF") .. ": " .. DarkMode:GetColorModes()[val]) - DarkMode:UpdateColors() - end, 1, getn(DarkMode:GetColorModes()), 1) + local sCMUF = AddSlider( + 4, + "COLORMODEUF", + DarkMode:GV("COLORMODEUF", 7), + function(sel, val) + sel.Text:SetText(DarkMode:GT("COLORMODEUF") .. ": " .. DarkMode:GetColorModes()[val]) + DarkMode:UpdateColors() + end, 1, getn(DarkMode:GetColorModes()), 1 + ) sCMUF.Text:SetText(DarkMode:GT("COLORMODEUF") .. ": " .. DarkMode:GetColorModes()[DarkMode:GV("COLORMODEUF", 7)]) DarkMode:AddColorPicker("CUSTOMUFC", DMSettings.SC, 0, 0) - - local sCMTT = AddSlider(4, "COLORMODETT", DarkMode:GV("COLORMODETT", 1), function(sel, val) - sel.Text:SetText(DarkMode:GT("COLORMODETT") .. ": " .. DarkMode:GetColorModes()[val]) - DarkMode:UpdateColors() - end, 1, getn(DarkMode:GetColorModes()), 1) + local sCMTT = AddSlider( + 4, + "COLORMODETT", + DarkMode:GV("COLORMODETT", 1), + function(sel, val) + sel.Text:SetText(DarkMode:GT("COLORMODETT") .. ": " .. DarkMode:GetColorModes()[val]) + DarkMode:UpdateColors() + end, 1, getn(DarkMode:GetColorModes()), 1 + ) sCMTT.Text:SetText(DarkMode:GT("COLORMODETT") .. ": " .. DarkMode:GetColorModes()[DarkMode:GV("COLORMODETT", 7)]) DarkMode:AddColorPicker("CUSTOMTTC", DMSettings.SC, 0, 0) - - local sCMF = AddSlider(4, "COLORMODEF", DarkMode:GV("COLORMODEF", 1), function(sel, val) - sel.Text:SetText(DarkMode:GT("COLORMODEF") .. ": " .. DarkMode:GetColorModes()[val]) - DarkMode:UpdateColors() - end, 1, getn(DarkMode:GetColorModes()), 1) + local sCMF = AddSlider( + 4, + "COLORMODEF", + DarkMode:GV("COLORMODEF", 1), + function(sel, val) + sel.Text:SetText(DarkMode:GT("COLORMODEF") .. ": " .. DarkMode:GetColorModes()[val]) + DarkMode:UpdateColors() + end, 1, getn(DarkMode:GetColorModes()), 1 + ) sCMF.Text:SetText(DarkMode:GT("COLORMODEF") .. ": " .. DarkMode:GetColorModes()[DarkMode:GV("COLORMODEF", 1)]) DarkMode:AddColorPicker("CUSTOMFRC", DMSettings.SC, 0, 0) @@ -281,11 +298,13 @@ function DarkMode:InitDMSettings() DMSettings.Search:SetPoint("TOPLEFT", DMSettings, "TOPLEFT", 12, -26) DMSettings.Search:SetSize(DMSettings:GetWidth() - 22 - 100, 24) DMSettings.Search:SetAutoFocus(false) - - DMSettings.Search:SetScript("OnTextChanged", function(sel, ...) - searchStr = DMSettings.Search:GetText() - DMUpdateElementList() - end) + DMSettings.Search:SetScript( + "OnTextChanged", + function(sel, ...) + searchStr = DMSettings.Search:GetText() + DMUpdateElementList() + end + ) DMSettings.SF = CreateFrame("ScrollFrame", "DMSettings_SF", DMSettings, "UIPanelScrollFrameTemplate") DMSettings.SF:SetPoint("TOPLEFT", DMSettings, 8, -30 - 24) @@ -301,34 +320,40 @@ function DarkMode:InitDMSettings() DMSettings.save:SetSize(120, 24) DMSettings.save:SetPoint("TOPLEFT", DMSettings, "TOPLEFT", 4, -DMSettings:GetHeight() + 24 + 4) DMSettings.save:SetText(SAVE) - - DMSettings.save:SetScript("OnClick", function() - C_UI.Reload() - end) + DMSettings.save:SetScript( + "OnClick", + function() + C_UI.Reload() + end + ) DMSettings.save:Disable() DMSettings.reload = CreateFrame("BUTTON", "DMSettings" .. ".reload", DMSettings, "UIPanelButtonTemplate") DMSettings.reload:SetSize(120, 24) DMSettings.reload:SetPoint("TOPLEFT", DMSettings, "TOPLEFT", 4 + 120 + 4, -DMSettings:GetHeight() + 24 + 4) DMSettings.reload:SetText(RELOADUI) - - DMSettings.reload:SetScript("OnClick", function() - C_UI.Reload() - end) + DMSettings.reload:SetScript( + "OnClick", + function() + C_UI.Reload() + end + ) DMSettings.showerrors = CreateFrame("BUTTON", "DMSettings" .. ".showerrors", DMSettings, "UIPanelButtonTemplate") DMSettings.showerrors:SetSize(120, 24) DMSettings.showerrors:SetPoint("TOPLEFT", DMSettings, "TOPLEFT", 4 + 120 + 4 + 120 + 4, -DMSettings:GetHeight() + 24 + 4) DMSettings.showerrors:SetText("Show Errors") + DMSettings.showerrors:SetScript( + "OnClick", + function() + if GetCVar("ScriptErrors") == "0" then + SetCVar("ScriptErrors", 1) + C_UI.Reload() + end - DMSettings.showerrors:SetScript("OnClick", function() - if GetCVar("ScriptErrors") == "0" then - SetCVar("ScriptErrors", 1) - C_UI.Reload() + DMSettings:UpdateShowErrors() end - - DMSettings:UpdateShowErrors() - end) + ) function DMSettings:UpdateShowErrors() if GetCVar("ScriptErrors") == "0" then @@ -345,7 +370,6 @@ function DarkMode:InitDMSettings() DMSettings.DISCORD:SetPoint("TOPLEFT", DMSettings, "TOPLEFT", DMSettings:GetWidth() - 160 - 8, -DMSettings:GetHeight() + 24 + 4) DMSettings.DISCORD:SetAutoFocus(false) local dbp1, _, dbp3, dbp4, dbp5 = DarkMode:GetElePoint("DMSettings") - if dbp1 and dbp3 then DMSettings:ClearAllPoints() DMSettings:SetPoint(dbp1, UIParent, dbp3, dbp4, dbp5)