Skip to content

Commit

Permalink
v0.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
d4kir92 committed Jan 1, 2024
1 parent 79136af commit fef3b82
Show file tree
Hide file tree
Showing 26 changed files with 655 additions and 18 deletions.
5 changes: 2 additions & 3 deletions DarkMode.toc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions DarkMode_TBC.toc
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions DarkMode_Vanilla.toc
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions DarkMode_Wrath.toc
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
33 changes: 33 additions & 0 deletions libs/D4Lib/D4DB.lua
Original file line number Diff line number Diff line change
@@ -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
137 changes: 137 additions & 0 deletions libs/D4Lib/D4Frames.lua
Original file line number Diff line number Diff line change
@@ -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
139 changes: 139 additions & 0 deletions libs/D4Lib/D4Grid.lua
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit fef3b82

Please sign in to comment.