introducing new config approach

This commit is contained in:
Eric Mauser
2016-06-26 18:34:08 +02:00
parent 39ee1ded73
commit 65f399747f
3 changed files with 56 additions and 49 deletions
+53
View File
@@ -0,0 +1,53 @@
pfUI_playerDB = {}
pfUI_config = {}
function pfUI:LoadConfig()
-- MODULE SUBGROUP ENTRY VALUE
pfUI:UpdateConfig("unitframes", nil, "animation_speed", "5")
pfUI:UpdateConfig("unitframes", nil, "portrait", "1")
pfUI:UpdateConfig("unitframes", nil, "buff_size", "22")
pfUI:UpdateConfig("unitframes", nil, "debuff_size", "22")
pfUI:UpdateConfig("unitframes", nil, "layout", "default")
pfUI:UpdateConfig("unitframes", "player", "width", "200")
pfUI:UpdateConfig("unitframes", "player", "height", "50")
pfUI:UpdateConfig("unitframes", "player", "pheight", "10")
pfUI:UpdateConfig("unitframes", "target", "width", "200")
pfUI:UpdateConfig("unitframes", "target", "height", "50")
pfUI:UpdateConfig("unitframes", "target", "pheight", "10")
pfUI:UpdateConfig("bars", nil, "icon_size", "22")
pfUI:UpdateConfig("bars", nil, "border", "2")
pfUI:UpdateConfig("panel", "left", "left", "guild")
pfUI:UpdateConfig("panel", "left", "center", "durability")
pfUI:UpdateConfig("panel", "left", "right", "friends")
pfUI:UpdateConfig("panel", "right", "left", "fps")
pfUI:UpdateConfig("panel", "right", "center", "time")
pfUI:UpdateConfig("panel", "right", "right", "gold")
pfUI:UpdateConfig("panel", "other", "minimap", "zone")
pfUI:UpdateConfig("tooltip", nil, "position", "bottom")
pfUI:UpdateConfig("position", nil, nil, nil)
end
function pfUI:UpdateConfig(group, subgroup, entry, value)
-- check for missing config groups
if not pfUI_config[group] then
pfUI_config[group] = {}
end
-- update config
if not subgroup and entry and value and not pfUI_config[group][entry] then
pfUI:Debug("Creating Config: " .. entry .. " with value " .. value)
pfUI_config[group][entry] = value
end
-- check for missing config subgroups
if subgroup and not pfUI_config[group][subgroup] then
pfUI:Debug("Creating Subgroup: " .. subgroup)
pfUI_config[group][subgroup] = {}
end
-- update config in subgroup
if subgroup and entry and value and not pfUI_config[group][subgroup][entry] then
pfUI:Debug("Creating Config in Subgroup (" .. subgroup .. "): " .. entry .. " with value " .. value)
pfUI_config[group][subgroup][entry] = value
end
end
+2 -49
View File
@@ -15,6 +15,7 @@ end
pfUI = CreateFrame("Frame",nil,UIParent)
pfUI:RegisterEvent("ADDON_LOADED")
pfUI:SetScript("OnEvent", function()
pfUI:LoadConfig()
if arg1 == "pfUI" then
pfUI:Debug("pfUI module loader:")
for i,m in pairs(this.modules) do
@@ -35,9 +36,7 @@ function pfUI:RegisterModule(n, f)
end
function pfUI:Debug(msg)
if pfUI_config.debug == 1 then
DEFAULT_CHAT_FRAME:AddMessage(msg)
end
-- DEFAULT_CHAT_FRAME:AddMessage(msg)
end
pfUI.backdrop = {
@@ -61,52 +60,6 @@ pfUI.backdrop_underline = {
insets = {left = 0, right = 0, top = 0, bottom = 0},
}
pfUI_playerDB = {}
pfUI_config = {
debug = 1,
["unitframes"] = {
animation_speed = 5,
portrait = 1,
buff_size = "22",
debuff_size = "22",
layout = "default",
["player"] = {
width = 200,
height = 50,
pheight = 10,
},
["target"] = {
width = 200,
height = 50,
pheight = 10,
},
},
["bars"] = {
icon_size = "22",
border = 2,
},
["panel"] = {
["left"] = {
left = "guild",
center = "durability",
right = "friends",
},
["right"] = {
left = "fps",
center = "time",
right = "gold",
},
["other"] = {
minimap = "zone",
},
},
["tooltip"] = {
position = "bottom"
},
["position"] = {
}
}
pfUI.utils = CreateFrame("Frame",nil,UIParent)
function pfUI.utils:loadPosition(frame)
+1
View File
@@ -12,6 +12,7 @@ env\colors.lua
env\locales.lua
env\functions.lua
modules\config.lua
modules\gui.lua
modules\actionbar.lua
modules\chat.lua