Auto-detect if in Cyrodiil and enable/disable accordingly
Sasky [06-07-14 - 21:47]
Auto-detect if in Cyrodiil and enable/disable accordingly
Save window position
Cleanup some debug output
diff --git a/CyrHUD.lua b/CyrHUD.lua
index 1ce94d8..08866cb 100644
--- a/CyrHUD.lua
+++ b/CyrHUD.lua
@@ -63,6 +63,12 @@ function CyrHUD.eventAttackChange(_, keepID, battlegroundContext, underAttack)
end
end
+function CyrHUD.saveWindowPosition( window )
+ _, _, _, _, x, y = window:GetAnchor()
+ CyrHUD.cfg.xoff = x
+ CyrHUD.cfg.yoff = y
+end
+
----------------------------------------------
-- Notification UI pool
@@ -167,7 +173,6 @@ end
CyrHUD.battles = {}
CyrHUD.add = function(keepID)
if CyrHUD.battles[keepID] == nil then
- d("Adding " .. GetKeepName(keepID))
CyrHUD.battles[keepID] = CyrHUD.Battle(keepID)
else
CyrHUD.battles[keepID]:restart()
@@ -192,7 +197,6 @@ CyrHUD.updateAll = function()
end
end
---TODO: Add outposts
CyrHUD.scanKeeps = function()
for i=3,20 do
CyrHUD.checkAdd(i)
@@ -206,12 +210,29 @@ end
------------------------------------------------------------------------
-- Initialization
------------------------------------------------------------------------
---TODO: Properly setup on Addon init or playerLoad
---TODO: only show while in Cyrodiil
-local function init()
+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)
+ 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_UI:SetHidden(false)
- d("Adding keep info")
+
+
+ --Get initial scan
+ CyrHUD.scanKeeps()
+
+ --Add events
EVENT_MANAGER:RegisterForUpdate("CyrHUDKeepCheck", 5000, function()
CyrHUD.scanKeeps()
CyrHUD.updateAll()
@@ -221,19 +242,36 @@ local function init()
CyrHUD.updateScore()
end)
EVENT_MANAGER:RegisterForEvent("CyrHUDAttackChange", EVENT_KEEP_UNDER_ATTACK_CHANGED, CyrHUD.eventAttackChange)
- showCyrHUD = true
+ CyrHUD.visible = true
+end
+
+function CyrHUD.deinit()
+ if WYK_QuestTracker_MQT then WYK_QuestTracker_MQT:SetAlpha(1) end
+ EVENT_MANAGER:UnregisterForUpdate("CyrHUDKeepCheck")
+ EVENT_MANAGER:UnregisterForUpdate("CyrHUDUIUpdate")
+ EVENT_MANAGER:UnregisterForUpdate("CyrHUDUpdateAPCount")
+ CyrHUD_UI:SetHidden(true)
+ CyrHUD.visible = false
end
-local showCyrHUD = false
+--TODO: Properly setup on Addon init or playerLoad
+--TODO: only show while in Cyrodiil
SLASH_COMMANDS["/cyrhud"] = function()
- if showCyrHUD then
- EVENT_MANAGER:UnregisterForUpdate("CyrHUDKeepCheck")
- EVENT_MANAGER:UnregisterForUpdate("CyrHUDUIUpdate")
- EVENT_MANAGER:UnregisterForUpdate("CyrHUDUpdateAPCount")
- if WYK_QuestTracker_MQT then WYK_QuestTracker_MQT:SetAlpha(1) end
- CyrHUD_UI:SetHidden(true)
- showCyrHUD = false
+ if CyrHUD.visible then
+ CyrHUD.deinit()
else
- init()
+ CyrHUD.init()
end
-end
\ No newline at end of file
+end
+
+function CyrHUD.playerInit()
+ if IsPlayerInAvAWorld() then
+ if not CyrHUD.visible then
+ CyrHUD.init()
+ end
+ elseif CyrHUD.visible then
+ CyrHUD.deinit()
+ end
+end
+
+EVENT_MANAGER:RegisterForEvent("CyrHUD-init", EVENT_PLAYER_ACTIVATED, CyrHUD.playerInit)
diff --git a/CyrHUD.txt b/CyrHUD.txt
index 56ccf1e..9da493b 100644
--- a/CyrHUD.txt
+++ b/CyrHUD.txt
@@ -2,6 +2,7 @@
## Title: CyrHUD
## Version: 0.9.3
## Author: Sasky
+## SavedVariables: CyrHUD_SavedVars
classes/Battle.lua
classes/Info.lua
diff --git a/CyrHUD.xml b/CyrHUD.xml
index c349cd2..5177562 100644
--- a/CyrHUD.xml
+++ b/CyrHUD.xml
@@ -2,11 +2,11 @@
<Controls>
<TopLevelControl name="CyrHUD_UI" mouseEnabled="true" movable="true" clampedToScreen="true" hidden="true" >
<Dimensions x="280" y="30" />
- <Anchor point="TOPRIGHT" offsetX="-10" offsetY="30" />
+ <Anchor point="TOPRIGHT" offsetX="-10" offsetY="60" />
- <!--<OnMoveStop>
- craftingXP.OnMoveStop( self )
- </OnMoveStop>-->
+ <OnMoveStop>
+ CyrHUD.saveWindowPosition( self )
+ </OnMoveStop>
<Controls>
<Label name="$(parent)_Time" font="ZoFontGameShadow" color="EEEEEE"
diff --git a/classes/Battle.lua b/classes/Battle.lua
index a170486..c0644eb 100644
--- a/classes/Battle.lua
+++ b/classes/Battle.lua
@@ -166,7 +166,6 @@ function CyrHUD.Battle:getIcon()
--Debug code
if CyrHUD.info[self.defender] == nil or CyrHUD.info[self.defender][self.keepType] == nil then
CyrHUD.error("Bad icon lookup. Defender: " .. self.defender .. " / KeepType: " .. self.keepType)
- d("|cFF0000Please file this bug info at esoui.com")
return CyrHUD.info.noIcon
end