From 406010a662bc41ac423df92551e61c817ddd182b Mon Sep 17 00:00:00 2001 From: D4KiR <23246564+d4kir92@users.noreply.github.com> Date: Fri, 1 Mar 2024 16:28:16 +0100 Subject: [PATCH] v0.5.0 --- DarkMode.toc | 16 ++--- DarkMode_TBC.toc | 2 +- DarkMode_Vanilla.toc | 2 +- DarkMode_Wrath.toc | 2 +- core.lua | 56 ++++++++------- data.lua | 2 +- libs/D4Lib/D4Lib.lua | 42 +++++++++++ libs/D4Lib/D4Versions.lua | 7 +- libs/db.lua | 5 -- libs/lang.lua | 3 - libs/math.lua | 4 -- settings.lua | 142 ++++++++++++++++++++++++++++++-------- 12 files changed, 201 insertions(+), 82 deletions(-) diff --git a/DarkMode.toc b/DarkMode.toc index 3728e73..14cdab5 100644 --- a/DarkMode.toc +++ b/DarkMode.toc @@ -3,7 +3,7 @@ ## Interface-Wrath: 30403 ## Interface: 100205 -## Version: 0.4.32 +## Version: 0.5.0 ## Title: DarkMode by |cff3FC7EBD4KiR |T132115:16:16:0:0|t ## Notes: Improve Any Ui or Frame ## Author: D4KiR @@ -16,14 +16,14 @@ libs\D4Lib\D4Lib.xml -libs/math.lua -libs/db.lua +libs\math.lua +libs\db.lua -locale/enUS.lua -locale/deDE.lua -locale/zhCN.lua -locale/zhTW.lua -libs/lang.lua +locale\enUS.lua +locale\deDE.lua +locale\zhCN.lua +locale\zhTW.lua +libs\lang.lua data.lua settings.lua diff --git a/DarkMode_TBC.toc b/DarkMode_TBC.toc index d8b6f7d..d78b4da 100644 --- a/DarkMode_TBC.toc +++ b/DarkMode_TBC.toc @@ -1,5 +1,5 @@ ## Interface: 20504 -## Version: 0.4.32 +## Version: 0.5.0 ## 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 6f549b3..c325503 100644 --- a/DarkMode_Vanilla.toc +++ b/DarkMode_Vanilla.toc @@ -1,5 +1,5 @@ ## Interface: 11501 -## Version: 0.4.32 +## Version: 0.5.0 ## 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 9dc1da0..4082da9 100644 --- a/DarkMode_Wrath.toc +++ b/DarkMode_Wrath.toc @@ -1,5 +1,5 @@ ## Interface: 30403 -## Version: 0.4.32 +## Version: 0.5.0 ## 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 60b3e7b..0107302 100644 --- a/core.lua +++ b/core.lua @@ -555,7 +555,6 @@ function DarkMode:InitQuestLogFrame() for index, name in pairs(DarkMode:GetFrameTextTable()) do if _G[name] and debug then DarkMode:FindTextsByName(name) - table.remove(DarkMode:GetFrameTextTable(), index) end end end @@ -686,10 +685,6 @@ function DarkMode:SearchUi(from) end end end - - if _G[name] and debug then - table.remove(tab, i) - end end elseif index == "Minimap" or index == "Artworks" or index == "Chat" or index == "Castbar" then for ind, name in pairs(tab) do @@ -707,35 +702,22 @@ function DarkMode:SearchUi(from) if name ~= "MainMenuBarBackpackButtonNormalTexture" or DarkMode:GetWoWBuild() ~= "RETAIL" then DarkMode:FindTexturesByName(name, "ui") end - - if _G[name] and debug then - table.remove(tab, ind) - end end elseif index == "Gryphons" then if DarkMode:IsEnabled("GRYPHONS", true) then for i, name in pairs(tab) do DarkMode:FindTexturesByName(name, "ui") - if _G[name] and debug then - table.remove(tab, i) - end end end elseif index == "Tooltips" then for i, name in pairs(tab) do DarkMode:FindTexturesByName(name, "tt") - if _G[name] and debug then - table.remove(tab, i) - end end elseif type(tab) == "string" then DarkMode:FindTexturesByName(tab, "ui") elseif index == "UnitFrames" then for i, name in pairs(tab) do DarkMode:FindTexturesByName(name, "uf") - if _G[name] and debug then - table.remove(tab, i) - end end else print("Missing Ui index:", index, tab) @@ -794,7 +776,10 @@ function DarkMode:SearchUi(from) border:SetTexture("Interface\\AddOns\\DarkMode\\media\\mmicon_border") border:SetPoint("TOPLEFT", 0, 1) border:SetDrawLayer("OVERLAY", 3) - border:SetScale(0.86) + if border.SetScale then + border:SetScale(0.86) + end + DarkMode:UpdateColor(border, "ui") end @@ -804,7 +789,10 @@ function DarkMode:SearchUi(from) border:SetTexture("Interface\\AddOns\\DarkMode\\media\\mmicon_border") border:SetPoint("TOPLEFT", 0, 1) border:SetDrawLayer("OVERLAY", 3) - border:SetScale(0.8) + if border.SetScale then + border:SetScale(0.8) + end + DarkMode:UpdateColor(border, "ui") end @@ -813,7 +801,10 @@ function DarkMode:SearchUi(from) border:SetTexture("Interface\\AddOns\\DarkMode\\media\\mmicon_border") border:SetPoint("TOPLEFT", 0, 1) border:SetDrawLayer("OVERLAY", 3) - border:SetScale(0.8) + if border.SetScale then + border:SetScale(0.8) + end + DarkMode:UpdateColor(border, "ui") end @@ -822,7 +813,9 @@ function DarkMode:SearchUi(from) border:SetTexture("Interface\\AddOns\\DarkMode\\media\\gt_border") if DarkMode:GetWoWBuild() == "WRATH" then border:SetPoint("TOPLEFT", -1, 1) - border:SetScale(0.82) + if border.SetScale then + border:SetScale(0.82) + end else border:SetPoint("TOPLEFT") end @@ -843,7 +836,10 @@ function DarkMode:SearchUi(from) border:SetTexture("Interface\\AddOns\\DarkMode\\media\\mmicon_border") border:SetPoint("TOPLEFT", 0, 1) border:SetParent(btn) - border:SetScale(0.84) + if border.SetScale then + border:SetScale(0.84) + end + border:SetDrawLayer("OVERLAY", 3) DarkMode:UpdateColor(border, "ui") end @@ -874,7 +870,10 @@ function DarkMode:SearchUi(from) border:SetTexture("Interface\\AddOns\\DarkMode\\media\\mmicon_border") border:SetPoint("TOPLEFT", 0, 1) border:SetParent(btwQ) - border:SetScale(0.9) + if border.SetScale then + border:SetScale(0.9) + end + border:SetDrawLayer("OVERLAY", 3) DarkMode:UpdateColor(border, "ui") end @@ -1014,8 +1013,13 @@ 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) + if C_UI then + D4:AddSlash("rl", C_UI.Reload) + D4:AddSlash("rel", C_UI.Reload) + else + D4:AddSlash("rl", ReloadUI) + D4:AddSlash("rel", ReloadUI) + end end local BAGS = {"MainMenuBarBackpackButton", "CharacterBag0Slot", "CharacterBag1Slot", "CharacterBag2Slot", "CharacterBag3Slot"} diff --git a/data.lua b/data.lua index 602bc1b..e1e5a2b 100644 --- a/data.lua +++ b/data.lua @@ -143,7 +143,7 @@ function DarkMode:GetUiAddonsTable() return DMUiAddons end -local DMFrames = {"MailItem1", "MailItem2", "MailItem3", "MailItem4", "MailItem5", "MailItem6", "MailItem7", "MailFrame", "InboxFrame", "GuildMemberDetailFrame", "TabardFrame", "TradeFrame", "TradeFrame.RecipientOverlay", "DressUpFrame", "LootFrame", "StaticPopup1", "StaticPopup2", "ItemTextFrame", "WorldStateScoreFrame", "WorldStateScoreFrameTab1", "WorldStateScoreFrameTab2", "WorldStateScoreFrameTab3", "SettingsPanel", "InspectPaperDollFrame", "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", "WorldMapFrame.MiniBorderFrame", "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", "OpenMailFrame", "OpenMailScrollFrame", "MailFrameTab1", "MailFrameTab2", "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", "BattlefieldListScrollFrame", "BattlefieldFrameType", "TaxiFrame", "YourFrameName", "QuestMapFrame", "QuestMapFrame.DetailsFrame"} +local DMFrames = {"MailItem1", "MailItem2", "MailItem3", "MailItem4", "MailItem5", "MailItem6", "MailItem7", "MailFrame", "InboxFrame", "GuildMemberDetailFrame", "TabardFrame", "TradeFrame", "TradeFrame.RecipientOverlay", "DressUpFrame", "LootFrame", "StaticPopup1", "StaticPopup2", "ItemTextFrame", "WorldStateScoreFrame", "WorldStateScoreFrameTab1", "WorldStateScoreFrameTab2", "WorldStateScoreFrameTab3", "SettingsPanel", "InspectPaperDollFrame", "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", "FriendsFrameTab5", "WhoFrameList", "WorldMapFrame", "WorldMapFrame.BorderFrame", "WorldMapFrame.MiniBorderFrame", "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", "OpenMailFrame", "OpenMailScrollFrame", "MailFrameTab1", "MailFrameTab2", "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", "BattlefieldListScrollFrame", "BattlefieldFrameType", "TaxiFrame", "YourFrameName", "QuestMapFrame", "QuestMapFrame.DetailsFrame"} function DarkMode:GetFrameTable() return DMFrames end diff --git a/libs/D4Lib/D4Lib.lua b/libs/D4Lib/D4Lib.lua index f2a3df0..657642d 100644 --- a/libs/D4Lib/D4Lib.lua +++ b/libs/D4Lib/D4Lib.lua @@ -19,6 +19,48 @@ function D4:GetWoWBuild() return Build end +local oldWow = false +if C_Timer == nil then + print("[D4] ADD C_Timer") + C_Timer = {} + local f = CreateFrame("Frame") + f.tab = {} + f:HookScript( + "OnUpdate", + function() + for i, v in pairs(f.tab) do + if v[1] < GetTime() then + local func = v[2] + func() + tremove(f.tab, i) + end + end + end + ) + + C_Timer.After = function(duration, callback) + tinsert(f.tab, {GetTime() + duration, callback}) + end + + oldWow = true +end + +if GetClassColor == nil then + print("[D4] ADD GetClassColor") + GetClassColor = function(classFilename) + local color = RAID_CLASS_COLORS[classFilename] + if color then return color.r, color.g, color.b, color.colorStr end + + return 1, 1, 1, "ffffffff" + end + + oldWow = true +end + +function D4:IsOldWow() + return oldWow +end + --[[ QOL ]] local ICON_TAG_LIST_EN = { ["star"] = 1, diff --git a/libs/D4Lib/D4Versions.lua b/libs/D4Lib/D4Versions.lua index de91e05..b66b339 100644 --- a/libs/D4Lib/D4Versions.lua +++ b/libs/D4Lib/D4Versions.lua @@ -1,7 +1,10 @@ local AddonName, _ = ... D4.VersionTab = D4.VersionTab or {} local pre = "D4PREFIX" -C_ChatInfo.RegisterAddonMessagePrefix(pre) +if C_ChatInfo then + C_ChatInfo.RegisterAddonMessagePrefix(pre) +end + function D4:SetVersion(name, icon, ver) if name == nil then D4:msg("|cffff0000MISSING NAME AT SetVersion", ver) @@ -118,7 +121,7 @@ f:SetScript( D4:MSG(AddonName, 0, "|cffff0000MISSING VERSION", AddonName) end - if isInitialLogin and ver and pre then + if isInitialLogin and ver and pre and C_ChatInfo then C_ChatInfo.SendAddonMessage(pre, format("A;%s;V;%s", AddonName, ver)) end end diff --git a/libs/db.lua b/libs/db.lua index e8e1176..0d22ea3 100644 --- a/libs/db.lua +++ b/libs/db.lua @@ -1,7 +1,6 @@ local _, DarkMode = ... local BuildNr = select(4, GetBuildInfo()) local Build = "CLASSIC" - if BuildNr >= 100000 then Build = "RETAIL" elseif BuildNr > 29999 then @@ -20,7 +19,6 @@ end local COL_R = "|cFFFF0000" local COL_Y = "|cFFFFFF00" - function DarkMode:MSG(msg) print("|cff3FC7EB" .. "[DarkMode |T136122:16:16:0:0|t]|r " .. COL_Y .. msg) end @@ -85,7 +83,6 @@ function DarkMode:IsEnabled(element, value) end DarkMode:GetTab()["ELES"]["OPTIONS"][element] = DarkMode:GetTab()["ELES"]["OPTIONS"][element] or {} - if DarkMode:GetTab()["ELES"]["OPTIONS"][element]["ENABLED"] == nil then DarkMode:GetTab()["ELES"]["OPTIONS"][element]["ENABLED"] = value end @@ -111,7 +108,6 @@ function DarkMode:SetElePoint(key, p1, p2, p3, p4, p5) DarkMode:GetTab()["ELES"]["POINTS"][key]["PX"] = p4 DarkMode:GetTab()["ELES"]["POINTS"][key]["PY"] = p5 local frame = _G[key] - if frame then frame:ClearAllPoints() frame:SetPoint(p1, UIParent, p3, p4, p5) @@ -127,7 +123,6 @@ end function DarkMode:GV(name, value) DMTAB = DMTAB or {} DMTAB["VALUES"] = DMTAB["VALUES"] or {} - if DMTAB["VALUES"][name] == nil then DarkMode:SV(name, value) end diff --git a/libs/lang.lua b/libs/lang.lua index d92c9e7..12e211b 100644 --- a/libs/lang.lua +++ b/libs/lang.lua @@ -1,6 +1,5 @@ local _, DarkMode = ... local ialang = {} - function DarkMode:GetLangTab() return ialang end @@ -8,7 +7,6 @@ end function DarkMode:GT(str) local tab = DarkMode:GetLangTab() local result = tab[str] - if result ~= nil then return result else @@ -20,7 +18,6 @@ end function DarkMode:UpdateLanguage() DarkMode:Lang_enUS() - if GetLocale() == "deDE" then DarkMode:Lang_deDE() elseif GetLocale() == "zhCN" then diff --git a/libs/math.lua b/libs/math.lua index eb4c25d..80dafe5 100644 --- a/libs/math.lua +++ b/libs/math.lua @@ -1,10 +1,8 @@ local _, DarkMode = ... - function DarkMode:MathC(val, vmin, vmax) if val == nil then return 0 end if vmin == nil then return 0 end if vmax == nil then return 1 end - if val < vmin then return vmin elseif val > vmax then @@ -23,7 +21,6 @@ end function DarkMode:FormatValue(val, dec) dec = dec or 1 - if val < 1000 then return ("%." .. 0 .. "f"):format(val) elseif val < 1000000 then @@ -44,7 +41,6 @@ end function DarkMode:ReplaceStr(text, old, new) if text == nil then return "" end local b, e = text:find(old, 1, true) - if b == nil then return text else diff --git a/settings.lua b/settings.lua index 8c2c111..cb36772 100644 --- a/settings.lua +++ b/settings.lua @@ -85,19 +85,58 @@ 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) + sls[key].SetText = function(self, text) + if sls[key].Text then + sls[key].Text:SetText(text) + else + _G["sls[" .. key .. "]" .. "Text"]:SetText(text) + end + end + if type(vmin) == "number" then - sls[key].Low:SetText(vmin) - sls[key].High:SetText(vmax) + if sls[key].Low then + sls[key].Low:SetText(vmin) + else + _G["sls[" .. key .. "]" .. "Low"]:SetText(vmin) + end + + if sls[key].High then + sls[key].High:SetText(vmax) + else + _G["sls[" .. key .. "]" .. "High"]:SetText(vmax) + end + sls[key]:SetMinMaxValues(vmin, vmax) - sls[key].Text:SetText(DarkMode:GT(key) .. ": " .. DarkMode:GV(key, val)) + if sls[key].Text then + sls[key].Text:SetText(DarkMode:GT(key) .. ": " .. DarkMode:GV(key, val)) + else + _G["sls[" .. key .. "]" .. "Text"]:SetText(DarkMode:GT(key) .. ": " .. DarkMode:GV(key, val)) + end else - sls[key].Low:SetText("") - sls[key].High:SetText("") + if sls[key].Low then + sls[key].Low:SetText("") + else + _G["sls[" .. key .. "]" .. "Low"]:SetText("") + end + + if sls[key].High then + sls[key].High:SetText("") + else + _G["sls[" .. key .. "]" .. "High"]:SetText("") + end + sls[key]:SetMinMaxValues(1, #vmin) - sls[key].Text:SetText(DarkMode:GT(key) .. ": " .. vmin[DarkMode:GV(key, val)]) + if sls[key].Text then + sls[key].Text:SetText(DarkMode:GT(key) .. ": " .. vmin[DarkMode:GV(key, val)]) + else + _G["sls[" .. key .. "]" .. "Text"]:SetText(DarkMode:GT(key) .. ": " .. vmin[DarkMode:GV(key, val)]) + end + end + + if sls[key].SetObeyStepOnDrag then + sls[key]:SetObeyStepOnDrag(true) end - sls[key]:SetObeyStepOnDrag(true) if steps then sls[key]:SetValueStep(steps) end @@ -114,10 +153,18 @@ local function AddSlider(x, key, val, func, vmin, vmax, steps) 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) + if sls[key].Text then + sls[key].Text:SetText(DarkMode:GT(key) .. ": " .. valu) + else + _G["sls[" .. key .. "]" .. "Text"]:SetText(DarkMode:GT(key) .. ": " .. valu) + end else DarkMode:SV(key, valu) - sls[key].Text:SetText(DarkMode:GT(key) .. ": " .. vmin[valu]) + if sls[key].Text then + sls[key].Text:SetText(DarkMode:GT(key) .. ": " .. vmin[valu]) + else + _G["sls[" .. key .. "]" .. "Text"]:SetText(DarkMode:GT(key) .. ": " .. vmin[valu]) + end end if func then @@ -197,11 +244,29 @@ function DarkMode:ToggleSettings() end function DarkMode:InitDMSettings() - DMSettings = CreateFrame("Frame", "DMSettings", UIParent, "BasicFrameTemplate") + if not D4:IsOldWow() then + DMSettings = CreateFrame("Frame", "DMSettings", UIParent, "BasicFrameTemplate") + else + DMSettings = CreateFrame("Frame", "DMSettings", UIParent) + DMSettings.TitleText = DMSettings:CreateFontString(nil, nil, "GameFontNormal") + DMSettings.TitleText:SetPoint("TOP", DMSettings, "TOP", 0, 0) + DMSettings.CloseButton = CreateFrame("Button", "DMSettings.CloseButton", DMSettings, "UIPanelButtonTemplate") + DMSettings.CloseButton:SetPoint("TOPRIGHT", DMSettings, "TOPRIGHT", 0, 0) + DMSettings.CloseButton:SetSize(25, 25) + DMSettings.CloseButton:SetText("X") + DMSettings.bg = DMSettings:CreateTexture("DMSettings.bg", "ARTWORK") + DMSettings.bg:SetAllPoints(DMSettings) + if DMSettings.bg.SetColorTexture then + DMSettings.bg:SetColorTexture(0.03, 0.03, 0.03, 0.5) + else + DMSettings.bg:SetTexture(0.03, 0.03, 0.03, 0.5) + end + end + DMSettings:SetSize(550, 500) DMSettings:SetPoint("CENTER", UIParent, "CENTER", 0, 0) DMSettings:SetFrameStrata("HIGH") - DMSettings:SetFrameLevel(999) + DMSettings:SetFrameLevel(99) DMSettings:SetClampedToScreen(true) DMSettings:SetMovable(true) DMSettings:EnableMouse(true) @@ -222,8 +287,8 @@ function DarkMode:InitDMSettings() DMSettings:Hide() end - D4:SetVersion(AddonName, 136122, "0.4.32") - DMSettings.TitleText:SetText(format("DarkMode |T136122:16:16:0:0|t v|cff3FC7EB%s", "0.4.32")) + D4:SetVersion(AddonName, 136122, "0.5.0") + DMSettings.TitleText:SetText(format("DarkMode |T136122:16:16:0:0|t v|cff3FC7EB%s", "0.5.0")) DMSettings.CloseButton:SetScript( "OnClick", function() @@ -243,24 +308,24 @@ function DarkMode:InitDMSettings() "COLORMODE", DarkMode:GV("COLORMODE", 1), function(sel, val) - sel.Text:SetText(DarkMode:GT("COLORMODE") .. ": " .. DarkMode:GetColorModes()[val]) + sel: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)]) + sCM: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", 1), function(sel, val) - sel.Text:SetText(DarkMode:GT("COLORMODEUF") .. ": " .. DarkMode:GetColorModes()[val]) + sel: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", 1)]) + sCMUF:SetText(DarkMode:GT("COLORMODEUF") .. ": " .. DarkMode:GetColorModes()[DarkMode:GV("COLORMODEUF", 1)]) DarkMode:AddColorPicker("CUSTOMUFC", DMSettings.SC, 0, 0) --TT local sCMTT = AddSlider( @@ -268,12 +333,12 @@ function DarkMode:InitDMSettings() "COLORMODETT", DarkMode:GV("COLORMODETT", 1), function(sel, val) - sel.Text:SetText(DarkMode:GT("COLORMODETT") .. ": " .. DarkMode:GetColorModes()[val]) + sel: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", 1)]) + sCMTT:SetText(DarkMode:GT("COLORMODETT") .. ": " .. DarkMode:GetColorModes()[DarkMode:GV("COLORMODETT", 1)]) DarkMode:AddColorPicker("CUSTOMTTC", DMSettings.SC, 0, 0) --AB local sCMAB = AddSlider( @@ -281,12 +346,12 @@ function DarkMode:InitDMSettings() "COLORMODEAB", DarkMode:GV("COLORMODEAB", 1), function(sel, val) - sel.Text:SetText(DarkMode:GT("COLORMODEAB") .. ": " .. DarkMode:GetColorModes()[val]) + sel:SetText(DarkMode:GT("COLORMODEAB") .. ": " .. DarkMode:GetColorModes()[val]) DarkMode:UpdateColors() end, 1, getn(DarkMode:GetColorModes()), 1 ) - sCMAB.Text:SetText(DarkMode:GT("COLORMODEAB") .. ": " .. DarkMode:GetColorModes()[DarkMode:GV("COLORMODEAB", 1)]) + sCMAB:SetText(DarkMode:GT("COLORMODEAB") .. ": " .. DarkMode:GetColorModes()[DarkMode:GV("COLORMODEAB", 1)]) DarkMode:AddColorPicker("CUSTOMABC", DMSettings.SC, 0, 0) --BAD local sCMBAD = AddSlider( @@ -294,12 +359,12 @@ function DarkMode:InitDMSettings() "COLORMODEBAD", DarkMode:GV("COLORMODEBAD", 1), function(sel, val) - sel.Text:SetText(DarkMode:GT("COLORMODEBAD") .. ": " .. DarkMode:GetColorModes()[val]) + sel:SetText(DarkMode:GT("COLORMODEBAD") .. ": " .. DarkMode:GetColorModes()[val]) DarkMode:UpdateColors() end, 1, getn(DarkMode:GetColorModes()), 1 ) - sCMBAD.Text:SetText(DarkMode:GT("COLORMODEBAD") .. ": " .. DarkMode:GetColorModes()[DarkMode:GV("COLORMODEBAD", 1)]) + sCMBAD:SetText(DarkMode:GT("COLORMODEBAD") .. ": " .. DarkMode:GetColorModes()[DarkMode:GV("COLORMODEBAD", 1)]) DarkMode:AddColorPicker("CUSTOMBADC", DMSettings.SC, 0, 0) --Frames local sCMF = AddSlider( @@ -307,12 +372,12 @@ function DarkMode:InitDMSettings() "COLORMODEF", DarkMode:GV("COLORMODEF", 1), function(sel, val) - sel.Text:SetText(DarkMode:GT("COLORMODEF") .. ": " .. DarkMode:GetColorModes()[val]) + sel: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)]) + sCMF:SetText(DarkMode:GT("COLORMODEF") .. ": " .. DarkMode:GetColorModes()[DarkMode:GV("COLORMODEF", 1)]) DarkMode:AddColorPicker("CUSTOMFRC", DMSettings.SC, 0, 0) end @@ -337,7 +402,12 @@ function DarkMode:InitDMSettings() DMSettings.SF:SetScrollChild(DMSettings.SC) DMSettings.SF.bg = DMSettings.SF:CreateTexture("DMSettings.SF.bg", "ARTWORK") DMSettings.SF.bg:SetAllPoints(DMSettings.SF) - DMSettings.SF.bg:SetColorTexture(0.03, 0.03, 0.03, 0.5) + if DMSettings.SF.bg.SetColorTexture then + DMSettings.SF.bg:SetColorTexture(0.03, 0.03, 0.03, 0.5) + else + DMSettings.SF.bg:SetTexture(0.03, 0.03, 0.03, 0.5) + end + DMSettings.save = CreateFrame("BUTTON", "DMSettings" .. ".save", DMSettings, "UIPanelButtonTemplate") DMSettings.save:SetSize(120, 24) DMSettings.save:SetPoint("TOPLEFT", DMSettings, "TOPLEFT", 4, -DMSettings:GetHeight() + 24 + 4) @@ -345,7 +415,11 @@ function DarkMode:InitDMSettings() DMSettings.save:SetScript( "OnClick", function() - C_UI.Reload() + if C_UI then + C_UI.Reload() + else + ReloadUI() + end end ) @@ -353,11 +427,15 @@ function DarkMode:InitDMSettings() 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:SetText(RELOADUI or "RELOADUI") DMSettings.reload:SetScript( "OnClick", function() - C_UI.Reload() + if C_UI then + C_UI.Reload() + else + ReloadUI() + end end ) @@ -370,7 +448,11 @@ function DarkMode:InitDMSettings() function() if GetCVar("ScriptErrors") == "0" then SetCVar("ScriptErrors", 1) - C_UI.Reload() + if C_UI then + C_UI.Reload() + else + ReloadUI() + end end DMSettings:UpdateShowErrors()