Skip to content

Commit

Permalink
v0.4.30
Browse files Browse the repository at this point in the history
  • Loading branch information
d4kir92 committed Feb 27, 2024
1 parent 7719ed0 commit a1e5bd8
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 104 deletions.
2 changes: 1 addition & 1 deletion DarkMode.toc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion DarkMode_TBC.toc
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion DarkMode_Vanilla.toc
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion DarkMode_Wrath.toc
Original file line number Diff line number Diff line change
@@ -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
Expand Down
164 changes: 66 additions & 98 deletions core.lua
Original file line number Diff line number Diff line change
@@ -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 = {}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit a1e5bd8

Please sign in to comment.