diff --git a/SummonAssistant.lua b/SummonAssistant.lua
index 2ab8682..186773f 100644
--- a/SummonAssistant.lua
+++ b/SummonAssistant.lua
@@ -62,15 +62,20 @@ SummonAssistant.Types = {
end
}
}
+SummonAssistant.OrderedTypes = {
+ [1] = SummonAssistant.Types["Banker"],
+ [2] = SummonAssistant.Types["Fence"],
+ [3] = SummonAssistant.Types["Vendor"]
+}
SummonAssistant.Default = {
- left = CENTER,
- top = CENTER,
- centerColor = {r = 0.88, g = 0.88, b = 0.88, a = 0.4},
- edgeColor = {r = 0.57, g = 0.57, b = 0.57, a = 0.6},
- useAccountSettings = true,
+ Left = CENTER,
+ Top = CENTER,
+ CenterColor = {r = 0.88, g = 0.88, b = 0.88, a = 0.4},
+ EdgeColor = {r = 0.57, g = 0.57, b = 0.57, a = 0.6},
+ UseAccountSettings = true,
Horizontal = true,
- hideBarInMenu = true,
+ HideBarInMenu = true,
ShowMoveAssitance = false,
ShowAssistants = {}
}
@@ -98,7 +103,7 @@ end
function SummonAssistant.Initialize()
-- Load saved values..
SummonAssistant.Saved = ZO_SavedVars:New("SummonAssistant_Character", ADDON_VERSION, nil, SummonAssistant.Default)
- if SummonAssistant.Saved.useAccountSettings then
+ if SummonAssistant.Saved.UseAccountSettings then
SummonAssistant.Saved = ZO_SavedVars:NewAccountWide("SummonAssistant_Account", ADDON_VERSION, nil, SummonAssistant.Default)
end
SummonAssistant_Frame:SetHandler("OnMoveStop", SummonAssistant.OnMoveStop)
@@ -111,8 +116,8 @@ function SummonAssistant.Initialize()
end
function SummonAssistant.OnMoveStop(frame)
- SummonAssistant.Saved.top = frame:GetTop()
- SummonAssistant.Saved.left = frame:GetLeft()
+ SummonAssistant.Saved.Top = frame:GetTop()
+ SummonAssistant.Saved.Left = frame:GetLeft()
end
-------------------------------------------------------------------------------------------------
@@ -172,9 +177,9 @@ function SummonAssistant:SetupButton(key, SummonAssistant_Button, id, enabled)
end
function SummonAssistant:CreateHotkeySelections()
- for key, _ in pairs(SummonAssistant.Types) do
- if IsCollectibleUnlocked(SummonAssistant.Types[key].Id) then
- ZO_CreateStringId(SummonAssistant.Types[key].KeyBinding, SummonAssistant.Types[key].Name)
+ for _, _value in ipairs(SummonAssistant.OrderedTypes) do
+ if IsCollectibleUnlocked(_value.Id) then
+ ZO_CreateStringId(_value.KeyBinding, _value.Name)
end
end
end
@@ -198,7 +203,7 @@ function SummonAssistant:SetFragmentBehaviour(menuOpen)
SummonAssistant.Fragment = ZO_HUDFadeSceneFragment:New(SummonAssistant_Frame)
end
- if SummonAssistant.Saved.hideBarInMenu then
+ if SummonAssistant.Saved.HideBarInMenu then
SummonAssistant:addControlToFrame(menuOpen)
else
SummonAssistant:removeControlToFrame(menuOpen)
@@ -231,61 +236,51 @@ end
function SummonAssistant:FrameBackdropColor(centerColor, edgeColor)
if not centerColor then
- centerColor = SummonAssistant.Saved.centerColor
+ centerColor = SummonAssistant.Saved.CenterColor
end
if not edgeColor then
- edgeColor = SummonAssistant.Saved.edgeColor
+ edgeColor = SummonAssistant.Saved.EdgeColor
end
SummonAssistant_FrameBackdrop:SetCenterColor(centerColor.r, centerColor.g, centerColor.b, centerColor.a)
SummonAssistant_FrameBackdrop:SetEdgeColor(edgeColor.r, edgeColor.g, edgeColor.b, edgeColor.a)
end
function SummonAssistant:InitializeButtons()
- local position = 0
- local index = 1
- for key, value in pairs(SummonAssistant.Types) do
- -- local id = GetCollectibleIdFromType(COLLECTIBLE_CATEGORY_TYPE_ASSISTANT, i)
- local id = SummonAssistant.Types[key].Id
+ for index, _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(SummonAssistant.Types[key].Id)
+ local enabled = IsCollectibleUnlocked(_value.Id)
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.Buttons[key]:SetHidden(false)
SummonAssistant.Buttons[key]:ClearAnchors()
- if SummonAssistant.Saved.Horizontal then
- SummonAssistant.Buttons[key]:SetAnchor(
- TOPLEFT,
- SummonAssistant_FrameBackdrop,
- TOPLEFT,
- SummonAssistant.Global.LblOffset + SummonAssistant.Global.LblHeight * (position),
- SummonAssistant.Global.LblOffset
- )
- else
- SummonAssistant.Buttons[key]:SetAnchor(
- TOPLEFT,
- SummonAssistant_FrameBackdrop,
- TOPLEFT,
- SummonAssistant.Global.LblOffset,
- SummonAssistant.Global.LblOffset + SummonAssistant.Global.LblHeight * (position)
- )
- end
- position = position + 1
- else
- if SummonAssistant.Buttons[key] ~= nil then
- SummonAssistant.Buttons[key]:SetHidden(true)
- end
+ SummonAssistant.Buttons[key]:SetAnchor(TOPLEFT, SummonAssistant_FrameBackdrop, TOPLEFT, left, top)
+ SummonAssistant.Buttons[key]:SetHidden(false)
+ elseif SummonAssistant.Buttons[key] ~= nil then
+ SummonAssistant.Buttons[key]:SetHidden(true)
end
end
end
+function SummonAssistant:GetButtonPosition(index)
+ local left = SummonAssistant.Global.LblOffset
+ local top = SummonAssistant.Global.LblOffset + SummonAssistant.Global.LblHeight * (index - 1)
+ if SummonAssistant.Saved.Horizontal then
+ left = SummonAssistant.Global.LblOffset + SummonAssistant.Global.LblHeight * (index - 1)
+ top = SummonAssistant.Global.LblOffset
+ end
+ return left, top
+end
+
function SummonAssistant:RestorePosition()
- local top = SummonAssistant.Saved.top
- local left = SummonAssistant.Saved.left
+ local Top = SummonAssistant.Saved.Top
+ local Left = SummonAssistant.Saved.Left
SummonAssistant_Frame:ClearAnchors()
- SummonAssistant_Frame:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, left, top)
+ SummonAssistant_Frame:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, Left, Top)
end
function SummonAssistant:ActivateMoveHandlers()
@@ -370,20 +365,20 @@ function SummonAssistant:CreateSettingsWindow()
type = "checkbox",
name = "Use account settings",
tooltip = "When ON the account settings will be used. When OFF character settings will be used.",
- default = SummonAssistant.Default.useAccountSettings,
+ default = SummonAssistant.Default.UseAccountSettings,
getFunc = function()
- return SummonAssistant.Saved.useAccountSettings
+ return SummonAssistant.Saved.UseAccountSettings
end,
setFunc = function(newValue)
--Apply value to existing variable
- SummonAssistant.Saved.useAccountSettings = newValue
+ SummonAssistant.Saved.UseAccountSettings = newValue
if newValue then
SummonAssistant.Saved = ZO_SavedVars:NewAccountWide("SummonAssistant_Account", ADDON_VERSION, nil, SummonAssistant.Default)
else
SummonAssistant.Saved = ZO_SavedVars:New("SummonAssistant_Character", ADDON_VERSION, nil, SummonAssistant.Default)
end
--Apply value to new variable
- SummonAssistant.Saved.useAccountSettings = newValue
+ SummonAssistant.Saved.UseAccountSettings = newValue
SummonAssistant:RestorePanel()
end
},
@@ -405,12 +400,12 @@ function SummonAssistant:CreateSettingsWindow()
type = "checkbox",
name = "Hide bar in menu",
tooltip = "When ON the bar will hide when a menu is opened.",
- default = SummonAssistant.Default.hideBarInMenu,
+ default = SummonAssistant.Default.HideBarInMenu,
getFunc = function()
- return SummonAssistant.Saved.hideBarInMenu
+ return SummonAssistant.Saved.HideBarInMenu
end,
setFunc = function(newValue)
- SummonAssistant.Saved.hideBarInMenu = newValue
+ SummonAssistant.Saved.HideBarInMenu = newValue
SummonAssistant:SetFragmentBehaviour(true)
end
},
@@ -442,14 +437,14 @@ function SummonAssistant:CreateSettingsWindow()
type = "colorpicker",
name = "Backdrop Color",
default = function()
- return SummonAssistant.Default.centerColor
+ return SummonAssistant.Default.CenterColor
end,
tooltip = "Changes the color of the background.",
getFunc = function()
- return SummonAssistant.Saved.centerColor.r, SummonAssistant.Saved.centerColor.g, SummonAssistant.Saved.centerColor.b, SummonAssistant.Saved.centerColor.a
+ return SummonAssistant.Saved.CenterColor.r, SummonAssistant.Saved.CenterColor.g, SummonAssistant.Saved.CenterColor.b, SummonAssistant.Saved.CenterColor.a
end,
setFunc = function(r, g, b, a)
- SummonAssistant.Saved.centerColor = {r = r, g = g, b = b, a = a}
+ SummonAssistant.Saved.CenterColor = {r = r, g = g, b = b, a = a}
SummonAssistant:FrameBackdropColor()
end,
width = "half"
@@ -458,14 +453,14 @@ function SummonAssistant:CreateSettingsWindow()
type = "colorpicker",
name = "Frame Color",
default = function()
- return SummonAssistant.Default.edgeColor
+ return SummonAssistant.Default.EdgeColor
end,
tooltip = "Changes the color of the frame.",
getFunc = function()
- return SummonAssistant.Saved.edgeColor.r, SummonAssistant.Saved.edgeColor.g, SummonAssistant.Saved.edgeColor.b, SummonAssistant.Saved.edgeColor.a
+ return SummonAssistant.Saved.EdgeColor.r, SummonAssistant.Saved.EdgeColor.g, SummonAssistant.Saved.EdgeColor.b, SummonAssistant.Saved.EdgeColor.a
end,
setFunc = function(r, g, b, a)
- SummonAssistant.Saved.edgeColor = {r = r, g = g, b = b, a = a}
+ SummonAssistant.Saved.EdgeColor = {r = r, g = g, b = b, a = a}
SummonAssistant:FrameBackdropColor()
end,
width = "half"
@@ -480,53 +475,29 @@ function SummonAssistant:CreateSettingsWindow()
[1] = {
type = "description",
text = "Select assistant buttons you want enabled."
- },
- [2] = {
- type = "checkbox",
- name = "Show " .. SummonAssistant.Types.Banker.name,
- tooltip = SummonAssistant.Types.Banker.Tooltip,
- default = not SummonAssistant.Types.Banker.Disabled,
- disabled = SummonAssistant.Types.Banker.Disabled,
- getFunc = function()
- return SummonAssistant.Saved.ShowAssistants[267]
- end,
- setFunc = function(newValue)
- SummonAssistant.Saved.ShowAssistants[267] = newValue
- SummonAssistant:RestorePanel()
- end
- },
- [3] = {
- type = "checkbox",
- name = "Show " .. SummonAssistant.Types.Fence.name,
- tooltip = SummonAssistant.Types.Fence.Tooltip,
- default = not SummonAssistant.Types.Fence.Disabled,
- disabled = SummonAssistant.Types.Fence.Disabled,
- getFunc = function()
- return SummonAssistant.Saved.ShowAssistants[300]
- end,
- setFunc = function(newValue)
- SummonAssistant.Saved.ShowAssistants[300] = newValue
- SummonAssistant:RestorePanel()
- end
- },
- [4] = {
- type = "checkbox",
- name = "Show " .. SummonAssistant.Types.Vendor.name,
- tooltip = SummonAssistant.Types.Vendor.Tooltip,
- default = not SummonAssistant.Types.Vendor.Disabled,
- disabled = SummonAssistant.Types.Vendor.Disabled,
- getFunc = function()
- return SummonAssistant.Saved.ShowAssistants[301]
- end,
- setFunc = function(newValue)
- SummonAssistant.Saved.ShowAssistants[301] = newValue
- SummonAssistant:RestorePanel()
- end
}
}
}
}
+
+ for index, _type in ipairs(SummonAssistant.OrderedTypes) do
+ local line = {
+ type = "checkbox",
+ name = "Show " .. _type.name,
+ tooltip = _type.Tooltip,
+ default = not _type.Disabled,
+ disabled = _type.Disabled,
+ getFunc = function()
+ return SummonAssistant.Saved.ShowAssistants[_type.Id]
+ end,
+ setFunc = function(newValue)
+ SummonAssistant.Saved.ShowAssistants[_type.Id] = newValue
+ SummonAssistant:RestorePanel()
+ end
+ }
+ table.insert(optionsData[8].controls, index + 1, line)
+ end
LAM2:RegisterOptionControls(ADDON_NAME, optionsData)
end
-EVENT_MANAGER:RegisterForEvent(ADDON_NAME, EVENT_ADD_ON_LOADED, SummonAssistant.OnAddOnLoaded)
\ No newline at end of file
+EVENT_MANAGER:RegisterForEvent(ADDON_NAME, EVENT_ADD_ON_LOADED, SummonAssistant.OnAddOnLoaded)