Skip to content

Commit

Permalink
toc and formatting updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuller committed Jul 18, 2020
1 parent 34f5f9e commit 28dcbbd
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 177 deletions.
2 changes: 1 addition & 1 deletion tullaRange_Config/tullaRange_Config.toc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Interface: 80300
#@end-retail@
#@non-retail@
# ## Interface: 11304
# ## Interface: 11305
#@end-non-retail@
## Title: tullaRange Config
## Notes: GUI based configuration for tullaRange
Expand Down
31 changes: 15 additions & 16 deletions tullaRange_Config/widgets/classy.lua
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
--[[
misc things I need to get my widget framework workingish
--]]
-- misc things I need to get my widget framework workingish

local _, Addon = ...

Addon.Classy = {
New = function(self, frameType, parentClass)
local class = CreateFrame(frameType)
class.mt = {__index = class}
New = function(_, frameType, parentClass)
local class = CreateFrame(frameType)

if parentClass then
class = setmetatable(class, {__index = parentClass})
class.super = parentClass
end
class.mt = {__index = class}

class.Bind = function(c, obj)
return setmetatable(obj, c.mt)
end
if parentClass then
class = setmetatable(class, {__index = parentClass})
class.super = parentClass
end

return class
end
}
class.Bind = function(c, obj)
return setmetatable(obj, c.mt)
end

return class
end
}
139 changes: 68 additions & 71 deletions tullaRange_Config/widgets/colorSelector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,98 +2,95 @@
colorSelector.lua
A bagnon color selector
--]]

local _, Addon = ...
local L = Addon.L
local tullaRange = _G.tullaRange
local ColorSelector = Addon.Classy:New('Frame'); Addon.ColorSelector = ColorSelector
local ColorSelector = Addon.Classy:New('Frame')
Addon.ColorSelector = ColorSelector

local backdrop = {
bgFile = [[Interface\ChatFrame\ChatFrameBackground]],
edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
edgeSize = 16,
tile = true, tileSize = 16,
insets = {left = 4, right = 4, top = 4, bottom = 4}
bgFile = [[Interface\ChatFrame\ChatFrameBackground]],
edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
edgeSize = 16,
tile = true,
tileSize = 16,
insets = {left = 4, right = 4, top = 4, bottom = 4}
}

local ColorSliders = { 'Red', 'Green', 'Blue' }

local ColorSliders = {'Red', 'Green', 'Blue'}

function ColorSelector:New(colorState, parent)
local f = self:Bind(CreateFrame('Frame', parent:GetName() .. '_' .. colorState, parent))

f:SetBackdrop(backdrop)
f:SetBackdropBorderColor(0.4, 0.4, 0.4)
f:SetBackdropColor(0, 0, 0, 0.3)
local f = self:Bind(CreateFrame('Frame', parent:GetName() .. '_' .. colorState, parent))

local t = f:CreateFontString(nil, 'BACKGROUND', 'GameFontHighlightLarge')
t:SetPoint('BOTTOMLEFT', f, 'TOPLEFT', 4, 2)
t:SetText(L[colorState])
f.text = t
f:SetBackdrop(backdrop)
f:SetBackdropBorderColor(0.4, 0.4, 0.4)
f:SetBackdropColor(0, 0, 0, 0.3)

local preview = f:CreateTexture(nil, 'ARTWORK')
preview:SetPoint('RIGHT', -16, 0)
preview:SetSize(96, 96)
f.preview = preview
local t = f:CreateFontString(nil, 'BACKGROUND', 'GameFontHighlightLarge')
t:SetPoint('BOTTOMLEFT', f, 'TOPLEFT', 4, 2)
t:SetText(L[colorState])
f.text = t

-- color sliders
local sliders = {}
for colorIndex, colorName in ipairs(ColorSliders) do
local slider = Addon.Slider:New(L[colorName], f, 0, 100, 1)
local preview = f:CreateTexture(nil, 'ARTWORK')
preview:SetPoint('RIGHT', -16, 0)
preview:SetSize(96, 96)
f.preview = preview

slider.SetSavedValue = function(_, value)
tullaRange.sets[colorState][colorIndex] = math.floor(value + 0.5) / 100
tullaRange:ForceColorUpdate()
-- color sliders
local sliders = {}
for colorIndex, colorName in ipairs(ColorSliders) do
local slider = Addon.Slider:New(L[colorName], f, 0, 100, 1)

preview:SetVertexColor(tullaRange:GetColor(colorState))
end
slider.SetSavedValue = function(_, value)
tullaRange.sets[colorState][colorIndex] = math.floor(value + 0.5) / 100
tullaRange:UpdateButtonStates(true)

