diff --git a/libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua b/libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua index 2cdb271..2b5ceec 100644 --- a/libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua +++ b/libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua @@ -4,7 +4,7 @@ --Register LAM with LibStub -local MAJOR, MINOR = "LibAddonMenu-2.0", 21 +local MAJOR, MINOR = "LibAddonMenu-2.0", 22 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 @@ -120,11 +120,19 @@ local function RequestRefreshIfNeeded(control) end end +local function GetTopPanel(panel) + while panel.panel and panel.panel ~= panel do + panel = panel.panel + end + return panel +end + local function RegisterForRefreshIfNeeded(control) -- if our parent window wants to refresh controls, then add this to the list - local panelData = control.panel.data + local panel = GetTopPanel(control.panel) + local panelData = panel.data if panelData.registerForRefresh or panelData.registerForDefaults then - tinsert(control.panel.controlsToRefresh, control) + tinsert(panel.controlsToRefresh, control) end end @@ -160,6 +168,48 @@ local function ShowConfirmationDialog(title, body, callback) ZO_Dialogs_ShowDialog(LAM_CONFIRM_DIALOG) end +local function UpdateWarning(control) + local warning = util.GetStringFromValue(control.data.warning) + if not warning then + control.warning:SetHidden(true) + else + control.warning.data = {tooltipText = warning} + control.warning:SetHidden(false) + end +end + +local localization = { + en = { + PANEL_NAME = "Addons", + AUTHOR = string.format("%s: <<X:1>>", GetString(SI_ADDON_MANAGER_AUTHOR)), -- "Author: <<X:1>>" + VERSION = "Version: <<X:1>>", + WEBSITE = "Visit Website", + PANEL_INFO_FONT = "$(CHAT_FONT)|14|soft-shadow-thin", + }, + fr = { -- provided by Ayantir + PANEL_NAME = "Extensions", + WEBSITE = "Visiter le site Web", + }, + de = { -- provided by sirinsidiator + PANEL_NAME = "Erweiterungen", + WEBSITE = "Webseite besuchen", + }, + ru = { -- provided by TERAB1T + PANEL_NAME = "Дополнения", + VERSION = "Версия: <<X:1>>", + WEBSITE = "Посетить сайт", + PANEL_INFO_FONT = "RuESO/fonts/Univers57.otf|14|soft-shadow-thin", + }, + es = { -- provided by silvereyes333 + WEBSITE = "Vaya al sitio web", + }, + jp = { -- provided by k0ta0uchi + PANEL_NAME = "アドオン設定", + WEBSITE = "ウェブサイトを見る", + }, +} + +util.L = ZO_ShallowTableCopy(localization[GetCVar("Language.2")], localization["en"]) util.GetTooltipText = GetStringFromValue -- deprecated, use util.GetStringFromValue instead util.GetStringFromValue = GetStringFromValue util.GetDefaultValue = GetDefaultValue @@ -167,7 +217,9 @@ util.CreateBaseControl = CreateBaseControl util.CreateLabelAndContainerControl = CreateLabelAndContainerControl util.RequestRefreshIfNeeded = RequestRefreshIfNeeded util.RegisterForRefreshIfNeeded = RegisterForRefreshIfNeeded +util.GetTopPanel = GetTopPanel util.ShowConfirmationDialog = ShowConfirmationDialog +util.UpdateWarning = UpdateWarning local ADDON_DATA_TYPE = 1 local RESELECTING_DURING_REBUILD = true @@ -578,26 +630,12 @@ function lam:RegisterOptionControls(addonID, optionsTable) --optionsTable = {sli addonToOptionsMap[addonID] = optionsTable end - --INTERNAL FUNCTION --creates LAM's Addon Settings entry in ZO_GameMenu local function CreateAddonSettingsMenuEntry() - --Russian for TERAB1T's RuESO addon, which creates an "ru" locale - --game font does not support Cyrillic, so they are using custom fonts + extended latin charset - --Spanish provided by Luisen75 for their translation project - --Japanese provided by k0ta0uchi - local controlPanelNames = { - en = "Addon Settings", - fr = "Extensions", - de = "Erweiterungen", - ru = "Îacòpoéêè äoïoìîeîèé", - es = "Configura Addons", - jp = "アドオン設定", - } - local panelData = { id = KEYBOARD_OPTIONS.currentPanelId, - name = controlPanelNames[GetCVar("Language.2")] or controlPanelNames["en"], + name = util.L["PANEL_NAME"], } KEYBOARD_OPTIONS.currentPanelId = panelData.id + 1 diff --git a/libs/LibAddonMenu-2.0/controls/button.lua b/libs/LibAddonMenu-2.0/controls/button.lua index 9bf5c01..82b5032 100644 --- a/libs/LibAddonMenu-2.0/controls/button.lua +++ b/libs/LibAddonMenu-2.0/controls/button.lua @@ -11,7 +11,7 @@ reference = "MyAddonButton", -- unique global reference to control (optional) } ]] -local widgetVersion = 10 +local widgetVersion = 11 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("button", widgetVersion) then return end @@ -73,10 +73,11 @@ function LAMCreateControl.button(parent, buttonData, controlName) end end) - if buttonData.warning then + if buttonData.warning ~= nil then control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") control.warning:SetAnchor(RIGHT, button, LEFT, -5, 0) - control.warning.data = {tooltipText = LAM.util.GetStringFromValue(buttonData.warning)} + control.UpdateWarning = LAM.util.UpdateWarning + control:UpdateWarning() end if buttonData.disabled ~= nil then diff --git a/libs/LibAddonMenu-2.0/controls/checkbox.lua b/libs/LibAddonMenu-2.0/controls/checkbox.lua index 6e34fec..5a55267 100644 --- a/libs/LibAddonMenu-2.0/controls/checkbox.lua +++ b/libs/LibAddonMenu-2.0/controls/checkbox.lua @@ -12,7 +12,7 @@ } ]] -local widgetVersion = 12 +local widgetVersion = 13 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("checkbox", widgetVersion) then return end @@ -118,10 +118,11 @@ function LAMCreateControl.checkbox(parent, checkboxData, controlName) control.checkedText = GetString(SI_CHECK_BUTTON_ON):upper() control.uncheckedText = GetString(SI_CHECK_BUTTON_OFF):upper() - if checkboxData.warning then + if checkboxData.warning ~= nil then control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") control.warning:SetAnchor(RIGHT, checkbox, LEFT, -5, 0) - control.warning.data = {tooltipText = LAM.util.GetStringFromValue(checkboxData.warning)} + control.UpdateWarning = LAM.util.UpdateWarning + control:UpdateWarning() end control.data.tooltipText = LAM.util.GetStringFromValue(checkboxData.tooltip) diff --git a/libs/LibAddonMenu-2.0/controls/colorpicker.lua b/libs/LibAddonMenu-2.0/controls/colorpicker.lua index eb5855a..3d06f5e 100644 --- a/libs/LibAddonMenu-2.0/controls/colorpicker.lua +++ b/libs/LibAddonMenu-2.0/controls/colorpicker.lua @@ -12,7 +12,7 @@ } ]] -local widgetVersion = 11 +local widgetVersion = 12 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("colorpicker", widgetVersion) then return end @@ -82,10 +82,11 @@ function LAMCreateControl.colorpicker(parent, colorpickerData, controlName) end end) - if colorpickerData.warning then + if colorpickerData.warning ~= nil then control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") control.warning:SetAnchor(RIGHT, control.color, LEFT, -5, 0) - control.warning.data = {tooltipText = LAM.util.GetStringFromValue(colorpickerData.warning)} + control.UpdateWarning = LAM.util.UpdateWarning + control:UpdateWarning() end control.data.tooltipText = LAM.util.GetStringFromValue(colorpickerData.tooltip) diff --git a/libs/LibAddonMenu-2.0/controls/divider.lua b/libs/LibAddonMenu-2.0/controls/divider.lua new file mode 100644 index 0000000..f54eb32 --- /dev/null +++ b/libs/LibAddonMenu-2.0/controls/divider.lua @@ -0,0 +1,40 @@ +--[[dividerData = { + type = "divider", + width = "full", --or "half" (optional) + height = 10, (optional) + alpha = 0.25, (optional) + reference = "MyAddonDivider" -- unique global reference to control (optional) +} ]] + + +local widgetVersion = 1 +local LAM = LibStub("LibAddonMenu-2.0") +if not LAM:RegisterWidget("divider", widgetVersion) then return end + +local wm = WINDOW_MANAGER + +local MIN_HEIGHT = 10 +local DEFAULT_ALPHA = 0.25 +function LAMCreateControl.divider(parent, dividerData, controlName) + local control = LAM.util.CreateBaseControl(parent, dividerData, controlName) + local isHalfWidth = control.isHalfWidth + local width = control:GetWidth() + local height = dividerData.height + if not height or type(height) ~= "numeric" or height < MIN_HEIGHT then + height = MIN_HEIGHT + end + control:SetDimensions(isHalfWidth and width / 2 or width, height) + + + local alpha = dividerData.alpha + if not alpha or type(alpha) ~= "numeric" or alpha > 1 or alpha < 0 then + alpha = DEFAULT_ALPHA + end + control.divider = wm:CreateControlFromVirtual(nil, control, "ZO_Options_Divider") + local divider = control.divider + divider:SetWidth(isHalfWidth and width / 2 or width) + divider:SetAnchor(TOPLEFT) + divider:SetAlpha(alpha) + + return control +end diff --git a/libs/LibAddonMenu-2.0/controls/dropdown.lua b/libs/LibAddonMenu-2.0/controls/dropdown.lua index 0e5d3e2..6d32954 100644 --- a/libs/LibAddonMenu-2.0/controls/dropdown.lua +++ b/libs/LibAddonMenu-2.0/controls/dropdown.lua @@ -14,7 +14,7 @@ } ]] -local widgetVersion = 13 +local widgetVersion = 14 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("dropdown", widgetVersion) then return end @@ -103,10 +103,11 @@ function LAMCreateControl.dropdown(parent, dropdownData, controlName) dropdown:SetSortOrder(sortOrder == "up" and ZO_SORT_ORDER_UP or ZO_SORT_ORDER_DOWN, sortType == "name" and ZO_SORT_BY_NAME or ZO_SORT_BY_NAME_NUMERIC) end - if dropdownData.warning then + if dropdownData.warning ~= nil then control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") control.warning:SetAnchor(RIGHT, combobox, LEFT, -5, 0) - control.warning.data = {tooltipText = LAM.util.GetStringFromValue(dropdownData.warning)} + control.UpdateWarning = LAM.util.UpdateWarning + control:UpdateWarning() end control.UpdateChoices = UpdateChoices diff --git a/libs/LibAddonMenu-2.0/controls/editbox.lua b/libs/LibAddonMenu-2.0/controls/editbox.lua index d7e2054..3f307f7 100644 --- a/libs/LibAddonMenu-2.0/controls/editbox.lua +++ b/libs/LibAddonMenu-2.0/controls/editbox.lua @@ -14,7 +14,7 @@ } ]] -local widgetVersion = 12 +local widgetVersion = 13 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("editbox", widgetVersion) then return end @@ -130,14 +130,15 @@ function LAMCreateControl.editbox(parent, editboxData, controlName) editbox:SetAnchor(TOPLEFT, container, TOPLEFT, 2, 2) editbox:SetAnchor(BOTTOMRIGHT, container, BOTTOMRIGHT, -2, -2) - if editboxData.warning then + if editboxData.warning ~= nil then control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") if editboxData.isExtraWide then control.warning:SetAnchor(BOTTOMRIGHT, control.bg, TOPRIGHT, 2, 0) else control.warning:SetAnchor(TOPRIGHT, control.bg, TOPLEFT, -5, 0) end - control.warning.data = {tooltipText = LAM.util.GetStringFromValue(editboxData.warning)} + control.UpdateWarning = LAM.util.UpdateWarning + control:UpdateWarning() end control.UpdateValue = UpdateValue diff --git a/libs/LibAddonMenu-2.0/controls/iconpicker.lua b/libs/LibAddonMenu-2.0/controls/iconpicker.lua index df93550..7042b30 100644 --- a/libs/LibAddonMenu-2.0/controls/iconpicker.lua +++ b/libs/LibAddonMenu-2.0/controls/iconpicker.lua @@ -18,7 +18,7 @@ reference = "MyAddonIconPicker" -- unique global reference to control (optional) } ]] -local widgetVersion = 6 +local widgetVersion = 7 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("iconpicker", widgetVersion) then return end @@ -304,7 +304,7 @@ local function UpdateDisabled(control) iconPicker:Clear() end - SetColor(control) + SetColor(control, control.icon.color) if disable then control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) else @@ -408,10 +408,11 @@ function LAMCreateControl.iconpicker(parent, iconpickerData, controlName) mungeOverlay:SetAddressMode(TEX_MODE_WRAP) mungeOverlay:SetAnchorFill() - if iconpickerData.warning then + if iconpickerData.warning ~= nil then control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") control.warning:SetAnchor(RIGHT, control.container, LEFT, -5, 0) - control.warning.data = {tooltipText = LAM.util.GetStringFromValue(iconpickerData.warning)} + control.UpdateWarning = LAM.util.UpdateWarning + control:UpdateWarning() end control.UpdateChoices = UpdateChoices diff --git a/libs/LibAddonMenu-2.0/controls/panel.lua b/libs/LibAddonMenu-2.0/controls/panel.lua index 124f9fe..2bf9dfa 100644 --- a/libs/LibAddonMenu-2.0/controls/panel.lua +++ b/libs/LibAddonMenu-2.0/controls/panel.lua @@ -4,6 +4,7 @@ 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) + website = "http://www.esoui.com/downloads/info7-LibAddonMenu.html", -- URL of website where the addon can be updated (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) @@ -12,7 +13,7 @@ } ]] -local widgetVersion = 10 +local widgetVersion = 11 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("panel", widgetVersion) then return end @@ -20,17 +21,20 @@ local wm = WINDOW_MANAGER local cm = CALLBACK_MANAGER local function RefreshPanel(control) - local panel = control.panel or control --callback can be fired by a single control or by the panel showing + local panel = LAM.util.GetTopPanel(control) --callback can be fired by a single control, by the panel showing or by a nested submenu local panelControls = panel.controlsToRefresh for i = 1, #panelControls do - local updateControl = panelControls[i] + local updateControl = panelControls[i] if updateControl ~= control and updateControl.UpdateValue then updateControl:UpdateValue() end if updateControl.UpdateDisabled then updateControl:UpdateDisabled() end + if updateControl.UpdateWarning then + updateControl:UpdateWarning() + end end end @@ -72,6 +76,10 @@ ESO_Dialogs["LAM_DEFAULTS"] = { local callbackRegistered = false LAMCreateControl.scrollCount = LAMCreateControl.scrollCount or 1 +local SEPARATOR = " - " +local LINK_COLOR = ZO_ColorDef:New("5959D5") +local LINK_MOUSE_OVER_COLOR = ZO_ColorDef:New("B8B8D3") + function LAMCreateControl.panel(parent, panelData, controlName) local control = wm:CreateControl(controlName, parent, CT_CONTROL) @@ -83,15 +91,37 @@ function LAMCreateControl.panel(parent, panelData, controlName) if panelData.author or panelData.version then control.info = wm:CreateControl(nil, control, CT_LABEL) local info = control.info - info:SetFont("$(CHAT_FONT)|14|soft-shadow-thin") + info:SetFont(LAM.util.L["PANEL_INFO_FONT"]) info:SetAnchor(TOPLEFT, label, BOTTOMLEFT, 0, -2) - if panelData.author and panelData.version then - 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), LAM.util.GetStringFromValue(panelData.author))) + + local output = {} + if panelData.author then + output[#output + 1] = zo_strformat(LAM.util.L["AUTHOR"], LAM.util.GetStringFromValue(panelData.author)) + end + if panelData.version then + output[#output + 1] = zo_strformat(LAM.util.L["VERSION"], LAM.util.GetStringFromValue(panelData.version)) + end + info:SetText(table.concat(output, SEPARATOR)) + end + + if panelData.website then + control.website = wm:CreateControl(nil, control, CT_BUTTON) + local website = control.website + website:SetClickSound("Click") + website:SetFont(LAM.util.L["PANEL_INFO_FONT"]) + website:SetNormalFontColor(LINK_COLOR:UnpackRGBA()) + website:SetMouseOverFontColor(LINK_MOUSE_OVER_COLOR:UnpackRGBA()) + if(control.info) then + website:SetAnchor(TOPLEFT, control.info, TOPRIGHT, 0, 0) + website:SetText(string.format("|cffffff%s|r%s", SEPARATOR, LAM.util.L["WEBSITE"])) else - info:SetText("Version: " .. LAM.util.GetStringFromValue(panelData.version)) + website:SetAnchor(TOPLEFT, label, BOTTOMLEFT, 0, -2) + website:SetText(LAM.util.L["WEBSITE"]) end + website:SetDimensions(website:GetLabelControl():GetTextDimensions()) + website:SetHandler("OnClicked", function() + RequestOpenUnsafeURL(panelData.website) + end) end control.container = wm:CreateControlFromVirtual("LAMAddonPanelContainer"..LAMCreateControl.scrollCount, control, "ZO_ScrollContainer") @@ -107,7 +137,6 @@ function LAMCreateControl.panel(parent, panelData, controlName) local defaultButton = control.defaultButton defaultButton:SetFont("ZoFontDialogKeybindDescription") defaultButton:SetHorizontalAlignment(TEXT_ALIGN_LEFT) - --defaultButton:SetText("Reset To Defaults") defaultButton:SetText(GetString(SI_OPTIONS_DEFAULTS)) defaultButton:SetDimensions(200, 30) defaultButton:SetAnchor(TOPLEFT, control, BOTTOMLEFT, 0, 2) diff --git a/libs/LibAddonMenu-2.0/controls/separator.dds b/libs/LibAddonMenu-2.0/controls/separator.dds deleted file mode 100644 index 02bb2ab..0000000 Binary files a/libs/LibAddonMenu-2.0/controls/separator.dds and /dev/null differ diff --git a/libs/LibAddonMenu-2.0/controls/slider.lua b/libs/LibAddonMenu-2.0/controls/slider.lua index aef9438..fe339ba 100644 --- a/libs/LibAddonMenu-2.0/controls/slider.lua +++ b/libs/LibAddonMenu-2.0/controls/slider.lua @@ -18,7 +18,7 @@ reference = "MyAddonSlider" -- unique global reference to control (optional) } ]] -local widgetVersion = 10 +local widgetVersion = 11 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("slider", widgetVersion) then return end @@ -96,7 +96,7 @@ function LAMCreateControl.slider(parent, sliderData, controlName) local maxValue = sliderData.max slider:SetMinMax(minValue, maxValue) slider:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseEnter(control) end) - slider:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseExit(control) end) + slider:SetHandler("OnMouseExit", function() ZO_Options_OnMouseExit(control) end) slider.bg = wm:CreateControl(nil, slider, CT_BACKDROP) local bg = slider.bg @@ -161,7 +161,9 @@ function LAMCreateControl.slider(parent, sliderData, controlName) control:UpdateValue(false, value) end) slidervalue:SetHandler("OnTextChanged", function(self) - local value = tonumber(self:GetText()) + local input = self:GetText() + if(#input > 1 and not input:sub(-1):match("[0-9]")) then return end + local value = tonumber(input) if(value) then HandleValueChanged(value) end @@ -182,14 +184,16 @@ function LAMCreateControl.slider(parent, sliderData, controlName) control:UpdateValue(false, value) end) slider:SetHandler("OnMouseWheel", function(self, value) + if(not self:GetEnabled()) then return end local new_value = (tonumber(slidervalue:GetText()) or sliderData.min or 0) + ((sliderData.step or 1) * value) control:UpdateValue(false, new_value) end) - if sliderData.warning then + if sliderData.warning ~= nil then control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") control.warning:SetAnchor(RIGHT, slider, LEFT, -5, 0) - control.warning.data = {tooltipText = LAM.util.GetStringFromValue(sliderData.warning)} + control.UpdateWarning = LAM.util.UpdateWarning + control:UpdateWarning() end control.UpdateValue = UpdateValue diff --git a/libs/LibAddonMenu-2.0/controls/texture.lua b/libs/LibAddonMenu-2.0/controls/texture.lua index a42a29b..29dda7c 100644 --- a/libs/LibAddonMenu-2.0/controls/texture.lua +++ b/libs/LibAddonMenu-2.0/controls/texture.lua @@ -10,7 +10,7 @@ --add texture coords support? -local widgetVersion = 8 +local widgetVersion = 9 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("texture", widgetVersion) then return end @@ -38,7 +38,7 @@ function LAMCreateControl.texture(parent, textureData, controlName) texture:SetMouseEnabled(true) texture.data = {tooltipText = LAM.util.GetStringFromValue(textureData.tooltip)} texture:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - texture:SetHandler("OnMouseEnter", ZO_Options_OnMouseExit) + texture:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) end return control