Version 1.3.1 (09-01-2018)

Jarth [01-09-18 - 18:53]
Version 1.3.1 (09-01-2018)
Filename
Changelog
SummonAssistant.lua
SummonAssistant.txt
diff --git a/Changelog b/Changelog
index 2f3b581..3508fdc 100644
--- a/Changelog
+++ b/Changelog
@@ -1,7 +1,15 @@
 -------------------------------------------------------------------------------
 Summon Assistant
 -------------------------------------------------------------------------------
-Version 1.3.0 (07-01-2017)
+Version 1.3.1 (09-01-2018)
+- Added sliders to set: Button margin/height/width.
+(It is at this time, 'not possible' to move/drag the frame, when the margin is set to 0)
+- It should now only be possible to enable the assistants you have available,
+  reference to disabledtextures have been removed.
+  Resettomg the settings (file), should resolve the issue.
+- Fixed issue where the icons would be placed outside the frame
+
+Version 1.3.0 (07-01-2018)
 (Breaking changes to the saved settings)
 - Added setting to show X,Y coordinates when the bar is moved
     (Should be disabled after move)
diff --git a/SummonAssistant.lua b/SummonAssistant.lua
index 186773f..634f970 100644
--- a/SummonAssistant.lua
+++ b/SummonAssistant.lua
@@ -14,7 +14,7 @@ local LAM2 = LibStub:GetLibrary("LibAddonMenu-2.0")
 local ADDON_NAME = "SummonAssistant"
 local ADDON_DISPLAY_NAME = "Summon Assistant"
 local ADDON_VERSION = 1.3
-local ADDON_MINOR_VERSION = 0
+local ADDON_MINOR_VERSION = 1
 local ADDON_AUTHOR = "Jarth"
 local ADDON_WEBSITE = ""
 local SummonAssistant = {}
