diff --git a/Librarian.lua b/Librarian.lua index feae865..0b8fca6 100644 --- a/Librarian.lua +++ b/Librarian.lua @@ -10,7 +10,7 @@ ZO_CreateStringId("SI_LIBRARIAN_SORT_TYPE_TITLE", "Title") ZO_CreateStringId("SI_LIBRARIAN_SORT_TYPE_WORD_COUNT", "Words") ZO_CreateStringId("SI_LIBRARIAN_MARK_UNREAD", "Mark as Unread") ZO_CreateStringId("SI_LIBRARIAN_MARK_READ", "Mark as Read") -ZO_CreateStringId("SI_LIBRARIAN_CREDIT", "Librarian 1.2.2 by Flamage") +ZO_CreateStringId("SI_LIBRARIAN_CREDIT", "Librarian 1.2.3 by Flamage") ZO_CreateStringId("SI_LIBRARIAN_BOOK_COUNT", "%d Books") ZO_CreateStringId("SI_LIBRARIAN_UNREAD_COUNT", "%s (%d Unread)") ZO_CreateStringId("SI_LIBRARIAN_SHOW_ALL_BOOKS", "Show books for all characters") diff --git a/Librarian.txt b/Librarian.txt index 51ff9f3..bb07427 100644 --- a/Librarian.txt +++ b/Librarian.txt @@ -6,6 +6,18 @@ Libs\LibStub\LibStub.lua Libs\LibAddonMenu-2.0\LibAddonMenu-2.0.lua +Libs\LibAddonMenu-2.0\controls\panel.lua +Libs\LibAddonMenu-2.0\controls\submenu.lua +Libs\LibAddonMenu-2.0\controls\button.lua +Libs\LibAddonMenu-2.0\controls\checkbox.lua +Libs\LibAddonMenu-2.0\controls\colorpicker.lua +Libs\LibAddonMenu-2.0\controls\custom.lua +Libs\LibAddonMenu-2.0\controls\description.lua +Libs\LibAddonMenu-2.0\controls\dropdown.lua +Libs\LibAddonMenu-2.0\controls\editbox.lua +Libs\LibAddonMenu-2.0\controls\header.lua +Libs\LibAddonMenu-2.0\controls\slider.lua +Libs\LibAddonMenu-2.0\controls\texture.lua Librarian.lua LibrarianSettings.lua diff --git a/LibrarianSettings.lua b/LibrarianSettings.lua index b0426e2..72fd79a 100644 --- a/LibrarianSettings.lua +++ b/LibrarianSettings.lua @@ -75,7 +75,7 @@ function LibrarianSettings:Initialise(settings) name = "Librarian", displayName = "Librarian Book Manager", author = "Flamage", - version = "1.2.0", + version = "1.2.3", slashCommand = "/lo" } diff --git a/Libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua b/Libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua index a501670..a58bf03 100644 --- a/Libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua +++ b/Libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua @@ -7,7 +7,7 @@ --Register LAM with LibStub -local MAJOR, MINOR = "LibAddonMenu-2.0", 8 +local MAJOR, MINOR = "LibAddonMenu-2.0", 14 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 @@ -22,7 +22,8 @@ local _ local addonsForList = {} local addonToOptionsMap = {} local optionsCreated = {} -local widgets = {} +lam.widgets = lam.widgets or {} +local widgets = lam.widgets --METHOD: REGISTER WIDGET-- @@ -57,6 +58,10 @@ function lam:OpenToPanel(panel) ZO_GameMenu_InGame.gameMenu.headerControls[locSettings]:SetOpen(true) SCENE_MANAGER:AddFragment(OPTIONS_WINDOW_FRAGMENT) ZO_OptionsWindow_ChangePanels(lam.panelID) + if not lam.panelSubCategoryControl then + lam.panelSubCategoryControl = _G["ZO_GameMenu_InGameNavigationContainerScrollChildZO_GameMenu_SubCategory"..(lam.panelID + 1)] + end + ZO_TreeEntry_OnMouseUp(lam.panelSubCategoryControl, true) panel:SetHidden(false) end, 200) end @@ -218,9 +223,11 @@ end local function CreateAddonSettingsPanel() if not LAMSettingsPanelCreated then local controlPanelID = "LAM_ADDON_SETTINGS_PANEL" - local controlPanelNames = {en = "Addon Settings", fr = "Extensions", de = "Erweiterungen"} + --Russian for TERAB1T's RuESO addon, which creates an "ru" locale + --game font does not support Cyrillic, so they are using custom fonts + extended latin charset + local controlPanelNames = {en = "Addon Settings", fr = "Extensions", de = "Erweiterungen", ru = "Îacòpoéêè äoïoìîeîèé"} - ZO_OptionsWindow_AddUserPanel(controlPanelID, controlPanelNames[GetCVar("Language.2")]) + ZO_OptionsWindow_AddUserPanel(controlPanelID, controlPanelNames[GetCVar("Language.2")] or controlPanelName["en"]) lam.panelID = _G[controlPanelID] @@ -235,14 +242,14 @@ end --adds each registered addon to the menu in LAM's panel local function CreateAddonButtons(list, addons) for i = 1, #addons do - local button = wm:CreateControlFromVirtual("LAMAddonMenuButton"..i, list, "ZO_DefaultTextButton") + local button = wm:CreateControlFromVirtual("LAMAddonMenuButton"..i, list.scrollChild, "ZO_DefaultTextButton") button.name = addons[i].name button.panel = _G[addons[i].panel] button:SetText(button.name) button:SetHorizontalAlignment(TEXT_ALIGN_LEFT) button:SetWidth(190) if i == 1 then - button:SetAnchor(TOPLEFT, list, TOPLEFT, 5, 5) + button:SetAnchor(TOPLEFT, list.scrollChild, TOPLEFT, 5, 5) else button:SetAnchor(TOPLEFT, _G["LAMAddonMenuButton"..i-1], BOTTOMLEFT) end @@ -268,6 +275,9 @@ local function CreateAddonList() bg:SetEdgeTexture("EsoUI\\Art\\miscellaneous\\borderedinsettransparent_edgefile.dds", 128, 16) bg:SetCenterColor(0, 0, 0, 0) + list.scrollChild = LAMAddonPanelsMenuScrollChild + list.scrollChild:SetResizeToFitPadding(0, 15) + local generatedButtons list:SetHandler("OnShow", function(self) if not generatedButtons and #addonsForList > 0 then diff --git a/Libs/LibAddonMenu-2.0/controls/button.lua b/Libs/LibAddonMenu-2.0/controls/button.lua index 9954a1e..090a812 100644 --- a/Libs/LibAddonMenu-2.0/controls/button.lua +++ b/Libs/LibAddonMenu-2.0/controls/button.lua @@ -11,7 +11,7 @@ } ]] -local widgetVersion = 2 +local widgetVersion = 3 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("button", widgetVersion) then return end @@ -34,7 +34,7 @@ end --controlName is optional function LAMCreateControl.button(parent, buttonData, controlName) local control = wm:CreateTopLevelWindow(controlName or buttonData.reference) - control:SetParent(parent.scroll) + control:SetParent(parent.scroll or parent) local isHalfWidth = buttonData.width == "half" control:SetDimensions(isHalfWidth and 250 or 510, isHalfWidth and 55 or 28) diff --git a/Libs/LibAddonMenu-2.0/controls/checkbox.lua b/Libs/LibAddonMenu-2.0/controls/checkbox.lua index 8432109..b178043 100644 --- a/Libs/LibAddonMenu-2.0/controls/checkbox.lua +++ b/Libs/LibAddonMenu-2.0/controls/checkbox.lua @@ -12,7 +12,7 @@ } ]] -local widgetVersion = 4 +local widgetVersion = 5 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("checkbox", widgetVersion) then return end @@ -105,7 +105,7 @@ end --controlName is optional function LAMCreateControl.checkbox(parent, checkboxData, controlName) local control = wm:CreateTopLevelWindow(controlName or checkboxData.reference) - control:SetParent(parent.scroll) + control:SetParent(parent.scroll or parent) control:SetMouseEnabled(true) control.tooltipText = checkboxData.tooltip control:SetHandler("OnMouseEnter", OnMouseEnter) diff --git a/Libs/LibAddonMenu-2.0/controls/colorpicker.lua b/Libs/LibAddonMenu-2.0/controls/colorpicker.lua index af645ba..42e8e25 100644 --- a/Libs/LibAddonMenu-2.0/controls/colorpicker.lua +++ b/Libs/LibAddonMenu-2.0/controls/colorpicker.lua @@ -12,7 +12,7 @@ } ]] -local widgetVersion = 2 +local widgetVersion = 3 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("colorpicker", widgetVersion) then return end @@ -59,7 +59,7 @@ end function LAMCreateControl.colorpicker(parent, colorpickerData, controlName) local control = wm:CreateTopLevelWindow(controlName or colorpickerData.reference) - control:SetParent(parent.scroll) + control:SetParent(parent.scroll or parent) control:SetMouseEnabled(true) control.tooltipText = colorpickerData.tooltip control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) diff --git a/Libs/LibAddonMenu-2.0/controls/custom.lua b/Libs/LibAddonMenu-2.0/controls/custom.lua index ae7cdb2..54c9775 100644 --- a/Libs/LibAddonMenu-2.0/controls/custom.lua +++ b/Libs/LibAddonMenu-2.0/controls/custom.lua @@ -1,19 +1,27 @@ --[[customData = { type = "custom", - reference = "MyAddonCustomControl", --unique name for your control to use as reference + 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) } ]] -local widgetVersion = 2 +local widgetVersion = 4 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("custom", widgetVersion) then return end local wm = WINDOW_MANAGER +local tinsert = table.insert + +local function UpdateValue(control) + if control.data.refreshFunc then + control.data.refreshFunc(control) + end +end function LAMCreateControl.custom(parent, customData, controlName) local control = wm:CreateTopLevelWindow(controlName or customData.reference) control:SetResizeToFitDescendents(true) - control:SetParent(parent.scroll) + control:SetParent(parent.scroll or parent) local isHalfWidth = customData.width == "half" if isHalfWidth then --note these restrictions @@ -27,5 +35,11 @@ function LAMCreateControl.custom(parent, customData, controlName) control.panel = parent.panel or parent --if this is in a submenu, panel is its parent control.data = customData + control.UpdateValue = UpdateValue + + if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list + tinsert(control.panel.controlsToRefresh, control) + end + return control end \ No newline at end of file diff --git a/Libs/LibAddonMenu-2.0/controls/description.lua b/Libs/LibAddonMenu-2.0/controls/description.lua index 2db253b..5d7219d 100644 --- a/Libs/LibAddonMenu-2.0/controls/description.lua +++ b/Libs/LibAddonMenu-2.0/controls/description.lua @@ -7,16 +7,24 @@ } ]] -local widgetVersion = 2 +local widgetVersion = 4 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("description", widgetVersion) then return end local wm = WINDOW_MANAGER +local tinsert = table.insert + +local function UpdateValue(control) + if control.title then + control.title:SetText(control.data.title) + end + control.desc:SetText(control.data.text) +end function LAMCreateControl.description(parent, descriptionData, controlName) local control = wm:CreateTopLevelWindow(controlName or descriptionData.reference) control:SetResizeToFitDescendents(true) - control:SetParent(parent.scroll) + control:SetParent(parent.scroll or parent) local isHalfWidth = descriptionData.width == "half" if isHalfWidth then control:SetDimensionConstraints(250, 55, 250, 100) @@ -47,6 +55,12 @@ function LAMCreateControl.description(parent, descriptionData, controlName) control.panel = parent.panel or parent --if this is in a submenu, panel is its parent control.data = descriptionData + + control.UpdateValue = UpdateValue + + if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list + tinsert(control.panel.controlsToRefresh, control) + end return control diff --git a/Libs/LibAddonMenu-2.0/controls/dropdown.lua b/Libs/LibAddonMenu-2.0/controls/dropdown.lua index e338db6..4ced295 100644 --- a/Libs/LibAddonMenu-2.0/controls/dropdown.lua +++ b/Libs/LibAddonMenu-2.0/controls/dropdown.lua @@ -14,7 +14,7 @@ } ]] -local widgetVersion = 3 +local widgetVersion = 5 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("dropdown", widgetVersion) then return end @@ -86,7 +86,7 @@ end local comboboxCount = 1 function LAMCreateControl.dropdown(parent, dropdownData, controlName) local control = wm:CreateTopLevelWindow(controlName or dropdownData.reference) - control:SetParent(parent.scroll) + control:SetParent(parent.scroll or parent) control:SetMouseEnabled(true) control.tooltipText = dropdownData.tooltip control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) @@ -116,21 +116,19 @@ function LAMCreateControl.dropdown(parent, dropdownData, controlName) if isHalfWidth then control:SetDimensions(250, 55) label:SetDimensions(250, 26) - combobox:SetDimensions(240, 26) - --dropdown:SetWidth(240) + combobox:SetDimensions(225, 26) combobox:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT) else control:SetDimensions(510, 30) label:SetDimensions(300, 26) combobox:SetDimensions(200, 26) - --dropdown:SetWidth(200) combobox:SetAnchor(TOPRIGHT) end - if warning then + if dropdownData.warning then control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") control.warning:SetAnchor(RIGHT, combobox, LEFT, -5, 0) - control.warning.tooltipText = warningText + control.warning.tooltipText = dropdownData.warning end control.panel = parent.panel or parent --if this is in a submenu, panel is its parent diff --git a/Libs/LibAddonMenu-2.0/controls/editbox.lua b/Libs/LibAddonMenu-2.0/controls/editbox.lua index f2b4ded..3b92ea0 100644 --- a/Libs/LibAddonMenu-2.0/controls/editbox.lua +++ b/Libs/LibAddonMenu-2.0/controls/editbox.lua @@ -13,7 +13,7 @@ } ]] -local widgetVersion = 3 +local widgetVersion = 4 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("editbox", widgetVersion) then return end @@ -61,7 +61,7 @@ end function LAMCreateControl.editbox(parent, editboxData, controlName) local control = wm:CreateTopLevelWindow(controlName or editboxData.reference) - control:SetParent(parent.scroll) + control:SetParent(parent.scroll or parent) control:SetMouseEnabled(true) control:SetResizeToFitDescendents(true) control.tooltipText = editboxData.tooltip diff --git a/Libs/LibAddonMenu-2.0/controls/header.lua b/Libs/LibAddonMenu-2.0/controls/header.lua index 46250ca..bbf2c60 100644 --- a/Libs/LibAddonMenu-2.0/controls/header.lua +++ b/Libs/LibAddonMenu-2.0/controls/header.lua @@ -6,15 +6,20 @@ } ]] -local widgetVersion = 2 +local widgetVersion = 4 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("header", widgetVersion) then return end local wm = WINDOW_MANAGER +local tinsert = table.insert + +local function UpdateValue(control) + control.header:SetText(control.data.name) +end function LAMCreateControl.header(parent, headerData, controlName) local control = wm:CreateTopLevelWindow(controlName or headerData.reference) - control:SetParent(parent.scroll) + control:SetParent(parent.scroll or parent) local isHalfWidth = headerData.width == "half" control:SetDimensions(isHalfWidth and 250 or 510, 30) @@ -32,5 +37,11 @@ function LAMCreateControl.header(parent, headerData, controlName) control.panel = parent.panel or parent --if this is in a submenu, panel is its parent control.data = headerData + control.UpdateValue = UpdateValue + + if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list + tinsert(control.panel.controlsToRefresh, control) + end + return control end \ No newline at end of file diff --git a/Libs/LibAddonMenu-2.0/controls/panel.lua b/Libs/LibAddonMenu-2.0/controls/panel.lua index ed3d2ff..5f9f41b 100644 --- a/Libs/LibAddonMenu-2.0/controls/panel.lua +++ b/Libs/LibAddonMenu-2.0/controls/panel.lua @@ -11,7 +11,7 @@ } ]] -local widgetVersion = 5 +local widgetVersion = 8 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("panel", widgetVersion) then return end @@ -70,7 +70,8 @@ ESO_Dialogs["LAM_DEFAULTS"] = { }, } -local scrollCount = 1 +local callbackRegistered = false +LAMCreateControl.scrollCount = LAMCreateControl.scrollCount or 1 function LAMCreateControl.panel(parent, panelData, controlName) local control = wm:CreateTopLevelWindow(controlName) control:SetParent(parent) @@ -103,8 +104,8 @@ function LAMCreateControl.panel(parent, panelData, controlName) end end - control.container = wm:CreateControlFromVirtual("LAMAddonPanelContainer"..scrollCount, control, "ZO_ScrollContainer") - scrollCount = scrollCount + 1 + control.container = wm:CreateControlFromVirtual("LAMAddonPanelContainer"..LAMCreateControl.scrollCount, control, "ZO_ScrollContainer") + LAMCreateControl.scrollCount = LAMCreateControl.scrollCount + 1 local container = control.container container:SetAnchor(TOPLEFT, label, BOTTOMLEFT, 0, 20) container:SetAnchor(BOTTOMRIGHT, control, BOTTOMRIGHT, -3, -3) @@ -125,8 +126,9 @@ function LAMCreateControl.panel(parent, panelData, controlName) end) end - if panelData.registerForRefresh then + if panelData.registerForRefresh and not callbackRegistered then --don't want to register our callback more than once cm:RegisterCallback("LAM-RefreshPanel", RefreshPanel) + callbackRegistered = true end control.data = panelData diff --git a/Libs/LibAddonMenu-2.0/controls/slider.lua b/Libs/LibAddonMenu-2.0/controls/slider.lua index b28e1b8..d26f314 100644 --- a/Libs/LibAddonMenu-2.0/controls/slider.lua +++ b/Libs/LibAddonMenu-2.0/controls/slider.lua @@ -15,7 +15,7 @@ } ]] -local widgetVersion = 2 +local widgetVersion = 3 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("slider", widgetVersion) then return end @@ -69,7 +69,7 @@ end function LAMCreateControl.slider(parent, sliderData, controlName) local control = wm:CreateTopLevelWindow(controlName or sliderData.reference) - control:SetParent(parent.scroll) + control:SetParent(parent.scroll or parent) local isHalfWidth = sliderData.width == "half" if isHalfWidth then control:SetDimensions(250, 55) @@ -164,7 +164,7 @@ function LAMCreateControl.slider(parent, sliderData, controlName) control.warning.tooltipText = sliderData.warning end - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent + control.panel = parent.panel or parent --if this is in a submenu, panel is the submenu's parent control.data = sliderData if sliderData.disabled then diff --git a/Libs/LibAddonMenu-2.0/controls/submenu.lua b/Libs/LibAddonMenu-2.0/controls/submenu.lua index 8a599c0..41e8402 100644 --- a/Libs/LibAddonMenu-2.0/controls/submenu.lua +++ b/Libs/LibAddonMenu-2.0/controls/submenu.lua @@ -6,16 +6,24 @@ reference = "MyAddonSubmenu" --(optional) unique global reference to control } ]] -local widgetVersion = 3 +local widgetVersion = 5 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("submenu", widgetVersion) then return end local wm = WINDOW_MANAGER local am = ANIMATION_MANAGER +local tinsert = table.insert -local function AnimateSubmenu(label) - local control = label:GetParent() +local function UpdateValue(control) + control.label:SetText(control.data.name) + if control.data.tooltip then + control.label.tooltipText = control.data.tooltip + end +end + +local function AnimateSubmenu(clicked) + local control = clicked:GetParent() control.open = not control.open if control.open then @@ -28,7 +36,7 @@ end function LAMCreateControl.submenu(parent, submenuData, controlName) local control = wm:CreateTopLevelWindow(controlName or submenuData.reference) - control:SetParent(parent.scroll) + control:SetParent(parent.scroll or parent) control.panel = parent control:SetDimensions(523, 40) @@ -90,8 +98,24 @@ function LAMCreateControl.submenu(parent, submenuData, controlName) end end) + --small strip at the bottom of the submenu that you can click to close it + control.btmToggle = wm:CreateControl(nil, control, CT_TEXTURE) + local btmToggle = control.btmToggle + btmToggle:SetMouseEnabled(true) + btmToggle:SetAnchor(BOTTOMLEFT, control.scroll, BOTTOMLEFT) + btmToggle:SetAnchor(BOTTOMRIGHT, control.scroll, BOTTOMRIGHT) + btmToggle:SetHeight(15) + btmToggle:SetAlpha(0) + btmToggle:SetHandler("OnMouseUp", AnimateSubmenu) + control.data = submenuData + control.UpdateValue = UpdateValue + + if control.panel.data.registerForRefresh or control.panel.data.registerForDefaults then --if our parent window wants to refresh controls, then add this to the list + tinsert(control.panel.controlsToRefresh, control) + end + return control end diff --git a/Libs/LibAddonMenu-2.0/controls/texture.lua b/Libs/LibAddonMenu-2.0/controls/texture.lua index fc4be69..8ce85de 100644 --- a/Libs/LibAddonMenu-2.0/controls/texture.lua +++ b/Libs/LibAddonMenu-2.0/controls/texture.lua @@ -10,7 +10,7 @@ --add texture coords support? -local widgetVersion = 2 +local widgetVersion = 3 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("texture", widgetVersion) then return end @@ -19,7 +19,7 @@ local wm = WINDOW_MANAGER function LAMCreateControl.texture(parent, textureData, controlName) local control = wm:CreateTopLevelWindow(controlName or textureData.reference) control:SetResizeToFitDescendents(true) - control:SetParent(parent.scroll) + control:SetParent(parent.scroll or parent) local isHalfWidth = textureData.width == "half" if isHalfWidth then