diff --git a/Clock.lua b/Clock.lua index b05ba19..c37668c 100644 --- a/Clock.lua +++ b/Clock.lua @@ -3,8 +3,11 @@ ------------------------------------------- cl = {} -cl.VERSION = "0.6.2" -cl.SAV_VERSION = 0.6 +cl.VERSION = "0.7.0" +cl.SAV_VERSION = 0.7 + +cl.LAM = LibStub:GetLibrary("LibAddonMenu-2.0") +cl.LMP = LibStub:GetLibrary("LibMediaProvider-1.0") ------------------------------------------- -- main diff --git a/Clock.txt b/Clock.txt index 7a9b0e1..81e6821 100644 --- a/Clock.txt +++ b/Clock.txt @@ -12,10 +12,10 @@ ## Manifest ## ################################### -## Title: Clock - By |c5175ea@Tyx|r -## Version 0.6.2 -## Author: @Tyx -## APIVersion: 100010 +## Title: Clock |cFFA5000.6.2|r +## Version 0.7.0 +## Author: |c5175eaTyx|r +## APIVersion: 100011 ## SavedVariables: Clock_Settings ## OptionalDependsOn: LibAddonMenu-2.0 @@ -23,8 +23,8 @@ ## Libraries ## ############### -## Author: Seerah ## Source: http://www.esoui.com/downloads/info7-LibAddonMenu.html +## Source_Author: Seerah libs\LibStub\LibStub.lua libs\LibAddonMenu-2.0\LibAddonMenu-2.0.lua libs\LibAddonMenu-2.0\controls\panel.lua @@ -40,8 +40,8 @@ libs\LibAddonMenu-2.0\controls\header.lua libs\LibAddonMenu-2.0\controls\slider.lua libs\LibAddonMenu-2.0\controls\texture.lua -## Author: Seerah ## Source: http://www.esoui.com/downloads/info56-LibMediaProvider.html +## Source_Author: Seerah libs\LibMediaProvider-1.0\LibMediaProvider-1.0.lua ################# diff --git a/data/gui.lua b/data/gui.lua index feef722..6a0adb6 100644 --- a/data/gui.lua +++ b/data/gui.lua @@ -4,8 +4,9 @@ cl.ui = {} local ui = cl.ui -local LAM = LibStub:GetLibrary("LibAddonMenu-2.0") -local LMP = LibStub:GetLibrary("LibMediaProvider-1.0") +local LAM = cl.LAM +local LMP = cl.LMP + local loc = {} local panel = { type = "panel", @@ -67,6 +68,14 @@ local function AddToggle() }, [4] = { type = "checkbox", + name = loc.nsBg, + tooltip = loc.tsBg, + getFunc = function() return cl.st.ShowBg() end, + setFunc = function(value) cl.st.SetShowBg(value) end, + disabled = function() return not cl.st.IsActive() end, + }, + [5] = { + type = "checkbox", name = loc.sAHide, tooltip = loc.tAHide, getFunc = function() return cl.st.AutoHide() end, @@ -76,7 +85,7 @@ local function AddToggle() end, disabled = function() return not cl.st.IsActive() end, }, - [5] = { + [6] = { type = "checkbox", name = loc.sFormat, getFunc = function() return cl.st.IsUSTime() end, @@ -86,14 +95,14 @@ local function AddToggle() end, disabled = function() return not cl.st.IsActive() end, }, - [6] = { + [7] = { type = "checkbox", name = loc.sAMPM, getFunc = function() return cl.st.ShowUS() end, setFunc = function(value) cl.st.SetShowUS(value) end, disabled = function() return not cl.st.IsUSTime() or not cl.st.IsActive() end, }, - [7] = { + [8] = { type = "checkbox", name = loc.sNum, tooltip = loc.tNum, @@ -101,14 +110,14 @@ local function AddToggle() setFunc = function(value) cl.st.SetShowNum(value) end, disabled = function() return not cl.st.IsActive() end, }, - [8] = { + [9] = { type = "checkbox", name = loc.sSec, getFunc = function() return cl.st.ShowSec() end, setFunc = function(value) cl.st.SetShowSec(value) end, disabled = function() return not cl.st.IsActive() end, }, - [9] = { + [10] = { type = "checkbox", name = loc.sMoon, tooltip = loc.tMoon, @@ -116,7 +125,7 @@ local function AddToggle() setFunc = function(value) cl.st.SetShowMoon(value) end, disabled = function() return not cl.st.IsActive() end, }, - [10] = { + [11] = { type = "checkbox", name = loc.sLDate, tooltip = loc.tLDate, @@ -129,7 +138,7 @@ local function AddToggle() end, disabled = function() return not cl.st.IsActive() end, }, - [11] = { + [12] = { type = "checkbox", name = loc.sFLDate, tooltip = loc.tFLDate, @@ -142,7 +151,7 @@ local function AddToggle() end, disabled = function() return not cl.st.IsActive() end, }, - [12] = { + [13] = { type = "checkbox", name = loc.sRT, tooltip = loc.tRT, @@ -150,7 +159,7 @@ local function AddToggle() setFunc = function(value) cl.st.SetShowRT(value) end, disabled = function() return not cl.st.IsActive() end, }, - [13] = { + [14] = { type = "checkbox", name = loc.sDate, tooltip = loc.tDate, @@ -158,6 +167,14 @@ local function AddToggle() setFunc = function(value) cl.st.SetShowDate(value) end, disabled = function() return not cl.st.IsActive() end, }, + [15] = { + type = "checkbox", + name = loc.sHor, + tooltip = loc.tHor, + getFunc = function() return cl.st.ShowHz() end, + setFunc = function(value) cl.st.SetShowHz(value) end, + disabled = function() return not cl.st.IsActive() end, + }, } } return toggle @@ -195,6 +212,16 @@ local function AddLook() getFunc = function() return cl.st.GetLook("style") end, setFunc = function(value) cl.st.SetLook("style", value) end }, + --[[ [4] = { + type = "dropdown", + name = loc.nBg, + tooltip = loc.tBg, + choices = LMP:List('background'), + getFunc = function() return cl.st.GetBg() end, + setFunc = function(value) cl.st.SetBg(value) end, + disabled = function() return not cl.st.ShowBg() end + }, + --]] [4] = { type = "slider", name = loc.nSize, @@ -220,7 +247,7 @@ local function AddLook() title = loc.descEditLookE, text = loc.descEditLookETxt, }, - [8] = { + [9] = { type = "editbox", name = loc.nELore, tooltip = loc.tELore, @@ -228,7 +255,7 @@ local function AddLook() setFunc = function(value) cl.st.SetFormat("lore", value) end, isMultiline = true, }, - [9] = { + [8] = { type = "editbox", name = loc.nEReal, tooltip = loc.tEReal, @@ -535,9 +562,9 @@ end -- Init ------------------ function ui.InitSettings() - LAM:RegisterAddonPanel("ClockSettings", panel) - loc = cl.ln.gui -- Localization table with the current selected language + + LAM:RegisterAddonPanel("ClockSettings", panel) local data = { [1] = AddToggle(), diff --git a/data/settings.lua b/data/settings.lua index b8366e9..c5fb558 100644 --- a/data/settings.lua +++ b/data/settings.lua @@ -22,6 +22,8 @@ local defaults = { show_fldate = false, show_date = false, show_rt = false, + show_bg = true, + show_hz = false, time = { start = 1398044126, -- exact unix time at the calculated game time start in s daytime = 20955, -- length of one day in s (default 5.75h right now) @@ -44,11 +46,12 @@ local defaults = { r = 1, g = 1, b = 1, - a = 0.5, + a = 0.75, }, - font = "ESO Cartographer", + font = "ESO Book Font", style = "thin_shadow", size = 24, + bg = "Solid", format = { lore = "_DDD, _D. _MMM _YY _hh:_mm:_ss", real = "_DDD, _D. _MMM _YY _hh:_mm:_ss", @@ -123,6 +126,16 @@ function st.SetShowRT(rt) cl.vi.UpdateClock() end +function st.SetShowBg(bg) + cl.settings.show_bg = bg + cl.vi.UpdateClock() +end + +function st.SetShowHz(hz) + cl.settings.show_hz = hz + cl.vi.UpdateClock() +end + ---------------------------------- ----------- @@ -162,6 +175,11 @@ function st.SetFormat(name, value) cl.vi.UpdateClock() end +function st.SetBg(bg) + cl.settings.look.bg = bg + cl.vi.UpdateClock() +end + ------------------ -- GET ------------------ @@ -227,6 +245,14 @@ function st.ShowRT() return cl.settings.show_rt end +function st.ShowBg() + return cl.settings.show_bg +end + +function st.ShowHz() + return cl.settings.show_hz +end + ----------- -- moon ----------- @@ -269,6 +295,10 @@ function st.GetFormat(name) return cl.settings.look.format[name] end +function st.GetBg() + return cl.settings.look.bg +end + ------------------ -- language ------------------ diff --git a/data/time.lua b/data/time.lua index 9c521f1..0aa5fd5 100644 --- a/data/time.lua +++ b/data/time.lua @@ -221,11 +221,12 @@ function tm.GetRealWeekDay(day, month, yearShort) if dd + 1 > m[mm] then if mm + 1 > 12 then + dd = 1 mm = 1 yy = yy + 1 else - mm = mm + 1 dd = 1 + mm = mm + 1 end else dd = dd + 1 diff --git a/data/view.lua b/data/view.lua index 7dc565b..58885ce 100644 --- a/data/view.lua +++ b/data/view.lua @@ -4,7 +4,7 @@ cl.vi = {} local vi = cl.vi -local LMP = LibStub:GetLibrary("LibMediaProvider-1.0") +local LMP = cl.LMP local loc local CLOCKUI_SCENE_FRAGMENT @@ -286,7 +286,7 @@ function vi.UpdateMoon() vi.moontexture:SetAnchor(CENTER, ClockUITime, TOPLEFT, -2 / 3 * size, 1 / 3 * size) vi.moontexture:SetTexture(vi.moons[moon]) - + local font = LMP:Fetch('font', cl.st.GetLook("font")) local style = cl.st.GetLook("style") local size = cl.st.GetLook("size") @@ -325,6 +325,8 @@ local function IsMenuHidden() end function vi.UpdateClock() + vi.UpdateBackground() + ClockUITime:SetColor(cl.st.GetColor()) local font = LMP:Fetch('font', cl.st.GetLook("font")) @@ -340,7 +342,38 @@ function vi.UpdateClock() ClockUI:SetMouseEnabled(cl.st.IsMoveable()) end +function vi.UpdateBackground() + --local bg = LMP:Fetch('background', cl.st.GetBg()) + local size = cl.st.GetLook("size") + + local x = ClockUITime:GetDimensions() * 2 + local y = size * 8 + local pos_y = -size/2 + + if cl.st.ShowRT() or cl.st.ShowDate() then -- real + if cl.st.ShowMoon() or cl.st.ShowTime() or cl.st.ShowFLDate() or cl.st.ShowLoreDate() then -- lore + real + if not cl.st.ShowHz() then + y = y*2 + pos_y = 0 + end + else + pos_y = size/2 + end + end + if cl.st.ShowHz() then + pos_y = 0 + end + + vi.background:ClearAnchors() + vi.background:SetAnchor(CENTER, ClockUITime, CENTER, 0, pos_y) + vi.background:SetDimensions(x, y) + vi.background:SetTexture("EsoUI/Art/Performance/StatusMeterMunge.dds") + + +end + function vi.PrintClock() + local osT = GetTimeStamp() local tst = cl.tm.GetTST(osT) local lore, real @@ -374,7 +407,11 @@ function vi.PrintClock() real = vi.ParseFormat(year, month, day, hour, minute, second, false) - ClockUITime:SetText(lore .. "\n" .. real) + if cl.st.ShowHz() then + ClockUITime:SetText(lore .. "\t" .. real) + else + ClockUITime:SetText(lore .. "\n" .. real) + end vi.UpdateClock() @@ -385,11 +422,17 @@ function vi.PrintClock() HUD_SCENE:RemoveFragment(CLOCKUI_SCENE_FRAGMENT) HUD_UI_SCENE:RemoveFragment(CLOCKUI_SCENE_FRAGMENT) end - + + vi.HideBackground(cl.st.ShowBg()) vi.HideMoon(cl.st.ShowMoon()) vi.HideClock(cl.st.IsActive()) end +function vi.HideBackground(value) + local value = not value + vi.background:SetHidden(value) +end + function vi.HideMoon(value) local value = not value vi.moontexture:SetHidden(value) @@ -397,8 +440,14 @@ function vi.HideMoon(value) end function vi.InitMoon() - vi.moontexture = WINDOW_MANAGER:CreateControl("cl_moontexture", ClockUITime, CT_TEXTURE) - vi.moonlabel = WINDOW_MANAGER:CreateControl("cl_moonlabel", ClockUITime, CT_LABEL) + vi.moontexture = WINDOW_MANAGER:GetControlByName("cl_moontexture") + if not vi.moontexture then + vi.moontexture = WINDOW_MANAGER:CreateControl("cl_moontexture", ClockUITime, CT_TEXTURE) + end + vi.moonlabel = WINDOW_MANAGER:GetControlByName("cl_moonlabel") + if not vi.moonlabel then + vi.moonlabel = WINDOW_MANAGER:CreateControl("cl_moonlabel", ClockUITime, CT_LABEL) + end end function vi.HideClock(value) @@ -415,6 +464,11 @@ function vi.InitClock() ClockUITime:ClearAnchors() ClockUITime:SetAnchor(CENTER, ClockUI, CENTER, 0, 0) + vi.background = WINDOW_MANAGER:GetControlByName("cl_background") + if not vi.background then + vi.background = WINDOW_MANAGER:CreateControl("cl_background", ClockUITime, CT_TEXTURE) + end + -- Thanks Garkin for the method CALLBACK_MANAGER:RegisterCallback("LAM-PanelControlsCreated", function(panel) diff --git a/img/waningmoon.dds b/img/waningmoon.dds index a68dd90..1aa7384 100644 Binary files a/img/waningmoon.dds and b/img/waningmoon.dds differ diff --git a/img/waxingmoon.dds b/img/waxingmoon.dds index 1aa7384..a68dd90 100644 Binary files a/img/waxingmoon.dds and b/img/waxingmoon.dds differ diff --git a/libs/LibAddonMenu-2.0/LICENSE b/libs/LibAddonMenu-2.0/LICENSE new file mode 100644 index 0000000..82fcf2f --- /dev/null +++ b/libs/LibAddonMenu-2.0/LICENSE @@ -0,0 +1,201 @@ + The Artistic License 2.0 + + Copyright (c) 2015 Ryan Lakanen (Seerah) + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +Preamble + +This license establishes the terms under which a given free software +Package may be copied, modified, distributed, and/or redistributed. +The intent is that the Copyright Holder maintains some artistic +control over the development of that Package while still keeping the +Package available as open source and free software. + +You are always permitted to make arrangements wholly outside of this +license directly with the Copyright Holder of a given Package. If the +terms of this license do not permit the full use that you propose to +make of the Package, you should contact the Copyright Holder and seek +a different licensing arrangement. + +Definitions + + "Copyright Holder" means the individual(s) or organization(s) + named in the copyright notice for the entire Package. + + "Contributor" means any party that has contributed code or other + material to the Package, in accordance with the Copyright Holder's + procedures. + + "You" and "your" means any person who would like to copy, + distribute, or modify the Package. + + "Package" means the collection of files distributed by the + Copyright Holder, and derivatives of that collection and/or of + those files. A given Package may consist of either the Standard + Version, or a Modified Version. + + "Distribute" means providing a copy of the Package or making it + accessible to anyone else, or in the case of a company or + organization, to others outside of your company or organization. + + "Distributor Fee" means any fee that you charge for Distributing + this Package or providing support for this Package to another + party. It does not mean licensing fees. + + "Standard Version" refers to the Package if it has not been + modified, or has been modified only in ways explicitly requested + by the Copyright Holder. + + "Modified Version" means the Package, if it has been changed, and + such changes were not explicitly requested by the Copyright + Holder. + + "Original License" means this Artistic License as Distributed with + the Standard Version of the Package, in its current version or as + it may be modified by The Perl Foundation in the future. + + "Source" form means the source code, documentation source, and + configuration files for the Package. + + "Compiled" form means the compiled bytecode, object code, binary, + or any other form resulting from mechanical transformation or + translation of the Source form. + + +Permission for Use and Modification Without Distribution + +(1) You are permitted to use the Standard Version and create and use +Modified Versions for any purpose without restriction, provided that +you do not Distribute the Modified Version. + + +Permissions for Redistribution of the Standard Version + +(2) You may Distribute verbatim copies of the Source form of the +Standard Version of this Package in any medium without restriction, +either gratis or for a Distributor Fee, provided that you duplicate +all of the original copyright notices and associated disclaimers. At +your discretion, such verbatim copies may or may not include a +Compiled form of the Package. + +(3) You may apply any bug fixes, portability changes, and other +modifications made available from the Copyright Holder. The resulting +Package will still be considered the Standard Version, and as such +will be subject to the Original License. + + +Distribution of Modified Versions of the Package as Source + +(4) You may Distribute your Modified Version as Source (either gratis +or for a Distributor Fee, and with or without a Compiled form of the +Modified Version) provided that you clearly document how it differs +from the Standard Version, including, but not limited to, documenting +any non-standard features, executables, or modules, and provided that +you do at least ONE of the following: + + (a) make the Modified Version available to the Copyright Holder + of the Standard Version, under the Original License, so that the + Copyright Holder may include your modifications in the Standard + Version. + + (b) ensure that installation of your Modified Version does not + prevent the user installing or running the Standard Version. In + addition, the Modified Version must bear a name that is different + from the name of the Standard Version. + + (c) allow anyone who receives a copy of the Modified Version to + make the Source form of the Modified Version available to others + under + + (i) the Original License or + + (ii) a license that permits the licensee to freely copy, + modify and redistribute the Modified Version using the same + licensing terms that apply to the copy that the licensee + received, and requires that the Source form of the Modified + Version, and of any works derived from it, be made freely + available in that license fees are prohibited but Distributor + Fees are allowed. + + +Distribution of Compiled Forms of the Standard Version +or Modified Versions without the Source + +(5) You may Distribute Compiled forms of the Standard Version without +the Source, provided that you include complete instructions on how to +get the Source of the Standard Version. Such instructions must be +valid at the time of your distribution. If these instructions, at any +time while you are carrying out such distribution, become invalid, you +must provide new instructions on demand or cease further distribution. +If you provide valid instructions or cease distribution within thirty +days after you become aware that the instructions are invalid, then +you do not forfeit any of your rights under this license. + +(6) You may Distribute a Modified Version in Compiled form without +the Source, provided that you comply with Section 4 with respect to +the Source of the Modified Version. + + +Aggregating or Linking the Package + +(7) You may aggregate the Package (either the Standard Version or +Modified Version) with other packages and Distribute the resulting +aggregation provided that you do not charge a licensing fee for the +Package. Distributor Fees are permitted, and licensing fees for other +components in the aggregation are permitted. The terms of this license +apply to the use and Distribution of the Standard or Modified Versions +as included in the aggregation. + +(8) You are permitted to link Modified and Standard Versions with +other works, to embed the Package in a larger work of your own, or to +build stand-alone binary or bytecode versions of applications that +include the Package, and Distribute the result without restriction, +provided the result does not expose a direct interface to the Package. + + +Items That are Not Considered Part of a Modified Version + +(9) Works (including, but not limited to, modules and scripts) that +merely extend or make use of the Package, do not, by themselves, cause +the Package to be a Modified Version. In addition, such works are not +considered parts of the Package itself, and are not subject to the +terms of this license. + + +General Provisions + +(10) Any use, modification, and distribution of the Standard or +Modified Versions is governed by this Artistic License. By using, +modifying or distributing the Package, you accept this license. Do not +use, modify, or distribute the Package, if you do not accept this +license. + +(11) If your Modified Version has been derived from a Modified +Version made by someone other than you, you are nevertheless required +to ensure that your Modified Version complies with the requirements of +this license. + +(12) This license does not grant you the right to use any trademark, +service mark, tradename, or logo of the Copyright Holder. + +(13) This license includes the non-exclusive, worldwide, +free-of-charge patent license to make, have made, use, offer to sell, +sell, import and otherwise transfer the Package with respect to any +patent claims licensable by the Copyright Holder that are necessarily +infringed by the Package. If you institute patent litigation +(including a cross-claim or counterclaim) against any party alleging +that the Package constitutes direct or contributory patent +infringement, then this Artistic License to you shall terminate on the +date that such litigation is filed. + +(14) Disclaimer of Warranty: +THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS +IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR +NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL +LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua b/libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua index 0d30640..03fb4c4 100644 --- a/libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua +++ b/libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua @@ -1,16 +1,34 @@ --- LibAddonMenu-2.0 & its files © Ryan Lakanen (Seerah) -- --- All Rights Reserved -- --- Permission is granted to use Seerah's LibAddonMenu-2.0 -- --- in your project. Any modifications to LibAddonMenu-2.0 -- --- may not be redistributed. -- --------------------------------------------------------------- +-- LibAddonMenu-2.0 & its files © Ryan Lakanen (Seerah) -- +-- Distributed under The Artistic License 2.0 (see LICENSE) -- +------------------------------------------------------------------ --Register LAM with LibStub -local MAJOR, MINOR = "LibAddonMenu-2.0", 16 +local MAJOR, MINOR = "LibAddonMenu-2.0", 17 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 +if not lam then return end --the same or newer version of this lib is already loaded into memory + +local messages = {} +local MESSAGE_PREFIX = "[LAM2] " +local function PrintLater(msg) + if(CHAT_SYSTEM.primaryContainer) then + d(MESSAGE_PREFIX .. msg) + else + messages[#messages + 1] = msg + end +end +local function FlushMessages() + for i = 1, #messages do + d(MESSAGE_PREFIX .. messages[i]) + end + messages = {} +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 +end --UPVALUES-- local wm = WINDOW_MANAGER @@ -36,35 +54,43 @@ LAMCreateControl = LAMCreateControl or {} local lamcc = LAMCreateControl function lam:RegisterWidget(widgetType, widgetVersion) - if widgets[widgetType] and widgets[widgetType] >= widgetVersion then - return false - else - widgets[widgetType] = widgetVersion - return true - end + if widgets[widgetType] and widgets[widgetType] >= widgetVersion then + return false + else + widgets[widgetType] = widgetVersion + return true + end end --METHOD: OPEN TO ADDON PANEL-- --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")] +-- panel = userdata; the panel returned by the :RegisterOptionsPanel method local locSettings = GetString(SI_GAME_MENU_SETTINGS) function lam:OpenToPanel(panel) - SCENE_MANAGER:Show("gameMenuInGame") - zo_callLater(function() - ZO_GameMenu_InGame.gameMenu.headerControls[locSettings]:SetOpen(true) - SCENE_MANAGER:AddFragment(OPTIONS_WINDOW_FRAGMENT) - --ZO_OptionsWindow_ChangePanels(lam.panelID) - KEYBOARD_OPTIONS: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) + SCENE_MANAGER:Show("gameMenuInGame") + zo_callLater(function() + local settingsMenu = ZO_GameMenu_InGame.gameMenu.headerControls[locSettings] + settingsMenu:SetOpen(true) + SCENE_MANAGER:AddFragment(OPTIONS_WINDOW_FRAGMENT) + KEYBOARD_OPTIONS:ChangePanels(lam.panelID) + for i, child in pairs(settingsMenu.children) do + if type(child) == "table" and child.data.name == KEYBOARD_OPTIONS.panelNames[lam.panelID] then + ZO_TreeEntry_OnMouseUp(child.control, true) + break + end + end + local scroll = LAMAddonPanelsMenuScrollChild + for i = 1, scroll:GetNumChildren() do + local button = scroll:GetChild(i) + if button.panel == panel then + zo_callHandler(button, "OnClicked") + ZO_Scroll_ScrollControlToTop(LAMAddonPanelsMenu, button) + break + end + end + end, 200) end @@ -72,85 +98,100 @@ end --creates controls when options panel is first shown --controls anchoring of these controls in the panel local function CreateOptionsControls(panel) - local addonID = panel:GetName() - local optionsTable = addonToOptionsMap[addonID] - - if optionsTable then - local lastAddedControl, lacAtHalfRow - for _, widgetData in ipairs(optionsTable) do - local widgetType = widgetData.type - if widgetType == "submenu" then - local submenu = LAMCreateControl[widgetType](panel, widgetData) - if lastAddedControl then - submenu:SetAnchor(TOPLEFT, lastAddedControl, BOTTOMLEFT, 0, 15) - else - submenu:SetAnchor(TOPLEFT) - end - lastAddedControl = submenu - lacAtHalfRow = false - - local lastAddedControlSub, lacAtHalfRowSub - for _, subWidgetData in ipairs(widgetData.controls) do - local subWidgetType = subWidgetData.type - local subWidget = LAMCreateControl[subWidgetType](submenu, subWidgetData) - local isHalf = subWidgetData.width == "half" - if lastAddedControlSub then - if lacAtHalfRowSub and isHalf then - subWidget:SetAnchor(TOPLEFT, lastAddedControlSub, TOPRIGHT, 5, 0) - lacAtHalfRowSub = false - else - subWidget:SetAnchor(TOPLEFT, lastAddedControlSub, BOTTOMLEFT, 0, 15) - lacAtHalfRowSub = isHalf and true or false - lastAddedControlSub = subWidget - end - else - subWidget:SetAnchor(TOPLEFT) - lacAtHalfRowSub = isHalf and true or false - lastAddedControlSub = subWidget - end - end - else - local widget = LAMCreateControl[widgetType](panel, widgetData) - local isHalf = widgetData.width == "half" - if lastAddedControl then - if lacAtHalfRow and isHalf then - widget:SetAnchor(TOPLEFT, lastAddedControl, TOPRIGHT, 10, 0) - lacAtHalfRow = false - else - widget:SetAnchor(TOPLEFT, lastAddedControl, BOTTOMLEFT, 0, 15) - lacAtHalfRow = isHalf and true or false - lastAddedControl = widget - end - else - widget:SetAnchor(TOPLEFT) - lacAtHalfRow = isHalf and true or false - lastAddedControl = widget - end - end - end - end - - optionsCreated[addonID] = true - cm:FireCallbacks("LAM-PanelControlsCreated", panel) + local addonID = panel:GetName() + local optionsTable = addonToOptionsMap[addonID] + + if optionsTable then + local isHalf, widget + local lastAddedControl, lacAtHalfRow, oIndex, widgetData, widgetType + local submenu, subWidgetData, sIndex, subWidgetType, subWidget + local anchorOffset = 0 + local anchorOffsetSub + local lastAddedControlSub, lacAtHalfRowSub + for oIndex=1,#optionsTable do + widgetData = optionsTable[oIndex] + widgetType = widgetData.type + if widgetType == "submenu" then + submenu = LAMCreateControl[widgetType](panel, widgetData) + if lastAddedControl then + submenu:SetAnchor(TOPLEFT, lastAddedControl, BOTTOMLEFT, 0, 15 + anchorOffset) + else + submenu:SetAnchor(TOPLEFT) + end + lastAddedControl = submenu + lacAtHalfRow = false + + anchorOffsetSub = 0 + lacAtHalfRowSub = nil + lastAddedControlSub = nil + for sIndex=1,#widgetData.controls do + subWidgetData = widgetData.controls[sIndex] + subWidgetType = subWidgetData.type + subWidget = LAMCreateControl[subWidgetType](submenu, subWidgetData) + isHalf = subWidgetData.width == "half" + if lastAddedControlSub then + if lacAtHalfRowSub and isHalf then + subWidget:SetAnchor(TOPLEFT, lastAddedControlSub, TOPRIGHT, 5, 0) + lacAtHalfRowSub = false + anchorOffsetSub = zo_max(0, subWidget:GetHeight() - lastAddedControlSub:GetHeight()) + else + subWidget:SetAnchor(TOPLEFT, lastAddedControlSub, BOTTOMLEFT, 0, 15 + anchorOffsetSub) + lacAtHalfRowSub = isHalf + anchorOffsetSub = 0 + lastAddedControlSub = subWidget + end + else + subWidget:SetAnchor(TOPLEFT) + lacAtHalfRowSub = isHalf + lastAddedControlSub = subWidget + end + end + else + widget = LAMCreateControl[widgetType](panel, widgetData) + isHalf = widgetData.width == "half" + if lastAddedControl then + if lacAtHalfRow and isHalf then + widget:SetAnchor(TOPLEFT, lastAddedControl, TOPRIGHT, 10, 0) + anchorOffset = zo_max(0, widget:GetHeight() - lastAddedControl:GetHeight()) + lacAtHalfRow = false + else + widget:SetAnchor(TOPLEFT, lastAddedControl, BOTTOMLEFT, 0, 15 + anchorOffset) + lacAtHalfRow = isHalf + anchorOffset = 0 + lastAddedControl = widget + end + else + widget:SetAnchor(TOPLEFT) + lacAtHalfRow = isHalf + lastAddedControl = widget + end + end + end + end + + optionsCreated[addonID] = true + cm:FireCallbacks("LAM-PanelControlsCreated", panel) end --INTERNAL FUNCTION --handles switching between panels -local function ToggleAddonPanels(panel) --called in OnShow of newly shown panel - local currentlySelected = LAMAddonPanelsMenu.currentlySelected - if currentlySelected and currentlySelected ~= panel then - currentlySelected:SetHidden(true) - end - LAMAddonPanelsMenu.currentlySelected = panel - - if not optionsCreated[panel:GetName()] then --if this is the first time opening this panel, create these options - CreateOptionsControls(panel) - end - - cm:FireCallbacks("LAM-RefreshPanel", panel) +local function ToggleAddonPanels(panel) --called in OnShow of newly shown panel + local currentlySelected = LAMAddonPanelsMenu.currentlySelected + if currentlySelected and currentlySelected ~= panel then + currentlySelected:SetHidden(true) + end + LAMAddonPanelsMenu.currentlySelected = panel + + if not optionsCreated[panel:GetName()] then --if this is the first time opening this panel, create these options + CreateOptionsControls(panel) + end + + cm:FireCallbacks("LAM-RefreshPanel", panel) end +local Initialize +local hasInitialized = false --METHOD: REGISTER ADDON PANEL --registers your addon with LibAddonMenu and creates a panel @@ -158,21 +199,22 @@ end -- addonID = "string"; unique ID which will be the global name of your panel -- panelData = table; data object for your panel - see controls\panel.lua function lam:RegisterAddonPanel(addonID, panelData) - local panel = lamcc.panel(nil, panelData, addonID) --addonID==global name of panel - panel:SetHidden(true) - panel:SetAnchor(TOPLEFT, LAMAddonPanelsMenu, TOPRIGHT, 10, 0) - panel:SetAnchor(BOTTOMLEFT, LAMAddonPanelsMenu, BOTTOMRIGHT, 10, 0) - panel:SetWidth(549) - panel:SetDrawLayer(DL_OVERLAY) - tinsert(addonsForList, { panel = addonID, name = panelData.name }) - panel:SetHandler("OnShow", ToggleAddonPanels) - if panelData.slashCommand then - SLASH_COMMANDS[panelData.slashCommand] = function() - lam:OpenToPanel(panel) - end - end - - return panel --return for authors creating options manually + if(not hasInitialized) then Initialize(addonID) end + local panel = lamcc.panel(nil, panelData, addonID) --addonID==global name of panel + panel:SetHidden(true) + panel:SetAnchor(TOPLEFT, LAMAddonPanelsMenu, TOPRIGHT, 10, 0) + panel:SetAnchor(BOTTOMLEFT, LAMAddonPanelsMenu, BOTTOMRIGHT, 10, 0) + panel:SetWidth(549) + panel:SetDrawLayer(DL_OVERLAY) + tinsert(addonsForList, {panel = addonID, name = panelData.name}) + panel:SetHandler("OnShow", ToggleAddonPanels) + if panelData.slashCommand then + SLASH_COMMANDS[panelData.slashCommand] = function() + lam:OpenToPanel(panel) + end + end + + return panel --return for authors creating options manually end @@ -185,8 +227,8 @@ end --Usage: -- addonID = "string"; the same string passed to :RegisterAddonPanel -- optionsTable = table; the table containing all of the options controls and their data -function lam:RegisterOptionControls(addonID, optionsTable) --optionsTable = {sliderData, buttonData, etc} - addonToOptionsMap[addonID] = optionsTable +function lam:RegisterOptionControls(addonID, optionsTable) --optionsTable = {sliderData, buttonData, etc} + addonToOptionsMap[addonID] = optionsTable end @@ -199,124 +241,144 @@ local panelWindow = ZO_OptionsWindow local bgL = ZO_OptionsWindowBGLeft local bgR = ZO_OptionsWindowBGLeftBGRight local function HandlePanelSwitching(self, panel) - if panel == lam.panelID then --our addon settings panel - oldDefaultButton:SetCallback(dummyFunc) - oldDefaultButton:SetHidden(true) - oldDefaultButton:SetAlpha(0) --just because it still bugs out - panelWindow:SetDimensions(999, 960) - bgL:SetWidth(666) - bgR:SetWidth(333) - else - local shown = LAMAddonPanelsMenu.currentlySelected - if shown then shown:SetHidden(true) end - oldDefaultButton:SetCallback(oldCallback) - oldDefaultButton:SetHidden(false) - oldDefaultButton:SetAlpha(1) - panelWindow:SetDimensions(768, 914) - bgL:SetWidth(512) - bgR:SetWidth(256) - end + if panel == lam.panelID then --our addon settings panel + oldDefaultButton:SetCallback(dummyFunc) + oldDefaultButton:SetHidden(true) + oldDefaultButton:SetAlpha(0) --just because it still bugs out + panelWindow:SetDimensions(999, 960) + bgL:SetWidth(666) + bgR:SetWidth(333) + else + local shown = LAMAddonPanelsMenu.currentlySelected + if shown then shown:SetHidden(true) end + oldDefaultButton:SetCallback(oldCallback) + oldDefaultButton:SetHidden(false) + oldDefaultButton:SetAlpha(1) + panelWindow:SetDimensions(768, 914) + bgL:SetWidth(512) + bgR:SetWidth(256) + end end --INTERNAL FUNCTION --creates LAM's Addon Settings panel local function CreateAddonSettingsPanel() - if not LAMSettingsPanelCreated then - local controlPanelID = "LAM_ADDON_SETTINGS_PANEL" - --Russian for TERAB1T's RuESO addon, which creates an "ru" locale - --game font does not support Cyrillic, so they are using custom fonts + extended latin charset - --Spanish provided by Luisen75 for their translation project - local controlPanelNames = { - en = "Addon Settings", - fr = "Extensions", - de = "Erweiterungen", - ru = "Îacòpoéêè äoïoìîeîèé", - es = "Configura Addons", - } - - ZO_OptionsWindow_AddUserPanel(controlPanelID, controlPanelNames[GetCVar("Language.2")] or controlPanelName["en"]) - - lam.panelID = _G[controlPanelID] - - --ZO_PreHook("ZO_OptionsWindow_ChangePanels", HandlePanelSwitching) - ZO_PreHook(ZO_SharedOptions, "ChangePanels", HandlePanelSwitching) - - LAMSettingsPanelCreated = true - end + if not LAMSettingsPanelCreated then + local controlPanelID = "LAM_ADDON_SETTINGS_PANEL" + --Russian for TERAB1T's RuESO addon, which creates an "ru" locale + --game font does not support Cyrillic, so they are using custom fonts + extended latin charset + --Spanish provided by Luisen75 for their translation project + local controlPanelNames = { + en = "Addon Settings", + fr = "Extensions", + de = "Erweiterungen", + ru = "Îacòpoéêè äoïoìîeîèé", + es = "Configura Addons", + } + + ZO_OptionsWindow_AddUserPanel(controlPanelID, controlPanelNames[GetCVar("Language.2")] or controlPanelNames["en"], PANEL_TYPE_SETTINGS) + + lam.panelID = _G[controlPanelID] + + ZO_PreHook(ZO_KeyboardOptions, "ChangePanels", HandlePanelSwitching) + + LAMSettingsPanelCreated = true + end end --INTERNAL FUNCTION --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.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.scrollChild, TOPLEFT, 5, 5) - else - button:SetAnchor(TOPLEFT, _G["LAMAddonMenuButton" .. i - 1], BOTTOMLEFT) - end - button:SetHandler("OnClicked", function(self) self.panel:SetHidden(false) end) - end + for i = 1, #addons do + 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.scrollChild, TOPLEFT, 5, 5) + else + button:SetAnchor(TOPLEFT, _G["LAMAddonMenuButton"..i-1], BOTTOMLEFT) + end + button:SetHandler("OnClicked", function(self) self.panel:SetHidden(false) end) + end end --INTERNAL FUNCTION --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 - list = LAMAddonPanelsMenu or wm:CreateControlFromVirtual("LAMAddonPanelsMenu", optionsWindow, "ZO_ScrollContainer") - list:ClearAnchors() - list:SetAnchor(TOPLEFT) - list:SetHeight(675) - list:SetWidth(200) - - list.bg = list.bg or wm:CreateControl(nil, list, CT_BACKDROP) - local bg = list.bg - bg:SetAnchorFill() --offsets of 8? - 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 - --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 - end) - CreateAddonButtons(list, addonsForList) - self.currentlySelected = LAMAddonMenuButton1 and LAMAddonMenuButton1.panel - --since our addon panels don't have a parent, let's make sure they hide when we're done with them - ZO_PreHookHandler(ZO_OptionsWindow, "OnHide", function() self.currentlySelected:SetHidden(true) end) - generatedButtons = true - end - if self.currentlySelected then self.currentlySelected:SetHidden(false) end - end) - - --list.controlType = OPTIONS_CUSTOM - --list.panel = lam.panelID - list.data = { - controlType = OPTIONS_CUSTOM, - panel = lam.panelID, - } - - ZO_OptionsWindow_InitializeControl(list) - - return list + 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 = list.bg or wm:CreateControl(nil, list, CT_BACKDROP) + local bg = list.bg + bg:SetAnchorFill() --offsets of 8? + 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 + --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 + end) + CreateAddonButtons(list, addonsForList) + self.currentlySelected = LAMAddonMenuButton1 and LAMAddonMenuButton1.panel + --since our addon panels don't have a parent, let's make sure they hide when we're done with them + ZO_PreHookHandler(ZO_OptionsWindow, "OnHide", function() self.currentlySelected:SetHidden(true) end) + generatedButtons = true + end + if self.currentlySelected then self.currentlySelected:SetHidden(false) end + end) + + --list.controlType = OPTIONS_CUSTOM + --list.panel = lam.panelID + list.data = { + controlType = OPTIONS_CUSTOM, + panel = lam.panelID, + } + + ZO_OptionsWindow_InitializeControl(list) + + return list end - --INITIALIZING -CreateAddonSettingsPanel() -CreateAddonList() +local safeToInitialize = false +local eventHandle = table.concat({MAJOR, MINOR}, "r") +local function OnLoad(_, addonName) + -- wait for the first loaded event + EVENT_MANAGER:UnregisterForEvent(eventHandle, EVENT_ADD_ON_LOADED) + safeToInitialize = true +end +EVENT_MANAGER:RegisterForEvent(eventHandle, EVENT_ADD_ON_LOADED, OnLoad) + +local function OnActivated(_, addonName) + EVENT_MANAGER:UnregisterForEvent(eventHandle, EVENT_PLAYER_ACTIVATED) + FlushMessages() +end +EVENT_MANAGER:RegisterForEvent(eventHandle, EVENT_PLAYER_ACTIVATED, OnActivated) + +function Initialize(addonID) + if(not safeToInitialize) then + local msg = string.format("The panel with id '%s' was registered before addon loading has completed. This might break the AddOn Settings menu.", addonID) + PrintLater(msg) + end + CreateAddonSettingsPanel() + CreateAddonList() + hasInitialized = true +end diff --git a/libs/LibAddonMenu-2.0/controls/button.lua b/libs/LibAddonMenu-2.0/controls/button.lua index f6218ac..8a6ecda 100644 --- a/libs/LibAddonMenu-2.0/controls/button.lua +++ b/libs/LibAddonMenu-2.0/controls/button.lua @@ -11,7 +11,7 @@ } ]] -local widgetVersion = 5 +local widgetVersion = 6 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("button", widgetVersion) then return end @@ -20,70 +20,69 @@ local cm = CALLBACK_MANAGER local tinsert = table.insert local function UpdateDisabled(control) - local disable - if type(control.data.disabled) == "function" then - disable = control.data.disabled() - else - disable = control.data.disabled - end - - control.button:SetEnabled(not disable) + local disable + if type(control.data.disabled) == "function" then + disable = control.data.disabled() + else + disable = control.data.disabled + end + + control.button:SetEnabled(not disable) end --controlName is optional function LAMCreateControl.button(parent, buttonData, controlName) - local control = wm:CreateTopLevelWindow(controlName or buttonData.reference) - control:SetParent(parent.scroll or parent) + local control = wm:CreateControl(controlName or buttonData.reference, parent.scroll or parent, CT_CONTROL) - local isHalfWidth = buttonData.width == "half" - control:SetDimensions(isHalfWidth and 250 or 510, isHalfWidth and 55 or 28) - control:SetMouseEnabled(true) + local isHalfWidth = buttonData.width == "half" + control:SetDimensions(isHalfWidth and 250 or 510, isHalfWidth and 55 or 28) + control:SetMouseEnabled(true) - if buttonData.icon then - control.button = wm:CreateControl(nil, control, CT_BUTTON) - control.button:SetDimensions(26, 26) - control.button:SetNormalTexture(buttonData.icon) - control.button:SetPressedOffset(2, 2) - else - --control.button = wm:CreateControlFromVirtual(controlName.."Button", control, "ZO_DefaultButton") - control.button = wm:CreateControlFromVirtual(nil, control, "ZO_DefaultButton") - control.button:SetWidth(isHalfWidth and 180 or 200) - control.button:SetText(buttonData.name) - end - local button = control.button - button:SetAnchor(isHalfWidth and CENTER or RIGHT) - button:SetClickSound("Click") - --button.tooltipText = buttonData.tooltip - button.data = { tooltipText = buttonData.tooltip } - button:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - button:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - button:SetHandler("OnClicked", function(self, ...) - buttonData.func(self, ...) - if control.panel.data.registerForRefresh then - cm:FireCallbacks("LAM-RefreshPanel", control) - end - end) + if buttonData.icon then + control.button = wm:CreateControl(nil, control, CT_BUTTON) + control.button:SetDimensions(26, 26) + control.button:SetNormalTexture(buttonData.icon) + control.button:SetPressedOffset(2, 2) + else + --control.button = wm:CreateControlFromVirtual(controlName.."Button", control, "ZO_DefaultButton") + control.button = wm:CreateControlFromVirtual(nil, control, "ZO_DefaultButton") + control.button:SetWidth(isHalfWidth and 180 or 200) + control.button:SetText(buttonData.name) + end + local button = control.button + button:SetAnchor(isHalfWidth and CENTER or RIGHT) + button:SetClickSound("Click") + --button.tooltipText = buttonData.tooltip + button.data = {tooltipText = buttonData.tooltip} + button:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) + button:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) + button:SetHandler("OnClicked", function(self, ...) + buttonData.func(self, ...) + if control.panel.data.registerForRefresh then + cm:FireCallbacks("LAM-RefreshPanel", control) + end + end) - if buttonData.warning then - control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") - control.warning:SetAnchor(RIGHT, button, LEFT, -5, 0) - --control.warning.tooltipText = buttonData.warning - control.warning.data = { tooltipText = buttonData.warning } - end + if buttonData.warning then + control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") + control.warning:SetAnchor(RIGHT, button, LEFT, -5, 0) + --control.warning.tooltipText = buttonData.warning + control.warning.data = {tooltipText = buttonData.warning} + end - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = buttonData + control.panel = parent.panel or parent --if this is in a submenu, panel is its parent + control.data = buttonData - if buttonData.disabled then - control.UpdateDisabled = UpdateDisabled - control:UpdateDisabled() + if buttonData.disabled then + control.UpdateDisabled = UpdateDisabled + control:UpdateDisabled() - --this is here because buttons don't have an UpdateValue method - if control.panel.data.registerForRefresh then --if our parent window wants to refresh controls, then add this to the list - tinsert(control.panel.controlsToRefresh, control) - end - end + --this is here because buttons don't have an UpdateValue method + if control.panel.data.registerForRefresh then --if our parent window wants to refresh controls, then add this to the list + tinsert(control.panel.controlsToRefresh, control) + end + end - return control + return control end \ No newline at end of file diff --git a/libs/LibAddonMenu-2.0/controls/checkbox.lua b/libs/LibAddonMenu-2.0/controls/checkbox.lua index 6d76d7c..ef8bf09 100644 --- a/libs/LibAddonMenu-2.0/controls/checkbox.lua +++ b/libs/LibAddonMenu-2.0/controls/checkbox.lua @@ -12,7 +12,7 @@ } ]] -local widgetVersion = 7 +local widgetVersion = 8 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("checkbox", widgetVersion) then return end @@ -30,143 +30,142 @@ local checkboxHLcolor = ZO_HIGHLIGHT_TEXT local function UpdateDisabled(control) - local disable - if type(control.data.disabled) == "function" then - disable = control.data.disabled() - else - disable = control.data.disabled - end - - 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) - - control.isDisabled = disable + local disable + if type(control.data.disabled) == "function" then + disable = control.data.disabled() + else + disable = control.data.disabled + end + + 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) + + control.isDisabled = disable end local function ToggleCheckbox(control) - if control.value then - control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - control.checkbox:SetText(control.checkedText) - else - control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - control.checkbox:SetText(control.uncheckedText) - end + if control.value then + control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + control.checkbox:SetText(control.checkedText) + else + control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + control.checkbox:SetText(control.uncheckedText) + end end local function UpdateValue(control, forceDefault, value) - if forceDefault then --if we are forcing defaults - value = control.data.default - control.data.setFunc(value) - elseif value ~= nil then --our value could be false - 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 - if control.panel.data.registerForRefresh then - cm:FireCallbacks("LAM-RefreshPanel", control) - end - else - value = control.data.getFunc() - end - control.value = value - - ToggleCheckbox(control) + if forceDefault then --if we are forcing defaults + value = control.data.default + control.data.setFunc(value) + elseif value ~= nil then --our value could be false + 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 + if control.panel.data.registerForRefresh then + cm:FireCallbacks("LAM-RefreshPanel", control) + end + else + value = control.data.getFunc() + end + control.value = value + + ToggleCheckbox(control) end local function OnMouseEnter(control) - ZO_Options_OnMouseEnter(control) + ZO_Options_OnMouseEnter(control) - if control.isDisabled then return end + if control.isDisabled then return end - local label = control.label - if control.value then - label:SetColor(ZO_HIGHLIGHT_TEXT:UnpackRGBA()) - else - label:SetColor(ZO_DEFAULT_DISABLED_MOUSEOVER_COLOR:UnpackRGBA()) - end - control.checkbox:SetColor(ZO_HIGHLIGHT_TEXT:UnpackRGBA()) + local label = control.label + if control.value then + label:SetColor(ZO_HIGHLIGHT_TEXT:UnpackRGBA()) + else + label:SetColor(ZO_DEFAULT_DISABLED_MOUSEOVER_COLOR:UnpackRGBA()) + end + control.checkbox:SetColor(ZO_HIGHLIGHT_TEXT:UnpackRGBA()) end local function OnMouseExit(control) - ZO_Options_OnMouseExit(control) + ZO_Options_OnMouseExit(control) - if control.isDisabled then return end + if control.isDisabled then return end - local label = control.label - if control.value then - label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - else - label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - end - control.checkbox:SetColor(ZO_NORMAL_TEXT:UnpackRGBA()) + local label = control.label + if control.value then + label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + else + label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + end + control.checkbox:SetColor(ZO_NORMAL_TEXT:UnpackRGBA()) end --controlName is optional function LAMCreateControl.checkbox(parent, checkboxData, controlName) - local control = wm:CreateTopLevelWindow(controlName or checkboxData.reference) - control:SetParent(parent.scroll or parent) - control:SetMouseEnabled(true) - --control.tooltipText = checkboxData.tooltip - control:SetHandler("OnMouseEnter", OnMouseEnter) - 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) - - control.label = wm:CreateControl(nil, control, CT_LABEL) - local label = control.label - label:SetFont("ZoFontWinH4") - label:SetText(checkboxData.name) - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetHeight(26) - - control.checkbox = wm:CreateControl(nil, control, CT_LABEL) - local checkbox = control.checkbox - checkbox:SetFont("ZoFontGameBold") - checkbox:SetColor(ZO_NORMAL_TEXT:UnpackRGBA()) - control.checkedText = GetString(SI_CHECK_BUTTON_ON):upper() - control.uncheckedText = GetString(SI_CHECK_BUTTON_OFF):upper() - - local isHalfWidth = checkboxData.width == "half" - if isHalfWidth then - control:SetDimensions(250, 55) - checkbox:SetDimensions(100, 26) - checkbox:SetAnchor(BOTTOMRIGHT) - label:SetAnchor(TOPLEFT) - label:SetAnchor(TOPRIGHT) - else - control:SetDimensions(510, 30) - checkbox:SetDimensions(200, 26) - checkbox:SetAnchor(RIGHT) - label:SetAnchor(LEFT) - label:SetAnchor(RIGHT, checkbox, LEFT, -5, 0) - end - - if checkboxData.warning then - control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") - control.warning:SetAnchor(RIGHT, checkbox, LEFT, -5, 0) - --control.warning.tooltipText = checkboxData.warning - control.warning.data = { tooltipText = checkboxData.warning } - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = checkboxData - control.data.tooltipText = checkboxData.tooltip - - if checkboxData.disabled then - control.UpdateDisabled = UpdateDisabled - control:UpdateDisabled() - end - control.UpdateValue = UpdateValue - control: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 + local control = wm:CreateControl(controlName or checkboxData.reference, parent.scroll or parent, CT_CONTROL) + control:SetMouseEnabled(true) + --control.tooltipText = checkboxData.tooltip + control:SetHandler("OnMouseEnter", OnMouseEnter) + 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) + + control.label = wm:CreateControl(nil, control, CT_LABEL) + local label = control.label + label:SetFont("ZoFontWinH4") + label:SetText(checkboxData.name) + label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) + label:SetHeight(26) + + control.checkbox = wm:CreateControl(nil, control, CT_LABEL) + local checkbox = control.checkbox + checkbox:SetFont("ZoFontGameBold") + checkbox:SetColor(ZO_NORMAL_TEXT:UnpackRGBA()) + control.checkedText = GetString(SI_CHECK_BUTTON_ON):upper() + control.uncheckedText = GetString(SI_CHECK_BUTTON_OFF):upper() + + local isHalfWidth = checkboxData.width == "half" + if isHalfWidth then + control:SetDimensions(250, 55) + checkbox:SetDimensions(100, 26) + checkbox:SetAnchor(BOTTOMRIGHT) + label:SetAnchor(TOPLEFT) + label:SetAnchor(TOPRIGHT) + else + control:SetDimensions(510, 30) + checkbox:SetDimensions(200, 26) + checkbox:SetAnchor(RIGHT) + label:SetAnchor(LEFT) + label:SetAnchor(RIGHT, checkbox, LEFT, -5, 0) + end + + if checkboxData.warning then + control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") + control.warning:SetAnchor(RIGHT, checkbox, LEFT, -5, 0) + --control.warning.tooltipText = checkboxData.warning + control.warning.data = {tooltipText = checkboxData.warning} + end + + control.panel = parent.panel or parent --if this is in a submenu, panel is its parent + control.data = checkboxData + control.data.tooltipText = checkboxData.tooltip + + if checkboxData.disabled then + control.UpdateDisabled = UpdateDisabled + control:UpdateDisabled() + end + control.UpdateValue = UpdateValue + control: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/colorpicker.lua b/libs/LibAddonMenu-2.0/controls/colorpicker.lua index 2659f28..c5724b0 100644 --- a/libs/LibAddonMenu-2.0/controls/colorpicker.lua +++ b/libs/LibAddonMenu-2.0/controls/colorpicker.lua @@ -12,7 +12,7 @@ } ]] -local widgetVersion = 5 +local widgetVersion = 6 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("colorpicker", widgetVersion) then return end @@ -22,119 +22,117 @@ local tinsert = table.insert local function UpdateDisabled(control) - local disable - if type(control.data.disabled) == "function" then - disable = control.data.disabled() - else - disable = control.data.disabled - end - - if disable then - control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - else - control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - end - - control.isDisabled = disable + local disable + if type(control.data.disabled) == "function" then + disable = control.data.disabled() + else + disable = control.data.disabled + end + + if disable then + control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + else + control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + end + + control.isDisabled = disable end -local function UpdateValue(control, forceDefault, valueR, valueG, valueB, valueA) - if forceDefault then --if we are forcing defaults - local color = control.data.default - valueR, valueG, valueB, valueA = color.r, color.g, color.b, color.a - control.data.setFunc(valueR, valueG, valueB, valueA) - elseif valueR and valueG and valueB then - control.data.setFunc(valueR, valueG, valueB, valueA or 1) - --after setting this value, let's refresh the others to see if any should be disabled or have their settings changed - if control.panel.data.registerForRefresh then - cm:FireCallbacks("LAM-RefreshPanel", control) - end - else - valueR, valueG, valueB, valueA = control.data.getFunc() - end - - control.thumb:SetColor(valueR, valueG, valueB, valueA or 1) +local function UpdateValue(control, forceDefault, valueR, valueG, valueB, valueA) + if forceDefault then --if we are forcing defaults + local color = control.data.default + valueR, valueG, valueB, valueA = color.r, color.g, color.b, color.a + control.data.setFunc(valueR, valueG, valueB, valueA) + elseif valueR and valueG and valueB then + control.data.setFunc(valueR, valueG, valueB, valueA or 1) + --after setting this value, let's refresh the others to see if any should be disabled or have their settings changed + if control.panel.data.registerForRefresh then + cm:FireCallbacks("LAM-RefreshPanel", control) + end + else + valueR, valueG, valueB, valueA = control.data.getFunc() + end + + control.thumb:SetColor(valueR, valueG, valueB, valueA or 1) end function LAMCreateControl.colorpicker(parent, colorpickerData, controlName) - local control = wm:CreateTopLevelWindow(controlName or colorpickerData.reference) - control:SetParent(parent.scroll or parent) - control:SetMouseEnabled(true) - --control.tooltipText = colorpickerData.tooltip - control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - - control.label = wm:CreateControl(nil, control, CT_LABEL) - local label = control.label - label:SetDimensions(300, 26) - label:SetAnchor(TOPLEFT) - label:SetFont("ZoFontWinH4") - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetText(colorpickerData.name) - - control.color = wm:CreateControl(nil, control, CT_CONTROL) - local color = control.color - - local isHalfWidth = colorpickerData.width == "half" - if isHalfWidth then - control:SetDimensions(250, 55) - label:SetDimensions(250, 26) - color:SetDimensions(100, 24) - color:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT) - else - control:SetDimensions(510, 30) - label:SetDimensions(300, 26) - color:SetDimensions(200, 24) - color:SetAnchor(TOPRIGHT) - end - - control.thumb = wm:CreateControl(nil, color, CT_TEXTURE) - local thumb = control.thumb - thumb:SetDimensions(36, 18) - thumb:SetAnchor(LEFT, color, LEFT, 4, 0) - - color.border = wm:CreateControl(nil, color, CT_TEXTURE) - local border = color.border - border:SetTexture("EsoUI\\Art\\ChatWindow\\chatOptions_bgColSwatch_frame.dds") - border:SetTextureCoords(0, .625, 0, .8125) - border:SetDimensions(40, 22) - border:SetAnchor(CENTER, thumb, CENTER, 0, 0) - - local function ColorPickerCallback(r, g, b, a) - control:UpdateValue(false, r, g, b, a) - end - - control:SetHandler("OnMouseUp", function(self, btn, upInside) - if self.isDisabled then return end - - if upInside then - local r, g, b, a = colorpickerData.getFunc() - COLOR_PICKER:Show(ColorPickerCallback, r, g, b, a, colorpickerData.name) - end - end) - - if colorpickerData.warning then - control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") - control.warning:SetAnchor(RIGHT, control.color, LEFT, -5, 0) - --control.warning.tooltipText = colorpickerData.warning - control.warning.data = { tooltipText = colorpickerData.warning } - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = colorpickerData - control.data.tooltipText = colorpickerData.tooltip - - if colorpickerData.disabled then - control.UpdateDisabled = UpdateDisabled - control:UpdateDisabled() - end - control.UpdateValue = UpdateValue - control: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 + local control = wm:CreateControl(controlName or colorpickerData.reference, parent.scroll or parent, CT_CONTROL) + control:SetMouseEnabled(true) + control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) + control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) + + control.label = wm:CreateControl(nil, control, CT_LABEL) + local label = control.label + label:SetDimensions(300, 26) + label:SetAnchor(TOPLEFT) + label:SetFont("ZoFontWinH4") + label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) + label:SetText(colorpickerData.name) + + control.color = wm:CreateControl(nil, control, CT_CONTROL) + local color = control.color + + local isHalfWidth = colorpickerData.width == "half" + if isHalfWidth then + control:SetDimensions(250, 55) + label:SetDimensions(250, 26) + color:SetDimensions(100, 24) + color:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT) + else + control:SetDimensions(510, 30) + label:SetDimensions(300, 26) + color:SetDimensions(200, 24) + color:SetAnchor(TOPRIGHT) + end + + control.thumb = wm:CreateControl(nil, color, CT_TEXTURE) + local thumb = control.thumb + thumb:SetDimensions(36, 18) + thumb:SetAnchor(LEFT, color, LEFT, 4, 0) + + color.border = wm:CreateControl(nil, color, CT_TEXTURE) + local border = color.border + border:SetTexture("EsoUI\\Art\\ChatWindow\\chatOptions_bgColSwatch_frame.dds") + border:SetTextureCoords(0, .625, 0, .8125) + border:SetDimensions(40, 22) + border:SetAnchor(CENTER, thumb, CENTER, 0, 0) + + local function ColorPickerCallback(r, g, b, a) + control:UpdateValue(false, r, g, b, a) + end + + control:SetHandler("OnMouseUp", function(self, btn, upInside) + if self.isDisabled then return end + + if upInside then + local r, g, b, a = colorpickerData.getFunc() + COLOR_PICKER:Show(ColorPickerCallback, r, g, b, a, colorpickerData.name) + end + end) + + if colorpickerData.warning then + control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") + control.warning:SetAnchor(RIGHT, control.color, LEFT, -5, 0) + --control.warning.tooltipText = colorpickerData.warning + control.warning.data = {tooltipText = colorpickerData.warning} + end + + control.panel = parent.panel or parent --if this is in a submenu, panel is its parent + control.data = colorpickerData + control.data.tooltipText = colorpickerData.tooltip + + if colorpickerData.disabled then + control.UpdateDisabled = UpdateDisabled + control:UpdateDisabled() + end + control.UpdateValue = UpdateValue + control: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/custom.lua b/libs/LibAddonMenu-2.0/controls/custom.lua index 85d1b68..6a31c34 100644 --- a/libs/LibAddonMenu-2.0/controls/custom.lua +++ b/libs/LibAddonMenu-2.0/controls/custom.lua @@ -5,7 +5,7 @@ width = "full", --or "half" (optional) } ]] -local widgetVersion = 4 +local widgetVersion = 5 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("custom", widgetVersion) then return end @@ -13,33 +13,32 @@ local wm = WINDOW_MANAGER local tinsert = table.insert local function UpdateValue(control) - if control.data.refreshFunc then - control.data.refreshFunc(control) - end + 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 or parent) - - local isHalfWidth = customData.width == "half" - if isHalfWidth then --note these restrictions - control:SetDimensionConstraints(250, 55, 250, 100) - control:SetDimensions(250, 55) - else - control:SetDimensionConstraints(510, 30, 510, 100) - control:SetDimensions(510, 30) - end - - 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 + local control = wm:CreateControl(controlName or customData.reference, parent.scroll or parent, CT_CONTROL) + control:SetResizeToFitDescendents(true) + + local isHalfWidth = customData.width == "half" + if isHalfWidth then --note these restrictions + control:SetDimensionConstraints(250, 55, 250, 100) + control:SetDimensions(250, 55) + else + control:SetDimensionConstraints(510, 30, 510, 100) + control:SetDimensions(510, 30) + end + + 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 18f92a6..b886b83 100644 --- a/libs/LibAddonMenu-2.0/controls/description.lua +++ b/libs/LibAddonMenu-2.0/controls/description.lua @@ -7,7 +7,7 @@ } ]] -local widgetVersion = 4 +local widgetVersion = 5 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("description", widgetVersion) then return end @@ -15,52 +15,52 @@ 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) + 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 or parent) - local isHalfWidth = descriptionData.width == "half" - if isHalfWidth then - control:SetDimensionConstraints(250, 55, 250, 100) - control:SetDimensions(250, 55) - else - control:SetDimensionConstraints(510, 40, 510, 100) - control:SetDimensions(510, 30) - end + local control = wm:CreateControl(controlName or descriptionData.reference, parent.scroll or parent, CT_CONTROL) + control:SetResizeToFitDescendents(true) + local isHalfWidth = descriptionData.width == "half" + if isHalfWidth then + control:SetDimensionConstraints(250, 55, 250, 100) + control:SetDimensions(250, 55) + else + control:SetDimensionConstraints(510, 40, 510, 100) + control:SetDimensions(510, 30) + end - control.desc = wm:CreateControl(nil, control, CT_LABEL) - local desc = control.desc - desc:SetVerticalAlignment(TEXT_ALIGN_TOP) - desc:SetFont("ZoFontGame") - desc:SetText(descriptionData.text) - desc:SetWidth(isHalfWidth and 250 or 510) + control.desc = wm:CreateControl(nil, control, CT_LABEL) + local desc = control.desc + desc:SetVerticalAlignment(TEXT_ALIGN_TOP) + desc:SetFont("ZoFontGame") + desc:SetText(descriptionData.text) + desc:SetWidth(isHalfWidth and 250 or 510) - if descriptionData.title then - control.title = wm:CreateControl(nil, control, CT_LABEL) - local title = control.title - title:SetWidth(isHalfWidth and 250 or 510) - title:SetAnchor(TOPLEFT, control, TOPLEFT) - title:SetFont("ZoFontWinH4") - title:SetText(descriptionData.title) - desc:SetAnchor(TOPLEFT, title, BOTTOMLEFT) - else - desc:SetAnchor(TOPLEFT) - end + if descriptionData.title then + control.title = wm:CreateControl(nil, control, CT_LABEL) + local title = control.title + title:SetWidth(isHalfWidth and 250 or 510) + title:SetAnchor(TOPLEFT, control, TOPLEFT) + title:SetFont("ZoFontWinH4") + title:SetText(descriptionData.title) + desc:SetAnchor(TOPLEFT, title, BOTTOMLEFT) + else + desc:SetAnchor(TOPLEFT) + end - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = descriptionData + control.panel = parent.panel or parent --if this is in a submenu, panel is its parent + control.data = descriptionData - control.UpdateValue = UpdateValue + 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 + 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 - return control end \ No newline at end of file diff --git a/libs/LibAddonMenu-2.0/controls/dropdown.lua b/libs/LibAddonMenu-2.0/controls/dropdown.lua index 0bf0ed5..795404c 100644 --- a/libs/LibAddonMenu-2.0/controls/dropdown.lua +++ b/libs/LibAddonMenu-2.0/controls/dropdown.lua @@ -14,7 +14,7 @@ } ]] -local widgetVersion = 7 +local widgetVersion = 8 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("dropdown", widgetVersion) then return end @@ -24,130 +24,134 @@ local tinsert = table.insert local function UpdateDisabled(control) - local disable - if type(control.data.disabled) == "function" then - disable = control.data.disabled() - else - disable = control.data.disabled - end - - control.dropdown:SetEnabled(not disable) - if disable then - control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - else - control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - end + local disable + if type(control.data.disabled) == "function" then + disable = control.data.disabled() + else + disable = control.data.disabled + end + + control.dropdown:SetEnabled(not disable) + if disable then + control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + else + control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + end end local function UpdateValue(control, forceDefault, value) - if forceDefault then --if we are forcing defaults - value = control.data.default - control.data.setFunc(value) - control.dropdown:SetSelectedItem(value) - elseif value then - 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 - if control.panel.data.registerForRefresh then - cm:FireCallbacks("LAM-RefreshPanel", control) - end - else - value = control.data.getFunc() - control.dropdown:SetSelectedItem(value) - end + if forceDefault then --if we are forcing defaults + value = control.data.default + control.data.setFunc(value) + control.dropdown:SetSelectedItem(value) + elseif value then + 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 + if control.panel.data.registerForRefresh then + cm:FireCallbacks("LAM-RefreshPanel", control) + end + else + value = control.data.getFunc() + control.dropdown:SetSelectedItem(value) + end end -local function DropdownCallback(choice, choiceText, choice) - choice.control:UpdateValue(false, choiceText) +local function DropdownCallback(control, choiceText, choice) + choice.control:UpdateValue(false, choiceText) end local function UpdateChoices(control, choices) - control.dropdown:ClearItems() --remove previous choices --(need to call :SetSelectedItem()?) - - --build new list of choices - local choices = choices or control.data.choices - for i = 1, #choices do - local entry = control.dropdown:CreateItemEntry(choices[i], DropdownCallback) - entry.control = control - 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 + control.dropdown:ClearItems() --remove previous choices --(need to call :SetSelectedItem()?) + + --build new list of choices + local choices = choices or control.data.choices + for i = 1, #choices do + local entry = control.dropdown:CreateItemEntry(choices[i], DropdownCallback) + entry.control = control + 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 + local t, i = {}, 1 + for info in string.gmatch(sortInfo, "([^%-]+)") do + t[i] = info + i = i + 1 + end - return t + return t end -local comboboxCount = 1 function LAMCreateControl.dropdown(parent, dropdownData, controlName) - local control = wm:CreateTopLevelWindow(controlName or dropdownData.reference) - control:SetParent(parent.scroll or parent) - control:SetMouseEnabled(true) - --control.tooltipText = dropdownData.tooltip - control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - - control.label = wm:CreateControl(nil, control, CT_LABEL) - local label = control.label - label:SetAnchor(TOPLEFT) - label:SetFont("ZoFontWinH4") - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetText(dropdownData.name) - - control.combobox = wm:CreateControlFromVirtual(parent:GetName() .. "Combobox" .. comboboxCount, control, "ZO_ComboBox") - comboboxCount = comboboxCount + 1 - local combobox = control.combobox - combobox:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseEnter(control) end) - 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) - label:SetDimensions(250, 26) - combobox:SetDimensions(225, 26) - combobox:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT) - else - control:SetDimensions(510, 30) - label:SetDimensions(300, 26) - combobox:SetDimensions(200, 26) - combobox:SetAnchor(TOPRIGHT) - end - - if dropdownData.warning then - control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") - control.warning:SetAnchor(RIGHT, combobox, LEFT, -5, 0) - --control.warning.tooltipText = dropdownData.warning - control.warning.data = { tooltipText = dropdownData.warning } - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = dropdownData - control.data.tooltipText = dropdownData.tooltip - - if dropdownData.disabled then - control.UpdateDisabled = UpdateDisabled - control:UpdateDisabled() - end - control.UpdateChoices = UpdateChoices - control:UpdateChoices(dropdownData.choices) - control.UpdateValue = UpdateValue - control: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 + local control = wm:CreateControl(controlName or dropdownData.reference, parent.scroll or parent, CT_CONTROL) + control:SetMouseEnabled(true) + control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) + control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) + + control.label = wm:CreateControl(nil, control, CT_LABEL) + local label = control.label + label:SetAnchor(TOPLEFT) + label:SetFont("ZoFontWinH4") + label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) + label:SetText(dropdownData.name) + + local countControl = parent + local name = parent:GetName() + if not name or #name == 0 then + countControl = LAMCreateControl + name = "LAM" + end + local comboboxCount = (countControl.comboboxCount or 0) + 1 + countControl.comboboxCount = comboboxCount + control.combobox = wm:CreateControlFromVirtual(zo_strjoin(nil, name, "Combobox", comboboxCount), control, "ZO_ComboBox") + + local combobox = control.combobox + combobox:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseEnter(control) end) + 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) + label:SetDimensions(250, 26) + combobox:SetDimensions(225, 26) + combobox:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT) + else + control:SetDimensions(510, 30) + label:SetDimensions(300, 26) + combobox:SetDimensions(200, 26) + combobox:SetAnchor(TOPRIGHT) + end + + if dropdownData.warning then + control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") + control.warning:SetAnchor(RIGHT, combobox, LEFT, -5, 0) + control.warning.data = {tooltipText = dropdownData.warning} + end + + control.panel = parent.panel or parent --if this is in a submenu, panel is its parent + control.data = dropdownData + control.data.tooltipText = dropdownData.tooltip + + if dropdownData.disabled then + control.UpdateDisabled = UpdateDisabled + control:UpdateDisabled() + end + control.UpdateChoices = UpdateChoices + control:UpdateChoices(dropdownData.choices) + control.UpdateValue = UpdateValue + control: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/editbox.lua b/libs/LibAddonMenu-2.0/controls/editbox.lua index 44e560c..3ab069f 100644 --- a/libs/LibAddonMenu-2.0/controls/editbox.lua +++ b/libs/LibAddonMenu-2.0/controls/editbox.lua @@ -13,7 +13,7 @@ } ]] -local widgetVersion = 6 +local widgetVersion = 7 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("editbox", widgetVersion) then return end @@ -23,133 +23,131 @@ local tinsert = table.insert local function UpdateDisabled(control) - local disable - if type(control.data.disabled) == "function" then - disable = control.data.disabled() - else - disable = control.data.disabled - end - - if disable then - control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - control.editbox:SetColor(ZO_DEFAULT_DISABLED_MOUSEOVER_COLOR:UnpackRGBA()) - else - control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - control.editbox:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - end - --control.editbox:SetEditEnabled(not disable) - control.editbox:SetMouseEnabled(not disable) + local disable + if type(control.data.disabled) == "function" then + disable = control.data.disabled() + else + disable = control.data.disabled + end + + if disable then + control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + control.editbox:SetColor(ZO_DEFAULT_DISABLED_MOUSEOVER_COLOR:UnpackRGBA()) + else + control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + control.editbox:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + end + --control.editbox:SetEditEnabled(not disable) + control.editbox:SetMouseEnabled(not disable) end -local function UpdateValue(control, forceDefault, value) - if forceDefault then --if we are forcing defaults - value = control.data.default - control.data.setFunc(value) - control.editbox:SetText(value) - elseif value then - 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 - if control.panel.data.registerForRefresh then - cm:FireCallbacks("LAM-RefreshPanel", control) - end - else - value = control.data.getFunc() - control.editbox:SetText(value) - end +local function UpdateValue(control, forceDefault, value) + if forceDefault then --if we are forcing defaults + value = control.data.default + control.data.setFunc(value) + control.editbox:SetText(value) + elseif value then + 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 + if control.panel.data.registerForRefresh then + cm:FireCallbacks("LAM-RefreshPanel", control) + end + else + value = control.data.getFunc() + control.editbox:SetText(value) + end end function LAMCreateControl.editbox(parent, editboxData, controlName) - local control = wm:CreateTopLevelWindow(controlName or editboxData.reference) - control:SetParent(parent.scroll or parent) - control:SetMouseEnabled(true) - control:SetResizeToFitDescendents(true) - --control.tooltipText = editboxData.tooltip - control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - - control.label = wm:CreateControl(nil, control, CT_LABEL) - local label = control.label - label:SetAnchor(TOPLEFT) - label:SetFont("ZoFontWinH4") - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetText(editboxData.name) - - control.bg = wm:CreateControlFromVirtual(nil, control, "ZO_EditBackdrop") - local bg = control.bg - - if editboxData.isMultiline then - 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 - local editbox = control.editbox - 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(false, self:GetText()) end) - editbox:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseEnter(control) end) - editbox:SetHandler("OnMouseExit", function() ZO_Options_OnMouseExit(control) end) - - local isHalfWidth = editboxData.width == "half" - if isHalfWidth then - control:SetDimensions(250, 55) - label:SetDimensions(250, 26) - 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 - control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") - control.warning:SetAnchor(TOPRIGHT, control.bg, TOPLEFT, -5, 0) - --control.warning.tooltipText = editboxData.warning - control.warning.data = { tooltipText = editboxData.warning } - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = editboxData - control.data.tooltipText = editboxData.tooltip - - if editboxData.disabled then - control.UpdateDisabled = UpdateDisabled - control:UpdateDisabled() - end - control.UpdateValue = UpdateValue - control: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 + local control = wm:CreateControl(controlName or editboxData.reference, parent.scroll or parent, CT_CONTROL) + control:SetMouseEnabled(true) + control:SetResizeToFitDescendents(true) + control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) + control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) + + control.label = wm:CreateControl(nil, control, CT_LABEL) + local label = control.label + label:SetAnchor(TOPLEFT) + label:SetFont("ZoFontWinH4") + label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) + label:SetText(editboxData.name) + + control.bg = wm:CreateControlFromVirtual(nil, control, "ZO_EditBackdrop") + local bg = control.bg + + if editboxData.isMultiline then + 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 + local editbox = control.editbox + 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(false, self:GetText()) end) + editbox:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseEnter(control) end) + editbox:SetHandler("OnMouseExit", function() ZO_Options_OnMouseExit(control) end) + + local isHalfWidth = editboxData.width == "half" + if isHalfWidth then + control:SetDimensions(250, 55) + label:SetDimensions(250, 26) + 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 + control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") + control.warning:SetAnchor(TOPRIGHT, control.bg, TOPLEFT, -5, 0) + --control.warning.tooltipText = editboxData.warning + control.warning.data = {tooltipText = editboxData.warning} + end + + control.panel = parent.panel or parent --if this is in a submenu, panel is its parent + control.data = editboxData + control.data.tooltipText = editboxData.tooltip + + if editboxData.disabled then + control.UpdateDisabled = UpdateDisabled + control:UpdateDisabled() + end + control.UpdateValue = UpdateValue + control: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/header.lua b/libs/LibAddonMenu-2.0/controls/header.lua index aac21d6..83c862b 100644 --- a/libs/LibAddonMenu-2.0/controls/header.lua +++ b/libs/LibAddonMenu-2.0/controls/header.lua @@ -6,7 +6,7 @@ } ]] -local widgetVersion = 4 +local widgetVersion = 5 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("header", widgetVersion) then return end @@ -14,34 +14,33 @@ local wm = WINDOW_MANAGER local tinsert = table.insert local function UpdateValue(control) - control.header:SetText(control.data.name) + 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 or parent) - local isHalfWidth = headerData.width == "half" - control:SetDimensions(isHalfWidth and 250 or 510, 30) + local control = wm:CreateControl(controlName or headerData.reference, parent.scroll or parent, CT_CONTROL) + local isHalfWidth = headerData.width == "half" + control:SetDimensions(isHalfWidth and 250 or 510, 30) - control.divider = wm:CreateControlFromVirtual(nil, control, "ZO_Options_Divider") - local divider = control.divider - divider:SetWidth(isHalfWidth and 250 or 510) - divider:SetAnchor(TOPLEFT) + control.divider = wm:CreateControlFromVirtual(nil, control, "ZO_Options_Divider") + local divider = control.divider + divider:SetWidth(isHalfWidth and 250 or 510) + divider:SetAnchor(TOPLEFT) - control.header = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel") - local header = control.header - header:SetAnchor(TOPLEFT, divider, BOTTOMLEFT) - header:SetAnchor(BOTTOMRIGHT) - header:SetText(headerData.name) + control.header = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel") + local header = control.header + header:SetAnchor(TOPLEFT, divider, BOTTOMLEFT) + header:SetAnchor(BOTTOMRIGHT) + header:SetText(headerData.name) - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = headerData + control.panel = parent.panel or parent --if this is in a submenu, panel is its parent + control.data = headerData - control.UpdateValue = UpdateValue + 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 + 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 + 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 6dd4e4f..8db73ee 100644 --- a/libs/LibAddonMenu-2.0/controls/panel.lua +++ b/libs/LibAddonMenu-2.0/controls/panel.lua @@ -19,121 +19,120 @@ local wm = WINDOW_MANAGER local cm = CALLBACK_MANAGER local function RefreshPanel(control) - local panel = control.panel or control --callback can be fired by a single control or by the panel showing - local panelControls = panel.controlsToRefresh - - for i = 1, #panelControls do - local updateControl = panelControls[i] - if updateControl ~= control then - if updateControl.UpdateValue then - updateControl:UpdateValue() - end - if updateControl.UpdateDisabled then - updateControl:UpdateDisabled() - end - end - end + local panel = control.panel or control --callback can be fired by a single control or by the panel showing + local panelControls = panel.controlsToRefresh + + for i = 1, #panelControls do + local updateControl = panelControls[i] + if updateControl ~= control then + if updateControl.UpdateValue then + updateControl:UpdateValue() + end + if updateControl.UpdateDisabled then + updateControl:UpdateDisabled() + end + end + end end local function ForceDefaults(panel) - local panelControls = panel.controlsToRefresh + local panelControls = panel.controlsToRefresh - for i = 1, #panelControls do - local updateControl = panelControls[i] - if updateControl.UpdateValue and updateControl.data.default ~= nil then - updateControl:UpdateValue(true) - end - end + for i = 1, #panelControls do + local updateControl = panelControls[i] + if updateControl.UpdateValue and updateControl.data.default ~= nil then + updateControl:UpdateValue(true) + end + end - if panel.data.resetFunc then - panel.data.resetFunc() - end + if panel.data.resetFunc then + panel.data.resetFunc() + end - cm:FireCallbacks("LAM-RefreshPanel", panel) + cm:FireCallbacks("LAM-RefreshPanel", panel) end - ESO_Dialogs["LAM_DEFAULTS"] = { - title = { - text = SI_OPTIONS_RESET_TITLE, - }, - mainText = { - text = SI_OPTIONS_RESET_PROMPT, - align = TEXT_ALIGN_CENTER, - }, - buttons = { - [1] = { - text = SI_OPTIONS_RESET, - callback = function(dialog) ForceDefaults(dialog.data[1]) end, - }, - [2] = { - text = SI_DIALOG_CANCEL, - }, - }, + title = { + text = SI_OPTIONS_RESET_TITLE, + }, + mainText = { + text = SI_OPTIONS_RESET_PROMPT, + align = TEXT_ALIGN_CENTER, + }, + buttons = { + [1] = { + text = SI_OPTIONS_RESET, + callback = function(dialog) ForceDefaults(dialog.data[1]) end, + }, + [2] = { + text = SI_DIALOG_CANCEL, + }, + }, } local callbackRegistered = false LAMCreateControl.scrollCount = LAMCreateControl.scrollCount or 1 function LAMCreateControl.panel(parent, panelData, controlName) - local control = wm:CreateTopLevelWindow(controlName) - control:SetParent(parent) - - control.bg = wm:CreateControl(nil, control, CT_BACKDROP) - local bg = control.bg - bg:SetAnchorFill() - 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") - local label = control.label - label:SetAnchor(TOPLEFT, control, TOPLEFT, 10, 10) - label:SetText(panelData.displayName and panelData.displayName or panelData.name) - - if panelData.author or panelData.version then - control.info = wm:CreateControl(nil, control, CT_LABEL) - local info = control.info - info:SetFont("$(CHAT_FONT)|14|soft-shadow-thin") - info: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.." - "..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(string.format("%s: %s", GetString(SI_ADDON_MANAGER_AUTHOR), panelData.author)) - else - info:SetText("Version: " .. panelData.version) - end - end - - 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) - control.scroll = GetControl(control.container, "ScrollChild") - control.scroll:SetResizeToFitPadding(0, 20) - - if panelData.registerForDefaults then - control.defaultButton = wm:CreateControlFromVirtual(nil, control, "ZO_DefaultTextButton") - local defaultButton = control.defaultButton - defaultButton:SetFont("ZoFontDialogKeybindDescription") - defaultButton:SetHorizontalAlignment(TEXT_ALIGN_LEFT) - --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() - ZO_Dialogs_ShowDialog("LAM_DEFAULTS", { control }) - end) - end - - 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 - control.controlsToRefresh = {} - - return control + local control = wm:CreateTopLevelWindow(controlName) + control:SetParent(parent) + + control.bg = wm:CreateControl(nil, control, CT_BACKDROP) + local bg = control.bg + bg:SetAnchorFill() + 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") + local label = control.label + label:SetAnchor(TOPLEFT, control, TOPLEFT, 10, 10) + label:SetText(panelData.displayName and panelData.displayName or panelData.name) + + if panelData.author or panelData.version then + control.info = wm:CreateControl(nil, control, CT_LABEL) + local info = control.info + info:SetFont("$(CHAT_FONT)|14|soft-shadow-thin") + info: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.." - "..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(string.format("%s: %s", GetString(SI_ADDON_MANAGER_AUTHOR), panelData.author)) + else + info:SetText("Version: "..panelData.version) + end + end + + 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) + control.scroll = GetControl(control.container, "ScrollChild") + control.scroll:SetResizeToFitPadding(0, 20) + + if panelData.registerForDefaults then + control.defaultButton = wm:CreateControlFromVirtual(nil, control, "ZO_DefaultTextButton") + local defaultButton = control.defaultButton + defaultButton:SetFont("ZoFontDialogKeybindDescription") + defaultButton:SetHorizontalAlignment(TEXT_ALIGN_LEFT) + --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() + ZO_Dialogs_ShowDialog("LAM_DEFAULTS", {control}) + end) + end + + 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 + control.controlsToRefresh = {} + + return control end \ No newline at end of file diff --git a/libs/LibAddonMenu-2.0/controls/slider.lua b/libs/LibAddonMenu-2.0/controls/slider.lua index d782bb3..845fa7d 100644 --- a/libs/LibAddonMenu-2.0/controls/slider.lua +++ b/libs/LibAddonMenu-2.0/controls/slider.lua @@ -15,7 +15,7 @@ } ]] -local widgetVersion = 5 +local widgetVersion = 6 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("slider", widgetVersion) then return end @@ -26,159 +26,158 @@ local strformat = string.format local tinsert = table.insert local function UpdateDisabled(control) - local disable - if type(control.data.disabled) == "function" then - disable = control.data.disabled() - else - disable = control.data.disabled - end - - control.slider:SetEnabled(not disable) - control.slidervalue:SetEditEnabled(not disable) - if disable then - control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - control.minText:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - control.maxText:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) - control.slidervalue:SetColor(ZO_DEFAULT_DISABLED_MOUSEOVER_COLOR:UnpackRGBA()) - else - control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - control.minText:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - control.maxText:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - control.slidervalue:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) - end + local disable + if type(control.data.disabled) == "function" then + disable = control.data.disabled() + else + disable = control.data.disabled + end + + control.slider:SetEnabled(not disable) + control.slidervalue:SetEditEnabled(not disable) + if disable then + control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + control.minText:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + control.maxText:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + control.slidervalue:SetColor(ZO_DEFAULT_DISABLED_MOUSEOVER_COLOR:UnpackRGBA()) + else + control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + control.minText:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + control.maxText:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + control.slidervalue:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + end end local function UpdateValue(control, forceDefault, value) - if forceDefault then --if we are forcing defaults - value = control.data.default - control.data.setFunc(value) - elseif value and value >= control.data.min and value <= control.data.max then - 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 - if control.panel.data.registerForRefresh then - cm:FireCallbacks("LAM-RefreshPanel", control) - end - else - value = control.data.getFunc() - end - - control.slider:SetValue(value) - control.slidervalue:SetText(value) + if forceDefault then --if we are forcing defaults + value = control.data.default + control.data.setFunc(value) + elseif value and value >= control.data.min and value <= control.data.max then + 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 + if control.panel.data.registerForRefresh then + cm:FireCallbacks("LAM-RefreshPanel", control) + end + else + value = control.data.getFunc() + end + + control.slider:SetValue(value) + control.slidervalue:SetText(value) end function LAMCreateControl.slider(parent, sliderData, controlName) - local control = wm:CreateTopLevelWindow(controlName or sliderData.reference) - control:SetParent(parent.scroll or parent) - local isHalfWidth = sliderData.width == "half" - if isHalfWidth then - control:SetDimensions(250, 55) - else - control:SetDimensions(510, 40) - end - control:SetMouseEnabled(true) - --control.tooltipText = sliderData.tooltip - control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - - control.label = wm:CreateControl(nil, control, CT_LABEL) - local label = control.label - label:SetFont("ZoFontWinH4") - label:SetDimensions(isHalfWidth and 250 or 300, 26) - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetAnchor(isHalfWidth and TOPLEFT or LEFT) - label:SetText(sliderData.name) - - --skipping creating the backdrop... Is this the actual slider texture? - control.slider = wm:CreateControl(nil, control, CT_SLIDER) - local slider = control.slider - slider:SetDimensions(190, 14) - if isHalfWidth then - slider:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT, -5, 2) - else - slider:SetAnchor(RIGHT, control, RIGHT, -5, -5) - end - slider:SetMouseEnabled(true) - slider:SetOrientation(ORIENTATION_HORIZONTAL) - --put nil for highlighted texture file path, and what look to be texture coords - slider:SetThumbTexture("EsoUI\\Art\\Miscellaneous\\scrollbox_elevator.dds", "EsoUI\\Art\\Miscellaneous\\scrollbox_elevator_disabled.dds", nil, 8, 16) - local minValue = sliderData.min - local maxValue = sliderData.max - slider:SetMinMax(minValue, maxValue) - slider:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseEnter(control) end) - slider:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseExit(control) end) - - slider.bg = wm:CreateControl(nil, slider, CT_BACKDROP) - local bg = slider.bg - bg:SetCenterColor(0, 0, 0) - bg:SetAnchor(TOPLEFT, slider, TOPLEFT, 0, 4) - bg:SetAnchor(BOTTOMRIGHT, slider, BOTTOMRIGHT, 0, -4) - bg:SetEdgeTexture("EsoUI\\Art\\Tooltips\\UI-SliderBackdrop.dds", 32, 4) - - control.minText = wm:CreateControl(nil, slider, CT_LABEL) - local minText = control.minText - minText:SetFont("ZoFontGameSmall") - minText:SetAnchor(TOPLEFT, slider, BOTTOMLEFT) - minText:SetText(sliderData.min) - - control.maxText = wm:CreateControl(nil, slider, CT_LABEL) - local maxText = control.maxText - maxText:SetFont("ZoFontGameSmall") - maxText:SetAnchor(TOPRIGHT, slider, BOTTOMRIGHT) - maxText:SetText(sliderData.max) - - control.slidervalueBG = wm:CreateControlFromVirtual(nil, slider, "ZO_EditBackdrop") - control.slidervalueBG:SetDimensions(50, 16) - control.slidervalueBG:SetAnchor(TOP, slider, BOTTOM, 0, 0) - control.slidervalue = wm:CreateControlFromVirtual(nil, control.slidervalueBG, "ZO_DefaultEditForBackdrop") - local slidervalue = control.slidervalue - slidervalue:ClearAnchors() - slidervalue:SetAnchor(TOPLEFT, slidervaluebg, TOPLEFT, 3, 1) - slidervalue:SetAnchor(BOTTOMRIGHT, slidervaluebg, BOTTOMRIGHT, -3, -1) - slidervalue:SetTextType(TEXT_TYPE_NUMERIC) - slidervalue:SetFont("ZoFontGameSmall") - slidervalue:SetHandler("OnEscape", function(self) - self:LoseFocus() - control:UpdateValue() - end) - slidervalue:SetHandler("OnEnter", function(self) - self:LoseFocus() - control:UpdateValue(false, tonumber(self:GetText())) - end) - - local range = maxValue - minValue - slider:SetValueStep(sliderData.step or 1) - slider:SetHandler("OnValueChanged", function(self, value, eventReason) - if eventReason == EVENT_REASON_SOFTWARE then return end - self:SetValue(value) --do we actually need this line? - slidervalue:SetText(value) - end) - slider:SetHandler("OnSliderReleased", function(self, value) - --sliderData.setFunc(value) - control:UpdateValue(false, value) --does this work here instead? - end) - - if sliderData.warning then - control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") - control.warning:SetAnchor(RIGHT, slider, LEFT, -5, 0) - --control.warning.tooltipText = sliderData.warning - control.warning.data = { tooltipText = sliderData.warning } - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is the submenu's parent - control.data = sliderData - control.data.tooltipText = sliderData.tooltip - - if sliderData.disabled then - control.UpdateDisabled = UpdateDisabled - control:UpdateDisabled() - end - control.UpdateValue = UpdateValue - control: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 + local control = wm:CreateControl(controlName or sliderData.reference, parent.scroll or parent, CT_CONTROL) + local isHalfWidth = sliderData.width == "half" + if isHalfWidth then + control:SetDimensions(250, 55) + else + control:SetDimensions(510, 40) + end + control:SetMouseEnabled(true) + --control.tooltipText = sliderData.tooltip + control:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) + control:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) + + control.label = wm:CreateControl(nil, control, CT_LABEL) + local label = control.label + label:SetFont("ZoFontWinH4") + label:SetDimensions(isHalfWidth and 250 or 300, 26) + label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) + label:SetAnchor(isHalfWidth and TOPLEFT or LEFT) + label:SetText(sliderData.name) + + --skipping creating the backdrop... Is this the actual slider texture? + control.slider = wm:CreateControl(nil, control, CT_SLIDER) + local slider = control.slider + slider:SetDimensions(190, 14) + if isHalfWidth then + slider:SetAnchor(TOPRIGHT, label, BOTTOMRIGHT, -5, 2) + else + slider:SetAnchor(RIGHT, control, RIGHT, -5, -5) + end + slider:SetMouseEnabled(true) + slider:SetOrientation(ORIENTATION_HORIZONTAL) + --put nil for highlighted texture file path, and what look to be texture coords + slider:SetThumbTexture("EsoUI\\Art\\Miscellaneous\\scrollbox_elevator.dds", "EsoUI\\Art\\Miscellaneous\\scrollbox_elevator_disabled.dds", nil, 8, 16) + local minValue = sliderData.min + local maxValue = sliderData.max + slider:SetMinMax(minValue, maxValue) + slider:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseEnter(control) end) + slider:SetHandler("OnMouseEnter", function() ZO_Options_OnMouseExit(control) end) + + slider.bg = wm:CreateControl(nil, slider, CT_BACKDROP) + local bg = slider.bg + bg:SetCenterColor(0, 0, 0) + bg:SetAnchor(TOPLEFT, slider, TOPLEFT, 0, 4) + bg:SetAnchor(BOTTOMRIGHT, slider, BOTTOMRIGHT, 0, -4) + bg:SetEdgeTexture("EsoUI\\Art\\Tooltips\\UI-SliderBackdrop.dds", 32, 4) + + control.minText = wm:CreateControl(nil, slider, CT_LABEL) + local minText = control.minText + minText:SetFont("ZoFontGameSmall") + minText:SetAnchor(TOPLEFT, slider, BOTTOMLEFT) + minText:SetText(sliderData.min) + + control.maxText = wm:CreateControl(nil, slider, CT_LABEL) + local maxText = control.maxText + maxText:SetFont("ZoFontGameSmall") + maxText:SetAnchor(TOPRIGHT, slider, BOTTOMRIGHT) + maxText:SetText(sliderData.max) + + control.slidervalueBG = wm:CreateControlFromVirtual(nil, slider, "ZO_EditBackdrop") + control.slidervalueBG:SetDimensions(50, 16) + control.slidervalueBG:SetAnchor(TOP, slider, BOTTOM, 0, 0) + control.slidervalue = wm:CreateControlFromVirtual(nil, control.slidervalueBG, "ZO_DefaultEditForBackdrop") + local slidervalue = control.slidervalue + slidervalue:ClearAnchors() + slidervalue:SetAnchor(TOPLEFT, slidervaluebg, TOPLEFT, 3, 1) + slidervalue:SetAnchor(BOTTOMRIGHT, slidervaluebg, BOTTOMRIGHT, -3, -1) + slidervalue:SetTextType(TEXT_TYPE_NUMERIC) + slidervalue:SetFont("ZoFontGameSmall") + slidervalue:SetHandler("OnEscape", function(self) + self:LoseFocus() + control:UpdateValue() + end) + slidervalue:SetHandler("OnEnter", function(self) + self:LoseFocus() + control:UpdateValue(false, tonumber(self:GetText())) + end) + + local range = maxValue - minValue + slider:SetValueStep(sliderData.step or 1) + slider:SetHandler("OnValueChanged", function(self, value, eventReason) + if eventReason == EVENT_REASON_SOFTWARE then return end + self:SetValue(value) --do we actually need this line? + slidervalue:SetText(value) + end) + slider:SetHandler("OnSliderReleased", function(self, value) + --sliderData.setFunc(value) + control:UpdateValue(false, value) --does this work here instead? + end) + + if sliderData.warning then + control.warning = wm:CreateControlFromVirtual(nil, control, "ZO_Options_WarningIcon") + control.warning:SetAnchor(RIGHT, slider, LEFT, -5, 0) + --control.warning.tooltipText = sliderData.warning + control.warning.data = {tooltipText = sliderData.warning} + end + + control.panel = parent.panel or parent --if this is in a submenu, panel is the submenu's parent + control.data = sliderData + control.data.tooltipText = sliderData.tooltip + + if sliderData.disabled then + control.UpdateDisabled = UpdateDisabled + control:UpdateDisabled() + end + control.UpdateValue = UpdateValue + control: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/submenu.lua b/libs/LibAddonMenu-2.0/controls/submenu.lua index 81838f9..d3da3eb 100644 --- a/libs/LibAddonMenu-2.0/controls/submenu.lua +++ b/libs/LibAddonMenu-2.0/controls/submenu.lua @@ -6,7 +6,7 @@ reference = "MyAddonSubmenu" --(optional) unique global reference to control } ]] -local widgetVersion = 7 +local widgetVersion = 8 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("submenu", widgetVersion) then return end @@ -16,108 +16,99 @@ local tinsert = table.insert local function UpdateValue(control) - control.label:SetText(control.data.name) - if control.data.tooltip then - --control.label.tooltipText = control.data.tooltip - control.label.data = { tooltipText = control.data.tooltip } - end + control.label:SetText(control.data.name) + if control.data.tooltip then + control.label.data = {tooltipText = control.data.tooltip} + end end local function AnimateSubmenu(clicked) - local control = clicked:GetParent() - control.open = not control.open - - if control.open then - control.animation:PlayFromStart() - else - control.animation:PlayFromEnd() - end + local control = clicked:GetParent() + control.open = not control.open + + if control.open then + control.animation:PlayFromStart() + else + control.animation:PlayFromEnd() + end end function LAMCreateControl.submenu(parent, submenuData, controlName) - local control = wm:CreateTopLevelWindow(controlName or submenuData.reference) - control:SetParent(parent.scroll or parent) - control.panel = parent - control:SetDimensions(523, 40) - - control.label = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel") - local label = control.label - label:SetAnchor(TOPLEFT, control, TOPLEFT, 5, 5) - label:SetDimensions(520, 30) - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - label:SetText(submenuData.name) - label:SetMouseEnabled(true) - if submenuData.tooltip then - --label.tooltipText = submenuData.tooltip - label.data = { tooltipText = submenuData.tooltip } - label:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - label:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) - end - - control.scroll = wm:CreateControl(nil, control, CT_SCROLL) - local scroll = control.scroll - scroll:SetParent(control) - scroll:SetAnchor(TOPLEFT, label, BOTTOMLEFT, 0, 10) - scroll:SetDimensionConstraints(525, 0, 525, 2500) - - control.bg = wm:CreateControl(nil, label, CT_BACKDROP) - local bg = control.bg - bg:SetAnchor(TOPLEFT, 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) - - control.arrow = wm:CreateControl(nil, bg, CT_TEXTURE) - local arrow = control.arrow - arrow:SetDimensions(28, 28) - arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortdown.dds") --list_sortup for the other way - arrow:SetAnchor(TOPRIGHT, bg, TOPRIGHT, -5, 5) - - --figure out the cool animation later... - control.animation = am:CreateTimeline() - local animation = control.animation - animation:SetPlaybackType(ANIMATION_SIZE, 0) --2nd arg = loop count - --animation:SetDuration(1) - --animation:SetEasingFunction(ZO_LinearEase) --is this needed? - --animation:SetHeightStartAndEnd(40, 80) --SetStartAndEndHeight - --animation:SetStartAndEndHeight(40, 80) --SetStartAndEndHeight - --animation:SetAnimatedControl(control) - - control:SetResizeToFitDescendents(true) - control.open = false - label:SetHandler("OnMouseUp", AnimateSubmenu) - animation:SetHandler("OnStop", function(self, completedPlaying) - scroll:SetResizeToFitDescendents(control.open) - if control.open then - control.arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortup.dds") - scroll:SetResizeToFitPadding(5, 20) - else - control.arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortdown.dds") - scroll:SetResizeToFitPadding(5, 0) - scroll:SetHeight(0) - 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 + local control = wm:CreateControl(controlName or submenuData.reference, parent.scroll or parent, CT_CONTROL) + control.panel = parent + control:SetDimensions(523, 40) + + control.label = wm:CreateControlFromVirtual(nil, control, "ZO_Options_SectionTitleLabel") + local label = control.label + label:SetAnchor(TOPLEFT, control, TOPLEFT, 5, 5) + label:SetDimensions(520, 30) + label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) + label:SetText(submenuData.name) + label:SetMouseEnabled(true) + if submenuData.tooltip then + label.data = {tooltipText = submenuData.tooltip} + label:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) + label:SetHandler("OnMouseExit", ZO_Options_OnMouseExit) + end + + control.scroll = wm:CreateControl(nil, control, CT_SCROLL) + local scroll = control.scroll + scroll:SetParent(control) + scroll:SetAnchor(TOPLEFT, label, BOTTOMLEFT, 0, 10) + scroll:SetDimensionConstraints(525, 0, 525, 2500) + + control.bg = wm:CreateControl(nil, label, CT_BACKDROP) + local bg = control.bg + bg:SetAnchor(TOPLEFT, 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) + + control.arrow = wm:CreateControl(nil, bg, CT_TEXTURE) + local arrow = control.arrow + arrow:SetDimensions(28, 28) + arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortdown.dds") --list_sortup for the other way + arrow:SetAnchor(TOPRIGHT, bg, TOPRIGHT, -5, 5) + + --figure out the cool animation later... + control.animation = am:CreateTimeline() + local animation = control.animation + animation:SetPlaybackType(ANIMATION_SIZE, 0) --2nd arg = loop count + + control:SetResizeToFitDescendents(true) + control.open = false + label:SetHandler("OnMouseUp", AnimateSubmenu) + animation:SetHandler("OnStop", function(self, completedPlaying) + scroll:SetResizeToFitDescendents(control.open) + if control.open then + control.arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortup.dds") + scroll:SetResizeToFitPadding(5, 20) + else + control.arrow:SetTexture("EsoUI\\Art\\Miscellaneous\\list_sortdown.dds") + scroll:SetResizeToFitPadding(5, 0) + scroll:SetHeight(0) + 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 c51f063..26b0353 100644 --- a/libs/LibAddonMenu-2.0/controls/texture.lua +++ b/libs/LibAddonMenu-2.0/controls/texture.lua @@ -10,42 +10,41 @@ --add texture coords support? -local widgetVersion = 5 +local widgetVersion = 6 local LAM = LibStub("LibAddonMenu-2.0") if not LAM:RegisterWidget("texture", widgetVersion) then return end 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 or parent) - - local isHalfWidth = textureData.width == "half" - if isHalfWidth then - control:SetDimensionConstraints(250, 55, 250, 100) - control:SetDimensions(250, 55) - else - control:SetDimensionConstraints(510, 30, 510, 100) - control:SetDimensions(510, 30) - end - - control.texture = wm:CreateControl(nil, control, CT_TEXTURE) - local texture = control.texture - texture:SetAnchor(CENTER) - texture:SetDimensions(textureData.imageWidth, textureData.imageHeight) - texture:SetTexture(textureData.image) - - if textureData.tooltip then - texture:SetMouseEnabled(true) - --texture.tooltipText = textureData.tooltip - texture.data = { tooltipText = textureData.tooltip } - texture:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) - texture:SetHandler("OnMouseEnter", ZO_Options_OnMouseExit) - end - - control.panel = parent.panel or parent --if this is in a submenu, panel is its parent - control.data = textureData - - return control + local control = wm:CreateControl(controlName or textureData.reference, parent.scroll or parent, CT_CONTROL) + control:SetResizeToFitDescendents(true) + + local isHalfWidth = textureData.width == "half" + if isHalfWidth then + control:SetDimensionConstraints(250, 55, 250, 100) + control:SetDimensions(250, 55) + else + control:SetDimensionConstraints(510, 30, 510, 100) + control:SetDimensions(510, 30) + end + + control.texture = wm:CreateControl(nil, control, CT_TEXTURE) + local texture = control.texture + texture:SetAnchor(CENTER) + texture:SetDimensions(textureData.imageWidth, textureData.imageHeight) + texture:SetTexture(textureData.image) + + if textureData.tooltip then + texture:SetMouseEnabled(true) + --texture.tooltipText = textureData.tooltip + texture.data = {tooltipText = textureData.tooltip} + texture:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter) + texture:SetHandler("OnMouseEnter", ZO_Options_OnMouseExit) + end + + control.panel = parent.panel or parent --if this is in a submenu, panel is its parent + control.data = textureData + + return control end \ No newline at end of file diff --git a/libs/LibMediaProvider-1.0/LibMediaProvider-1.0.lua b/libs/LibMediaProvider-1.0/LibMediaProvider-1.0.lua index aaa18d1..f829a96 100644 --- a/libs/LibMediaProvider-1.0/LibMediaProvider-1.0.lua +++ b/libs/LibMediaProvider-1.0/LibMediaProvider-1.0.lua @@ -1,7 +1,7 @@ --LibMediaProvider-1.0 is inspired by and borrows from LibSharedMedia-3.0 for World of Warcraft by Elkano --LibSharedMedia-3.0 and LibMediaProvider-1.0 are under the LGPL-2.1 license -local MAJOR, MINOR = "LibMediaProvider-1.0", 7 -- remember to increase manually on changes +local MAJOR, MINOR = "LibMediaProvider-1.0", 8 -- remember to increase manually on changes local LMP = LibStub:NewLibrary(MAJOR, MINOR) if not LMP then return end @@ -56,8 +56,9 @@ LMP.DefaultMedia.border = "ESO Gold" LMP.MediaTable.font = LMP.MediaTable.font or {} LMP.MediaTable.font["ProseAntique"] = "EsoUI/Common/Fonts/ProseAntiquePSMT.otf" LMP.MediaTable.font["Consolas"] = "EsoUI/Common/Fonts/consola.ttf" -LMP.MediaTable.font["Futura Condensed Light"] = "EsoUI/Common/Fonts/FuturaStd-CondensedLight.otf" -LMP.MediaTable.font["Futura Condensed"] = "EsoUI/Common/Fonts/FuturaStd-Condensed.otf" +LMP.MediaTable.font["Futura Condensed"] = "EsoUI/Common/Fonts/FTN57.otf" +LMP.MediaTable.font["Futura Condensed Bold"] = "EsoUI/Common/Fonts/FTN87.otf" +LMP.MediaTable.font["Futura Condensed Light"] = "EsoUI/Common/Fonts/FTN47.otf" LMP.MediaTable.font["Skyrim Handwritten"] = "EsoUI/Common/Fonts/Handwritten_Bold.otf" LMP.MediaTable.font["Trajan Pro"] = "EsoUI/Common/Fonts/trajanpro-regular.otf" LMP.MediaTable.font["Univers 55"] = "EsoUI/Common/Fonts/univers55.otf" @@ -159,5 +160,3 @@ function LMP:SetDefault(mediatype, key) return false end end - - diff --git a/local/de.lua b/local/de.lua index d91ee46..5680119 100644 --- a/local/de.lua +++ b/local/de.lua @@ -101,6 +101,10 @@ cl.ln = { tRT = "Fügt eine Zeile unter der Clock ein mit der Zeit deines Betriebssystems.", sDate = "Zeige reales Datum", tDate = "Fügt eine Zeile unter der Clock ein mit dem Tag, Monat und Jahr deines Betriebssystems.", + nsBg = "Zeige Hintergrund", + tsBg = "Fügt einen Hintergrund hinter die Clock hinzu.", + sHor = "Horizontal", + tHor = "Zeige die lore- und reale Zeit nebeneinander an.", -- Look look = "Aussehen Einstellungen", lookTxt = "Verschiedene Einstellungen um das Aussehen der Clock zu verändern.", @@ -112,6 +116,8 @@ cl.ln = { tStyle = "Verändere die Design der Clock.", nSize = "Größe", tSize = "Verändere die Größe der Clock.", + nBg = "Hintergrund", + tBg = "Wählen Sie den Hintergrund aus.", descEditLookY = "Verändere das Format der Clock: Benutze '_' bevor einer Variablen!\n" .. "Jahr/Monat/Tag", descEditLookYTxt = "Jahr: Y = 582 (14)\tYY = 2Ä 582 (2014)\n" diff --git a/local/en.lua b/local/en.lua index b97e9b4..696d05d 100644 --- a/local/en.lua +++ b/local/en.lua @@ -98,6 +98,8 @@ cl.ln = { tRT = "Adds a line under the Clock with the Time of your Operating System.", sDate = "Show real Date", tDate = "Adds a line under the Clock with the day, month and year of your Operating System.", + nsBg = "Show Background", + tsBg = "Adds a background behind the Clock.", -- Look look = "Look Options", lookTxt = "Various options to change how the Clock looks.", @@ -109,6 +111,10 @@ cl.ln = { tStyle = "Change the style of the Clock.", nSize = "Size", tSize = "Change the size of the Clock.", + nBg = "Background", + tBg = "Choose a background for the Clock.", + sHor = "Horizontal", + tHor = "Show the lore- and real time next to each other.", descEditLookY = "Change the format of the Clock: Use '_' before a variable!\n" .. "Year/Month/Day", descEditLookYTxt = "Year: Y = 582 (14)\tYY = 2E 582 (2014)\n" diff --git a/local/fr.lua b/local/fr.lua index 69e9783..f09b44e 100644 --- a/local/fr.lua +++ b/local/fr.lua @@ -98,6 +98,8 @@ cl.ln = { tRT = "Adds a line under the Clock with the Time of your Operating System.", sDate = "Show real Date", tDate = "Adds a line under the Clock with the day, month and year of your Operating System.", + nsBg = "Show Background", + tsBg = "Adds a background behind the Clock.", -- Look look = "Look Options", lookTxt = "Various options to change how the Clock looks.", @@ -109,6 +111,10 @@ cl.ln = { tStyle = "Change the style of the Clock.", nSize = "Size", tSize = "Change the size of the Clock.", + nBg = "Background", + tBg = "Choose a background for the Clock.", + sHor = "Horizontal", + tHor = "Show the lore- and real time next to each other.", descEditLookY = "Change the format of the Clock: Use '_' before a variable!\n" .. "Year/Month/Day", descEditLookYTxt = "Year: Y = 582 (14)\tYY = 2E 582 (2014)\n"