-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
655 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.