Skip to content

Commit

Permalink
Switch to LibDDI-1.0
Browse files Browse the repository at this point in the history
AceGUI-3.0-SharedMediaWidgets locks the client for several seconds
while building the dropdown for some reason.
  • Loading branch information
nebularg committed Jul 21, 2018
1 parent 03d1834 commit 32ceea8
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .pkgmeta
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ externals:
Libs/AceLocale-3.0: https://repos.wowace.com/wow/ace3/trunk/AceLocale-3.0
Libs/AceTimer-3.0: https://repos.wowace.com/wow/ace3/trunk/AceTimer-3.0
Libs/LibSharedMedia-3.0: https://repos.wowace.com/wow/libsharedmedia-3-0/trunk/LibSharedMedia-3.0
Libs/AceGUI-3.0-SharedMediaWidgets: https://repos.wowace.com/wow/ace-gui-3-0-shared-media-widgets/trunk/AceGUI-3.0-SharedMediaWidgets
Libs/LibDDI-1.0: https://repos.wowace.com/wow/libddi-1-0/trunk
Libs/LibSink-2.0: https://repos.wowace.com/wow/libsink-2-0/trunk/LibSink-2.0
Libs/LibDualSpec-1.0: https://repos.wowace.com/wow/libdualspec-1-0

Expand Down
48 changes: 25 additions & 23 deletions Code/CombatEvents.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local Parrot = ns.addon
local module = Parrot:NewModule("CombatEvents", "AceEvent-3.0", "AceTimer-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("Parrot_CombatEvents")

local SharedMedia = LibStub("LibSharedMedia-3.0")
local LibSharedMedia = LibStub("LibSharedMedia-3.0")

local tinsert, tremove, tconcat, tsort = table.insert, table.remove, table.concat, table.sort
local newList, del, newDict = Parrot.newList, Parrot.del, Parrot.newDict
Expand Down Expand Up @@ -340,14 +340,6 @@ local function createOption() end
local function createThrottleOption() end
local function createFilterOption() end

local function getSoundChoices()
local t = {}
for _,v in ipairs(SharedMedia:List("sound")) do
t[v] = v
end
return t
end

local function setOption(info, value)
local name = info[#info]
debug("Parrot.db: set option ", name, " = ", value)
Expand Down Expand Up @@ -825,17 +817,19 @@ function module:OnOptionsCreate()
local category, name = getArgs(info)
local font = db[category][name].font
if font == nil then
return "1"
else
return font
return -1
end
for i, v in next, Parrot.fontValues do
if v == font then return i end
end
end
local function setFontFace(info, value)
local category, name = getArgs(info)
if value == "1" then
value = nil
if value == -1 then
db[category][name].font = nil
else
db[category][name].font = Parrot.fontValues[value]
end
db[category][name].font = value
end
local function getFontSize(info)
local category, name = getArgs(info)
Expand Down Expand Up @@ -920,15 +914,21 @@ function module:OnOptionsCreate()
end
local function getSound(info)
local category, name = getArgs(info)
return db[category][name].sound or "None"
local value = db[category][name].sound or "None"
for i, v in next, Parrot.soundValues do
if v == value then
return i
end
end
end
local function setSound(info, value)
local category, name = getArgs(info)
PlaySoundFile(SharedMedia:Fetch('sound', value), "MASTER")
if value == "None" then
value = nil
local v = Parrot.soundValues[value]
PlaySoundFile(LibSharedMedia:Fetch("sound", v), "Master")
if v == "None" then
v = nil
end
db[category][name].sound = value
db[category][name].sound = v
end

local function getCommonEnabled(info)
Expand Down Expand Up @@ -1082,11 +1082,12 @@ function module:OnOptionsCreate()
},
sound = {
type = 'select',
values = getSoundChoices,
name = L["Sound"],
desc = L["What sound to play when the current event occurs."],
values = Parrot.soundValues,
get = getSound,
set = setSound,
itemControl = "DDI-Sound",
},
sticky = {
name = L["Sticky"],
Expand All @@ -1105,9 +1106,10 @@ function module:OnOptionsCreate()
type = 'select',
name = L["Font face"],
desc = L["Font face"],
values = Parrot.fontValues,
values = Parrot.fontWithInheritValues,
get = getFontFace,
set = setFontFace,
itemControl = "DDI-Font",
order = 1,
},
fontSizeInherit = {
Expand Down Expand Up @@ -2162,7 +2164,7 @@ local function runEvent(category, name, info)
end
Parrot:ShowMessage(text, cdb.scrollArea or category, sticky, r, g, b, cdb.font, cdb.fontSize, cdb.fontOutline, icon)
if cdb.sound then
PlaySoundFile(SharedMedia:Fetch('sound', cdb.sound), "MASTER")
PlaySoundFile(LibSharedMedia:Fetch('sound', cdb.sound), "Master")
end
end

Expand Down
38 changes: 26 additions & 12 deletions Code/Display.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ local Parrot_AnimationStyles
local Parrot_Suppressions
local Parrot_ScrollAreas

local SharedMedia = LibStub("LibSharedMedia-3.0")
local DEFAULT_FONT_NAME = SharedMedia:GetDefault("font")
local LibSharedMedia = LibStub("LibSharedMedia-3.0")
local DEFAULT_FONT_NAME = LibSharedMedia:GetDefault("font")

local newList, del = Parrot.newList, Parrot.del

Expand Down Expand Up @@ -60,12 +60,22 @@ local function getOption(info)
return db[name]
end

local function getFontChoices()
local result = {}
for _,v in ipairs(SharedMedia:List("font")) do
result[v] = v
local function getFontFace(info)
local font = db[info[#info]]
if font == nil then
return -1
end
for i, v in next, Parrot.fontValues do
if v == font then return i end
end
return font
end
local function setFontFace(info, value)
if value == -1 then
db[info[#info]] = nil
else
db[info[#info]] = Parrot.fontValues[value]
end
return result
end

function module:OnOptionsCreate()
Expand Down Expand Up @@ -114,9 +124,11 @@ function module:OnOptionsCreate()
args = {
font = {
type = "select",
control = "LSM30_Font",
name = L["Normal font face"],
values = getFontChoices(),
values = Parrot.fontValues,
get = getFontFace,
set = setFontFace,
itemControl = "DDI-Font",
},
fontSize = {
type = "range",
Expand All @@ -136,9 +148,11 @@ function module:OnOptionsCreate()
},
stickyFont = {
type = "select",
control = "LSM30_Font",
name = L["Sticky font face"],
values = getFontChoices(),
values = Parrot.fontValues,
get = getFontFace,
set = setFontFace,
itemControl = "DDI-Font",
},
stickyFontSize = {
type = "range",
Expand Down Expand Up @@ -255,7 +269,7 @@ function module:ShowMessage(text, area, sticky, r, g, b, font, fontSize, outline
fontString_num = fontString_num + 1
fs = frame:CreateFontString("ParrotFrameFontString" .. fontString_num, "ARTWORK", "SystemFont_Shadow_Small")
end
fs:SetFont(SharedMedia:Fetch("font", font), fontSize, outline)
fs:SetFont(LibSharedMedia:Fetch("font", font), fontSize, outline)
if shadow then
fs:SetShadowColor(0, 0, 0, 1)
else
Expand Down
21 changes: 21 additions & 0 deletions Code/Parrot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,27 @@ do
end

-- Config
do
local LibSharedMedia = LibStub("LibSharedMedia-3.0")

Parrot.soundValues = LibSharedMedia:List("sound")
Parrot.fontValues = LibSharedMedia:List("font")
Parrot.fontWithInheritValues = {}

local function rebuild(_, mediatype)
if mediatype == "font" then
wipe(Parrot.fontWithInheritValues)
for i, v in next, Parrot.fontValues do
Parrot.fontWithInheritValues[i] = v
end
Parrot.fontWithInheritValues[-1] = L["Inherit"]
end
end
rebuild(nil, "font")

LibSharedMedia.RegisterCallback(Parrot, "LibSharedMedia_Registered", rebuild)
end

function Parrot:ShowConfig()
if self.OnOptionsCreate then
self:OnOptionsCreate()
Expand Down
33 changes: 12 additions & 21 deletions Code/ScrollAreas.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,6 @@ local L = LibStub("AceLocale-3.0"):GetLocale("Parrot_ScrollAreas")

local Parrot_AnimationStyles = Parrot:GetModule("AnimationStyles")

do
local SharedMedia = LibStub("LibSharedMedia-3.0")
local values = {}
function Parrot.fontValues()
wipe(values)
for _, font in ipairs(SharedMedia:List("font")) do
values[font] = font
end
values["1"] = L["Inherit"]
return values
end
end

local db = nil
local defaults = {
profile = {
Expand Down Expand Up @@ -351,17 +338,19 @@ function module:OnOptionsCreate()
local kind, k = info.arg[1], info.arg[2]
local font = scrollAreas[k][kind == "normal" and "font" or "stickyFont"]
if font == nil then
return "1"
else
return font
return -1
end
for i, v in next, Parrot.fontValues do
if v == font then return i end
end
end
local function setFontFace(info, value)
local kind, k = info.arg[1], info.arg[2]
if value == "1" then
value = nil
if value == -1 then
scrollAreas[k][kind == "normal" and "font" or "stickyFont"] = nil
else
scrollAreas[k][kind == "normal" and "font" or "stickyFont"] = Parrot.fontValues[value]
end
scrollAreas[k][kind == "normal" and "font" or "stickyFont"] = value
if not configMode then
test(kind, k)
end
Expand Down Expand Up @@ -774,9 +763,10 @@ function module:OnOptionsCreate()
fontface = {
type = 'select',
name = L["Normal font face"],
values = Parrot.fontValues,
values = Parrot.fontWithInheritValues,
get = getFontFace,
set = setFontFace,
itemControl = "DDI-Font",
arg = {"normal", k},
order = 1,
},
Expand Down Expand Up @@ -826,9 +816,10 @@ function module:OnOptionsCreate()
stickyfontface = {
type = 'select',
name = L["Sticky font face"],
values = Parrot.fontValues,
values = Parrot.fontWithInheritValues,
get = getFontFace,
set = setFontFace,
itemControl = "DDI-Font",
arg = {"sticky", k},
order = 7,
},
Expand Down
Loading

0 comments on commit 32ceea8

Please sign in to comment.