diff --git a/Bindings.xml b/Bindings.xml index bd36d2e..17dda63 100644 --- a/Bindings.xml +++ b/Bindings.xml @@ -1,6 +1,7 @@ <Bindings> <Layer name="SI_KEYBINDINGS_LAYER_GENERAL"> <Category name="Collection bars"> + <Action name="CBs_Settings"><Down>CBs_ShowSettings()</Down></Action> <Action name="CBs_1"><Down>CBs_Clicked(1)</Down></Action> <Action name="CBs_2"><Down>CBs_Clicked(2)</Down></Action> <Action name="CBs_3"><Down>CBs_Clicked(3)</Down></Action> @@ -11,6 +12,16 @@ <Action name="CBs_8"><Down>CBs_Clicked(8)</Down></Action> <Action name="CBs_9"><Down>CBs_Clicked(9)</Down></Action> <Action name="CBs_10"><Down>CBs_Clicked(10)</Down></Action> + <Action name="CBs_11"><Down>CBs_Clicked(11)</Down></Action> + <Action name="CBs_12"><Down>CBs_Clicked(12)</Down></Action> + <Action name="CBs_13"><Down>CBs_Clicked(13)</Down></Action> + <Action name="CBs_14"><Down>CBs_Clicked(14)</Down></Action> + <Action name="CBs_15"><Down>CBs_Clicked(15)</Down></Action> + <Action name="CBs_16"><Down>CBs_Clicked(16)</Down></Action> + <Action name="CBs_17"><Down>CBs_Clicked(17)</Down></Action> + <Action name="CBs_18"><Down>CBs_Clicked(18)</Down></Action> + <Action name="CBs_19"><Down>CBs_Clicked(19)</Down></Action> + <Action name="CBs_20"><Down>CBs_Clicked(20)</Down></Action> </Category> </Layer> </Bindings> \ No newline at end of file diff --git a/CBs_Bindings.lua b/CBs_Bindings.lua index e59dfbc..62e7100 100644 --- a/CBs_Bindings.lua +++ b/CBs_Bindings.lua @@ -6,24 +6,23 @@ Filename: CBs_Bindings.lua -- VARIABLES -- ------------------------------------------------------------------------------------------------- local base = CollectionBars +local texts = base.Texts ------------------------------------------------------------------------------------------------- -- FUNCTIONS -- ------------------------------------------------------------------------------------------------- +function CBs_ShowSettings() base.ShowSettings() end + function CBs_Clicked(keyId) local control = base.WM:GetMouseOverControl() - local collectibleId = base.Saved.Bindings[keyId] + if control ~= nil and control.CBs then local newCId = control:GetId() local previousCId = collectibleId if previousCId ~= newCId then - for _keyId, cid in pairs(base.Saved.Bindings) do - if _keyId ~= keyId and cid == newCId then - base.Saved.Bindings[_keyId] = 0 - end - end + for _keyId, cid in pairs(base.Saved.Bindings) do if _keyId ~= keyId and cid == newCId then base.Saved.Bindings[_keyId] = 0 end end for cid, _keyId in pairs(base.Global.ReverseBindings) do if cid ~= newCId and _keyId == keyId then @@ -45,41 +44,14 @@ function CBs_Clicked(keyId) end end -function base.SetbindingText(cid) - if base.Buttons[cid] then - base.Buttons[cid]:SetBindingText(base.Saved.ShowBinding, cid) - end -end +function base.SetbindingText(cid) if base.Buttons[cid] then base.Buttons[cid]:SetBindingText(base.Saved.ShowBinding, cid) end end function base.InitializeBindings() + local bindingsName = texts.Components.SIBindingName .. base.Addon.Abbreviation .. texts.Helpers.Lowdash + ZO_CreateStringId(bindingsName .. texts.Components.Settings, texts.Components.Settings) for key, _ in ipairs(base.Saved.Bindings) do - local abbreviation = base.Addon.Abbreviation - ZO_CreateStringId("SI_BINDING_NAME_" .. abbreviation .. "_" .. key, abbreviation .. "_" .. key) - end -end - -function base.InitializeReverseBinding() - for keyId, collectibleId in ipairs(base.Saved.Bindings) do - if collectibleId > 0 then - base.Global.ReverseBindings[collectibleId] = keyId - end + ZO_CreateStringId(bindingsName .. key, base.Addon.Abbreviation .. texts.Helpers.Lowdash .. key) end end -function base.GetBindingNameFromCId(cid) - local result = "" - local keyId = base.Global.ReverseBindings[cid] - if keyId then - for _, value in pairs({GetHighestPriorityActionBindingInfoFromName(base.Addon.Abbreviation .. "_" .. keyId)}) do - if value > 0 then - local bindingName = GetKeyName(value) - if result ~= "" then - result = string.format("%s+%s", bindingName, result) - else - result = bindingName - end - end - end - end - return result -end +function base.InitializeReverseBinding() for keyId, collectibleId in ipairs(base.Saved.Bindings) do if collectibleId > 0 then base.Global.ReverseBindings[collectibleId] = keyId end end end \ No newline at end of file diff --git a/CBs_Button.lua b/CBs_Button.lua index 3617c29..adc329b 100644 --- a/CBs_Button.lua +++ b/CBs_Button.lua @@ -3,32 +3,38 @@ Author: Jarth Filename: CBs_Button.lua ]] -- ------------------------------------------------------------------------------------------------- +-- VARIABLES -- +------------------------------------------------------------------------------------------------- +local base = CollectionBars +local texts = base.Texts + +------------------------------------------------------------------------------------------------- -- FUNCTIONS -- ------------------------------------------------------------------------------------------------- CBs_Button = ZO_Object:Subclass() -function CBs_Button:New(base, _type, frame, cId, saved) +function CBs_Button:New(_type, frame, cId, saved) local newB = ZO_Object.New(self) if newB then - local ctrl = CreateControlFromVirtual(_type.Name .. "_Button", frame, "CBs_Button", cId) + local lowdashButton = texts.Helpers.Lowdash .. texts.Components.Button + local ctrl = CreateControlFromVirtual(_type.Name .. lowdashButton, frame, base.Addon.Abbreviation .. lowdashButton, cId) newB.cId = cId - newB.base = base newB.type = _type newB.saved = saved newB.ctrl = ctrl newB.ctrl.cId = cId - newB.button = ctrl:GetNamedChild("Button") + newB.button = ctrl:GetNamedChild(texts.Components.Button) newB.button:SetId(cId) - newB.button.tooltip = _type.Collection[cId].Name + newB.button.tooltip = _type.Category[cId].Name newB.button.CBs = true - newB.icon = ctrl:GetNamedChild("Icon") - newB.cooldownIcon = ctrl:GetNamedChild("CooldownIcon") - newB.cooldownTime = ctrl:GetNamedChild("CooldownTime") - newB.buttonText = ctrl:GetNamedChild("ButtonText") - newB.cooldown = ctrl:GetNamedChild("Cooldown") - newB.cooldownCompleteAnim = ctrl:GetNamedChild("CooldownCompleteAnimation") - newB.status = ctrl:GetNamedChild("Status") + newB.icon = ctrl:GetNamedChild(texts.Components.Icon) + newB.cooldownIcon = ctrl:GetNamedChild(texts.Components.Cooldown .. texts.Components.Icon) + newB.cooldownTime = ctrl:GetNamedChild(texts.Components.Cooldown .. texts.Components.Time) + newB.buttonText = ctrl:GetNamedChild(texts.Components.Button .. texts.Components.Text) + newB.cooldown = ctrl:GetNamedChild(texts.Components.Cooldown) + newB.cooldownCompleteAnim = ctrl:GetNamedChild(texts.Components.Cooldown .. texts.Components.Complete .. texts.Components.Animation) + newB.status = ctrl:GetNamedChild(texts.Components.Status) newB.inCooldown = false newB.showingCooldown = false newB.playSounds = false @@ -42,10 +48,10 @@ function CBs_Button:UpdateAnchor(frame, left, top) self.ctrl:SetAnchor(TOPLEFT, frame, TOPLEFT, left, top) end -function CBs_Button:Setup(base) +function CBs_Button:Setup() self.ctrl:SetHidden(false) - local texture = self.type.Collection[self.cId].EnabledTexture + local texture = self.type.Category[self.cId].EnabledTexture self.icon:SetTexture(texture) self.icon:SetHidden(false) @@ -54,26 +60,18 @@ function CBs_Button:Setup(base) self.cooldownIcon:SetDesaturation(1) end - 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(texts.Action.OnClicked, function() base.Activate(self) end) + self.button:SetHandler(texts.Action.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 + local text = self.type.Category[self.cId].Name ZO_Tooltips_ShowTextTooltip(self.button, self.type.Saved.Tooltip.Position, text) end end) - self.button:SetHandler("OnMouseExit", function() - ZO_Tooltips_HideTextTooltip() - end) + self.button:SetHandler(texts.Action.OnMouseExit, function() ZO_Tooltips_HideTextTooltip() end) end -function CBs_Button:SetShowBindingText(visible) - self.buttonText:SetHidden(not visible) -end +function CBs_Button:SetShowBindingText(visible) self.buttonText:SetHidden(not visible) end function CBs_Button:SetSize(size) self.ctrl:SetHeight(size) @@ -83,45 +81,35 @@ function CBs_Button:SetSize(size) end function CBs_Button:SetBindingText(show, cId) - local keyId = self.base.Global.ReverseBindings[cId] + local keyId = base.Global.ReverseBindings[cId] if self.buttonText ~= nil then ZO_Keybindings_UnregisterLabelForBindingUpdate(self.buttonText) self.buttonText:ClearAnchors() - self.buttonText:SetText("") + self.buttonText:SetText(texts.EmptyString) 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) + ZO_Keybindings_RegisterLabelForBindingUpdate(self.buttonText, base.Addon.Abbreviation .. texts.Helpers.Lowdash .. keyId, false) end end end -function CBs_Button:OnClicked() - if self.usable then - UseCollectible(self.cId) - end -end +function CBs_Button:OnClicked() if self.usable then UseCollectible(self.cId) end end function CBs_Button:UpdateState(forceId, isAttempting) local show = false - if self.saved.IsActiveActivationEnabled then - show = self.cId == forceId and isAttempting or not forceId and IsCollectibleActive(self.cId) - end + if self.saved.IsActiveActivationEnabled then show = self.cId == forceId and isAttempting or not forceId and IsCollectibleActive(self.cId) end self.status:SetHidden(show == false) end function CBs_Button:UpdateUsable() local isShowingCooldown = self.showingCooldown local usable = false - if not isShowingCooldown then - usable = true - end + if not isShowingCooldown then usable = true end - if usable ~= self.usable then - self.usable = usable - end + if usable ~= self.usable then self.usable = usable end end function CBs_Button:RefreshCooldown(remaining, duration, cooldown) @@ -131,9 +119,7 @@ function CBs_Button:RefreshCooldown(remaining, duration, cooldown) self.cooldownTime:SetText(cooldown) end -function CBs_Button:UpdatePlaySounds(playSounds) - self.playSounds = playSounds -end +function CBs_Button:UpdatePlaySounds(playSounds) self.playSounds = playSounds end function CBs_Button:UpdateCooldown(remaining, duration, cooldown) local showCooldown = duration > 0 @@ -143,18 +129,12 @@ function CBs_Button:UpdateCooldown(remaining, duration, cooldown) if showCooldown then self.cooldown:StartCooldown(remaining, duration, CD_TYPE_RADIAL, nil, NO_LEADING_EDGE) - if self.cooldownCompleteAnim.animation then - self.cooldownCompleteAnim.animation:GetTimeline():PlayInstantlyToStart() - end + if self.cooldownCompleteAnim.animation then self.cooldownCompleteAnim.animation:GetTimeline():PlayInstantlyToStart() end self.cooldown:SetHidden(false) - self.ctrl:SetHandler("OnUpdate", function() - self:RefreshCooldown(remaining, duration, cooldown) - end) + self.ctrl:SetHandler(texts.Action.OnUpdate, function() self:RefreshCooldown(remaining, duration, cooldown) end) else if self.showingCooldown then - if self.playSounds then - PlaySound(SOUNDS.ABILITY_READY) - end + if self.playSounds then PlaySound(SOUNDS.ABILITY_READY) end self.cooldownCompleteAnim.animation = self.cooldownCompleteAnim.animation or CreateSimpleAnimation(ANIMATION_TEXTURE, self.cooldownCompleteAnim) self.cooldownCompleteAnim:SetHidden(false) @@ -166,7 +146,7 @@ function CBs_Button:UpdateCooldown(remaining, duration, cooldown) end self.icon.percentComplete = 1 - self.ctrl:SetHandler("OnUpdate", nil) + self.ctrl:SetHandler(texts.Action.OnUpdate, nil) self.cooldown:ResetCooldown() end @@ -186,6 +166,4 @@ function CBs_Button:UpdateCooldown(remaining, duration, cooldown) self:UpdateUsable() end -function CBs_Button:SetHidden(value) - self.ctrl:SetHidden(value) -end +function CBs_Button:SetHidden(value) self.ctrl:SetHidden(value) end diff --git a/CBs_Buttons.lua b/CBs_Buttons.lua index 76bed2f..28240d7 100644 --- a/CBs_Buttons.lua +++ b/CBs_Buttons.lua @@ -6,6 +6,7 @@ Filename: CBs_Buttons.lua -- VARIABLES -- ------------------------------------------------------------------------------------------------- local base = CollectionBars +local texts = base.Texts ------------------------------------------------------------------------------------------------- -- FUNCTIONS -- @@ -14,17 +15,13 @@ function base.SetFrameAndCombineSize(_type) local width, height = base.GetBarWidthHeight(_type) base.SetFrameSizeIfExists(_type.Frame, width, height) - if _type.Saved.IsCombined and not _type.Saved.HideAll then - base.SetFrameSizeIfExists(base.Global.Combine.Frame, width, height) - end + if _type.Saved.IsCombined and not _type.Saved.HideAll then base.SetFrameSizeIfExists(base.Global.Combine.Frame, width, height) end end function base.GetFrame(name, virtual) local frame = GetControl(name) - if frame == nil then - frame = base.WM:CreateControlFromVirtual(name, GuiRoot, virtual) - end + if frame == nil then frame = base.WM:CreateControlFromVirtual(name, GuiRoot, virtual) end return frame end @@ -48,19 +45,17 @@ function base.SetupButtons(_type) _type.IsEmpty = true - for _, _value in ipairs(_type.OrderedCollection) do + for _, _value in ipairs(_type.CategoryOrdered) do local hideButton = true 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(base, _type, frame, _value.Id, base.Saved) - end + if base.Buttons[_value.Id] == nil then base.Buttons[_value.Id] = CBs_Button:New(_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, _value.Id) - base.Buttons[_value.Id]:Setup(base) + base.Buttons[_value.Id]:Setup() base.Buttons[_value.Id]:UpdateAnchor(frame, left, top) base.Buttons[_value.Id]:UpdatePlaySounds(base.Saved.IsAudioEnabled) base.Buttons[_value.Id]:UpdateState() @@ -79,37 +74,29 @@ function base.SetupButtons(_type) end local isHidden = (_type.IsEmpty or not _type.Saved.LabelShow) and not base.Global.EnableSettings or not _type.Saved.Enabled - if _type.Frame then - _type.Frame:SetHidden(isHidden) - end + if _type.Frame then _type.Frame:SetHidden(isHidden) end - if _type.FrameLabel then - _type.FrameLabel:SetHidden(isHidden) - end + if _type.FrameLabel then _type.FrameLabel:SetHidden(isHidden) end end function base.UpdateButtonsState(_type, forceId, isAttemptingActivation) - for _, _value in ipairs(_type.OrderedCollection) do + for _, _value in ipairs(_type.CategoryOrdered) do local button = base.Buttons[_value.Id] - - if button ~= nil then - button:UpdateState(forceId, isAttemptingActivation) - end + if button ~= nil then button:UpdateState(forceId, isAttemptingActivation) end end end function base.UpdateButtonsCooldown(type, remaining, duration, cooldown) for _cId in pairs(type.Saved.Selected) do - if base.Buttons[_cId] ~= nil and type.Collection[_cId] then - base.Buttons[_cId]:UpdateCooldown(remaining, duration, cooldown) - end + local button = base.Buttons[_cId] + if button ~= nil and type.Category[_cId] then button:UpdateCooldown(remaining, duration, cooldown) end end end function base.GetCooldownText(countDown, duration) - local cooldown = "" + local cooldown = texts.EmptyString - if type(duration) == "number" and countDown.StartTime ~= nil then + if type(duration) == texts.Type.Number and countDown.StartTime ~= nil then local startTime = countDown.StartTime or 0 local secondsRemaining = math.max(startTime + duration - GetFrameTimeMilliseconds(), 0) / 1000 cooldown = ZO_FormatTimeAsDecimalWhenBelowThreshold(secondsRemaining, 60) diff --git a/CBs_Constants.lua b/CBs_Constants.lua index 55340ab..ea09a7a 100644 --- a/CBs_Constants.lua +++ b/CBs_Constants.lua @@ -7,17 +7,7 @@ Filename: CBs_Constants.lua ------------------------------------------------------------------------------------------------- CollectionBars = { WM = GetWindowManager(), - Addon = { - Name = "CollectionBars", - DisplayName = "Collection Bars", - Abbreviation = "CBs", - Version = 1.0, - MinorVersion = 0.7, - Command = "/cb_menu", - SettingsSlash = "/cb", - Author = "Jarth", - Website = "" - }, + Addon = {Name = "CollectionBars", DisplayName = "Collection Bars", Abbreviation = "CBs", Version = 1.0, MinorVersion = 0.8, SettingsSlash = "/cb", Author = "Jarth"}, Buttons = {}, Default = { BarDepth = 5, @@ -34,20 +24,39 @@ CollectionBars = { ShowBarInStore = false, SnapSize = 5, ShowBinding = true, - Bindings = {[1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0, [10] = 0}, + Bindings = { + [1] = 0, + [2] = 0, + [3] = 0, + [4] = 0, + [5] = 0, + [6] = 0, + [7] = 0, + [8] = 0, + [9] = 0, + [10] = 0, + [11] = 0, + [12] = 0, + [13] = 0, + [14] = 0, + [15] = 0, + [16] = 0, + [17] = 0, + [18] = 0, + [19] = 0, + [20] = 0 + }, IsAudioEnabled = true, IsActiveActivationEnabled = true, - Combine = {BarDepth = 0, BarWidth = 0, X = CENTER, Y = CENTER, Display = "CombineBar", Label = {OffsetX = 0, OffsetY = 0, Position = BOTTOMLEFT, PositionTarget = TOPLEFT}}, - UseLAMMenu = true + Combine = {BarDepth = 0, BarWidth = 0, X = CENTER, Y = CENTER, Display = "CombineBar", Label = {OffsetX = 0, OffsetY = 0, Position = BOTTOMLEFT, PositionTarget = TOPLEFT}} }, Global = { - HideAllId = "CBs_HideAll", EnableSettings = false, IsMoveEnabled = false, ReverseBindings = {}, SettingsFrame = nil, SettingsList = nil, - SettingsFilters = {["CollectionTypes"] = "Collection Types", ["Selection"] = "Collectibles", ["Collection"] = "Collection bar", ["General"] = "General", ["Combined"] = "Combined bar"}, + SettingsFilters = {["Categories"] = "Categories", ["Selection"] = "Collectibles", ["Category"] = "Category", ["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"}, AvailableFonts = {"ZoFontGameSmall", "ZoFontGameLarge", "ZoFontGameLargeBold", "ZoFontGameLargeBoldShadow", "ZoFontHeader", "ZoFontHeader2", "ZoFontHeader3", "ZoFontHeader4"}, @@ -63,79 +72,179 @@ CollectionBars = { }, HighestUnlocked = 0 }, - Type = {}, - TypeOrdered = {} + Types = {}, + TypesOrdered = {}, + Texts = { + Action = { + UpdateColor = "UpdateColor", + UpdateText = "UpdateText", + OnClicked = "OnClicked", + OnTextChanged = "OnTextChanged", + OnValueChanged = "OnValueChanged", + OnMouseEnter = "OnMouseEnter", + OnMouseExit = "OnMouseExit", + OnMouseDown = "OnMouseDown", + OnMouseUp = "OnMouseUp", + OnUpdate = "OnUpdate", + }, + Font = {ZoFontWinT1 = "ZoFontWinT1", ZoFontWinH4 = "ZoFontWinH4"}, + Format = {Number = "%.2f", Decimal = "%d", Comma = "%s,%s"}, + Components = { + Label = "Label", + Global = "Global", + Checkbox = "Checkbox", + Dropdown = "Dropdown", + Slider = "Slider", + EditBox = "EditBox", + Title = "Title", + Divider = "Divider", + Icon = "Icon", + Name = "Name", + Button = "Button", + Close = "Close", + Status = "Status", + Move = "Move", + Refresh = "Refresh", + Cooldown = "Cooldown", + Time = "Time", + Settings = "Settings", + Complete = "Complete", + Animation = "Animation", + Text = "Text", + Toggle = "Toggle", + BG = "BG", + Combine = "Combine", + Top = "Top", + Left = "Left", + Center = "Center", + Value = "Value", + Frame = "Frame", + HideAll = "HideAll", + Parent = "$(parent)", + Default = "Default", + Marker = "Marker", + Selection = "Selection", + Category = "Category", + Categories = "Categories", + List = "List", + Row = "Row", + General = "General", + Combined = "Combined", + Account = "Account", + Character = "Character", + ZOOptions = "ZO_Options_", + SIBindingName = "SI_BINDING_NAME_" + }, + Location = {Bottom = "bottom", Center = "center", Left = "left", Right = "right", Top = "top"}, + Tooltip = {Main = "Description: %s \nHint: %s"}, + EmptyString = "", + Helpers = {Lowdash = "_", Minus = "-", Plus = "+", Space = " ", Dot = ".", Comma = ","}, + Settings = {ToggleMoveFrameText = "Toggle move frame", ReloadText = "Reload list of 'Collectibles'\nHint: Usefull after gaining a new collectible)"}, + Type = {Number = "number", Empty = "empty", BarDepth = "BarDepth", BarWidth = "BarWidth"} + } } ------------------------------------------------------------------------------------------------- -- FUNCTIONS -- ------------------------------------------------------------------------------------------------- -function CollectionBars.GenerateCollectionTypes() - local setupElements = { - [1] = {Name = "Assistants", Display = "Assistants", TypeId = COLLECTIBLE_CATEGORY_TYPE_ASSISTANT}, - [2] = {Name = "Mementos", Display = "Mementos", TypeId = COLLECTIBLE_CATEGORY_TYPE_MEMENTO}, - [3] = {Name = "Mounts", Display = "Mounts", TypeId = COLLECTIBLE_CATEGORY_TYPE_MOUNT}, - [4] = {Name = "Vanity_Pets", Display = "Non-Combat Pets", TypeId = COLLECTIBLE_CATEGORY_TYPE_VANITY_PET}, - [5] = {Name = "Ability_Skins", Display = "Special", TypeId = COLLECTIBLE_CATEGORY_TYPE_ABILITY_SKIN}, - [6] = {Name = "Hats", Display = "Hats", TypeId = COLLECTIBLE_CATEGORY_TYPE_HAT}, - [7] = {Name = "Head_Markings", Display = "Head Markings", TypeId = COLLECTIBLE_CATEGORY_TYPE_HEAD_MARKING}, - [8] = {Name = "Facial_Accessories", Display = "Major Adornments", TypeId = COLLECTIBLE_CATEGORY_TYPE_FACIAL_ACCESSORY}, - [9] = {Name = "Costumes", Display = "Costumes", TypeId = COLLECTIBLE_CATEGORY_TYPE_COSTUME}, - [10] = {Name = "Body_Markings", Display = "Body Markings", TypeId = COLLECTIBLE_CATEGORY_TYPE_BODY_MARKING}, - [11] = {Name = "Skins", Display = "Skins", TypeId = COLLECTIBLE_CATEGORY_TYPE_SKIN}, - [12] = {Name = "Personalities", Display = "Personalities", TypeId = COLLECTIBLE_CATEGORY_TYPE_PERSONALITY}, - [13] = {Name = "Polymorph", Display = "Polymorphs", TypeId = COLLECTIBLE_CATEGORY_TYPE_POLYMORPH}, - [14] = {Name = "Emotes", Display = "Emotes", TypeId = COLLECTIBLE_CATEGORY_TYPE_EMOTE}, - [15] = {Name = "Hairs", Display = "Hairs", TypeId = COLLECTIBLE_CATEGORY_TYPE_HAIR}, - [16] = {Name = "Facial_Hair_Horns", Display = "Facial_Hair_Horns", TypeId = COLLECTIBLE_CATEGORY_TYPE_FACIAL_HAIR_HORNS}, - [17] = {Name = "Piercing_Jewelry", Display = "Piercing_Jewelry", TypeId = COLLECTIBLE_CATEGORY_TYPE_PIERCING_JEWELRY} - } +function CollectionBars.GenerateCategories() + CollectionBars.Types = {} + + for _, categoryData in ZO_COLLECTIBLE_DATA_MANAGER:CategoryIterator({ZO_CollectibleCategoryData.HasShownCollectiblesInCollection}) do + if categoryData ~= nil and categoryData:IsStandardCategory() then + local categoryType = CollectionBars.GetCategoryType(categoryData) + if categoryType ~= nil and CollectionBars.CategoryHasUsableCollectible(categoryData) then + CollectionBars.AddCategory(categoryType, categoryData) + else + if categoryData:IsTopLevelCategory() and CollectionBars.SubCategoryHasUsableCollectible(categoryData) then + local parentIcons = {categoryData:GetKeyboardIcons()} + CollectionBars.AddCategory(nil, categoryData, parentIcons, true) + for _, subcategoryData in categoryData:SubcategoryIterator({ZO_CollectibleCategoryData.HasShownCollectiblesInCollection}) do + categoryType = CollectionBars.GetCategoryType(subcategoryData) + if categoryType ~= nil and subcategoryData ~= nil and subcategoryData:HasShownCollectiblesInCollection() then + CollectionBars.AddCategory(categoryType, subcategoryData, parentIcons, false, categoryData:GetFormattedName()) + end + end + end + end + end + end +end + +function CollectionBars.GetCategoryType(categoryData) + local categoryType = nil + local collectibles = categoryData:GetCollectibleDataBySpecializedSort() + if collectibles ~= nil and collectibles[1] ~= nil then categoryType = collectibles[1]:GetCategoryType() end - CollectionBars.Type = {} - local collectionIndex = 1 - for _, setupElement in ipairs(setupElements) do - local isUsable = IsCollectibleCategoryUsable(setupElement.TypeId) - if isUsable then - CollectionBars.Type[setupElement.Name] = { - Collection = {}, - OrderedCollection = {}, - TypeId = setupElement.TypeId, - Unlocked = 0, - Name = setupElement.Name, - Total = 0, - IsUsable = 0, - FrameLabel = nil, - FrameLabelButton = nil, - FrameToggleSettings = nil, - MoveFrame = nil, - Frame = nil, - Count = nil, - BarDepth = 0, - BarWidth = nil, - Cooldown = {Event = "Cooldown" .. setupElement.Name, CollectibleId = nil, StartTime = nil, Tick = 100}, - Fragment = nil - } - CollectionBars.TypeOrdered[collectionIndex] = CollectionBars.Type[setupElement.Name] - collectionIndex = collectionIndex + 1 + return categoryType +end + +function CollectionBars.AddCategory(categoryType, categoryData, parentIcons, hasChildren, parentKey) + local categoryName = categoryData:GetFormattedName() + local icon = parentIcons or {categoryData:GetKeyboardIcons()} + if icon ~= nil and icon[1] == ZO_NO_TEXTURE_FILE then icon = nil end + CollectionBars.Types[categoryName] = { + Category = {}, + CategoryOrdered = {}, + CategoryType = categoryType, + Icon = icon, + HasChildren = hasChildren, + ParentKey = parentKey, + Unlocked = 0, + Name = categoryName, + Total = 0, + IsUsable = 0, + FrameLabel = nil, + FrameLabelButton = nil, + FrameToggleSettings = nil, + MoveFrame = nil, + Frame = nil, + Count = nil, + BarDepth = 0, + BarWidth = nil, + Cooldown = {Event = "Cooldown" .. categoryName, CollectibleId = nil, StartTime = nil, Tick = 100}, + Fragment = nil + } + table.insert(CollectionBars.TypesOrdered, CollectionBars.Types[categoryName]) + CollectionBars.Default[categoryName] = { + Selected = {}, + Enabled = false, + HideAll = true, + HideAllEnabled = true, + MenuShowDisabled = false, + Tooltip = {Show = true, Position = TOP}, + Horizontal = true, + BarDepth = 0, + BarWidth = 0, + X = CENTER, + Y = CENTER, + Display = categoryName, + LabelShow = true, + Label = {OffsetX = 0, OffsetY = 0, Height = 19, Width = 75, Font = "ZoFontGameSmall", Position = BOTTOMLEFT, PositionTarget = TOPLEFT}, + IsCombined = true, + ShowChildren = true + } +end - CollectionBars.Default[setupElement.Name] = { - Selected = {}, - Enabled = false, - HideAll = true, - HideAllEnabled = true, - MenuShowDisabled = false, - Tooltip = {Show = true, Position = TOP}, - Horizontal = true, - BarDepth = 0, - BarWidth = 0, - X = CENTER, - Y = CENTER, - Display = setupElement.Display, - LabelShow = true, - Label = {OffsetX = 0, OffsetY = 0, Height = 19, Width = 75, Font = "ZoFontGameSmall", Position = BOTTOMLEFT, PositionTarget = TOPLEFT}, - IsCombined = true - } +function CollectionBars.CategoryHasUnlockedValidAndUsableCollectible(categoryData) + if GetTotalCollectiblesByCategoryType(categoryData:GetId()) > 0 then + for _, collectibleData in ZO_CollectibleCategoryData.CollectibleIterator(categoryData, {ZO_CollectibleData.IsShownInCollection}) do + if collectibleData:IsUnlocked() and collectibleData:IsValidForPlayer() and collectibleData:IsUsable() then return true end end end + return false +end + +function CollectionBars.CategoryHasUsableCollectible(categoryData) + if categoryData ~= nil and CollectionBars.CategoryHasUnlockedValidAndUsableCollectible(categoryData) then return true end + return false +end + +function CollectionBars.SubCategoryHasUsableCollectible(categoryData) + for _, subcategoryData in categoryData:SubcategoryIterator({ZO_CollectibleCategoryData.HasShownCollectiblesInCollection}) do + local categoryType = CollectionBars.GetCategoryType(subcategoryData) + if categoryType ~= nil and subcategoryData ~= nil and CollectionBars.CategoryHasUnlockedValidAndUsableCollectible(subcategoryData) then return true end + end + return false end diff --git a/CBs_Fragment.lua b/CBs_Fragment.lua index 2a4a08b..b3b98ff 100644 --- a/CBs_Fragment.lua +++ b/CBs_Fragment.lua @@ -6,50 +6,33 @@ Filename: CBs_Fragment.lua -- VARIABLES -- ------------------------------------------------------------------------------------------------- local base = CollectionBars +local texts = base.Texts ------------------------------------------------------------------------------------------------- -- FUNCTIONS -- ------------------------------------------------------------------------------------------------- function base.UpdateFragments(fragmentType) - for _, _type in pairs(base.Type) do - if _type.Saved.Enabled then - base.UpdateFragment(_type, fragmentType) - end - end + for _, _type in pairs(base.Types) do if _type.Saved.Enabled then base.UpdateFragment(_type, fragmentType) end end base.UpdateFragment(base.Global.Combine, fragmentType) end function base.UpdateFragment(_type, fragmentType) local currentScene = SCENE_MANAGER:GetCurrentScene() - local isHidden = (currentScene == nil or currentScene:GetName() == "empty") and not base.Saved.ShowBarOnHud + local isHidden = (currentScene == nil or currentScene:GetName() == texts.Type.Empty) and not base.Saved.ShowBarOnHud - if _type.Fragment == nil then - _type.Fragment = ZO_HUDFadeSceneFragment:New(_type.Frame) - end + if _type.Fragment == nil then _type.Fragment = ZO_HUDFadeSceneFragment:New(_type.Frame) end for key, scene in pairs(base.Global.ScenePairs) do if (not fragmentType or key == fragmentType) and scene ~= nil then if base.Saved[key] then - if not scene:HasFragment(_type.Fragment) then - scene:AddFragment(_type.Fragment) - end + if not scene:HasFragment(_type.Fragment) then scene:AddFragment(_type.Fragment) end else scene:RemoveFragment(_type.Fragment) end end - if scene == currentScene then - isHidden = isHidden or not base.Saved[key] - end + if scene == currentScene then isHidden = isHidden or not base.Saved[key] end end _type.Frame:SetHidden(isHidden) end -function base.RemoveFragments(_type) - if _type.Fragment ~= nil then - for _, scene in pairs(base.Global.ScenePairs) do - if scene ~= nil then - scene:RemoveFragment(_type.Fragment) - end - end - end -end +function base.RemoveFragments(_type) if _type.Fragment ~= nil then for _, scene in pairs(base.Global.ScenePairs) do if scene ~= nil then scene:RemoveFragment(_type.Fragment) end end end end diff --git a/CBs_Helpers.lua b/CBs_Helpers.lua index 6d89c5e..f67d493 100644 --- a/CBs_Helpers.lua +++ b/CBs_Helpers.lua @@ -6,6 +6,7 @@ Filename: CBs_Helpers.lua -- VARIABLES -- ------------------------------------------------------------------------------------------------- local base = CollectionBars +local texts = base.Texts ------------------------------------------------------------------------------------------------- -- FUNCTIONS -- @@ -13,23 +14,23 @@ local base = CollectionBars function base.GetLocationValue(value) local result - if value == "bottom" then + if value == texts.Location.Bottom then result = BOTTOM - elseif value == "bottomleft" then + elseif value == (texts.Location.Bottom .. texts.Location.Left) then result = BOTTOMLEFT - elseif value == "bottomright" then + elseif value == (texts.Location.Bottom .. texts.Location.Right) then result = BOTTOMRIGHT - elseif value == "center" then + elseif value == texts.Location.Center then result = CENTER - elseif value == "left" then + elseif value == texts.Location.Left then result = LEFT - elseif value == "right" then + elseif value == texts.Location.Right then result = RIGHT - elseif value == "top" then + elseif value == texts.Location.Top then result = TOP - elseif value == "topleft" then + elseif value == (texts.Location.Top .. texts.Location.Left) then result = TOPLEFT - elseif value == "topright" then + elseif value == (texts.Location.Top .. texts.Location.Right) then result = TOPRIGHT end @@ -40,23 +41,23 @@ function base.GetLocationText(value) local result if value == BOTTOM then - result = "bottom" + result = texts.Location.Bottom elseif value == BOTTOMLEFT then - result = "bottomleft" + result = (texts.Location.Bottom .. texts.Location.Left) elseif value == BOTTOMRIGHT then - result = "bottomright" + result = (texts.Location.Bottom .. texts.Location.Right) elseif value == CENTER then - result = "center" + result = texts.Location.Center elseif value == LEFT then - result = "left" + result = texts.Location.Left elseif value == RIGHT then - result = "right" + result = texts.Location.Right elseif value == TOP then - result = "top" + result = texts.Location.Top elseif value == TOPLEFT then - result = "topleft" + result = (texts.Location.Top .. texts.Location.Left) elseif value == TOPRIGHT then - result = "topright" + result = (texts.Location.Top .. texts.Location.Right) end return result @@ -77,12 +78,12 @@ function base.RestorePosition(_type) end function base.GetLabelPostFix(_type) - local postFix = "" + local postFix = texts.EmptyString if _type.Saved.HideAllEnabled then if not _type.Saved.HideAll then - postFix = " -" + postFix = texts.Helpers.Space .. texts.Helpers.Minus else - postFix = " +" + postFix = texts.Helpers.Space .. texts.Helpers.Plus end end return postFix @@ -90,8 +91,8 @@ end function base.IsAllSelected(_type) local isAllSelected = true - for _, collection in pairs(_type.Collection) do - if _type.Saved.Selected[collection.Id] == nil then + for _, collectible in pairs(_type.Category) do + if _type.Saved.Selected[collectible.Id] == nil then isAllSelected = false break end @@ -101,80 +102,68 @@ function base.IsAllSelected(_type) end function base.SelectAll(_type, newValue) - for _, collection in pairs(_type.Collection) do + for _, collectible in pairs(_type.Category) do if newValue == true then - _type.Saved.Selected[collection.Id] = newValue + _type.Saved.Selected[collectible.Id] = newValue else - _type.Saved.Selected[collection.Id] = nil + _type.Saved.Selected[collectible.Id] = nil end end end function base.GetVersion(showMinor) - if showMinor == false or base.Addon.MinorVersion == nil then - return tostring(base.Addon.Version) - end + if showMinor == false or base.Addon.MinorVersion == nil then return tostring(base.Addon.Version) end - return string.format("%s.%s", tostring(base.Addon.Version), tostring(base.Addon.MinorVersion)) + return tostring(base.Addon.Version) .. texts.Helpers.Dot .. tostring(base.Addon.MinorVersion) end function base.SetAndUpdateAccountSettings(newUseAccountSettings) - base.Saved = ZO_SavedVars:New(base.Addon.Name .. "_Character", base.Addon.Version, nil, base.Default) + local accountKey = base.Addon.Name .. texts.Helpers.Lowdash .. texts.Components.Account + base.Saved = ZO_SavedVars:NewAccountWide(accountKey, base.Addon.Version, nil, base.Default) - if newUseAccountSettings ~= nil then - base.Saved.UseAccountSettings = newUseAccountSettings - end + if newUseAccountSettings ~= nil then base.Saved.UseAccountSettings = newUseAccountSettings end + local useAccountSettings = base.Saved.UseAccountSettings - if base.Saved.UseAccountSettings then - base.Saved = ZO_SavedVars:NewAccountWide(base.Addon.Name .. "_Account", base.Addon.Version, nil, base.Default) + if not useAccountSettings then + local characterKey = base.Addon.Name .. texts.Helpers.Lowdash .. texts.Components.Character + base.Saved = ZO_SavedVars:New(characterKey, base.Addon.Version, nil, base.Default) + base.Saved.UseAccountSettings = useAccountSettings 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) + local accountKey = base.Addon.Name .. texts.Helpers.Lowdash .. texts.Components.Account + _G[accountKey] = nil + base.Saved = ZO_SavedVars:NewAccountWide(accountKey, 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) + local characterKey = base.Addon.Name .. texts.Helpers.Lowdash .. texts.Components.Character + _G[characterKey] = nil + base.Saved = ZO_SavedVars:New(characterKey, base.Addon.Version, nil, base.Default) end end function base.GetBarWidthHeight(_type) local width, height, count = 0, 0, 0 - if not _type.Saved.HideAll then - for key, value in pairs(_type.Saved.Selected) do - if IsCollectibleUnlocked(key) and IsCollectibleValidForPlayer(key) and value then - count = count + 1 - end - end - end + if not _type.Saved.HideAll then for key, value in pairs(_type.Saved.Selected) do if IsCollectibleUnlocked(key) and IsCollectibleValidForPlayer(key) and value then count = count + 1 end end end local function GetBarMaxCount(type) local barConstraintXY = _type.Saved[type] - if _type.Saved.IsCombined then - barConstraintXY = base.Saved.Combine[type] - end + if _type.Saved.IsCombined then barConstraintXY = base.Saved.Combine[type] end - if barConstraintXY == 0 then - barConstraintXY = base.Saved[type] - end + if barConstraintXY == 0 then barConstraintXY = base.Saved[type] end - if count < barConstraintXY then - barConstraintXY = count - end + if count < barConstraintXY then barConstraintXY = count end return barConstraintXY end - _type.BarDepth, _type.BarWidth = GetBarMaxCount("BarDepth"), GetBarMaxCount("BarWidth") + _type.BarDepth, _type.BarWidth = GetBarMaxCount(texts.Type.BarDepth), GetBarMaxCount(texts.Type.BarWidth) if count > 0 then local barWidth = math.ceil(count / _type.BarDepth) local maxBarWidth = _type.BarWidth - if maxBarWidth > 0 and maxBarWidth < barWidth then - barWidth = maxBarWidth - end + if maxBarWidth > 0 and maxBarWidth < barWidth then barWidth = maxBarWidth end local isHorizontal = _type.Saved.Horizontal width = base.Saved.ButtonXY * (not isHorizontal and barWidth or _type.BarDepth) height = base.Saved.ButtonXY * (isHorizontal and barWidth or _type.BarDepth) @@ -191,12 +180,8 @@ function base.SetFrameSizeIfExists(frame, width, height) end function base.HasAny(array) - for _ in pairs(array) do - return true - end + for _ in pairs(array) do return true end return false end -function base.SetControlText(control, text) - control.SetText(control, text) -end +function base.SetControlText(control, text) control.SetText(control, text) end diff --git a/CBs_Labels.lua b/CBs_Labels.lua index cfcbeb7..cd22911 100644 --- a/CBs_Labels.lua +++ b/CBs_Labels.lua @@ -6,31 +6,29 @@ Filename: CBs_Labels.lua -- VARIABLES -- ------------------------------------------------------------------------------------------------- local base = CollectionBars +local texts = base.Texts ------------------------------------------------------------------------------------------------- -- FUNCTIONS -- ------------------------------------------------------------------------------------------------- function base.SetupLabel(_type) + local hideAllId = base.Addon.Abbreviation .. texts.Helpers.Lowdash .. texts.Components.HideAll if _type.FrameLabel == nil then - _type.FrameLabel = GetControl(base.Global.HideAllId .. _type.Name) - if _type.FrameLabel == nil then - _type.FrameLabel = base.WM:CreateControlFromVirtual(base.Global.HideAllId, _type.Frame, base.Global.HideAllId, _type.Name) - end + _type.FrameLabel = GetControl(hideAllId .. _type.Name) + if _type.FrameLabel == nil then _type.FrameLabel = base.WM:CreateControlFromVirtual(hideAllId, _type.Frame, hideAllId, _type.Name) end end _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") + _type.FrameToggleSettings = GetControl(hideAllId .. _type.Name .. texts.Components.Toggle .. texts.Components.Settings) + _type.FrameLabelButton = GetControl(hideAllId .. _type.Name .. texts.Components.Button) if _type.FrameLabelButton ~= nil then - _type.FrameLabelButton:SetHandler("OnClicked", function(_, button) + _type.FrameLabelButton:SetHandler(texts.Action.OnClicked, function(_, button) if button == MOUSE_BUTTON_INDEX_RIGHT then base.ToggleEnableSettings() elseif button == MOUSE_BUTTON_INDEX_LEFT and _type.Saved.HideAllEnabled or _type.Saved.IsCombined then _type.Saved.HideAll = not _type.Saved.HideAll - if _type.Saved.IsCombined then - base.HideOthers(_type) - end + if _type.Saved.IsCombined then base.HideOthers(_type) end base.RestoreFrame(_type) base.RestoreCombine() end @@ -48,9 +46,7 @@ function base.RestoreLabel(_type) frameLabel:ClearAnchors() frameLabel:SetHeight(label.Height) frameLabel:SetWidth(label.Width) - if not _type.Saved.IsCombined then - frameLabel:SetAnchor(label.Position, _type.Frame, label.PositionTarget, label.OffsetX, label.OffsetY) - end + if not _type.Saved.IsCombined then frameLabel:SetAnchor(label.Position, _type.Frame, label.PositionTarget, label.OffsetX, label.OffsetY) end frameLabel:SetHidden(not _type.Saved.LabelShow and not _type.Saved.IsCombined and not base.Global.EnableSettings) end @@ -64,9 +60,7 @@ function base.RestoreLabel(_type) end local frameLabelToggleSettings = _type.FrameToggleSettings - if frameLabelToggleSettings ~= nil then - frameLabelToggleSettings:SetHidden(false) - end + if frameLabelToggleSettings ~= nil then frameLabelToggleSettings:SetHidden(false) end end function base.RemoveLabel(_type) @@ -75,20 +69,16 @@ function base.RemoveLabel(_type) _type.FrameLabel:SetHidden(true) end - if _type.FrameLabelButton ~= nil then - _type.FrameLabelButton:SetHidden(true) - end + if _type.FrameLabelButton ~= nil then _type.FrameLabelButton:SetHidden(true) end - if _type.FrameToggleSettings ~= nil then - _type.FrameToggleSettings:SetHidden(true) - end + if _type.FrameToggleSettings ~= nil then _type.FrameToggleSettings:SetHidden(true) end end function base.RestoreCombineLabels() local combineLabel = base.Saved.Combine.Label local width = 0 local height = 0 - for _, _type in pairs(base.TypeOrdered) do + for _, _type in pairs(base.TypesOrdered) do 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) @@ -100,9 +90,7 @@ function base.RestoreCombineLabels() _type.FrameLabel:SetAnchor(TOPLEFT, base.Global.Combine.HideAll, TOPLEFT, width, offsetY) width = width + _type.FrameLabel:GetWidth() local labelHeight = _type.FrameLabel:GetHeight() - if labelHeight > height then - height = labelHeight - end + if labelHeight > height then height = labelHeight end end end end diff --git a/CBs_Menu.lua b/CBs_Menu.lua deleted file mode 100644 index fc83e8b..0000000 --- a/CBs_Menu.lua +++ /dev/null @@ -1,710 +0,0 @@ ---[[ -Author: Jarth -Filename: CBs_Menu.lua -]] -- -------------------------------------------------------------------------------------------------- --- Libraries -- -------------------------------------------------------------------------------------------------- -local LAM2 = LibAddonMenu2 - -------------------------------------------------------------------------------------------------- --- VARIABLES -- -------------------------------------------------------------------------------------------------- -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 - }) - - local whenOnTheBar = "When ON the bar will show the bar " - 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" - - local optionsData = { - {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", - default = base.Default.UseAccountSettings, - warning = "Reload to see full effect", - requiresReload = true, - getFunc = function() - return base.Saved.UseAccountSettings - end, - setFunc = function(newValue) - 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.", - func = function() - 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 = "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", - default = function() - return base.Global.IsMoveEnabled - end, - getFunc = function() - return base.Global.IsMoveEnabled - end, - setFunc = function(newValue) - base.Global.IsMoveEnabled = newValue - base.RestoreFrames() - end - }, { - type = "slider", - name = "Choose snap size when moving", - default = base.Default.SnapSize, - getFunc = function() - return base.Saved.SnapSize - end, - setFunc = function(value) - base.Saved.SnapSize = value - base.RestoreFrames() - end, - min = 1, - max = 10 - }, { - type = "slider", - name = "Choose default bar depth (number of rows/columns)", - default = base.Default.BarDepth, - getFunc = function() - return base.Saved.BarDepth - end, - setFunc = function(value) - base.Saved.BarDepth = value - base.RestoreFrames() - end, - min = 1, - max = base.Global.HighestUnlocked - }, { - type = "slider", - name = "Choose max bar height (number of inverse rows/columns)", - default = base.Default.BarWidth, - getFunc = function() - return base.Saved.BarWidth - end, - setFunc = function(value) - base.Saved.BarWidth = value - base.RestoreFrames() - 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", - default = base.Default.ShowBinding, - getFunc = function() - return base.Saved.ShowBinding - end, - setFunc = function(newValue) - base.Saved.ShowBinding = newValue - base.RestoreFrames() - end, - width = "half" - }, { - type = "slider", - name = "Button size", - default = ZO_GAMEPAD_ACTION_BUTTON_SIZE, - getFunc = function() - return base.Saved.ButtonXY - end, - setFunc = function(value) - base.Saved.ButtonXY = value - base.RestoreFrames() - end, - min = 1, - max = 100, - width = "half" - }, {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", - default = base.Default.ShowBarOnHud, - getFunc = function() - return base.Saved.ShowBarOnHud - end, - setFunc = function(newValue) - 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", - default = base.Default.ShowBarOnHudUI, - getFunc = function() - return base.Saved.ShowBarOnHudUI - end, - setFunc = function(newValue) - base.Saved.ShowBarOnHudUI = newValue - base.UpdateFragments("ShowBarOnHudUI") - end - }, { - type = "checkbox", - name = "Show bar " .. "in menu", - tooltip = whenOnTheBar .. "in menu", - default = base.Default.ShowBarInMenu, - getFunc = function() - return base.Saved.ShowBarInMenu - end, - setFunc = function(newValue) - base.Saved.ShowBarInMenu = newValue - base.UpdateFragments("ShowBarInMenu") - end - }, { - type = "checkbox", - name = "Show bar " .. "in the inventory", - tooltip = whenOnTheBar .. "in the inventory", - default = base.Default.ShowBarInInventory, - getFunc = function() - return base.Saved.ShowBarInInventory - end, - setFunc = function(newValue) - base.Saved.ShowBarInInventory = newValue - base.UpdateFragments("ShowBarInInventory") - end - }, { - type = "checkbox", - name = "Show bar " .. "in interactions", - tooltip = whenOnTheBar .. "in interactions", - default = base.Default.ShowBarInInteract, - getFunc = function() - return base.Saved.ShowBarInInteract - end, - setFunc = function(newValue) - base.Saved.ShowBarInInteract = newValue - base.UpdateFragments("ShowBarInInteract") - end - }, { - type = "checkbox", - name = "Show bar " .. "at a bank", - tooltip = whenOnTheBar .. "at a bank", - default = base.Default.ShowBarInBank, - getFunc = function() - return base.Saved.ShowBarInBank - end, - setFunc = function(newValue) - base.Saved.ShowBarInBank = newValue - base.UpdateFragments("ShowBarInBank") - end - }, { - type = "checkbox", - name = "Show bar " .. "at a fence", - tooltip = whenOnTheBar .. "at a fence", - default = base.Default.ShowBarInFence, - getFunc = function() - return base.Saved.ShowBarInFence - end, - setFunc = function(newValue) - base.Saved.ShowBarInFence = newValue - base.UpdateFragments("ShowBarInFence") - end - }, { - type = "checkbox", - name = "Show bar " .. "at a store", - tooltip = whenOnTheBar .. "at a store", - default = base.Default.ShowBarInStore, - getFunc = function() - return base.Saved.ShowBarInStore - end, - setFunc = function(newValue) - 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 = "checkbox", - name = "Show active and activation", - tooltip = "When ON the active collectibles will be highlighted, and activation animation will display", - default = function() - return base.Saved.IsActiveActivationEnabled - end, - getFunc = function() - return base.Saved.IsActiveActivationEnabled - end, - setFunc = function(newValue) - 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 = "slider", - name = "Display name offset horizontal (X)", - default = base.Default.Combine.Label.OffsetX, - getFunc = function() - return base.Saved.Combine.Label.OffsetX - end, - setFunc = function(value) - base.Saved.Combine.Label.OffsetX = value - base.RestoreCombineLabels() - end, - min = -500, - max = 500, - width = "half" - }, { - type = "slider", - name = "Display name offset vertical (Y)", - default = base.Default.Combine.Label.OffsetY, - getFunc = function() - return base.Saved.Combine.Label.OffsetY - end, - setFunc = function(value) - base.Saved.Combine.Label.OffsetY = value - base.RestoreCombineLabels() - end, - min = -500, - max = 500, - width = "half" - }, { - type = "dropdown", - name = "Display name anchor position on button", - tooltip = "Select display name anchor position on the button", - choices = base.Global.ChoiceLocations, - default = base.Default.Combine.Label.PositionTarget, - getFunc = function() - return base.GetLocationText(base.Saved.Combine.Label.PositionTarget) - end, - setFunc = function(value) - base.Saved.Combine.Label.PositionTarget = base.GetLocationValue(value) - base.RestoreCombineLabels() - end, - width = "half" - }, { - type = "dropdown", - name = "Display name anchor position on label", - tooltip = "Select display name anchor position on the label", - choices = base.Global.ChoiceLocations, - default = base.Default.Combine.Label.Position, - getFunc = function() - return base.GetLocationText(base.Saved.Combine.Label.Position) - end, - setFunc = function(value) - base.Saved.Combine.Label.Position = base.GetLocationValue(value) - base.RestoreCombineLabels() - end, - width = "half" - }, { - 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, - getFunc = function() - return base.Saved.Combine.BarDepth - end, - setFunc = function(value) - base.Saved.Combine.BarDepth = value - base.RestoreFrames() - end, - min = 0, - max = base.Global.HighestUnlocked - }, { - type = "slider", - name = "Choose max bar height (number of inverse rows/columns)", - default = base.Default.BarWidth, - getFunc = function() - return base.Saved.Combine.BarWidth - end, - setFunc = function(value) - base.Saved.Combine.BarWidth = value - base.RestoreFrames() - end, - min = 0, - 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"}} - } - } - - 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.IsCombined then - base.RestoreCombineLabels() - end - end - }) - end - - local function AppendCollectionMenuItem(controlIndex, _type) - local typeName = _type.Name - local controls = { - { - type = "checkbox", - name = "Include " .. typeName .. " in combine bar", - tooltip = "When ON " .. typeName .. " will be attached to a combined bar", - default = base.Default[typeName].Combine, - getFunc = function() - return _type.Saved.IsCombined - end, - setFunc = function(newValue) - _type.Saved.IsCombined = newValue - base.RestoreFrame(_type) - base.RestoreCombineLabels() - end - }, {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", - default = base.Default[typeName].Tooltip.Show, - getFunc = function() - return _type.Saved.Tooltip.Show - end, - setFunc = function(newValue) - _type.Saved.Tooltip.Show = newValue - base.SetupButtons(_type) - end, - width = "half" - }, { - type = "dropdown", - name = "Show tooltip anchor position", - tooltip = "Select tooltip anchor position\n" .. disabledWhenTooltipIsHidden, - choices = base.Global.ChoiceLocations, - default = base.Default[typeName].Tooltip.Position, - disabled = function() - return not _type.Saved.Tooltip.Show - end, - getFunc = function() - return base.GetLocationText(_type.Saved.Tooltip.Position) - end, - setFunc = function(value) - _type.Saved.Tooltip.Position = base.GetLocationValue(value) - base.SetupButtons(_type) - end, - width = "half" - }, {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.IsCombined - end, - default = base.Default[typeName].HideAllEnabled, - getFunc = function() - return _type.Saved.IsCombined or _type.Saved.HideAllEnabled - end, - setFunc = function(newValue) - if (not newValue) then - _type.Saved.HideAll = newValue - base.RestoreFrame(_type) - end - _type.Saved.HideAllEnabled = newValue - _type.Saved.LabelShow = true - base.SetupLabel(_type) - 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.IsCombined - end, - default = base.Default[typeName].LabelShow, - getFunc = function() - return _type.Saved.LabelShow or _type.Saved.IsCombined - end, - setFunc = function(newValue) - _type.Saved.LabelShow = newValue - base.SetupLabel(_type) - base.RestoreLabel(_type) - end, - width = "half" - }, { - type = "editbox", - name = "Display name", - tooltip = disabledWhenLabelIsHidden, - disabled = function() - return not _type.Saved.LabelShow - end, - default = base.Default[typeName].Display, - getFunc = function() - return tostring(_type.Saved.Display) - end, - setFunc = function(value) - _type.Saved.Display = value - base.RestoreFrame(_type) - base.RestoreCombineLabels() - end, - width = "half" - }, { - type = "dropdown", - name = "Display name font", - tooltip = disabledWhenLabelIsHidden, - disabled = function() - return not _type.Saved.LabelShow - end, - choices = base.Global.AvailableFonts, - default = base.Default[typeName].Label.Font, - getFunc = function() - return _type.Saved.Label.Font - end, - setFunc = function(value) - _type.Saved.Label.Font = value - base.RestoreFrame(_type) - base.RestoreCombineLabels() - end, - width = "half" - }, { - type = "slider", - name = "Display name height", - tooltip = disabledWhenLabelIsHidden, - disabled = function() - return not _type.Saved.LabelShow - end, - default = base.Default[typeName].Label.Height, - getFunc = function() - return _type.Saved.Label.Height - end, - setFunc = function(value) - _type.Saved.Label.Height = value - base.RestoreFrame(_type) - base.RestoreCombineLabels() - end, - min = 0, - max = 500, - width = "half" - }, { - type = "slider", - name = "Display name width", - tooltip = disabledWhenLabelIsHidden, - disabled = function() - return not _type.Saved.LabelShow - end, - default = base.Default[typeName].Label.Width, - getFunc = function() - return _type.Saved.Label.Width - end, - setFunc = function(value) - _type.Saved.Label.Width = value - base.RestoreFrame(_type) - base.RestoreCombineLabels() - end, - min = 0, - max = 500, - width = "half" - }, { - type = "slider", - name = "Display name offset horizontal (X)", - tooltip = disabledWhenLabelIsHidden, - disabled = function() - return not _type.Saved.LabelShow - end, - default = base.Default[typeName].Label.OffsetX, - getFunc = function() - return _type.Saved.Label.OffsetX - end, - setFunc = function(value) - _type.Saved.Label.OffsetX = value - base.RestoreFrame(_type) - base.RestoreCombineLabels() - end, - min = -500, - max = 500, - width = "half" - }, { - type = "slider", - name = "Display name offset vertical (Y)", - tooltip = disabledWhenLabelIsHidden, - disabled = function() - return not _type.Saved.LabelShow - end, - default = base.Default[typeName].Label.OffsetY, - getFunc = function() - return _type.Saved.Label.OffsetY - end, - setFunc = function(value) - _type.Saved.Label.OffsetY = value - base.RestoreFrame(_type) - base.RestoreCombineLabels() - end, - 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.IsCombined - end, - choices = base.Global.ChoiceLocations, - default = base.Default.BindingLocation, - getFunc = function() - if _type.Saved.IsCombined then - return base.GetLocationText(base.Saved.Combine.Label.PositionTarget) - else - return base.GetLocationText(_type.Saved.Label.PositionTarget) - end - end, - setFunc = function(value) - _type.Saved.Label.PositionTarget = base.GetLocationValue(value) - base.RestoreFrame(_type) - 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.IsCombined - end, - choices = base.Global.ChoiceLocations, - default = base.Default.BindingLocation, - getFunc = function() - if _type.Saved.IsCombined then - return base.GetLocationText(base.Saved.Combine.Label.Position) - else - return base.GetLocationText(_type.Saved.Label.Position) - end - end, - setFunc = function(value) - _type.Saved.Label.Position = base.GetLocationValue(value) - base.RestoreFrame(_type) - base.RestoreCombineLabels() - end, - width = "half" - }, {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.IsCombined - end, - getFunc = function() - return _type.Saved.BarDepth - end, - setFunc = function(value) - _type.Saved.BarDepth = value - base.RestoreFrame(_type) - base.RestoreCombineLabels() - 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.IsCombined - end, - getFunc = function() - return _type.Saved.BarWidth - end, - setFunc = function(value) - _type.Saved.BarWidth = value - base.RestoreFrame(_type) - base.RestoreCombineLabels() - end, - min = 0, - max = _type.Unlocked - }, { - type = "checkbox", - name = "Bar orientation horizontal", - default = base.Default[typeName].Horizontal, - tooltip = disabledWhenCombined, - disabled = function() - return _type.Saved.IsCombined - end, - getFunc = function() - return _type.Saved.Horizontal - end, - setFunc = function(newValue) - _type.Saved.Horizontal = newValue - base.RestoreFrame(_type) - base.RestoreCombineLabels() - 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 - }) - end - - local indexShowCollection = 7 - local indexCollectionMenuItem = 8 - for _, _type in ipairs(base.TypeOrdered) do - AppendCollectionType(indexShowCollection, _type) - AppendCollectionMenuItem(indexCollectionMenuItem, _type) - indexCollectionMenuItem = indexCollectionMenuItem + 1 - end - - LAM2:RegisterOptionControls(base.Addon.Name, optionsData) -end diff --git a/CBs_MoveFrame.lua b/CBs_MoveFrame.lua index 239929f..5b3ea1c 100644 --- a/CBs_MoveFrame.lua +++ b/CBs_MoveFrame.lua @@ -6,6 +6,7 @@ Filename: CBs_MoveFrame.lua -- VARIABLES -- ------------------------------------------------------------------------------------------------- local base = CollectionBars +local texts = base.Texts ------------------------------------------------------------------------------------------------- -- FUNCTIONS -- @@ -37,32 +38,26 @@ 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.IsCombined) then + if base.Global.IsMoveEnabled and (_type.Name == texts.Components.Combine or not _type.IsEmpty and not _type.Saved.IsCombined) then moveFrame = base.GetOrCreateMoveFrame(targetFrame, _type) - onMouseEnter = function(frame) - frame.MoveFrameUpdateText(frame, true) - end - onMouseExit = function(frame) - frame.MoveFrameUpdateText(frame, false) - end - onMouseDown = function(frame) - frame:SetHandler("OnUpdate", frame.MoveFrameOnUpdate) - end + onMouseEnter = function(frame) frame.MoveFrameUpdateText(frame, true) end + onMouseExit = function(frame) frame.MoveFrameUpdateText(frame, false) end + onMouseDown = function(frame) frame:SetHandler(texts.Action.OnUpdate, frame.MoveFrameOnUpdate) end onMouseUp = function(frame) local saved = frame.Type.Saved frame.MoveFrameOnUpdate(frame) frame.MoveFrameUpdateText(frame, false) - frame:SetHandler("OnUpdate", nil) + frame:SetHandler(texts.Action.OnUpdate, nil) saved.X, saved.Y = base.GetMoveFrameSnapPosition(frame, _type.Saved.Label.PositionTarget, frame.Saved.SnapSize) end end if moveFrame then - moveFrame:SetHandler("OnMouseEnter", onMouseEnter) - moveFrame:SetHandler("OnMouseExit", onMouseExit) - moveFrame:SetHandler("OnMouseDown", onMouseDown) - moveFrame:SetHandler("OnMouseUp", onMouseUp) + moveFrame:SetHandler(texts.Action.OnMouseEnter, onMouseEnter) + moveFrame:SetHandler(texts.Action.OnMouseExit, onMouseExit) + moveFrame:SetHandler(texts.Action.OnMouseDown, onMouseDown) + moveFrame:SetHandler(texts.Action.OnMouseUp, onMouseUp) moveFrame:SetHidden(not base.Global.IsMoveEnabled) moveFrame.overlay:SetHidden(not base.Global.IsMoveEnabled) moveFrame.labelCenter:SetHidden(not base.Global.IsMoveEnabled) @@ -77,53 +72,48 @@ end function base.GetOrCreateMoveFrame(targetFrame, _type) if _type.MoveFrame == nil then - local moveFrameName = _type.Name .. "_MoveFrame" - local newMoveFrame = base.WM:CreateControlFromVirtual(moveFrameName, GuiRoot, base.Addon.Abbreviation .. "_MoveFrame") + local moveFrame = texts.Components.Move .. texts.Components.Frame + local lowdashMoveFrame = texts.Helpers.Lowdash .. moveFrame + local moveFrameName = _type.Name .. lowdashMoveFrame + local newMoveFrame = base.WM:CreateControlFromVirtual(moveFrameName, GuiRoot, base.Addon.Abbreviation .. lowdashMoveFrame) -- Variable is used to define what savedVariable the Frame refers to. newMoveFrame.TargetFrame = targetFrame newMoveFrame.Saved = base.Saved newMoveFrame.Type = _type + newMoveFrame[moveFrame .. texts.Action.UpdateText] = function(frame, position) + local labelTextTopLeft = texts.EmptyString - newMoveFrame["MoveFrameUpdateText"] = function(frame, position) - local labelTextTopLeft = "" + if (position) then labelTextTopLeft = string.format(texts.Format.Comma, base.GetMoveFrameSnapPosition(frame.TargetFrame, _type.Saved.Label.PositionTarget, frame.Saved.SnapSize)) end - if (position) then - labelTextTopLeft = string.format("%s,%s", base.GetMoveFrameSnapPosition(frame.TargetFrame, _type.Saved.Label.PositionTarget, frame.Saved.SnapSize)) - end - - frame.labelCenter:SetText(string.format("%s,%s", frame:GetWidth(), frame:GetHeight())) + frame.labelCenter:SetText(string.format(texts.Format.Comma, frame:GetWidth(), frame:GetHeight())) frame.labelTopLeft:SetText(labelTextTopLeft) end - newMoveFrame["MoveFrameOnUpdate"] = function(frame) + newMoveFrame[moveFrame .. texts.Action.OnUpdate] = function(frame) local x, y = base.GetMoveFrameSnapPosition(frame, _type.Saved.Label.PositionTarget, frame.Saved.SnapSize) frame.TargetFrame:ClearAnchors() frame.TargetFrame:SetAnchor(_type.Saved.Label.PositionTarget, GuiRoot, TOPLEFT, x, y) frame.MoveFrameUpdateText(frame, true) end - - newMoveFrame["MoveFrameUpdateColor"] = function(frame) + newMoveFrame[moveFrame .. texts.Action.UpdateColor] = function(frame) frame.overlay:SetCenterColor(0.88, 0.88, 0.88, 0.4) frame.overlay:SetEdgeColor(0.88, 0.88, 0.88, 0) frame.labelCenter:SetColor(0.9, 0.9, 0.9, 0.9) frame.labelTopLeft:SetColor(0.9, 0.9, 0.9, 0.9) end - newMoveFrame:SetAnchorFill(targetFrame) newMoveFrame:SetParent(GuiRoot) -- -- overlay - if newMoveFrame.overlay == nil then - newMoveFrame.overlay = GetControl(moveFrameName .. "BG") - end + if newMoveFrame.overlay == nil then newMoveFrame.overlay = GetControl(moveFrameName .. texts.Components.BG) end -- labels if newMoveFrame.labelTopLeft == nil or newMoveFrame.labelCenter == nil then - newMoveFrame.labelTopLeft = GetControl(moveFrameName .. "LabelTopLeft") + newMoveFrame.labelTopLeft = GetControl(moveFrameName .. texts.Components.Label .. texts.Components.Top .. texts.Components.Left) newMoveFrame.labelTopLeft:SetHorizontalAlignment(TEXT_ALIGN_LEFT) newMoveFrame.labelTopLeft:SetVerticalAlignment(TEXT_ALIGN_TOP) - newMoveFrame.labelCenter = GetControl(moveFrameName .. "LabelCenter") + newMoveFrame.labelCenter = GetControl(moveFrameName .. texts.Components.Label .. texts.Components.Center) newMoveFrame.labelCenter:SetHorizontalAlignment(TEXT_ALIGN_CENTER) newMoveFrame.labelCenter:SetVerticalAlignment(TEXT_ALIGN_CENTER) end diff --git a/CBs_Settings.lua b/CBs_Settings.lua index bcc3637..ed83caf 100644 --- a/CBs_Settings.lua +++ b/CBs_Settings.lua @@ -6,6 +6,7 @@ Filename: CBs_Settings.lua -- VARIABLES -- ------------------------------------------------------------------------------------------------- local base = CollectionBars +local texts = base.Texts ------------------------------------------------------------------------------------------------- -- FUNCTIONS -- @@ -19,10 +20,10 @@ function base.ToggleEnableSettings() end function base.SetupToggleSettings(_type) - local toggleSettings = GetControl(base.Global.HideAllId .. _type.Name .. "ToggleSettings") + local toggleSettings = GetControl(base.Addon.Abbreviation .. texts.Helpers.Lowdash .. texts.Components.HideAll .. _type.Name .. texts.Components.Toggle .. texts.Components.Settings) if toggleSettings then local hideAllSettingsFunc = function() base.ShowSettings(_type) end - toggleSettings:SetHandler("OnClicked", hideAllSettingsFunc) + toggleSettings:SetHandler(texts.Action.OnClicked, hideAllSettingsFunc) end end @@ -44,36 +45,39 @@ 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(texts.Action.OnClicked, onClicked) + control:SetHandler(texts.Action.OnMouseEnter, function(_control) ZO_Tooltips_ShowTextTooltip(_control, BOTTOM, _control.tooltipText) end) + control:SetHandler(texts.Action.OnMouseExit, function() ZO_Tooltips_HideTextTooltip() end) end function base.SetupSetttingsFrame(_type) - local selector = base.Addon.Abbreviation .. "_Settings" - + local selector = base.Addon.Abbreviation .. texts.Helpers.Lowdash .. texts.Components.Settings base.Global.SettingsFrame = base.WM:CreateControlFromVirtual(selector, GuiRoot, selector) - base.Global.SettingsLabel = GetControl(selector .. "Label") - base.Global.SettingsList = CBs_Settings_List:New(base, _type, base.Global.SettingsFrame) + base.Global.SettingsLabel = GetControl(selector .. texts.Components.Label) + base.Global.SettingsList = CBs_Settings_List:New(_type, base.Global.SettingsFrame) + + local titleControl = GetControl(selector .. texts.Components.Title) + titleControl:SetText(base.Addon.DisplayName .. texts.Helpers.Space .. texts.Components.Settings) - local titleControl = GetControl(selector .. "Title") - titleControl:SetText(base.Addon.DisplayName .. " Settings") + if base.Global.SettingsFrame.closeFrame == nil then base.Global.SettingsFrame.closeFrame = GetControl(base.Global.SettingsFrame, texts.Components.Close) end + if base.Global.SettingsFrame.closeFrame then + base.SetupSettingsFrameHandlers(base.Global.SettingsFrame.closeFrame, texts.Components.Close, function(buttonControl) buttonControl:GetParent():SetHidden(true) end) + end - local closeFrame = GetControl(base.Global.SettingsFrame, "Close") - if closeFrame then 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() + if base.Global.SettingsFrame.moveFrame == nil then base.Global.SettingsFrame.moveFrame = GetControl(base.Global.SettingsFrame, texts.Components.Move) end + if base.Global.SettingsFrame.moveFrame then + base.SetupSettingsFrameHandlers(base.Global.SettingsFrame.moveFrame, texts.Settings.ToggleMoveFrameText, 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 list of 'Collectibles'\nHint: Usefull after gaining a new collectible)", function() + + if base.Global.SettingsFrame.refreshFrame == nil then base.Global.SettingsFrame.refreshFrame = GetControl(base.Global.SettingsFrame, texts.Components.Refresh) end + if base.Global.SettingsFrame.refreshFrame then + base.SetupSettingsFrameHandlers(base.Global.SettingsFrame.refreshFrame, texts.Settings.ReloadText, function() if base.Global.SettingsList._type ~= nil then - base.CreateCollection(base.Global.SettingsList._type) + base.CreateCategory(base.Global.SettingsList._type) base.RestoreFrame(base.Global.SettingsList._type) end base.RestoreCombineLabels() @@ -88,7 +92,7 @@ function base.SetupSettingsFilter(control, controlName, displayName) local filterControl = GetControl(control, controlName) if filterControl then base.SetControlText(filterControl, displayName) - filterControl:SetHandler("OnClicked", function() + filterControl:SetHandler(texts.Action.OnClicked, function() base.Global.SettingsList.masterListType = controlName base.Global.SettingsList:RefreshFilters() end) @@ -111,5 +115,5 @@ end function base.UpdateSettingsType(show, _type) if base.Global.SettingsList ~= nil then base.Global.SettingsList._type = _type end - if base.Global.SettingsLabel ~= nil then base.Global.SettingsLabel:SetText(show and _type and _type.Name or "Global") end + if base.Global.SettingsLabel ~= nil then base.Global.SettingsLabel:SetText(show and _type and _type.Name or texts.Components.Global) end end diff --git a/CBs_Settings.xml b/CBs_Settings.xml index 170f115..31df0a8 100644 --- a/CBs_Settings.xml +++ b/CBs_Settings.xml @@ -29,20 +29,20 @@ <Anchor point="TOPLEFT" relativeTo="$(parent)Label" relativePoint="BOTTOMLEFT" offsetY="15"/> <Dimensions x="122" y="22" /> </Button> - <Button name="$(parent)CollectionTypes" inherits="ZO_DefaultButton" clickSound="Click" relativeTo="$(parent)"> + <Button name="$(parent)Categories" inherits="ZO_DefaultButton" clickSound="Click" relativeTo="$(parent)"> <Anchor point="TOPLEFT" relativeTo="$(parent)General" relativePoint="TOPRIGHT" /> <Dimensions x="122" y="22" /> </Button> <Button name="$(parent)Selection" inherits="ZO_DefaultButton" clickSound="Click" relativeTo="$(parent)"> - <Anchor point="TOPLEFT" relativeTo="$(parent)CollectionTypes" relativePoint="TOPRIGHT" /> + <Anchor point="TOPLEFT" relativeTo="$(parent)Categories" relativePoint="TOPRIGHT" /> <Dimensions x="122" y="22" /> </Button> - <Button name="$(parent)Collection" inherits="ZO_DefaultButton" clickSound="Click" relativeTo="$(parent)"> + <Button name="$(parent)Category" inherits="ZO_DefaultButton" clickSound="Click" relativeTo="$(parent)"> <Anchor point="TOPLEFT" relativeTo="$(parent)Selection" relativePoint="TOPRIGHT" /> <Dimensions x="122" y="22" /> </Button> <Button name="$(parent)Combined" inherits="ZO_DefaultButton" clickSound="Click" relativeTo="$(parent)"> - <Anchor point="BOTTOMLEFT" relativeTo="$(parent)Collection" relativePoint="TOPLEFT" offsetY="-5" /> + <Anchor point="BOTTOMLEFT" relativeTo="$(parent)Category" relativePoint="TOPLEFT" offsetY="-5" /> <Dimensions x="122" y="22" /> </Button> @@ -80,14 +80,41 @@ </Controls> </Control> + <Control name="CBs_Settings_ListRow_Category_Title" mouseEnabled="true" virtual="true"> + <Dimensions x="510" y="26" /> + <Controls> + <Texture name="$(parent)Icon" relativeTo="$(parent)"> + <Dimensions x="26" y="26" /> + <Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" /> + <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetX="26" offsetY="26" /> + </Texture> + <Label name="$(parent)Name" font="ZoFontWinH4" modifyTextType="NONE"> + <Anchor point="TOPLEFT" offsetX="26" /> + <OnLinkClicked> + </OnLinkClicked> + </Label> + </Controls> + </Control> + <!-- Inspiration: ZO_Options_Checkbox --> - <Control name="CBs_Settings_ListRow_Checkbox_CogButton" inherits="CBs_Settings_ListRow_Checkbox" mouseEnabled="true" virtual="true"> + <Control name="CBs_Settings_ListRow_Category_Checkbox" mouseEnabled="true" virtual="true"> + <Dimensions x="510" y="26" /> <Controls> - <Button name="$(parent)CogButton" relativeTo="$(parent)"> - <Anchor point="TOPLEFT" relativeTo="$(parent)Checkbox" relativePoint="TOPLEFT" offsetX="33" /> - <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)Checkbox" /> + <Texture name="$(parent)Icon" relativeTo="$(parent)"> + <Dimensions x="26" y="26" /> + <Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" /> + <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetX="26" offsetY="26" /> + </Texture> + <Button name="$(parent)Button" relativeTo="$(parent)"> + <Dimensions x="26" y="26" /> + <Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPRIGHT" offsetX="-26" /> + <Anchor point="BOTTOMRIGHT" relativeTo="$(parent)" relativePoint="BOTTOMRIGHT" /> <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> + <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" offsetX="-26" /> + </Button> </Controls> </Control> @@ -178,6 +205,7 @@ <!-- Inspiration: ZO_EditDefaultText --> <Control name="CBs_Settings_ListRow_EditBox" inherits="CBs_Settings_ListRow_Label" mouseEnabled="true" virtual="true"> + <Dimensions x="510" y="26" /> <Controls> <EditBox name="$(parent)EditBox" inherits="ZO_DefaultEditForBackdrop ZO_EditDefaultText"> <Dimensions x="150" y="26" /> @@ -187,16 +215,18 @@ </Control> <Control name="CBs_Settings_ListRow_Title" mouseEnabled="true" virtual="true"> - <Dimensions x="510" y="26" /> + <Dimensions x="510" y="38" /> <Controls> <Label name="$(parent)Name" font="ZoFontWinH1" modifyTextType="UPPERCASE"> - <Anchor point="TOPLEFT" /> + <Dimensions y="38" /> + <Anchor point="LEFT" /> </Label> </Controls> </Control> <!-- Inspiration: ZO_EditDefaultText --> <Control name="CBs_Settings_ListRow_Button" inherits="CBs_Settings_ListRow_Label" mouseEnabled="true" virtual="true"> + <Dimensions x="510" y="26" /> <Controls> <Button name="$(parent)Button" inherits="ZO_DefaultButton" clickSound="Click" relativeTo="$(parent)"> <Anchor point="RIGHT" offsetX="-40" /> diff --git a/CBs_Settings_Data.lua b/CBs_Settings_Data.lua index dd58db2..27e7ac7 100644 --- a/CBs_Settings_Data.lua +++ b/CBs_Settings_Data.lua @@ -6,6 +6,7 @@ Filename: CBs_Settings_Data.lua -- VARIABLES -- ------------------------------------------------------------------------------------------------- local base = CollectionBars +local texts = base.Texts ------------------------------------------------------------------------------------------------- -- FUNCTIONS -- @@ -14,41 +15,25 @@ 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, + funcGet = function() return base.Saved.UseAccountSettings end, funcSet = function(_, newValue) - self.base.Saved.UseLAMMenu = LibAddonMenu2 and newValue - self.base.Global.SettingsList:RefreshData() + base.SetAndUpdateAccountSettings(newValue) + base.InitializeWithSavedData() + base.RestoreFrames() + base.RestoreCombineLabels() + 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() + base.ResetAccountSettings() + base.SetAndUpdateAccountSettings() + base.InitializeWithSavedData() + base.RestoreFrames() + base.RestoreCombineLabels() + base.Global.SettingsList:RefreshData() end }) self:AppendRow_Title(typeSelection, {name = "Position and size"}) @@ -56,107 +41,87 @@ function base.AppendMasterListTypeGeneral(self, 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, + funcGet = function() return base.Global.IsMoveEnabled end, funcSet = function(_, newValue) - self.base.Global.IsMoveEnabled = newValue - self.base.RestoreFrames() + base.Global.IsMoveEnabled = newValue + 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, + funcGet = function() return 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() + local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + if valueLabel then valueLabel:SetText(newValue) end + base.Saved.SnapSize = newValue + base.RestoreFrames() end, minValue = 1, maxValue = 10, valueStep = 1, - default = self.base.Default.SnapSize, - valueFormat = "%.2f", + default = base.Default.SnapSize, + valueFormat = texts.Format.Number, 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, + funcGet = function() return 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() + local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + if valueLabel then valueLabel:SetText(newValue) end + base.Saved.BarDepth = newValue + base.RestoreFrames() end, minValue = 0, maxValue = base.Global.HighestUnlocked, valueStep = 1, - default = self.base.Default.BarDepth, - valueFormat = "%.2f", + default = base.Default.BarDepth, + valueFormat = texts.Format.Number, 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, + funcGet = function() return 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() + local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + if valueLabel then valueLabel:SetText(newValue) end + base.Saved.BarWidth = newValue + base.RestoreFrames() end, minValue = 0, maxValue = base.Global.HighestUnlocked, valueStep = 1, - default = self.base.Default.BarWidth, - valueFormat = "%.2f", + default = base.Default.BarWidth, + valueFormat = texts.Format.Number, 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, + funcGet = function() return base.Saved.ShowBinding end, funcSet = function(_, newValue) - self.base.Saved.ShowBinding = newValue - self.base.RestoreFrames() + base.Saved.ShowBinding = newValue + base.RestoreFrames() end }) self:AppendRow_Slider(typeSelection, { name = "Choose button size", tooltipText = "Choose button size", - funcGet = function() - return self.base.Saved.ButtonXY - end, + funcGet = function() return 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() + local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + if valueLabel then valueLabel:SetText(newValue) end + base.Saved.ButtonXY = newValue + base.RestoreFrames() end, minValue = 1, maxValue = 100, valueStep = 1, default = ZO_GAMEPAD_ACTION_BUTTON_SIZE, - valueFormat = "%.2f", + valueFormat = texts.Format.Number, showValue = true }) @@ -166,89 +131,73 @@ function base.AppendMasterListTypeGeneral(self, 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, + funcGet = function() return base.Saved.ShowBarOnHud end, funcSet = function(_, newValue) - self.base.Saved.ShowBarOnHud = newValue - self.base.UpdateFragments("ShowBarOnHud") + base.Saved.ShowBarOnHud = newValue + 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, + funcGet = function() return base.Saved.ShowBarOnHudUI end, funcSet = function(_, newValue) - self.base.Saved.ShowBarOnHudUI = newValue - self.base.UpdateFragments("ShowBarOnHudUI") + base.Saved.ShowBarOnHudUI = newValue + 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, + funcGet = function() return base.Saved.ShowBarInMenu end, funcSet = function(_, newValue) - self.base.Saved.ShowBarInMenu = newValue - self.base.UpdateFragments("ShowBarInMenu") + base.Saved.ShowBarInMenu = newValue + 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, + funcGet = function() return base.Saved.ShowBarInInventory end, funcSet = function(_, newValue) - self.base.Saved.ShowBarInInventory = newValue - self.base.UpdateFragments("ShowBarInInventory") + base.Saved.ShowBarInInventory = newValue + 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, + funcGet = function() return base.Saved.ShowBarInInteract end, funcSet = function(_, newValue) - self.base.Saved.ShowBarInInteract = newValue - self.base.UpdateFragments("ShowBarInInteract") + base.Saved.ShowBarInInteract = newValue + 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, + funcGet = function() return base.Saved.ShowBarInBank end, funcSet = function(_, newValue) - self.base.Saved.ShowBarInBank = newValue - self.base.UpdateFragments("ShowBarInBank") + base.Saved.ShowBarInBank = newValue + 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, + funcGet = function() return base.Saved.ShowBarInFence end, funcSet = function(_, newValue) - self.base.Saved.ShowBarInFence = newValue - self.base.UpdateFragments("ShowBarInFence") + base.Saved.ShowBarInFence = newValue + 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, + funcGet = function() return base.Saved.ShowBarInStore end, funcSet = function(_, newValue) - self.base.Saved.ShowBarInStore = newValue - self.base.UpdateFragments("ShowBarInStore") + base.Saved.ShowBarInStore = newValue + base.UpdateFragments("ShowBarInStore") end }) @@ -257,12 +206,10 @@ function base.AppendMasterListTypeGeneral(self, 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, + funcGet = function() return base.Saved.IsActiveActivationEnabled end, funcSet = function(_, newValue) - self.base.Saved.IsActiveActivationEnabled = newValue - self.base.RestoreFrames() + base.Saved.IsActiveActivationEnabled = newValue + base.RestoreFrames() end }) @@ -271,54 +218,56 @@ function base.AppendMasterListTypeGeneral(self, 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, + funcGet = function() return base.Saved.IsAudioEnabled end, funcSet = function(_, newValue) - self.base.Saved.IsAudioEnabled = newValue - self.base.RestoreFrames() + base.Saved.IsAudioEnabled = newValue + base.RestoreFrames() end }) end -function base.AppendMasterListTypeCollectionTypes(self, typeSelection) - self:AppendRow_Title(typeSelection, {name = "Collection types"}) +function base.AppendMasterListTypeCategories(self, typeSelection) + self:AppendRow_Title(typeSelection, {name = "Categories"}) self:AppendRow_Divider(typeSelection, {}) - for _, _type in ipairs(self.base.TypeOrdered or {}) do - self:AppendRow_Checkbox_CogButton(typeSelection, { + for _, _type in ipairs(base.TypesOrdered or {}) do + local data = { cId = _type.Id, + icon = _type.Icon, name = string.format("Show %s", _type.Name), + hasChildren = _type.HasChildren, + parentKey = _type.ParentKey, tooltipText = string.format("When ON the collection type: %s will enabled\nPress the 'cog' to display collectible in: 'Collectibles' and 'Collection bar'", _type.Name), - funcGet = function() - return _type.Saved.Enabled - end, - disabledFunc = function() - return _type.Disabled - end, + 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) + base.InitializeType(_type) else - self.base.RemoveLabel(_type) - self.base.RemoveFrame(_type) + base.RemoveLabel(_type) + base.RemoveFrame(_type) if self._type == _type then self._type = nil - self.base.UpdateSettingsType(true, nil) + base.UpdateSettingsType(true, nil) end end - if _type.Saved.IsCombined then - self.base.RestoreCombineLabels() - end - self.base.Global.SettingsList:RefreshData() + if _type.Saved.IsCombined then base.RestoreCombineLabels() end + base.Global.SettingsList:RefreshData() end, funcCog = function(_) self._type = _type - self.base.UpdateSettingsType(true, _type) - self.base.Global.SettingsList:RefreshData() + base.UpdateSettingsType(true, _type) + base.Global.SettingsList:RefreshData() end - }) + } + + if _type.HasChildren then + data.name = _type.Name + self:AppendRow_Category_Title(typeSelection, data) + else + self:AppendRow_Category_Checkbox(typeSelection, data) + end end end @@ -328,67 +277,55 @@ function base.AppendMasterListTypeCombined(self, 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, + funcGet = function() return 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() + local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + if valueLabel then valueLabel:SetText(newValue) end + base.Saved.Combine.Label.OffsetX = newValue + base.RestoreCombineLabels() end, minValue = -500, maxValue = 500, valueStep = 1, - default = self.base.Default.Combine.Label.OffsetX, - valueFormat = "%.2f", + default = base.Default.Combine.Label.OffsetX, + valueFormat = texts.Format.Number, 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, + funcGet = function() return 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() + local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + if valueLabel then valueLabel:SetText(newValue) end + base.Saved.Combine.Label.OffsetY = newValue + base.RestoreCombineLabels() end, minValue = -500, maxValue = 500, valueStep = 1, - default = self.base.Default.Combine.Label.OffsetY, - valueFormat = "%.2f", + default = base.Default.Combine.Label.OffsetY, + valueFormat = texts.Format.Number, 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.ChoiceLocations, + funcGet = function() return base.GetLocationText(base.Saved.Combine.Label.PositionTarget) end, + choices = base.Global.ChoiceLocations, funcSet = function(_, newValue) - self.base.Saved.Combine.Label.PositionTarget = self.base.GetLocationValue(newValue) - self.base.RestoreCombineLabels() + base.Saved.Combine.Label.PositionTarget = base.GetLocationValue(newValue) + 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, + funcGet = function() return base.GetLocationText(base.Saved.Combine.Label.Position) end, + choices = base.Global.ChoiceLocations, funcSet = function(_, newValue) - self.base.Saved.Combine.Label.Position = self.base.GetLocationValue(newValue) - self.base.RestoreCombineLabels() + base.Saved.Combine.Label.Position = base.GetLocationValue(newValue) + base.RestoreCombineLabels() end }) self:AppendRow_Title(typeSelection, {name = "Position and size"}) @@ -396,89 +333,73 @@ function base.AppendMasterListTypeCombined(self, 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, + funcGet = function() return 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() + local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + if valueLabel then valueLabel:SetText(newValue) end + base.Saved.Combine.BarDepth = newValue + base.RestoreFrames() end, minValue = 0, - maxValue = self.base.Global.HighestUnlocked, + maxValue = base.Global.HighestUnlocked, valueStep = 1, - default = self.base.Default.BarDepth, - valueFormat = "%.2f", + default = base.Default.BarDepth, + valueFormat = texts.Format.Number, 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, + funcGet = function() return 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() + local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + if valueLabel then valueLabel:SetText(newValue) end + base.Saved.Combine.BarWidth = newValue + base.RestoreFrames() end, minValue = 0, - maxValue = self.base.Global.HighestUnlocked, + maxValue = base.Global.HighestUnlocked, valueStep = 1, - default = self.base.Default.BarWidth, - valueFormat = "%.2f", + default = base.Default.BarWidth, + valueFormat = texts.Format.Number, showValue = true }) end function base.AppendMasterListTypeSelection(self, typeSelection) - self:AppendRow_Title(typeSelection, {name = "Selection"}) + self:AppendRow_Title(typeSelection, {name = texts.Components.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, + 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() + base.CreateCategory(self._type) + 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, + funcGet = function() return 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() + base.SelectAll(self._type, newValue) + base.RestoreFrame(self._type) + base.RestoreCombineLabels() + 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 + for _, collectible in ipairs(self._type.CategoryOrdered or {}) do + if self._type.Saved.MenuShowDisabled and collectible.Disabled or not collectible.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, + cId = collectible.Id, + name = string.format("Show %s", collectible.Name), + tooltipText = collectible.Tooltip, + funcGet = function() return self._type.Saved.Selected[collectible.Id] end, + disabledFunc = function() return collectible.Disabled end, funcSet = function(checkBoxControl, newValue) local control = checkBoxControl:GetParent() if not (control.data.disabledFunc and control.data.disabledFunc()) then @@ -487,9 +408,9 @@ function base.AppendMasterListTypeSelection(self, typeSelection) else self._type.Saved.Selected[control.data.cId] = nil end - self.base.RestoreFrame(self._type) - self.base.RestoreCombineLabels() - self.base.Global.SettingsList:RefreshData() + base.RestoreFrame(self._type) + base.RestoreCombineLabels() + base.Global.SettingsList:RefreshData() end end @@ -498,7 +419,7 @@ function base.AppendMasterListTypeSelection(self, typeSelection) end end -function base.AppendMasterListTypeCollection(self, typeSelection) +function base.AppendMasterListTypeCategory(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" @@ -508,28 +429,22 @@ function base.AppendMasterListTypeCollection(self, 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, + 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() + base.SetupButtons(self._type) + 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.ChoiceLocations, - disabledFunc = function() - return not self._type.Saved.Tooltip.Show - end, - funcGet = function() - return self.base.GetLocationText(self._type.Saved.Tooltip.Position) - end, + choices = base.Global.ChoiceLocations, + disabledFunc = function() return not self._type.Saved.Tooltip.Show end, + funcGet = function() return 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) + self._type.Saved.Tooltip.Position = base.GetLocationValue(newValue) + base.SetupButtons(self._type) end }) @@ -538,223 +453,166 @@ function base.AppendMasterListTypeCollection(self, 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, + 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() + base.RestoreFrame(self._type) + base.RestoreCombineLabels() + 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, + 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) + 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() + base.SetupLabel(self._type) + base.RestoreLabel(self._type) + 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, + 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() + base.SetupLabel(self._type) + base.RestoreLabel(self._type) + base.Global.SettingsList:RefreshData() 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, + disabledFunc = function() return not self._type.Saved.LabelShow end, + choices = 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() + base.RestoreFrame(self._type) + 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, + 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 + local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + if valueLabel then valueLabel:SetText(newValue) end self._type.Saved.Label.Height = newValue - self.base.RestoreFrame(self._type) - self.base.RestoreCombineLabels() + base.RestoreFrame(self._type) + base.RestoreCombineLabels() end, minValue = 0, maxValue = 100, valueStep = 1, - default = self.base.Default[self._type.Name].Label.Height, - valueFormat = "%.2f", + default = base.Default[self._type.Name].Label.Height, + valueFormat = texts.Format.Number, 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, + 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 + local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + if valueLabel then valueLabel:SetText(newValue) end self._type.Saved.Label.Width = newValue - self.base.RestoreFrame(self._type) - self.base.RestoreCombineLabels() + base.RestoreFrame(self._type) + base.RestoreCombineLabels() end, minValue = 0, maxValue = 500, valueStep = 1, - default = self.base.Default[self._type.Name].Label.Width, - valueFormat = "%.2f", + default = base.Default[self._type.Name].Label.Width, + valueFormat = texts.Format.Number, 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, + 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 + local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + if valueLabel then valueLabel:SetText(newValue) end self._type.Saved.Label.OffsetX = newValue - self.base.RestoreFrame(self._type) - self.base.RestoreCombineLabels() + base.RestoreFrame(self._type) + base.RestoreCombineLabels() end, minValue = -500, maxValue = 500, valueStep = 1, - default = self.base.Default[self._type.Name].Label.OffsetX, - valueFormat = "%.2f", + default = base.Default[self._type.Name].Label.OffsetX, + valueFormat = texts.Format.Number, 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, + 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 + local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + if valueLabel then valueLabel:SetText(newValue) end self._type.Saved.Label.OffsetY = newValue - self.base.RestoreFrame(self._type) - self.base.RestoreCombineLabels() + base.RestoreFrame(self._type) + base.RestoreCombineLabels() end, minValue = -500, maxValue = 500, valueStep = 1, - default = self.base.Default[self._type.Name].Label.OffsetY, - valueFormat = "%.2f", + default = base.Default[self._type.Name].Label.OffsetY, + valueFormat = texts.Format.Number, 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, + 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) + return base.GetLocationText(base.Saved.Combine.Label.PositionTarget) else - return self.base.GetLocationText(self._type.Saved.Label.PositionTarget) + return base.GetLocationText(self._type.Saved.Label.PositionTarget) end end, - choices = self.base.Global.ChoiceLocations, + choices = base.Global.ChoiceLocations, funcSet = function(_, newValue) - self._type.Saved.Label.PositionTarget = self.base.GetLocationValue(newValue) - self.base.RestoreFrame(self._type) - self.base.RestoreCombineLabels() + self._type.Saved.Label.PositionTarget = base.GetLocationValue(newValue) + base.RestoreFrame(self._type) + 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, + 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) + return base.GetLocationText(base.Saved.Combine.Label.Position) else - return self.base.GetLocationText(self._type.Saved.Label.Position) + return base.GetLocationText(self._type.Saved.Label.Position) end end, - choices = self.base.Global.ChoiceLocations, + choices = base.Global.ChoiceLocations, funcSet = function(_, newValue) - self._type.Saved.Label.Position = self.base.GetLocationValue(newValue) - self.base.RestoreFrame(self._type) - self.base.RestoreCombineLabels() + self._type.Saved.Label.Position = base.GetLocationValue(newValue) + base.RestoreFrame(self._type) + base.RestoreCombineLabels() end }) @@ -763,70 +621,54 @@ function base.AppendMasterListTypeCollection(self, 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, + 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 + local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + if valueLabel then valueLabel:SetText(newValue) end self._type.Saved.BarDepth = newValue - self.base.RestoreFrame(self._type) - self.base.RestoreCombineLabels() + base.RestoreFrame(self._type) + base.RestoreCombineLabels() end, minValue = 0, maxValue = self._type.Unlocked, valueStep = 1, - default = self.base.Default[self._type.Name].BarDepth, - valueFormat = "%.2f", + default = base.Default[self._type.Name].BarDepth, + valueFormat = texts.Format.Number, 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, + 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 + local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + if valueLabel then valueLabel:SetText(newValue) end self._type.Saved.BarWidth = newValue - self.base.RestoreFrame(self._type) - self.base.RestoreCombineLabels() + base.RestoreFrame(self._type) + base.RestoreCombineLabels() end, minValue = 0, maxValue = self._type.Unlocked, valueStep = 1, - default = self.base.Default[self._type.Name].BarWidth, + default = 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, + 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() + base.RestoreFrame(self._type) + base.RestoreCombineLabels() end }) end -function base.AppendMasterListTypeNoCollectionType(self, typeSelection) - self:AppendRow_Title(typeSelection, {name = "Select a collection type"}) +function base.AppendMasterListTypeNoCategory(self, typeSelection) + self:AppendRow_Title(typeSelection, {name = "Select a category"}) self:AppendRow_Divider(typeSelection, {}) end diff --git a/CBs_Settings_List.lua b/CBs_Settings_List.lua index a8fbea1..bf456ae 100644 --- a/CBs_Settings_List.lua +++ b/CBs_Settings_List.lua @@ -3,24 +3,27 @@ Author: Jarth Filename: CBs_Settings_List.lua ]] -- ------------------------------------------------------------------------------------------------- +-- VARIABLES -- +------------------------------------------------------------------------------------------------- +local base = CollectionBars +local texts = base.Texts + +------------------------------------------------------------------------------------------------- -- FUNCTIONS -- ------------------------------------------------------------------------------------------------- CBs_Settings_List = ZO_SortFilterList:Subclass() function CBs_Settings_List:New(...) self.list = ZO_SortFilterList.New(self, ...) - self.masterListType = "Selection" + self.masterListType = texts.Components.Selection return self.list end -function CBs_Settings_List:Initialize(base, _type, ...) +function CBs_Settings_List:Initialize(_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 + if not (self._type and self._type.Enabled) then self.masterListType = texts.Components.Categories end self:SetAlternateRowBackgrounds(false) self:AppendDataTypes() @@ -31,68 +34,21 @@ end ------------------------------------------------------------------------------------------------- function CBs_Settings_List:AppendDataTypes() + local listRowAnd = base.Addon.Abbreviation .. texts.Helpers.Lowdash .. texts.Components.Settings .. texts.Helpers.Lowdash .. texts.Components.List .. texts.Components.Row .. texts.Helpers.Lowdash + local categoriesAnd = texts.Components.Category .. texts.Helpers.Lowdash 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 - } + [10] = {name = listRowAnd .. texts.Components.Checkbox, height = 40, func = function(...) self:SetupRow_Checkbox(...) end}, + [11] = {name = listRowAnd .. categoriesAnd .. texts.Components.Title, height = 40, func = function(...) self:SetupRow_Category_Title(...) end}, + [15] = {name = listRowAnd .. categoriesAnd .. texts.Components.Checkbox, height = 40, func = function(...) self:SetupRow_Category_Checkbox(...) end}, + [20] = {name = listRowAnd .. texts.Components.Dropdown, height = 40, func = function(...) self:SetupRow_Dropdown(...) end}, + [30] = {name = listRowAnd .. texts.Components.Slider, height = 40, func = function(...) self:SetupRow_Slider(...) end}, + [40] = {name = listRowAnd .. texts.Components.EditBox, height = 40, func = function(...) self:SetupRow_EditBox(...) end}, + [50] = {name = listRowAnd .. texts.Components.Title, height = 40, func = function(...) self:SetupRow_Title(...) end}, + [60] = {name = listRowAnd .. texts.Components.Button, height = 40, func = function(...) self:SetupRow_Button(...) end}, + [100] = {name = listRowAnd .. texts.Components.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 + for index, dataType in pairs(dataTypes) do ZO_ScrollList_AddDataType(self.list, index, dataType.name, dataType.height, dataType.func) end end ------------------------------------------------------------------------------------------------- @@ -109,7 +65,7 @@ function CBs_Settings_List:SetupRow_Checkbox(control, data) control.data = data ZO_SortFilterList.SetupRow(self, control, data) - control.checkbox = GetControl(control, "Checkbox") + control.checkbox = GetControl(control, texts.Components.Checkbox) if control.checkbox then control.checkbox.tooltipText = data.tooltipText ZO_CheckButton_SetCheckState(control.checkbox, control.data.funcGet and control.data.funcGet()) @@ -117,7 +73,7 @@ function CBs_Settings_List:SetupRow_Checkbox(control, data) 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(TOPLEFT, control, TOPLEFT, 0) control.checkbox.label:SetAnchor(BOTTOMRIGHT, control.checkbox, BOTTOMLEFT) end ZO_CheckButton_SetTooltipAnchor(control.checkbox, TOP, control.checkbox.label) @@ -126,25 +82,51 @@ function CBs_Settings_List:SetupRow_Checkbox(control, data) end end -function CBs_Settings_List:AppendRow_Checkbox_CogButton(typeSelection, data) +function CBs_Settings_List:AppendRow_Category_Title(typeSelection, data) + data.type = typeSelection + data.dataTypeId = 11 + table.insert(self.masterList, data) +end + +function CBs_Settings_List:SetupRow_Category_Title(control, data) + control.data = data + ZO_SortFilterList.SetupRow(self, control, control.data) + control:SetHandler(texts.Action.OnMouseUp, function() + local savedTypeData = base.Saved[data.name] + if savedTypeData ~= nil then + savedTypeData.ShowChildren = not savedTypeData.ShowChildren + base.Global.SettingsList:RefreshFilters() + end + end) + + self.SetNameText(control, control.data.name) + self.SetupIcon(control, control.data) + self.SetActiveOrInactive(control) +end + +function CBs_Settings_List:AppendRow_Category_Checkbox(typeSelection, data) data.type = typeSelection data.dataTypeId = 15 table.insert(self.masterList, data) end -function CBs_Settings_List:SetupRow_Checkbox_CogButton(control, data) +function CBs_Settings_List:SetupRow_Category_Checkbox(control, data) + control.data = data self:SetupRow_Checkbox(control, data) - control.cogButton = GetControl(control, "CogButton") - if control.cogButton then - control.cogButton:SetHidden(false) + control.button = GetControl(control, texts.Components.Button) + if control.button then + control.button: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) - self.base.SetupSettingsFrameHandlers(control.cogButton, data.tooltipText, function() + ZO_CheckButton_SetEnableState(control.button, isEnabled) + control.button:SetAlpha(isEnabled and 1 or 0.5) + base.SetupSettingsFrameHandlers(control.button, data.tooltipText, function() PlaySound(SOUNDS.SINGLE_SETTING_RESET_TO_DEFAULT) control.data.funcCog(control.slider, data.default) end) end + + local hasIcon = self.SetupIcon(control, data) + if control.checkbox ~= nil and control.checkbox.label ~= nil and hasIcon then control.checkbox.label:SetAnchor(TOPLEFT, control, TOPLEFT, 26) end end function CBs_Settings_List:AppendRow_Dropdown(typeSelection, data) @@ -157,10 +139,10 @@ function CBs_Settings_List:SetupRow_Dropdown(control, data) control.data = data ZO_SortFilterList.SetupRow(self, control, data) - control.dropdown = GetControl(control, "Dropdown") + control.dropdown = GetControl(control, texts.Components.Dropdown) control.comboBox = ZO_ComboBox_ObjectFromContainer(control.dropdown) control.comboBox:SetSortsItems(false) - control.comboBox:SetFont("ZoFontWinT1") + control.comboBox:SetFont(texts.Font.ZoFontWinT1) control.comboBox:SetSpacing(4) control.comboBox.tooltipText = data.tooltipText @@ -179,29 +161,30 @@ function CBs_Settings_List:SetupRow_Slider(control, data) control.data = data ZO_SortFilterList.SetupRow(self, control, control.data) - control.slider = GetControl(control, "Slider") + control.slider = GetControl(control, texts.Components.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:SetHandler(texts.Action.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) + control.slider:SetHandler(texts.Action.OnValueChanged, control.data.funcSet) if data.default then if control.defaultMarkerControl == nil then - control.defaultMarkerControl = CreateControlFromVirtual("$(parent)DefaultMarker", control.slider, "ZO_Options_DefaultMarker") + local defaultMarker = texts.Components.Default .. texts.Components.Marker + control.defaultMarkerControl = CreateControlFromVirtual(texts.Components.Parent .. defaultMarker, control.slider, texts.Components.ZOOptions .. 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() + control.defaultMarkerControl:SetHandler(texts.Action.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") + local valueLabelControl = GetControl(control, texts.Components.Value .. texts.Components.Label) if valueLabelControl and data.showValue then local shownVal = data.funcGet() if data.valueMin and data.valueMax and data.valueMax > data.valueMin then @@ -210,7 +193,7 @@ function CBs_Settings_List:SetupRow_Slider(control, data) local shownRange = data.valueMax - data.valueMin shownVal = data.valueMin + percentage * shownRange - shownVal = string.format("%d", shownVal) + shownVal = string.format(texts.Format.Decimal, shownVal) end valueLabelControl:SetText(shownVal) end @@ -229,14 +212,12 @@ function CBs_Settings_List:SetupRow_EditBox(control, data) control.data = data ZO_SortFilterList.SetupRow(self, control, control.data) - control.editBox = GetControl(control, "EditBox") + control.editBox = GetControl(control, texts.Components.EditBox) if control.editBox then ZO_EditDefaultText_Initialize(control.editBox) - control.editBox:SetHandler("OnTextChanged", nil) + control.editBox:SetHandler(texts.Action.OnTextChanged, nil) control.editBox:SetText(data.funcGet()) - control.editBox:SetHandler("OnTextChanged", function() - data.funcSet(control.editBox) - end) + control.editBox:SetHandler(texts.Action.OnTextChanged, function() data.funcSet(control.editBox) end) end self.SetNameText(control, control.data.name) @@ -251,9 +232,11 @@ end function CBs_Settings_List:SetupRow_Title(control, data) control.data = data - ZO_SortFilterList.SetupRow(self, control, control.data) + ZO_SortFilterList.SetupRow(self, control, data) - self.SetNameText(control, control.data.name) + local fontOverrides = nil + if data.hasChildren then fontOverrides = {font = texts.Font.ZoFontWinH4, modifyTextType = MODIFY_TEXT_TYPE_NONE} end + self.SetNameText(control, data.name, fontOverrides) self.SetActiveOrInactive(control) end @@ -267,12 +250,10 @@ function CBs_Settings_List:SetupRow_Button(control, data) control.data = data ZO_SortFilterList.SetupRow(self, control, control.data) - control.button = GetControl(control, "Button") + control.button = GetControl(control, texts.Components.Button) if control.button then - control.button:SetText(control.data.buttonName or "") - control.button:SetHandler("OnClicked", function() - control.data.funcSet() - end) + control.button:SetText(control.data.buttonName or texts.EmptyString) + control.button:SetHandler(texts.Action.OnClicked, function() control.data.funcSet() end) end self.SetNameText(control, control.data.name) @@ -297,56 +278,65 @@ function CBs_Settings_List.RepopulateDropdownOptions(control) local entry = ZO_ComboBox:CreateItemEntry(optionValue, control.data.funcSet) control.comboBox:AddItem(entry) - if optionValue == selectedValue then - selectedEntry = entry - end + 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 "") +function CBs_Settings_List.SetNameText(control, text, fontOverrides) + if control.label == nil then control.label = GetControl(control, texts.Components.Name) end + if control.label ~= nil then + if fontOverrides ~= nil then + control.label:SetFont(fontOverrides.font) + control.label:SetModifyTextType(fontOverrides.modifyTextType) + end + control.label:SetText(text or texts.EmptyString) + end +end + +function CBs_Settings_List.SetupIcon(control, data) + if control.icon == nil then control.icon = GetControl(control, texts.Components.Icon) end + if control.icon ~= nil then + local hasIcon = data.icon ~= nil + control.icon:SetHidden(not hasIcon) + control.icon:SetTexture(data.icon and data.icon[1]) + + if data.icon[1] ~= nil and data.icon[3] ~= nil then + control:SetHandler(texts.Action.OnMouseEnter, function() control.icon:SetTexture(data.icon[3]) end) + control:SetHandler(texts.Action.OnMouseExit, function() control.icon:SetTexture(data.icon[1]) end) + end + return hasIcon 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 + control.label = GetControl(control, texts.Components.Name) + if control.label then if disabled then - nameControl:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) else - nameControl:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + control.label:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) end end - local valueLabelControl = GetControl(control, "ValueLabel") - if valueLabelControl then + control.valueLabelControl = GetControl(control, texts.Components.Value .. texts.Components.Label) + if control.valueLabelControl then if disabled then - valueLabelControl:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) + control.valueLabelControl:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) else - valueLabelControl:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) + control.valueLabelControl:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGBA()) end end - if control.button then - control.button:SetEnabled(not disabled) - end + if control.button then control.button:SetEnabled(not disabled) end - if control.comboBox then - control.comboBox: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.slider then control.slider:SetEnabled(not disabled) end - if control.editBox then - ZO_DefaultEdit_SetEnabled(control.editBox, not disabled) - end + if control.editBox then ZO_DefaultEdit_SetEnabled(control.editBox, not disabled) end end ------------------------------------------------------------------------------------------------- @@ -355,15 +345,15 @@ end function CBs_Settings_List:BuildMasterList() self.masterList = {} - self.base.AppendMasterListTypeGeneral(self, "General") - self.base.AppendMasterListTypeCollectionTypes(self, "CollectionTypes") - self.base.AppendMasterListTypeCombined(self, "Combined") + base.AppendMasterListTypeGeneral(self, texts.Components.General) + base.AppendMasterListTypeCategories(self, texts.Components.Categories) + base.AppendMasterListTypeCombined(self, texts.Components.Combined) if self._type then - self.base.AppendMasterListTypeSelection(self, "Selection") - self.base.AppendMasterListTypeCollection(self, "Collection") + base.AppendMasterListTypeSelection(self, texts.Components.Selection) + base.AppendMasterListTypeCategory(self, texts.Components.Category) else - self.base.AppendMasterListTypeNoCollectionType(self, "Selection") - self.base.AppendMasterListTypeNoCollectionType(self, "Collection") + base.AppendMasterListTypeNoCategory(self, texts.Components.Selection) + base.AppendMasterListTypeNoCategory(self, texts.Components.Category) end end @@ -373,10 +363,16 @@ function CBs_Settings_List:FilterScrollList() 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]) + if self.masterListType == texts.Components.Categories and self.masterList[i].parentKey ~= nil then + local savedTypeData = base.Saved[self.masterList[i].parentKey] + if savedTypeData ~= nil and savedTypeData.ShowChildren or savedTypeData == nil then + scrollData[#scrollData + 1] = ZO_ScrollList_CreateDataEntry(self.masterList[i].dataTypeId, self.masterList[i]) + end + else + scrollData[#scrollData + 1] = ZO_ScrollList_CreateDataEntry(self.masterList[i].dataTypeId, self.masterList[i]) + end end end end -function CBs_Settings_List:SortScrollList() -end +function CBs_Settings_List:SortScrollList() end diff --git a/Changelog b/Changelog index ede40f2..85fd546 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,35 @@ ------------------------------------------------------------------------------- Collection bars ------------------------------------------------------------------------------- +Version 1.0.8 (24-05-2020) +- Updated APIVersion to 100030 + +Menu: +- Support for LibAddonMenu-2.0 have been removed from the addon +- Setup is done solely from the settings window + +Bindings: +- Added binding to open settings window +- Added 10 bindings, total is now 20 + +Changes to Categories (previous "collection types"): +- Renamed to Categories +- Removed the hardcoded list of Categories +- Populates types based on ZO_CollectibleCategoryData +-- A category is shown when the category or its children has usable collectibles +- Categories are now named and ordered the same as in the ESO Collections view +- A category now has an icon, the icon from the parent category is shown for sub categories. +- A parent category can collapse its children +-- The icon highlights when hovering a parent category + +Texts: +- Moved "magic strings" through out the code to variables, making them reusable and allowing for better overview and reusability +- TODO: Identify patterns and improve, now nearly all strings are joined by .. not string.format. + +Improvements: +- Removed Base reference from CBs_Button +- Removed Base from CBs_Button + Version 1.0.7 (07-02-2020) -- Fixed issue when reloading the list of Collectibles, with no collection type selected -- Increased width of settings tabs, to allow for the full text: "Collection Types" diff --git a/CollectionBars.lua b/CollectionBars.lua index 8df8ddf..299d8f3 100644 --- a/CollectionBars.lua +++ b/CollectionBars.lua @@ -6,6 +6,7 @@ Filename: CollectionBars.lua -- VARIABLES -- ------------------------------------------------------------------------------------------------- local base = CollectionBars +local texts = base.Texts ------------------------------------------------------------------------------------------------- -- FUNCTIONS -- @@ -13,7 +14,7 @@ local base = CollectionBars function base.OnAddOnLoaded(_, addonName) if addonName == base.Addon.Name then - base.GenerateCollectionTypes() + base.GenerateCategories() base.Initialize() end end @@ -26,19 +27,13 @@ function base.Initialize() 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 + for _, _type in pairs(base.Types) do _type.Saved = base.Saved[_type.Name] - if _type.Saved.Enabled then - base.InitializeType(_type) - end + if _type.Saved.Enabled then base.InitializeType(_type) end end base.InitializeCombine() @@ -46,50 +41,47 @@ function base.InitializeWithSavedData() end function base.InitializeType(_type) - base.CreateCollection(_type) + base.CreateCategory(_type) base.SetupLabel(_type) base.RestoreFrame(_type) end function base.InitializeCombineFrame() - local name = base.Addon.Abbreviation .. "_CombineFrame" - base.Global.Combine.Frame = base.GetFrame(name, name) - base.Global.Combine.HideAll = base.GetFrame(name .. "HideAll", name .. "HideAll") + local frameName = base.Addon.Abbreviation .. texts.Helpers.Lowdash .. texts.Components.Combine .. texts.Components.Frame + base.Global.Combine.Frame = base.GetFrame(frameName, frameName) + local frameNameHideAll = frameName .. texts.Components.HideAll + base.Global.Combine.HideAll = base.GetFrame(frameNameHideAll, frameNameHideAll) end -function base.CreateCollection(_type) - local unlocked = GetTotalUnlockedCollectiblesByCategoryType(_type.TypeId) - _type.Collection = {} - _type.OrderedCollection = {} +function base.CreateCategory(_type) + local unlocked = GetTotalUnlockedCollectiblesByCategoryType(_type.CategoryType) + _type.Category = {} + _type.CategoryOrdered = {} _type.Unlocked = unlocked - _type.Total = GetTotalCollectiblesByCategoryType(_type.TypeId) - _type.IsUsable = IsCollectibleCategoryUsable(_type.TypeId) + _type.Total = GetTotalCollectiblesByCategoryType(_type.CategoryType) + _type.IsUsable = IsCollectibleCategoryUsable(_type.CategoryType) + + if unlocked > base.Global.HighestUnlocked then base.Global.HighestUnlocked = unlocked end - if unlocked > base.Global.HighestUnlocked then - base.Global.HighestUnlocked = unlocked - end - local elementsAdded = 1 for index = 1, _type.Total do - local id = GetCollectibleIdFromType(_type.TypeId, index) + local id = GetCollectibleIdFromType(_type.CategoryType, 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.OrderedCollection[elementsAdded] = _type.Collection[id] - elementsAdded = elementsAdded + 1 + _type.Category[id] = {Id = id, Name = name, EnabledTexture = icon, Disabled = not _unlocked, Tooltip = string.format(texts.Tooltip.Main, description, hint)} + table.insert(_type.CategoryOrdered, _type.Category[id]) end end - _type.Frame = base.GetFrame(_type.Name, base.Addon.Abbreviation .. "_Frame") + + _type.Frame = base.GetFrame(_type.Name, base.Addon.Abbreviation .. texts.Helpers.Lowdash .. texts.Components.Frame) end function base.RestoreFrames() - for _, _type in pairs(base.Type) do - base.RestoreFrame(_type) - end + for _, _type in pairs(base.Types) do base.RestoreFrame(_type) end base.RestoreCombine() end function base.HideOthers(newType) - for _, _type in pairs(base.Type) do + for _, _type in pairs(base.Types) do 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) @@ -114,20 +106,15 @@ end function base.RemoveFrame(_type) base.RemoveFragments(_type) - for _, _value in ipairs(_type.OrderedCollection) do - if base.Buttons[_value.Id] ~= nil then - base.Buttons[_value.Id]:SetHidden(true) - end + for _, _value in ipairs(_type.CategoryOrdered) do + local button = base.Buttons[_value.Id] + if button ~= nil then button:SetHidden(true) end end - if _type.Frame ~= nil then - _type.Frame:SetHidden(true) - end + if _type.Frame ~= nil then _type.Frame:SetHidden(true) end end -function base.InitializeCombine() - base.Global.Combine.Saved = base.Saved.Combine -end +function base.InitializeCombine() base.Global.Combine.Saved = base.Saved.Combine end function base.RestoreCombine() base.RestoreCombineLabels() diff --git a/CollectionBars.txt b/CollectionBars.txt index 308d69c..50d3c40 100644 --- a/CollectionBars.txt +++ b/CollectionBars.txt @@ -4,11 +4,11 @@ ; States and/or other countries. All rights reserved. ; You can read the full terms at https://account.elderscrollsonline.com/add-on-terms -## APIVersion: 100029 +## APIVersion: 100030 ## Title: Collection Bars -## Version: 1.0.7 +## Version: 1.0.8 ## Author: Jarth -## Description: Show collection bars and activate collections with key or button press. Shortcuts: Settings window: /cb LibAddonMenu: /cb_menu +## Description: Show collection bars and activate collections with key or button press. Shortcuts: Settings window: /cb ## ## 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,6 @@ ## SavedVariables: CollectionBars_Account ## SavedVariables: CollectionBars_Character -## OptionalDependsOn: LibAddonMenu-2.0 - CBs_Settings.xml CBs_Button.xml CollectionBars.xml @@ -27,7 +25,6 @@ CBs_Constants.lua CBs_Helpers.lua CBs_Button.lua CBs_Bindings.lua -CBs_Menu.lua CBs_MoveFrame.lua CBs_Fragment.lua CBs_Buttons.lua diff --git a/CollectionBars.xml b/CollectionBars.xml index ce8d9e5..eb9524e 100644 --- a/CollectionBars.xml +++ b/CollectionBars.xml @@ -2,7 +2,7 @@ <Controls> <TopLevelControl name="CBs_MoveFrame" clampedToScreen="true" movable="true" mouseEnabled="true" virtual="true" level="4"> <Controls> - <Backdrop name="$(parent)BG" level="2" > + <Backdrop name="$(parent)BG" level="2"> <AnchorFill /> </Backdrop> <Label name="$(parent)LabelTopLeft" wrapMode="ELLIPSIS" tier="HIGH" font="ZoFontWinH5" level="3">