diff --git a/TaosGroupTools/Defaults.lua b/TaosGroupTools/Defaults.lua new file mode 100644 index 0000000..4820276 --- /dev/null +++ b/TaosGroupTools/Defaults.lua @@ -0,0 +1,37 @@ +--[[ + Addon: Taos Group Tools + Author: TProg Taonnor + Created by @Taonnor +]]-- + +--[[ + Default variables +]]-- + +TGT_DEFAULTS = +{ + -- Global settings + ["Movable"] = true, + ["IsGroupUltimateEnabled"] = true, + + -- Group Ultimate settings + ["OnlyAva"] = false, + ["Style"] = 3, + -- Positioning + ["PosX"] = 0, + ["PosY"] = 0, + ["SelectorPosX"] = 0, + ["SelectorPosY"] = 0, + -- Lane settings + ["IsSortingActive"] = false, + ["StaticUltimateID"] = 29861, + ["SwimlaneUltimateGroupIds"] = + { + [1] = 29861, + [2] = 27413, + [3] = 86536, + [4] = 86112, + [5] = 46537, + [6] = 46622, + }, +} \ No newline at end of file diff --git a/TaosGroupTools/TaosGroupTools.txt b/TaosGroupTools/TaosGroupTools.txt index b085850..394c23f 100644 --- a/TaosGroupTools/TaosGroupTools.txt +++ b/TaosGroupTools/TaosGroupTools.txt @@ -52,4 +52,5 @@ ui/groupultimate/CompactSwimlaneList.xml ui/groupultimate/CompactSwimlaneList.lua ui/groupultimate/UltimateGroupMenu.lua +Defaults.lua TaosGroupTools.lua \ No newline at end of file diff --git a/TaosGroupTools/i18n/de.lua b/TaosGroupTools/i18n/de.lua index dcb5ac4..807d35e 100644 --- a/TaosGroupTools/i18n/de.lua +++ b/TaosGroupTools/i18n/de.lua @@ -3,6 +3,9 @@ -- Options local strings = { TGT_OPTIONS_HEADER = "Optionen", + TGT_OPTIONS_GROUP_ULTIMATE_HEADER = "Group Ultimate Settings", + TGT_OPTIONS_GROUP_ULTIMATE_LABEL = "Group Ultimate aktiv", + TGT_OPTIONS_GROUP_ULTIMATE_TOOLTIP = "Wenn die Option aktiviert ist, sind die Group Ultimate Frames aktiv (Schwimmbahn-Liste).", TGT_OPTIONS_DRAG_LABEL = "Elemente verschieben", TGT_OPTIONS_DRAG_TOOLTIP = "Wenn die Option aktiviert ist, können alle Elemente verschoben werden.", TGT_OPTIONS_ONLY_AVA_LABEL = "Nur im AvA Gebiet anzeigen", diff --git a/TaosGroupTools/i18n/en.lua b/TaosGroupTools/i18n/en.lua index 210895c..ec257e3 100644 --- a/TaosGroupTools/i18n/en.lua +++ b/TaosGroupTools/i18n/en.lua @@ -3,6 +3,9 @@ -- Options local strings = { TGT_OPTIONS_HEADER = "Options", + TGT_OPTIONS_GROUP_ULTIMATE_HEADER = "Group Ultimate Settings", + TGT_OPTIONS_GROUP_ULTIMATE_LABEL = "Group Ultimate active", + TGT_OPTIONS_GROUP_ULTIMATE_TOOLTIP = "If activated, Group Ultimate Frames are active (Swimlane-List).", TGT_OPTIONS_DRAG_LABEL = "Drag elements", TGT_OPTIONS_DRAG_TOOLTIP = "If activated, you can drag all elements.", TGT_OPTIONS_ONLY_AVA_LABEL = "Show only in AvA", diff --git a/TaosGroupTools/i18n/fr.lua b/TaosGroupTools/i18n/fr.lua index 1e421ca..92b1099 100644 --- a/TaosGroupTools/i18n/fr.lua +++ b/TaosGroupTools/i18n/fr.lua @@ -3,6 +3,9 @@ -- Options local strings = { TGT_OPTIONS_HEADER = "Options", + TGT_OPTIONS_GROUP_ULTIMATE_HEADER = "Group Ultimate Settings", + TGT_OPTIONS_GROUP_ULTIMATE_LABEL = "Group Ultimate active", + TGT_OPTIONS_GROUP_ULTIMATE_TOOLTIP = "If activated, Group Ultimate Frames are active (Swimlane-List).", TGT_OPTIONS_DRAG_LABEL = "Drag elements", TGT_OPTIONS_DRAG_TOOLTIP = "If activated, you can drag all elements.", TGT_OPTIONS_ONLY_AVA_LABEL = "Show only in AvA", diff --git a/TaosGroupTools/logic/SettingsHandler.lua b/TaosGroupTools/logic/SettingsHandler.lua index 72f6431..742e50d 100644 --- a/TaosGroupTools/logic/SettingsHandler.lua +++ b/TaosGroupTools/logic/SettingsHandler.lua @@ -33,30 +33,9 @@ TGT_SettingsHandler.__index = TGT_SettingsHandler TGT_SettingsHandler.Name = "TGT-SettingsHandler" TGT_SettingsHandler.SettingsName = "TaosGroupToolSettings" TGT_SettingsHandler.SavedVariables = nil -TGT_SettingsHandler.Default = -{ - ["PosX"] = 0, - ["PosY"] = 0, - ["SelectorPosX"] = 0, - ["SelectorPosY"] = 0, - ["OnlyAva"] = false, - ["IsSortingActive"] = false, - ["Movable"] = true, - ["Style"] = 3, - ["StaticUltimateID"] = 29861, - ["SwimlaneUltimateGroupIds"] = - { - [1] = 29861, - [2] = 27413, - [3] = 86536, - [4] = 86112, - [5] = 46537, - [6] = 46622, - }, -} - ---[[ - Sets SetStyleSettings and fires TGT-StyleChanged callbacks + +--[[ + Sets SetStyleSettings and fires TGT_STYLE_CHANGED callbacks ]]-- function TGT_SettingsHandler.SetStyleSettings(style) if (LOG_ACTIVE) then @@ -76,7 +55,7 @@ function TGT_SettingsHandler.SetStyleSettings(style) end --[[ - Sets MovableSettings and fires TGT-MovableChanged callbacks + Sets StaticUltimateIDSettings and fires TGT_STATIC_ULTIMATE_ID_CHANGED callbacks ]]-- function TGT_SettingsHandler.SetStaticUltimateIDSettings(staticUltimateID) if (LOG_ACTIVE) then @@ -90,7 +69,7 @@ function TGT_SettingsHandler.SetStaticUltimateIDSettings(staticUltimateID) end --[[ - Sets MovableSettings and fires TGT-MovableChanged callbacks + Sets StaticUltimateIDSettings and fires TGT_SWIMLANE_ULTIMATE_GROUP_ID_CHANGED callbacks ]]-- function TGT_SettingsHandler.SetSwimlaneUltimateGroupIdSettings(swimlane, ultimateGroup) if (LOG_ACTIVE) then @@ -119,7 +98,7 @@ function TGT_SettingsHandler.SetMovableSettings(movable) end --[[ - Sets MovableSettings and fires TGT-MovableChanged callbacks + Sets OnlyAvaSettings and fires TGT_IS_ZONE_CHANGED callbacks ]]-- function TGT_SettingsHandler.SetOnlyAvaSettings(onlyAva) if (LOG_ACTIVE) then @@ -133,11 +112,11 @@ function TGT_SettingsHandler.SetOnlyAvaSettings(onlyAva) end --[[ - Sets IsSortingActive settings + Sets IsSortingActiveSettings settings ]]-- function TGT_SettingsHandler.SetIsSortingActiveSettings(isSortingActive) if (LOG_ACTIVE) then - _logger:logTrace("TGT_SettingsHandler.SetIsLgsActiveSettings") + _logger:logTrace("TGT_SettingsHandler.SetIsSortingActiveSettings") _logger:logDebug("isSortingActive", isSortingActive) end @@ -206,7 +185,7 @@ function TGT_SettingsHandler.IsControlsVisible() end --[[ - OnPlayerActivated sends IsZoneChanged event + OnPlayerActivated fires TGT_IS_ZONE_CHANGED callbacks ]]-- function TGT_SettingsHandler.OnPlayerActivated(eventCode) if (LOG_ACTIVE) then @@ -224,7 +203,7 @@ function TGT_SettingsHandler.Initialize(logger) _logger = logger - TGT_SettingsHandler.SavedVariables = ZO_SavedVars:NewAccountWide(TGT_SettingsHandler.SettingsName, SETTINGS_VERSION, nil, TGT_SettingsHandler.Default) + TGT_SettingsHandler.SavedVariables = ZO_SavedVars:NewAccountWide(TGT_SettingsHandler.SettingsName, SETTINGS_VERSION, nil, TGT_DEFAULTS) -- Register EVENT_MANAGER:RegisterForEvent(TGT_SettingsHandler.Name, EVENT_PLAYER_ACTIVATED, TGT_SettingsHandler.OnPlayerActivated) diff --git a/TaosGroupTools/ui/SettingsWindow.lua b/TaosGroupTools/ui/SettingsWindow.lua index cf2c34d..0d2d736 100644 --- a/TaosGroupTools/ui/SettingsWindow.lua +++ b/TaosGroupTools/ui/SettingsWindow.lua @@ -19,14 +19,12 @@ TGT_SettingsWindow.__index = TGT_SettingsWindow Table Members ]]-- TGT_SettingsWindow.MainMenuName = "TaosGroupToolsSettingsMainMenu" +TGT_SettingsWindow.Panel = nil +TGT_SettingsWindow.Options = nil ---[[ - Initialize creates settings window -]]-- -function TGT_SettingsWindow.Initialize(logger, major, minor, patch) +function TGT_SettingsWindow.AddGroupUltimateOptions() if (LOG_ACTIVE) then - logger:logTrace("TGT_SettingsWindow.Initialize") - logger:logDebug("major, minor, patch", major, minor, patch) + logger:logTrace("TGT_SettingsWindow.AddGroupUltimateOptions") end local styleChoices = { @@ -35,85 +33,145 @@ function TGT_SettingsWindow.Initialize(logger, major, minor, patch) [3] = GetString(TGT_OPTIONS_STYLE_SHORT_SWIM), } - local panelData = { - type = "panel", - name = "Taos Group Tools", - author = "TProg Taonnor", - version = major .. "." .. minor .. "." .. patch, - slashCommand = "/taosGroupTools", - registerForDefaults = true + local optionsData = { + -- Submenu Group Ultimate Options + { type = "submenu", + name = GetString(TGT_OPTIONS_GROUP_ULTIMATE_HEADER), + controls = { + -- Only AvA visible + { type = "checkbox", + name = GetString(TGT_OPTIONS_ONLY_AVA_LABEL), + tooltip = GetString(TGT_OPTIONS_ONLY_AVA_TOOLTIP), + getFunc = + function() + return TGT_SettingsHandler.SavedVariables.OnlyAva + end, + setFunc = + function(value) + TGT_SettingsHandler.SetOnlyAvaSettings(value) + end, + default = TGT_DEFAULTS.OnlyAva + }, + -- Sorting active + { type = "checkbox", + name = GetString(TGT_OPTIONS_USE_SORTING_LABEL), + tooltip = GetString(TGT_OPTIONS_USE_SORTING_TOOLTIP), + getFunc = + function() + return TGT_SettingsHandler.SavedVariables.IsSortingActive + end, + setFunc = + function(value) + TGT_SettingsHandler.SetIsSortingActiveSettings(value) + end, + default = TGT_DEFAULTS.IsSortingActive + }, + -- Style + { type = "dropdown", + name = GetString(TGT_OPTIONS_STYLE_LABEL), + tooltip = GetString(TGT_OPTIONS_STYLE_TOOLTIP), + choices = styleChoices, + getFunc = + function() + return styleChoices[TGT_SettingsHandler.SavedVariables.Style] + end, + setFunc = + function(value) + for index, name in ipairs(styleChoices) do + if (name == value) then + TGT_SettingsHandler.SetStyleSettings(index) + break + end + end + end, + default = styleChoices[TGT_DEFAULTS.Style] + }, + }, + }, } + + -- Add options + for i = 1 , #optionsData do + table.insert(TGT_SettingsWindow.Options , optionsData[i]) + end +end - local optionsData = { - [1] = { - type = "header", +function TGT_SettingsWindow.CreateOptions() + if (LOG_ACTIVE) then + logger:logTrace("TGT_SettingsWindow.CreateOptions") + end + + TGT_SettingsWindow.Options = { + -- Options Header + { type = "header", name = GetString(TGT_OPTIONS_HEADER), + width = "full" }, - [2] = { - type = "checkbox", + -- Controls Movable + { type = "checkbox", name = GetString(TGT_OPTIONS_DRAG_LABEL), tooltip = GetString(TGT_OPTIONS_DRAG_TOOLTIP), getFunc = - function() - return TGT_SettingsHandler.SavedVariables.Movable - end, - setFunc = - function(value) - TGT_SettingsHandler.SetMovableSettings(value) - end, - default = TGT_SettingsHandler.Default.Movable - }, - [3] = { - type = "checkbox", - name = GetString(TGT_OPTIONS_ONLY_AVA_LABEL), - tooltip = GetString(TGT_OPTIONS_ONLY_AVA_TOOLTIP), - getFunc = - function() - return TGT_SettingsHandler.SavedVariables.OnlyAva - end, - setFunc = - function(value) - TGT_SettingsHandler.SetOnlyAvaSettings(value) - end, - default = TGT_SettingsHandler.Default.OnlyAva - }, - [4] = { - type = "checkbox", - name = GetString(TGT_OPTIONS_USE_SORTING_LABEL), - tooltip = GetString(TGT_OPTIONS_USE_SORTING_TOOLTIP), - getFunc = - function() - return TGT_SettingsHandler.SavedVariables.IsSortingActive - end, + function() + return TGT_SettingsHandler.SavedVariables.Movable + end, setFunc = - function(value) - TGT_SettingsHandler.SetIsSortingActiveSettings(value) - end, - default = TGT_SettingsHandler.Default.IsSortingActive + function(value) + TGT_SettingsHandler.SetMovableSettings(value) + end, + default = TGT_DEFAULTS.Movable }, - [5] = { - type = "dropdown", - name = GetString(TGT_OPTIONS_STYLE_LABEL), - tooltip = GetString(TGT_OPTIONS_STYLE_TOOLTIP), - choices = styleChoices, + -- Enable/Disable Group Ultimate + { type = "checkbox", + name = GetString(TGT_OPTIONS_GROUP_ULTIMATE_LABEL), + tooltip = GetString(TGT_OPTIONS_GROUP_ULTIMATE_TOOLTIP), getFunc = function() - return styleChoices[TGT_SettingsHandler.SavedVariables.Style] + return TGT_SettingsHandler.SavedVariables.IsGroupUltimateEnabled end, setFunc = function(value) - for index, name in ipairs(styleChoices) do - if (name == value) then - TGT_SettingsHandler.SetStyleSettings(index) - break - end - end + TGT_SettingsHandler.SetIsGroupUltimateEnabledSettings(value) end, - default = styleChoices[TGT_SettingsHandler.Default.Style] + default = TGT_DEFAULTS.IsGroupUltimateEnabled }, + } + + TGT_SettingsWindow.AddGroupUltimateOptions() +end + +--[[ + Creates settings panel +]]-- +function TGT_SettingsWindow.CreatePanel(major, minor, patch) + if (LOG_ACTIVE) then + logger:logTrace("TGT_SettingsWindow.CreatePanel") + logger:logDebug("major, minor, patch", major, minor, patch) + end + + TGT_SettingsWindow.Panel = { + type = "panel", + name = "Taos Group Tools", + author = "TProg Taonnor", + version = major .. "." .. minor .. "." .. patch, + slashCommand = "/taosGroupTools", + registerForDefaults = true } - +end + +--[[ + Initialize creates settings window +]]-- +function TGT_SettingsWindow.Initialize(logger, major, minor, patch) + if (LOG_ACTIVE) then + logger:logTrace("TGT_SettingsWindow.Initialize") + logger:logDebug("major, minor, patch", major, minor, patch) + end + + TGT_SettingsWindow.CreatePanel(major, minor, patch) + TGT_SettingsWindow.CreateOptions() + local LAM = LibStub("LibAddonMenu-2.0") - LAM:RegisterAddonPanel(TGT_SettingsWindow.MainMenuName, panelData) - LAM:RegisterOptionControls(TGT_SettingsWindow.MainMenuName, optionsData) + LAM:RegisterAddonPanel(TGT_SettingsWindow.MainMenuName, TGT_SettingsWindow.Panel) + LAM:RegisterOptionControls(TGT_SettingsWindow.MainMenuName, TGT_SettingsWindow.Options) end \ No newline at end of file