Add keybind, tracker auto-toggle, and API bump for ESO1.6

Sasky [03-15-15 - 05:13]
Add keybind, tracker auto-toggle, and API bump for  ESO1.6
Filename
CyrHUD.lua
CyrHUD.txt
bindings.xml
menu.lua
diff --git a/CyrHUD.lua b/CyrHUD.lua
index 9ed5979..5696bad 100644
--- a/CyrHUD.lua
+++ b/CyrHUD.lua
@@ -15,10 +15,7 @@
 -- You should have received a copy of the GNU General Public License
 -- along with this program.  If not, see <http://www.gnu.org/licenses/>.

-if CyrHUD == nil then
-    --noinspection GlobalCreationOutsideO
-    CyrHUD = {}
-end
+CyrHUD = CyrHUD or {}

 ----------------------------------------------
 -- Utility
@@ -227,21 +224,13 @@ end
 -- Initialization
 ------------------------------------------------------------------------
 CyrHUD.visible = false
-function CyrHUD.init()
-    --TODO: Add default quest tracker, other major quest trackers
-    --TODO: Make this an option in menu and not default behavior
-    --Init saved variables
-    local def = {
-        xoff = -10,
-        yoff = 60
-    }
-    CyrHUD.cfg = ZO_SavedVars:NewAccountWide("CyrHUD_SavedVars", 1.0, "config", def)
+function CyrHUD:init()
     local _, pt, relTo, relPt = CyrHUD_UI:GetAnchor()
     CyrHUD_UI:ClearAnchors()
     CyrHUD_UI:SetAnchor(pt, relTo, relPt, CyrHUD.cfg.xoff, CyrHUD.cfg.yoff)

     --Init UI
-    --if WYK_QuestTracker_MQT then WYK_QuestTracker_MQT:SetAlpha(0) end
+    CyrHUD:disableQuestTrackers()
     CyrHUD_UI:SetHidden(false)


@@ -266,8 +255,26 @@ function CyrHUD.init()
     EVENT_MANAGER:RegisterForEvent('CyrHUD', EVENT_ACTION_LAYER_PUSHED, CyrHUD.actionLayerChange)
 end

-function CyrHUD.deinit()
-    --if WYK_QuestTracker_MQT then WYK_QuestTracker_MQT:SetAlpha(1) end
+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)
+        end
+    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
+        end
+    end
+end
+
+function CyrHUD:deinit()
+    CyrHUD:reEnableQuestTrackers()
     EVENT_MANAGER:UnregisterForUpdate("CyrHUDKeepCheck")
     EVENT_MANAGER:UnregisterForUpdate("CyrHUDUIUpdate")
     EVENT_MANAGER:UnregisterForUpdate("CyrHUDUpdateAPCount")
@@ -277,15 +284,17 @@ function CyrHUD.deinit()
     CyrHUD.visible = false
 end

---TODO: Properly setup on Addon init or playerLoad
---TODO: only show while in Cyrodiil
-SLASH_COMMANDS["/cyrhud"] = function()
+
+function CyrHUD.toggle()
     if CyrHUD.visible then
         CyrHUD.deinit()
     else
         CyrHUD.init()
     end
 end
+--TODO: Properly setup on Addon init or playerLoad
+--TODO: only show while in Cyrodiil?
+SLASH_COMMANDS["/cyrhud"] = CyrHUD.toggle

 function CyrHUD.playerInit()
     if IsPlayerInAvAWorld() then
@@ -295,6 +304,21 @@ function CyrHUD.playerInit()
     elseif CyrHUD.visible then
         CyrHUD.deinit()
     end
+
+    if not CyrHUD.initLAM then
+        local LAM = LibStub("LibAddonMenu-2.0")
+        LAM:RegisterAddonPanel("CyrHUD-LAM", CyrHUD.menuPanel)
+        LAM:RegisterOptionControls("CyrHUD-LAM", CyrHUD.menuOptions)
+        CyrHUD.initLAM = true
+
+        --Init saved variables
+        local def = {
+            xoff = -10,
+            yoff = 60,
+            trackerDisable = false,
+        }
+        CyrHUD.cfg = ZO_SavedVars:NewAccountWide("CyrHUD_SavedVars", 1.0, "config", def)
+    end
 end

 EVENT_MANAGER:RegisterForEvent("CyrHUD-init", EVENT_PLAYER_ACTIVATED, CyrHUD.playerInit)
diff --git a/CyrHUD.txt b/CyrHUD.txt
index d76ecf0..6eb604d 100644
--- a/CyrHUD.txt
+++ b/CyrHUD.txt
@@ -1,6 +1,6 @@
-## APIVersion: 100009
+## APIVersion: 100011
 ## Title: CyrHUD
-## Version: 1.0.4
+## Version: 1.1.1
 ## Author: Sasky
 ## SavedVariables: CyrHUD_SavedVars
 ## OptionalDependsOn: LibAddonMenu-2.0
@@ -24,4 +24,6 @@ classes/Battle.lua
 classes/Info.lua

 CyrHUD.lua
-CyrHUD.xml
\ No newline at end of file
+menu.lua
+bindings.xml
+CyrHUD.xml
diff --git a/bindings.xml b/bindings.xml
new file mode 100644
index 0000000..7f0655a
--- /dev/null
+++ b/bindings.xml
@@ -0,0 +1,9 @@
+<Bindings>
+    <Layer name="SI_KEYBINDINGS_LAYER_GENERAL">
+        <Category name="CyrHUD">
+            <Action name="CYRHUD_TOGGLE">
+                <Down>CyrHUD.toggle()</Down>
+            </Action>
+        </Category>
+    </Layer>
+</Bindings>
diff --git a/menu.lua b/menu.lua
new file mode 100644
index 0000000..db2ba49
--- /dev/null
+++ b/menu.lua
@@ -0,0 +1,49 @@
+-- This file is part of CyrHUD
+--
+-- (C) 2015 Scott Yeskie (Sasky)
+--
+-- This p.rogram is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 2 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+CyrHUD = CyrHUD or {}
+CyrHUD.menuPanel = {
+    type = "panel",
+    name = "CyrHUD",
+    author = "Sasky",
+    version = "1.1.0",
+}
+
+local c1 = "|cC5C29E" -- ZOS standard text color
+
+CyrHUD.menuOptions = {
+    [1] = {
+        type = "checkbox",
+        name = "Auto-hide 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
+    },
+    [2] = {
+        type = "description",
+        text = c1 .. "Currently only works for Wykkyd's MQT"
+    },
+    [3] = {
+        type = "description",
+        title = "Keybind",
+        text = c1 .. "See the controls game menu for setting a keybind for the |cFFFFFF/cyrhud" .. c1 .. " command.\n"
+            .."This toggles the addon on or off."
+    }
+}
+
+--TODO: Move this and other strings to proper translator format
+ZO_CreateStringId("SI_BINDING_NAME_CYRHUD_TOGGLE", "Enable/disable CyrHUD")
\ No newline at end of file