From 975f5d4371db03349e6a6b18a8b2111dc55529ef Mon Sep 17 00:00:00 2001 From: Florian Brinker Date: Sat, 26 Oct 2019 21:38:00 +0200 Subject: [PATCH 1/6] Update Api Version --- AchievementInfo.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AchievementInfo.txt b/AchievementInfo.txt index c541203..49b9e7a 100644 --- a/AchievementInfo.txt +++ b/AchievementInfo.txt @@ -5,7 +5,7 @@ ## Author: |c87B7CCAsto|r, @Astarax ## Contact: mail@coded-with-heart.com -## APIVersion: 100028 +## APIVersion: 100029 ## SavedVariables: ACHIEVEMENT_INFO_DB ## OptionalDependsOn: LibAddonMenu-2.0, LibStub -- 2.45.2 From 458fd2b70a88f86524fc17c33c52a66202e74691 Mon Sep 17 00:00:00 2001 From: Florian Brinker Date: Sat, 26 Oct 2019 21:50:15 +0200 Subject: [PATCH 2/6] Added .drone.status for VSCode Extension --- .drone.status | 3 +++ .drone.yml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 .drone.status diff --git a/.drone.status b/.drone.status new file mode 100644 index 0000000..9fd0140 --- /dev/null +++ b/.drone.status @@ -0,0 +1,3 @@ + { + "url": "https://drone.f-brinker.de/fbrinker/elderscrolls-addon-achievementInfo/" + } \ No newline at end of file diff --git a/.drone.yml b/.drone.yml index e7b9b54..8cfd6c0 100644 --- a/.drone.yml +++ b/.drone.yml @@ -27,7 +27,7 @@ steps: commands: - apk update && apk add --no-cache zip # Delete unneeded files/dirs - - rm -rf sources/{.git,.drone.yml,.luacheckrc} + - rm -rf sources/{.git,.drone.*,.luacheckrc} # Set Version and AddonVersion - export VERSION=$DRONE_TAG - export ADDON_VERSION=$(echo $DRONE_TAG | sed -E 's/(0|)\.//g') -- 2.45.2 From 02cbf2cd2b9178d62642eb1150db92c6256d324d Mon Sep 17 00:00:00 2001 From: Florian Brinker Date: Sat, 26 Oct 2019 22:14:39 +0200 Subject: [PATCH 3/6] Updated Dependencies --- Libs/LibAddonMenu-2.0.txt | 10 +- Libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua | 123 ++++++++++++++---- Libs/LibAddonMenu-2.0/controls/button.lua | 8 +- Libs/LibAddonMenu-2.0/controls/checkbox.lua | 2 +- .../LibAddonMenu-2.0/controls/colorpicker.lua | 18 ++- Libs/LibAddonMenu-2.0/controls/custom.lua | 6 +- .../LibAddonMenu-2.0/controls/description.lua | 40 +++++- Libs/LibAddonMenu-2.0/controls/divider.lua | 6 +- Libs/LibAddonMenu-2.0/controls/dropdown.lua | 119 +++++++++++------ Libs/LibAddonMenu-2.0/controls/editbox.lua | 8 +- Libs/LibAddonMenu-2.0/controls/header.lua | 2 +- Libs/LibAddonMenu-2.0/controls/iconpicker.lua | 4 +- Libs/LibAddonMenu-2.0/controls/panel.lua | 86 ++++++++---- Libs/LibAddonMenu-2.0/controls/slider.lua | 18 ++- Libs/LibAddonMenu-2.0/controls/submenu.lua | 94 +++++++++++-- Libs/LibAddonMenu-2.0/controls/texture.lua | 10 +- Libs/LibStub/LibStub.lua | 2 +- 17 files changed, 418 insertions(+), 138 deletions(-) diff --git a/Libs/LibAddonMenu-2.0.txt b/Libs/LibAddonMenu-2.0.txt index a2f6285..f8007e8 100644 --- a/Libs/LibAddonMenu-2.0.txt +++ b/Libs/LibAddonMenu-2.0.txt @@ -1,9 +1,11 @@ -## APIVersion: 100022 100023 +## APIVersion: 100029 100030 ## Title: LibAddonMenu-2.0 -## Version: 2.0 r26 -## AddOnVersion: 26 +## Version: 2.0 r30 +## AddOnVersion: 30 +## IsLibrary: true +## OptionalDependsOn: LibStub LibDebugLogger ## Author: Seerah, sirinsidiator, et al. -## Contributors: votan, merlight, Garkin, Randactyl, KuroiLight, silvereyes333, Baertram, kyoma +## Contributors: votan, merlight, Garkin, Randactyl, KuroiLight, silvereyes333, Baertram, kyoma, klingo, phuein ## Description: A library to aid in the creation of option panels. ## ## This Add-on is not created by, affiliated with or sponsored by ZeniMax Media Inc. or its affiliates. diff --git a/Libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua b/Libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua index 1638383..e539759 100644 --- a/Libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua +++ b/Libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua @@ -4,9 +4,10 @@ --Register LAM with LibStub -local MAJOR, MINOR = "LibAddonMenu-2.0", 26 +local MAJOR, MINOR = "LibAddonMenu-2.0", 30 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 +LibAddonMenu2 = lam local messages = {} local MESSAGE_PREFIX = "[LAM2] " @@ -25,6 +26,11 @@ local function FlushMessages() messages = {} end +local logger +if LibDebugLogger then + logger = LibDebugLogger(MAJOR) +end + if LAMSettingsPanelCreated and not LAMCompatibilityWarning then PrintLater("An old version of LibAddonMenu with compatibility issues was detected. For more information on how to proceed search for LibAddonMenu on esoui.com") LAMCompatibilityWarning = true @@ -72,6 +78,10 @@ local function GetStringFromValue(value) return value end +local function GetColorForState(disabled) + return disabled and ZO_DEFAULT_DISABLED_COLOR or ZO_DEFAULT_ENABLED_COLOR +end + local function CreateBaseControl(parent, controlData, controlName) local control = wm:CreateControl(controlName or controlData.reference, parent.scroll or parent, CT_CONTROL) control.panel = parent.panel or parent -- if this is in a submenu, panel is the submenu's parent @@ -144,12 +154,14 @@ local function RefreshReloadUIButton() end end - lam.applyButton:SetHidden(not lam.requiresReload) + if lam.applyButton then + lam.applyButton:SetHidden(not lam.requiresReload) + end end local function RequestRefreshIfNeeded(control) -- if our parent window wants to refresh controls, then fire the callback - local panel = GetTopPanel(control.panel) + local panel = GetTopPanel(control) local panelData = panel.data if panelData.registerForRefresh then cm:FireCallbacks("LAM-RefreshPanel", control) @@ -313,9 +325,9 @@ local function UpdateWarning(control) if control.data.requiresReload then if not warning then - warning = string.format("|cff0000%s", util.L["RELOAD_UI_WARNING"]) + warning = string.format("%s", util.L["RELOAD_UI_WARNING"]) else - warning = string.format("%s\n\n|cff0000%s", warning, util.L["RELOAD_UI_WARNING"]) + warning = string.format("%s\n\n%s", warning, util.L["RELOAD_UI_WARNING"]) end end @@ -333,10 +345,13 @@ local localization = { AUTHOR = string.format("%s: <>", GetString(SI_ADDON_MANAGER_AUTHOR)), -- "Author: <>" VERSION = "Version: <>", WEBSITE = "Visit Website", + FEEDBACK = "Feedback", + TRANSLATION = "Translation", + DONATION = "Donate", PANEL_INFO_FONT = "$(CHAT_FONT)|14|soft-shadow-thin", - RELOAD_UI_WARNING = "Changes to this setting require an UI reload in order to take effect.", - RELOAD_DIALOG_TITLE = "UI Reload required", - RELOAD_DIALOG_TEXT = "Some changes require an UI reload in order to take effect. Do you want to reload now or discard the changes?", + RELOAD_UI_WARNING = "Changes to this setting require a UI reload in order to take effect.", + RELOAD_DIALOG_TITLE = "UI Reload Required", + RELOAD_DIALOG_TEXT = "Some changes require a UI reload in order to take effect. Do you want to reload now or discard the changes?", RELOAD_DIALOG_RELOAD_BUTTON = "Reload", RELOAD_DIALOG_DISCARD_BUTTON = "Discard", }, @@ -344,6 +359,9 @@ local localization = { PANEL_NAME = "Addon", VERSION = "Versione: <>", WEBSITE = "Visita il Sitoweb", + FEEDBACK = "Feedback", + TRANSLATION = "Traduzione", + DONATION = "Donare", RELOAD_UI_WARNING = "Cambiare questa impostazione richiede un Ricarica UI al fine che faccia effetto.", RELOAD_DIALOG_TITLE = "Ricarica UI richiesto", RELOAD_DIALOG_TEXT = "Alcune modifiche richiedono un Ricarica UI al fine che facciano effetto. Sei sicuro di voler ricaricare ora o di voler annullare le modifiche?", @@ -353,6 +371,9 @@ local localization = { fr = { -- provided by Ayantir PANEL_NAME = "Extensions", WEBSITE = "Visiter le site Web", + FEEDBACK = "Réaction", + TRANSLATION = "Traduction", + DONATION = "Donner", RELOAD_UI_WARNING = "La modification de ce paramètre requiert un rechargement de l'UI pour qu'il soit pris en compte.", RELOAD_DIALOG_TITLE = "Reload UI requis", RELOAD_DIALOG_TEXT = "Certaines modifications requièrent un rechargement de l'UI pour qu'ils soient pris en compte. Souhaitez-vous recharger l'interface maintenant ou annuler les modifications ?", @@ -362,6 +383,9 @@ local localization = { de = { -- provided by sirinsidiator PANEL_NAME = "Erweiterungen", WEBSITE = "Webseite besuchen", + FEEDBACK = "Feedback", + TRANSLATION = "Übersetzung", + DONATION = "Spende", RELOAD_UI_WARNING = "Änderungen an dieser Option werden erst übernommen nachdem die Benutzeroberfläche neu geladen wird.", RELOAD_DIALOG_TITLE = "Neuladen benötigt", RELOAD_DIALOG_TEXT = "Einige Änderungen werden erst übernommen nachdem die Benutzeroberfläche neu geladen wird. Wollt Ihr sie jetzt neu laden oder die Änderungen verwerfen?", @@ -372,6 +396,9 @@ local localization = { PANEL_NAME = "Дополнения", VERSION = "Версия: <>", WEBSITE = "Посетить сайт", + FEEDBACK = "отзыв", + TRANSLATION = "Перевод", + DONATION = "жертвовать", PANEL_INFO_FONT = "RuESO/fonts/Univers57.otf|14|soft-shadow-thin", RELOAD_UI_WARNING = "Для применения этой настройки необходима перезагрузка интерфейса.", RELOAD_DIALOG_TITLE = "Необходима перезагрузка интерфейса", @@ -383,6 +410,9 @@ local localization = { PANEL_NAME = "Configuración", VERSION = "Versión: <>", WEBSITE = "Visita la página web", + FEEDBACK = "Reaccion", + TRANSLATION = "Traducción", + DONATION = "Donar", RELOAD_UI_WARNING = "Cambiar este ajuste recargará la interfaz del usuario.", RELOAD_DIALOG_TITLE = "Requiere recargar la interfaz", RELOAD_DIALOG_TEXT = "Algunos cambios requieren recargar la interfaz para poder aplicarse. Quieres aplicar los cambios y recargar la interfaz?", @@ -392,6 +422,9 @@ local localization = { jp = { -- provided by k0ta0uchi PANEL_NAME = "アドオン設定", WEBSITE = "ウェブサイトを見る", + FEEDBACK = "フィードバック", + TRANSLATION = "訳書", + DONATION = "寄贈する", }, zh = { -- provided by bssthu PANEL_NAME = "插件", @@ -409,34 +442,49 @@ local localization = { RELOAD_DIALOG_RELOAD_BUTTON = "Przeładuj", RELOAD_DIALOG_DISCARD_BUTTON = "Porzuć", }, - kr = { -- provided by p.walker - PANEL_NAME = "蝠盜蠨", - VERSION = "纄訄: <>", - WEBSITE = "裹芬襴钸 縩紸", - PANEL_INFO_FONT = "EsoKR/fonts/Univers57.otf|14|soft-shadow-thin", - RELOAD_UI_WARNING = "襴 茤訕襄 绀溽靘籴 風滼筼 訁袩靘瀰褄靴 UI 苈穜滠遨襴 靄袔革瓈瓤.", - RELOAD_DIALOG_TITLE = "UI 苈穜滠遨 靄袔", - RELOAD_DIALOG_TEXT = "绀溽瘜 茤訕 謑 UI 苈穜滠遨襄 靄袔穜靘璔 芬靭襴 覈蒵瓈瓤. 诀瀈 苈穜滠遨靘蓜溠蒵瓈灌? 蝄瓈籴 绀溽襄 迨莌靘蓜溠蒵瓈灌?", - RELOAD_DIALOG_RELOAD_BUTTON = "苈穜滠遨", - RELOAD_DIALOG_DISCARD_BUTTON = "绀溽迨莌", - }, - br = { -- provided by mlsevero + br = { -- provided by mlsevero & FelipeS11 PANEL_NAME = "Addons", AUTHOR = string.format("%s: <>", GetString(SI_ADDON_MANAGER_AUTHOR)), -- "Autor: <>" VERSION = "Versão: <>", WEBSITE = "Visite o Website", - RELOAD_UI_WARNING = "Mudanças nessa configuração requer a releitura da UI para ter efeito.", - RELOAD_DIALOG_TITLE = "Releitura da UI requerida", - RELOAD_DIALOG_TEXT = "Algumas mudanças requerem a releitura da UI para ter efeito. Você deseja reler agora ou descartar as mudanças?", - RELOAD_DIALOG_RELOAD_BUTTON = "Relê", - RELOAD_DIALOG_DISCARD_BUTTON = "Descarta", + FEEDBACK = "Feedback", + TRANSLATION = "Tradução", + DONATION = "Doação", + RELOAD_UI_WARNING = "Mudanças nessa configuração requerem o recarregamento da UI para ter efeito.", + RELOAD_DIALOG_TITLE = "Recarregamento da UI requerida", + RELOAD_DIALOG_TEXT = "Algumas mudanças requerem o recarregamento da UI para ter efeito. Você deseja recarregar agora ou descartar as mudanças?", + RELOAD_DIALOG_RELOAD_BUTTON = "Recarregar", + RELOAD_DIALOG_DISCARD_BUTTON = "Descartar", }, } -util.L = ZO_ShallowTableCopy(localization[GetCVar("Language.2")] or {}, localization["en"]) +do + local EsoKR = EsoKR + if EsoKR and EsoKR:isKorean() then + util.L = ZO_ShallowTableCopy({ -- provided by whya5448 + PANEL_NAME = EsoKR:E("애드온"), + AUTHOR = string.format("%s: <>", GetString(SI_ADDON_MANAGER_AUTHOR)), -- "Author: <>" + VERSION = EsoKR:E("버전: <>"), + WEBSITE = EsoKR:E("웹사이트 방문"), + FEEDBACK = EsoKR:E("피드백"), + TRANSLATION = EsoKR:E("번역"), + DONATION = EsoKR:E("기부"), + PANEL_INFO_FONT = "EsoKR/fonts/Univers57.otf|14|soft-shadow-thin", + RELOAD_UI_WARNING = EsoKR:E("이 설정을 변경하면 효과를 적용하기위해 UI 새로고침이 필요합니다."), + RELOAD_DIALOG_TITLE = EsoKR:E("UI 새로고침 필요"), + RELOAD_DIALOG_TEXT = EsoKR:E("변경된 설정 중 UI 새로고침을 필요로하는 사항이 있습니다. 지금 새로고침하시겠습니까? 아니면 변경을 취소하시겠습니까?"), + RELOAD_DIALOG_RELOAD_BUTTON = EsoKR:E("새로고침"), + RELOAD_DIALOG_DISCARD_BUTTON = EsoKR:E("변경취소"), + }, localization["en"]) + else + util.L = ZO_ShallowTableCopy(localization[GetCVar("Language.2")] or {}, localization["en"]) + end +end + util.GetTooltipText = GetStringFromValue -- deprecated, use util.GetStringFromValue instead util.GetStringFromValue = GetStringFromValue util.GetDefaultValue = GetDefaultValue +util.GetColorForState = GetColorForState util.CreateBaseControl = CreateBaseControl util.CreateLabelAndContainerControl = CreateLabelAndContainerControl util.RequestRefreshIfNeeded = RequestRefreshIfNeeded @@ -776,6 +824,9 @@ local function CreateOptionsControls(panel) err, anchorOffset, lastAddedControl, wasHalf = CreateAndAnchorWidget(parent, widgetData, offsetX, anchorOffset, lastAddedControl, wasHalf) if err then PrintLater(("Could not create %s '%s' of %s."):format(widgetData.type, GetStringFromValue(widgetData.name or "unnamed"), addonID)) + if logger then + logger:Error(err) + end end if isSubmenu then @@ -833,6 +884,22 @@ local function ToggleAddonPanels(panel) --called in OnShow of newly shown panel end local CheckSafetyAndInitialize +local function ShowSetHandlerWarning(panel, handler) + local hint + if(handler == "OnShow" or handler == "OnEffectivelyShown") then + hint = "'LAM-PanelControlsCreated' or 'LAM-PanelOpened'" + elseif(handler == "OnHide" or handler == "OnEffectivelyHidden") then + hint = "'LAM-PanelClosed'" + end + + if hint then + local message = ("Setting a handler on a panel is not recommended. Use the global callback %s instead. (%s on %s)"):format(hint, handler, panel.data.name) + PrintLater(message) + if logger then + logger:Warn(message) + end + end +end --METHOD: REGISTER ADDON PANEL --registers your addon with LibAddonMenu and creates a panel @@ -845,7 +912,8 @@ function lam:RegisterAddonPanel(addonID, panelData) local panel = lamcc.panel(container, panelData, addonID) --addonID==global name of panel panel:SetHidden(true) panel:SetAnchorFill(container) - panel:SetHandler("OnShow", ToggleAddonPanels) + panel:SetHandler("OnEffectivelyShown", ToggleAddonPanels) + ZO_PreHook(panel, "SetHandler", ShowSetHandlerWarning) local function stripMarkup(str) return str:gsub("|[Cc]%x%x%x%x%x%x", ""):gsub("|[Rr]", "") @@ -897,6 +965,7 @@ local function CreateAddonSettingsMenuEntry() KEYBOARD_OPTIONS.currentPanelId = panelData.id + 1 KEYBOARD_OPTIONS.panelNames[panelData.id] = panelData.name + KEYBOARD_OPTIONS.controlTable[panelData.id] = {} lam.panelId = panelData.id diff --git a/Libs/LibAddonMenu-2.0/controls/button.lua b/Libs/LibAddonMenu-2.0/controls/button.lua index be55dfc..605691e 100644 --- a/Libs/LibAddonMenu-2.0/controls/button.lua +++ b/Libs/LibAddonMenu-2.0/controls/button.lua @@ -3,11 +3,11 @@ 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) + width = "full", -- or "half" (optional) + disabled = function() return db.someBooleanSetting end, -- or boolean (optional) + icon = "icon\\path.dds", -- (optional) isDangerous = false, -- boolean, if set to true, the button text will be red and a confirmation dialog with the button label and warning text will show on click before the callback is executed (optional) - warning = "Will need to reload the UI.", --(optional) + warning = "Will need to reload the UI.", -- (optional) reference = "MyAddonButton", -- unique global reference to control (optional) } ]] diff --git a/Libs/LibAddonMenu-2.0/controls/checkbox.lua b/Libs/LibAddonMenu-2.0/controls/checkbox.lua index 84710de..4651f57 100644 --- a/Libs/LibAddonMenu-2.0/controls/checkbox.lua +++ b/Libs/LibAddonMenu-2.0/controls/checkbox.lua @@ -5,7 +5,7 @@ setFunc = function(value) db.var = value doStuff() end, 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) + disabled = function() return db.someBooleanSetting end, -- or boolean (optional) warning = "May cause permanent awesomeness.", -- or string id or function returning a string (optional) requiresReload = false, -- boolean, if set to true, the warning text will contain a notice that changes are only applied after an UI reload and any change to the value will make the "Apply Settings" button appear on the panel which will reload the UI when pressed (optional) default = defaults.var, -- a boolean or function that returns a boolean (optional) diff --git a/Libs/LibAddonMenu-2.0/controls/colorpicker.lua b/Libs/LibAddonMenu-2.0/controls/colorpicker.lua index db21260..0fad0c3 100644 --- a/Libs/LibAddonMenu-2.0/controls/colorpicker.lua +++ b/Libs/LibAddonMenu-2.0/controls/colorpicker.lua @@ -1,19 +1,19 @@ --[[colorpickerData = { type = "colorpicker", 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) + 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) + width = "full", -- or "half" (optional) + disabled = function() return db.someBooleanSetting end, -- or boolean (optional) warning = "May cause permanent awesomeness.", -- or string id or function returning a string (optional) requiresReload = false, -- boolean, if set to true, the warning text will contain a notice that changes are only applied after an UI reload and any change to the value will make the "Apply Settings" button appear on the panel which will reload the UI when pressed (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 + 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 = 13 +local widgetVersion = 14 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("colorpicker", widgetVersion) then return end @@ -79,7 +79,11 @@ function LAMCreateControl.colorpicker(parent, colorpickerData, controlName) if upInside then local r, g, b, a = colorpickerData.getFunc() - COLOR_PICKER:Show(ColorPickerCallback, r, g, b, a, LAM.util.GetStringFromValue(colorpickerData.name)) + if IsInGamepadPreferredMode() then + COLOR_PICKER_GAMEPAD:Show(ColorPickerCallback, r, g, b, a) + else + COLOR_PICKER:Show(ColorPickerCallback, r, g, b, a) + end end end) diff --git a/Libs/LibAddonMenu-2.0/controls/custom.lua b/Libs/LibAddonMenu-2.0/controls/custom.lua index 5d6111c..a941646 100644 --- a/Libs/LibAddonMenu-2.0/controls/custom.lua +++ b/Libs/LibAddonMenu-2.0/controls/custom.lua @@ -1,8 +1,8 @@ --[[customData = { type = "custom", - reference = "MyAddonCustomControl", --(optional) unique name for your control to use as reference - refreshFunc = function(customControl) end, --(optional) function to call when panel/controls refresh - width = "full", --or "half" (optional) + reference = "MyAddonCustomControl", -- unique name for your control to use as reference (optional) + refreshFunc = function(customControl) end, -- function to call when panel/controls refresh (optional) + width = "full", -- or "half" (optional) } ]] local widgetVersion = 7 diff --git a/Libs/LibAddonMenu-2.0/controls/description.lua b/Libs/LibAddonMenu-2.0/controls/description.lua index 27c7192..eaffa06 100644 --- a/Libs/LibAddonMenu-2.0/controls/description.lua +++ b/Libs/LibAddonMenu-2.0/controls/description.lua @@ -2,17 +2,39 @@ type = "description", 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) + width = "full", -- or "half" (optional) + disabled = function() return db.someBooleanSetting end, -- or boolean (optional) + enableLinks = nil, -- or true for default tooltips, or function OnLinkClicked handler (optional) + -- see: https://wiki.esoui.com/UI_XML#OnLinkClicked reference = "MyAddonDescription" -- unique global reference to control (optional) } ]] -local widgetVersion = 8 +local widgetVersion = 10 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("description", widgetVersion) then return end local wm = WINDOW_MANAGER +local GetDefaultValue = LAM.util.GetDefaultValue +local GetColorForState = LAM.util.GetColorForState + +local function OnLinkClicked(control, linkData, linkText, button) + ZO_LinkHandler_OnLinkClicked(linkText, button) +end + +local function UpdateDisabled(control) + local disable = GetDefaultValue(control.data.disabled) + if disable ~= control.disabled then + local color = GetColorForState(disable) + control.desc:SetColor(color:UnpackRGBA()) + if control.title then + control.title:SetColor(color:UnpackRGBA()) + end + control.disabled = disable + end +end + local function UpdateValue(control) if control.title then control.title:SetText(LAM.util.GetStringFromValue(control.data.title)) @@ -50,8 +72,22 @@ function LAMCreateControl.description(parent, descriptionData, controlName) else desc:SetAnchor(TOPLEFT) end + + if descriptionData.enableLinks then + desc:SetMouseEnabled(true) + desc:SetLinkEnabled(true) + if type(descriptionData.enableLinks) == "function" then + desc:SetHandler("OnLinkClicked", descriptionData.enableLinks) + else + desc:SetHandler("OnLinkClicked", OnLinkClicked) + end + end control.UpdateValue = UpdateValue + if descriptionData.disabled ~= nil then + control.UpdateDisabled = UpdateDisabled + control:UpdateDisabled() + end LAM.util.RegisterForRefreshIfNeeded(control) diff --git a/Libs/LibAddonMenu-2.0/controls/divider.lua b/Libs/LibAddonMenu-2.0/controls/divider.lua index b24e2fc..ab015b7 100644 --- a/Libs/LibAddonMenu-2.0/controls/divider.lua +++ b/Libs/LibAddonMenu-2.0/controls/divider.lua @@ -1,8 +1,8 @@ --[[dividerData = { type = "divider", - width = "full", --or "half" (optional) - height = 10, (optional) - alpha = 0.25, (optional) + width = "full", -- or "half" (optional) + height = 10, -- (optional) + alpha = 0.25, -- (optional) reference = "MyAddonDivider" -- unique global reference to control (optional) } ]] diff --git a/Libs/LibAddonMenu-2.0/controls/dropdown.lua b/Libs/LibAddonMenu-2.0/controls/dropdown.lua index c67624a..1722845 100644 --- a/Libs/LibAddonMenu-2.0/controls/dropdown.lua +++ b/Libs/LibAddonMenu-2.0/controls/dropdown.lua @@ -7,10 +7,10 @@ setFunc = function(var) db.var = var doStuff() end, tooltip = "Dropdown's tooltip text.", -- or string id or function returning a string (optional) choicesTooltips = {"tooltip 1", "tooltip 2", "tooltip 3"}, -- or array of string ids or array of functions returning a string (optional) - sort = "name-up", --or "name-down", "numeric-up", "numeric-down", "value-up", "value-down", "numericvalue-up", "numericvalue-down" (optional) - if not provided, list will not be sorted - width = "full", --or "half" (optional) + sort = "name-up", -- or "name-down", "numeric-up", "numeric-down", "value-up", "value-down", "numericvalue-up", "numericvalue-down" (optional) - if not provided, list will not be sorted + width = "full", -- or "half" (optional) scrollable = true, -- boolean or number, if set the dropdown will feature a scroll bar if there are a large amount of choices and limit the visible lines to the specified number or 10 if true is used (optional) - disabled = function() return db.someBooleanSetting end, --or boolean (optional) + disabled = function() return db.someBooleanSetting end, -- or boolean (optional) warning = "May cause permanent awesomeness.", -- or string id or function returning a string (optional) requiresReload = false, -- boolean, if set to true, the warning text will contain a notice that changes are only applied after an UI reload and any change to the value will make the "Apply Settings" button appear on the panel which will reload the UI when pressed (optional) default = defaults.var, -- default value or function that returns the default value (optional) @@ -18,12 +18,13 @@ } ]] -local widgetVersion = 18 +local widgetVersion = 20 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("dropdown", widgetVersion) then return end local wm = WINDOW_MANAGER -local SORT_BY_VALUE = { ["value"] = {} } +local cm = CALLBACK_MANAGER +local SORT_BY_VALUE = { ["value"] = {} } local SORT_BY_VALUE_NUMERIC = { ["value"] = { isNumeric = true } } local SORT_TYPES = { name = ZO_SORT_BY_NAME, @@ -155,11 +156,16 @@ local function GrabSortingInfo(sortInfo) return t end +local ENTRY_ID = 1 +local LAST_ENTRY_ID = 2 +local OFFSET_X_INDEX = 4 local DEFAULT_VISIBLE_ROWS = 10 -local SCROLLABLE_ENTRY_TEMPLATE_HEIGHT = 25 -- same as in zo_combobox.lua -local CONTENT_PADDING = 24 -local SCROLLBAR_PADDING = 16 -local PADDING = GetMenuPadding() / 2 -- half the amount looks closer to the regular dropdown +local SCROLLABLE_ENTRY_TEMPLATE_HEIGHT = ZO_SCROLLABLE_ENTRY_TEMPLATE_HEIGHT +local SCROLLBAR_PADDING = ZO_SCROLL_BAR_WIDTH +local PADDING_X = GetMenuPadding() +local PADDING_Y = ZO_SCROLLABLE_COMBO_BOX_LIST_PADDING_Y +local LABEL_OFFSET_X = 2 +local CONTENT_PADDING = PADDING_X * 4 local ROUNDING_MARGIN = 0.01 -- needed to avoid rare issue with too many anchors processed local ScrollableDropdownHelper = ZO_Object:Subclass() @@ -169,10 +175,10 @@ function ScrollableDropdownHelper:New(...) return object end -function ScrollableDropdownHelper:Initialize(parent, control, visibleRows) +function ScrollableDropdownHelper:Initialize(panel, control, visibleRows) local combobox = control.combobox local dropdown = control.dropdown - self.parent = parent + self.panel = panel self.control = control self.combobox = combobox self.dropdown = dropdown @@ -183,14 +189,16 @@ function ScrollableDropdownHelper:Initialize(parent, control, visibleRows) dropdown.m_dropdown:SetAnchor(TOPLEFT, combobox, BOTTOMLEFT) -- handle dropdown or settingsmenu opening/closing - local function onShow() self:OnShow() end + local function onShow() return self:OnShow() end local function onHide() self:OnHide() end - local function doHide() self:DoHide() end + local function doHide(closedPanel) + if closedPanel == panel then self:DoHide() end + end ZO_PreHook(dropdown, "ShowDropdownOnMouseUp", onShow) ZO_PreHook(dropdown, "HideDropdownInternal", onHide) combobox:SetHandler("OnEffectivelyHidden", onHide) - parent:SetHandler("OnEffectivelyHidden", doHide) + cm:RegisterCallback("LAM-PanelClosed", doHide) -- dont fade entries near the edges local scrollList = dropdown.m_scroll @@ -202,32 +210,32 @@ function ScrollableDropdownHelper:Initialize(parent, control, visibleRows) -- adjust scroll content anchor to mimic menu padding local scroll = dropdown.m_dropdown:GetNamedChild("Scroll") - local anchor1 = {scroll:GetAnchor(0)} - local anchor2 = {scroll:GetAnchor(1)} + local anchor1 = {select(2, scroll:GetAnchor(0))} + local anchor2 = {select(2, scroll:GetAnchor(1))} + anchor1[OFFSET_X_INDEX] = PADDING_X - LABEL_OFFSET_X + anchor2[OFFSET_X_INDEX] = -anchor1[OFFSET_X_INDEX] scroll:ClearAnchors() - scroll:SetAnchor(anchor1[2], anchor1[3], anchor1[4], anchor1[5] + PADDING, anchor1[6] + PADDING) - scroll:SetAnchor(anchor2[2], anchor2[3], anchor2[4], anchor2[5] - PADDING, anchor2[6] - PADDING) + scroll:SetAnchor(unpack(anchor1)) + scroll:SetAnchor(unpack(anchor2)) ZO_ScrollList_Commit(scrollList) - + -- hook mouse enter/exit local function onMouseEnter(control) self:OnMouseEnter(control) end local function onMouseExit(control) self:OnMouseExit(control) end -- adjust row setup to mimic the highlight padding - local dataType1 = ZO_ScrollList_GetDataTypeTable(dropdown.m_scroll, 1) - local dataType2 = ZO_ScrollList_GetDataTypeTable(dropdown.m_scroll, 2) + local dataType1 = ZO_ScrollList_GetDataTypeTable(dropdown.m_scroll, ENTRY_ID) + local dataType2 = ZO_ScrollList_GetDataTypeTable(dropdown.m_scroll, LAST_ENTRY_ID) local oSetup = dataType1.setupCallback -- both types have the same setup function local function SetupEntry(control, data, list) oSetup(control, data, list) - control.m_label:SetAnchor(LEFT, nil, nil, 2) + control.m_label:SetAnchor(LEFT, nil, nil, LABEL_OFFSET_X) + control.m_label:SetAnchor(RIGHT, nil, nil, -LABEL_OFFSET_X) -- no need to store old ones since we have full ownership of our dropdown controls if not control.hookedMouseHandlers then --only do it once per control control.hookedMouseHandlers = true ZO_PreHookHandler(control, "OnMouseEnter", onMouseEnter) ZO_PreHookHandler(control, "OnMouseExit", onMouseExit) - -- we could also just replace the handlers - --control:SetHandler("OnMouseEnter", onMouseEnter) - --control:SetHandler("OnMouseExit", onMouseExit) end end dataType1.setupCallback = SetupEntry @@ -235,24 +243,61 @@ function ScrollableDropdownHelper:Initialize(parent, control, visibleRows) -- adjust dimensions based on entries local scrollContent = scroll:GetNamedChild("Contents") - ZO_PreHook(dropdown, "AddMenuItems", function() - local width = PADDING * 2 + zo_max(self:GetMaxWidth(), combobox:GetWidth()) + dropdown.AddMenuItems = ScrollableDropdownHelper.AddMenuItems + + dropdown.AdjustDimensions = function() local numItems = #dropdown.m_sortedItems + local contentWidth = self:CalculateContentWidth() + CONTENT_PADDING local anchorOffset = 0 if(numItems > self.visibleRows) then - width = width + CONTENT_PADDING + SCROLLBAR_PADDING - anchorOffset = -SCROLLBAR_PADDING numItems = self.visibleRows + contentWidth = contentWidth + SCROLLBAR_PADDING + anchorOffset = -SCROLLBAR_PADDING end - scrollContent:SetAnchor(BOTTOMRIGHT, nil, nil, anchorOffset) - local height = PADDING * 2 + numItems * (SCROLLABLE_ENTRY_TEMPLATE_HEIGHT + dropdown.m_spacing) - dropdown.m_spacing + ROUNDING_MARGIN + + local width = zo_max(contentWidth, dropdown.m_container:GetWidth()) + local height = dropdown:GetEntryTemplateHeightWithSpacing() * numItems - dropdown.m_spacing + (PADDING_Y * 2) + ROUNDING_MARGIN + dropdown.m_dropdown:SetWidth(width) dropdown.m_dropdown:SetHeight(height) - end) + ZO_ScrollList_SetHeight(dropdown.m_scroll, height) + + scrollContent:SetAnchor(BOTTOMRIGHT, nil, nil, anchorOffset) + end +end + +local function CreateScrollableComboBoxEntry(self, item, index, isLast) + item.m_index = index + item.m_owner = self + local entryType = isLast and LAST_ENTRY_ID or ENTRY_ID + local entry = ZO_ScrollList_CreateDataEntry(entryType, item) + + return entry +end + +function ScrollableDropdownHelper.AddMenuItems(self) -- self refers to the ZO_ScrollableComboBox here + ZO_ScrollList_Clear(self.m_scroll) + + local numItems = #self.m_sortedItems + local dataList = ZO_ScrollList_GetDataList(self.m_scroll) + + for i = 1, numItems do + local item = self.m_sortedItems[i] + local entry = CreateScrollableComboBoxEntry(self, item, i, i == numItems) + table.insert(dataList, entry) + end + + self:AdjustDimensions() + + ZO_ScrollList_Commit(self.m_scroll) end function ScrollableDropdownHelper:OnShow() local dropdown = self.dropdown + + -- don't show if there are no entries + if #dropdown.m_sortedItems == 0 then return true end + if dropdown.m_lastParent ~= ZO_Menus then dropdown.m_lastParent = dropdown.m_dropdown:GetParent() dropdown.m_dropdown:SetParent(ZO_Menus) @@ -262,7 +307,7 @@ end function ScrollableDropdownHelper:OnHide() local dropdown = self.dropdown - if dropdown.m_lastParent then + if dropdown.m_lastParent then dropdown.m_dropdown:SetParent(dropdown.m_lastParent) dropdown.m_lastParent = nil end @@ -275,9 +320,9 @@ function ScrollableDropdownHelper:DoHide() end end -function ScrollableDropdownHelper:GetMaxWidth() +function ScrollableDropdownHelper:CalculateContentWidth() local dropdown = self.dropdown - local dataType = ZO_ScrollList_GetDataTypeTable(dropdown.m_scroll, 1) + local dataType = ZO_ScrollList_GetDataTypeTable(dropdown.m_scroll, 1) local dummy = dataType.pool:AcquireObject() dataType.setupCallback(dummy, { @@ -344,8 +389,8 @@ function LAMCreateControl.dropdown(parent, dropdownData, controlName) dropdown:SetSortsItems(false) -- need to sort ourselves in order to be able to sort by value if dropdownData.scrollable then - local visibleRows = type(dropdownData.scrollable) == "number" and dropdownData.scrollable or DEFAULT_VISIBLE_ROWS - control.scrollHelper = ScrollableDropdownHelper:New(parent, control, visibleRows) + local visibleRows = type(dropdownData.scrollable) == "number" and dropdownData.scrollable or DEFAULT_VISIBLE_ROWS + control.scrollHelper = ScrollableDropdownHelper:New(LAM.util.GetTopPanel(parent), control, visibleRows) end ZO_PreHook(dropdown, "UpdateItems", function(self) diff --git a/Libs/LibAddonMenu-2.0/controls/editbox.lua b/Libs/LibAddonMenu-2.0/controls/editbox.lua index bcc6a7c..7c80028 100644 --- a/Libs/LibAddonMenu-2.0/controls/editbox.lua +++ b/Libs/LibAddonMenu-2.0/controls/editbox.lua @@ -4,10 +4,10 @@ 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) + isMultiline = true, -- boolean (optional) + isExtraWide = true, -- boolean (optional) + width = "full", -- or "half" (optional) + disabled = function() return db.someBooleanSetting end, -- or boolean (optional) warning = "May cause permanent awesomeness.", -- or string id or function returning a string (optional) requiresReload = false, -- boolean, if set to true, the warning text will contain a notice that changes are only applied after an UI reload and any change to the value will make the "Apply Settings" button appear on the panel which will reload the UI when pressed (optional) default = defaults.text, -- default value or function that returns the default value (optional) diff --git a/Libs/LibAddonMenu-2.0/controls/header.lua b/Libs/LibAddonMenu-2.0/controls/header.lua index 3290c89..b63b881 100644 --- a/Libs/LibAddonMenu-2.0/controls/header.lua +++ b/Libs/LibAddonMenu-2.0/controls/header.lua @@ -1,7 +1,7 @@ --[[headerData = { type = "header", name = "My Header", -- or string id or function returning a string - width = "full", --or "half" (optional) + width = "full", -- or "half" (optional) reference = "MyAddonHeader" -- unique global reference to control (optional) } ]] diff --git a/Libs/LibAddonMenu-2.0/controls/iconpicker.lua b/Libs/LibAddonMenu-2.0/controls/iconpicker.lua index 3485740..5148552 100644 --- a/Libs/LibAddonMenu-2.0/controls/iconpicker.lua +++ b/Libs/LibAddonMenu-2.0/controls/iconpicker.lua @@ -11,8 +11,8 @@ 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) + beforeShow = function(control, iconPicker) return preventShow end, -- (optional) + disabled = function() return db.someBooleanSetting end, -- or boolean (optional) warning = "May cause permanent awesomeness.", -- or string id or function returning a string (optional) requiresReload = false, -- boolean, if set to true, the warning text will contain a notice that changes are only applied after an UI reload and any change to the value will make the "Apply Settings" button appear on the panel which will reload the UI when pressed (optional) default = defaults.var, -- default value or function that returns the default value (optional) diff --git a/Libs/LibAddonMenu-2.0/controls/panel.lua b/Libs/LibAddonMenu-2.0/controls/panel.lua index d6956d8..514f4be 100644 --- a/Libs/LibAddonMenu-2.0/controls/panel.lua +++ b/Libs/LibAddonMenu-2.0/controls/panel.lua @@ -4,16 +4,19 @@ 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) + website = "http://www.esoui.com/downloads/info7-LibAddonMenu.html", -- URL of website where the addon can be updated or function (optional) + feedback = "https://www.esoui.com/portal.php?uid=5815", -- URL of website where feedback/feature requests/bugs can be reported for the addon or function (optional) + translation = "https://www.esoui.com/portal.php?uid=5815", -- URL of website where translation texts of the addon can be helped with or function (optional) + donation = "http://www.esoui.com/downloads/info7-LibAddonMenu.html", -- URL of website where a donation for the addon author can be raised or function (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 + registerForRefresh = true, -- boolean will refresh all options controls when a setting is changed and when the panel is shown (optional) + registerForDefaults = true, -- boolean will set all options controls back to default values (optional) + resetFunc = function() print("defaults reset") end, -- custom function to run after settings are reset to defaults (optional) } ]] -local widgetVersion = 13 +local widgetVersion = 15 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("panel", widgetVersion) then return end @@ -22,6 +25,8 @@ local cm = CALLBACK_MANAGER local function RefreshPanel(control) local panel = LAM.util.GetTopPanel(control) --callback can be fired by a single control, by the panel showing or by a nested submenu + if LAM.currentAddonPanel ~= panel or not LAM.currentPanelOpened then return end -- we refresh it later when the panel is opened + local panelControls = panel.controlsToRefresh for i = 1, #panelControls do @@ -58,8 +63,39 @@ end local callbackRegistered = false LAMCreateControl.scrollCount = LAMCreateControl.scrollCount or 1 local SEPARATOR = " - " +local COLORED_SEPARATOR = ZO_WHITE:Colorize(SEPARATOR) local LINK_COLOR = ZO_ColorDef:New("5959D5") local LINK_MOUSE_OVER_COLOR = ZO_ColorDef:New("B8B8D3") +local LINK_COLOR_DONATE = ZO_ColorDef:New("FFD700") -- golden +local LINK_MOUSE_OVER_COLOR_DONATE = ZO_ColorDef:New("FFF6CC") + +local function CreateButtonControl(control, label, clickAction, relativeTo) + local button = wm:CreateControl(nil, control, CT_BUTTON) + button:SetClickSound("Click") + button:SetFont(LAM.util.L["PANEL_INFO_FONT"]) + button:SetNormalFontColor(LINK_COLOR:UnpackRGBA()) + button:SetMouseOverFontColor(LINK_MOUSE_OVER_COLOR:UnpackRGBA()) + + local OnClicked + local actionType = type(clickAction) + if actionType == "string" then + OnClicked = function() RequestOpenUnsafeURL(clickAction) end + elseif actionType == "function" then + OnClicked = clickAction + end + button:SetHandler("OnClicked", OnClicked) + + if relativeTo then + button:SetAnchor(TOPLEFT, relativeTo, TOPRIGHT, 0, 0) + button:SetText(COLORED_SEPARATOR .. label) + else + button:SetAnchor(TOPLEFT, control.label, BOTTOMLEFT, 0, -2) + button:SetText(label) + end + button:SetDimensions(button:GetLabelControl():GetTextDimensions()) + + return button +end function LAMCreateControl.panel(parent, panelData, controlName) local control = wm:CreateControl(controlName, parent, CT_CONTROL) @@ -69,6 +105,7 @@ function LAMCreateControl.panel(parent, panelData, controlName) label:SetAnchor(TOPLEFT, control, TOPLEFT, 0, 4) label:SetText(LAM.util.GetStringFromValue(panelData.displayName or panelData.name)) + local previousInfoControl if panelData.author or panelData.version then control.info = wm:CreateControl(nil, control, CT_LABEL) local info = control.info @@ -83,26 +120,30 @@ function LAMCreateControl.panel(parent, panelData, controlName) output[#output + 1] = zo_strformat(LAM.util.L["VERSION"], LAM.util.GetStringFromValue(panelData.version)) end info:SetText(table.concat(output, SEPARATOR)) + previousInfoControl = info 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 - 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) + control.website = CreateButtonControl(control, LAM.util.L["WEBSITE"], panelData.website, previousInfoControl) + previousInfoControl = control.website + end + + if panelData.feedback then + control.feedback = CreateButtonControl(control, LAM.util.L["FEEDBACK"], panelData.feedback, previousInfoControl) + previousInfoControl = control.feedback + end + + if panelData.translation then + control.translation = CreateButtonControl(control, LAM.util.L["TRANSLATION"], panelData.translation, previousInfoControl) + previousInfoControl = control.translation + end + + if panelData.donation then + control.donation = CreateButtonControl(control, LAM.util.L["DONATION"], panelData.donation, previousInfoControl) + local donation = control.donation + previousInfoControl = donation + donation:SetNormalFontColor(LINK_COLOR_DONATE:UnpackRGBA()) + donation:SetMouseOverFontColor(LINK_MOUSE_OVER_COLOR_DONATE:UnpackRGBA()) end control.container = wm:CreateControlFromVirtual("LAMAddonPanelContainer"..LAMCreateControl.scrollCount, control, "ZO_ScrollContainer") @@ -119,6 +160,7 @@ function LAMCreateControl.panel(parent, panelData, controlName) end control.ForceDefaults = ForceDefaults + control.RefreshPanel = LAM.util.RequestRefreshIfNeeded control.data = panelData control.controlsToRefresh = {} diff --git a/Libs/LibAddonMenu-2.0/controls/slider.lua b/Libs/LibAddonMenu-2.0/controls/slider.lua index 7a85d57..e2edf2d 100644 --- a/Libs/LibAddonMenu-2.0/controls/slider.lua +++ b/Libs/LibAddonMenu-2.0/controls/slider.lua @@ -5,13 +5,14 @@ setFunc = function(value) db.var = value doStuff() end, min = 0, max = 20, - step = 1, --(optional) + step = 1, -- (optional) clampInput = true, -- boolean, if set to false the input won't clamp to min and max and allow any number instead (optional) + clampFunction = function(value, min, max) return math.max(math.min(value, max), min) end, -- function that is called to clamp the value (optional) decimals = 0, -- when specified the input value is rounded to the specified number of decimals (optional) autoSelect = false, -- boolean, automatically select everything in the text input field when it gains focus (optional) inputLocation = "below", -- or "right", determines where the input field is shown. This should not be used within the addon menu and is for custom sliders (optional) tooltip = "Slider's tooltip text.", -- or string id or function returning a string (optional) - width = "full", --or "half" (optional) + width = "full", -- or "half" (optional) disabled = function() return db.someBooleanSetting end, --or boolean (optional) warning = "May cause permanent awesomeness.", -- or string id or function returning a string (optional) requiresReload = false, -- boolean, if set to true, the warning text will contain a notice that changes are only applied after an UI reload and any change to the value will make the "Apply Settings" button appear on the panel which will reload the UI when pressed (optional) @@ -19,7 +20,7 @@ reference = "MyAddonSlider" -- unique global reference to control (optional) } ]] -local widgetVersion = 12 +local widgetVersion = 13 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("slider", widgetVersion) then return end @@ -30,6 +31,10 @@ local function RoundDecimalToPlace(d, place) return tonumber(strformat("%." .. tostring(place) .. "f", d)) end +local function ClampValue(value, min, max) + return math.max(math.min(value, max), min) +end + local function UpdateDisabled(control) local disable if type(control.data.disabled) == "function" then @@ -62,7 +67,8 @@ local function UpdateValue(control, forceDefault, value) value = RoundDecimalToPlace(value, control.data.decimals) end if control.data.clampInput ~= false then - value = math.max(math.min(value, control.data.max), control.data.min) + local clamp = control.data.clampFunction or ClampValue + value = clamp(value, control.data.min, control.data.max) end control.data.setFunc(value) --after setting this value, let's refresh the others to see if any should be disabled or have their settings changed @@ -182,7 +188,9 @@ function LAMCreateControl.slider(parent, sliderData, controlName) HandleValueChanged(value) end) slider:SetHandler("OnSliderReleased", function(self, value) - control:UpdateValue(false, value) + if self:GetEnabled() then + control:UpdateValue(false, value) + end end) slider:SetHandler("OnMouseWheel", function(self, value) if(not self:GetEnabled()) then return end diff --git a/Libs/LibAddonMenu-2.0/controls/submenu.lua b/Libs/LibAddonMenu-2.0/controls/submenu.lua index 94087cb..0dcc964 100644 --- a/Libs/LibAddonMenu-2.0/controls/submenu.lua +++ b/Libs/LibAddonMenu-2.0/controls/submenu.lua @@ -1,20 +1,61 @@ --[[submenuData = { type = "submenu", 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 + icon = "path/to/my/icon.dds", -- or function returning a string (optional) + iconTextureCoords = {left, right, top, bottom}, -- or function returning a table (optional) + tooltip = "My submenu tooltip", -- or string id or function returning a string (optional) + controls = {sliderData, buttonData} -- used by LAM (optional) + disabled = function() return db.someBooleanSetting end, -- or boolean (optional) + disabledLabel = function() return db.someBooleanSetting end, -- or boolean (optional) + reference = "MyAddonSubmenu" -- unique global reference to control (optional) } ]] -local widgetVersion = 11 +local widgetVersion = 13 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("submenu", widgetVersion) then return end local wm = WINDOW_MANAGER local am = ANIMATION_MANAGER +local ICON_SIZE = 32 + +local GetDefaultValue = LAM.util.GetDefaultValue +local GetColorForState = LAM.util.GetColorForState + +local function UpdateDisabled(control) + local disable = GetDefaultValue(control.data.disabled) + if disable ~= control.disabled then + local color = GetColorForState(disable) + if disable and control.open then + control.open = false + control.animation:PlayFromStart() + end + + control.arrow:SetColor(color:UnpackRGBA()) + control.disabled = disable + end + + local disableLabel = control.disabled or GetDefaultValue(control.data.disabledLabel) + if disableLabel ~= control.disabledLabel then + local color = GetColorForState(disableLabel) + control.label:SetColor(color:UnpackRGBA()) + if(control.icon) then + control.icon:SetDesaturation(disableLabel and 1 or 0) + end + control.disabledLabel = disableLabel + end +end local function UpdateValue(control) control.label:SetText(LAM.util.GetStringFromValue(control.data.name)) + + if control.icon then + control.icon:SetTexture(GetDefaultValue(control.data.icon)) + if(control.data.iconTextureCoords) then + local coords = GetDefaultValue(control.data.iconTextureCoords) + control.icon:SetTextureCoords(unpack(coords)) + end + end + if control.data.tooltip then control.label.data.tooltipText = LAM.util.GetStringFromValue(control.data.tooltip) end @@ -22,8 +63,9 @@ end local function AnimateSubmenu(clicked) local control = clicked:GetParent() - control.open = not control.open + if control.disabled then return end + control.open = not control.open if control.open then control.animation:PlayFromStart() else @@ -39,30 +81,55 @@ function LAMCreateControl.submenu(parent, submenuData, controlName) control.label = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel") local label = control.label - label:SetAnchor(TOPLEFT, control, TOPLEFT, 5, 5) - label:SetDimensions(width, 30) label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) label:SetText(LAM.util.GetStringFromValue(submenuData.name)) label:SetMouseEnabled(true) + + if submenuData.icon then + control.icon = wm:CreateControl(nil, control, CT_TEXTURE) + local icon = control.icon + icon:SetTexture(GetDefaultValue(submenuData.icon)) + if(submenuData.iconTextureCoords) then + local coords = GetDefaultValue(submenuData.iconTextureCoords) + icon:SetTextureCoords(unpack(coords)) + end + icon:SetDimensions(ICON_SIZE, ICON_SIZE) + icon:SetAnchor(TOPLEFT, control, TOPLEFT, 5, 5) + icon:SetMouseEnabled(true) + icon:SetDrawLayer(DL_CONTROLS) + label:SetAnchor(TOP, control, TOP, 0, 5, ANCHOR_CONSTRAINS_Y) + label:SetAnchor(LEFT, icon, RIGHT, 10, 0, ANCHOR_CONSTRAINS_X) + label:SetDimensions(width - ICON_SIZE - 5, 30) + else + label:SetAnchor(TOPLEFT, control, TOPLEFT, 5, 5) + label:SetDimensions(width, 30) + end + if submenuData.tooltip then label.data = {tooltipText = LAM.util.GetStringFromValue(submenuData.tooltip)} label:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) label:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) + if control.icon then + control.icon.data = label.data + control.icon:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) + control.icon:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) + end end control.scroll = wm:CreateControl(nil, control, CT_SCROLL) local scroll = control.scroll scroll:SetParent(control) - scroll:SetAnchor(TOPLEFT, label, BOTTOMLEFT, 0, 10) + scroll:SetAnchor(TOPLEFT, control.icon or label, BOTTOMLEFT, 0, 10) scroll:SetDimensionConstraints(width + 5, 0, width + 5, 0) - control.bg = wm:CreateControl(nil, label, CT_BACKDROP) + control.bg = wm:CreateControl(nil, control.icon or label, CT_BACKDROP) local bg = control.bg - bg:SetAnchor(TOPLEFT, label, TOPLEFT, -5, -5) + bg:SetAnchor(TOPLEFT, control.icon or label, TOPLEFT, -5, -5) bg:SetAnchor(BOTTOMRIGHT, scroll, BOTTOMRIGHT, -7, 0) bg:SetEdgeTexture("EsoUI\\Art\\Tooltips\\UI-Border.dds", 128, 16) bg:SetCenterTexture("EsoUI\\Art\\Tooltips\\UI-TooltipCenter.dds") bg:SetInsets(16, 16, -16, -16) + bg:SetDrawLayer(DL_BACKGROUND) control.arrow = wm:CreateControl(nil, bg, CT_TEXTURE) local arrow = control.arrow @@ -78,6 +145,9 @@ function LAMCreateControl.submenu(parent, submenuData, controlName) control:SetResizeToFitDescendents(true) control.open = false label:SetHandler("OnMouseUp", AnimateSubmenu) + if(control.icon) then + control.icon:SetHandler("OnMouseUp", AnimateSubmenu) + end animation:SetHandler("OnStop", function(self, completedPlaying) scroll:SetResizeToFitDescendents(control.open) if control.open then @@ -101,6 +171,10 @@ function LAMCreateControl.submenu(parent, submenuData, controlName) btmToggle:SetHandler("OnMouseUp", AnimateSubmenu) control.UpdateValue = UpdateValue + if submenuData.disabled ~= nil or submenuData.disabledLabel ~= nil then + control.UpdateDisabled = UpdateDisabled + control:UpdateDisabled() + end LAM.util.RegisterForRefreshIfNeeded(control) diff --git a/Libs/LibAddonMenu-2.0/controls/texture.lua b/Libs/LibAddonMenu-2.0/controls/texture.lua index 4604fea..03a2569 100644 --- a/Libs/LibAddonMenu-2.0/controls/texture.lua +++ b/Libs/LibAddonMenu-2.0/controls/texture.lua @@ -1,14 +1,14 @@ --[[textureData = { type = "texture", image = "file/path.dds", - imageWidth = 64, --max of 250 for half width, 510 for full - imageHeight = 32, --max of 100 + imageWidth = 64, -- max of 250 for half width, 510 for full + imageHeight = 32, -- max of 100 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 + width = "full", -- or "half" (optional) + reference = "MyAddonTexture" -- unique global reference to control (optional) } ]] ---add texture coords support? +-- TODO: add texture coords support? local widgetVersion = 9 local LAM = LibStub("LibAddonMenu-2.0") diff --git a/Libs/LibStub/LibStub.lua b/Libs/LibStub/LibStub.lua index 4c35014..b9cbad4 100644 --- a/Libs/LibStub/LibStub.lua +++ b/Libs/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", 4 +local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 5 local LibStub = _G[LIBSTUB_MAJOR] local strformat = string.format -- 2.45.2 From 3279e2d0fb3b5e134e9c47d3a0a5cf88bd00ea6d Mon Sep 17 00:00:00 2001 From: Florian Brinker Date: Sat, 26 Oct 2019 22:15:38 +0200 Subject: [PATCH 4/6] Fix Addon Version --- .drone.yml | 6 +++--- AchievementInfo.txt | 4 ++-- AchievementInfoCommon.lua | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.drone.yml b/.drone.yml index 8cfd6c0..d684c4c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -31,9 +31,9 @@ steps: # Set Version and AddonVersion - export VERSION=$DRONE_TAG - export ADDON_VERSION=$(echo $DRONE_TAG | sed -E 's/(0|)\.//g') - - sed -i "s/\"%VERSION%\"/$VERSION/g" sources/AchievementInfoCommon.lua - - sed -i "s/%VERSION%/$VERSION/g" sources/AchievementInfo.txt - - sed -i "s/%ADDON_VERSION%/$ADDON_VERSION/g" sources/AchievementInfo.txt + - sed -i "s/0.123456789/$VERSION/g" sources/AchievementInfoCommon.lua + - sed -i "s/0.123456789/$VERSION/g" sources/AchievementInfo.txt + - sed -i "s/0.123456789/$ADDON_VERSION/g" sources/AchievementInfo.txt # Rename and zip - mv sources AchievementInfo - zip -r "AchievementInfo-$DRONE_TAG.zip" ./AchievementInfo diff --git a/AchievementInfo.txt b/AchievementInfo.txt index 49b9e7a..9ffcc5d 100644 --- a/AchievementInfo.txt +++ b/AchievementInfo.txt @@ -1,7 +1,7 @@ ## Title: AchievementInfo ## Description: Displays progress updates for achievements in the chat. You can display update-details like 'Slay 25/100 Monsters' if interested. |cFF0000Important:|r The messages appear only when an achievement is updated. This is no permanent tracking tool. -## AddOnVersion %ADDON_VERSION% -## Version: %VERSION% +## AddOnVersion 0.123456789 +## Version: 0.123456789 ## Author: |c87B7CCAsto|r, @Astarax ## Contact: mail@coded-with-heart.com diff --git a/AchievementInfoCommon.lua b/AchievementInfoCommon.lua index db0e92f..1f08177 100644 --- a/AchievementInfoCommon.lua +++ b/AchievementInfoCommon.lua @@ -8,7 +8,7 @@ AchievementInfo = {} AchievementInfo.name = "AchievementInfo" AchievementInfo.author = "Asto, @Astarax" -AchievementInfo.version = "%VERSION%" +AchievementInfo.version = 0.123456789 AchievementInfo.savedVars = nil AchievementInfo.LangStore = {} -- 2.45.2 From 7bfc87c37c025f5a2ebac26495bd9601cd9291a4 Mon Sep 17 00:00:00 2001 From: Florian Brinker Date: Sat, 26 Oct 2019 22:21:11 +0200 Subject: [PATCH 5/6] Removed LibStub Usage --- .drone.status | 6 +- .luacheckrc | 7 +-- AchievementInfo.txt | 3 +- AchievementInfoSettings.lua | 6 +- CHANGELOG.md | 4 ++ Libs/exampleoptions.lua | 119 ------------------------------------ 6 files changed, 13 insertions(+), 132 deletions(-) delete mode 100644 Libs/exampleoptions.lua diff --git a/.drone.status b/.drone.status index 9fd0140..afd16ef 100644 --- a/.drone.status +++ b/.drone.status @@ -1,3 +1,3 @@ - { - "url": "https://drone.f-brinker.de/fbrinker/elderscrolls-addon-achievementInfo/" - } \ No newline at end of file +{ + "url": "https://drone.f-brinker.de/fbrinker/elderscrolls-addon-achievementInfo/" +} \ No newline at end of file diff --git a/.luacheckrc b/.luacheckrc index 79cebd3..38dbd2d 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -12,12 +12,11 @@ read_globals = { "GetCVar", "GetNumAchievementCategories", "GetPreviousAchievementInLine", - "CHAT_SYSTEM", + "CHAT_SYSTEM", "EVENT_ACHIEVEMENT_UPDATED", "EVENT_ADD_ON_LOADED", - "EVENT_MANAGER", - "LibStub", - "LINK_STYLE_BRACKET", + "EVENT_MANAGER", + "LINK_STYLE_BRACKET", "zo_callLater", "ZO_SavedVars", } \ No newline at end of file diff --git a/AchievementInfo.txt b/AchievementInfo.txt index 9ffcc5d..d645eb1 100644 --- a/AchievementInfo.txt +++ b/AchievementInfo.txt @@ -8,10 +8,9 @@ ## APIVersion: 100029 ## SavedVariables: ACHIEVEMENT_INFO_DB -## OptionalDependsOn: LibAddonMenu-2.0, LibStub +## OptionalDependsOn: LibAddonMenu-2.0 ## Libraries: -Libs/LibStub/LibStub.lua Libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua ## Helper: diff --git a/AchievementInfoSettings.lua b/AchievementInfoSettings.lua index 14fb0d8..ece4aaa 100644 --- a/AchievementInfoSettings.lua +++ b/AchievementInfoSettings.lua @@ -46,8 +46,6 @@ end -- Function to create the settings panel function AchievementInfo.createSettingsPanel() - local LAM = LibStub("LibAddonMenu-2.0") - local panelData = { type = "panel", name = AchievementInfo.name, @@ -151,8 +149,8 @@ function AchievementInfo.createSettingsPanel() }) -- Register - LAM:RegisterAddonPanel(AchievementInfo.name.."SettingsPanel", panelData) - LAM:RegisterOptionControls(AchievementInfo.name.."SettingsPanel", optionsTable) + LibAddonMenu2:RegisterAddonPanel(AchievementInfo.name.."SettingsPanel", panelData) + LibAddonMenu2:RegisterOptionControls(AchievementInfo.name.."SettingsPanel", optionsTable) end diff --git a/CHANGELOG.md b/CHANGELOG.md index 370196e..d6bd964 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ #### Notable Changes +##### Release 2.24 +* Updated Dependencies +* Removed LibStub Usage + ##### Release 2.20 * Now all the new achievement categories are enabled by default in the settings panel diff --git a/Libs/exampleoptions.lua b/Libs/exampleoptions.lua deleted file mode 100644 index 9b4d9ea..0000000 --- a/Libs/exampleoptions.lua +++ /dev/null @@ -1,119 +0,0 @@ -local panelData = { - type = "panel", - name = "Window Title", - displayName = "Longer Window Title", - author = "Seerah", - version = "1.3", - slashCommand = "/myaddon", --(optional) will register a keybind to open to this panel - 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) -} - -local optionsTable = { - [1] = { - type = "header", - name = "My Header", - width = "full", --or "half" (optional) - }, - [2] = { - type = "description", - --title = "My Title", --(optional) - title = nil, --(optional) - text = "My description text to display. blah blah blah blah blah blah blah - even more sample text!!", - width = "full", --or "half" (optional) - }, - [3] = { - type = "dropdown", - name = "My Dropdown", - tooltip = "Dropdown's tooltip text.", - choices = {"table", "of", "choices"}, - getFunc = function() return "of" end, - setFunc = function(var) print(var) end, - width = "half", --or "half" (optional) - warning = "Will need to reload the UI.", --(optional) - }, - [4] = { - type = "dropdown", - name = "My Dropdown", - tooltip = "Dropdown's tooltip text.", - choices = {"table", "of", "choices"}, - getFunc = function() return "of" end, - setFunc = function(var) print(var) end, - width = "half", --or "half" (optional) - warning = "Will need to reload the UI.", --(optional) - }, - [5] = { - type = "slider", - name = "My Slider", - tooltip = "Slider's tooltip text.", - min = 0, - max = 20, - step = 1, --(optional) - getFunc = function() return 3 end, - setFunc = function(value) d(value) end, - width = "half", --or "half" (optional) - default = 5, --(optional) - }, - [6] = { - type = "button", - name = "My Button", - tooltip = "Button's tooltip text.", - func = function() d("button pressed!") end, - width = "half", --or "half" (optional) - warning = "Will need to reload the UI.", --(optional) - }, - [7] = { - type = "submenu", - name = "Submenu Title", - tooltip = "My submenu tooltip", --(optional) - controls = { - [1] = { - type = "checkbox", - name = "My Checkbox", - tooltip = "Checkbox's tooltip text.", - getFunc = function() return true end, - setFunc = function(value) d(value) end, - width = "half", --or "half" (optional) - warning = "Will need to reload the UI.", --(optional) - }, - [2] = { - type = "colorpicker", - name = "My Color Picker", - tooltip = "Color Picker's tooltip text.", - getFunc = function() return 1, 0, 0, 1 end, --(alpha is optional) - setFunc = function(r,g,b,a) print(r, g, b, a) end, --(alpha is optional) - width = "half", --or "half" (optional) - warning = "warning text", - }, - [3] = { - type = "editbox", - name = "My Editbox", - tooltip = "Editbox's tooltip text.", - getFunc = function() return "this is some text" end, - setFunc = function(text) print(text) end, - isMultiline = false, --boolean - width = "half", --or "half" (optional) - warning = "Will need to reload the UI.", --(optional) - default = "", --(optional) - }, - }, - }, - [8] = { - type = "custom", - reference = "MyAddonCustomControl", --unique name for your control to use as reference - refreshFunc = function(customControl) end, --(optional) function to call when panel/controls refresh - width = "half", --or "half" (optional) - }, - [9] = { - type = "texture", - image = "EsoUI\\Art\\ActionBar\\abilityframe64_up.dds", - imageWidth = 64, --max of 250 for half width, 510 for full - imageHeight = 64, --max of 100 - tooltip = "Image's tooltip text.", --(optional) - width = "half", --or "half" (optional) - }, -} - -local LAM = LibStub("LibAddonMenu-2.0") -LAM:RegisterAddonPanel("MyAddon", panelData) -LAM:RegisterOptionControls("MyAddon", optionsTable) -- 2.45.2 From 2fb1fba3046c24231adc1ab2906c38a980a4a170 Mon Sep 17 00:00:00 2001 From: Florian Brinker Date: Sat, 26 Oct 2019 23:51:19 +0200 Subject: [PATCH 6/6] =?UTF-8?q?Whitelist=20=C2=96Dependency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .luacheckrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.luacheckrc b/.luacheckrc index 38dbd2d..1e132bf 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -12,6 +12,7 @@ read_globals = { "GetCVar", "GetNumAchievementCategories", "GetPreviousAchievementInLine", + "LibAddonMenu2", "CHAT_SYSTEM", "EVENT_ACHIEVEMENT_UPDATED", "EVENT_ADD_ON_LOADED", -- 2.45.2