diff --git a/lib/LibAddonMenu-2.0/LAM-1to2-Interface-1.0.lua b/lib/LibAddonMenu-2.0/LAM-1to2-Interface-1.0.lua deleted file mode 100644 index 3421165..0000000 --- a/lib/LibAddonMenu-2.0/LAM-1to2-Interface-1.0.lua +++ /dev/null @@ -1,127 +0,0 @@ -local MAJOR, MINOR = "LibAddonMenu-1.0-to-2.0", 1 -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 - -local lam2 = LibStub("LibAddonMenu-2.0") - -lam.optionControls = {} -function lam:CreateControlPanel(controlPanelID, controlPanelName) - local data = { - type = "panel", - --Remove coloring from the name for addon list - name = controlPanelName:gsub("%|[Cc]......",""):gsub("%|[Rr]",""), - displayName = text - } - lam2:RegisterAddonPanel(controlPanelName, data) - lam.optionControls[controlPanelName] = {} - return controlPanelName -end - -function lam:AddHeader(panelID, controlName, text) - local data = { - type = "header", - name = text - } - table.insert(lam.optionControls[panelID], data) - lam2:RegisterOptionControls(panelID, lam.optionControls[panelID]) -end - -function lam:AddSlider(panelID, controlName, text, tooltip, minValue, maxValue, step, getFunc, setFunc, warning, warningText) - local data = { - type = "slider", - name = text, - tooltip = tooltip, - min = minValue, - max = maxValue, - step = step, - getFunc = getFunc, - setFunc = setFunc, - warning = warningText - } - table.insert(lam.optionControls[panelID], data) -end - -function lam:AddDropdown(panelID, controlName, text, tooltip, validChoices, getFunc, setFunc, warning, warningText) - local data = { - type = "dropdown", - name = text, - tooltip = tooltip, - choices = validChoices, - getFunc = getFunc, - setFunc = setFunc, - warning = warningText - } - table.insert(lam.optionControls[panelID], data) -end - -function lam:AddCheckbox(panelID, controlName, text, tooltip, getFunc, setFunc, warning, warningText) - local data = { - type = "checkbox", - name = text, - tooltip = tooltip, - getFunc = getFunc, - setFunc = setFunc, - warning = warningText - } - table.insert(lam.optionControls[panelID], data) -end - -function lam:AddColorPicker(panelID, controlName, text, tooltip, getFunc, setFunc, warning, warningText) - local data = { - type = "colorpicker", - name = text, - tooltip = tooltip, - getFunc = getFunc, - setFunc = setFunc, - warning = warningText - } - table.insert(lam.optionControls[panelID], data) -end - -function lam:AddEditBox(panelID, controlName, text, tooltip, isMultiLine, getFunc, setFunc, warning, warningText) - local data = { - type = "editbox", - name = text, - tooltip = tooltip, - getFunc = getFunc, - setFunc = setFunc, - isMultiLine = isMultiLine, - warning = warningText - } - table.insert(lam.optionControls[panelID], data) -end - -function lam:AddButton(panelID, controlName, text, tooltip, onClick, warning, warningText) - local data = { - type = "button", - name = text, - tooltip = tooltip, - func = onClick, - warning = warningText - } - table.insert(lam.optionControls[panelID], data) -end - -function lam:AddDescription(panelID, controlName, text, titleText) - local data = { - type = "description", - title = titleText, - text = text - } - table.insert(lam.optionControls[panelID], data) -end - -function lam:AddSubMenu(panelID, controlName, text, tooltip) - local subName = panelID .. "-" .. controlName - lam.optionControls[subName] = {} - - local data = { - type = "submenu", - name = text, - tooltip = tooltip, - controls = lam.optionControls[subName] - } - table.insert(lam.optionControls[panelID], data) - - return subName -end \ No newline at end of file diff --git a/lib/LibAddonMenu-2.0/LAM-2.0-OOP.lua b/lib/LibAddonMenu-2.0/LAM-2.0-OOP.lua deleted file mode 100644 index 5aaca8f..0000000 --- a/lib/LibAddonMenu-2.0/LAM-2.0-OOP.lua +++ /dev/null @@ -1,172 +0,0 @@ -local MAJOR, MINOR = "LibAddonMenu-2.0-OOP", 1 -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 - -local lam2 = LibStub("LibAddonMenu-2.0") - -setmetatable(lam, { __call = lam.CreateControlPanel }) - -function lam.CreateControlPanel(controlPanelName, displayName) - local self = {} - setmetatable(self, lam.Panel) - local data = { - type = "panel", - name = controlPanelName, - displayName = displayName - } - self.name = controlPanelName - self.options = {} - - lam2:RegisterAddonPanel(controlPanelName, data) - lam2:RegisterOptionControls(controlPanelName, self.options) - return self -end - -lam.Panel = {} - -function lam.Panel:AddHeader(text) - local data = { - type = "header", - name = text - } - table.insert(self.options, data) - return self -end - -function lam.Panel:AddSlider(text, tooltip, minValue, maxValue, step, getFunc, setFunc, warningText) - local data = { - type = "slider", - name = text, - tooltip = tooltip, - min = minValue, - max = maxValue, - step = step, - getFunc = getFunc, - setFunc = setFunc, - warning = warningText - } - table.insert(self.options, data) - return self -end - -function lam.Panel:AddDropdown(text, tooltip, validChoices, getFunc, setFunc, warningText) - local data = { - type = "dropdown", - name = text, - tooltip = tooltip, - choices = validChoices, - getFunc = getFunc, - setFunc = setFunc, - warning = warningText - } - table.insert(self.options, data) - return self -end - -function lam.Panel:AddCheckbox(text, tooltip, getFunc, setFunc, warningText) - local data = { - type = "checkbox", - name = text, - tooltip = tooltip, - getFunc = getFunc, - setFunc = setFunc, - warning = warningText - } - table.insert(self.options, data) - return self -end - -function lam.Panel:AddColorPicker(text, tooltip, getFunc, setFunc, warningText) - local data = { - type = "colorpicker", - name = text, - tooltip = tooltip, - getFunc = getFunc, - setFunc = setFunc, - warning = warningText - } - table.insert(self.options, data) - return self -end - -function lam.Panel:AddEditBox(text, tooltip, isMultiLine, getFunc, setFunc, warningText) - local data = { - type = "editbox", - name = text, - tooltip = tooltip, - getFunc = getFunc, - setFunc = setFunc, - isMultiLine = isMultiLine, - warning = warningText - } - table.insert(self.options, data) - return self -end - -function lam.Panel:AddButton(text, tooltip, onClick, warningText) - local data = { - type = "button", - name = text, - tooltip = tooltip, - func = onClick, - warning = warningText - } - table.insert(self.options, data) - return self -end - -function lam.Panel:AddDescription(text, titleText) - local data = { - type = "description", - title = titleText, - text = text - } - table.insert(self.options, data) - return self -end - -function lam.Panel:AddSubMenu(text, tooltip) - if self.subpanel then return nil end - - local sub = {} - setmetatable(sub, lam.Panel) - sub.options = {} - sub.subpanel = true - - local data = { - type = "submenu", - name = text, - tooltip = tooltip, - controls = sub.options - } - table.insert(self.options, data) - - return sub -end - -function lam.Panel:AddCustom(reference, width, additionalData) - if additionalData == nil then - additionalData = {} - end - - additionalData.type = "custom" - additionalData.reference = reference - additionalData.width = width - table.insert(self.options, additionalData) - return self -end - -function lam.Panel:AddTexture(image, w, h, tooltip, width, reference) - local data = { - type = "texture", - image = image, - imageWidth = w, - imageHeight = h, - tooltip = tooltip, - width = width, - reference = reference - } - - table.insert(self.options, data) - return self -end \ No newline at end of file diff --git a/lib/LibAddonMenu-2.0/LibAddonMenu-2.0.lua b/lib/LibAddonMenu-2.0/LibAddonMenu-2.0.lua index ce2f2e5..a501670 100644 --- a/lib/LibAddonMenu-2.0/LibAddonMenu-2.0.lua +++ b/lib/LibAddonMenu-2.0/LibAddonMenu-2.0.lua @@ -7,7 +7,7 @@ --Register LAM with LibStub -local MAJOR, MINOR = "LibAddonMenu-2.0", 4 +local MAJOR, MINOR = "LibAddonMenu-2.0", 8 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 @@ -125,6 +125,7 @@ local function CreateOptionsControls(panel) end optionsCreated[addonID] = true + cm:FireCallbacks("LAM-PanelControlsCreated", panel) end @@ -215,14 +216,18 @@ end --INTERNAL FUNCTION --creates LAM's Addon Settings panel local function CreateAddonSettingsPanel() - local controlPanelID = "LAM_ADDON_SETTINGS_PANEL" - local controlPanelName = "Addon Settings" + if not LAMSettingsPanelCreated then + local controlPanelID = "LAM_ADDON_SETTINGS_PANEL" + local controlPanelNames = {en = "Addon Settings", fr = "Extensions", de = "Erweiterungen"} - ZO_OptionsWindow_AddUserPanel(controlPanelID, controlPanelName) + ZO_OptionsWindow_AddUserPanel(controlPanelID, controlPanelNames[GetCVar("Language.2")]) - lam.panelID = _G[controlPanelID] - - ZO_PreHook("ZO_OptionsWindow_ChangePanels", HandlePanelSwitching) + lam.panelID = _G[controlPanelID] + + ZO_PreHook("ZO_OptionsWindow_ChangePanels", HandlePanelSwitching) + + LAMSettingsPanelCreated = true + end end @@ -247,7 +252,7 @@ end --INTERNAL FUNCTION ---creates the right-hand menu in LAM's panel +--creates the left-hand menu in LAM's panel local function CreateAddonList() local list --check if an earlier loaded copy of LAM created it already @@ -260,7 +265,7 @@ local function CreateAddonList() list.bg = list.bg or wm:CreateControl(nil, list, CT_BACKDROP) local bg = list.bg bg:SetAnchorFill() --offsets of 8? - bg:SetEdgeTexture("EsoUI\\Art\\Tooltips\\UI-Border.dds", 128, 16) + bg:SetEdgeTexture("EsoUI\\Art\\miscellaneous\\borderedinsettransparent_edgefile.dds", 128, 16) bg:SetCenterColor(0, 0, 0, 0) local generatedButtons diff --git a/lib/LibAddonMenu-2.0/controls/checkbox.lua b/lib/LibAddonMenu-2.0/controls/checkbox.lua index fb48f56..8432109 100644 --- a/lib/LibAddonMenu-2.0/controls/checkbox.lua +++ b/lib/LibAddonMenu-2.0/controls/checkbox.lua @@ -12,7 +12,7 @@ } ]] -local widgetVersion = 3 +local widgetVersion = 4 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("checkbox", widgetVersion) then return end @@ -37,7 +37,7 @@ local function UpdateDisabled(control) disable = control.data.disabled end - control.label:SetColor((disable and ZO_DEFAULT_DISABLED_COLOR or ZO_DEFAULT_ENABLED_COLOR):UnpackRGBA()) + control.label:SetColor((disable and ZO_DEFAULT_DISABLED_COLOR or control.value and ZO_DEFAULT_ENABLED_COLOR or ZO_DEFAULT_DISABLED_COLOR):UnpackRGBA()) control.checkbox:SetColor((disable and ZO_DEFAULT_DISABLED_COLOR or ZO_NORMAL_TEXT):UnpackRGBA()) --control:SetMouseEnabled(not disable) --control:SetMouseEnabled(true) diff --git a/lib/LibAddonMenu-2.0/controls/dropdown.lua b/lib/LibAddonMenu-2.0/controls/dropdown.lua index 87719c4..e338db6 100644 --- a/lib/LibAddonMenu-2.0/controls/dropdown.lua +++ b/lib/LibAddonMenu-2.0/controls/dropdown.lua @@ -3,6 +3,7 @@ name = "My Dropdown", tooltip = "Dropdown's tooltip text.", 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, width = "full", --or "half" (optional) @@ -13,7 +14,7 @@ } ]] -local widgetVersion = 2 +local widgetVersion = 3 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("dropdown", widgetVersion) then return end @@ -67,10 +68,20 @@ local function UpdateChoices(control, choices) for i = 1, #choices do local entry = control.dropdown:CreateItemEntry(choices[i], DropdownCallback) entry.control = control - control.dropdown:AddItem(entry) --second arg to alphabetize or no? (no = ZO_COMBOBOX_SUPRESS_UPDATE) + control.dropdown:AddItem(entry, not control.data.sort and ZO_COMBOBOX_SUPRESS_UPDATE) --if sort type/order isn't specified, then don't sort end end +local function GrabSortingInfo(sortInfo) + local t, i = {}, 1 + for info in string.gmatch(sortInfo, "([^%-]+)") do + t[i] = info + i = i + 1 + end + + return t +end + local comboboxCount = 1 function LAMCreateControl.dropdown(parent, dropdownData, controlName) @@ -95,7 +106,12 @@ function LAMCreateControl.dropdown(parent, dropdownData, controlName) combobox:SetHandler("OnMouseExit", function() ZO_Options_OnMouseExit(control) end) control.dropdown = ZO_ComboBox_ObjectFromContainer(combobox) local dropdown = control.dropdown - + if dropdownData.sort then + local sortInfo = GrabSortingInfo(dropdownData.sort) + local sortType, sortOrder = sortInfo[1], sortInfo[2] + 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 + local isHalfWidth = dropdownData.width == "half" if isHalfWidth then control:SetDimensions(250, 55) diff --git a/lib/LibAddonMenu-2.0/controls/editbox.lua b/lib/LibAddonMenu-2.0/controls/editbox.lua index 9981585..f2b4ded 100644 --- a/lib/LibAddonMenu-2.0/controls/editbox.lua +++ b/lib/LibAddonMenu-2.0/controls/editbox.lua @@ -13,7 +13,7 @@ } ]] -local widgetVersion = 2 +local widgetVersion = 3 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("editbox", widgetVersion) then return end @@ -59,7 +59,6 @@ local function UpdateValue(control, forceDefault, value) end -local scrollCount = 1 function LAMCreateControl.editbox(parent, editboxData, controlName) local control = wm:CreateTopLevelWindow(controlName or editboxData.reference) control:SetParent(parent.scroll) @@ -80,9 +79,26 @@ function LAMCreateControl.editbox(parent, editboxData, controlName) local bg = control.bg if editboxData.isMultiline then - control.scroll = wm:CreateControlFromVirtual(parent:GetName().."Scroll"..scrollCount, bg, "ZO_ScrollContainer") - scrollCount = scrollCount + 1 - control.editbox = wm:CreateControlFromVirtual(nil, control.scroll, "ZO_DefaultEditMultiLineForBackdrop") + control.editbox = wm:CreateControlFromVirtual(nil, bg, "ZO_DefaultEditMultiLineForBackdrop") + control.editbox:SetHandler("OnMouseWheel", function(self, delta) + if self:HasFocus() then --only set focus to new spots if the editbox is currently in use + local cursorPos = self:GetCursorPosition() + local text = self:GetText() + local textLen = text:len() + local newPos + if delta > 0 then --scrolling up + local reverseText = text:reverse() + local revCursorPos = textLen - cursorPos + local revPos = reverseText:find("\n", revCursorPos+1) + newPos = revPos and textLen - revPos + else --scrolling down + newPos = text:find("\n", cursorPos+1) + end + if newPos then --if we found a new line, then scroll, otherwise don't + self:SetCursorPosition(newPos) + end + end + end) else control.editbox = wm:CreateControlFromVirtual(nil, bg, "ZO_DefaultEditForBackdrop") end @@ -90,7 +106,7 @@ function LAMCreateControl.editbox(parent, editboxData, controlName) editbox:SetText(editboxData.getFunc()) editbox:SetMaxInputChars(3000) editbox:SetHandler("OnFocusLost", function(self) control:UpdateValue(false, self:GetText()) end) - editbox:SetHandler("OnEscape", function(self) self:LoseFocus() control:UpdateValue() end) + editbox:SetHandler("OnEscape", function(self) self:LoseFocus() control:UpdateValue(false, self:GetText()) end) editbox:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseEnter(control) end) editbox:SetHandler("OnMouseExit", function() ZO_Options_OnMouseExit(control) end) @@ -98,13 +114,19 @@ function LAMCreateControl.editbox(parent, editboxData, controlName) if isHalfWidth then control:SetDimensions(250, 55) label:SetDimensions(250, 26) - bg:SetDimensions(240, editboxData.isMultiline and 74 or 24) + bg:SetDimensions(225, editboxData.isMultiline and 74 or 24) bg:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT) + if editboxData.isMultiline then + editbox:SetDimensionConstraints(210, 74, 210, 500) + end else control:SetDimensions(510, 30) label:SetDimensions(300, 26) bg:SetDimensions(200, editboxData.isMultiline and 100 or 24) bg:SetAnchor(TOPRIGHT) + if editboxData.isMultiline then + editbox:SetDimensionConstraints(185, 100, 185, 500) + end end if editboxData.warning then diff --git a/lib/LibAddonMenu-2.0/controls/panel.lua b/lib/LibAddonMenu-2.0/controls/panel.lua index d167139..ed3d2ff 100644 --- a/lib/LibAddonMenu-2.0/controls/panel.lua +++ b/lib/LibAddonMenu-2.0/controls/panel.lua @@ -11,7 +11,7 @@ } ]] -local widgetVersion = 2 +local widgetVersion = 5 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("panel", widgetVersion) then return end @@ -24,13 +24,13 @@ local function RefreshPanel(control) for i = 1, #panelControls do local updateControl = panelControls[i] - if updateControl == control then return end - - if updateControl.UpdateValue then - updateControl:UpdateValue() - end - if updateControl.UpdateDisabled then - updateControl:UpdateDisabled() + if updateControl ~= control then + if updateControl.UpdateValue then + updateControl:UpdateValue() + end + if updateControl.UpdateDisabled then + updateControl:UpdateDisabled() + end end end end @@ -48,13 +48,15 @@ local function ForceDefaults(panel) if panel.data.resetFunc then panel.data.resetFunc() end + + cm:FireCallbacks("LAM-RefreshPanel", panel) end ESO_Dialogs["LAM_DEFAULTS"] = { title = { - text = "Reset To Defaults", + text = SI_OPTIONS_RESET_TITLE, }, mainText = { - text = "Reset this addon's settings to their default values?", + text = SI_OPTIONS_RESET_PROMPT, align = TEXT_ALIGN_CENTER, }, buttons = { @@ -76,7 +78,7 @@ function LAMCreateControl.panel(parent, panelData, controlName) control.bg = wm:CreateControl(nil, control, CT_BACKDROP) local bg = control.bg bg:SetAnchorFill() - bg:SetEdgeTexture("EsoUI\\Art\\Tooltips\\UI-Border.dds", 128, 16) + bg:SetEdgeTexture("EsoUI\\Art\\miscellaneous\\borderedinsettransparent_edgefile.dds", 128, 16) bg:SetCenterColor(0, 0, 0, 0) control.label = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel") @@ -87,15 +89,15 @@ 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("ZoFontGameSmall") info:SetFont("$(CHAT_FONT)|14|soft-shadow-thin") info:SetColor(ZO_HIGHLIGHT_TEXT:UnpackRGBA()) info:SetHeight(13) info:SetAnchor(TOPRIGHT, control, BOTTOMRIGHT, -5, 2) if panelData.author and panelData.version then - info:SetText("Version: "..panelData.version.." - Author: "..panelData.author) + --info:SetText("Version: "..panelData.version.." - "..GetString(SI_ADDON_MANAGER_AUTHOR)..": "..panelData.author) + info:SetText(string.format("Version: %s - %s: %s", panelData.version, GetString(SI_ADDON_MANAGER_AUTHOR), panelData.author)) elseif panelData.author then - info:SetText("Author: "..panelData.author) + info:SetText(string.format("%s: %s", GetString(SI_ADDON_MANAGER_AUTHOR), panelData.author)) else info:SetText("Version: "..panelData.version) end @@ -114,7 +116,8 @@ 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("Reset To Defaults") + defaultButton:SetText(GetString(SI_OPTIONS_RESET_TITLE)) defaultButton:SetDimensions(200, 30) defaultButton:SetAnchor(TOPLEFT, control, BOTTOMLEFT, 0, 2) defaultButton:SetHandler("OnClicked", function() diff --git a/lib/LibAddonMenu-2.0/controls/submenu.lua b/lib/LibAddonMenu-2.0/controls/submenu.lua index b2b399d..8a599c0 100644 --- a/lib/LibAddonMenu-2.0/controls/submenu.lua +++ b/lib/LibAddonMenu-2.0/controls/submenu.lua @@ -6,7 +6,7 @@ reference = "MyAddonSubmenu" --(optional) unique global reference to control } ]] -local widgetVersion = 2 +local widgetVersion = 3 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("submenu", widgetVersion) then return end @@ -49,7 +49,7 @@ function LAMCreateControl.submenu(parent, submenuData, controlName) local scroll = control.scroll scroll:SetParent(control) scroll:SetAnchor(TOPLEFT, label, BOTTOMLEFT, 0, 10) - scroll:SetDimensionConstraints(525, 0, 525, 1500) + scroll:SetDimensionConstraints(525, 0, 525, 2500) control.bg = wm:CreateControl(nil, label, CT_BACKDROP) local bg = control.bg