From fef3b826597024d4528566b886eaa245f6b4b959 Mon Sep 17 00:00:00 2001 From: D4KiR <23246564+d4kir92@users.noreply.github.com> Date: Mon, 1 Jan 2024 12:20:01 +0100 Subject: [PATCH] v0.4.6 --- DarkMode.toc | 5 +- DarkMode_TBC.toc | 5 +- DarkMode_Vanilla.toc | 5 +- DarkMode_Wrath.toc | 5 +- libs/D4Lib/D4DB.lua | 33 ++++ libs/D4Lib/D4Frames.lua | 137 ++++++++++++++++ libs/D4Lib/D4Grid.lua | 139 +++++++++++++++++ libs/D4Lib/D4Lib.lua | 38 +++++ libs/D4Lib/D4Lib.xml | 19 +++ libs/D4Lib/D4MinimapButtons.lua | 44 ++++++ libs/D4Lib/D4Output.lua | 7 + libs/D4Lib/D4SlashCmds.lua | 44 ++++++ libs/D4Lib/D4Translations.lua | 36 +++++ libs/D4Lib/D4Versions.lua | 147 ++++++++++++++++++ libs/{ => D4Lib}/LibDBIcon-1.0/CHANGES.txt | 0 .../CallbackHandler-1.0.lua | 0 .../LibDBIcon-1.0/LibDBIcon-1.0.toc | 0 .../LibDBIcon-1.0/LibDBIcon-1.0.lua | 0 .../LibDBIcon-1.0/LibDBIcon-1.0/lib.xml | 0 .../LibDBIcon-1.0/LibDBIcon-1.0_TBC.toc | 0 .../LibDBIcon-1.0/LibDBIcon-1.0_Vanilla.toc | 0 .../LibDBIcon-1.0/LibDBIcon-1.0_Wrath.toc | 0 .../LibDataBroker-1.1/LibDataBroker-1.1.lua | 0 .../LibDBIcon-1.0/LibStub/LibStub.lua | 0 libs/{ => D4Lib}/LibDBIcon-1.0/embeds.xml | 0 settings.lua | 9 +- 26 files changed, 655 insertions(+), 18 deletions(-) create mode 100644 libs/D4Lib/D4DB.lua create mode 100644 libs/D4Lib/D4Frames.lua create mode 100644 libs/D4Lib/D4Grid.lua create mode 100644 libs/D4Lib/D4Lib.lua create mode 100644 libs/D4Lib/D4Lib.xml create mode 100644 libs/D4Lib/D4MinimapButtons.lua create mode 100644 libs/D4Lib/D4Output.lua create mode 100644 libs/D4Lib/D4SlashCmds.lua create mode 100644 libs/D4Lib/D4Translations.lua create mode 100644 libs/D4Lib/D4Versions.lua rename libs/{ => D4Lib}/LibDBIcon-1.0/CHANGES.txt (100%) rename libs/{ => D4Lib}/LibDBIcon-1.0/CallbackHandler-1.0/CallbackHandler-1.0.lua (100%) rename libs/{ => D4Lib}/LibDBIcon-1.0/LibDBIcon-1.0.toc (100%) rename libs/{ => D4Lib}/LibDBIcon-1.0/LibDBIcon-1.0/LibDBIcon-1.0.lua (100%) rename libs/{ => D4Lib}/LibDBIcon-1.0/LibDBIcon-1.0/lib.xml (100%) rename libs/{ => D4Lib}/LibDBIcon-1.0/LibDBIcon-1.0_TBC.toc (100%) rename libs/{ => D4Lib}/LibDBIcon-1.0/LibDBIcon-1.0_Vanilla.toc (100%) rename libs/{ => D4Lib}/LibDBIcon-1.0/LibDBIcon-1.0_Wrath.toc (100%) rename libs/{ => D4Lib}/LibDBIcon-1.0/LibDataBroker-1.1/LibDataBroker-1.1.lua (100%) rename libs/{ => D4Lib}/LibDBIcon-1.0/LibStub/LibStub.lua (100%) rename libs/{ => D4Lib}/LibDBIcon-1.0/embeds.xml (100%) diff --git a/DarkMode.toc b/DarkMode.toc index c9b2801..01ccf76 100644 --- a/DarkMode.toc +++ b/DarkMode.toc @@ -3,7 +3,7 @@ ## Interface-Wrath: 30403 ## Interface: 100200 -## Version: 0.4.5 +## Version: 0.4.6 ## Title: DarkMode by |cff3FC7EBD4KiR |T132115:16:16:0:0|t ## Notes: Improve Any Ui or Frame ## Author: D4KiR @@ -14,8 +14,7 @@ ## X-Wago-ID: VBNBDqKx ## IconTexture: 136122 -libs\LibDBIcon-1.0\embeds.xml -libs\LibDBIcon-1.0\LibDBIcon-1.0\lib.xml +libs\D4Lib\D4Lib.xml libs/math.lua libs/db.lua diff --git a/DarkMode_TBC.toc b/DarkMode_TBC.toc index 650225a..290fcdf 100644 --- a/DarkMode_TBC.toc +++ b/DarkMode_TBC.toc @@ -1,5 +1,5 @@ ## Interface: 20504 -## Version: 0.4.5 +## Version: 0.4.6 ## Title: DarkMode |T136122:16:16:0:0|t by |cff3FC7EBD4KiR |T132115:16:16:0:0|t ## Notes: Improve Any Ui or Frame ## Author: D4KiR @@ -9,8 +9,7 @@ ## X-Curse-Project-ID: 812982 ## X-Wago-ID: VBNBDqKx -libs\LibDBIcon-1.0\embeds.xml -libs\LibDBIcon-1.0\LibDBIcon-1.0\lib.xml +libs\D4Lib\D4Lib.xml libs/math.lua libs/db.lua diff --git a/DarkMode_Vanilla.toc b/DarkMode_Vanilla.toc index a5dc29f..0fa6936 100644 --- a/DarkMode_Vanilla.toc +++ b/DarkMode_Vanilla.toc @@ -1,5 +1,5 @@ ## Interface: 11500 -## Version: 0.4.5 +## Version: 0.4.6 ## Title: DarkMode |T136122:16:16:0:0|t by |cff3FC7EBD4KiR |T132115:16:16:0:0|t ## Notes: Improve Any Ui or Frame ## Author: D4KiR @@ -9,8 +9,7 @@ ## X-Curse-Project-ID: 812982 ## X-Wago-ID: VBNBDqKx -libs\LibDBIcon-1.0\embeds.xml -libs\LibDBIcon-1.0\LibDBIcon-1.0\lib.xml +libs\D4Lib\D4Lib.xml libs/math.lua libs/db.lua diff --git a/DarkMode_Wrath.toc b/DarkMode_Wrath.toc index 872610f..d1d0c91 100644 --- a/DarkMode_Wrath.toc +++ b/DarkMode_Wrath.toc @@ -1,5 +1,5 @@ ## Interface: 30403 -## Version: 0.4.5 +## Version: 0.4.6 ## Title: DarkMode |T136122:16:16:0:0|t by |cff3FC7EBD4KiR |T132115:16:16:0:0|t ## Notes: Improve Any Ui or Frame ## Author: D4KiR @@ -9,8 +9,7 @@ ## X-Curse-Project-ID: 812982 ## X-Wago-ID: VBNBDqKx -libs\LibDBIcon-1.0\embeds.xml -libs\LibDBIcon-1.0\LibDBIcon-1.0\lib.xml +libs\D4Lib\D4Lib.xml libs/math.lua libs/db.lua diff --git a/libs/D4Lib/D4DB.lua b/libs/D4Lib/D4DB.lua new file mode 100644 index 0000000..221ba7e --- /dev/null +++ b/libs/D4Lib/D4DB.lua @@ -0,0 +1,33 @@ +function D4:GV(db, key, value) + if db == nil then + D4:msg("[D4:GV] db is nil", "db", tostring(db), "key", tostring(key), "value", tostring(value)) + + return value + end + + if type(db) ~= "table" then + D4:msg("[D4:GV] db is not table", "db", tostring(db), "key", tostring(key), "value", tostring(value)) + + return value + end + + if db[key] ~= nil then return db[key] end + + return value +end + +function D4:SV(db, key, value) + if db == nil then + D4:msg("[D4:SV] db is nil", "db", tostring(db), "key", tostring(key), "value", tostring(value)) + + return false + end + + if key == nil then + D4:msg("[D4:SV] key is nil", "db", tostring(db), "key", tostring(key), "value", tostring(value)) + + return false + end + + db[key] = value +end \ No newline at end of file diff --git a/libs/D4Lib/D4Frames.lua b/libs/D4Lib/D4Frames.lua new file mode 100644 index 0000000..d1ad162 --- /dev/null +++ b/libs/D4Lib/D4Frames.lua @@ -0,0 +1,137 @@ +--[[ INPUTS ]] +function D4:AddCategory(tab) + tab.sw = tab.sw or 25 + tab.sh = tab.sh or 25 + tab.parent = tab.parent or UIParent + tab.pTab = tab.pTab or "CENTER" + tab.parent.f = tab.parent:CreateFontString(nil, nil, "GameFontNormal") + tab.parent.f:SetPoint(unpack(tab.pTab)) + tab.parent.f:SetText(D4:Trans(tab.name)) +end + +function D4:CreateCheckbox(tab) + tab.sw = tab.sw or 25 + tab.sh = tab.sh or 25 + tab.parent = tab.parent or UIParent + tab.pTab = tab.pTab or "CENTER" + tab.value = tab.value or nil + local cb = CreateFrame("CheckButton", tab.name, tab.parent, "UICheckButtonTemplate") + cb:SetSize(tab.sw, tab.sh) + cb:SetPoint(unpack(tab.pTab)) + cb:SetChecked(tab.value) + cb:SetScript( + "OnClick", + function(sel) + tab:funcV(sel:GetChecked()) + end + ) + + cb.f = cb:CreateFontString(nil, nil, "GameFontNormal") + cb.f:SetPoint("LEFT", cb, "RIGHT", 0, 0) + cb.f:SetText(D4:Trans(tab.name)) + + return cb +end + +function D4:CreateCheckboxForCVAR(tab) + tab.sw = tab.sw or 25 + tab.sh = tab.sh or 25 + tab.parent = tab.parent or UIParent + tab.pTab = tab.pTab or "CENTER" + tab.value = tab.value or nil + local cb = D4:CreateCheckbox(tab) + local cb2 = CreateFrame("CheckButton", tab.name, tab.parent, "UICheckButtonTemplate") + cb2:SetSize(tab.sw, tab.sh) + local p1, p2, p3 = unpack(tab.pTab) + cb2:SetPoint(p1, p2 + 25, p3) + cb2:SetChecked(tab.value2) + cb2:SetScript( + "OnClick", + function(sel) + tab:funcV2(sel:GetChecked()) + end + ) + + cb.f:SetPoint("LEFT", cb, "RIGHT", 25, 0) + + return cb +end + +function D4:CreateEditBox(tab) + tab.sw = tab.sw or 200 + tab.sh = tab.sh or 25 + tab.parent = tab.parent or UIParent + tab.pTab = tab.pTab or "CENTER" + tab.value = tab.value or nil + local cb = CreateFrame("EditBox", tab.name, tab.parent, "InputBoxTemplate") + cb:SetSize(tab.sw, tab.sh) + cb:SetPoint(unpack(tab.pTab)) + cb:SetText(tab.value) + cb:SetScript( + "OnTextChanged", + function(sel) + tab:funcV(sel:GetText()) + end + ) + + cb.f = cb:CreateFontString(nil, nil, "GameFontNormal") + cb.f:SetPoint("LEFT", cb, "RIGHT", 0, 0) + cb.f:SetText(D4:Trans(tab.name)) + + return cb +end + +function D4:CreateSlider(tab) + tab.sw = tab.sw or 200 + tab.sh = tab.sh or 25 + tab.parent = tab.parent or UIParent + tab.pTab = tab.pTab or "CENTER" + tab.value = tab.value or nil + tab.vmin = tab.vmin or 1 + tab.vmax = tab.vmax or 1 + tab.steps = tab.steps or 1 + tab.key = tab.key or tab.name or "" + local slider = CreateFrame("Slider", tab.name, tab.parent, "OptionsSliderTemplate") + slider:SetWidth(tab.sw) + slider:SetPoint(unpack(tab.pTab)) + slider.Low:SetText(tab.vmin) + slider.High:SetText(tab.vmax) + slider.Text:SetText(format("%s: %s", D4:Trans(tab.key), tab.value)) + slider:SetMinMaxValues(tab.vmin, tab.vmax) + slider:SetObeyStepOnDrag(true) + slider:SetValueStep(tab.steps) + slider:SetValue(tab.value) + slider:SetScript( + "OnValueChanged", + function(sel, val) + val = string.format("%" .. tab.steps .. "f", val) + tab:funcV(val) + slider.Text:SetText(format("%s: %s", D4:Trans(tab.key), val)) + end + ) + + return slider +end + +--[[ FRAMES ]] +function D4:CreateFrame(tab) + tab.sw = tab.sw or 100 + tab.sh = tab.sh or 100 + tab.parent = tab.parent or UIParent + tab.pTab = tab.pTab or "CENTER" + tab.title = tab.title or "" + tab.templates = tab.templates or "BasicFrameTemplateWithInset" + local fra = CreateFrame("FRAME", tab.name, tab.parent, tab.templates) + fra:SetSize(tab.sw, tab.sh) + fra:SetPoint(unpack(tab.pTab)) + fra:SetClampedToScreen(true) + fra:SetMovable(true) + fra:EnableMouse(true) + fra:RegisterForDrag("LeftButton") + fra:SetScript("OnDragStart", fra.StartMoving) + fra:SetScript("OnDragStop", fra.StopMovingOrSizing) + fra:Hide() + fra.TitleText:SetText(tab.title) + + return fra +end \ No newline at end of file diff --git a/libs/D4Lib/D4Grid.lua b/libs/D4Lib/D4Grid.lua new file mode 100644 index 0000000..f2e9b88 --- /dev/null +++ b/libs/D4Lib/D4Grid.lua @@ -0,0 +1,139 @@ +function D4:Grid(n, snap) + n = n or 0 + snap = snap or 10 + local mod = n % snap + + return (mod > (snap / 2)) and (n - mod + snap) or (n - mod) +end + +function D4:SetGridSize(size) + return size +end + +function D4:GetGridSize() + return 10 +end + +function D4:UpdateGrid() + local id = 0 + grid.lines = grid.lines or {} + for i, v in pairs(grid.lines) do + v:Hide() + end + + for x = 0, GetScreenWidth() / 2, D4:GetGridSize() do + grid.lines[id] = grid.lines[id] or grid:CreateTexture() + grid.lines[id]:SetPoint("CENTER", 0.5 + x, 0) + grid.lines[id]:SetSize(1.09, GetScreenHeight()) + if x % 50 == 0 then + grid.lines[id]:SetColorTexture(1, 1, 0.5, 0.25) + else + grid.lines[id]:SetColorTexture(0.5, 0.5, 0.5, 0.25) + end + + grid.lines[id]:Show() + id = id + 1 + end + + for x = 0, -GetScreenWidth() / 2, -D4:GetGridSize() do + grid.lines[id] = grid.lines[id] or grid:CreateTexture() + grid.lines[id]:SetPoint("CENTER", 0.5 + x, 0) + grid.lines[id]:SetSize(1.09, GetScreenHeight()) + if x % 50 == 0 then + grid.lines[id]:SetColorTexture(1, 1, 0.5, 0.25) + else + grid.lines[id]:SetColorTexture(0.5, 0.5, 0.5, 0.25) + end + + grid.lines[id]:Show() + id = id + 1 + end + + for y = 0, GetScreenHeight() / 2, D4:GetGridSize() do + grid.lines[id] = grid.lines[id] or grid:CreateTexture() + grid.lines[id]:SetPoint("CENTER", 0, 0.5 + y) + grid.lines[id]:SetSize(GetScreenWidth(), 1.09, GetScreenHeight()) + if y % 50 == 0 then + grid.lines[id]:SetColorTexture(1, 1, 0.5, 0.25) + else + grid.lines[id]:SetColorTexture(0.5, 0.5, 0.5, 0.25) + end + + grid.lines[id]:Show() + id = id + 1 + end + + for y = 0, -GetScreenHeight() / 2, -D4:GetGridSize() do + grid.lines[id] = grid.lines[id] or grid:CreateTexture() + grid.lines[id]:SetPoint("CENTER", 0, 0.5 + y) + grid.lines[id]:SetSize(GetScreenWidth(), 1.09) + if y % 50 == 0 then + grid.lines[id]:SetColorTexture(1, 1, 0.5, 0.25) + else + grid.lines[id]:SetColorTexture(0.5, 0.5, 0.5, 0.25) + end + + grid.lines[id]:Show() + id = id + 1 + end +end + +function D4:CreateGrid() + if grid == nil then + grid = CreateFrame("Frame", "grid", UIParent) + grid:EnableMouse(false) + grid:SetSize(GetScreenWidth(), GetScreenHeight()) + grid:SetPoint("CENTER", UIParent, "CENTER", 0, 0) + grid:SetFrameStrata("LOW") + grid:SetFrameLevel(1) + grid.bg = grid:CreateTexture("grid.bg", "BACKGROUND", nil, 0) + grid.bg:SetAllPoints(grid) + grid.bg:SetColorTexture(0.03, 0.03, 0.03, 0) + grid.hor = grid:CreateTexture() + grid.hor:SetPoint("CENTER", 0, -0.5) + grid.hor:SetSize(GetScreenWidth(), 1) + grid.hor:SetColorTexture(1, 1, 1, 1) + grid.ver = grid:CreateTexture() + grid.ver:SetPoint("CENTER", 0.5, 0) + grid.ver:SetSize(1, GetScreenHeight()) + grid.ver:SetColorTexture(1, 1, 1, 1) + end + + D4:UpdateGrid() +end + +function D4:AddHelper(frame, hide) + if frame.hh == nil then + frame.hh = frame:CreateTexture(nil, "HIGHLIGHT") + frame.hh:SetSize(1.1, frame:GetHeight()) + frame.hh:SetPoint("CENTER", frame, "CENTER", 0, 0) + frame.hh:SetColorTexture(1, 1, 1) + end + + if frame.vh == nil then + frame.vh = frame:CreateTexture(nil, "HIGHLIGHT") + frame.vh:SetSize(frame:GetWidth(), 1.1) + frame.vh:SetPoint("CENTER", frame, "CENTER", 0, 0) + frame.vh:SetColorTexture(1, 1, 1) + end + + if hide then + frame.hh:Hide() + frame.vh:Hide() + else + frame.hh:Show() + frame.vh:Show() + end +end + +function D4:HideGrid(frame) + D4:AddHelper(frame, true) + D4:CreateGrid() + grid:Hide() +end + +function D4:ShowGrid(frame) + D4:AddHelper(frame, false) + D4:CreateGrid() + grid:Show() +end \ No newline at end of file diff --git a/libs/D4Lib/D4Lib.lua b/libs/D4Lib/D4Lib.lua new file mode 100644 index 0000000..10cf9fb --- /dev/null +++ b/libs/D4Lib/D4Lib.lua @@ -0,0 +1,38 @@ +local _, _ = ... +D4 = D4 or {} +--[[ Basics ]] +local BuildNr = select(4, GetBuildInfo()) +local Build = "CLASSIC" +if BuildNr >= 100000 then + Build = "RETAIL" +elseif BuildNr > 29999 then + Build = "WRATH" +elseif BuildNr > 19999 then + Build = "TBC" +end + +function D4:GetWoWBuildNr() + return BuildNr +end + +function D4:GetWoWBuild() + return Build +end + +--[[ QOL ]] +C_Timer.After( + 4, + function() + if D4.LoadTargetHealth == nil then + function D4:LoadTargetHealth() + if D4:GetWoWBuild() ~= "RETAIL" and ShouldKnowUnitHealth and ShouldKnowUnitHealth("target") == false then + function ShouldKnowUnitHealth(unit) + return true + end + end + end + + D4:LoadTargetHealth() + end + end +) \ No newline at end of file diff --git a/libs/D4Lib/D4Lib.xml b/libs/D4Lib/D4Lib.xml new file mode 100644 index 0000000..b91e41d --- /dev/null +++ b/libs/D4Lib/D4Lib.xml @@ -0,0 +1,19 @@ + + + + + +