From a1e5bd885639c4e226093018356d798dece51568 Mon Sep 17 00:00:00 2001 From: D4KiR <23246564+d4kir92@users.noreply.github.com> Date: Tue, 27 Feb 2024 19:14:39 +0100 Subject: [PATCH] v0.4.30 --- DarkMode.toc | 2 +- DarkMode_TBC.toc | 2 +- DarkMode_Vanilla.toc | 2 +- DarkMode_Wrath.toc | 2 +- core.lua | 164 +++++++++++++++++-------------------------- settings.lua | 4 +- 6 files changed, 72 insertions(+), 104 deletions(-) diff --git a/DarkMode.toc b/DarkMode.toc index c958c7e..75924f3 100644 --- a/DarkMode.toc +++ b/DarkMode.toc @@ -3,7 +3,7 @@ ## Interface-Wrath: 30403 ## Interface: 100205 -## Version: 0.4.29 +## Version: 0.4.30 ## 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 e98f5fb..e1f433b 100644 --- a/DarkMode_TBC.toc +++ b/DarkMode_TBC.toc @@ -1,5 +1,5 @@ ## Interface: 20504 -## Version: 0.4.29 +## Version: 0.4.30 ## 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 68518c2..f133fcb 100644 --- a/DarkMode_Vanilla.toc +++ b/DarkMode_Vanilla.toc @@ -1,5 +1,5 @@ ## Interface: 11501 -## Version: 0.4.29 +## Version: 0.4.30 ## 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 49ee0b3..936ce79 100644 --- a/DarkMode_Wrath.toc +++ b/DarkMode_Wrath.toc @@ -1,5 +1,5 @@ ## Interface: 30403 -## Version: 0.4.29 +## Version: 0.4.30 ## 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 0b781a5..d527621 100644 --- a/core.lua +++ b/core.lua @@ -1,46 +1,4 @@ local _, DarkMode = ... --- TAINTFREE SLASH COMMANDS -- -local lastMessage = "" -local cmds = {} -hooksecurefunc( - "ChatEdit_ParseText", - function(editBox, send, parseIfNoSpace) - if send == 0 then - lastMessage = editBox:GetText() - 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() - local function predicateFunction(entry) - if count == numMessages and entry == HELP_TEXT_SIMPLE then return true end - count = count + 1 - end - - frame:RemoveMessagesByPredicate(predicateFunction) - cmds[cmd]() - end - end - end -) - -function DarkMode:InitSlash() - cmds["/DM"] = DarkMode.ToggleSettings - cmds["/DARK"] = DarkMode.ToggleSettings - cmds["/DARKMODE"] = DarkMode.ToggleSettings - cmds["/RL"] = C_UI.Reload - cmds["/REL"] = C_UI.Reload -end - --- TAINTFREE SLASH COMMANDS -- DMHIDDEN = CreateFrame("FRAME", "DMHIDDEN") DMHIDDEN:Hide() local DMTexturesUi = {} @@ -1043,6 +1001,14 @@ function DarkMode:InitQuestFrame() end end +function DarkMode:InitSlash() + D4:AddSlash("dm", DarkMode.ToggleSettings) + D4:AddSlash("dark", DarkMode.ToggleSettings) + D4:AddSlash("darkmode", DarkMode.ToggleSettings) + D4:AddSlash("rl", C_UI.Reload) + D4:AddSlash("rel", C_UI.Reload) +end + local BAGS = {"MainMenuBarBackpackButton", "CharacterBag0Slot", "CharacterBag1Slot", "CharacterBag2Slot", "CharacterBag3Slot"} function DarkMode:Event(event, ...) if event == "PLAYER_LOGIN" then @@ -1324,75 +1290,77 @@ function DarkMode:Event(event, ...) FriendsFramePortrait:Hide() end - function DarkMode:UpdateMinimapButton() - if DMMMBTN then - if DarkMode:IsEnabled("SHOWMINIMAPBUTTON", true) then - DMMMBTN:Show("DarkModeMinimapIcon") - else - DMMMBTN:Hide("DarkModeMinimapIcon") + if UIParent.SetFixedFrameStrata then + function DarkMode:UpdateMinimapButton() + if DMMMBTN then + if DarkMode:IsEnabled("SHOWMINIMAPBUTTON", true) then + DMMMBTN:Show("DarkModeMinimapIcon") + else + DMMMBTN:Hide("DarkModeMinimapIcon") + end end end - end - function DarkMode:ToggleMinimapButton() - DarkMode:SetEnabled("SHOWMINIMAPBUTTON", not DarkMode:IsEnabled("SHOWMINIMAPBUTTON", true)) - if DMMMBTN then - if DarkMode:IsEnabled("SHOWMINIMAPBUTTON", true) then - DMMMBTN:Show("DarkModeMinimapIcon") - else - DMMMBTN:Hide("DarkModeMinimapIcon") + function DarkMode:ToggleMinimapButton() + DarkMode:SetEnabled("SHOWMINIMAPBUTTON", not DarkMode:IsEnabled("SHOWMINIMAPBUTTON", true)) + if DMMMBTN then + if DarkMode:IsEnabled("SHOWMINIMAPBUTTON", true) then + DMMMBTN:Show("DarkModeMinimapIcon") + else + DMMMBTN:Hide("DarkModeMinimapIcon") + end end end - end - function DarkMode:HideMinimapButton() - DarkMode:SetEnabled("SHOWMINIMAPBUTTON", false) - if DMMMBTN then - DMMMBTN:Hide("DarkModeMinimapIcon") + function DarkMode:HideMinimapButton() + DarkMode:SetEnabled("SHOWMINIMAPBUTTON", false) + if DMMMBTN then + DMMMBTN:Hide("DarkModeMinimapIcon") + end end - end - function DarkMode:ShowMinimapButton() - DarkMode:SetEnabled("SHOWMINIMAPBUTTON", true) - if DMMMBTN then - DMMMBTN:Show("DarkModeMinimapIcon") + function DarkMode:ShowMinimapButton() + DarkMode:SetEnabled("SHOWMINIMAPBUTTON", true) + if DMMMBTN then + DMMMBTN:Show("DarkModeMinimapIcon") + end 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()) + if DarkModeMinimapIcon then + DMMMBTN = LibStub("LibDBIcon-1.0", true) + if DMMMBTN then + DMMMBTN:Register("DarkModeMinimapIcon", DarkModeMinimapIcon, DarkMode:GetMinimapTable()) + end end - end - if DMMMBTN then - if DarkMode:IsEnabled("SHOWMINIMAPBUTTON", true) then - DMMMBTN:Show("DarkModeMinimapIcon") - else - DMMMBTN:Hide("DarkModeMinimapIcon") + if DMMMBTN then + if DarkMode:IsEnabled("SHOWMINIMAPBUTTON", true) then + DMMMBTN:Show("DarkModeMinimapIcon") + else + DMMMBTN:Hide("DarkModeMinimapIcon") + end end end end diff --git a/settings.lua b/settings.lua index c716758..384846a 100644 --- a/settings.lua +++ b/settings.lua @@ -222,8 +222,8 @@ function DarkMode:InitDMSettings() DMSettings:Hide() end - D4:SetVersion(AddonName, 136122, "0.4.29") - DMSettings.TitleText:SetText(format("DarkMode |T136122:16:16:0:0|t v|cff3FC7EB%s", "0.4.29")) + D4:SetVersion(AddonName, 136122, "0.4.30") + DMSettings.TitleText:SetText(format("DarkMode |T136122:16:16:0:0|t v|cff3FC7EB%s", "0.4.30")) DMSettings.CloseButton:SetScript( "OnClick", function()