slider.GetSavedValue = function()
return tullaRange.sets[colorState][colorIndex] * 100
end
preview:SetVertexColor(tullaRange:GetColor(colorState))
end

if colorIndex > 1 then
slider:SetPoint('TOPLEFT', sliders[colorIndex - 1], 'BOTTOMLEFT', 0, -24)
else
slider:SetPoint('BOTTOMLEFT', t, 'BOTTOMLEFT', 8, -40)
end
slider.GetSavedValue = function()
return tullaRange.sets[colorState][colorIndex] * 100
end

table.insert(sliders, slider)
end
if colorIndex > 1 then
slider:SetPoint('TOPLEFT', sliders[colorIndex - 1], 'BOTTOMLEFT', 0, -24)
else
slider:SetPoint('BOTTOMLEFT', t, 'BOTTOMLEFT', 8, -40)
end

table.insert(sliders, slider)
end

f.sliders = sliders

f.sliders = sliders

return f
return f
end

do
local spellIcons = {}

-- generate spell icons
do
for i = 1, GetNumSpellTabs() do
local offset, numSpells = select(3, GetSpellTabInfo(i))
local tabEnd = offset + numSpells

for j = offset, tabEnd - 1 do
local texture = GetSpellBookItemTexture(j, 'player')
if texture then
table.insert(spellIcons, texture)
end
end
end
end

function ColorSelector:UpdateValues()

local texture = spellIcons[math.random(1, #spellIcons)]

self.preview:SetTexture(texture)

for _, slider in pairs(self.sliders) do
slider:UpdateValue()
end
end
local spellIcons = {}

-- generate spell icons
do
for i = 1, GetNumSpellTabs() do
local offset, numSpells = select(3, GetSpellTabInfo(i))
local tabEnd = offset + numSpells

for j = offset, tabEnd - 1 do
local texture = GetSpellBookItemTexture(j, 'player')
if texture then
table.insert(spellIcons, texture)
end
end
end
end

function ColorSelector:UpdateValues()
local texture = spellIcons[math.random(1, #spellIcons)]

self.preview:SetTexture(texture)

for _, slider in pairs(self.sliders) do
slider:UpdateValue()
end
end
end
43 changes: 21 additions & 22 deletions tullaRange_Config/widgets/optionsPanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,34 @@
optionsPanel.lua
A bagnon options panel
--]]

local _, Addon = ...
local OptionsPanel = Addon.Classy:New('Frame')

function OptionsPanel:New(name, parent, title, subtitle, icon)
local f = self:Bind(CreateFrame('Frame', name))
f.name = title
f.parent = parent
local f = self:Bind(CreateFrame('Frame', name))
f.name = title
f.parent = parent

local text = f:CreateFontString(nil, 'ARTWORK', 'GameFontNormalLarge')
text:SetPoint('TOPLEFT', 16, -16)
if icon then
text:SetFormattedText('|T%s:%d|t %s', icon, 32, title)
else
text:SetText(title)
end
local text = f:CreateFontString(nil, 'ARTWORK', 'GameFontNormalLarge')
text:SetPoint('TOPLEFT', 16, -16)
if icon then
text:SetFormattedText('|T%s:%d|t %s', icon, 32, title)
else
text:SetText(title)
end

local subtext = f:CreateFontString(nil, 'ARTWORK', 'GameFontHighlightSmall')
subtext:SetHeight(32)
subtext:SetPoint('TOPLEFT', text, 'BOTTOMLEFT', 0, -8)
subtext:SetPoint('RIGHT', f, -32, 0)
subtext:SetNonSpaceWrap(true)
subtext:SetJustifyH('LEFT')
subtext:SetJustifyV('TOP')
subtext:SetText(subtitle)
local subtext = f:CreateFontString(nil, 'ARTWORK', 'GameFontHighlightSmall')
subtext:SetHeight(32)
subtext:SetPoint('TOPLEFT', text, 'BOTTOMLEFT', 0, -8)
subtext:SetPoint('RIGHT', f, -32, 0)
subtext:SetNonSpaceWrap(true)
subtext:SetJustifyH('LEFT')
subtext:SetJustifyV('TOP')
subtext:SetText(subtitle)

InterfaceOptions_AddCategory(f)
InterfaceOptions_AddCategory(f)

return f
return f
end

Addon.OptionsPanel = OptionsPanel
Addon.OptionsPanel = OptionsPanel
Loading

0 comments on commit 28dcbbd

Please sign in to comment.