diff --git a/GuildCharacterInfo.txt b/GuildCharacterInfo.txt index ab8f2c6..d9471f6 100644 --- a/GuildCharacterInfo.txt +++ b/GuildCharacterInfo.txt @@ -1,6 +1,6 @@ ## APIVersion: 100004 ## Title: Guild Character Info -## Version: 1.1.0 +## Version: 1.1.1 ## Author: Sasky ## SavedVariables: GuildCharacterInfo ## OptionalDependsOn: LibAddonMenu-2.0 @@ -21,7 +21,7 @@ lib/LibAddonMenu-2.0/controls/header.lua lib/LibAddonMenu-2.0/controls/slider.lua lib/LibAddonMenu-2.0/controls/texture.lua -lib/LibAddonMenu-2.0/LAM-1to2-Interface-1.0.lua +lib/LAM-1to2-Interface-1.0.lua GuildCharNames.lua diff --git a/lib/LAM-1to2-Interface-1.0.lua b/lib/LAM-1to2-Interface-1.0.lua new file mode 100644 index 0000000..3421165 --- /dev/null +++ b/lib/LAM-1to2-Interface-1.0.lua @@ -0,0 +1,127 @@ +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-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/LibAddonMenu-2.0.lua b/lib/LibAddonMenu-2.0/LibAddonMenu-2.0.lua index 35b4830..b68d516 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", 2 +local MAJOR, MINOR = "LibAddonMenu-2.0", 7 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 @@ -48,8 +48,9 @@ end --opens to a specific addon's option panel --Usage: -- panel = userdata; the panel returned by the :RegisterOptionsPanel method -local settings = {en = "Settings", de = "Einstellungen", fr = "Réglages"} -local locSettings = settings[GetCVar("Language.2")] +--local settings = {en = "Settings", de = "Einstellungen", fr = "Réglages"} +--local locSettings = settings[GetCVar("Language.2")] +local locSettings = GetString(SI_GAME_MENU_SETTINGS) function lam:OpenToPanel(panel) SCENE_MANAGER:Show("gameMenuInGame") zo_callLater(function() @@ -124,6 +125,7 @@ local function CreateOptionsControls(panel) end optionsCreated[addonID] = true + cm:FireCallbacks("LAM-PanelControlsCreated", panel) end @@ -214,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 @@ -246,15 +252,17 @@ 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 = wm:CreateControlFromVirtual("LAMAddonPanelsMenu", optionsWindow, "ZO_ScrollContainer") + local list + --check if an earlier loaded copy of LAM created it already + list = LAMAddonPanelsMenu or wm:CreateControlFromVirtual("LAMAddonPanelsMenu", optionsWindow, "ZO_ScrollContainer") list:ClearAnchors() list:SetAnchor(TOPLEFT) list:SetHeight(675) list:SetWidth(200) - list.bg = wm:CreateControl(nil, list, CT_BACKDROP) + 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) @@ -262,7 +270,7 @@ local function CreateAddonList() local generatedButtons list:SetHandler("OnShow", function(self) - if not generatedButtons then + if not generatedButtons and #addonsForList > 0 then --we're about to show our list for the first time - let's sort the buttons before creating them table.sort(addonsForList, function(a, b) return a.name < b.name diff --git a/lib/LibAddonMenu-2.0/controls/checkbox.lua b/lib/LibAddonMenu-2.0/controls/checkbox.lua index 734e180..8432109 100644 --- a/lib/LibAddonMenu-2.0/controls/checkbox.lua +++ b/lib/LibAddonMenu-2.0/controls/checkbox.lua @@ -12,7 +12,7 @@ } ]] -local widgetVersion = 2 +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) @@ -45,9 +45,7 @@ local function UpdateDisabled(control) control.isDisabled = disable end -local function ToggleCheckbox(control) - PlaySound(SOUNDS.DEFAULT_CLICK) - +local function ToggleCheckbox(control) if control.value then control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) control.checkbox:SetText(control.checkedText) @@ -114,6 +112,7 @@ function LAMCreateControl.checkbox(parent, checkboxData, controlName) control:SetHandler("OnMouseExit", OnMouseExit) control:SetHandler("OnMouseUp", function(control) if control.isDisabled then return end + PlaySound(SOUNDS.DEFAULT_CLICK) control.value = not control.value control:UpdateValue(false, control.value) end) 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..de1beb1 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 = 4 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 = { @@ -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()