diff --git a/.luacheckrc b/.luacheckrc deleted file mode 100644 index da25fd7..0000000 --- a/.luacheckrc +++ /dev/null @@ -1,119 +0,0 @@ --- -*- mode: lua; -*- -std = "luajit" - -globals = { - "base", - "LibAddonMenu2", - "CollectionBars", - "CBs_Button", - "CBs_Clicked", - "JarthSharedBase", - "LibStub", - "CreateControlFromVirtual", - "GetCollectibleCooldownAndDuration", - "GetControl", - "GetKeyName", - "GetHighestPriorityActionBindingInfoFromName", - "GetTotalCollectiblesByCategoryType", - "GetTotalUnlockedCollectiblesByCategoryType", - "GetTimeStamp", - "GetFrameTimeMilliseconds", - "GetCollectibleId", - "GetCollectibleIdFromType", - "GetCollectibleInfo", - "GetCollectibleCategoryInfo", - "GetInterfaceColor", - "CT_BACKDROP", - "CT_LABEL", - "CT_TEXTURE", - "SCENE_MANAGER", - "ZO_HUDFadeSceneFragment", - "GetWindowManager", - "IsCollectibleActive", - "IsCollectibleCategoryUsable", - "IsCollectibleUsable", - "IsCollectibleUnlocked", - "IsCollectibleValidForPlayer", - "UseCollectible", - "EVENT_MANAGER", - "EVENT_ADD_ON_LOADED", - "EVENT_COLLECTIBLE_USE_RESULT", - "COLLECTIBLE_USAGE_BLOCK_REASON_NOT_BLOCKED", - "COLLECTIBLE_CATEGORY_TYPE_ASSISTANT", - "COLLECTIBLE_CATEGORY_TYPE_COSTUME", - "COLLECTIBLE_CATEGORY_TYPE_ABILITY_SKIN", - "COLLECTIBLE_CATEGORY_TYPE_BODY_MARKING", - "COLLECTIBLE_CATEGORY_TYPE_EMOTE", - "COLLECTIBLE_CATEGORY_TYPE_FACIAL_ACCESSORY", - "COLLECTIBLE_CATEGORY_TYPE_FACIAL_HAIR_HORNS", - "COLLECTIBLE_CATEGORY_TYPE_HAIR", - "COLLECTIBLE_CATEGORY_TYPE_HAT", - "COLLECTIBLE_CATEGORY_TYPE_HEAD_MARKING", - "COLLECTIBLE_CATEGORY_TYPE_OUTFIT_STYLE", - "COLLECTIBLE_CATEGORY_TYPE_PERSONALITY", - "COLLECTIBLE_CATEGORY_TYPE_PIERCING_JEWELRY", - "COLLECTIBLE_CATEGORY_TYPE_POLYMORPH", - "COLLECTIBLE_CATEGORY_TYPE_SKIN", - "COLLECTIBLE_CATEGORY_TYPE_MEMENTO", - "COLLECTIBLE_CATEGORY_TYPE_MOUNT", - "COLLECTIBLE_CATEGORY_TYPE_VANITY_PET", - "TOPLEFT", - "TOPRIGHT", - "BOTTOM", - "BOTTOMLEFT", - "CENTER", - "BOTTOMRIGHT", - "LEFT", - "RIGHT", - "TOP", - "GuiRoot", - "ADDON_MINOR_VERSION", - "ZO_Object", - "ZO_CreateStringId", - "ZO_GAMEPAD_ACTION_BUTTON_SIZE", - "ZO_Tooltips_ShowTextTooltip", - "ZO_Tooltips_HideTextTooltip", - "ZO_SavedVars", - "ZO_Anchor", - "CD_TYPE_RADIAL", - "NO_LEADING_EDGE", - "ANIMATION_TEXTURE", - "CreateSimpleAnimation", - "ZO_ContextualActionBar_AddReference", - "ZO_ContextualActionBar_RemoveReference", - "ZO_FormatTimeAsDecimalWhenBelowThreshold", - "d", - "_", - "HUD_SCENE", - "HUD_UI_SCENE", - "zo_round", - "zo_ceil", - "BSTATE_PRESSED", - "BSTATE_NORMAL", - "PlaySound", - "SOUNDS", - "INTERFACE_TEXT_COLOR_FAILED", - "INTERFACE_TEXT_COLOR_SELECTED", - "INTERFACE_COLOR_TYPE_TEXT_COLORS", - "TEXT_ALIGN_LEFT", -- 0 - "TEXT_ALIGN_CENTER", -- 1 - "TEXT_ALIGN_RIGHT", -- 2 - "TEXT_ALIGN_TOP", -- 3 - "TEXT_ALIGN_BOTTOM", -- 4 - "IsSlotToggled", - "FORCE_SUPPRESS_COOLDOWN_SOUND", - "SLASH_COMMANDS", - "CBs_List", - "ZO_SortFilterList", - "ZO_ScrollList_AddDataType", - "ZO_ScrollList_GetDataList", - "ZO_ClearNumericallyIndexedTable", - "ZO_ScrollList_CreateDataEntry", - "ZO_CheckButton_SetCheckState", - "ZO_CheckButton_SetToggleFunction", - "ZO_CheckButton_SetEnableState", - "MOUSE_BUTTON_INDEX_LEFT", - "MOUSE_BUTTON_INDEX_RIGHT", - "ZO_CheckButton_SetLabelText", - "ZO_DEFAULT_ENABLED_COLOR" -} diff --git a/CBs_Bindings.lua b/CBs_Bindings.lua index b6861cf..e59dfbc 100644 --- a/CBs_Bindings.lua +++ b/CBs_Bindings.lua @@ -2,7 +2,6 @@ Author: Jarth Filename: CBs_Bindings.lua ]] -- - ------------------------------------------------------------------------------------------------- -- VARIABLES -- ------------------------------------------------------------------------------------------------- @@ -29,16 +28,13 @@ function CBs_Clicked(keyId) for cid, _keyId in pairs(base.Global.ReverseBindings) do if cid ~= newCId and _keyId == keyId then base.Global.ReverseBindings[cid] = nil - base.SetbindingText(cid, "") + base.SetbindingText(cid) end end base.Saved.Bindings[keyId] = newCId base.Global.ReverseBindings[newCId] = keyId - - if base.Buttons[newCId] then - base.Buttons[newCId]:SetBindingText(base.Saved.ShowBinding, base.GetBindingNameFromCId(newCId)) - end + base.SetbindingText(newCId) end elseif collectibleId > 0 then if base.Buttons[collectibleId] then @@ -49,9 +45,9 @@ function CBs_Clicked(keyId) end end -function base.SetbindingText(cid, text) +function base.SetbindingText(cid) if base.Buttons[cid] then - base.Buttons[cid]:SetBindingText(base.Saved.ShowBinding, text) + base.Buttons[cid]:SetBindingText(base.Saved.ShowBinding, cid) end end @@ -87,8 +83,3 @@ function base.GetBindingNameFromCId(cid) end return result end - ---- ---- TODO: Implement a listener, that is set/unset when a field is selected. ---- Inspiration: "keybindingutils.lua":"function ZO_Keybindings_RegisterLabelForBindingUpdate(label, actionName, showUnbound, gamepadActionName, onChangedCallback, alwaysPreferGamepadMode)" ---- \ No newline at end of file diff --git a/CBs_Button.lua b/CBs_Button.lua index 963fe1c..3617c29 100644 --- a/CBs_Button.lua +++ b/CBs_Button.lua @@ -2,18 +2,18 @@ Author: Jarth Filename: CBs_Button.lua ]] -- - ------------------------------------------------------------------------------------------------- -- FUNCTIONS -- ------------------------------------------------------------------------------------------------- CBs_Button = ZO_Object:Subclass() -function CBs_Button:New(_type, frame, cId, saved) +function CBs_Button:New(base, _type, frame, cId, saved) local newB = ZO_Object.New(self) if newB then local ctrl = CreateControlFromVirtual(_type.Name .. "_Button", frame, "CBs_Button", cId) newB.cId = cId + newB.base = base newB.type = _type newB.saved = saved newB.ctrl = ctrl @@ -54,30 +54,21 @@ function CBs_Button:Setup(base) self.cooldownIcon:SetDesaturation(1) end - self.button:SetHandler( - "OnClicked", - function() - base.Activate(self) + self.button:SetHandler("OnClicked", function() + base.Activate(self) + end) + self.button:SetHandler("OnMouseEnter", function() + if self.playSounds then + PlaySound(SOUNDS.QUICKSLOT_MOUSEOVER) end - ) - self.button:SetHandler( - "OnMouseEnter", - function() - if self.playSounds then - PlaySound(SOUNDS.QUICKSLOT_MOUSEOVER) - end - if self.type.Saved.Tooltip.Show then - local text = self.type.Collection[self.cId].Name - ZO_Tooltips_ShowTextTooltip(self.button, self.type.Saved.Tooltip.Position, text) - end + if self.type.Saved.Tooltip.Show then + local text = self.type.Collection[self.cId].Name + ZO_Tooltips_ShowTextTooltip(self.button, self.type.Saved.Tooltip.Position, text) end - ) - self.button:SetHandler( - "OnMouseExit", - function() - ZO_Tooltips_HideTextTooltip() - end - ) + end) + self.button:SetHandler("OnMouseExit", function() + ZO_Tooltips_HideTextTooltip() + end) end function CBs_Button:SetShowBindingText(visible) @@ -91,15 +82,19 @@ function CBs_Button:SetSize(size) self.icon:SetWidth(size - 6) end -function CBs_Button:SetBindingText(show, text) - if self.buttonText ~= nil and show then - self.buttonText:SetHeight(self.ctrl:GetHeight()) - self.buttonText:SetWidth(self.ctrl:GetWidth()) +function CBs_Button:SetBindingText(show, cId) + local keyId = self.base.Global.ReverseBindings[cId] + if self.buttonText ~= nil then + ZO_Keybindings_UnregisterLabelForBindingUpdate(self.buttonText) self.buttonText:ClearAnchors() - self.buttonText:SetAnchor(BOTTOM, self.ctrl, BOTTOM, 0, 0) - self.buttonText:SetText(text) - elseif self.buttonText ~= nil then self.buttonText:SetText("") + if keyId ~= nil and show then + ZO_Keybindings_UnregisterLabelForBindingUpdate(self.buttonText) + self.buttonText:SetHeight(self.ctrl:GetHeight()) + self.buttonText:SetWidth(self.ctrl:GetWidth()) + self.buttonText:SetAnchor(BOTTOM, self.ctrl, BOTTOM, 0, 0) + ZO_Keybindings_RegisterLabelForBindingUpdate(self.buttonText, string.format("%s_%s", self.base.Addon.Abbreviation, keyId), false) + end end end @@ -152,12 +147,9 @@ function CBs_Button:UpdateCooldown(remaining, duration, cooldown) self.cooldownCompleteAnim.animation:GetTimeline():PlayInstantlyToStart() end self.cooldown:SetHidden(false) - self.ctrl:SetHandler( - "OnUpdate", - function() - self:RefreshCooldown(remaining, duration, cooldown) - end - ) + self.ctrl:SetHandler("OnUpdate", function() + self:RefreshCooldown(remaining, duration, cooldown) + end) else if self.showingCooldown then if self.playSounds then diff --git a/CBs_Button.xml b/CBs_Button.xml new file mode 100644 index 0000000..a23a1ad --- /dev/null +++ b/CBs_Button.xml @@ -0,0 +1,49 @@ +<GuiXml> + <Controls> + <Control name="CBs_Button" clampedToScreen="true" movable="false" virtual="true"> + <Controls> + <Button name="$(parent)Button" mouseOverBlendMode="ADD"> + <AnchorFill /> + <MouseButton button="1" enabled="true" /> + <MouseButton button="2" enabled="true" /> + <Textures normal="/EsoUI/Art/ActionBar/abilityFrame64_up.dds" pressed="/EsoUI/Art/ActionBar/abilityFrame64_down.dds" mouseOver="/EsoUI/Art/ActionBar/actionBar_mouseOver.dds" /> + </Button> + + <Texture name="$(parent)BG" level="0" textureFile="/EsoUI/Art/ActionBar/abilityInset.dds"> + <Anchor point="TOPLEFT" relativeTo="$(parent)" /> + <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)" /> + </Texture> + <Texture name="$(parent)Icon" level="1"> + <Anchor point="CENTER" relativeTo="$(parent)" /> + </Texture> + <Texture name="$(parent)CooldownIcon" level="1"> + <TextureCoords left="0" right="1" top="0" bottom="0" /> + <Anchor point="TOPLEFT" relativeTo="$(parent)Icon" relativePoint="TOPLEFT" /> + <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)Icon" relativePoint="BOTTOMRIGHT" /> + </Texture> + <Texture name="$(parent)Status" textureFile="/EsoUI/Art/ActionBar/ActionSlot_toggledon.dds" tier="HIGH" hidden="true"> + <Anchor point="TOPLEFT" relativeTo="$(parent)Icon" relativePoint="TOPLEFT" /> + <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)Icon" relativePoint="BOTTOMRIGHT" /> + </Texture> + + <Cooldown name="$(parent)Cooldown" inherits="ZO_DefaultCooldown" tier="HIGH" alpha="0.7"> + <Anchor point="TOPLEFT" relativeTo="$(parent)Icon" relativePoint="TOPLEFT" /> + <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)Icon" relativePoint="BOTTOMRIGHT" /> + </Cooldown> + <Texture name="$(parent)CooldownCompleteAnimation" textureFile="/EsoUI/Art/ActionBar/coolDown_completeEFX.dds" blendMode="ADD" tier="HIGH" hidden="true"> + <Anchor point="TOPLEFT" relativeTo="$(parent)Icon" relativePoint="TOPLEFT" /> + <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)Icon" relativePoint="BOTTOMRIGHT" /> + </Texture> + + <Label name="$(parent)ButtonText" wrapMode="ELLIPSIS" horizontalAlignment="CENTER" tier="HIGH" verticalAlignment="BOTTOM" font="ZoFontGameSmall"> + <Anchor point="BOTTOM" relativeTo="$(parent)Button" relativePoint="BOTTOM" /> + </Label> + + <Label name="$(parent)CooldownTime" inherits="ZO_CollectibleTileDefaultLabel" hidden="true" clampedToScreen="true"> + <Anchor point="TOPLEFT" relativeTo="$(parent)Icon" relativePoint="TOPLEFT" /> + <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)Icon" relativePoint="BOTTOMRIGHT" /> + </Label> + </Controls> + </Control> + </Controls> +</GuiXml> \ No newline at end of file diff --git a/CBs_Buttons.lua b/CBs_Buttons.lua index 3d8fc42..901ceae 100644 --- a/CBs_Buttons.lua +++ b/CBs_Buttons.lua @@ -2,7 +2,6 @@ Author: Jarth Filename: CBs_Buttons.lua ]] -- - ------------------------------------------------------------------------------------------------- -- VARIABLES -- ------------------------------------------------------------------------------------------------- @@ -15,7 +14,7 @@ function base.SetFrameAndCombineSize(_type) local width, height = base.GetBarWidthHeight(_type) base.SetFrameSizeIfExists(_type.Frame, width, height) - if _type.Saved.Combine then + if _type.Saved.IsCombined and not _type.Saved.HideAll then base.SetFrameSizeIfExists(base.Global.Combine.Frame, width, height) end end @@ -52,16 +51,16 @@ function base.SetupButtons(_type) for _, _value in ipairs(_type.OrderedCollection) do local hideButton = true - if selected[_value.Id] and IsCollectibleUnlocked(_value.Id) and IsCollectibleValidForPlayer(_value.Id) then + if _type.Saved.Enabled and selected[_value.Id] and IsCollectibleUnlocked(_value.Id) and IsCollectibleValidForPlayer(_value.Id) then if base.Buttons[_value.Id] == nil then - base.Buttons[_value.Id] = CBs_Button:New(_type, frame, _value.Id, base.Saved) + base.Buttons[_value.Id] = CBs_Button:New(base, _type, frame, _value.Id, base.Saved) end if not _type.Saved.HideAll and (maxIndex == 0 or index <= maxIndex) then hideButton = false local left, top = base.GetButtonPosition(_type, index) - base.Buttons[_value.Id]:SetBindingText(base.Saved.ShowBinding, base.GetBindingNameFromCId(_value.Id)) + base.Buttons[_value.Id]:SetBindingText(base.Saved.ShowBinding, _value.Id) base.Buttons[_value.Id]:Setup(base) base.Buttons[_value.Id]:UpdateAnchor(frame, left, top) base.Buttons[_value.Id]:UpdatePlaySounds(base.Saved.IsAudioEnabled) @@ -69,6 +68,8 @@ function base.SetupButtons(_type) index = index + 1 end _type.IsEmpty = false + elseif not _type.Saved.Enabled and base.Buttons[_value.Id] ~= nil then + base.Buttons[_value.Id]:SetHidden(true) end if base.Buttons[_value.Id] ~= nil then @@ -78,12 +79,13 @@ function base.SetupButtons(_type) end end + local isHidden = _type.IsEmpty and not base.Global.EnableSettings or not _type.Saved.Enabled if _type.Frame then - _type.Frame:SetHidden(_type.IsEmpty and not base.Global.EnableSettings) + _type.Frame:SetHidden(isHidden) end if _type.FrameLabel then - _type.FrameLabel:SetHidden(_type.IsEmpty and not base.Global.EnableSettings) + _type.FrameLabel:SetHidden(isHidden) end end @@ -132,45 +134,37 @@ function base.Activate(button) if button and base.Saved.IsActiveActivationEnabled then EVENT_MANAGER:UnregisterForEvent(base.Addon.Abbreviation .. button.type.Name .. tostring(button.type.EventTS), EVENT_COLLECTIBLE_USE_RESULT) button.type.EventTS = GetTimeStamp() - EVENT_MANAGER:RegisterForEvent( - base.Addon.Abbreviation .. button.type.Name .. tostring(button.type.EventTS), - EVENT_COLLECTIBLE_USE_RESULT, - function(_, result, isAttemptingActivation) - local countDown = button.type.Cooldown - local success = false - - if result == COLLECTIBLE_USAGE_BLOCK_REASON_NOT_BLOCKED and button.button then - success = true - countDown.CollectibleId = button.cId - base.UpdateButtonsState(button.type, button.cId, isAttemptingActivation) - end - - local successActivate = isAttemptingActivation and success - countDown.StartTime = GetFrameTimeMilliseconds() - - EVENT_MANAGER:UnregisterForEvent(base.Addon.Abbreviation .. button.type.Name .. tostring(button.type.EventTS), EVENT_COLLECTIBLE_USE_RESULT) - - if success then - EVENT_MANAGER:UnregisterForUpdate(base.Addon.Abbreviation .. button.type.Name .. countDown.Event) - EVENT_MANAGER:RegisterForUpdate( - base.Addon.Abbreviation .. button.type.Name .. countDown.Event, - countDown.Tick, - function() - local remaining, duration = GetCollectibleCooldownAndDuration(countDown.CollectibleId) - local cooldown = base.GetCooldownText(countDown, duration) - - base.UpdateButtonsCooldown(button.type, remaining, duration, cooldown) - if duration == 0 then - countDown.StartTime = nil - local isActive = successActivate or IsCollectibleActive(button.cId) - base.UpdateButtonsState(button.type, button.cId, isActive) - EVENT_MANAGER:UnregisterForUpdate(base.Addon.Abbreviation .. button.type.Name .. countDown.Event) - end - end - ) - end + EVENT_MANAGER:RegisterForEvent(base.Addon.Abbreviation .. button.type.Name .. tostring(button.type.EventTS), EVENT_COLLECTIBLE_USE_RESULT, function(_, result, isAttemptingActivation) + local countDown = button.type.Cooldown + local success = false + + if result == COLLECTIBLE_USAGE_BLOCK_REASON_NOT_BLOCKED and button.button then + success = true + countDown.CollectibleId = button.cId + base.UpdateButtonsState(button.type, button.cId, isAttemptingActivation) + end + + local successActivate = isAttemptingActivation and success + countDown.StartTime = GetFrameTimeMilliseconds() + + EVENT_MANAGER:UnregisterForEvent(base.Addon.Abbreviation .. button.type.Name .. tostring(button.type.EventTS), EVENT_COLLECTIBLE_USE_RESULT) + + if success then + EVENT_MANAGER:UnregisterForUpdate(base.Addon.Abbreviation .. button.type.Name .. countDown.Event) + EVENT_MANAGER:RegisterForUpdate(base.Addon.Abbreviation .. button.type.Name .. countDown.Event, countDown.Tick, function() + local remaining, duration = GetCollectibleCooldownAndDuration(countDown.CollectibleId) + local cooldown = base.GetCooldownText(countDown, duration) + + base.UpdateButtonsCooldown(button.type, remaining, duration, cooldown) + if duration == 0 then + countDown.StartTime = nil + local isActive = successActivate or IsCollectibleActive(button.cId) + base.UpdateButtonsState(button.type, button.cId, isActive) + EVENT_MANAGER:UnregisterForUpdate(base.Addon.Abbreviation .. button.type.Name .. countDown.Event) + end + end) end - ) + end) end button:UpdateUsable() button:OnClicked() diff --git a/CBs_Constants.lua b/CBs_Constants.lua index 9d77fee..72582ab 100644 --- a/CBs_Constants.lua +++ b/CBs_Constants.lua @@ -2,7 +2,6 @@ Author: Jarth Filename: CBs_Constants.lua ]] -- - ------------------------------------------------------------------------------------------------- -- VARIABLES -- ------------------------------------------------------------------------------------------------- @@ -13,8 +12,9 @@ CollectionBars = { DisplayName = "Collection Bars", Abbreviation = "CBs", Version = 1.0, - MinorVersion = 0.2, - Command = "/cb", + MinorVersion = 0.3, + Command = "/cb_menu", + SettingsSlash = "/cb", Author = "Jarth", Website = "" }, @@ -37,71 +37,22 @@ CollectionBars = { Bindings = {[1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0, [10] = 0}, IsAudioEnabled = true, IsActiveActivationEnabled = true, - Combine = { - BarDepth = 0, - BarWidth = 0, - X = CENTER, - Y = CENTER, - AnchorXY = TOPLEFT, - Display = "CombineBar", - Label = { - OffsetX = 0, - OffsetY = 0, - Position = BOTTOMLEFT, - PositionTarget = TOPLEFT - } - } + Combine = {BarDepth = 0, BarWidth = 0, X = CENTER, Y = CENTER, AnchorXY = TOPLEFT, Display = "CombineBar", Label = {OffsetX = 0, OffsetY = 0, Position = BOTTOMLEFT, PositionTarget = TOPLEFT}}, + UseLAMMenu = true }, Global = { HideAllId = "CBs_HideAll", - SettingsSlash = "/cb_settings", EnableSettings = false, IsMoveEnabled = false, ReverseBindings = {}, SettingsFrame = nil, SettingsList = nil, - Combine = { - Name = "Combine", - EventTS = nil, - MoveFrame = nil, - Frame = nil, - HideAll = nil, - Fragment = nil, - IsEmpty = false - }, - ChoiceLocations = { - "top", - "topright", - "right", - "bottomright", - "bottom", - "bottomleft", - "left", - "topleft", - "center" - }, - ChoiceCornerLocations = { - "topleft", - "topright", - "bottomright", - "bottomleft" - }, - ChoiceSideLocations = { - "top", - "right", - "bottom", - "left" - }, - AvailableFonts = { - "ZoFontGameSmall", - "ZoFontGameLarge", - "ZoFontGameLargeBold", - "ZoFontGameLargeBoldShadow", - "ZoFontHeader", - "ZoFontHeader2", - "ZoFontHeader3", - "ZoFontHeader4" - }, + SettingsFilters = {["CollectionTypes"] = "Collection Types", ["Selection"] = "Collectibles", ["Collection"] = "Collection bar", ["General"] = "General", ["Combined"] = "Combined bar"}, + Combine = {Name = "Combine", EventTS = nil, MoveFrame = nil, Frame = nil, _type = nil, HideAll = nil, Fragment = nil, IsEmpty = false}, + ChoiceLocations = {"top", "topright", "right", "bottomright", "bottom", "bottomleft", "left", "topleft", "center"}, + ChoiceCornerLocations = {"topleft", "topright", "bottomright", "bottomleft"}, + ChoiceSideLocations = {"top", "right", "bottom", "left"}, + AvailableFonts = {"ZoFontGameSmall", "ZoFontGameLarge", "ZoFontGameLargeBold", "ZoFontGameLargeBoldShadow", "ZoFontHeader", "ZoFontHeader2", "ZoFontHeader3", "ZoFontHeader4"}, ScenePairs = { ShowBarOnHud = HUD_SCENE, ShowBarOnHudUI = HUD_UI_SCENE, @@ -164,12 +115,7 @@ function CollectionBars.GenerateCollectionTypes() Count = nil, BarDepth = 0, BarWidth = nil, - Cooldown = { - Event = "Cooldown" .. setupElement.Name, - CollectibleId = nil, - StartTime = nil, - Tick = 100 - }, + Cooldown = {Event = "Cooldown" .. setupElement.Name, CollectibleId = nil, StartTime = nil, Tick = 100}, Fragment = nil } CollectionBars.TypeOrdered[collectionIndex] = CollectionBars.Type[setupElement.Name] @@ -181,10 +127,7 @@ function CollectionBars.GenerateCollectionTypes() HideAll = true, HideAllEnabled = true, MenuShowDisabled = false, - Tooltip = { - Show = true, - Position = TOP - }, + Tooltip = {Show = true, Position = TOP}, Horizontal = true, BarDepth = 0, BarWidth = 0, @@ -193,17 +136,9 @@ function CollectionBars.GenerateCollectionTypes() AnchorXY = TOPLEFT, Display = setupElement.Display, LabelShow = true, - Label = { - OffsetX = 0, - OffsetY = 0, - Height = 19, - Width = 75, - Font = "ZoFontGameSmall", - Position = BOTTOMLEFT, - PositionTarget = TOPLEFT - }, - Combine = true + Label = {OffsetX = 0, OffsetY = 0, Height = 19, Width = 75, Font = "ZoFontGameSmall", Position = BOTTOMLEFT, PositionTarget = TOPLEFT}, + IsCombined = true } end end -end \ No newline at end of file +end diff --git a/CBs_Fragment.lua b/CBs_Fragment.lua index 15aa5aa..2a4a08b 100644 --- a/CBs_Fragment.lua +++ b/CBs_Fragment.lua @@ -2,7 +2,6 @@ Author: Jarth Filename: CBs_Fragment.lua ]] -- - ------------------------------------------------------------------------------------------------- -- VARIABLES -- ------------------------------------------------------------------------------------------------- diff --git a/CBs_Helpers.lua b/CBs_Helpers.lua index 9416261..09d2595 100644 --- a/CBs_Helpers.lua +++ b/CBs_Helpers.lua @@ -2,7 +2,6 @@ Author: Jarth Filename: CBs_Helpers.lua ]] -- - ------------------------------------------------------------------------------------------------- -- VARIABLES -- ------------------------------------------------------------------------------------------------- @@ -66,9 +65,9 @@ end function base.RestorePosition(_type) _type.Frame:ClearAnchors() local combineFrame = base.Global.Combine.Frame - if not _type.Saved.Combine or not combineFrame then + if not _type.Saved.IsCombined or not combineFrame then _type.Frame:SetAnchor(_type.Saved.AnchorXY, GuiRoot, TOPLEFT, _type.Saved.X, _type.Saved.Y) - elseif _type.Saved.Combine then + elseif _type.Saved.IsCombined then if not _type.Saved.HideAll then _type.Frame:SetAnchorFill(combineFrame) else @@ -89,7 +88,6 @@ function base.GetLabelPostFix(_type) return postFix end - function base.IsAllSelected(_type) local isAllSelected = true for _, collection in pairs(_type.Collection) do @@ -117,7 +115,7 @@ function base.GetVersion(showMinor) return tostring(base.Addon.Version) end - return tostring(base.Addon.Version) .. "." .. tostring(base.Addon.MinorVersion) + return string.format("%s.%s", tostring(base.Addon.Version), tostring(base.Addon.MinorVersion)) end function base.SetAndUpdateAccountSettings(newUseAccountSettings) @@ -132,6 +130,16 @@ function base.SetAndUpdateAccountSettings(newUseAccountSettings) end end +function base.ResetAccountSettings() + if base.Saved.UseAccountSettings then + _G[base.Addon.Name .. "_Account"] = nil + base.Saved = ZO_SavedVars:NewAccountWide(base.Addon.Name .. "_Account", base.Addon.Version, nil, base.Default) + else + _G[base.Addon.Name .. "_Character"] = nil + base.Saved = ZO_SavedVars:New(base.Addon.Name .. "_Character", base.Addon.Version, nil, base.Default) + end +end + function base.GetBarWidthHeight(_type) local width, height, count = 0, 0, 0 @@ -145,7 +153,7 @@ function base.GetBarWidthHeight(_type) local function GetBarMaxCount(type) local barConstraintXY = _type.Saved[type] - if _type.Saved.Combine then + if _type.Saved.IsCombined then barConstraintXY = base.Saved.Combine[type] end @@ -187,4 +195,8 @@ function base.HasAny(array) return true end return false -end \ No newline at end of file +end + +function base.SetControlText(control, text) + control.SetText(control, text) +end diff --git a/CBs_Labels.lua b/CBs_Labels.lua index dbed0a0..b206b41 100644 --- a/CBs_Labels.lua +++ b/CBs_Labels.lua @@ -2,7 +2,6 @@ Author: Jarth Filename: CBs_Labels.lua ]] -- - ------------------------------------------------------------------------------------------------- -- VARIABLES -- ------------------------------------------------------------------------------------------------- @@ -19,28 +18,25 @@ function base.SetupLabel(_type) _type.FrameLabel:SetDrawLevel(2) end end - _type.FrameLabel:SetHidden(not _type.Saved.LabelShow and not _type.Saved.Combine) + _type.FrameLabel:SetHidden(not _type.Saved.LabelShow and not _type.Saved.IsCombined) _type.FrameToggleSettings = GetControl(base.Global.HideAllId .. _type.Name .. "ToggleSettings") _type.FrameLabelButton = GetControl(base.Global.HideAllId .. _type.Name .. "Button") if _type.FrameLabelButton ~= nil then - _type.FrameLabelButton:SetHandler( - "OnClicked", - function(_, button) - if button == MOUSE_BUTTON_INDEX_LEFT then - if _type.Saved.HideAllEnabled or _type.Saved.Combine then - _type.Saved.HideAll = not _type.Saved.HideAll - if _type.Saved.Combine then - base.HideOther(_type) - end - base.RestoreFrame(_type) - base.RestoreCombine() + _type.FrameLabelButton:SetHandler("OnClicked", function(_, button) + if button == MOUSE_BUTTON_INDEX_LEFT then + if _type.Saved.HideAllEnabled or _type.Saved.IsCombined then + _type.Saved.HideAll = not _type.Saved.HideAll + if _type.Saved.IsCombined then + base.HideOthers(_type) end - elseif button == MOUSE_BUTTON_INDEX_RIGHT then - base.ToggleEnableSettings() + base.RestoreFrame(_type) + base.RestoreCombine() end + elseif button == MOUSE_BUTTON_INDEX_RIGHT then + base.ToggleEnableSettings() end - ) + end) end base.SetupToggleSettings(_type) @@ -54,10 +50,10 @@ function base.RestoreLabel(_type) frameLabel:ClearAnchors() frameLabel:SetHeight(label.Height) frameLabel:SetWidth(label.Width) - if not _type.Saved.Combine then + if not _type.Saved.IsCombined then frameLabel:SetAnchor(label.Position, _type.Frame, label.PositionTarget, label.OffsetX, label.OffsetY) end - frameLabel:SetHidden(not _type.Saved.Combine and not _type.Saved.LabelShow) + frameLabel:SetHidden(not _type.Saved.IsCombined and not _type.Saved.LabelShow) end local frameLabelButton = _type.FrameLabelButton @@ -66,7 +62,7 @@ function base.RestoreLabel(_type) frameLabelButton:SetFont(label.Font) frameLabelButton:SetHorizontalAlignment(TEXT_ALIGN_LEFT) frameLabelButton:SetVerticalAlignment(TOP) - frameLabelButton:SetText(_type.Saved.Display .. base.GetLabelPostFix(_type)) + frameLabelButton:SetText(tostring(_type.Saved.Display) .. base.GetLabelPostFix(_type)) end local frameLabelToggleSettings = _type.FrameToggleSettings @@ -97,11 +93,12 @@ function base.RestoreCombineLabels() local positionTarget = combineLabel.PositionTarget local position = combineLabel.Position for _, _type in pairs(base.TypeOrdered) do - if _type.Saved.Enabled and _type.Saved.Combine and _type.FrameLabel then + if _type.Saved.Enabled and _type.Saved.IsCombined and _type.FrameLabel then if (not _type.IsEmpty or base.Global.EnableSettings) then + local hasSelected = not base.HasAny(_type.Saved.Selected) _type.FrameLabel:ClearAnchors() - _type.FrameLabel:SetHidden(not _type.Saved.Combine and not base.HasAny(_type.Saved.Selected) and not _type.Saved.LabelShow and not base.Global.EnableSettings) - if not _type.FrameLabel:IsHidden() or (_type.Saved.LabelShow and base.HasAny(_type.Saved.Selected)) or base.Global.EnableSettings then + _type.FrameLabel:SetHidden(not hasSelected and not _type.Saved.LabelShow and not base.Global.EnableSettings) + if not _type.FrameLabel:IsHidden() or (_type.Saved.LabelShow and hasSelected) or base.Global.EnableSettings then width = width + _type.Saved.Label.OffsetX local offsetY = _type.Saved.Label.OffsetY + combineLabel.OffsetY _type.FrameLabel:SetAnchor(TOPLEFT, base.Global.Combine.HideAll, TOPLEFT, width, offsetY) diff --git a/CBs_List.lua b/CBs_List.lua deleted file mode 100644 index b422a0b..0000000 --- a/CBs_List.lua +++ /dev/null @@ -1,164 +0,0 @@ ---[[ -Author: Jarth -Filename: CBs_List.lua -]] -- - -------------------------------------------------------------------------------------------------- --- FUNCTIONS -- -------------------------------------------------------------------------------------------------- -CBs_List = ZO_SortFilterList:Subclass() - -function CBs_List:New(...) - self.list = ZO_SortFilterList.New(self, ...) - return self.list -end - -function CBs_List:Initialize(base, _type, ...) - ZO_SortFilterList.Initialize(self, ...) - self.base = base - self._type = _type - self.masterList = {} - - self:SetAlternateRowBackgrounds(false) - ZO_ScrollList_AddDataType( - self.list, - 1, - "CBs_ListRow", - 40, - function(control, data) - control._type = self._type - control.base = self.base - control.data = data - self:SetupListRow(control, data) - end - ) - ZO_ScrollList_AddDataType( - self.list, - 2, - "CBs_Divider", - 6, - function(control, data) - ZO_SortFilterList.SetupRow(self, control, data) - end - ) -end - -function CBs_List:SetupListRow(control, data) - ZO_SortFilterList.SetupRow(self, control, data) - - control.checkbox = GetControl(control, "Checkbox") - if control.checkbox then - control.checkbox.tooltipText = data.tooltipText - ZO_CheckButton_SetCheckState(control.checkbox, control.data.valueFunc and control.data.valueFunc()) - ZO_CheckButton_SetLabelText(control.checkbox, data.name) - if control.checkbox.label then - control.checkbox.label.defaultNormalColor = ZO_DEFAULT_ENABLED_COLOR - control.checkbox.label:ClearAnchors() - control.checkbox.label:SetAnchor(TOPLEFT, control.checkbox, TOPLEFT, -425) - control.checkbox.label:SetAnchor(BOTTOMRIGHT, control.checkbox, BOTTOMLEFT) - end - ZO_CheckButton_SetToggleFunction(control.checkbox, control.data.func) - ZO_CheckButton_SetEnableState(control.checkbox, not (control.data.disabledFunc and control.data.disabledFunc())) - end -end - -function CBs_List:BuildMasterList() - self.masterList = {} - - local function CBs_List_Show_Disabled_Collectible(checkBoxControl, newValue) - local control = checkBoxControl:GetParent() - control._type.Saved.MenuShowDisabled = newValue - control.base.CreateCollection(control._type) - control.base.Global.SettingsList:RefreshData() - end - - local function CBs_List_Select_All_Collectible(checkBoxControl, newValue) - local control = checkBoxControl:GetParent() - control.base.SelectAll(control._type, newValue) - control.base.RestoreFrame(control._type) - control.base.RestoreCombineLabels() - control.base.Global.SettingsList:RefreshData() - end - - local function CBs_List_Select_Collectible(checkBoxControl, newValue) - local control = checkBoxControl:GetParent() - if not (control.data.disabledFunc and control.data.disabledFunc()) then - if newValue == true then - control._type.Saved.Selected[control.data.cId] = newValue - else - control._type.Saved.Selected[control.data.cId] = nil - end - control.base.RestoreFrame(control._type) - control.base.RestoreCombineLabels() - control.base.Global.SettingsList:RefreshData() - end - end - - if self._type then - table.insert( - self.masterList, - { - name = "Show disabled " .. self._type.Name, - tooltipText = "When ON disabled elements will be shown for " .. self._type.Name, - valueFunc = function() - return self._type.Saved.MenuShowDisabled - end, - func = CBs_List_Show_Disabled_Collectible, - type = "show_disabled_collectible" - } - ) - table.insert(self.masterList, {type = "divider"}) - table.insert( - self.masterList, - { - name = "Select all " .. self._type.Name, - tooltipText = "When pressed all " .. self._type.Name .. " will either be selected or deselected", - valueFunc = function() - return self.base.IsAllSelected(self._type) - end, - func = CBs_List_Select_All_Collectible, - type = "select_all_collectible" - } - ) - table.insert(self.masterList, {type = "divider"}) - - if self._type.OrderedCollection then - for _, collection in ipairs(self._type.OrderedCollection) do - if self._type.Saved.MenuShowDisabled and collection.Disabled or not collection.Disabled then - table.insert( - self.masterList, - { - cId = collection.Id, - name = "Show " .. collection.Name, - tooltipText = collection.Tooltip, - valueFunc = function() - return self._type.Saved.Selected[collection.Id] - end, - disabledFunc = function() - return collection.Disabled - end, - func = CBs_List_Select_Collectible, - type = "select_collectible" - } - ) - end - end - end - end -end - -function CBs_List:FilterScrollList() - local scrollData = ZO_ScrollList_GetDataList(self.list) - ZO_ClearNumericallyIndexedTable(scrollData) - - for i = 1, #self.masterList do - if self.masterList[i].type == "divider" then - scrollData[#scrollData + 1] = ZO_ScrollList_CreateDataEntry(2, self.masterList[i]) - else - scrollData[#scrollData + 1] = ZO_ScrollList_CreateDataEntry(1, self.masterList[i]) - end - end -end - -function CBs_List:SortScrollList() -end diff --git a/CBs_Menu.lua b/CBs_Menu.lua index 9a8ab58..3f5c5b0 100644 --- a/CBs_Menu.lua +++ b/CBs_Menu.lua @@ -2,7 +2,6 @@ Author: Jarth Filename: CBs_Menu.lua ]] -- - ------------------------------------------------------------------------------------------------- -- Libraries -- ------------------------------------------------------------------------------------------------- @@ -17,19 +16,16 @@ local base = CollectionBars -- FUNCTIONS -- ------------------------------------------------------------------------------------------------- function base.CreateSettingsWindow() - LAM2:RegisterAddonPanel( - base.Addon.Name, - { - _type = "panel", - name = base.Addon.DisplayName, - displayName = base.Addon.DisplayName, - author = base.Addon.Author, - version = base.GetVersion(true), - slashCommand = base.Addon.Command, - registerForRefresh = true, - registerForDefaults = true - } - ) + LAM2:RegisterAddonPanel(base.Addon.Name, { + _type = "panel", + name = base.Addon.DisplayName, + displayName = base.Addon.DisplayName, + author = base.Addon.Author, + version = base.GetVersion(true), + slashCommand = base.Addon.Command, + registerForRefresh = true, + registerForDefaults = true + }) local whenOnTheBar = "When ON the bar will show the bar " local disabledWhenTooltipIsHidden = "Disabled when tooltip is not shown" @@ -37,15 +33,7 @@ function base.CreateSettingsWindow() local disabledWhenCombined = "Disabled when Collection is included in combine bar" local optionsData = { - { - type = "header", - name = base.Addon.DisplayName .. " Settings" - }, - { - type = "description", - text = string.format("Here you can setup %s.\nCMD: %s", base.Addon.DisplayName, base.Addon.Command) - }, - { + {type = "header", name = base.Addon.DisplayName .. " Settings"}, {type = "description", text = string.format("Here you can setup %s.\nSlash command: %s\nCollection bars settings: %s", base.Addon.DisplayName, base.Addon.Command, base.Addon.SettingsSlash)}, { type = "checkbox", name = "Use account settings", tooltip = "When ON the account settings will be used. When OFF character settings will be used", @@ -59,8 +47,7 @@ function base.CreateSettingsWindow() base.SetAndUpdateAccountSettings(newValue) end, width = "half" - }, - { + }, { type = "button", name = "Toggle settings", tooltip = "When ON all enabled collection types will display a label\nOpen a settings panel for each collection type, and select what collectibles you want to enable.", @@ -68,17 +55,12 @@ function base.CreateSettingsWindow() base.ToggleEnableSettings() end, width = "half" - }, - { + }, { type = "submenu", name = "General settings", tooltip = "Setup some general settings", controls = { - { - type = "description", - text = "Here you can setup position and size" - }, - { + {type = "description", text = "Here you can setup position and size"}, { type = "checkbox", name = "Unlock movement of bar", tooltip = "When ON the bar will show the X,Y position of the top left corner, and is draggable", @@ -92,8 +74,7 @@ function base.CreateSettingsWindow() base.Global.IsMoveEnabled = newValue base.RestoreFrames() end - }, - { + }, { type = "slider", name = "Choose snap size when moving", default = base.Default.SnapSize, @@ -106,8 +87,7 @@ function base.CreateSettingsWindow() end, min = 1, max = 10 - }, - { + }, { type = "slider", name = "Choose default bar depth (number of rows/columns)", default = base.Default.BarDepth, @@ -120,8 +100,7 @@ function base.CreateSettingsWindow() end, min = 1, max = base.Global.HighestUnlocked - }, - { + }, { type = "slider", name = "Choose max bar height (number of inverse rows/columns)", default = base.Default.BarWidth, @@ -134,8 +113,7 @@ function base.CreateSettingsWindow() end, min = 0, max = base.Global.HighestUnlocked - }, - { + }, { type = "checkbox", name = "Show binding's on bar", tooltip = "When ON the binding's will be shown on the bar", @@ -148,8 +126,7 @@ function base.CreateSettingsWindow() base.RestoreFrames() end, width = "half" - }, - { + }, { type = "slider", name = "Button size", default = ZO_GAMEPAD_ACTION_BUTTON_SIZE, @@ -163,39 +140,7 @@ function base.CreateSettingsWindow() min = 1, max = 100, width = "half" - }, - { - type = "divider", - width = "full" - }, - { - type = "description", - text = "Here you can setup the audio" - }, - { - type = "checkbox", - name = "Play hover audio", - tooltip = "When ON hover events on the bar, will play audio", - default = function() - return base.Saved.IsAudioEnabled - end, - getFunc = function() - return base.Saved.IsAudioEnabled - end, - setFunc = function(newValue) - base.Saved.IsAudioEnabled = newValue - base.RestoreFrames() - end - }, - { - type = "divider", - width = "full" - }, - { - type = "description", - text = "Here you can setup what views/scenes the bars are visible in" - }, - { + }, {type = "divider", width = "full"}, {type = "description", text = "Here you can setup what views/scenes the bars are visible in"}, { type = "checkbox", name = "Show bar " .. "on main view/hud", tooltip = whenOnTheBar .. "on main view/hud", @@ -207,8 +152,7 @@ function base.CreateSettingsWindow() base.Saved.ShowBarOnHud = newValue base.UpdateFragments("ShowBarOnHud") end - }, - { + }, { type = "checkbox", name = "Show bar " .. "on the main view when an overlay is activated/hudui", tooltip = whenOnTheBar .. "on the main view when an overlay is activated/hudui", @@ -220,8 +164,7 @@ function base.CreateSettingsWindow() base.Saved.ShowBarOnHudUI = newValue base.UpdateFragments("ShowBarOnHudUI") end - }, - { + }, { type = "checkbox", name = "Show bar " .. "in menu", tooltip = whenOnTheBar .. "in menu", @@ -233,8 +176,7 @@ function base.CreateSettingsWindow() base.Saved.ShowBarInMenu = newValue base.UpdateFragments("ShowBarInMenu") end - }, - { + }, { type = "checkbox", name = "Show bar " .. "in the inventory", tooltip = whenOnTheBar .. "in the inventory", @@ -246,8 +188,7 @@ function base.CreateSettingsWindow() base.Saved.ShowBarInInventory = newValue base.UpdateFragments("ShowBarInInventory") end - }, - { + }, { type = "checkbox", name = "Show bar " .. "in interactions", tooltip = whenOnTheBar .. "in interactions", @@ -259,8 +200,7 @@ function base.CreateSettingsWindow() base.Saved.ShowBarInInteract = newValue base.UpdateFragments("ShowBarInInteract") end - }, - { + }, { type = "checkbox", name = "Show bar " .. "at a bank", tooltip = whenOnTheBar .. "at a bank", @@ -272,8 +212,7 @@ function base.CreateSettingsWindow() base.Saved.ShowBarInBank = newValue base.UpdateFragments("ShowBarInBank") end - }, - { + }, { type = "checkbox", name = "Show bar " .. "at a fence", tooltip = whenOnTheBar .. "at a fence", @@ -285,8 +224,7 @@ function base.CreateSettingsWindow() base.Saved.ShowBarInFence = newValue base.UpdateFragments("ShowBarInFence") end - }, - { + }, { type = "checkbox", name = "Show bar " .. "at a store", tooltip = whenOnTheBar .. "at a store", @@ -298,16 +236,7 @@ function base.CreateSettingsWindow() base.Saved.ShowBarInStore = newValue base.UpdateFragments("ShowBarInStore") end - }, - { - type = "divider", - width = "full" - }, - { - type = "description", - text = "Here you can setup the active and activation indication" - }, - { + }, {type = "divider", width = "full"}, {type = "description", text = "Here you can setup the active and activation indication"}, { type = "checkbox", name = "Show active and activation", tooltip = "When ON the active collectibles will be highlighted, and activation animation will display", @@ -321,19 +250,28 @@ function base.CreateSettingsWindow() base.Saved.IsActiveActivationEnabled = newValue base.RestoreFrames() end + }, {type = "divider", width = "full"}, {type = "description", text = "Here you can setup the audio"}, { + type = "checkbox", + name = "Play hover audio", + tooltip = "When ON hover events on the bar, will play audio", + default = function() + return base.Saved.IsAudioEnabled + end, + getFunc = function() + return base.Saved.IsAudioEnabled + end, + setFunc = function(newValue) + base.Saved.IsAudioEnabled = newValue + base.RestoreFrames() + end } } - }, - { + }, { type = "submenu", name = "Combined bar", tooltip = "Setup the combined bar", controls = { - { - type = "description", - text = "Here you can setup the display name and labels" - }, - { + {type = "description", text = "Here you can setup the display name and labels"}, { type = "slider", name = "Display name offset horizontal (X)", default = base.Default.Combine.Label.OffsetX, @@ -347,8 +285,7 @@ function base.CreateSettingsWindow() min = -500, max = 500, width = "half" - }, - { + }, { type = "slider", name = "Display name offset vertical (Y)", default = base.Default.Combine.Label.OffsetY, @@ -362,8 +299,7 @@ function base.CreateSettingsWindow() min = -500, max = 500, width = "half" - }, - { + }, { type = "dropdown", name = "Display name anchor position on button", tooltip = "Select display name anchor position on the button", @@ -378,8 +314,7 @@ function base.CreateSettingsWindow() base.RestoreCombineLabels() end, width = "half" - }, - { + }, { type = "dropdown", name = "Display name anchor position on label", tooltip = "Select display name anchor position on the label", @@ -393,8 +328,7 @@ function base.CreateSettingsWindow() base.RestoreCombineLabels() end, width = "half" - }, - { + }, { type = "dropdown", name = "Bar anchor location", tooltip = "Select Bar anchor location, used when bar is collapsed", @@ -408,16 +342,7 @@ function base.CreateSettingsWindow() base.RestoreCombineLabels() end, width = "half" - }, - { - type = "divider", - width = "full" - }, - { - type = "description", - text = "Here you can setup position and size" - }, - { + }, {type = "divider", width = "full"}, {type = "description", text = "Here you can setup position and size"}, { type = "slider", name = "Choose default bar depth (number of rows/columns)", default = base.Default.BarDepth, @@ -430,8 +355,7 @@ function base.CreateSettingsWindow() end, min = 0, max = base.Global.HighestUnlocked - }, - { + }, { type = "slider", name = "Choose max bar height (number of inverse rows/columns)", default = base.Default.BarWidth, @@ -446,45 +370,36 @@ function base.CreateSettingsWindow() max = base.Global.HighestUnlocked } } - }, - { + }, { type = "submenu", name = "Collection types", tooltip = "Select what collection types you want enabled", - controls = { - { - type = "description", - text = "The selected collection types will be displayed when ON\nReload to see effect in menu" - } - } + controls = {{type = "description", text = "The selected collection types will be displayed when ON\nReload to see effect in menu"}} } } local function AppendCollectionType(controlIndex, _type) - table.insert( - optionsData[controlIndex].controls, - { - type = "checkbox", - name = string.format("Show %s", _type.Name), - tooltip = "When ON the menu item " .. _type.Name .. " will be available for selection", - default = base.Default[_type.Name].Enabled, - getFunc = function() - return _type.Saved.Enabled - end, - setFunc = function(newValue) - _type.Saved.Enabled = newValue - if newValue then - base.InitializeType(_type) - else - base.RemoveLabel(_type) - base.RemoveFrame(_type) - end - if _type.Saved.Combine then - base.RestoreCombineLabels() - end + table.insert(optionsData[controlIndex].controls, { + type = "checkbox", + name = string.format("Show %s", _type.Name), + tooltip = "When ON the menu item " .. _type.Name .. " will be available for selection", + default = base.Default[_type.Name].Enabled, + getFunc = function() + return _type.Saved.Enabled + end, + setFunc = function(newValue) + _type.Saved.Enabled = newValue + if newValue then + base.InitializeType(_type) + else + base.RemoveLabel(_type) + base.RemoveFrame(_type) end - } - ) + if _type.Saved.IsCombined then + base.RestoreCombineLabels() + end + end + }) end local function AppendCollectionMenuItem(controlIndex, _type) @@ -496,23 +411,14 @@ function base.CreateSettingsWindow() tooltip = "When ON " .. typeName .. " will be attached to a combined bar", default = base.Default[typeName].Combine, getFunc = function() - return _type.Saved.Combine + return _type.Saved.IsCombined end, setFunc = function(newValue) - _type.Saved.Combine = newValue + _type.Saved.IsCombined = newValue base.RestoreFrame(_type) base.RestoreCombineLabels() end - }, - { - type = "divider", - width = "full" - }, - { - type = "description", - text = "Here you can setup tooltips" - }, - { + }, {type = "divider", width = "full"}, {type = "description", text = "Here you can setup tooltips"}, { type = "checkbox", name = "Show tooltip", tooltip = "When ON tooltips will be shown, when hovering buttons on the bar", @@ -525,8 +431,7 @@ function base.CreateSettingsWindow() base.SetupButtons(_type) end, width = "half" - }, - { + }, { type = "dropdown", name = "Show tooltip anchor position", tooltip = "Select tooltip anchor position\n" .. disabledWhenTooltipIsHidden, @@ -543,25 +448,16 @@ function base.CreateSettingsWindow() base.SetupButtons(_type) end, width = "half" - }, - { - type = "divider", - width = "full" - }, - { - type = "description", - text = "Here you can setup the name and labels" - }, - { + }, {type = "divider", width = "full"}, {type = "description", text = "Here you can setup the name and labels"}, { type = "checkbox", name = "Enable hide/toggle visibility of the label", tooltip = "When enabled a +/- at the end of the label indicates if the label is hidden or shown\n" .. disabledWhenCombined, disabled = function() - return _type.Saved.Combine + return _type.Saved.IsCombined end, default = base.Default[typeName].HideAllEnabled, getFunc = function() - return _type.Saved.Combine or _type.Saved.HideAllEnabled + return _type.Saved.IsCombined or _type.Saved.HideAllEnabled end, setFunc = function(newValue) if (not newValue) then @@ -574,17 +470,16 @@ function base.CreateSettingsWindow() base.RestoreLabel(_type) end, width = "half" - }, - { + }, { type = "checkbox", name = "Show label", tooltip = disabledWhenCombined .. " or hide/toggle visibility is enabled", disabled = function() - return _type.Saved.HideAllEnabled or _type.Saved.Combine + return _type.Saved.HideAllEnabled or _type.Saved.IsCombined end, default = base.Default[typeName].LabelShow, getFunc = function() - return _type.Saved.LabelShow or _type.Saved.Combine + return _type.Saved.LabelShow or _type.Saved.IsCombined end, setFunc = function(newValue) _type.Saved.LabelShow = newValue @@ -592,8 +487,7 @@ function base.CreateSettingsWindow() base.RestoreLabel(_type) end, width = "half" - }, - { + }, { type = "editbox", name = "Display name", tooltip = disabledWhenLabelIsHidden, @@ -602,7 +496,7 @@ function base.CreateSettingsWindow() end, default = base.Default[typeName].Display, getFunc = function() - return _type.Saved.Display + return tostring(_type.Saved.Display) end, setFunc = function(value) _type.Saved.Display = value @@ -610,8 +504,7 @@ function base.CreateSettingsWindow() base.RestoreCombineLabels() end, width = "half" - }, - { + }, { type = "dropdown", name = "Display name font", tooltip = disabledWhenLabelIsHidden, @@ -629,8 +522,7 @@ function base.CreateSettingsWindow() base.RestoreCombineLabels() end, width = "half" - }, - { + }, { type = "slider", name = "Display name height", tooltip = disabledWhenLabelIsHidden, @@ -649,8 +541,7 @@ function base.CreateSettingsWindow() min = 0, max = 500, width = "half" - }, - { + }, { type = "slider", name = "Display name width", tooltip = disabledWhenLabelIsHidden, @@ -669,8 +560,7 @@ function base.CreateSettingsWindow() min = 0, max = 500, width = "half" - }, - { + }, { type = "slider", name = "Display name offset horizontal (X)", tooltip = disabledWhenLabelIsHidden, @@ -689,8 +579,7 @@ function base.CreateSettingsWindow() min = -500, max = 500, width = "half" - }, - { + }, { type = "slider", name = "Display name offset vertical (Y)", tooltip = disabledWhenLabelIsHidden, @@ -709,18 +598,17 @@ function base.CreateSettingsWindow() min = -500, max = 500, width = "half" - }, - { + }, { type = "dropdown", name = "Display name anchor position on button", tooltip = "Select display name anchor position on the button\n" .. disabledWhenLabelIsHidden .. "\n or Collection is included in combine bar", disabled = function() - return not _type.Saved.LabelShow or _type.Saved.Combine + return not _type.Saved.LabelShow or _type.Saved.IsCombined end, choices = base.Global.ChoiceLocations, default = base.Default.BindingLocation, getFunc = function() - if _type.Saved.Combine then + if _type.Saved.IsCombined then return base.GetLocationText(base.Saved.Combine.Label.PositionTarget) else return base.GetLocationText(_type.Saved.Label.PositionTarget) @@ -733,18 +621,17 @@ function base.CreateSettingsWindow() base.RestoreCombineLabels() end, width = "half" - }, - { + }, { type = "dropdown", name = "Display name anchor position on label", tooltip = "Select display name anchor position on the label\n" .. disabledWhenLabelIsHidden .. "\n or Collection is included in combine bar", disabled = function() - return not _type.Saved.LabelShow or _type.Saved.Combine + return not _type.Saved.LabelShow or _type.Saved.IsCombined end, choices = base.Global.ChoiceLocations, default = base.Default.BindingLocation, getFunc = function() - if _type.Saved.Combine then + if _type.Saved.IsCombined then return base.GetLocationText(base.Saved.Combine.Label.Position) else return base.GetLocationText(_type.Saved.Label.Position) @@ -756,18 +643,17 @@ function base.CreateSettingsWindow() base.RestoreCombineLabels() end, width = "half" - }, - { + }, { type = "dropdown", name = "Bar anchor location", tooltip = "Select Bar anchor location, used when bar is collapsed\n" .. disabledWhenCombined, choices = base.Global.ChoiceCornerLocations, default = base.Default[typeName].AnchorXY, disabled = function() - return _type.Saved.Combine + return _type.Saved.IsCombined end, getFunc = function() - if _type.Saved.Combine then + if _type.Saved.IsCombined then return base.GetLocationText(base.Saved.Combine.AnchorXY) else return base.GetLocationText(_type.Saved.AnchorXY) @@ -779,22 +665,13 @@ function base.CreateSettingsWindow() base.RestoreCombineLabels() end, width = "half" - }, - { - type = "divider", - width = "full" - }, - { - type = "description", - text = "Here you can setup the position and size" - }, - { + }, {type = "divider", width = "full"}, {type = "description", text = "Here you can setup the position and size"}, { type = "slider", name = "Choose bar depth (number of rows/columns)", default = base.Default[typeName].BarDepth, tooltip = disabledWhenCombined, disabled = function() - return _type.Saved.Combine + return _type.Saved.IsCombined end, getFunc = function() return _type.Saved.BarDepth @@ -806,14 +683,13 @@ function base.CreateSettingsWindow() end, min = 0, max = _type.Unlocked - }, - { + }, { type = "slider", name = "Choose max bar height (number of inverse rows/columns)", default = base.Default[typeName].BarWidth, tooltip = disabledWhenCombined, disabled = function() - return _type.Saved.Combine + return _type.Saved.IsCombined end, getFunc = function() return _type.Saved.BarWidth @@ -825,14 +701,13 @@ function base.CreateSettingsWindow() end, min = 0, max = _type.Unlocked - }, - { + }, { type = "checkbox", name = "Bar orientation horizontal", default = base.Default[typeName].Horizontal, tooltip = disabledWhenCombined, disabled = function() - return _type.Saved.Combine + return _type.Saved.IsCombined end, getFunc = function() return _type.Saved.Horizontal @@ -844,19 +719,15 @@ function base.CreateSettingsWindow() end } } - table.insert( - optionsData, - controlIndex, - { - type = "submenu", - name = string.format("Setup %s", typeName), - tooltip = 'Choose what collection\'s you want on the bar\nDisabled when collection is disabled in "Collection Types"', - disabled = function() - return not _type.Saved.Enabled - end, - controls = controls - } - ) + table.insert(optionsData, controlIndex, { + type = "submenu", + name = string.format("Setup %s", typeName), + tooltip = 'Choose what collection\'s you want on the bar\nDisabled when collection is disabled in "Collection Types"', + disabled = function() + return not _type.Saved.Enabled + end, + controls = controls + }) end local indexShowCollection = 7 diff --git a/CBs_MoveFrame.lua b/CBs_MoveFrame.lua index 3125ef4..682d7a6 100644 --- a/CBs_MoveFrame.lua +++ b/CBs_MoveFrame.lua @@ -2,7 +2,6 @@ Author: Jarth Filename: CBs_MoveFrame.lua ]] -- - ------------------------------------------------------------------------------------------------- -- VARIABLES -- ------------------------------------------------------------------------------------------------- @@ -31,7 +30,7 @@ function base.UpdateMoveFrame(_type) local targetFrame = _type.Frame local onMouseEnter, onMouseExit, onMouseDown, onMouseUp = nil, nil, nil, nil - if base.Global.IsMoveEnabled and (_type.Name == "Combine" or not _type.IsEmpty and not _type.Saved.Combine) then + if base.Global.IsMoveEnabled and (_type.Name == "Combine" or not _type.IsEmpty and not _type.Saved.IsCombined) then moveFrame = base.GetOrCreateMoveFrame(targetFrame, _type) onMouseEnter = function(frame) @@ -73,7 +72,7 @@ function base.GetOrCreateMoveFrame(targetFrame, _type) if _type.MoveFrame == nil then local newMoveFrame = base.WM:CreateControlFromVirtual(nil, GuiRoot, base.Addon.Abbreviation .. "_MoveFrame") - --Variable is used to define what savedVariable the Frame refers to. + -- Variable is used to define what savedVariable the Frame refers to. newMoveFrame.TargetFrame = targetFrame newMoveFrame.Saved = base.Saved newMoveFrame.Type = _type diff --git a/CBs_Settings.lua b/CBs_Settings.lua index 403ca83..a99cd23 100644 --- a/CBs_Settings.lua +++ b/CBs_Settings.lua @@ -2,7 +2,6 @@ Author: Jarth Filename: CBs_Settings.lua ]] -- - ------------------------------------------------------------------------------------------------- -- VARIABLES -- ------------------------------------------------------------------------------------------------- @@ -12,8 +11,8 @@ local base = CollectionBars -- FUNCTIONS -- ------------------------------------------------------------------------------------------------- function base.InitializeSettingsSlash() - SLASH_COMMANDS[base.Global.SettingsSlash] = function() - base.ToggleEnableSettings() + SLASH_COMMANDS[base.Addon.SettingsSlash] = function() + base.ShowSettings() end end @@ -54,18 +53,12 @@ end function base.SetupSettingsFrameHandlers(control, text, onClicked) control.tooltipText = text control:SetHandler("OnClicked", onClicked) - control:SetHandler( - "OnMouseEnter", - function(_control) - ZO_Tooltips_ShowTextTooltip(_control, BOTTOM, _control.tooltipText) - end - ) - control:SetHandler( - "OnMouseExit", - function() - ZO_Tooltips_HideTextTooltip() - end - ) + control:SetHandler("OnMouseEnter", function(_control) + ZO_Tooltips_ShowTextTooltip(_control, BOTTOM, _control.tooltipText) + end) + control:SetHandler("OnMouseExit", function() + ZO_Tooltips_HideTextTooltip() + end) end function base.SetupSetttingsFrame(_type) @@ -73,60 +66,68 @@ function base.SetupSetttingsFrame(_type) base.Global.SettingsFrame = base.WM:CreateControlFromVirtual(selector, GuiRoot, selector) base.Global.SettingsLabel = GetControl(selector .. "Label") - base.Global.SettingsList = CBs_List:New(base, _type, base.Global.SettingsFrame) + base.Global.SettingsList = CBs_Settings_List:New(base, _type, base.Global.SettingsFrame) local titleControl = GetControl(selector .. "Title") titleControl:SetText(base.Addon.DisplayName .. " Settings") local closeFrame = GetControl(base.Global.SettingsFrame, "Close") if closeFrame then - base.SetupSettingsFrameHandlers( - closeFrame, - "Close", - function(buttonControl) - local control = buttonControl:GetParent() - control:SetHidden(true) - end - ) + base.SetupSettingsFrameHandlers(closeFrame, "Close", function(buttonControl) + buttonControl:GetParent():SetHidden(true) + end) end local moveFrame = GetControl(base.Global.SettingsFrame, "Move") if moveFrame then - base.SetupSettingsFrameHandlers( - moveFrame, - "Toggle move frame", - function() - base.Global.IsMoveEnabled = not base.Global.IsMoveEnabled - base.RestoreFrames() - end - ) + base.SetupSettingsFrameHandlers(moveFrame, "Toggle move frame", function() + base.Global.IsMoveEnabled = not base.Global.IsMoveEnabled + base.Global.SettingsList:RefreshData() + base.RestoreFrames() + end) end local refreshFrame = GetControl(base.Global.SettingsFrame, "Refresh") if refreshFrame then - base.SetupSettingsFrameHandlers( - refreshFrame, - "Reload collection list", - function() - base.CreateCollection(_type) - base.RestoreFrame(_type) - base.RestoreCombineLabels() - base.Global.SettingsList:RefreshData() - end - ) + base.SetupSettingsFrameHandlers(refreshFrame, "Reload collection list", function() + base.CreateCollection(_type) + base.RestoreFrame(_type) + base.RestoreCombineLabels() + base.Global.SettingsList:RefreshData() + end) + end + + for controlName, displayName in pairs(base.Global.SettingsFilters) do + base.SetupSettingsFilter(base.Global.SettingsFrame, controlName, displayName) + end +end + +function base.SetupSettingsFilter(control, controlName, displayName) + local filterControl = GetControl(control, controlName) + if filterControl then + base.SetControlText(filterControl, displayName) + filterControl:SetHandler("OnClicked", function() + base.Global.SettingsList.masterListType = controlName + base.Global.SettingsList:RefreshFilters() + end) end end function base.ShowSettings(_type) - local show = false - if base.Global.SettingsFrame == nil then + local show = base.Global.SettingsFrame == nil + if show then base.SetupSetttingsFrame(_type) - show = true end show = show or base.Global.SettingsFrame:IsHidden() or _type ~= base.Global.SettingsList._type base.Global.SettingsFrame:SetHidden(not show) + base.UpdateSettingsType(show, _type) if show then - base.Global.SettingsLabel:SetText(show and _type.Name or "") base.Global.SettingsList._type = show and _type or nil base.Global.SettingsList:RefreshData() end end + +function base.UpdateSettingsType(show, _type) + if base.Global.SettingsLabel ~= nil then + base.Global.SettingsLabel:SetText(show and _type and _type.Name or "Global") + end +end diff --git a/CBs_Settings.xml b/CBs_Settings.xml new file mode 100644 index 0000000..e670c0b --- /dev/null +++ b/CBs_Settings.xml @@ -0,0 +1,212 @@ +<GuiXml> + <Controls> + <TopLevelControl name="CBs_Settings" clampedToScreen="true" movable="true" mouseEnabled="true" virtual="true"> + <Anchor point="CENTER" relativePoint="CENTER"/> + <Dimensions x="544" y="944" /> + <DimensionConstraints minX="544" minY="944" /> + <Controls> + <Backdrop name="$(parent)Bg" integralWrapping="true"> + <Anchor point="TOPLEFT" offsetX="-8" offsetY="-6"/> + <Anchor point="BOTTOMRIGHT" offsetX="4" offsetY="4"/> + + <Edge file="EsoUI/Art/ChatWindow/chat_BG_edge.dds" edgeFileWidth="256" edgeFileHeight="256" edgeSize="32"/> + <Center file="EsoUI/Art/ChatWindow/chat_BG_center.dds" /> + <Insets left="32" top="32" right="-32" bottom="-32" /> + </Backdrop> + <Label name="$(parent)Title" font="ZoFontWinH1" modifyTextType="UPPERCASE"> + <Anchor point="TOPLEFT" offsetX="22" offsetY="22" /> + </Label> + + <Texture name="$(parent)Divider" inherits="ZO_Options_Divider"> + <Anchor point="TOPLEFT" relativeTo="$(parent)Title" relativePoint="BOTTOMLEFT" offsetY="2"/> + </Texture> + + <Label name="$(parent)Label" inherits="ZO_Options_SectionTitleLabel"> + <Anchor point="TOPLEFT" relativeTo="$(parent)Divider" relativePoint="TOPLEFT" offsetY="5"/> + </Label> + + <Button name="$(parent)General" inherits="ZO_DefaultButton" clickSound="Click" relativeTo="$(parent)"> + <Anchor point="TOPLEFT" relativeTo="$(parent)Label" relativePoint="BOTTOMLEFT" offsetY="15"/> + <Dimensions x="120" y="22" /> + </Button> + <Button name="$(parent)CollectionTypes" inherits="ZO_DefaultButton" clickSound="Click" relativeTo="$(parent)"> + <Anchor point="TOPLEFT" relativeTo="$(parent)General" relativePoint="TOPRIGHT" /> + <Dimensions x="120" y="22" /> + </Button> + <Button name="$(parent)Selection" inherits="ZO_DefaultButton" clickSound="Click" relativeTo="$(parent)"> + <Anchor point="TOPLEFT" relativeTo="$(parent)CollectionTypes" relativePoint="TOPRIGHT" /> + <Dimensions x="120" y="22" /> + </Button> + <Button name="$(parent)Collection" inherits="ZO_DefaultButton" clickSound="Click" relativeTo="$(parent)"> + <Anchor point="TOPLEFT" relativeTo="$(parent)Selection" relativePoint="TOPRIGHT" /> + <Dimensions x="120" y="22" /> + </Button> + <Button name="$(parent)Combined" inherits="ZO_DefaultButton" clickSound="Click" relativeTo="$(parent)"> + <Anchor point="BOTTOMLEFT" relativeTo="$(parent)Collection" relativePoint="TOPLEFT" offsetY="-5" /> + <Dimensions x="120" y="22" /> + </Button> + + <Control name="$(parent)List" inherits="ZO_ScrollList"> + <Anchor point="TOPLEFT" relativeTo="$(parent)General" relativePoint="BOTTOMLEFT" offsetY="22"/> + <Anchor point="BOTTOMRIGHT" offsetX="-22" offsetY="-22" /> + </Control> + + <Button name="$(parent)Close" clickSound="Click" relativeTo="$(parent)"> + <Anchor point="TOPRIGHT" relativeTo="$(parent)" relativePoint="TOPRIGHT" offsetX="-10" offsetY="10" /> + <Dimensions x="22" y="22" /> + <Textures name="$(parent)Textures" normal="/EsoUI/Art/Buttons/decline_up.dds" mouseOver="/EsoUI/Art/Buttons/decline_over.dds" pressed="/EsoUI/Art/Buttons/decline_down.dds" /> + </Button> + <Button name="$(parent)Refresh" clickSound="Click" relativeTo="$(parent)"> + <Anchor point="TOPRIGHT" relativeTo="$(parent)Close" relativePoint="TOPRIGHT" offsetX="-32" /> + <Dimensions x="22" y="22" /> + <Textures name="$(parent)Textures" normal="/EsoUI/Art/Buttons/edit_save_up.dds" mouseOver="/EsoUI/Art/Buttons/edit_save_over.dds" pressed="/EsoUI/Art/Buttons/edit_save_down.dds" /> + </Button> + <Button name="$(parent)Move" clickSound="Click" relativeTo="$(parent)"> + <Anchor point="TOPRIGHT" relativeTo="$(parent)Refresh" relativePoint="TOPRIGHT" offsetX="-32" /> + <Dimensions x="22" y="22" /> + <Textures name="$(parent)Textures" normal="/EsoUI/Art/Buttons/edit_up.dds" mouseOver="/EsoUI/Art/Buttons/edit_over.dds" pressed="/EsoUI/Art/Buttons/edit_down.dds" /> + </Button> + </Controls> + </TopLevelControl> + + <!-- Inspiration: ZO_Options_Checkbox --> + <Control name="CBs_Settings_ListRow_Checkbox" mouseEnabled="true" virtual="true"> + <Dimensions x="510" y="26" /> + <Controls> + <Button name="$(parent)Checkbox" inherits="ZO_CheckButton_Text" horizontalAlignment="LEFT" font="ZoFontWinH4" modifyTextType="UPPERCASE"> + <Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetX="425" /> + <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)" relativePoint="BOTTOMRIGHT" /> + </Button> + </Controls> + </Control> + + <!-- Inspiration: ZO_Options_Checkbox --> + <Control name="CBs_Settings_ListRow_Checkbox_CogButton" inherits="CBs_Settings_ListRow_Checkbox" mouseEnabled="true" virtual="true"> + <Controls> + <Button name="$(parent)CogButton" relativeTo="$(parent)"> + <Anchor point="TOPLEFT" relativeTo="$(parent)Checkbox" relativePoint="TOPLEFT" offsetX="33" /> + <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)Checkbox" /> + <Textures name="$(parent)Textures" normal="/EsoUI/Art/Chatwindow/chat_options_up.dds" pressed="/EsoUI/Art/Chatwindow/chat_options_down.dds" mouseOver="/EsoUI/Art/Chatwindow/chat_options_over.dds" /> + </Button> + </Controls> + </Control> + + <!-- Inspiration: ZO_ScrollableComboBox --> + <Control name="CBs_Settings_ListRow_Dropdown" mouseEnabled="true" virtual="true"> + <Dimensions x="510" y="26" /> + <OnMouseEnter> + ZO_Options_OnMouseEnter(self) + </OnMouseEnter> + <OnMouseExit> + ZO_Options_OnMouseExit(self) + </OnMouseExit> + + <Controls> + <Control name="$(parent)Dropdown" inherits="ZO_ComboBox"> + <Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetX="293" /> + <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)" relativePoint="BOTTOMRIGHT" /> + <OnMouseEnter> + ZO_Options_OnMouseEnter(self:GetParent()) + </OnMouseEnter> + <OnMouseExit> + ZO_Options_OnMouseExit(self:GetParent()) + </OnMouseExit> + </Control> + + <Label name="$(parent)Name" font="ZoFontWinH4" wrapMode="ELLIPSIS"> + <Anchor point="LEFT" /> + <Anchor point="RIGHT" relativeTo="$(parent)Dropdown" relativePoint="LEFT" /> + </Label> + </Controls> + </Control> + + <!-- Inspiration: ZO_Options_Slider --> + <Control name="CBs_Settings_ListRow_Slider" mouseEnabled="true" virtual="true"> + <Dimensions x="510" y="26" /> + <OnMouseEnter> + ZO_Options_OnMouseEnter(self) + </OnMouseEnter> + <OnMouseExit> + ZO_Options_OnMouseExit(self) + </OnMouseExit> + <OnShow> + ZO_Options_OnShow(self) + </OnShow> + + <Controls> + <Slider name="$(parent)Slider" inherits="ZO_Slider"> + <Dimensions x="150" y="16" /> + <Anchor point="RIGHT" offsetX="-40" /> + <OnMouseEnter> + ZO_Options_OnMouseEnter(self:GetParent()) + </OnMouseEnter> + <OnMouseExit> + ZO_Options_OnMouseExit(self:GetParent()) + </OnMouseExit> + </Slider> + + <Label name="$(parent)Name" font="ZoFontWinH4" wrapMode="ELLIPSIS" horizontalAlignment="LEFT" verticalAlignment="CENTER"> + <Dimensions y="26" /> + <Anchor point="LEFT" /> + <Anchor point="RIGHT" relativeTo="$(parent)Slider" relativePoint="LEFT" /> + </Label> + + <Label name="$(parent)ValueLabel" font="ZoFontWinH4" wrapMode="ELLIPSIS" verticalAlignment="CENTER" excludeFromResizeToFitExtents="true"> + <Dimensions x="75" y="26" /> + <Anchor point="LEFT" relativeTo="$(parent)Slider" relativePoint="RIGHT" offsetX="10" /> + </Label> + </Controls> + </Control> + + <Control name="CBs_Settings_ListRow_Label" mouseEnabled="true" virtual="true"> + <Dimensions x="510" y="26" /> + <OnMouseEnter> + ZO_Options_OnMouseEnter(self) + </OnMouseEnter> + <OnMouseExit> + ZO_Options_OnMouseExit(self) + </OnMouseExit> + + <Controls> + <Label name="$(parent)Name" font="ZoFontWinH4" wrapMode="ELLIPSIS" horizontalAlignment="LEFT" verticalAlignment="CENTER"> + <Dimensions y="26" /> + <Anchor point="LEFT" /> + <Anchor point="RIGHT" relativeTo="$(parent)LowLabel" relativePoint="LEFT" /> + </Label> + </Controls> + </Control> + + <!-- Inspiration: ZO_EditDefaultText --> + <Control name="CBs_Settings_ListRow_EditBox" inherits="CBs_Settings_ListRow_Label" mouseEnabled="true" virtual="true"> + <Controls> + <EditBox name="$(parent)EditBox" inherits="ZO_DefaultEditForBackdrop ZO_EditDefaultText"> + <Dimensions x="150" y="26" /> + <Anchor point="RIGHT" offsetX="-40" /> + </EditBox> + </Controls> + </Control> + + <Control name="CBs_Settings_ListRow_Title" mouseEnabled="true" virtual="true"> + <Dimensions x="510" y="26" /> + <Controls> + <Label name="$(parent)Name" font="ZoFontWinH1" modifyTextType="UPPERCASE"> + <Anchor point="TOPLEFT" /> + </Label> + </Controls> + </Control> + + <!-- Inspiration: ZO_EditDefaultText --> + <Control name="CBs_Settings_ListRow_Button" inherits="CBs_Settings_ListRow_Label" mouseEnabled="true" virtual="true"> + <Controls> + <Button name="$(parent)Button" inherits="ZO_DefaultButton" clickSound="Click" relativeTo="$(parent)"> + <Anchor point="RIGHT" offsetX="-40" /> + <Dimensions x="150" y="26" /> + </Button> + </Controls> + </Control> + + <Texture name="CBs_Settings_ListRow_Divider" inherits="ZO_Options_Divider" virtual="true"> + <Dimensions x="512" y="2" /> + </Texture> + </Controls> +</GuiXml> \ No newline at end of file diff --git a/CBs_Settings_Data.lua b/CBs_Settings_Data.lua new file mode 100644 index 0000000..5392dc7 --- /dev/null +++ b/CBs_Settings_Data.lua @@ -0,0 +1,866 @@ +--[[ +Author: Jarth +Filename: CBs_Settings_Data.lua +]] -- +------------------------------------------------------------------------------------------------- +-- VARIABLES -- +------------------------------------------------------------------------------------------------- +local base = CollectionBars + +------------------------------------------------------------------------------------------------- +-- FUNCTIONS -- +------------------------------------------------------------------------------------------------- +function base.AppendMasterListTypeGeneral(self, typeSelection) + self:AppendRow_Checkbox(typeSelection, { + name = "Use account settings", + tooltip = "When ON the account settings will be used. When OFF character settings will be used", + funcGet = function() + return self.base.Saved.UseAccountSettings + end, + funcSet = function(_, newValue) + self.base.SetAndUpdateAccountSettings(newValue) + self.base.InitializeWithSavedData() + self.base.RestoreFrames() + self.base.RestoreCombineLabels() + self.base.Global.SettingsList:RefreshData() + end + }) + self:AppendRow_Checkbox(typeSelection, { + name = "Load LibAddonMenu", + tooltip = 'When ON the "Settings > Addons > Collection Bars" menu will be loaded\nRequires: LibAddonMenu-2.0\nReload after change with "/reloadui"\nDisclamer: Settings changed outside "LibAddonMenu" does not show as updated in the "LibAddonMenu"', + funcGet = function() + return LibAddonMenu2 and self.base.Saved.UseLAMMenu + end, + disabledFunc = function() + return not LibAddonMenu2 + end, + funcSet = function(_, newValue) + self.base.Saved.UseLAMMenu = LibAddonMenu2 and newValue + self.base.Global.SettingsList:RefreshData() + end + }) + self:AppendRow_Button(typeSelection, { + name = "Reset settings", + buttonName = "Reset", + funcSet = function() + self.base.ResetAccountSettings() + self.base.SetAndUpdateAccountSettings() + self.base.InitializeWithSavedData() + self.base.RestoreFrames() + self.base.RestoreCombineLabels() + self.base.Global.SettingsList:RefreshData() + end + }) + self:AppendRow_Title(typeSelection, {name = "Position and size"}) + self:AppendRow_Divider(typeSelection, {}) + self:AppendRow_Checkbox(typeSelection, { + name = "Unlock movement of bar", + tooltipText = "When ON the bar will show the X,Y position of the top left corner, and is draggable", + funcGet = function() + return self.base.Global.IsMoveEnabled + end, + funcSet = function(_, newValue) + self.base.Global.IsMoveEnabled = newValue + self.base.RestoreFrames() + end + }) + self:AppendRow_Slider(typeSelection, { + name = "Choose snap size when moving", + tooltipText = "Choose snap size when moving", + funcGet = function() + return self.base.Saved.SnapSize + end, + funcSet = function(sliderControl, newValue) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") + if valueLabel then + valueLabel:SetText(newValue) + end + self.base.Saved.SnapSize = newValue + self.base.RestoreFrames() + end, + minValue = 1, + maxValue = 10, + valueStep = 1, + default = self.base.Default.SnapSize, + valueFormat = "%.2f", + showValue = true + }) + self:AppendRow_Slider(typeSelection, { + name = "Choose max bar depth", + tooltipText = "Choose max bar depth\n(number of inverse rows/columns)", + funcGet = function() + return self.base.Saved.BarDepth + end, + funcSet = function(sliderControl, newValue) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") + if valueLabel then + valueLabel:SetText(newValue) + end + self.base.Saved.BarDepth = newValue + self.base.RestoreFrames() + end, + minValue = 0, + maxValue = base.Global.HighestUnlocked, + valueStep = 1, + default = self.base.Default.BarDepth, + valueFormat = "%.2f", + showValue = true + }) + self:AppendRow_Slider(typeSelection, { + name = "Choose max bar height", + tooltipText = "Choose max bar height\n(number of inverse rows/columns)", + funcGet = function() + return self.base.Saved.BarWidth + end, + funcSet = function(sliderControl, newValue) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") + if valueLabel then + valueLabel:SetText(newValue) + end + self.base.Saved.BarWidth = newValue + self.base.RestoreFrames() + end, + minValue = 0, + maxValue = base.Global.HighestUnlocked, + valueStep = 1, + default = self.base.Default.BarWidth, + valueFormat = "%.2f", + showValue = true + }) + self:AppendRow_Checkbox(typeSelection, { + name = "Show binding's on bar", + tooltipText = "When ON the binding's will be shown on the bar", + funcGet = function() + return self.base.Saved.ShowBinding + end, + funcSet = function(_, newValue) + self.base.Saved.ShowBinding = newValue + self.base.RestoreFrames() + end + }) + self:AppendRow_Slider(typeSelection, { + name = "Choose button size", + tooltipText = "Choose button size", + funcGet = function() + return self.base.Saved.ButtonXY + end, + funcSet = function(sliderControl, newValue) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") + if valueLabel then + valueLabel:SetText(newValue) + end + self.base.Saved.ButtonXY = newValue + self.base.RestoreFrames() + end, + minValue = 1, + maxValue = 100, + valueStep = 1, + default = ZO_GAMEPAD_ACTION_BUTTON_SIZE, + valueFormat = "%.2f", + showValue = true + }) + + local whenOnTheBar = "When ON the bar will show the bar " + self:AppendRow_Title(typeSelection, {name = "Visibility"}) + self:AppendRow_Divider(typeSelection, {}) + self:AppendRow_Checkbox(typeSelection, { + name = "Show bar on main view/hud", + tooltipText = string.format("%s on main view/hud", whenOnTheBar), + funcGet = function() + return self.base.Saved.ShowBarOnHud + end, + funcSet = function(_, newValue) + self.base.Saved.ShowBarOnHud = newValue + self.base.UpdateFragments("ShowBarOnHud") + end + }) + self:AppendRow_Checkbox(typeSelection, { + name = "Show bar on the main view when an overlay is activated/hudui", + tooltipText = string.format("%s on the main view when an overlay is activated/hudui", whenOnTheBar), + funcGet = function() + return self.base.Saved.ShowBarOnHudUI + end, + funcSet = function(_, newValue) + self.base.Saved.ShowBarOnHudUI = newValue + self.base.UpdateFragments("ShowBarOnHudUI") + end + }) + self:AppendRow_Checkbox(typeSelection, { + name = "Show bar in menu", + tooltipText = string.format("%s in menu", whenOnTheBar), + funcGet = function() + return self.base.Saved.ShowBarInMenu + end, + funcSet = function(_, newValue) + self.base.Saved.ShowBarInMenu = newValue + self.base.UpdateFragments("ShowBarInMenu") + end + }) + self:AppendRow_Checkbox(typeSelection, { + name = "Show bar in the inventory", + tooltipText = string.format("%s in the inventory", whenOnTheBar), + funcGet = function() + return self.base.Saved.ShowBarInInventory + end, + funcSet = function(_, newValue) + self.base.Saved.ShowBarInInventory = newValue + self.base.UpdateFragments("ShowBarInInventory") + end + }) + self:AppendRow_Checkbox(typeSelection, { + name = "Show bar in interactions", + tooltipText = string.format("%s in interactions", whenOnTheBar), + funcGet = function() + return self.base.Saved.ShowBarInInteract + end, + funcSet = function(_, newValue) + self.base.Saved.ShowBarInInteract = newValue + self.base.UpdateFragments("ShowBarInInteract") + end + }) + self:AppendRow_Checkbox(typeSelection, { + name = "Show bar at a bank", + tooltipText = string.format("%s at a bank", whenOnTheBar), + funcGet = function() + return self.base.Saved.ShowBarInBank + end, + funcSet = function(_, newValue) + self.base.Saved.ShowBarInBank = newValue + self.base.UpdateFragments("ShowBarInBank") + end + }) + self:AppendRow_Checkbox(typeSelection, { + name = "Show bar at a fence", + tooltipText = string.format("%s at a fence", whenOnTheBar), + funcGet = function() + return self.base.Saved.ShowBarInFence + end, + funcSet = function(_, newValue) + self.base.Saved.ShowBarInFence = newValue + self.base.UpdateFragments("ShowBarInFence") + end + }) + self:AppendRow_Checkbox(typeSelection, { + name = "Show bar at a store", + tooltipText = string.format("%s at a store", whenOnTheBar), + funcGet = function() + return self.base.Saved.ShowBarInStore + end, + funcSet = function(_, newValue) + self.base.Saved.ShowBarInStore = newValue + self.base.UpdateFragments("ShowBarInStore") + end + }) + + self:AppendRow_Title(typeSelection, {name = "Active and activation"}) + self:AppendRow_Divider(typeSelection, {}) + self:AppendRow_Checkbox(typeSelection, { + name = "Show active and activation", + tooltipText = "When ON the active collectibles will be highlighted, and activation animation will display", + funcGet = function() + return self.base.Saved.IsActiveActivationEnabled + end, + funcSet = function(_, newValue) + self.base.Saved.IsActiveActivationEnabled = newValue + self.base.RestoreFrames() + end + }) + + self:AppendRow_Title(typeSelection, {name = "Audio"}) + self:AppendRow_Divider(typeSelection, {}) + self:AppendRow_Checkbox(typeSelection, { + name = "Play hover audio", + tooltipText = "When ON hover events on the bar, will play audio", + funcGet = function() + return self.base.Saved.IsAudioEnabled + end, + funcSet = function(_, newValue) + self.base.Saved.IsAudioEnabled = newValue + self.base.RestoreFrames() + end + }) +end + +function base.AppendMasterListTypeCollectionTypes(self, typeSelection) + self:AppendRow_Title(typeSelection, {name = "Collection types"}) + self:AppendRow_Divider(typeSelection, {}) + + for _, _type in ipairs(self.base.TypeOrdered or {}) do + self:AppendRow_Checkbox_CogButton(typeSelection, { + cId = _type.Id, + name = string.format("Show %s", _type.Name), + tooltipText = string.format("When ON the collection type: %s will enabled\nSelect by pressing settings-symbol/cog", _type.Name), + funcGet = function() + return _type.Saved.Enabled + end, + disabledFunc = function() + return _type.Disabled + end, + funcSet = function(_, newValue) + _type.Saved.Enabled = newValue + if newValue then + self.base.InitializeType(_type) + else + self.base.RemoveLabel(_type) + self.base.RemoveFrame(_type) + if self._type == _type then + self._type = nil + self.base.UpdateSettingsType(true, self._type) + end + end + if _type.Saved.IsCombined then + self.base.RestoreCombineLabels() + end + self.base.Global.SettingsList:RefreshData() + end, + funcCog = function(_) + self._type = _type + self.base.UpdateSettingsType(true, self._type) + self.base.Global.SettingsList:RefreshData() + end + }) + end +end + +function base.AppendMasterListTypeCombined(self, typeSelection) + self:AppendRow_Title(typeSelection, {name = "Display names and labels"}) + self:AppendRow_Divider(typeSelection, {}) + self:AppendRow_Slider(typeSelection, { + name = "Display name offset horizontal", + tooltipText = "Display name offset horizontal\n(X)", + funcGet = function() + return self.base.Saved.Combine.Label.OffsetX + end, + funcSet = function(sliderControl, newValue) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") + if valueLabel then + valueLabel:SetText(newValue) + end + self.base.Saved.Combine.Label.OffsetX = newValue + self.base.RestoreCombineLabels() + end, + minValue = -500, + maxValue = 500, + valueStep = 1, + default = self.base.Default.Combine.Label.OffsetX, + valueFormat = "%.2f", + showValue = true + }) + self:AppendRow_Slider(typeSelection, { + name = "Display name offset vertical", + tooltipText = "Display name offset vertical\n(Y)", + funcGet = function() + return self.base.Saved.Combine.Label.OffsetY + end, + funcSet = function(sliderControl, newValue) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") + if valueLabel then + valueLabel:SetText(newValue) + end + self.base.Saved.Combine.Label.OffsetY = newValue + self.base.RestoreCombineLabels() + end, + minValue = -500, + maxValue = 500, + valueStep = 1, + default = self.base.Default.Combine.Label.OffsetY, + valueFormat = "%.2f", + showValue = true + }) + self:AppendRow_Dropdown(typeSelection, { + name = "Display name anchor position on button", + tooltipText = "Select display name anchor position on the button", + funcGet = function() + return self.base.GetLocationText(self.base.Saved.Combine.Label.PositionTarget) + end, + choices = self.base.Global.ChoiceCornerLocations, + funcSet = function(_, newValue) + self.base.Saved.Combine.Label.PositionTarget = self.base.GetLocationValue(newValue) + self.base.Saved.Combine.AnchorXY = self.base.GetLocationValue(newValue) + self.base.RestoreCombineLabels() + end + }) + self:AppendRow_Dropdown(typeSelection, { + name = "Display name anchor position on label", + tooltipText = "Select display name anchor position on the label", + funcGet = function() + return self.base.GetLocationText(self.base.Saved.Combine.Label.Position) + end, + choices = self.base.Global.ChoiceLocations, + funcSet = function(_, newValue) + self.base.Saved.Combine.Label.Position = self.base.GetLocationValue(newValue) + self.base.RestoreCombineLabels() + end + }) + self:AppendRow_Dropdown(typeSelection, { + name = "Bar anchor location", + tooltipText = "Select Bar anchor location, used when bar is collapsed", + funcGet = function() + return self.base.GetLocationText(self.base.Saved.Combine.AnchorXY) + end, + choices = self.base.Global.ChoiceCornerLocations, + funcSet = function(_, newValue) + self.base.Saved.Combine.AnchorXY = self.base.GetLocationValue(newValue) + self.base.RestoreCombineLabels() + end + }) + self:AppendRow_Title(typeSelection, {name = "Position and size"}) + self:AppendRow_Divider(typeSelection, {}) + self:AppendRow_Slider(typeSelection, { + name = "Choose default bar depth", + tooltipText = "Choose default bar depth\n(number of rows/columns)", + funcGet = function() + return self.base.Saved.Combine.BarDepth + end, + funcSet = function(sliderControl, newValue) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") + if valueLabel then + valueLabel:SetText(newValue) + end + self.base.Saved.Combine.BarDepth = newValue + self.base.RestoreFrames() + end, + minValue = 0, + maxValue = self.base.Global.HighestUnlocked, + valueStep = 1, + default = self.base.Default.BarDepth, + valueFormat = "%.2f", + showValue = true + }) + self:AppendRow_Slider(typeSelection, { + name = "Choose max bar height", + tooltipText = "Choose max bar height\n(number of inverse rows/columns)", + funcGet = function() + return self.base.Saved.Combine.BarWidth + end, + funcSet = function(sliderControl, newValue) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") + if valueLabel then + valueLabel:SetText(newValue) + end + self.base.Saved.Combine.BarWidth = newValue + self.base.RestoreFrames() + end, + minValue = 0, + maxValue = self.base.Global.HighestUnlocked, + valueStep = 1, + default = self.base.Default.BarWidth, + valueFormat = "%.2f", + showValue = true + }) +end + +function base.AppendMasterListTypeSelection(self, typeSelection) + self:AppendRow_Title(typeSelection, {name = "Selection"}) + self:AppendRow_Divider(typeSelection, {}) + self:AppendRow_Checkbox(typeSelection, { + name = string.format("Show disabled %s", self._type.Name), + tooltipText = string.format("When ON disabled elements will be shown for %s", self._type.Name), + funcGet = function() + return self._type.Saved.MenuShowDisabled + end, + funcSet = function(_, newValue) + self._type.Saved.MenuShowDisabled = newValue + self.base.CreateCollection(self._type) + self.base.Global.SettingsList:RefreshData() + end + }) + self:AppendRow_Divider(typeSelection, {}) + self:AppendRow_Checkbox(typeSelection, { + name = string.format("Select all %s", self._type.Name), + tooltipText = string.format("When pressed all %s will either be selected or deselected", self._type.Name), + funcGet = function() + return self.base.IsAllSelected(self._type) + end, + funcSet = function(_, newValue) + self.base.SelectAll(self._type, newValue) + self.base.RestoreFrame(self._type) + self.base.RestoreCombineLabels() + self.base.Global.SettingsList:RefreshData() + end + }) + self:AppendRow_Divider(typeSelection, {}) + for _, collection in ipairs(self._type.OrderedCollection or {}) do + if self._type.Saved.MenuShowDisabled and collection.Disabled or not collection.Disabled then + self:AppendRow_Checkbox(typeSelection, { + cId = collection.Id, + name = string.format("Show %s", collection.Name), + tooltipText = collection.Tooltip, + funcGet = function() + return self._type.Saved.Selected[collection.Id] + end, + disabledFunc = function() + return collection.Disabled + end, + funcSet = function(checkBoxControl, newValue) + local control = checkBoxControl:GetParent() + if not (control.data.disabledFunc and control.data.disabledFunc()) then + if newValue == true then + self._type.Saved.Selected[control.data.cId] = newValue + else + self._type.Saved.Selected[control.data.cId] = nil + end + self.base.RestoreFrame(self._type) + self.base.RestoreCombineLabels() + self.base.Global.SettingsList:RefreshData() + end + end + + }) + end + end +end + +function base.AppendMasterListTypeCollection(self, typeSelection) + local disabledWhenTooltipIsHidden = "Disabled when tooltip is not shown" + local disabledWhenLabelIsHidden = "Disabled when label is not shown" + local disabledWhenCombined = "Disabled when Collection is included in combine bar" + + self:AppendRow_Title(typeSelection, {name = "Tooltip"}) + self:AppendRow_Divider(typeSelection, {}) + self:AppendRow_Checkbox(typeSelection, { + name = "Show tooltip", + tooltipText = "When ON tooltips will be shown, when hovering buttons on the bar", + funcGet = function() + return self._type.Saved.Tooltip.Show + end, + funcSet = function(_, newValue) + self._type.Saved.Tooltip.Show = newValue + self.base.SetupButtons(self._type) + self.base.Global.SettingsList:RefreshData() + end + }) + self:AppendRow_Dropdown(typeSelection, { + name = "Show tooltip anchor position", + tooltipText = string.format("Select tooltip anchor position\n%s", disabledWhenTooltipIsHidden), + choices = self.base.Global.ChoiceSideLocations, + disabledFunc = function() + return not self._type.Saved.Tooltip.Show + end, + funcGet = function() + return self.base.GetLocationText(self._type.Saved.Tooltip.Position) + end, + funcSet = function(_, newValue) + self._type.Saved.Tooltip.Position = self.base.GetLocationValue(newValue) + self.base.SetupButtons(self._type) + end + }) + + self:AppendRow_Title(typeSelection, {name = "Display name and label"}) + self:AppendRow_Divider(typeSelection, {}) + self:AppendRow_Checkbox(typeSelection, { + name = "Include in combine bar", + tooltipText = "When ON will be attached to a combined bar", + funcGet = function() + return self._type.Saved.IsCombined + end, + funcSet = function(_, newValue) + self._type.Saved.IsCombined = newValue + self.base.RestoreFrame(self._type) + self.base.RestoreCombineLabels() + self.base.Global.SettingsList:RefreshData() + end + }) + self:AppendRow_Divider(typeSelection, {}) + self:AppendRow_Checkbox(typeSelection, { + name = "Enable hide/toggle visibility of the label", + tooltipText = string.format("When enabled a +/- at the end of the label indicates if the label is hidden or shown\n%s", disabledWhenCombined), + disabledFunc = function() + return self._type.Saved.IsCombined + end, + funcGet = function() + return self._type.Saved.IsCombined or self._type.Saved.HideAllEnabled + end, + funcSet = function(_, newValue) + if (not newValue) then + self._type.Saved.HideAll = newValue + self.base.RestoreFrame(self._type) + end + self._type.Saved.HideAllEnabled = newValue + self._type.Saved.LabelShow = true + self.base.SetupLabel(self._type) + self.base.RestoreLabel(self._type) + self.base.Global.SettingsList:RefreshData() + end + }) + self:AppendRow_Checkbox(typeSelection, { + name = "Show label", + tooltipText = string.format("%s or hide/toggle visibility is enabled", disabledWhenCombined), + disabledFunc = function() + return self._type.Saved.HideAllEnabled or self._type.Saved.IsCombined + end, + funcGet = function() + return self._type.Saved.LabelShow or self._type.Saved.IsCombined + end, + funcSet = function(_, newValue) + self._type.Saved.LabelShow = newValue + self.base.SetupLabel(self._type) + self.base.RestoreLabel(self._type) + self.base.Global.SettingsList:RefreshData() + end + }) + self:AppendRow_EditBox(typeSelection, { + name = "Display name", + tooltipText = string.format("Change displayname used on the label\n%s", disabledWhenLabelIsHidden), + disabledFunc = function() + return not self._type.Saved.LabelShow + end, + funcGet = function() + return tostring(self._type.Saved.Display) + end, + funcSet = function(control) + self._type.Saved.Display = control:GetText() or "" + self.base.RestoreFrame(self._type) + self.base.RestoreCombineLabels() + end + }) + self:AppendRow_Dropdown(typeSelection, { + name = "Display name font", + tooltipText = string.format("Change display name font\n%s", disabledWhenLabelIsHidden), + disabledFunc = function() + return not self._type.Saved.LabelShow + end, + choices = self.base.Global.AvailableFonts, + funcGet = function() + return self._type.Saved.Label.Font + end, + funcSet = function(_, newValue) + self._type.Saved.Label.Font = newValue + self.base.RestoreFrame(self._type) + self.base.RestoreCombineLabels() + end + }) + self:AppendRow_Slider(typeSelection, { + name = "Display name height", + tooltipText = string.format("Change display name height\n%s", disabledWhenLabelIsHidden), + disabledFunc = function() + return not self._type.Saved.LabelShow + end, + funcGet = function() + return self._type.Saved.Label.Height + end, + funcSet = function(sliderControl, newValue) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") + if valueLabel then + valueLabel:SetText(newValue) + end + self._type.Saved.Label.Height = newValue + self.base.RestoreFrame(self._type) + self.base.RestoreCombineLabels() + end, + minValue = 0, + maxValue = 100, + valueStep = 1, + default = self.base.Default[self._type.Name].Label.Height, + valueFormat = "%.2f", + showValue = true + }) + self:AppendRow_Slider(typeSelection, { + name = "Display name width", + tooltipText = string.format("Change display name width\n%s", disabledWhenLabelIsHidden), + disabledFunc = function() + return not self._type.Saved.LabelShow + end, + funcGet = function() + return self._type.Saved.Label.Width + end, + funcSet = function(sliderControl, newValue) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") + if valueLabel then + valueLabel:SetText(newValue) + end + self._type.Saved.Label.Width = newValue + self.base.RestoreFrame(self._type) + self.base.RestoreCombineLabels() + end, + minValue = 0, + maxValue = 500, + valueStep = 1, + default = self.base.Default[self._type.Name].Label.Width, + valueFormat = "%.2f", + showValue = true + }) + self:AppendRow_Slider(typeSelection, { + name = "Display name offset horizontal", + tooltipText = string.format("Display name offset horizontal\n(X)\n%s", disabledWhenLabelIsHidden), + disabledFunc = function() + return not self._type.Saved.LabelShow + end, + funcGet = function() + return self._type.Saved.Label.OffsetX + end, + funcSet = function(sliderControl, newValue) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") + if valueLabel then + valueLabel:SetText(newValue) + end + self._type.Saved.Label.OffsetX = newValue + self.base.RestoreFrame(self._type) + self.base.RestoreCombineLabels() + end, + minValue = -500, + maxValue = 500, + valueStep = 1, + default = self.base.Default[self._type.Name].Label.OffsetX, + valueFormat = "%.2f", + showValue = true + }) + self:AppendRow_Slider(typeSelection, { + name = "Display name offset vertical", + tooltipText = string.format("Display name offset vertical\n(y)\n%s", disabledWhenLabelIsHidden), + disabledFunc = function() + return not self._type.Saved.LabelShow + end, + funcGet = function() + return self._type.Saved.Label.OffsetY + end, + funcSet = function(sliderControl, newValue) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") + if valueLabel then + valueLabel:SetText(newValue) + end + self._type.Saved.Label.OffsetY = newValue + self.base.RestoreFrame(self._type) + self.base.RestoreCombineLabels() + end, + minValue = -500, + maxValue = 500, + valueStep = 1, + default = self.base.Default[self._type.Name].Label.OffsetY, + valueFormat = "%.2f", + showValue = true + }) + self:AppendRow_Dropdown(typeSelection, { + name = "Display name anchor position on button", + tooltipText = string.format("Select display name anchor position on the button\n%s\n or Collection is included in combine bar", disabledWhenLabelIsHidden), + disabledFunc = function() + return not self._type.Saved.LabelShow or self._type.Saved.IsCombined + end, + funcGet = function() + if self._type.Saved.IsCombined then + return self.base.GetLocationText(self.base.Saved.Combine.Label.PositionTarget) + else + return self.base.GetLocationText(self._type.Saved.Label.PositionTarget) + end + end, + choices = self.base.Global.ChoiceLocations, + funcSet = function(_, newValue) + self._type.Saved.Label.PositionTarget = self.base.GetLocationValue(newValue) + self._type.Saved.AnchorXY = self.base.GetLocationValue(newValue) + self.base.RestoreFrame(self._type) + self.base.RestoreCombineLabels() + end + }) + self:AppendRow_Dropdown(typeSelection, { + name = "Display name anchor position on label", + tooltipText = string.format("Select display name anchor position on the label\n%s\n or Collection is included in combine bar", disabledWhenLabelIsHidden), + disabledFunc = function() + return not self._type.Saved.LabelShow or self._type.Saved.IsCombined + end, + funcGet = function() + if self._type.Saved.IsCombined then + return self.base.GetLocationText(self.base.Saved.Combine.Label.Position) + else + return self.base.GetLocationText(self._type.Saved.Label.Position) + end + end, + choices = self.base.Global.ChoiceLocations, + funcSet = function(_, newValue) + self._type.Saved.Label.Position = self.base.GetLocationValue(newValue) + self.base.RestoreFrame(self._type) + self.base.RestoreCombineLabels() + end + }) + self:AppendRow_Dropdown(typeSelection, { + name = "Bar anchor location", + tooltipText = string.format("Select Bar anchor location, used when bar is collapsed\n%s", disabledWhenCombined), + disabledFunc = function() + return self._type.Saved.IsCombined + end, + funcGet = function() + if self._type.Saved.IsCombined then + return self.base.GetLocationText(self.base.Saved.Combine.AnchorXY) + else + return self.base.GetLocationText(self._type.Saved.AnchorXY) + end + end, + choices = self.base.Global.ChoiceCornerLocations, + funcSet = function(_, newValue) + self._type.Saved.AnchorXY = self.base.GetLocationValue(newValue) + self.base.RestoreFrame(self._type) + self.base.RestoreCombineLabels() + end + }) + + self:AppendRow_Title(typeSelection, {name = "Position and size"}) + self:AppendRow_Divider(typeSelection, {}) + self:AppendRow_Slider(typeSelection, { + name = "Choose bar depth", + tooltipText = string.format("Choose bar depth\n(number of rows/columns)\n%s", disabledWhenCombined), + disabledFunc = function() + return self._type.Saved.IsCombined + end, + funcGet = function() + return self._type.Saved.BarDepth + end, + funcSet = function(sliderControl, newValue) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") + if valueLabel then + valueLabel:SetText(newValue) + end + self._type.Saved.BarDepth = newValue + self.base.RestoreFrame(self._type) + self.base.RestoreCombineLabels() + end, + minValue = 0, + maxValue = self._type.Unlocked, + valueStep = 1, + default = self.base.Default[self._type.Name].BarDepth, + valueFormat = "%.2f", + showValue = true + }) + self:AppendRow_Slider(typeSelection, { + name = "Choose max bar height", + tooltipText = string.format("Choose bar height\n(number of inverse rows/columns)\n%s", disabledWhenCombined), + disabledFunc = function() + return self._type.Saved.IsCombined + end, + funcGet = function() + return self._type.Saved.BarWidth + end, + funcSet = function(sliderControl, newValue) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") + if valueLabel then + valueLabel:SetText(newValue) + end + self._type.Saved.BarWidth = newValue + self.base.RestoreFrame(self._type) + self.base.RestoreCombineLabels() + end, + minValue = 0, + maxValue = self._type.Unlocked, + valueStep = 1, + default = self.base.Default[self._type.Name].BarWidth, + showValue = true + }) + self:AppendRow_Checkbox(typeSelection, { + name = "Bar orientation horizontal", + tooltipText = string.format("Bar orientation horizontal\n%s", disabledWhenCombined), + disabledFunc = function() + return self._type.Saved.IsCombined + end, + funcGet = function() + return self._type.Saved.Horizontal + end, + funcSet = function(_, newValue) + self._type.Saved.Horizontal = newValue + self.base.RestoreFrame(self._type) + self.base.RestoreCombineLabels() + end + }) +end + +function base.AppendMasterListTypeNoCollectionType(self, typeSelection) + self:AppendRow_Title(typeSelection, {name = "Select a collection type"}) + self:AppendRow_Divider(typeSelection, {}) +end diff --git a/CBs_Settings_List.lua b/CBs_Settings_List.lua new file mode 100644 index 0000000..1b0dcc5 --- /dev/null +++ b/CBs_Settings_List.lua @@ -0,0 +1,382 @@ +--[[ +Author: Jarth +Filename: CBs_Settings_List.lua +]] -- +------------------------------------------------------------------------------------------------- +-- FUNCTIONS -- +------------------------------------------------------------------------------------------------- +CBs_Settings_List = ZO_SortFilterList:Subclass() + +function CBs_Settings_List:New(...) + self.list = ZO_SortFilterList.New(self, ...) + self.masterListType = "Selection" + return self.list +end + +function CBs_Settings_List:Initialize(base, _type, ...) + ZO_SortFilterList.Initialize(self, ...) + self.base = base + self._type = _type + self.masterList = {} + if not (self._type and self._type.Enabled) then + self.masterListType = "CollectionTypes" + end + + self:SetAlternateRowBackgrounds(false) + self:AppendDataTypes() +end + +------------------------------------------------------------------------------------------------- +-- FUNCTIONS - Append DataTypes -- +------------------------------------------------------------------------------------------------- + +function CBs_Settings_List:AppendDataTypes() + local dataTypes = { + [10] = { + name = "CBs_Settings_ListRow_Checkbox", + height = 40, + func = function(...) + self:SetupRow_Checkbox(...) + end + }, + [15] = { + name = "CBs_Settings_ListRow_Checkbox_CogButton", + height = 40, + func = function(...) + self:SetupRow_Checkbox_CogButton(...) + end + }, + [20] = { + name = "CBs_Settings_ListRow_Dropdown", + height = 40, + func = function(...) + self:SetupRow_Dropdown(...) + end + }, + [30] = { + name = "CBs_Settings_ListRow_Slider", + height = 40, + func = function(...) + self:SetupRow_Slider(...) + end + }, + [40] = { + name = "CBs_Settings_ListRow_EditBox", + height = 40, + func = function(...) + self:SetupRow_EditBox(...) + end + }, + [50] = { + name = "CBs_Settings_ListRow_Title", + height = 40, + func = function(...) + self:SetupRow_Title(...) + end + }, + [60] = { + name = "CBs_Settings_ListRow_Button", + height = 40, + func = function(...) + self:SetupRow_Button(...) + end + }, + [100] = { + name = "CBs_Settings_ListRow_Divider", + height = 6, + func = function(...) + ZO_SortFilterList.SetupRow(self, ...) + end + } + } + + for index, dataType in pairs(dataTypes) do + ZO_ScrollList_AddDataType(self.list, index, dataType.name, dataType.height, dataType.func) + end +end + +------------------------------------------------------------------------------------------------- +-- FUNCTIONS - Append and Setup RowTypes -- +------------------------------------------------------------------------------------------------- + +function CBs_Settings_List:AppendRow_Checkbox(typeSelection, data) + data.type = typeSelection + data.dataTypeId = 10 + table.insert(self.masterList, data) +end + +function CBs_Settings_List:SetupRow_Checkbox(control, data) + control.data = data + ZO_SortFilterList.SetupRow(self, control, data) + + control.checkbox = GetControl(control, "Checkbox") + if control.checkbox then + control.checkbox.tooltipText = data.tooltipText + ZO_CheckButton_SetCheckState(control.checkbox, control.data.funcGet and control.data.funcGet()) + ZO_CheckButton_SetLabelText(control.checkbox, data.name) + if control.checkbox.label then + control.checkbox.label.defaultNormalColor = ZO_DEFAULT_ENABLED_COLOR + control.checkbox.label:ClearAnchors() + control.checkbox.label:SetAnchor(TOPLEFT, control.checkbox, TOPLEFT, -425) + control.checkbox.label:SetAnchor(BOTTOMRIGHT, control.checkbox, BOTTOMLEFT) + end + ZO_CheckButton_SetTooltipAnchor(control.checkbox, TOP, control.checkbox.label) + ZO_CheckButton_SetToggleFunction(control.checkbox, control.data.funcSet) + ZO_CheckButton_SetEnableState(control.checkbox, not (control.data.disabledFunc and control.data.disabledFunc())) + end +end + +function CBs_Settings_List:AppendRow_Checkbox_CogButton(typeSelection, data) + data.type = typeSelection + data.dataTypeId = 15 + table.insert(self.masterList, data) +end + +function CBs_Settings_List:SetupRow_Checkbox_CogButton(control, data) + self:SetupRow_Checkbox(control, data) + control.cogButton = GetControl(control, "CogButton") + if control.cogButton then + control.cogButton:SetHidden(false) + local isEnabled = control.data.funcGet and control.data.funcGet() + ZO_CheckButton_SetEnableState(control.cogButton, isEnabled) + control.cogButton:SetAlpha(isEnabled and 1 or 0.5) + control.cogButton:SetHandler("OnClicked", function() + PlaySound(SOUNDS.SINGLE_SETTING_RESET_TO_DEFAULT) + control.data.funcCog(control.slider, data.default) + end) + end +end + +function CBs_Settings_List:AppendRow_Dropdown(typeSelection, data) + data.type = typeSelection + data.dataTypeId = 20 + table.insert(self.masterList, data) +end + +function CBs_Settings_List:SetupRow_Dropdown(control, data) + control.data = data + ZO_SortFilterList.SetupRow(self, control, data) + + control.dropdown = GetControl(control, "Dropdown") + control.comboBox = ZO_ComboBox_ObjectFromContainer(control.dropdown) + control.comboBox:SetSortsItems(false) + control.comboBox:SetFont("ZoFontWinT1") + control.comboBox:SetSpacing(4) + control.comboBox.tooltipText = data.tooltipText + + self.SetNameText(control, control.data.name) + self.RepopulateDropdownOptions(control) + self.SetActiveOrInactive(control) +end + +function CBs_Settings_List:AppendRow_Slider(typeSelection, data) + data.type = typeSelection + data.dataTypeId = 30 + table.insert(self.masterList, data) +end + +function CBs_Settings_List:SetupRow_Slider(control, data) + control.data = data + ZO_SortFilterList.SetupRow(self, control, control.data) + + control.slider = GetControl(control, "Slider") + -- Need to override the existing value changed handler first so it doesn't run when we do the SetMinMax + control.slider:SetHandler("OnValueChanged", nil) + control.slider:SetMinMax(control.data.minValue, control.data.maxValue) + control.slider:SetValueStep(control.data.valueStep or 1) + control.slider:SetValue(data.funcGet()) + control.slider:SetHandler("OnValueChanged", control.data.funcSet) + + if data.default then + if control.defaultMarkerControl == nil then + control.defaultMarkerControl = CreateControlFromVirtual("$(parent)DefaultMarker", control.slider, "ZO_Options_DefaultMarker") + end + local offsetX = zo_clampedPercentBetween(data.minValue, data.maxValue, data.default) * control.slider:GetWidth() + control.defaultMarkerControl:SetAnchor(TOP, control.slider, LEFT, offsetX + .25, 6) + + control.defaultMarkerControl:SetHandler("OnClicked", function() + PlaySound(SOUNDS.SINGLE_SETTING_RESET_TO_DEFAULT) + control.slider:SetValue(data.default) + control.data.funcSet(control.slider, data.default) + end) + end + + local valueLabelControl = GetControl(control, "ValueLabel") + if valueLabelControl and data.showValue then + local shownVal = data.funcGet() + if data.valueMin and data.valueMax and data.valueMax > data.valueMin then + local range = data.maxValue - data.minValue + local percentage = (shownVal - data.minValue) / range + + local shownRange = data.valueMax - data.valueMin + shownVal = data.valueMin + percentage * shownRange + shownVal = string.format("%d", shownVal) + end + valueLabelControl:SetText(shownVal) + end + + self.SetNameText(control, control.data.name) + self.SetActiveOrInactive(control) +end + +function CBs_Settings_List:AppendRow_EditBox(typeSelection, data) + data.type = typeSelection + data.dataTypeId = 40 + table.insert(self.masterList, data) +end + +function CBs_Settings_List:SetupRow_EditBox(control, data) + control.data = data + ZO_SortFilterList.SetupRow(self, control, control.data) + + control.editBox = GetControl(control, "EditBox") + if control.editBox then + ZO_EditDefaultText_Initialize(control.editBox) + control.editBox:SetHandler("OnTextChanged", nil) + control.editBox:SetText(data.funcGet()) + control.editBox:SetHandler("OnTextChanged", function() + data.funcSet(control.editBox) + end) + end + + self.SetNameText(control, control.data.name) + self.SetActiveOrInactive(control) +end + +function CBs_Settings_List:AppendRow_Title(typeSelection, data) + data.type = typeSelection + data.dataTypeId = 50 + table.insert(self.masterList, data) +end + +function CBs_Settings_List:SetupRow_Title(control, data) + control.data = data + ZO_SortFilterList.SetupRow(self, control, control.data) + + self.SetNameText(control, control.data.name) + self.SetActiveOrInactive(control) +end + +function CBs_Settings_List:AppendRow_Button(typeSelection, data) + data.type = typeSelection + data.dataTypeId = 60 + table.insert(self.masterList, data) +end + +function CBs_Settings_List:SetupRow_Button(control, data) + control.data = data + ZO_SortFilterList.SetupRow(self, control, control.data) + + control.button = GetControl(control, "Button") + if control.button then + control.button:SetText(control.data.buttonName or "") + control.button:SetHandler("OnClicked", function() + control.data.funcSet() + end) + end + + self.SetNameText(control, control.data.name) + self.SetActiveOrInactive(control) +end + +function CBs_Settings_List:AppendRow_Divider(typeSelection, data) + data.type = typeSelection + data.dataTypeId = 100 + table.insert(self.masterList, data) +end + +------------------------------------------------------------------------------------------------- +-- FUNCTIONS - SetupRowType - Helpers -- +------------------------------------------------------------------------------------------------- +function CBs_Settings_List.RepopulateDropdownOptions(control) + control.comboBox:ClearItems() + + local selectedValue = control.data.funcGet() + local selectedEntry = nil + for _, optionValue in pairs(control.data.choices or {}) do + local entry = ZO_ComboBox:CreateItemEntry(optionValue, control.data.funcSet) + control.comboBox:AddItem(entry) + + if optionValue == selectedValue then + selectedEntry = entry + end + end + control.comboBox:SelectItem(selectedEntry) +end + +function CBs_Settings_List.SetNameText(control, text) + local controlLabel = GetControl(control, "Name") + if controlLabel then + controlLabel:SetText(text or "") + end +end + +function CBs_Settings_List.SetActiveOrInactive(control) + local disabled = control.data.disabledFunc and control.data.disabledFunc() + + local nameControl = GetControl(control, "Name") + if nameControl then + if disabled then + nameControl:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + else + nameControl:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + end + end + + local valueLabelControl = GetControl(control, "ValueLabel") + if valueLabelControl then + if disabled then + valueLabelControl:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + else + valueLabelControl:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + end + end + + if control.button then + control.button:SetEnabled(not disabled) + end + + if control.comboBox then + control.comboBox:SetEnabled(not disabled) + end + + if control.slider then + control.slider:SetEnabled(not disabled) + end + + if control.editBox then + ZO_DefaultEdit_SetEnabled(control.editBox, not disabled) + end +end + +------------------------------------------------------------------------------------------------- +-- FUNCTIONS - MasterList -- +------------------------------------------------------------------------------------------------- +function CBs_Settings_List:BuildMasterList() + self.masterList = {} + + self.base.AppendMasterListTypeGeneral(self, "General") + self.base.AppendMasterListTypeCollectionTypes(self, "CollectionTypes") + self.base.AppendMasterListTypeCombined(self, "Combined") + if self._type then + self.base.AppendMasterListTypeSelection(self, "Selection") + self.base.AppendMasterListTypeCollection(self, "Collection") + else + self.base.AppendMasterListTypeNoCollectionType(self, "Selection") + self.base.AppendMasterListTypeNoCollectionType(self, "Collection") + end +end + +function CBs_Settings_List:FilterScrollList() + local scrollData = ZO_ScrollList_GetDataList(self.list) + ZO_ClearNumericallyIndexedTable(scrollData) + + for i = 1, #self.masterList do + if self.masterListType == nil or self.masterListType == self.masterList[i].type then + scrollData[#scrollData + 1] = ZO_ScrollList_CreateDataEntry(self.masterList[i].dataTypeId, self.masterList[i]) + end + end +end + +function CBs_Settings_List:SortScrollList() +end diff --git a/Changelog b/Changelog index 46c50ea..5e352c5 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,19 @@ ------------------------------------------------------------------------------- Collection bars ------------------------------------------------------------------------------- +Version 1.0.3 (23-06-2019) +- Updated bindings, so they update when a key is remapped in ESO settings +- Made LibAddonMenu-2.0 Optional +-- I expect to remove LibAddonMenu-2.0 completely.. eventually +- Added functionality to "Collection Bar Settings" +-- Option to select if addon should be added to the menu ("LibAddonMenu-2.0") +-- Migrated missing settings from the menu +-- Allows for adding and removing "Collection types", without reloading the LibAddonMenu +-- Allows for changing between account or user settings, without reloading the LibAddonMenu +-- Change active collection type by pressing settings-symbol/cog in "Collection types". +- Updated menu slash command to: "/cb_menu" +- Updated settings window slash command to: "/cb" + Version 1.0.2 (14-06-2019) - Removed files for library: LibAddonMenu-2.0 -- It is still required, but files needs to be downloaded separately diff --git a/CollectionBars.lua b/CollectionBars.lua index e5cc4e4..8df8ddf 100644 --- a/CollectionBars.lua +++ b/CollectionBars.lua @@ -2,7 +2,6 @@ Author: Jarth Filename: CollectionBars.lua ]] -- - ------------------------------------------------------------------------------------------------- -- VARIABLES -- ------------------------------------------------------------------------------------------------- @@ -25,7 +24,16 @@ function base.Initialize() base.InitializeBindings() base.InitializeSettingsSlash() base.InitializeReverseBinding() + base.InitializeWithSavedData() + + if LibAddonMenu2 ~= nil and base.Saved.UseLAMMenu then + base.CreateSettingsWindow() + end + EVENT_MANAGER:UnregisterForEvent(base.Addon.Name, EVENT_ADD_ON_LOADED) +end + +function base.InitializeWithSavedData() for _, _type in pairs(base.Type) do _type.Saved = base.Saved[_type.Name] if _type.Saved.Enabled then @@ -35,10 +43,6 @@ function base.Initialize() base.InitializeCombine() base.RestoreCombine() - - base.CreateSettingsWindow() - - EVENT_MANAGER:UnregisterForEvent(base.Addon.Name, EVENT_ADD_ON_LOADED) end function base.InitializeType(_type) @@ -50,8 +54,7 @@ end function base.InitializeCombineFrame() local name = base.Addon.Abbreviation .. "_CombineFrame" base.Global.Combine.Frame = base.GetFrame(name, name) - name = name .. "HideAll" - base.Global.Combine.HideAll = base.GetFrame(name, name) + base.Global.Combine.HideAll = base.GetFrame(name .. "HideAll", name .. "HideAll") end function base.CreateCollection(_type) @@ -70,13 +73,7 @@ function base.CreateCollection(_type) local id = GetCollectibleIdFromType(_type.TypeId, index) local name, description, icon, _, _unlocked, _, _, _, hint, _ = GetCollectibleInfo(id) if _unlocked or _type.Saved.MenuShowDisabled then - _type.Collection[id] = { - Id = id, - Name = name, - EnabledTexture = icon, - Disabled = not _unlocked, - Tooltip = string.format("Description: %s \nHint: %s", description, hint) - } + _type.Collection[id] = {Id = id, Name = name, EnabledTexture = icon, Disabled = not _unlocked, Tooltip = string.format("Description: %s \nHint: %s", description, hint)} _type.OrderedCollection[elementsAdded] = _type.Collection[id] elementsAdded = elementsAdded + 1 end @@ -91,9 +88,9 @@ function base.RestoreFrames() base.RestoreCombine() end -function base.HideOther(newType) +function base.HideOthers(newType) for _, _type in pairs(base.Type) do - if _type.Saved.Enabled and _type.Saved.Combine and not _type.Saved.HideAll and _type ~= newType then + if _type.Saved.Enabled and _type.Saved.IsCombined and not _type.Saved.HideAll and _type ~= newType then _type.Saved.HideAll = not _type.Saved.HideAll base.RestoreFrame(_type) end @@ -109,6 +106,9 @@ function base.RestoreFrame(_type) base.UpdateToggleSettings(_type) base.UpdateMoveFrame(_type) base.UpdateFragment(_type) + else + base.RemoveLabel(_type) + base.RemoveFrame(_type) end end diff --git a/CollectionBars.txt b/CollectionBars.txt index bf56b0c..7e2942e 100644 --- a/CollectionBars.txt +++ b/CollectionBars.txt @@ -6,9 +6,9 @@ ## APIVersion: 100027 ## Title: Collection Bars -## Version: 1.0.2 +## Version: 1.0.3 ## Author: Jarth -## Description: Show collection bars and activate collections with key or button press +## Description: Show collection bars and activate collections with key or button press. Shortcuts: Settings window: /cb LibAddonMenu: /cb_menu ## ## This Add-on is not created by, affiliated with or sponsored by ZeniMax Media Inc. or its affiliates. ## The Elder Scrolls® and related logos are registered trademarks or trademarks of ZeniMax Media Inc. in the United States and/or other countries. @@ -18,8 +18,10 @@ ## SavedVariables: CollectionBars_Account ## SavedVariables: CollectionBars_Character -## DependsOn: LibAddonMenu-2.0 +## OptionalDependsOn: LibAddonMenu-2.0 +CBs_Settings.xml +CBs_Button.xml CollectionBars.xml CBs_Constants.lua CBs_Helpers.lua @@ -29,7 +31,8 @@ CBs_Menu.lua CBs_MoveFrame.lua CBs_Fragment.lua CBs_Buttons.lua -CBs_List.lua +CBs_Settings_Data.lua +CBs_Settings_List.lua CBs_Settings.lua CBs_Labels.lua CollectionBars.lua diff --git a/CollectionBars.xml b/CollectionBars.xml index 5f72f92..918186d 100644 --- a/CollectionBars.xml +++ b/CollectionBars.xml @@ -30,122 +30,5 @@ </Button> </Controls> </Control> - - <Control name="CBs_Button" clampedToScreen="true" movable="false" virtual="true"> - <Controls> - <Button name="$(parent)Button" mouseOverBlendMode="ADD"> - <AnchorFill /> - <MouseButton button="1" enabled="true" /> - <MouseButton button="2" enabled="true" /> - <Textures normal="/EsoUI/Art/ActionBar/abilityFrame64_up.dds" pressed="/EsoUI/Art/ActionBar/abilityFrame64_down.dds" mouseOver="/EsoUI/Art/ActionBar/actionBar_mouseOver.dds" /> - </Button> - - <Texture name="$(parent)BG" level="0" textureFile="/EsoUI/Art/ActionBar/abilityInset.dds"> - <Anchor point="TOPLEFT" relativeTo="$(parent)" /> - <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)" /> - </Texture> - <Texture name="$(parent)Icon" level="1"> - <Anchor point="CENTER" relativeTo="$(parent)" /> - </Texture> - <Texture name="$(parent)CooldownIcon" level="1"> - <TextureCoords left="0" right="1" top="0" bottom="0" /> - <Anchor point="TOPLEFT" relativeTo="$(parent)Icon" relativePoint="TOPLEFT" /> - <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)Icon" relativePoint="BOTTOMRIGHT" /> - </Texture> - <Texture name="$(parent)Status" textureFile="/EsoUI/Art/ActionBar/ActionSlot_toggledon.dds" tier="HIGH" hidden="true"> - <Anchor point="TOPLEFT" relativeTo="$(parent)Icon" relativePoint="TOPLEFT" /> - <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)Icon" relativePoint="BOTTOMRIGHT" /> - </Texture> - - <Cooldown name="$(parent)Cooldown" inherits="ZO_DefaultCooldown" tier="HIGH" alpha="0.7"> - <Anchor point="TOPLEFT" relativeTo="$(parent)Icon" relativePoint="TOPLEFT" /> - <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)Icon" relativePoint="BOTTOMRIGHT" /> - </Cooldown> - <Texture name="$(parent)CooldownCompleteAnimation" textureFile="/EsoUI/Art/ActionBar/coolDown_completeEFX.dds" blendMode="ADD" tier="HIGH" hidden="true"> - <Anchor point="TOPLEFT" relativeTo="$(parent)Icon" relativePoint="TOPLEFT" /> - <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)Icon" relativePoint="BOTTOMRIGHT" /> - </Texture> - - <Label name="$(parent)ButtonText" wrapMode="ELLIPSIS" horizontalAlignment="CENTER" tier="HIGH" verticalAlignment="BOTTOM" font="ZoFontGameSmall"> - <Anchor point="BOTTOM" relativeTo="$(parent)Button" relativePoint="BOTTOM" /> - </Label> - - <Label name="$(parent)CooldownTime" inherits="ZO_CollectibleTileDefaultLabel" hidden="true" clampedToScreen="true"> - <Anchor point="TOPLEFT" relativeTo="$(parent)Icon" relativePoint="TOPLEFT" /> - <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)Icon" relativePoint="BOTTOMRIGHT" /> - </Label> - </Controls> - </Control> - - <TopLevelControl name="CBs_Settings" clampedToScreen="true" movable="true" mouseEnabled="true" virtual="true"> - <Anchor point="CENTER" relativePoint="CENTER"/> - <Dimensions x="544" y="944" /> - <DimensionConstraints minX="544" minY="944" /> - <Controls> - <Backdrop name="$(parent)Bg" integralWrapping="true"> - <Anchor point="TOPLEFT" offsetX="-8" offsetY="-6"/> - <Anchor point="BOTTOMRIGHT" offsetX="4" offsetY="4"/> - - <Edge file="EsoUI/Art/ChatWindow/chat_BG_edge.dds" edgeFileWidth="256" edgeFileHeight="256" edgeSize="32"/> - <Center file="EsoUI/Art/ChatWindow/chat_BG_center.dds" /> - <Insets left="32" top="32" right="-32" bottom="-32" /> - </Backdrop> - <Label name="$(parent)Title" font="ZoFontWinH1" modifyTextType="UPPERCASE"> - <Anchor point="TOPLEFT" offsetX="22" offsetY="22" /> - </Label> - - <Texture name="$(parent)Divider" inherits="ZO_Options_Divider"> - <Anchor point="TOPLEFT" relativeTo="$(parent)Title" relativePoint="BOTTOMLEFT" offsetY="2"/> - </Texture> - - <Label name="$(parent)Label" inherits="ZO_Options_SectionTitleLabel"> - <Anchor point="TOPLEFT" relativeTo="$(parent)Divider" relativePoint="TOPLEFT" offsetY="5"/> - </Label> - - <Control name="$(parent)List" inherits="ZO_ScrollList"> - <Anchor point="TOPLEFT" relativeTo="$(parent)Label" relativePoint="BOTTOMLEFT" offsetY="22"/> - <Anchor point="BOTTOMRIGHT" offsetX="-22" offsetY="-22" /> - </Control> - - <Button name="CBs_" clickSound="Click" relativeTo="$(parent)"> - <Anchor point="TOPRIGHT" relativeTo="$(parent)" relativePoint="TOPRIGHT" offsetX="-10" offsetY="10" /> - <Dimensions x="22" y="22" /> - </Button> - - <Button name="$(parent)Close" clickSound="Click" relativeTo="$(parent)"> - <Anchor point="TOPRIGHT" relativeTo="$(parent)" relativePoint="TOPRIGHT" offsetX="-10" offsetY="10" /> - <Dimensions x="22" y="22" /> - <Textures name="$(parent)Textures" normal="/EsoUI/Art/Buttons/decline_up.dds" mouseOver="/EsoUI/Art/Buttons/decline_over.dds" pressed="/EsoUI/Art/Buttons/decline_down.dds" /> - </Button> - - <Button name="$(parent)Refresh" clickSound="Click" relativeTo="$(parent)"> - <Anchor point="TOPRIGHT" relativeTo="$(parent)Close" relativePoint="TOPRIGHT" offsetX="-32" /> - <Dimensions x="22" y="22" /> - <Textures name="$(parent)Textures" normal="/EsoUI/Art/Buttons/edit_save_up.dds" mouseOver="/EsoUI/Art/Buttons/edit_save_over.dds" pressed="/EsoUI/Art/Buttons/edit_save_down.dds" /> - </Button> - - <Button name="$(parent)Move" clickSound="Click" relativeTo="$(parent)"> - <Anchor point="TOPRIGHT" relativeTo="$(parent)Refresh" relativePoint="TOPRIGHT" offsetX="-32" /> - <Dimensions x="22" y="22" /> - <Textures name="$(parent)Textures" normal="/EsoUI/Art/Buttons/edit_up.dds" mouseOver="/EsoUI/Art/Buttons/edit_over.dds" pressed="/EsoUI/Art/Buttons/edit_down.dds" /> - </Button> - </Controls> - </TopLevelControl> - - <!-- Inspiration: ZO_Options_Checkbox --> - <Control name="CBs_ListRow" mouseEnabled="true" virtual="true"> - <Dimensions x="510" y="26" /> - <Controls> - <Button name="$(parent)Checkbox" inherits="ZO_CheckButton_Text" horizontalAlignment="LEFT" font="ZoFontWinH4" modifyTextType="UPPERCASE"> - <Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetX="425" /> - <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)" relativePoint="BOTTOMRIGHT" /> - <FontColors normalColor="INTERFACE_COLOR_TYPE_TEXT_COLORS:INTERFACE_TEXT_COLOR_NORMAL" pressedColor="INTERFACE_COLOR_TYPE_TEXT_COLORS:INTERFACE_TEXT_COLOR_NORMAL" mouseOverColor="INTERFACE_COLOR_TYPE_TEXT_COLORS:INTERFACE_TEXT_COLOR_HIGHLIGHT" disabledColor="INTERFACE_COLOR_TYPE_TEXT_COLORS:INTERFACE_TEXT_COLOR_DISABLED" /> - </Button> - </Controls> - </Control> - - <Texture name="CBs_Divider" inherits="ZO_Options_Divider" virtual="true"> - <Dimensions x="512" y="2" /> - </Texture> </Controls> </GuiXml> \ No newline at end of file