From ae839d0c9e19656a6b0407f5b19f816a132c92b8 Mon Sep 17 00:00:00 2001 From: prowley Date: Mon, 28 Sep 2020 19:08:20 -0700 Subject: [PATCH] Edge case Catch some edge cases where setting up the initial window with out of date window positioning settings would throw an error. Should be limited to intermediate dev builds, but doing a release anyway to be sure. --- SteaSummon.toc | 2 +- settings.lua | 10 +++++----- summon.lua | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/SteaSummon.toc b/SteaSummon.toc index 0578c35..3d28f4b 100755 --- a/SteaSummon.toc +++ b/SteaSummon.toc @@ -2,7 +2,7 @@ ## Title: SteaSummon ## Notes: Warlock Summoning ## Author: Stea -## Version: 0.47 +## Version: 0.48 ## SavedVariablesPerCharacter: SteaSummonSave, SteaDEBUG diff --git a/settings.lua b/settings.lua index 6a889e7..3633132 100644 --- a/settings.lua +++ b/settings.lua @@ -58,8 +58,8 @@ settings = { SteaSummonSave.buffs = true end - if SteaSummonSave.windowPos == nil then - SteaSummonSave.windowPos = {} + if SteaSummonSave.windowPos == nil or (type(SteaSummonSave.windowPos[2]) == "table" or not SteaSummonSave.windowPos["height"]) then + SteaSummonSave.windowPos = {"CENTER", nil, "CENTER", 0, 0, ["height"] = 300, ["width"] = 250} end end, @@ -81,7 +81,7 @@ settings = { SteaSummonSave.timeStamp = 0 SteaSummonSave.waitingKeepTime = 5 SteaSummonSave.buffs = true - SteaSummonSave.windowPos = {} + SteaSummonSave.windowPos = {"CENTER", nil, "CENTER", 0, 0, ["height"] = 300, ["width"] = 250} end, findSummonWord = function(self, phrase) @@ -143,11 +143,11 @@ settings = { end, getWindowPos = function(self) - return SteaSummonSave.winowPos + return SteaSummonSave.windowPos end, setWindowPos = function(self, pos) - SteaSummonSave.winowPos = pos + SteaSummonSave.windowPos = pos end, } diff --git a/summon.lua b/summon.lua index 681acf6..eaec576 100644 --- a/summon.lua +++ b/summon.lua @@ -291,9 +291,10 @@ local summon = { f:SetPoint("CENTER") f:SetSize(300, 250) f:SetScale(SteaSummonSave.windowSize) + local wpos = addonData.settings:getWindowPos() - if wpos and #wpos then - cprint("summon.display", wpos[1], wpos[2], wpos[3], wpos[4], wpos[5], "width:", wpos["width"], "height:", wpos["height"]) + if wpos and #wpos > 0 then + db("summon.display", wpos[1], wpos[2], wpos[3], wpos[4], wpos[5], "width:", wpos["width"], "height:", wpos["height"]) f:ClearAllPoints() f:SetPoint(wpos[1], wpos[2], wpos[3], wpos[4], wpos[5]) --f:SetPoint("TOPLEFT", UIParent, "TOPLEFT", wpos["left"], wpos["top"])