Position save fix, option to hide default quest tracker

Sasky [03-31-15 - 02:41]
Position save fix, option to hide default quest tracker

Consequence of fix is that positions in the lower half of the screen will use one of the
bottom points to anchor. This means it will grow upwards from the anchor position
instead of the default downwards.

TODO: Add re-anchor after move and option to grow up or down.
Filename
CyrHUD.lua
CyrHUD.txt
menu.lua
diff --git a/CyrHUD.lua b/CyrHUD.lua
index 98f8676..3ab7482 100644
--- a/CyrHUD.lua
+++ b/CyrHUD.lua
@@ -63,8 +63,9 @@ function CyrHUD.eventAttackChange(_, keepID, battlegroundContext, underAttack)
 end

 function CyrHUD.saveWindowPosition( window )
-    local _, _, _, aP, x, y = window:GetAnchor()
+    local _, sP, _, aP, x, y = window:GetAnchor()
     CyrHUD.cfg.anchPoint = aP
+    CyrHUD.cfg.selfPoint = sP
     CyrHUD.cfg.xoff = x
     CyrHUD.cfg.yoff = y
 end
@@ -168,10 +169,6 @@ end
 ------------------------------------------------------------------------
 CyrHUD.visible = false
 function CyrHUD:init()
-    local _, pt, relTo, relPt = CyrHUD_UI:GetAnchor()
-    self.ui:ClearAnchors()
-    self.ui:SetAnchor(pt, relTo, CyrHUD.cfg.anchPoint or relPt, CyrHUD.cfg.xoff, CyrHUD.cfg.yoff)
-
     --Init UI
     self:disableQuestTrackers()
     self.ui:SetHidden(false)
@@ -225,16 +222,22 @@ function CyrHUD:disableQuestTrackers()
     self.trackers = {}
     if self.cfg.trackerDisable then
         if WYK_QuestTracker_MQT then
-            self.trackers.WYK_QuestTracker_MQT = WYK_QuestTracker_MQT:GetAlpha()
-            WYK_QuestTracker_MQT:SetAlpha(0)
+            self.trackers.WYK_QuestTracker_MQT = WYK_QuestTracker_MQT:IsHidden()
+            WYK_QuestTracker_MQT:SetHidden(true)
         end
     end
+    if self.cfg.zosTrackerDisable then
+        self.trackers.ZO_QuestTracker = ZO_QuestTracker:IsHidden()
+        self.trackers.ZO_FocusedQuestTrackerPanel = ZO_FocusedQuestTrackerPanel:IsHidden()
+        ZO_FocusedQuestTrackerPanel:SetHidden(true)
+        ZO_QuestTracker:SetHidden(true)
+    end
 end

 function CyrHUD:reEnableQuestTrackers()
     if self.trackers then
         for k,v in pairs(self.trackers) do
-            if _G[k] then _G[k]:SetAlpha(v) end
+            if _G[k] ~= nil then _G[k]:SetHidden(v) end
         end
     end
 end
@@ -266,6 +269,16 @@ SLASH_COMMANDS["/cyrhud"] = CyrHUD.toggle
 --Called once. Handles controls, etc.
 function CyrHUD.addonInit()
     local self = CyrHUD
+
+    --Init saved variables
+    local def = {
+        xoff = -10,
+        yoff = 60,
+        trackerDisable = false,
+        showPopBars = false,
+    }
+    self.cfg = ZO_SavedVars:NewAccountWide("CyrHUD_SavedVars", 1.0, "config", def)
+
     --Create UI
     self.ui = WINDOW_MANAGER:CreateTopLevelWindow("CyrHUD_UI")
     self.ui:SetWidth(280)
@@ -273,21 +286,18 @@ function CyrHUD.addonInit()
     self.ui:SetMovable(true)
     self.ui:SetClampedToScreen(true)
     self.ui:SetHandler("OnMoveStop", self.saveWindowPosition)
+    local _, pt, relTo, relPt = CyrHUD_UI:GetAnchor()
+    self.ui:ClearAnchors()
+    self.ui:SetAnchor(CyrHUD.cfg.selfPoint or TOPLEFT,
+        GuiRoot, CyrHUD.cfg.anchPoint or TOPRIGHT,
+        CyrHUD.cfg.xoff, CyrHUD.cfg.yoff)
+
     --Create settings menu
     local LAM = LibStub("LibAddonMenu-2.0")
     LAM:RegisterAddonPanel("CyrHUD-LAM", self.menuPanel)
     LAM:RegisterOptionControls("CyrHUD-LAM", self.menuOptions)
     self.initLAM = true

-    --Init saved variables
-    local def = {
-        xoff = -10,
-        yoff = 60,
-        trackerDisable = false,
-        showPopBars = false,
-    }
-    self.cfg = ZO_SavedVars:NewAccountWide("CyrHUD_SavedVars", 1.0, "config", def)
-
     if (GetDate() % 1000)== 401 then
         --NOTE: If you see this before 4/1, please don't share
         table.insert(self.menuOptions,{
diff --git a/CyrHUD.txt b/CyrHUD.txt
index 2b261ba..f99761c 100644
--- a/CyrHUD.txt
+++ b/CyrHUD.txt
@@ -1,6 +1,6 @@
 ## APIVersion: 100011
 ## Title: CyrHUD
-## Version: 1.2.2
+## Version: 1.2.3
 ## Author: Sasky
 ## SavedVariables: CyrHUD_SavedVars
 ## OptionalDependsOn: LibAddonMenu-2.0
diff --git a/menu.lua b/menu.lua
index 2bb776a..1507b99 100644
--- a/menu.lua
+++ b/menu.lua
@@ -28,14 +28,17 @@ local c1 = "|cC5C29E" -- ZOS standard text color
 CyrHUD.menuOptions = {
     {
         type = "checkbox",
-        name = "Auto-hide Quest Tracker",
+        name = "Auto-hide Default Quest Tracker",
         tooltip = "Hides quest trackers when CyrHUD is shown",
-        getFunc = function() return CyrHUD.cfg.trackerDisable or false end,
-        setFunc = function(v) CyrHUD.cfg.trackerDisable = v end
+        getFunc = function() return CyrHUD.cfg.zosTrackerDisable or false end,
+        setFunc = function(v) CyrHUD.cfg.zosTrackerDisable = v end
     },
     {
-        type = "description",
-        text = c1 .. "Currently only works for Wykkyd's MQT"
+        type = "checkbox",
+        name = "Auto-hide Wykkyd's Quest Tracker",
+        tooltip = "Hides quest trackers when CyrHUD is shown",
+        getFunc = function() return CyrHUD.cfg.trackerDisable or false end,
+        setFunc = function(v) CyrHUD.cfg.trackerDisable = v end
     },
     {
         type = "checkbox",