Version 1.5.0 (20-01-2018)

Jarth [01-20-18 - 10:02]
Version 1.5.0 (20-01-2018)
Filename
Bindings.xml
Bindings/Bindings.lua
Bindings/Bindings.xml
Changelog
SummonAssistant.lua
SummonAssistant.txt
SummonAssistant.xml
SummonAssistant_Buttons.lua
SummonAssistant_Constants.lua
SummonAssistant_Hotkeys.lua
SummonAssistant_Menu.lua
diff --git a/Bindings.xml b/Bindings.xml
new file mode 100644
index 0000000..51fe944
--- /dev/null
+++ b/Bindings.xml
@@ -0,0 +1,9 @@
+<Bindings>
+  <Layer name="SI_KEYBINDINGS_LAYER_GENERAL">
+    <Category name="Summon Assistant">
+	  <Action name="SummonAssistant_Banker"><Down>UseCollectible(267)</Down></Action>
+    <Action name="SummonAssistant_Fence"><Down>UseCollectible(300)</Down></Action>
+	  <Action name="SummonAssistant_Vendor"><Down>UseCollectible(301)</Down></Action>
+    </Category>
+  </Layer>
+</Bindings>
\ No newline at end of file
diff --git a/Bindings/Bindings.lua b/Bindings/Bindings.lua
deleted file mode 100644
index e69de29..0000000
diff --git a/Bindings/Bindings.xml b/Bindings/Bindings.xml
deleted file mode 100644
index 270b77d..0000000
--- a/Bindings/Bindings.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<Bindings>
-  <Layer name="SI_KEYBINDINGS_LAYER_GENERAL">
-    <Category name="Summon Assistant">
-	  <Action name="SummonAssistant_Assistant_Banker"><Down>UseCollectible(267)</Down></Action>
-    <Action name="SummonAssistant_Assistant_Fence"><Down>UseCollectible(300)</Down></Action>
-	  <Action name="SummonAssistant_Assistant_Vendor"><Down>UseCollectible(301)</Down></Action>
-    </Category>
-  </Layer>
-</Bindings>
\ No newline at end of file
diff --git a/Changelog b/Changelog
index 0e116d6..965d910 100644
--- a/Changelog
+++ b/Changelog
@@ -1,6 +1,13 @@
 -------------------------------------------------------------------------------
 Summon Assistant
 -------------------------------------------------------------------------------
+Version 1.5.0 (20-01-2018)
+- Restructured:
+-- Option to show the keybinding for each button.
+-- Font color affects keybinding label.
+-- Change location of keybinding label.
+INFO: After updating a keybinding, /reloadui or flip a setting in either: Orientation, Visibility or Position and Size.
+
 Version 1.4.0 (13-01-2018)
 - Added functionality: Unlock the bar (the bar is by default locked)
 -- An overlay will appear on the bar, showing the size and position (X,Y top left).
diff --git a/SummonAssistant.lua b/SummonAssistant.lua
index 44e5d1a..13ce1b2 100644
--- a/SummonAssistant.lua
+++ b/SummonAssistant.lua
@@ -11,7 +11,7 @@ local SummonAssistant = SummonAssistant
 -------------------------------------------------------------------------------------------------
 -- FUNCTIONS --
 -------------------------------------------------------------------------------------------------
-function SummonAssistant.OnAddOnLoaded(event, addonName)
+function SummonAssistant.OnAddOnLoaded(_, addonName)
     if addonName == SummonAssistant.Addon.Name then
         SummonAssistant.Initialize()
     end
@@ -25,7 +25,7 @@ function SummonAssistant.Initialize()
     end

     SummonAssistant:RestorePanel()
-    SummonAssistant:CreateHotkeySelections()
+    SummonAssistant:HoykeyCreateSelections()
     SummonAssistant:CreateSettingsWindow()

     EVENT_MANAGER:UnregisterForEvent(SummonAssistant.Addon.Name, EVENT_ADD_ON_LOADED)
