diff --git a/lib/LibAddonMenu-2.0/LibAddonMenu-2.0.lua b/lib/LibAddonMenu-2.0/LibAddonMenu-2.0.lua index 568b95d..9d4150d 100644 --- a/lib/LibAddonMenu-2.0/LibAddonMenu-2.0.lua +++ b/lib/LibAddonMenu-2.0/LibAddonMenu-2.0.lua @@ -4,7 +4,7 @@ --Register LAM with LibStub -local MAJOR, MINOR = "LibAddonMenu-2.0", 19 +local MAJOR, MINOR = "LibAddonMenu-2.0", 999 -- only for test purposes. releases will get a smaller number local lam, oldminor = LibStub:NewLibrary(MAJOR, MINOR) if not lam then return end --the same or newer version of this lib is already loaded into memory @@ -46,13 +46,20 @@ local widgets = lam.widgets lam.util = {} local util = lam.util -local function GetTooltipText(tooltip) - if type(tooltip) == "string" then - return tooltip - elseif type(tooltip) == "function" then - return tostring(tooltip()) +local function GetDefaultValue(default) + if type(default) == "function" then + return default() end - return nil + return default +end + +local function GetStringFromValue(value) + if type(value) == "function" then + return value() + elseif type(value) == "number" then + return GetString(value) + end + return value end local function CreateBaseControl(parent, controlData, controlName) @@ -81,7 +88,7 @@ local function CreateLabelAndContainerControl(parent, controlData, controlName) label:SetFont("ZoFontWinH4") label:SetHeight(MIN_HEIGHT) label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetText(controlData.name) + label:SetText(GetStringFromValue(controlData.name)) control.label = label if control.isHalfWidth then @@ -96,14 +103,16 @@ local function CreateLabelAndContainerControl(parent, controlData, controlName) label:SetAnchor(TOPRIGHT, container, TOPLEFT, 5, 0) end - control.data.tooltipText = GetTooltipText(control.data.tooltip) + control.data.tooltipText = GetStringFromValue(control.data.tooltip) control:SetMouseEnabled(true) control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) return control end -util.GetTooltipText = GetTooltipText +util.GetTooltipText = GetStringFromValue -- deprecated, use util.GetStringFromValue instead +util.GetStringFromValue = GetStringFromValue +util.GetDefaultValue = GetDefaultValue util.CreateBaseControl = CreateBaseControl util.CreateLabelAndContainerControl = CreateLabelAndContainerControl @@ -227,6 +236,21 @@ function lam:RegisterWidget(widgetType, widgetVersion) end end +-- INTERNAL METHOD: fires the LAM-PanelOpened callback if not already done +local function OpenCurrentPanel() + if(lam.currentAddonPanel and not lam.currentPanelOpened) then + lam.currentPanelOpened = true + cm:FireCallbacks("LAM-PanelOpened", lam.currentAddonPanel) + end +end + +-- INTERNAL METHOD: fires the LAM-PanelClosed callback if not already done +local function CloseCurrentPanel() + if(lam.currentAddonPanel and lam.currentPanelOpened) then + lam.currentPanelOpened = false + cm:FireCallbacks("LAM-PanelClosed", lam.currentAddonPanel) + end +end --METHOD: OPEN TO ADDON PANEL-- --opens to a specific addon's option panel @@ -401,6 +425,7 @@ local function CreateOptionsControls(panel) else optionsCreated[addonID] = true cm:FireCallbacks("LAM-PanelControlsCreated", panel) + OpenCurrentPanel() end end @@ -408,6 +433,10 @@ local function CreateOptionsControls(panel) PrintLater(("The settings menu of %s is missing some entries."):format(addonID)) end DoCreateSettings() + else + optionsCreated[addonID] = true + cm:FireCallbacks("LAM-PanelControlsCreated", panel) + OpenCurrentPanel() end end @@ -418,6 +447,7 @@ local function ToggleAddonPanels(panel) --called in OnShow of newly shown panel local currentlySelected = lam.currentAddonPanel if currentlySelected and currentlySelected ~= panel then currentlySelected:SetHidden(true) + CloseCurrentPanel() end lam.currentAddonPanel = panel @@ -426,6 +456,8 @@ local function ToggleAddonPanels(panel) --called in OnShow of newly shown panel if not optionsCreated[panel:GetName()] then --if this is the first time opening this panel, create these options CreateOptionsControls(panel) + else + OpenCurrentPanel() end cm:FireCallbacks("LAM-RefreshPanel", panel) @@ -826,6 +858,13 @@ function lam:GetAddonSettingsFragment() if not LAMAddonSettingsFragment then local window = CreateAddonSettingsWindow() LAMAddonSettingsFragment = ZO_FadeSceneFragment:New(window, true, 100) + LAMAddonSettingsFragment:RegisterCallback("StateChange", function(oldState, newState) + if(newState == SCENE_FRAGMENT_SHOWN) then + OpenCurrentPanel() + elseif(newState == SCENE_FRAGMENT_HIDDEN) then + CloseCurrentPanel() + end + end) CreateAddonSettingsMenuEntry() end return LAMAddonSettingsFragment diff --git a/lib/LibAddonMenu-2.0/controls/button.lua b/lib/LibAddonMenu-2.0/controls/button.lua index 7489872..340ff35 100644 --- a/lib/LibAddonMenu-2.0/controls/button.lua +++ b/lib/LibAddonMenu-2.0/controls/button.lua @@ -1,17 +1,17 @@ --[[buttonData = { type = "button", - name = "My Button", - tooltip = "Button's tooltip text.", + name = "My Button", -- string id or function returning a string func = function() end, + tooltip = "Button's tooltip text.", -- string id or function returning a string (optional) width = "full", --or "half" (optional) disabled = function() return db.someBooleanSetting end, --or boolean (optional) icon = "icon\\path.dds", --(optional) warning = "Will need to reload the UI.", --(optional) - reference = "MyAddonButton" --(optional) unique global reference to control + reference = "MyAddonButton", -- unique global reference to control (optional) } ]] -local widgetVersion = 8 +local widgetVersion = 9 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("button", widgetVersion) then return end @@ -54,12 +54,12 @@ function LAMCreateControl.button(parent, buttonData, controlName) --control.button = wm:CreateControlFromVirtual(controlName.."Button", control, "ZO_DefaultButton") control.button = wm:CreateControlFromVirtual(nil, control, "ZO_DefaultButton") control.button:SetWidth(width / 3) - control.button:SetText(buttonData.name) + control.button:SetText(LAM.util.GetStringFromValue(buttonData.name)) end local button = control.button button:SetAnchor(control.isHalfWidth and CENTER or RIGHT) button:SetClickSound("Click") - button.data = {tooltipText = LAM.util.GetTooltipText(buttonData.tooltip)} + button.data = {tooltipText = LAM.util.GetStringFromValue(buttonData.tooltip)} button:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) button:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) button:SetHandler("OnClicked", function(self, ...) @@ -72,7 +72,7 @@ function LAMCreateControl.button(parent, buttonData, controlName) if buttonData.warning then control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") control.warning:SetAnchor(RIGHT, button, LEFT, -5, 0) - control.warning.data = {tooltipText = buttonData.warning} + control.warning.data = {tooltipText = LAM.util.GetStringFromValue(buttonData.warning)} end if buttonData.disabled ~= nil then diff --git a/lib/LibAddonMenu-2.0/controls/checkbox.lua b/lib/LibAddonMenu-2.0/controls/checkbox.lua index 46fe069..0b9ea48 100644 --- a/lib/LibAddonMenu-2.0/controls/checkbox.lua +++ b/lib/LibAddonMenu-2.0/controls/checkbox.lua @@ -1,18 +1,18 @@ --[[checkboxData = { type = "checkbox", - name = "My Checkbox", - tooltip = "Checkbox's tooltip text.", + name = "My Checkbox", -- or string id or function returning a string getFunc = function() return db.var end, setFunc = function(value) db.var = value doStuff() end, - width = "full", --or "half" (optional) + tooltip = "Checkbox's tooltip text.", -- or string id or function returning a string (optional) + width = "full", -- or "half" (optional) disabled = function() return db.someBooleanSetting end, --or boolean (optional) - warning = "Will need to reload the UI.", --(optional) - default = defaults.var, --(optional) - reference = "MyAddonCheckbox" --(optional) unique global reference to control + warning = "Will need to reload the UI.", -- or string id or function returning a string (optional) + default = defaults.var, -- a boolean or function that returns a boolean (optional) + reference = "MyAddonCheckbox", -- unique global reference to control (optional) } ]] -local widgetVersion = 10 +local widgetVersion = 11 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("checkbox", widgetVersion) then return end @@ -57,7 +57,7 @@ end local function UpdateValue(control, forceDefault, value) if forceDefault then --if we are forcing defaults - value = control.data.default + value = LAM.util.GetDefaultValue(control.data.default) control.data.setFunc(value) elseif value ~= nil then --our value could be false control.data.setFunc(value) @@ -124,10 +124,10 @@ function LAMCreateControl.checkbox(parent, checkboxData, controlName) if checkboxData.warning then control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") control.warning:SetAnchor(RIGHT, checkbox, LEFT, -5, 0) - control.warning.data = {tooltipText = checkboxData.warning} + control.warning.data = {tooltipText = LAM.util.GetStringFromValue(checkboxData.warning)} end - control.data.tooltipText = LAM.util.GetTooltipText(checkboxData.tooltip) + control.data.tooltipText = LAM.util.GetStringFromValue(checkboxData.tooltip) if checkboxData.disabled ~= nil then control.UpdateDisabled = UpdateDisabled diff --git a/lib/LibAddonMenu-2.0/controls/colorpicker.lua b/lib/LibAddonMenu-2.0/controls/colorpicker.lua index 184a2e4..afb6063 100644 --- a/lib/LibAddonMenu-2.0/controls/colorpicker.lua +++ b/lib/LibAddonMenu-2.0/controls/colorpicker.lua @@ -1,18 +1,18 @@ --[[colorpickerData = { type = "colorpicker", - name = "My Color Picker", - tooltip = "Color Picker's tooltip text.", + name = "My Color Picker", -- or string id or function returning a string getFunc = function() return db.r, db.g, db.b, db.a end, --(alpha is optional) setFunc = function(r,g,b,a) db.r=r, db.g=g, db.b=b, db.a=a end, --(alpha is optional) + tooltip = "Color Picker's tooltip text.", -- or string id or function returning a string (optional) width = "full", --or "half" (optional) disabled = function() return db.someBooleanSetting end, --or boolean (optional) - warning = "Will need to reload the UI.", --(optional) - default = {r = defaults.r, g = defaults.g, b = defaults.b, a = defaults.a}, --(optional) table of default color values (or default = defaultColor, where defaultColor is a table with keys of r, g, b[, a]) - reference = "MyAddonColorpicker" --(optional) unique global reference to control + warning = "Will need to reload the UI.", -- or string id or function returning a string (optional) + default = {r = defaults.r, g = defaults.g, b = defaults.b, a = defaults.a}, --(optional) table of default color values (or default = defaultColor, where defaultColor is a table with keys of r, g, b[, a]) or a function that returns the color + reference = "MyAddonColorpicker" -- unique global reference to control (optional) } ]] -local widgetVersion = 8 +local widgetVersion = 10 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("colorpicker", widgetVersion) then return end @@ -40,7 +40,7 @@ end local function UpdateValue(control, forceDefault, valueR, valueG, valueB, valueA) if forceDefault then --if we are forcing defaults - local color = control.data.default + local color = LAM.util.GetDefaultValue(control.data.default) valueR, valueG, valueB, valueA = color.r, color.g, color.b, color.a control.data.setFunc(valueR, valueG, valueB, valueA) elseif valueR and valueG and valueB then @@ -83,17 +83,17 @@ function LAMCreateControl.colorpicker(parent, colorpickerData, controlName) if upInside then local r, g, b, a = colorpickerData.getFunc() - COLOR_PICKER:Show(ColorPickerCallback, r, g, b, a, colorpickerData.name) + COLOR_PICKER:Show(ColorPickerCallback, r, g, b, a, LAM.util.GetStringFromValue(colorpickerData.name)) end end) if colorpickerData.warning then control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") control.warning:SetAnchor(RIGHT, control.color, LEFT, -5, 0) - control.warning.data = {tooltipText = colorpickerData.warning} + control.warning.data = {tooltipText = LAM.util.GetStringFromValue(colorpickerData.warning)} end - control.data.tooltipText = LAM.util.GetTooltipText(colorpickerData.tooltip) + control.data.tooltipText = LAM.util.GetStringFromValue(colorpickerData.tooltip) if colorpickerData.disabled ~= nil then control.UpdateDisabled = UpdateDisabled diff --git a/lib/LibAddonMenu-2.0/controls/description.lua b/lib/LibAddonMenu-2.0/controls/description.lua index 233d525..c9211ee 100644 --- a/lib/LibAddonMenu-2.0/controls/description.lua +++ b/lib/LibAddonMenu-2.0/controls/description.lua @@ -1,13 +1,13 @@ --[[descriptionData = { type = "description", - title = "My Title", --(optional) - text = "My description text to display.", + text = "My description text to display.", -- or string id or function returning a string + title = "My Title", -- or string id or function returning a string (optional) width = "full", --or "half" (optional) - reference = "MyAddonDescription" --(optional) unique global reference to control + reference = "MyAddonDescription" -- unique global reference to control (optional) } ]] -local widgetVersion = 7 +local widgetVersion = 8 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("description", widgetVersion) then return end @@ -16,9 +16,9 @@ local tinsert = table.insert local function UpdateValue(control) if control.title then - control.title:SetText(control.data.title) + control.title:SetText(LAM.util.GetStringFromValue(control.data.title)) end - control.desc:SetText(control.data.text) + control.desc:SetText(LAM.util.GetStringFromValue(control.data.text)) end function LAMCreateControl.description(parent, descriptionData, controlName) @@ -37,7 +37,7 @@ function LAMCreateControl.description(parent, descriptionData, controlName) local desc = control.desc desc:SetVerticalAlignment(TEXT_ALIGN_TOP) desc:SetFont("ZoFontGame") - desc:SetText(descriptionData.text) + desc:SetText(LAM.util.GetStringFromValue(descriptionData.text)) desc:SetWidth(isHalfWidth and width / 2 or width) if descriptionData.title then @@ -46,7 +46,7 @@ function LAMCreateControl.description(parent, descriptionData, controlName) title:SetWidth(isHalfWidth and width / 2 or width) title:SetAnchor(TOPLEFT, control, TOPLEFT) title:SetFont("ZoFontWinH4") - title:SetText(descriptionData.title) + title:SetText(LAM.util.GetStringFromValue(descriptionData.title)) desc:SetAnchor(TOPLEFT, title, BOTTOMLEFT) else desc:SetAnchor(TOPLEFT) diff --git a/lib/LibAddonMenu-2.0/controls/dropdown.lua b/lib/LibAddonMenu-2.0/controls/dropdown.lua index 5bdd546..6ed4370 100644 --- a/lib/LibAddonMenu-2.0/controls/dropdown.lua +++ b/lib/LibAddonMenu-2.0/controls/dropdown.lua @@ -1,20 +1,20 @@ --[[dropdownData = { type = "dropdown", - name = "My Dropdown", - tooltip = "Dropdown's tooltip text.", + name = "My Dropdown", -- or string id or function returning a string choices = {"table", "of", "choices"}, - sort = "name-up", --or "name-down", "numeric-up", "numeric-down" (optional) - if not provided, list will not be sorted getFunc = function() return db.var end, setFunc = function(var) db.var = var doStuff() end, + tooltip = "Dropdown's tooltip text.", -- or string id or function returning a string (optional) + sort = "name-up", --or "name-down", "numeric-up", "numeric-down" (optional) - if not provided, list will not be sorted width = "full", --or "half" (optional) disabled = function() return db.someBooleanSetting end, --or boolean (optional) - warning = "Will need to reload the UI.", --(optional) - default = defaults.var, --(optional) - reference = "MyAddonDropdown" --(optional) unique global reference to control + warning = "Will need to reload the UI.", -- or string id or function returning a string (optional) + default = defaults.var, -- default value or function that returns the default value (optional) + reference = "MyAddonDropdown" -- unique global reference to control (optional) } ]] -local widgetVersion = 10 +local widgetVersion = 12 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("dropdown", widgetVersion) then return end @@ -41,7 +41,7 @@ end local function UpdateValue(control, forceDefault, value) if forceDefault then --if we are forcing defaults - value = control.data.default + value = LAM.util.GetDefaultValue(control.data.default) control.data.setFunc(value) control.dropdown:SetSelectedItem(value) elseif value then @@ -111,7 +111,7 @@ function LAMCreateControl.dropdown(parent, dropdownData, controlName) if dropdownData.warning then control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") control.warning:SetAnchor(RIGHT, combobox, LEFT, -5, 0) - control.warning.data = {tooltipText = dropdownData.warning} + control.warning.data = {tooltipText = LAM.util.GetStringFromValue(dropdownData.warning)} end if dropdownData.disabled ~= nil then diff --git a/lib/LibAddonMenu-2.0/controls/editbox.lua b/lib/LibAddonMenu-2.0/controls/editbox.lua index 1f9bb47..fdcadfb 100644 --- a/lib/LibAddonMenu-2.0/controls/editbox.lua +++ b/lib/LibAddonMenu-2.0/controls/editbox.lua @@ -1,20 +1,20 @@ --[[editboxData = { type = "editbox", - name = "My Editbox", - tooltip = "Editbox's tooltip text.", + name = "My Editbox", -- or string id or function returning a string getFunc = function() return db.text end, setFunc = function(text) db.text = text doStuff() end, + tooltip = "Editbox's tooltip text.", -- or string id or function returning a string (optional) isMultiline = true, --boolean (optional) isExtraWide = true, --boolean (optional) width = "full", --or "half" (optional) disabled = function() return db.someBooleanSetting end, --or boolean (optional) - warning = "Will need to reload the UI.", --(optional) - default = defaults.text, --(optional) - reference = "MyAddonEditbox" --(optional) unique global reference to control + warning = "Will need to reload the UI.", -- or string id or function returning a string (optional) + default = defaults.text, -- default value or function that returns the default value (optional) + reference = "MyAddonEditbox" -- unique global reference to control (optional) } ]] -local widgetVersion = 9 +local widgetVersion = 11 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("editbox", widgetVersion) then return end @@ -44,7 +44,7 @@ end local function UpdateValue(control, forceDefault, value) if forceDefault then --if we are forcing defaults - value = control.data.default + value = LAM.util.GetDefaultValue(control.data.default) control.data.setFunc(value) control.editbox:SetText(value) elseif value then @@ -142,7 +142,7 @@ function LAMCreateControl.editbox(parent, editboxData, controlName) else control.warning:SetAnchor(TOPRIGHT, control.bg, TOPLEFT, -5, 0) end - control.warning.data = {tooltipText = editboxData.warning} + control.warning.data = {tooltipText = LAM.util.GetStringFromValue(editboxData.warning)} end if editboxData.disabled ~= nil then diff --git a/lib/LibAddonMenu-2.0/controls/header.lua b/lib/LibAddonMenu-2.0/controls/header.lua index 344f56b..72ead4b 100644 --- a/lib/LibAddonMenu-2.0/controls/header.lua +++ b/lib/LibAddonMenu-2.0/controls/header.lua @@ -1,12 +1,12 @@ --[[headerData = { type = "header", - name = "My Header", + name = "My Header", -- or string id or function returning a string width = "full", --or "half" (optional) - reference = "MyAddonHeader" --(optional) unique global reference to control + reference = "MyAddonHeader" -- unique global reference to control (optional) } ]] -local widgetVersion = 6 +local widgetVersion = 7 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("header", widgetVersion) then return end @@ -14,7 +14,7 @@ local wm = WINDOW_MANAGER local tinsert = table.insert local function UpdateValue(control) - control.header:SetText(control.data.name) + control.header:SetText(LAM.util.GetStringFromValue(control.data.name)) end local MIN_HEIGHT = 30 @@ -33,7 +33,7 @@ function LAMCreateControl.header(parent, headerData, controlName) local header = control.header header:SetAnchor(TOPLEFT, divider, BOTTOMLEFT) header:SetAnchor(BOTTOMRIGHT) - header:SetText(headerData.name) + header:SetText(LAM.util.GetStringFromValue(headerData.name)) control.UpdateValue = UpdateValue diff --git a/lib/LibAddonMenu-2.0/controls/iconpicker.lua b/lib/LibAddonMenu-2.0/controls/iconpicker.lua index 93c47f3..de720e9 100644 --- a/lib/LibAddonMenu-2.0/controls/iconpicker.lua +++ b/lib/LibAddonMenu-2.0/controls/iconpicker.lua @@ -1,24 +1,24 @@ --[[iconpickerData = { type = "iconpicker", - name = "My Icon Picker", - tooltip = "Color Picker's tooltip text.", + name = "My Icon Picker", -- or string id or function returning a string choices = {"texture path 1", "texture path 2", "texture path 3"}, - choicesTooltips = {"icon tooltip 1", "icon tooltip 2", "icon tooltip 3"}, --(optional) getFunc = function() return db.var end, setFunc = function(var) db.var = var doStuff() end, - maxColumns = 5, --(optional) number of icons in one row - visibleRows = 4.5, --(optional) number of visible rows - iconSize = 28, --(optional) size of the icons - defaultColor = ZO_ColorDef:New("FFFFFF"), --(optional) default color of the icons + tooltip = "Color Picker's tooltip text.", -- or string id or function returning a string (optional) + choicesTooltips = {"icon tooltip 1", "icon tooltip 2", "icon tooltip 3"}, -- or array of string ids or array of functions returning a string (optional) + maxColumns = 5, -- number of icons in one row (optional) + visibleRows = 4.5, -- number of visible rows (optional) + iconSize = 28, -- size of the icons (optional) + defaultColor = ZO_ColorDef:New("FFFFFF"), -- default color of the icons (optional) width = "full", --or "half" (optional) beforeShow = function(control, iconPicker) return preventShow end, --(optional) disabled = function() return db.someBooleanSetting end, --or boolean (optional) - warning = "Will need to reload the UI.", --(optional) - default = defaults.var, --(optional) - reference = "MyAddonIconPicker" --(optional) unique global reference to control + warning = "Will need to reload the UI.", -- or string id or function returning a string (optional) + default = defaults.var, -- default value or function that returns the default value (optional) + reference = "MyAddonIconPicker" -- unique global reference to control (optional) } ]] -local widgetVersion = 3 +local widgetVersion = 5 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("iconpicker", widgetVersion) then return end @@ -136,7 +136,7 @@ end function IconPickerMenu:OnMouseEnter(icon) InitializeTooltip(InformationTooltip, icon, TOPLEFT, 0, 0, BOTTOMRIGHT) - SetTooltipText(InformationTooltip, LAM.util.GetTooltipText(icon.tooltip)) + SetTooltipText(InformationTooltip, LAM.util.GetStringFromValue(icon.tooltip)) InformationTooltipTopLevel:BringWindowToTop() end @@ -268,7 +268,7 @@ local function UpdateChoices(control, choices, choicesTooltips) if control.panel.data.registerForRefresh then cm:FireCallbacks("LAM-RefreshPanel", control) end - end, choicesTooltips[i]) + end, LAM.util.GetStringFromValue(choicesTooltips[i])) addedChoices[texture] = true end end @@ -318,7 +318,7 @@ end local function UpdateValue(control, forceDefault, value) if forceDefault then --if we are forcing defaults - value = control.data.default + value = LAM.util.GetDefaultValue(control.data.default) control.data.setFunc(value) control.icon:SetTexture(value) elseif value then @@ -417,7 +417,7 @@ function LAMCreateControl.iconpicker(parent, iconpickerData, controlName) if iconpickerData.warning then control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") control.warning:SetAnchor(RIGHT, control.container, LEFT, -5, 0) - control.warning.data = {tooltipText = iconpickerData.warning} + control.warning.data = {tooltipText = LAM.util.GetStringFromValue(iconpickerData.warning)} end if iconpickerData.disabled ~= nil then diff --git a/lib/LibAddonMenu-2.0/controls/panel.lua b/lib/LibAddonMenu-2.0/controls/panel.lua index 92aa61e..315365a 100644 --- a/lib/LibAddonMenu-2.0/controls/panel.lua +++ b/lib/LibAddonMenu-2.0/controls/panel.lua @@ -1,18 +1,18 @@ --[[panelData = { type = "panel", - name = "Window Title", - displayName = "My Longer Window Title", --(optional) (can be useful for long addon names or if you want to colorize it) - author = "Seerah", --(optional) - version = "2.0", --(optional) - keywords = "settings", --(optional) additional keywords for search filter (it looks for matches in name..keywords..author) - slashCommand = "/myaddon", --(optional) will register a keybind to open to this panel (don't forget to include the slash!) + name = "Window Title", -- or string id or function returning a string + displayName = "My Longer Window Title", -- or string id or function returning a string (optional) (can be useful for long addon names or if you want to colorize it) + author = "Seerah", -- or string id or function returning a string (optional) + version = "2.0", -- or string id or function returning a string (optional) + keywords = "settings", -- additional keywords for search filter (it looks for matches in name..keywords..author) (optional) + slashCommand = "/myaddon", -- will register a keybind to open to this panel (don't forget to include the slash!) (optional) registerForRefresh = true, --boolean (optional) (will refresh all options controls when a setting is changed and when the panel is shown) registerForDefaults = true, --boolean (optional) (will set all options controls back to default values) resetFunc = function() print("defaults reset") end, --(optional) custom function to run after settings are reset to defaults } ]] -local widgetVersion = 9 +local widgetVersion = 10 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("panel", widgetVersion) then return end @@ -79,7 +79,7 @@ function LAMCreateControl.panel(parent, panelData, controlName) control.label = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel") local label = control.label label:SetAnchor(TOPLEFT, control, TOPLEFT, 0, 4) - label:SetText(panelData.displayName or panelData.name) + label:SetText(LAM.util.GetStringFromValue(panelData.displayName or panelData.name)) if panelData.author or panelData.version then control.info = wm:CreateControl(nil, control, CT_LABEL) @@ -87,11 +87,11 @@ function LAMCreateControl.panel(parent, panelData, controlName) info:SetFont("$(CHAT_FONT)|14|soft-shadow-thin") info:SetAnchor(TOPLEFT, label, BOTTOMLEFT, 0, -2) if panelData.author and panelData.version then - info:SetText(string.format("Version: %s - %s: %s", panelData.version, GetString(SI_ADDON_MANAGER_AUTHOR), panelData.author)) + info:SetText(string.format("Version: %s - %s: %s", LAM.util.GetStringFromValue(panelData.version), GetString(SI_ADDON_MANAGER_AUTHOR), LAM.util.GetStringFromValue(panelData.author))) elseif panelData.author then - info:SetText(string.format("%s: %s", GetString(SI_ADDON_MANAGER_AUTHOR), panelData.author)) + info:SetText(string.format("%s: %s", GetString(SI_ADDON_MANAGER_AUTHOR), LAM.util.GetStringFromValue(panelData.author))) else - info:SetText("Version: "..panelData.version) + info:SetText("Version: " .. LAM.util.GetStringFromValue(panelData.version)) end end diff --git a/lib/LibAddonMenu-2.0/controls/slider.lua b/lib/LibAddonMenu-2.0/controls/slider.lua index fa16686..801e16e 100644 --- a/lib/LibAddonMenu-2.0/controls/slider.lua +++ b/lib/LibAddonMenu-2.0/controls/slider.lua @@ -1,22 +1,22 @@ --[[sliderData = { type = "slider", - name = "My Slider", - tooltip = "Slider's tooltip text.", + name = "My Slider", -- or string id or function returning a string + getFunc = function() return db.var end, + setFunc = function(value) db.var = value doStuff() end, min = 0, max = 20, step = 1, --(optional) decimals = 0, --(optional) - getFunc = function() return db.var end, - setFunc = function(value) db.var = value doStuff() end, + tooltip = "Slider's tooltip text.", -- or string id or function returning a string (optional) width = "full", --or "half" (optional) disabled = function() return db.someBooleanSetting end, --or boolean (optional) - warning = "Will need to reload the UI.", --(optional) - default = defaults.var, --(optional) - reference = "MyAddonSlider" --(optional) unique global reference to control + warning = "Will need to reload the UI.", -- or string id or function returning a string (optional) + default = defaults.var, -- default value or function that returns the default value (optional) + reference = "MyAddonSlider" -- unique global reference to control (optional) } ]] -local widgetVersion = 8 +local widgetVersion = 9 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("slider", widgetVersion) then return end @@ -51,7 +51,7 @@ end local function UpdateValue(control, forceDefault, value) if forceDefault then --if we are forcing defaults - value = control.data.default + value = LAM.util.GetDefaultValue(control.data.default) control.data.setFunc(value) elseif value and value >= control.data.min and value <= control.data.max then control.data.setFunc(value) @@ -148,7 +148,7 @@ function LAMCreateControl.slider(parent, sliderData, controlName) if sliderData.warning then control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") control.warning:SetAnchor(RIGHT, slider, LEFT, -5, 0) - control.warning.data = {tooltipText = sliderData.warning} + control.warning.data = {tooltipText = LAM.util.GetStringFromValue(sliderData.warning)} end if sliderData.disabled ~= nil then diff --git a/lib/LibAddonMenu-2.0/controls/submenu.lua b/lib/LibAddonMenu-2.0/controls/submenu.lua index a7950ee..2512753 100644 --- a/lib/LibAddonMenu-2.0/controls/submenu.lua +++ b/lib/LibAddonMenu-2.0/controls/submenu.lua @@ -1,12 +1,12 @@ --[[submenuData = { type = "submenu", - name = "Submenu Title", - tooltip = "My submenu tooltip", --(optional) + name = "Submenu Title", -- or string id or function returning a string + tooltip = "My submenu tooltip", -- -- or string id or function returning a string (optional) controls = {sliderData, buttonData} --(optional) used by LAM reference = "MyAddonSubmenu" --(optional) unique global reference to control } ]] -local widgetVersion = 9 +local widgetVersion = 11 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("submenu", widgetVersion) then return end @@ -16,9 +16,9 @@ local tinsert = table.insert local function UpdateValue(control) - control.label:SetText(control.data.name) + control.label:SetText(LAM.util.GetStringFromValue(control.data.name)) if control.data.tooltip then - control.label.data.tooltipText = LAM.util.GetTooltipText(control.data.tooltip) + control.label.data.tooltipText = LAM.util.GetStringFromValue(control.data.tooltip) end end @@ -44,10 +44,10 @@ function LAMCreateControl.submenu(parent, submenuData, controlName) label:SetAnchor(TOPLEFT, control, TOPLEFT, 5, 5) label:SetDimensions(width, 30) label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetText(submenuData.name) + label:SetText(LAM.util.GetStringFromValue(submenuData.name)) label:SetMouseEnabled(true) if submenuData.tooltip then - label.data = {tooltipText = LAM.util.GetTooltipText(submenuData.tooltip)} + label.data = {tooltipText = LAM.util.GetStringFromValue(submenuData.tooltip)} label:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) label:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) end @@ -56,7 +56,7 @@ function LAMCreateControl.submenu(parent, submenuData, controlName) local scroll = control.scroll scroll:SetParent(control) scroll:SetAnchor(TOPLEFT, label, BOTTOMLEFT, 0, 10) - scroll:SetDimensionConstraints(width + 5, 0, width + 5, 2500) + scroll:SetDimensionConstraints(width + 5, 0, width + 5, 0) control.bg = wm:CreateControl(nil, label, CT_BACKDROP) local bg = control.bg diff --git a/lib/LibAddonMenu-2.0/controls/texture.lua b/lib/LibAddonMenu-2.0/controls/texture.lua index 711c6fd..077862e 100644 --- a/lib/LibAddonMenu-2.0/controls/texture.lua +++ b/lib/LibAddonMenu-2.0/controls/texture.lua @@ -3,14 +3,14 @@ image = "file/path.dds", imageWidth = 64, --max of 250 for half width, 510 for full imageHeight = 32, --max of 100 - tooltip = "Image's tooltip text.", --(optional) + tooltip = "Image's tooltip text.", -- or string id or function returning a string (optional) width = "full", --or "half" (optional) reference = "MyAddonTexture" --(optional) unique global reference to control } ]] --add texture coords support? -local widgetVersion = 7 +local widgetVersion = 8 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("texture", widgetVersion) then return end @@ -36,7 +36,7 @@ function LAMCreateControl.texture(parent, textureData, controlName) if textureData.tooltip then texture:SetMouseEnabled(true) - texture.data = {tooltipText = LAM.util.GetTooltipText(textureData.tooltip)} + texture.data = {tooltipText = LAM.util.GetStringFromValue(textureData.tooltip)} texture:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) texture:SetHandler("OnMouseEnter", ZO_Options_OnMouseExit) end diff --git a/lib/LibStub/LibStub.lua b/lib/LibStub/LibStub.lua index 2c56077..0e6bf67 100644 --- a/lib/LibStub/LibStub.lua +++ b/lib/LibStub/LibStub.lua @@ -3,7 +3,7 @@ -- LibStub developed for World of Warcraft by above members of the WowAce community. -- Ported to Elder Scrolls Online by Seerah -local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 3 +local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 4 local LibStub = _G[LIBSTUB_MAJOR] local strformat = string.format @@ -34,3 +34,5 @@ if not LibStub or LibStub.minor < LIBSTUB_MINOR then function LibStub:IterateLibraries() return pairs(self.libs) end setmetatable(LibStub, { __call = LibStub.GetLibrary }) end + +LibStub.SILENT = true \ No newline at end of file