From 65f399747f9b9bf3a69e22c56e2018aaead78392 Mon Sep 17 00:00:00 2001 From: Eric Mauser Date: Sun, 26 Jun 2016 18:34:08 +0200 Subject: [PATCH] introducing new config approach --- modules/config.lua | 53 ++++++++++++++++++++++++++++++++++++++++++++++ pfUI.lua | 51 ++------------------------------------------ pfUI.toc | 1 + 3 files changed, 56 insertions(+), 49 deletions(-) create mode 100644 modules/config.lua diff --git a/modules/config.lua b/modules/config.lua new file mode 100644 index 00000000..ce5882d1 --- /dev/null +++ b/modules/config.lua @@ -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 \ No newline at end of file diff --git a/pfUI.lua b/pfUI.lua index 12e3da5a..5f1df17b 100644 --- a/pfUI.lua +++ b/pfUI.lua @@ -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) diff --git a/pfUI.toc b/pfUI.toc index 76f9ef13..7d4ac97a 100644 --- a/pfUI.toc +++ b/pfUI.toc @@ -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