diff --git a/SummonAssistant.txt b/SummonAssistant.txt
index c34e88e..c6b45ba 100644
--- a/SummonAssistant.txt
+++ b/SummonAssistant.txt
@@ -6,7 +6,7 @@

 ## APIVersion: 100021 100022
 ## Title: SummonAssistant
-## Version: 1.4.0
+## Version: 1.5.0
 ## Author: Jarth
 ## Description: Summon assistant, by hotkey or button!
 ##
@@ -36,12 +36,12 @@ libs\LibAddonMenu-2.0\controls\texture.lua
 libs\LibAddonMenu-2.0\controls\iconpicker.lua
 libs\LibAddonMenu-2.0\controls\divider.lua

-Bindings\Bindings.xml
-SummonAssistant.xml
 SummonAssistant_Constants.lua
 SummonAssistant_Fragments.lua
 SummonAssistant_Hotkeys.lua
 SummonAssistant_Menu.lua
 SummonAssistant_Move.lua
 SummonAssistant_Buttons.lua
-SummonAssistant.lua
\ No newline at end of file
+SummonAssistant.lua
+SummonAssistant.xml
+Bindings.xml
\ No newline at end of file
diff --git a/SummonAssistant.xml b/SummonAssistant.xml
index e911d13..1a63cb3 100644
--- a/SummonAssistant.xml
+++ b/SummonAssistant.xml
@@ -7,6 +7,8 @@
       <Controls>
         <Backdrop name="$(parent)Backdrop" alpha="1">
         </Backdrop>
+        <Label name="$(parent)Binding" font="ZoFontGameSmall" alpha="1">
+				</Label>
         <Texture name="$(parent)Texture" alpha="1">
         </Texture>
       </Controls>
diff --git a/SummonAssistant_Buttons.lua b/SummonAssistant_Buttons.lua
index 56c093e..7f1e498 100644
--- a/SummonAssistant_Buttons.lua
+++ b/SummonAssistant_Buttons.lua
@@ -51,6 +51,20 @@ function SummonAssistant:SetupButton(button, left, top)
     button:SetHidden(false)
 end

+function SummonAssistant:SetupButtonBinding(button, key, left, top)
+    local buttonBinding = GetControl(button, "Binding")
+    if buttonBinding ~= nil and SummonAssistant.Saved.ShowKeyBinding then
+        SummonAssistant:HotkeyUpdateColor(buttonBinding)
+        buttonBinding:SetText(SummonAssistant:HoykeyGetKey(SummonAssistant.Types[key].Name))
+        buttonBinding:SetDrawLevel(3)
+        buttonBinding:ClearAnchors()
+        buttonBinding:SetAnchor(SummonAssistant.Saved.KeyBindingLocation, button, SummonAssistant.Saved.KeyBindingLocation, 0, 0)
+    end
+    if buttonBinding ~= nil then
+        buttonBinding:SetHidden(not SummonAssistant.Saved.ShowKeyBinding)
+    end
+end
+
 function SummonAssistant:SetupButtonTexture(button, key, left, top)
     local buttonTexture = GetControl(button, "Texture")
     if buttonTexture ~= nil then
@@ -115,6 +129,7 @@ function SummonAssistant:InitializeButtons()
                 SummonAssistant.Buttons[key]:SetId(id)
             end
             SummonAssistant:SetupButton(SummonAssistant.Buttons[key], left, top)
+            SummonAssistant:SetupButtonBinding(SummonAssistant.Buttons[key], key, left, top)
             SummonAssistant:SetupButtonBackdrop(SummonAssistant.Buttons[key], key, left, top)
             SummonAssistant:SetupButtonTexture(SummonAssistant.Buttons[key], key, left, top)
             SummonAssistant.Buttons[key]:SetHandler("OnMouseEnter", SummonAssistant.ButtonHighlightEnter)
