Add save position

Scott Yeskie [07-02-16 - 22:52]
Add save position
Filename
RaidDPS.lua
RaidDPS.txt
diff --git a/RaidDPS.lua b/RaidDPS.lua
index 0a98f6f..5ddeb99 100644
--- a/RaidDPS.lua
+++ b/RaidDPS.lua
@@ -15,7 +15,6 @@
 -- You should have received a copy of the GNU General Public License
 -- along with this program.  If not, see <http://www.gnu.org/licenses/>.

--- TODO: Save window position
 -- TODO: Fix window display/hide
 -- TODO: Add icons
 -- TODO: Fix bosses removed > 0hp
@@ -207,6 +206,10 @@ function RaidDPS:OnPowerUpdate(unitTag, powerValue)
 end

 function RaidDPS:CreateUI()
+    --Load settings
+    self.cfg = ZO_SavedVars:NewAccountWide("RaidDPS_SavedVars", 1.0, "config", {})
+    local cfg = self.cfg
+
     local font = "EsoUI/Common/Fonts/univers67.otf|16|thin"

     local ui = self.ui
@@ -215,9 +218,8 @@ function RaidDPS:CreateUI()
     ui.main:SetMouseEnabled(true)
     ui.main:SetMovable(true)
     ui.main:SetClampedToScreen(true)
-    --self.ui:SetHandler("OnMoveStop", self.saveWindowPosition)
+    ui.main:SetHandler("OnMoveStop", function(window) self:SaveUIPosition(window) end)
     ui.main:ClearAnchors()
-    local cfg = self.cfg or {}

     ui.bg = WINDOW_MANAGER:CreateControl("RaidDPS_UI_bg", RaidDPS_UI, CT_BACKDROP)
     ui.bg:SetDimensions(280, 30)
@@ -266,10 +268,19 @@ function RaidDPS:CreateUI()
     ui.txtDps10:SetText("0")
     ui.txtTime:SetText("0:00")
     ui.txtTime10:SetText(":10")
-    ui.main:SetHidden(true)
+    --ui.main:SetHidden(true)
     ui.main:UnregisterForEvent(EVENT_PLAYER_ACTIVATED)
 end

+function RaidDPS:SaveUIPosition( window )
+    local _, sP, _, aP, x, y = window:GetAnchor()
+    local cfg = self.cfg
+    cfg.anchPoint = aP
+    cfg.selfPoint = sP
+    cfg.xoff = x
+    cfg.yoff = y
+end
+
 function RaidDPS:UpdateUI()
     if not self.inFight then
         return
diff --git a/RaidDPS.txt b/RaidDPS.txt
index 7740d23..de0db95 100644
--- a/RaidDPS.txt
+++ b/RaidDPS.txt
@@ -2,6 +2,6 @@
 ## Title: Raid DPS
 ## Version: 0.9
 ## Author: Sasky
-## SavedVariables: RaidDPS
+## SavedVariables: RaidDPS_SavedVars

 RaidDPS.lua