From 674e0c047004a7f514ee4c991e09603bcee96432 Mon Sep 17 00:00:00 2001 From: Aleksi Blinnikka Date: Wed, 24 Jan 2018 18:09:27 +0200 Subject: [PATCH] Fix char-specific settings, add Gedren --- OmaRF/Events.lua | 8 +++++++- OmaRF/Indicators.lua | 9 +++++++-- OmaRF/RaidFrame.lua | 22 ++++++++++++++++++---- OmaRF/Settings.lua | 40 ++++++++++++++++++++++++++++++++++------ 4 files changed, 66 insertions(+), 13 deletions(-) diff --git a/OmaRF/Events.lua b/OmaRF/Events.lua index 4316a82..41fc221 100644 --- a/OmaRF/Events.lua +++ b/OmaRF/Events.lua @@ -19,12 +19,12 @@ local RAID_CLASS_COLORS = RAID_CLASS_COLORS; local checkIndicators = OmaRFIndicators.CheckIndicators; local Settings = OmaRFSettings; -local width = Settings.Character.Width; local baseColor = Settings.BaseColor; local overlayColorDispel = Settings.OverlayColorDispel; local overlayColorCharm = Settings.OverlayColorCharm; local overlayColorAlert = Settings.OverlayColorAlert; local powerColors = Settings.PowerColors; +local width = 10; local M = {}; OmaRFEvents = M; @@ -80,8 +80,10 @@ local function updateText(frame, unit) local healthLost = max - current; if UnitIsDeadOrGhost(unit) then frame.text:SetText("Dead"); + frame.text:Show(); elseif not UnitIsConnected(unit) then frame.text:SetText("DC"); + frame.text:Show(); elseif healthLost > 0 then if healthLost > 1200000000 then -- 1.2B frame.text:SetFormattedText("-%.1fB", healthLost / 1000000000); @@ -337,3 +339,7 @@ eventFuncs["GROUP_ROSTER_UPDATE"] = eventFuncs["UPDATE_ALL_BARS"]; function M.UnitEvent(self, event) eventFuncs[event](self); end + +function M.LoadChar() + width = Settings.Character.Width; +end diff --git a/OmaRF/Indicators.lua b/OmaRF/Indicators.lua index fbf9817..b3c7d07 100644 --- a/OmaRF/Indicators.lua +++ b/OmaRF/Indicators.lua @@ -7,9 +7,9 @@ local UnitIsDeadOrGhost, UnitIsConnected = UnitIsDeadOrGhost, UnitIsConnected; local CTimerAfter = C_Timer.After; local Settings = OmaRFSettings; -local positions = Settings.Positions; -local watchedAuras = Settings.Character["WatchedAuras"]; local majorAuras = Settings.MajorAuras; +local positions = {}; +local watchedAuras = {}; local updaters = {}; local updating = {}; @@ -122,3 +122,8 @@ function M.CheckIndicators(frame, unit) frame.major:Hide(); end end + +function M.LoadChar() + watchedAuras = Settings.Character["WatchedAuras"]; + positions = Settings.Character.Positions; +end diff --git a/OmaRF/RaidFrame.lua b/OmaRF/RaidFrame.lua index 31ef192..078280d 100644 --- a/OmaRF/RaidFrame.lua +++ b/OmaRF/RaidFrame.lua @@ -11,9 +11,6 @@ local registerEvents = OmaRFEvents.RegisterEvents; local unitEvent = OmaRFEvents.UnitEvent; local Settings = OmaRFSettings; -local positions = Settings.Positions; -local width, height = Settings.Character.Width, Settings.Character.Height; -local anchorX, anchorY = Settings.Character.AnchorX, Settings.Character.AnchorY; local indSize = Settings.IndSize; local baseColor = Settings.BaseColor; local bgColor = Settings.BgColor; @@ -22,7 +19,11 @@ local shieldColor = Settings.ShieldColor; local shieldhlColor = Settings.ShieldhlColor; local healpredColor = Settings.HealpredColor; local healabsorbColor = Settings.HealabsorbColor; -local attributes = Settings.Character.Clickheal; +-- placeholders with visible values when error happens +local positions = {}; +local width, height = 10, 10; +local anchorX, anchorY = 10, 10; +local attributes = {}; local CFrame = CreateFrame("Frame", "OmaRFFrame", UIParent); local inheritedFrames = "SecureUnitButtonTemplate,SecureHandlerStateTemplate"; @@ -289,9 +290,22 @@ local function initialize() initializeRaid(CFrame); end +local function loadCharSettings() + width, height = Settings.Character.Width, Settings.Character.Height; + anchorX, anchorY = Settings.Character.AnchorX, Settings.Character.AnchorY; + attributes = Settings.Character.Clickheal; + positions = Settings.Character.Positions; +end + +CFrame:RegisterEvent("ADDON_LOADED"); CFrame:RegisterEvent("PLAYER_LOGIN"); CFrame:SetScript("OnEvent", function(self, event) if event == "PLAYER_LOGIN" then initialize(); + elseif event == "ADDON_LOADED" then + OmaRFLoadChar(); + loadCharSettings(); + OmaRFEvents.LoadChar(); + OmaRFIndicators.LoadChar(); end end); diff --git a/OmaRF/Settings.lua b/OmaRF/Settings.lua index 997e4c7..de76ea7 100644 --- a/OmaRF/Settings.lua +++ b/OmaRF/Settings.lua @@ -9,6 +9,7 @@ local rawget = rawget; -- configurable settings -- character specific settings local charDefaults = { + Positions = {"TOPRIGHT", "BOTTOMLEFT"}, Width = 80, Height = 40, AnchorX = 0, @@ -21,6 +22,7 @@ local charDefaults = { local chars = { ["Stormreaver"] = { ["Vildan"] = { + Positions = {"TOPRIGHT", "BOTTOMLEFT"}, Width = 80, Height = 40, AnchorX = 0, @@ -50,12 +52,36 @@ local chars = { ["alt-shift-spell2"] = "Beacon of Faith", }, }, + ["Gedren"] = { + Positions = {"TOPLEFT", "TOPRIGHT", "BOTTOMLEFT"}, + Width = 80, + Height = 40, + AnchorX = 0, + AnchorY = -330, + WatchedAuras = { + ["Rejuvenation"] = "TOPRIGHT", + ["Lifebloom"] = "TOPLEFT", + }, + Clickheal = { + ["type1"] = "spell", + ["type2"] = "spell", + ["shift-type1"] = "spell", + ["shift-type2"] = "spell", + ["ctrl-type1"] = "spell", + ["alt-type2"] = "spell", + ["spell1"] = "Healing Touch", + ["spell2"] = "Swiftmend", + ["shift-spell1"] = "Regrowth", + ["shift-spell2"] = "Lifebloom", + ["ctrl-spell1"] = "Nature's Cure", + ["alt-spell2"] = "Rebirth", + }, + }, }, }; -- account-wide settings local settings = { - Positions = {"TOPRIGHT", "BOTTOMLEFT"}, IndSize = 14, BaseColor = {0, 0, 0}, BgColor = {0.7, 0.7, 0.7}, @@ -99,9 +125,11 @@ OmaRFSettings = settings; -- watch to not remove mana entry setmetatable(settings.PowerColors, {__index = function(t) return rawget(t, PowerTypeMana) end}); -local name, realm = UnitFullName("player"); -if chars[realm] and chars[realm][name] then - settings.Character = chars[realm][name]; -else - settings.Character = charDefaults; +function OmaRFLoadChar() + local name, realm = UnitFullName("player"); + if chars[realm] and chars[realm][name] then + settings.Character = chars[realm][name]; + else + settings.Character = charDefaults; + end end -- 2.39.5