diff --git a/SummonAssistant_Constants.lua b/SummonAssistant_Constants.lua
index 8332dc1..077a4ec 100644
--- a/SummonAssistant_Constants.lua
+++ b/SummonAssistant_Constants.lua
@@ -11,7 +11,7 @@ SummonAssistant = {}
 SummonAssistant.Addon = {
     Name = "SummonAssistant",
     DisplayName = "Summon Assistant",
-    Version = 1.4,
+    Version = 1.5,
     MinorVersion = 0,
     SlashCommand = "/sa",
     Author = "Jarth",
@@ -38,10 +38,13 @@ SummonAssistant.Default = {
         [267] = IsCollectibleUnlocked(267),
         [300] = IsCollectibleUnlocked(300),
         [301] = IsCollectibleUnlocked(301)
-    }
+    },
+    KeyBindingLocation = BOTTOM,
+    ShowKeyBinding = true
 }
 SummonAssistant.Global = {
-    IsMoveEnabled = false
+    IsMoveEnabled = false,
+    ChoisesKeyBindingLocation = {"bottom","bottomleft","bottomright","center","left","right","top","topleft","topright"}
 }
 SummonAssistant.Types = {
     Banker = {
@@ -51,7 +54,7 @@ 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",
-        KeyBinding = "SI_BINDING_NAME_SummonAssistant_Assistant_Banker",
+        KeyBinding = "SI_BINDING_NAME_SummonAssistant_Banker",
         Disabled = function()
             return not IsCollectibleUnlocked(267)
         end
@@ -63,7 +66,7 @@ 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",
-        KeyBinding = "SI_BINDING_NAME_SummonAssistant_Assistant_Fence",
+        KeyBinding = "SI_BINDING_NAME_SummonAssistant_Fence",
         Disabled = function()
             return not IsCollectibleUnlocked(300)
         end
@@ -75,7 +78,7 @@ 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",
-        KeyBinding = "SI_BINDING_NAME_SummonAssistant_Assistant_Vendor",
+        KeyBinding = "SI_BINDING_NAME_SummonAssistant_Vendor",
         Disabled = function()
             return not IsCollectibleUnlocked(301)
         end
diff --git a/SummonAssistant_Hotkeys.lua b/SummonAssistant_Hotkeys.lua
index dff79fd..afbeb05 100644
--- a/SummonAssistant_Hotkeys.lua
+++ b/SummonAssistant_Hotkeys.lua
@@ -11,10 +11,87 @@ local SummonAssistant = SummonAssistant
 -------------------------------------------------------------------------------------------------
 -- PRIVATE FUNCTIONS --
 -------------------------------------------------------------------------------------------------
-function SummonAssistant:CreateHotkeySelections()
+function SummonAssistant:HoykeyCreateSelections()
     for _, _value in ipairs(SummonAssistant.OrderedTypes) do
         if IsCollectibleUnlocked(_value.Id) then
             ZO_CreateStringId(_value.KeyBinding, _value.Name)
         end
     end
 end
+
+function SummonAssistant:HoykeyGetKey(keyBinding)
+    local result = ""
+    if keyBinding then
+        local keyBindingTable = {GetHighestPriorityActionBindingInfoFromName("SummonAssistant_" .. keyBinding)}
+        for _, keyValue in pairs(keyBindingTable) do
+            if keyValue > 0 then
+                result = SummonAssistant:HotkeyGetKeyName(result, keyValue)
+            end
+        end
+    end
+    return result
+end
+
+function SummonAssistant:HotkeyGetKeyName(result, keyValue)
+    if keyValue > 0 then
+        if result ~= "" then
+            result = string.format("%s+%s", result, GetKeyName(keyValue))
+        else
+            result = GetKeyName(keyValue)
+        end
+    end
+    return result
+end
+
+function SummonAssistant:HotkeyUpdateColor(frame)
+    local fontColor = SummonAssistant.Saved.FontColor
+    frame:SetColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a)
+end
+
+function SummonAssistant:HotKeyGetLocationValue(value)
+    local result
+    if value == "bottom" then
+        result = BOTTOM
+    elseif value == "bottomleft" then
+        result = BOTTOMLEFT
+    elseif value == "bottomright" then
+        result = BOTTOMRIGHT
+    elseif value == "center" then
+        result = CENTER
+    elseif value == "left" then
+        result = LEFT
+    elseif value == "right" then
+        result = RIGHT
+    elseif value == "top" then
+        result = TOP
+    elseif value == "topleft" then
+        result = TOPLEFT
+    elseif value == "topright" then
+        result = TOPRIGHT
+    end
+    return result
+end
+
+function SummonAssistant:HotKeyGetLocationText(value)
+    local result
+    if value == BOTTOM then
+        result = "bottom"
+    elseif value == BOTTOMLEFT then
+        result = "bottomleft"
+    elseif value == BOTTOMRIGHT then
+        result = "bottomright"
+    elseif value == CENTER then
+        result = "center"
+    elseif value == LEFT then
+        result = "left"
+    elseif value == RIGHT then
+        result = "right"
+    elseif value == TOP then
+        result = "top"
+    elseif value == TOPLEFT then
+        result = "topleft"
+    elseif value == TOPRIGHT then
+        result = "topright"
+    end
+    return result
+end
diff --git a/SummonAssistant_Menu.lua b/SummonAssistant_Menu.lua
index f3c3eb1..1ae648f 100644
--- a/SummonAssistant_Menu.lua
+++ b/SummonAssistant_Menu.lua
@@ -35,7 +35,7 @@ function SummonAssistant:CreateSettingsWindow()
         },
         [2] = {
             type = "description",
-            text = "Here you can adjust how the summon assistant works."
+            text = string.format("Here you can adjust the %s works.\nSlash command: %s", SummonAssistant.Addon.DisplayName, SummonAssistant.Addon.SlashCommand)
         },
         [3] = {
             type = "checkbox",
@@ -173,10 +173,42 @@ function SummonAssistant:CreateSettingsWindow()
                     max = 10
                 },
                 [6] = {
+                    type = "checkbox",
+                    name = "Show hotkey's on bar",
+                    tooltip = "When ON the hotkey's will be shown on the bar.",
+                    default = SummonAssistant.Default.ShowKeyBinding,
+                    getFunc = function()
+                        return SummonAssistant.Saved.ShowKeyBinding
+                    end,
+                    setFunc = function(newValue)
+                        SummonAssistant.Saved.ShowKeyBinding = newValue
+                        SummonAssistant:RestorePanel()
+                    end,
+                    width = "half"
+                },
+                [7] = {
+                    type = "dropdown",
+                    name = "Hotkey label location",
+                    tooltip = "Select hotkey label location",
+                    choices = SummonAssistant.Global.ChoisesKeyBindingLocation,
+                    default = SummonAssistant.Default.KeyBindingLocation,
+                    disabled = function()
+                        return not SummonAssistant.Saved.ShowKeyBinding
+                    end,
+                    getFunc = function()
+                        return SummonAssistant:HotKeyGetLocationText(SummonAssistant.Saved.KeyBindingLocation)
+                    end,
+                    setFunc = function(value)
+                        SummonAssistant.Saved.KeyBindingLocation = SummonAssistant:HotKeyGetLocationValue(value)
+                        SummonAssistant:RestorePanel()
+                    end,
+                    width = "half"
+                },
+                [8] = {
                     type = "colorpicker",
                     name = "Font Color",
                     default = SummonAssistant.Default.FontColor,
-                    tooltip = "Changes of the move frame font.",
+                    tooltip = "Changes of the bar font color.",
                     getFunc = function()
                         return SummonAssistant.Saved.FontColor.r, SummonAssistant.Saved.FontColor.g, SummonAssistant.Saved.FontColor.b, SummonAssistant.Saved.FontColor.a
                     end,