forked from varren/ViragDevTool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ViragDevToolOptions.lua
110 lines (89 loc) · 3.76 KB
/
ViragDevToolOptions.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
function ViragDevTool:ToggleOptions()
-- InterfaceOptionsFrame_OpenToCategory(ViragDevTool.ADDON_NAME);
self:LoadInterfaceOptions()
self:Toggle(self.wndRef.optionsFrame)
end
function ViragDevTool:LoadInterfaceOptions()
if not self.wndRef.optionsFrame then
local frame = CreateFrame("Frame", "ViragDevToolOptionsMainFrame", self.wndRef, "ViragDevToolOptionsFrameRowTemplate")
frame:SetPoint("BOTTOM", self.wndRef, "TOP")
frame:SetHeight(35)
frame:SetPoint("LEFT")
frame:SetPoint("RIGHT")
frame:Hide()
self:CreateColorPickerFrame(frame)
self.wndRef.optionsFrame = frame
--self.wndRef.optionsFrame.name = self.ADDON_NAME;
--InterfaceOptions_AddCategory(frame);
--InterfaceAddOnsList_Update();
--InterfaceOptionsFrame_OpenToCategory(ViragDevTool.ADDON_NAME);
end
end
function ViragDevTool:CreateColorPickerFrame(parent)
local point = "TOPLEFT"
local relativeTo = parent
local relativePoint = "TOPLEFT"
local xOffset = 5
local yOffset = -5
local update = function(button, color)
button.colorTexture:SetTexture(unpack(self.colors[color]))
button:GetHighlightTexture():SetVertexColor(unpack(self.colors[color]))
button:GetFontString():SetTextColor(unpack(self.colors[color]))
ViragDevTool:UpdateMainTableUI()
end
local buttons = {}
for i, color in pairs({ "table", "function", "string", "number", "default" }) do
local f = CreateFrame("Button", "VDTColorPickerFrameItem" .. i, parent, "VDTColorPickerFrameItemTemplate")
f:SetPoint(point, relativeTo, relativePoint, xOffset, yOffset)
local button = f.picker
buttons[i] = button
button:SetText(color)
button:SetScript("OnMouseUp", function(this, mouseButton, down)
if mouseButton == "RightButton" then
ViragDevTool.colors[color] = ViragDevTool.default_settings.colors[color]
update(this, color)
elseif mouseButton == "LeftButton" then
self:ShowColorPicker(color, function()
local r, g, b = ColorPickerFrame:GetColorRGB()
ViragDevTool.colors[color] = { r, g, b, 1 }
update(this, color)
end)
end
end)
update(button, color)
point = "LEFT"
relativeTo = f
relativePoint = "RIGHT"
yOffset = 0
xOffset = 5
end
local updateFontSize = function(button, fontSize)
button:SetText("Font: " .. tostring(fontSize))
ViragDevTool:UpdateMainTableUI()
end
local button = CreateFrame("Button", "VDTFrameColorReset", parent, "ViragDevToolButtonTemplate")
button:SetPoint(point, relativeTo, relativePoint, xOffset, yOffset)
button:SetPoint("TOP", parent, "TOP", -5, -5)
button:SetPoint("BOTTOM", parent, "BOTTOM", -5, 5)
updateFontSize(button, self.settings.fontSize)
button:SetScript("OnMouseUp", function(this, mouseButton, down)
if mouseButton == "RightButton" then
self.settings.fontSize = self.settings.fontSize - 1
elseif mouseButton == "LeftButton" then
self.settings.fontSize = self.settings.fontSize + 1
end
updateFontSize(this, self.settings.fontSize )
end)
end
function ViragDevTool:ShowColorPicker(color, changedCallback)
local r, g, b, a = unpack(ViragDevTool.colors[color])
ColorPickerFrame.func = function() end
ColorPickerFrame:SetColorRGB(r, g, b);
ColorPickerFrame.func = changedCallback
ColorPickerFrame.cancelFunc = function()
ColorPickerFrame:SetColorRGB(r, g, b);
changedCallback()
end
ColorPickerFrame:Hide(); -- Need to run the OnShow handler.
ColorPickerFrame:Show();
end