@@ -29,10 +29,9 @@ SummonAssistant.Types = {
         name = "banker",
         Tooltip = "When ON the banker button will be visible. When OFF the banker button will not be visible (disabled if locked for the account).",
         EnabledTexture = "/esoui/art/icons/" .. "assistant_banker_01.dds",
-        DisabledTexture = "/esoui/art/icons/" .. "assistant_banker_01-empty.dds",
         KeyBinding = "SI_BINDING_NAME_SummonAssistant_Assistant_Banker",
         Disabled = function()
-            IsCollectibleUnlocked(267)
+            return not IsCollectibleUnlocked(267)
         end
     },
     Fence = {
@@ -42,10 +41,9 @@ SummonAssistant.Types = {
         name = "fence",
         Tooltip = "When ON the fence button will be visible. When OFF the fence button will not be visible (disabled if locked for the account).",
         EnabledTexture = "/esoui/art/icons/" .. "assistant_fence_01.dds",
-        DisabledTexture = "/esoui/art/icons/" .. "assistant_fence_01-empty.dds",
         KeyBinding = "SI_BINDING_NAME_SummonAssistant_Assistant_Fence",
         Disabled = function()
-            IsCollectibleUnlocked(300)
+            return not IsCollectibleUnlocked(300)
         end
     },
     Vendor = {
@@ -55,10 +53,9 @@ SummonAssistant.Types = {
         name = "vendor",
         Tooltip = "When ON the vendor button will be visible. When OFF the vendor button will not be visible (disabled if locked for the account).",
         EnabledTexture = "/esoui/art/icons/" .. "assistant_vendor_01.dds",
-        DisabledTexture = "/esoui/art/icons/" .. "assistant_vendor_01-empty.dds",
         KeyBinding = "SI_BINDING_NAME_SummonAssistant_Assistant_Vendor",
         Disabled = function()
-            IsCollectibleUnlocked(301)
+            return not IsCollectibleUnlocked(301)
         end
     }
 }
@@ -77,19 +74,19 @@ SummonAssistant.Default = {
     Horizontal = true,
     HideBarInMenu = true,
     ShowMoveAssitance = false,
-    ShowAssistants = {}
+    Margin = 10,
+    Height = 60,
+    Width = 60,
+    ShowAssistants = {
+        [267] = IsCollectibleUnlocked(267),
+        [300] = IsCollectibleUnlocked(300),
+        [301] = IsCollectibleUnlocked(301)
+    }
 }
 --Shows assistants by default, when unlocked.
-SummonAssistant.Default.ShowAssistants[267] = IsCollectibleUnlocked(267)
-SummonAssistant.Default.ShowAssistants[300] = IsCollectibleUnlocked(300)
-SummonAssistant.Default.ShowAssistants[301] = IsCollectibleUnlocked(301)
 SummonAssistant.Global = {
-    NumberUnlocked = GetTotalCollectiblesByCategoryType(COLLECTIBLE_CATEGORY_TYPE_ASSISTANT),
-    LblOffset = 10,
-    LblHeight = 60,
-    LblWidth = 60
+    NumberUnlocked = GetTotalCollectiblesByCategoryType(COLLECTIBLE_CATEGORY_TYPE_ASSISTANT)
 }
-
 -------------------------------------------------------------------------------------------------
 --  FUNCTIONS --
 -------------------------------------------------------------------------------------------------
@@ -132,7 +129,6 @@ function SummonAssistant:GetVersion(showMinor)
 end

 function SummonAssistant:OnClicked(id)
-    -- increment the counter by one
     if id > 0 then
         if IsCollectibleUnlocked(id) then
             UseCollectible(id)
@@ -160,19 +156,22 @@ function SummonAssistant:removeControlToFrame(menuOpen)
     SCENE_MANAGER:GetScene("hudui"):RemoveFragment(SummonAssistant.Fragment)
 end

-function SummonAssistant:SetupButton(key, SummonAssistant_Button, id, enabled)
-    local SummonAssistant_ButtonTexture = SummonAssistant.wm:GetControlByName("SummonAssistant_Button" .. key .. "Texture")
-    if SummonAssistant_ButtonTexture ~= nil then
-        local handler = nil
-        local texture = SummonAssistant.Types[key].DisabledTexture
-        if enabled then
-            handler = function(self)
-                SummonAssistant:OnClicked(SummonAssistant_Button:GetId())
+function SummonAssistant:SetupButton(key, button, id)
+    local buttonTexture = SummonAssistant.wm:GetControlByName("SummonAssistant_Button" .. key .. "Texture")
+    if buttonTexture ~= nil then
+        button:SetHandler(
+            "OnClicked",
+            function(self)
+                SummonAssistant:OnClicked(button:GetId())
             end
-            texture = SummonAssistant.Types[key].EnabledTexture
-        end
-        SummonAssistant_Button:SetHandler("OnClicked", handler)
-        SummonAssistant_ButtonTexture:SetTexture(texture)
+        )
+        button:SetHeight(SummonAssistant.Saved.Height - (2 * SummonAssistant.Saved.Margin))
+        button:SetWidth(SummonAssistant.Saved.Width - (2 * SummonAssistant.Saved.Margin))
+        buttonTexture:ClearAnchors()
+        buttonTexture:SetAnchor(CENTER, button, CENTER, 0, 0)
+        buttonTexture:SetTexture(SummonAssistant.Types[key].EnabledTexture)
+        buttonTexture:SetHeight(SummonAssistant.Saved.Height - (2 * SummonAssistant.Saved.Margin))
+        buttonTexture:SetWidth(SummonAssistant.Saved.Width - (2 * SummonAssistant.Saved.Margin))
     end
 end

@@ -211,27 +210,31 @@ function SummonAssistant:SetFragmentBehaviour(menuOpen)
 end

 function SummonAssistant:SetButtonFrameWidth()
-    local saBtnHeight = 60
-    local saBtnWidth = 60
-    local saCount = 0
-    local saShow = 0
+    local count = 0
+    local show = 0
+    local height = 0
+    local width = 0

     for key, value in pairs(SummonAssistant.Saved.ShowAssistants) do
         if IsCollectibleUnlocked(key) and SummonAssistant.Saved.ShowAssistants[key] then
-            saCount = saCount + 1
-        end
-        if saShow == 0 then
-            saShow = 1
+            count = count + 1
         end
     end

-    SummonAssistant_Frame:SetHidden(saCount == 0)
-    SummonAssistant_Frame:SetHeight(SummonAssistant.Global.LblHeight * (SummonAssistant.Saved.Horizontal and saShow or saCount))
-    SummonAssistant_Frame:SetWidth(SummonAssistant.Global.LblWidth * (SummonAssistant.Saved.Horizontal and saCount or saShow))
+    if count > 0 then
+        show = 1
+    end
+    height = SummonAssistant.Saved.Height * (SummonAssistant.Saved.Horizontal and show or count)
+    width = SummonAssistant.Saved.Width * (SummonAssistant.Saved.Horizontal and count or show)
+
+    SummonAssistant:SetFrameValues(SummonAssistant_Frame, count, height, width)
+    SummonAssistant:SetFrameValues(SummonAssistant_FrameBackdrop, count, height, width)
+end

-    SummonAssistant_FrameBackdrop:SetHidden(saCount == 0)
-    SummonAssistant_FrameBackdrop:SetHeight(SummonAssistant.Global.LblHeight * (SummonAssistant.Saved.Horizontal and saShow or saCount))
-    SummonAssistant_FrameBackdrop:SetWidth(SummonAssistant.Global.LblWidth * (SummonAssistant.Saved.Horizontal and saCount or saShow))
+function SummonAssistant:SetFrameValues(frame, count, height, width)
+    frame:SetHidden(count == 0)
+    frame:SetHeight(height)
+    frame:SetWidth(width)
 end

 function SummonAssistant:FrameBackdropColor(centerColor, edgeColor)
@@ -246,20 +249,21 @@ function SummonAssistant:FrameBackdropColor(centerColor, edgeColor)
 end

 function SummonAssistant:InitializeButtons()
-    for index, _value in ipairs(SummonAssistant.OrderedTypes) do
+    local index = 1
+    for _, _value in ipairs(SummonAssistant.OrderedTypes) do
         local id = _value.Id
         local key = _value.Name
         local left, top = SummonAssistant:GetButtonPosition(index)
-        if SummonAssistant.Saved.ShowAssistants[id] then
-            local enabled = IsCollectibleUnlocked(_value.Id)
+        if SummonAssistant.Saved.ShowAssistants[id] and IsCollectibleUnlocked(_value.Id) then
             if SummonAssistant.Buttons[key] == nil then
                 SummonAssistant.Buttons[key] = WINDOW_MANAGER:CreateControlFromVirtual("SummonAssistant_Button", SummonAssistant_FrameBackdrop, "SummonAssistant_Button", key)
                 SummonAssistant.Buttons[key]:SetId(id)
             end
-            SummonAssistant:SetupButton(key, SummonAssistant.Buttons[key], id, enabled)
+            SummonAssistant:SetupButton(key, SummonAssistant.Buttons[key], id)
             SummonAssistant.Buttons[key]:ClearAnchors()
             SummonAssistant.Buttons[key]:SetAnchor(TOPLEFT, SummonAssistant_FrameBackdrop, TOPLEFT, left, top)
             SummonAssistant.Buttons[key]:SetHidden(false)
+            index = index + 1
         elseif SummonAssistant.Buttons[key] ~= nil then
             SummonAssistant.Buttons[key]:SetHidden(true)
         end
@@ -267,11 +271,11 @@ function SummonAssistant:InitializeButtons()
 end

 function SummonAssistant:GetButtonPosition(index)
-    local left = SummonAssistant.Global.LblOffset
-    local top = SummonAssistant.Global.LblOffset + SummonAssistant.Global.LblHeight * (index - 1)
+    local left = (SummonAssistant.Saved.Margin)
+    local top = (SummonAssistant.Saved.Margin) + SummonAssistant.Saved.Height * (index - 1)
     if SummonAssistant.Saved.Horizontal then
-        left = SummonAssistant.Global.LblOffset + SummonAssistant.Global.LblHeight * (index - 1)
-        top = SummonAssistant.Global.LblOffset
+        left = (SummonAssistant.Saved.Margin) + SummonAssistant.Saved.Width * (index - 1)
+        top = (SummonAssistant.Saved.Margin)
     end
     return left, top
 end
@@ -410,19 +414,69 @@ function SummonAssistant:CreateSettingsWindow()
             end
         },
         [6] = {
-            type = "checkbox",
-            name = "Show bar position",
-            tooltip = "When ON the bar will show the X,Y position of the top left corner, when the mouse enters and drags the panel around.",
-            default = function()
-                return SummonAssistant.Default.ShowMoveAssitance
-            end,
-            getFunc = function()
-                return SummonAssistant.Saved.ShowMoveAssitance
-            end,
-            setFunc = function(newValue)
-                SummonAssistant.Saved.ShowMoveAssitance = newValue
-                SummonAssistant:RestorePanel()
-            end
+            type = "submenu",
+            name = "Position and size",
+            tooltip = "Settings regarding position and size.",
+            controls = {
+                [1] = {
+                    type = "checkbox",
+                    name = "Show bar position",
+                    tooltip = "When ON the bar will show the X,Y position of the top left corner, when the mouse enters and drags the panel around.",
+                    default = function()
+                        return SummonAssistant.Default.ShowMoveAssitance
+                    end,
+                    getFunc = function()
+                        return SummonAssistant.Saved.ShowMoveAssitance
+                    end,
+                    setFunc = function(newValue)
+                        SummonAssistant.Saved.ShowMoveAssitance = newValue
+                        SummonAssistant:RestorePanel()
+                    end
+                },
+                [2] = {
+                    type = "slider",
+                    name = "Choose button margin",
+                    tooltip = "It is at this time, 'not possible' to move/drag the frame, when the margin is set to 0",
+                    default = SummonAssistant.Default.Margin,
+                    getFunc = function()
+                        return SummonAssistant.Saved.Margin
+                    end,
+                    setFunc = function(value)
+                        SummonAssistant.Saved.Margin = value
+                        SummonAssistant:RestorePanel()
+                    end,
+                    min = 0,
+                    max = 50
+                },
+                [3] = {
+                    type = "slider",
+                    name = "Choose button height",
+                    default = SummonAssistant.Default.Height,
+                    getFunc = function()
+                        return SummonAssistant.Saved.Height
+                    end,
+                    setFunc = function(value)
+                        SummonAssistant.Saved.Height = value
+                        SummonAssistant:RestorePanel()
+                    end,
+                    min = 1,
+                    max = 100
+                },
+                [4] = {
+                    type = "slider",
+                    name = "Choose button width",
+                    default = SummonAssistant.Default.Width,
+                    getFunc = function()
+                        return SummonAssistant.Saved.Width
+                    end,
+                    setFunc = function(value)
+                        SummonAssistant.Saved.Width = value
+                        SummonAssistant:RestorePanel()
+                    end,
+                    min = 1,
+                    max = 100
+                }
+            }
         },
         [7] = {
             type = "submenu",
diff --git a/SummonAssistant.txt b/SummonAssistant.txt
index 605ee67..c6f46da 100644
--- a/SummonAssistant.txt
+++ b/SummonAssistant.txt
@@ -6,7 +6,7 @@

 ## APIVersion: 100021
 ## Title: SummonAssistant
-## Version: 1.3.0
+## Version: 1.3.1
 ## Author: Jarth
 ## Description: Summon assistant, by hotkey or button!
 ##