diff --git a/CBs_Button.lua b/CBs_Button.lua index adc329b..3840a56 100644 --- a/CBs_Button.lua +++ b/CBs_Button.lua @@ -13,20 +13,20 @@ local texts = base.Texts ------------------------------------------------------------------------------------------------- CBs_Button = ZO_Object:Subclass() -function CBs_Button:New(_type, frame, cId, saved) +function CBs_Button:New(category, frame, cId, saved) local newB = ZO_Object.New(self) if newB then local lowdashButton = texts.Helpers.Lowdash .. texts.Components.Button - local ctrl = CreateControlFromVirtual(_type.Name .. lowdashButton, frame, base.Addon.Abbreviation .. lowdashButton, cId) + local ctrl = CreateControlFromVirtual(category.Name .. lowdashButton, frame, base.Addon.Abbreviation .. lowdashButton, cId) newB.cId = cId - newB.type = _type + newB.category = category newB.saved = saved newB.ctrl = ctrl newB.ctrl.cId = cId newB.button = ctrl:GetNamedChild(texts.Components.Button) newB.button:SetId(cId) - newB.button.tooltip = _type.Category[cId].Name + newB.button.tooltip = category.Collection[cId].Name newB.button.CBs = true newB.icon = ctrl:GetNamedChild(texts.Components.Icon) newB.cooldownIcon = ctrl:GetNamedChild(texts.Components.Cooldown .. texts.Components.Icon) @@ -51,7 +51,7 @@ end function CBs_Button:Setup() self.ctrl:SetHidden(false) - local texture = self.type.Category[self.cId].EnabledTexture + local texture = self.category.Collection[self.cId].EnabledTexture self.icon:SetTexture(texture) self.icon:SetHidden(false) @@ -63,9 +63,9 @@ function CBs_Button:Setup() 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.Category[self.cId].Name - ZO_Tooltips_ShowTextTooltip(self.button, self.type.Saved.Tooltip.Position, text) + if self.category.Saved.Tooltip.Show then + local text = self.category.Collection[self.cId].Name + ZO_Tooltips_ShowTextTooltip(self.button, self.category.Saved.Tooltip.Position, text) end end) self.button:SetHandler(texts.Action.OnMouseExit, function() ZO_Tooltips_HideTextTooltip() end) @@ -85,7 +85,7 @@ function CBs_Button:SetBindingText(show, cId) if self.buttonText ~= nil then ZO_Keybindings_UnregisterLabelForBindingUpdate(self.buttonText) self.buttonText:ClearAnchors() - self.buttonText:SetText(texts.EmptyString) + self.buttonText:SetText(texts.Helpers.EmptyString) if keyId ~= nil and show then ZO_Keybindings_UnregisterLabelForBindingUpdate(self.buttonText) self.buttonText:SetHeight(self.ctrl:GetHeight()) diff --git a/CBs_Buttons.lua b/CBs_Buttons.lua index 28240d7..decdbf1 100644 --- a/CBs_Buttons.lua +++ b/CBs_Buttons.lua @@ -11,11 +11,11 @@ local texts = base.Texts ------------------------------------------------------------------------------------------------- -- FUNCTIONS -- ------------------------------------------------------------------------------------------------- -function base.SetFrameAndCombineSize(_type) - local width, height = base.GetBarWidthHeight(_type) - base.SetFrameSizeIfExists(_type.Frame, width, height) +function base.SetFrameAndCombineSize(category) + local width, height = base.GetBarWidthHeight(category) + base.SetFrameSizeIfExists(category.Frame, width, height) - if _type.Saved.IsCombined and not _type.Saved.HideAll then base.SetFrameSizeIfExists(base.Global.Combine.Frame, width, height) end + if category.Saved.IsCombined and not category.Saved.HideAll then base.SetFrameSizeIfExists(base.Global.Combine.Frame, width, height) end end function base.GetFrame(name, virtual) @@ -26,34 +26,34 @@ function base.GetFrame(name, virtual) return frame end -function base.GetButtonPosition(_type, index) - local x = ((index - 1) % _type.BarDepth) * base.Saved.ButtonXY - local y = (math.floor((index - 1) / _type.BarDepth)) * base.Saved.ButtonXY +function base.GetButtonPosition(category, index) + local x = ((index - 1) % category.BarDepth) * base.Saved.ButtonXY + local y = (math.floor((index - 1) / category.BarDepth)) * base.Saved.ButtonXY - if not _type.Saved.Horizontal then + if not category.Saved.Horizontal then return y, x else return x, y end end -function base.SetupButtons(_type) +function base.SetupButtons(category) local index = 1 - local selected = _type.Saved.Selected - local frame = _type.Frame - local maxIndex = (_type.BarDepth or 0) * (_type.BarWidth or 0) + local selected = category.Saved.Selected + local frame = category.Frame + local maxIndex = (category.BarDepth or 0) * (category.BarWidth or 0) - _type.IsEmpty = true + category.IsEmpty = true - for _, _value in ipairs(_type.CategoryOrdered) do + for _, _value in ipairs(category.CollectionOrdered) 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(_type, frame, _value.Id, base.Saved) end + if category.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(category, frame, _value.Id, base.Saved) end - if not _type.Saved.HideAll and (maxIndex == 0 or index <= maxIndex) then + if not category.Saved.HideAll and (maxIndex == 0 or index <= maxIndex) then hideButton = false - local left, top = base.GetButtonPosition(_type, index) + local left, top = base.GetButtonPosition(category, index) base.Buttons[_value.Id]:SetBindingText(base.Saved.ShowBinding, _value.Id) base.Buttons[_value.Id]:Setup() base.Buttons[_value.Id]:UpdateAnchor(frame, left, top) @@ -61,8 +61,8 @@ function base.SetupButtons(_type) base.Buttons[_value.Id]:UpdateState() index = index + 1 end - _type.IsEmpty = false - elseif not _type.Saved.Enabled and base.Buttons[_value.Id] ~= nil then + category.IsEmpty = false + elseif not category.Saved.Enabled and base.Buttons[_value.Id] ~= nil then base.Buttons[_value.Id]:SetHidden(true) end @@ -73,30 +73,30 @@ function base.SetupButtons(_type) end 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 + local isHidden = (category.IsEmpty or not category.Saved.LabelShow) and not base.Global.EnableSettings or not category.Saved.Enabled + if category.Frame then category.Frame:SetHidden(isHidden) end - if _type.FrameLabel then _type.FrameLabel:SetHidden(isHidden) end + if category.FrameLabel then category.FrameLabel:SetHidden(isHidden) end end -function base.UpdateButtonsState(_type, forceId, isAttemptingActivation) - for _, _value in ipairs(_type.CategoryOrdered) do +function base.UpdateButtonsState(category, forceId, isAttemptingActivation) + for _, _value in ipairs(category.CollectionOrdered) do local button = base.Buttons[_value.Id] 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 +function base.UpdateButtonsCooldown(category, remaining, duration, cooldown) + for _cId in pairs(category.Saved.Selected) do local button = base.Buttons[_cId] - if button ~= nil and type.Category[_cId] then button:UpdateCooldown(remaining, duration, cooldown) end + if button ~= nil and category.Collection[_cId] then button:UpdateCooldown(remaining, duration, cooldown) end end end function base.GetCooldownText(countDown, duration) - local cooldown = texts.EmptyString + local cooldown = texts.Helpers.EmptyString - if type(duration) == texts.Type.Number and countDown.StartTime ~= nil then + if type(duration) == texts.Helpers.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) @@ -106,10 +106,10 @@ function base.GetCooldownText(countDown, duration) end function base.IsCollectibleUsable(button) - local isCollectibleUsable = button ~= nil and button.type.Cooldown.StartTime == nil and IsCollectibleUsable(button.cId) + local isCollectibleUsable = button ~= nil and button.category.Cooldown.StartTime == nil and IsCollectibleUsable(button.cId) if not isCollectibleUsable and button.cId then - local startTime = button.type.Cooldown.StartTime or 0 + local startTime = button.category.Cooldown.StartTime or 0 local _, duration = GetCollectibleCooldownAndDuration(button.cId) isCollectibleUsable = startTime + duration < GetFrameTimeMilliseconds() end @@ -120,35 +120,36 @@ end function base.Activate(button) if base.IsCollectibleUsable(button) then if button and base.Saved.IsActiveActivationEnabled then - EVENT_MANAGER:UnregisterForEvent(base.Addon.Abbreviation .. button.type.Name .. tostring(button.type.EventTS), EVENT_COLLECTIBLE_USE_RESULT) - button.type.EventTS = GetTimeStamp() - EVENT_MANAGER:RegisterForEvent(base.Addon.Abbreviation .. button.type.Name .. tostring(button.type.EventTS), EVENT_COLLECTIBLE_USE_RESULT, function(_, result, isAttemptingActivation) - local countDown = button.type.Cooldown + EVENT_MANAGER:UnregisterForEvent(base.Addon.Abbreviation .. button.category.Name .. tostring(button.category.EventTS), EVENT_COLLECTIBLE_USE_RESULT) + button.category.EventTS = GetTimeStamp() + EVENT_MANAGER:RegisterForEvent(base.Addon.Abbreviation .. button.category.Name .. tostring(button.category.EventTS), EVENT_COLLECTIBLE_USE_RESULT, + function(_, result, isAttemptingActivation) + local countDown = button.category.Cooldown local success = false if result == COLLECTIBLE_USAGE_BLOCK_REASON_NOT_BLOCKED and button.button then success = true countDown.CollectibleId = button.cId - base.UpdateButtonsState(button.type, button.cId, isAttemptingActivation) + base.UpdateButtonsState(button.category, button.cId, isAttemptingActivation) end local successActivate = isAttemptingActivation and success countDown.StartTime = GetFrameTimeMilliseconds() - EVENT_MANAGER:UnregisterForEvent(base.Addon.Abbreviation .. button.type.Name .. tostring(button.type.EventTS), EVENT_COLLECTIBLE_USE_RESULT) + EVENT_MANAGER:UnregisterForEvent(base.Addon.Abbreviation .. button.category.Name .. tostring(button.category.EventTS), EVENT_COLLECTIBLE_USE_RESULT) if success then - EVENT_MANAGER:UnregisterForUpdate(base.Addon.Abbreviation .. button.type.Name .. countDown.Event) - EVENT_MANAGER:RegisterForUpdate(base.Addon.Abbreviation .. button.type.Name .. countDown.Event, countDown.Tick, function() + EVENT_MANAGER:UnregisterForUpdate(base.Addon.Abbreviation .. button.category.Name .. countDown.Event) + EVENT_MANAGER:RegisterForUpdate(base.Addon.Abbreviation .. button.category.Name .. countDown.Event, countDown.Tick, function() local remaining, duration = GetCollectibleCooldownAndDuration(countDown.CollectibleId) local cooldown = base.GetCooldownText(countDown, duration) - base.UpdateButtonsCooldown(button.type, remaining, duration, cooldown) + base.UpdateButtonsCooldown(button.category, remaining, duration, cooldown) if duration == 0 then countDown.StartTime = nil local isActive = successActivate or IsCollectibleActive(button.cId) - base.UpdateButtonsState(button.type, button.cId, isActive) - EVENT_MANAGER:UnregisterForUpdate(base.Addon.Abbreviation .. button.type.Name .. countDown.Event) + base.UpdateButtonsState(button.category, button.cId, isActive) + EVENT_MANAGER:UnregisterForUpdate(base.Addon.Abbreviation .. button.category.Name .. countDown.Event) end end) end diff --git a/CBs_Constants.lua b/CBs_Constants.lua index ea09a7a..cc4c6f0 100644 --- a/CBs_Constants.lua +++ b/CBs_Constants.lua @@ -7,7 +7,7 @@ Filename: CBs_Constants.lua ------------------------------------------------------------------------------------------------- CollectionBars = { WM = GetWindowManager(), - Addon = {Name = "CollectionBars", DisplayName = "Collection Bars", Abbreviation = "CBs", Version = 1.0, MinorVersion = 0.8, SettingsSlash = "/cb", Author = "Jarth"}, + Addon = {Name = "CollectionBars", DisplayName = "Collection Bars", Abbreviation = "CBs", Version = 1.0, MinorVersion = 0.9, SettingsSlash = "/cb", Author = "Jarth"}, Buttons = {}, Default = { BarDepth = 5, @@ -56,8 +56,8 @@ CollectionBars = { ReverseBindings = {}, SettingsFrame = nil, SettingsList = nil, - 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}, + SettingsFilters = {["Categories"] = "Categories", ["Collectibles"] = "Collectibles", ["Category"] = "Category", ["General"] = "General", ["Combined"] = "Combined bar"}, + Combine = {Name = "Combine", EventTS = nil, MoveFrame = nil, Frame = nil, category = 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"}, ScenePairs = { @@ -72,8 +72,8 @@ CollectionBars = { }, HighestUnlocked = 0 }, - Types = {}, - TypesOrdered = {}, + Categories = {}, + CategoriesOrdered = {}, Texts = { Action = { UpdateColor = "UpdateColor", @@ -85,7 +85,7 @@ CollectionBars = { OnMouseExit = "OnMouseExit", OnMouseDown = "OnMouseDown", OnMouseUp = "OnMouseUp", - OnUpdate = "OnUpdate", + OnUpdate = "OnUpdate" }, Font = {ZoFontWinT1 = "ZoFontWinT1", ZoFontWinH4 = "ZoFontWinH4"}, Format = {Number = "%.2f", Decimal = "%d", Comma = "%s,%s"}, @@ -123,7 +123,7 @@ CollectionBars = { Parent = "$(parent)", Default = "Default", Marker = "Marker", - Selection = "Selection", + Collectibles = "Collectibles", Category = "Category", Categories = "Categories", List = "List", @@ -136,11 +136,9 @@ CollectionBars = { 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"} + Tooltip = {Main = "%s\n%s"}, + Helpers = {Lowdash = "_", Minus = "-", Plus = "+", Space = " ", Dot = ".", Comma = ",", Number = "number", EmptyString = "", Empty = "empty", BarDepth = "BarDepth", BarWidth = "BarWidth"}, + Settings = {ToggleMoveFrameText = "Toggle move frame", ReloadText = "Reload list of 'Collectibles'\nHint: Usefull after gaining a new collectible)"} } } @@ -149,21 +147,21 @@ CollectionBars = { ------------------------------------------------------------------------------------------------- function CollectionBars.GenerateCategories() - CollectionBars.Types = {} + CollectionBars.Categories = {} 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) + local type = CollectionBars.GetType(categoryData) + if type ~= nil and CollectionBars.CategoryHasUsableCollectible(categoryData) then + CollectionBars.AddCategory(type, 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()) + type = CollectionBars.GetType(subcategoryData) + if type ~= nil and subcategoryData ~= nil and subcategoryData:HasShownCollectiblesInCollection() then + CollectionBars.AddCategory(type, subcategoryData, parentIcons, false, categoryData:GetFormattedName()) end end end @@ -172,41 +170,39 @@ function CollectionBars.GenerateCategories() end end -function CollectionBars.GetCategoryType(categoryData) - local categoryType = nil +function CollectionBars.GetType(categoryData) + local type = nil local collectibles = categoryData:GetCollectibleDataBySpecializedSort() - if collectibles ~= nil and collectibles[1] ~= nil then categoryType = collectibles[1]:GetCategoryType() end + if collectibles ~= nil and collectibles[1] ~= nil then type = collectibles[1]:GetCategoryType() end - return categoryType + return type end -function CollectionBars.AddCategory(categoryType, categoryData, parentIcons, hasChildren, parentKey) +function CollectionBars.AddCategory(type, 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, + CollectionBars.Categories[categoryName] = { + Collection = {}, + CollectionOrdered = {}, + Type = type, + CategoryData = categoryData, 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]) + table.insert(CollectionBars.CategoriesOrdered, CollectionBars.Categories[categoryName]) CollectionBars.Default[categoryName] = { Selected = {}, Enabled = false, @@ -243,8 +239,8 @@ 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 + local type = CollectionBars.GetType(subcategoryData) + if type ~= 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 b3b98ff..5052bc2 100644 --- a/CBs_Fragment.lua +++ b/CBs_Fragment.lua @@ -12,27 +12,27 @@ local texts = base.Texts -- FUNCTIONS -- ------------------------------------------------------------------------------------------------- function base.UpdateFragments(fragmentType) - for _, _type in pairs(base.Types) do if _type.Saved.Enabled then base.UpdateFragment(_type, fragmentType) end end + for _, category in pairs(base.Categories) do if category.Saved.Enabled then base.UpdateFragment(category, fragmentType) end end base.UpdateFragment(base.Global.Combine, fragmentType) end -function base.UpdateFragment(_type, fragmentType) +function base.UpdateFragment(category, fragmentType) local currentScene = SCENE_MANAGER:GetCurrentScene() - local isHidden = (currentScene == nil or currentScene:GetName() == texts.Type.Empty) and not base.Saved.ShowBarOnHud + local isHidden = (currentScene == nil or currentScene:GetName() == texts.Helpers.Empty) and not base.Saved.ShowBarOnHud - if _type.Fragment == nil then _type.Fragment = ZO_HUDFadeSceneFragment:New(_type.Frame) end + if category.Fragment == nil then category.Fragment = ZO_HUDFadeSceneFragment:New(category.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(category.Fragment) then scene:AddFragment(category.Fragment) end else - scene:RemoveFragment(_type.Fragment) + scene:RemoveFragment(category.Fragment) end end if scene == currentScene then isHidden = isHidden or not base.Saved[key] end end - _type.Frame:SetHidden(isHidden) + category.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(category) if category.Fragment ~= nil then for _, scene in pairs(base.Global.ScenePairs) do if scene ~= nil then scene:RemoveFragment(category.Fragment) end end end end diff --git a/CBs_Helpers.lua b/CBs_Helpers.lua index f67d493..69192e5 100644 --- a/CBs_Helpers.lua +++ b/CBs_Helpers.lua @@ -63,24 +63,24 @@ function base.GetLocationText(value) return result end -function base.RestorePosition(_type) - _type.Frame:ClearAnchors() +function base.RestorePosition(category) + category.Frame:ClearAnchors() local combineFrame = base.Global.Combine.Frame - if not _type.Saved.IsCombined or not combineFrame then - _type.Frame:SetAnchor(_type.Saved.Label.PositionTarget, GuiRoot, TOPLEFT, _type.Saved.X, _type.Saved.Y) - elseif _type.Saved.IsCombined then - if not _type.Saved.HideAll then - _type.Frame:SetAnchorFill(combineFrame) + if not category.Saved.IsCombined or not combineFrame then + category.Frame:SetAnchor(category.Saved.Label.PositionTarget, GuiRoot, TOPLEFT, category.Saved.X, category.Saved.Y) + elseif category.Saved.IsCombined then + if not category.Saved.HideAll then + category.Frame:SetAnchorFill(combineFrame) else - _type.Frame:SetAnchor(TOPLEFT, combineFrame, TOPLEFT, 0, 0) + category.Frame:SetAnchor(TOPLEFT, combineFrame, TOPLEFT, 0, 0) end end end -function base.GetLabelPostFix(_type) - local postFix = texts.EmptyString - if _type.Saved.HideAllEnabled then - if not _type.Saved.HideAll then +function base.GetLabelPostFix(category) + local postFix = texts.Helpers.EmptyString + if category.Saved.HideAllEnabled then + if not category.Saved.HideAll then postFix = texts.Helpers.Space .. texts.Helpers.Minus else postFix = texts.Helpers.Space .. texts.Helpers.Plus @@ -89,10 +89,10 @@ function base.GetLabelPostFix(_type) return postFix end -function base.IsAllSelected(_type) +function base.IsAllSelected(category) local isAllSelected = true - for _, collectible in pairs(_type.Category) do - if _type.Saved.Selected[collectible.Id] == nil then + for _, collectible in pairs(category.Collection) do + if category.Saved.Selected[collectible.Id] == nil then isAllSelected = false break end @@ -101,12 +101,12 @@ function base.IsAllSelected(_type) return isAllSelected end -function base.SelectAll(_type, newValue) - for _, collectible in pairs(_type.Category) do +function base.SelectAll(category, newValue) + for _, collectible in pairs(category.Collection) do if newValue == true then - _type.Saved.Selected[collectible.Id] = newValue + category.Saved.Selected[collectible.Id] = newValue else - _type.Saved.Selected[collectible.Id] = nil + category.Saved.Selected[collectible.Id] = nil end end end @@ -143,30 +143,32 @@ function base.ResetAccountSettings() end end -function base.GetBarWidthHeight(_type) +function base.GetBarWidthHeight(category) 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 - local function GetBarMaxCount(type) - local barConstraintXY = _type.Saved[type] + if not category.Saved.HideAll then + for key, value in pairs(category.Saved.Selected) do if IsCollectibleUnlocked(key) and IsCollectibleValidForPlayer(key) and value then count = count + 1 end end + end + local function GetBarMaxCount(constraint) + local barConstraintXY = category.Saved[constraint] - if _type.Saved.IsCombined then barConstraintXY = base.Saved.Combine[type] end + if category.Saved.IsCombined then barConstraintXY = base.Saved.Combine[constraint] end - if barConstraintXY == 0 then barConstraintXY = base.Saved[type] end + if barConstraintXY == 0 then barConstraintXY = base.Saved[constraint] end if count < barConstraintXY then barConstraintXY = count end return barConstraintXY end - _type.BarDepth, _type.BarWidth = GetBarMaxCount(texts.Type.BarDepth), GetBarMaxCount(texts.Type.BarWidth) + category.BarDepth, category.BarWidth = GetBarMaxCount(texts.Helpers.BarDepth), GetBarMaxCount(texts.Helpers.BarWidth) if count > 0 then - local barWidth = math.ceil(count / _type.BarDepth) - local maxBarWidth = _type.BarWidth + local barWidth = math.ceil(count / category.BarDepth) + local maxBarWidth = category.BarWidth 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) + local isHorizontal = category.Saved.Horizontal + width = base.Saved.ButtonXY * (not isHorizontal and barWidth or category.BarDepth) + height = base.Saved.ButtonXY * (isHorizontal and barWidth or category.BarDepth) end return width, height diff --git a/CBs_Labels.lua b/CBs_Labels.lua index cd22911..4656c42 100644 --- a/CBs_Labels.lua +++ b/CBs_Labels.lua @@ -11,85 +11,85 @@ local texts = base.Texts ------------------------------------------------------------------------------------------------- -- FUNCTIONS -- ------------------------------------------------------------------------------------------------- -function base.SetupLabel(_type) +function base.SetupLabel(category) local hideAllId = base.Addon.Abbreviation .. texts.Helpers.Lowdash .. texts.Components.HideAll - if _type.FrameLabel == nil then - _type.FrameLabel = GetControl(hideAllId .. _type.Name) - if _type.FrameLabel == nil then _type.FrameLabel = base.WM:CreateControlFromVirtual(hideAllId, _type.Frame, hideAllId, _type.Name) end + if category.FrameLabel == nil then + category.FrameLabel = GetControl(hideAllId .. category.Name) + if category.FrameLabel == nil then category.FrameLabel = base.WM:CreateControlFromVirtual(hideAllId, category.Frame, hideAllId, category.Name) end end - _type.FrameLabel:SetHidden(not _type.Saved.LabelShow and not _type.Saved.IsCombined) + category.FrameLabel:SetHidden(not category.Saved.LabelShow and not category.Saved.IsCombined) - _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(texts.Action.OnClicked, function(_, button) + category.FrameToggleSettings = GetControl(hideAllId .. category.Name .. texts.Components.Toggle .. texts.Components.Settings) + category.FrameLabelButton = GetControl(hideAllId .. category.Name .. texts.Components.Button) + if category.FrameLabelButton ~= nil then + category.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 - base.RestoreFrame(_type) + elseif button == MOUSE_BUTTON_INDEX_LEFT and category.Saved.HideAllEnabled or category.Saved.IsCombined then + category.Saved.HideAll = not category.Saved.HideAll + if category.Saved.IsCombined then base.HideOthers(category) end + base.RestoreFrame(category) base.RestoreCombine() end end) end - base.SetupToggleSettings(_type) + base.SetupToggleSettings(category) end -function base.RestoreLabel(_type) - local label = _type.Saved.Label - local frameLabel = _type.FrameLabel +function base.RestoreLabel(category) + local label = category.Saved.Label + local frameLabel = category.FrameLabel if frameLabel ~= nil then 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 - frameLabel:SetHidden(not _type.Saved.LabelShow and not _type.Saved.IsCombined and not base.Global.EnableSettings) + if not category.Saved.IsCombined then frameLabel:SetAnchor(label.Position, category.Frame, label.PositionTarget, label.OffsetX, label.OffsetY) end + frameLabel:SetHidden(not category.Saved.LabelShow and not category.Saved.IsCombined and not base.Global.EnableSettings) end - local frameLabelButton = _type.FrameLabelButton + local frameLabelButton = category.FrameLabelButton if frameLabelButton ~= nil then frameLabelButton:SetHidden(false) frameLabelButton:SetFont(label.Font) frameLabelButton:SetHorizontalAlignment(TEXT_ALIGN_LEFT) frameLabelButton:SetVerticalAlignment(TOP) - frameLabelButton:SetText(tostring(_type.Saved.Display) .. base.GetLabelPostFix(_type)) + frameLabelButton:SetText(tostring(category.Saved.Display) .. base.GetLabelPostFix(category)) end - local frameLabelToggleSettings = _type.FrameToggleSettings + local frameLabelToggleSettings = category.FrameToggleSettings if frameLabelToggleSettings ~= nil then frameLabelToggleSettings:SetHidden(false) end end -function base.RemoveLabel(_type) - if _type.FrameLabel ~= nil then - _type.FrameLabel:ClearAnchors() - _type.FrameLabel:SetHidden(true) +function base.RemoveLabel(category) + if category.FrameLabel ~= nil then + category.FrameLabel:ClearAnchors() + category.FrameLabel:SetHidden(true) end - if _type.FrameLabelButton ~= nil then _type.FrameLabelButton:SetHidden(true) end + if category.FrameLabelButton ~= nil then category.FrameLabelButton:SetHidden(true) end - if _type.FrameToggleSettings ~= nil then _type.FrameToggleSettings:SetHidden(true) end + if category.FrameToggleSettings ~= nil then category.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.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) - _type.FrameLabel:ClearAnchors() - _type.FrameLabel:SetHidden(not hasSelected and not _type.Saved.LabelShow and not base.Global.EnableSettings) - if not _type.FrameLabel:IsHidden() or (_type.Saved.LabelShow and hasSelected) or base.Global.EnableSettings then - width = width + _type.Saved.Label.OffsetX - local offsetY = _type.Saved.Label.OffsetY + combineLabel.OffsetY - _type.FrameLabel:SetAnchor(TOPLEFT, base.Global.Combine.HideAll, TOPLEFT, width, offsetY) - width = width + _type.FrameLabel:GetWidth() - local labelHeight = _type.FrameLabel:GetHeight() + for _, category in pairs(base.CategoriesOrdered) do + if category.Saved.Enabled and category.Saved.IsCombined and category.FrameLabel then + if (not category.IsEmpty or base.Global.EnableSettings) then + local hasSelected = not base.HasAny(category.Saved.Selected) + category.FrameLabel:ClearAnchors() + category.FrameLabel:SetHidden(not hasSelected and not category.Saved.LabelShow and not base.Global.EnableSettings) + if not category.FrameLabel:IsHidden() or (category.Saved.LabelShow and hasSelected) or base.Global.EnableSettings then + width = width + category.Saved.Label.OffsetX + local offsetY = category.Saved.Label.OffsetY + combineLabel.OffsetY + category.FrameLabel:SetAnchor(TOPLEFT, base.Global.Combine.HideAll, TOPLEFT, width, offsetY) + width = width + category.FrameLabel:GetWidth() + local labelHeight = category.FrameLabel:GetHeight() if labelHeight > height then height = labelHeight end end end diff --git a/CBs_MoveFrame.lua b/CBs_MoveFrame.lua index 5b3ea1c..6cfd443 100644 --- a/CBs_MoveFrame.lua +++ b/CBs_MoveFrame.lua @@ -33,23 +33,23 @@ function base.GetMoveFrameSnapPosition(frame, positionTargetXY, snapSize) return (zo_round(x / snapSize) * snapSize), (zo_round(y / snapSize) * snapSize) end -function base.UpdateMoveFrame(_type) - local moveFrame = _type.MoveFrame - local targetFrame = _type.Frame +function base.UpdateMoveFrame(category) + local moveFrame = category.MoveFrame + local targetFrame = category.Frame local onMouseEnter, onMouseExit, onMouseDown, onMouseUp = nil, nil, nil, nil - 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) + if base.Global.IsMoveEnabled and (category.Name == texts.Components.Combine or not category.IsEmpty and not category.Saved.IsCombined) then + moveFrame = base.GetOrCreateMoveFrame(targetFrame, category) 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 + local saved = frame.category.Saved frame.MoveFrameOnUpdate(frame) frame.MoveFrameUpdateText(frame, false) frame:SetHandler(texts.Action.OnUpdate, nil) - saved.X, saved.Y = base.GetMoveFrameSnapPosition(frame, _type.Saved.Label.PositionTarget, frame.Saved.SnapSize) + saved.X, saved.Y = base.GetMoveFrameSnapPosition(frame, category.Saved.Label.PositionTarget, frame.Saved.SnapSize) end end @@ -70,29 +70,31 @@ function base.UpdateMoveFrame(_type) end end -function base.GetOrCreateMoveFrame(targetFrame, _type) - if _type.MoveFrame == nil then +function base.GetOrCreateMoveFrame(targetFrame, category) + if category.MoveFrame == nil then local moveFrame = texts.Components.Move .. texts.Components.Frame local lowdashMoveFrame = texts.Helpers.Lowdash .. moveFrame - local moveFrameName = _type.Name .. lowdashMoveFrame + local moveFrameName = category.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.category = category newMoveFrame[moveFrame .. texts.Action.UpdateText] = function(frame, position) - local labelTextTopLeft = texts.EmptyString + local labelTextTopLeft = texts.Helpers.EmptyString - 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(texts.Format.Comma, base.GetMoveFrameSnapPosition(frame.TargetFrame, category.Saved.Label.PositionTarget, frame.Saved.SnapSize)) + end frame.labelCenter:SetText(string.format(texts.Format.Comma, frame:GetWidth(), frame:GetHeight())) frame.labelTopLeft:SetText(labelTextTopLeft) end newMoveFrame[moveFrame .. texts.Action.OnUpdate] = function(frame) - local x, y = base.GetMoveFrameSnapPosition(frame, _type.Saved.Label.PositionTarget, frame.Saved.SnapSize) + local x, y = base.GetMoveFrameSnapPosition(frame, category.Saved.Label.PositionTarget, frame.Saved.SnapSize) frame.TargetFrame:ClearAnchors() - frame.TargetFrame:SetAnchor(_type.Saved.Label.PositionTarget, GuiRoot, TOPLEFT, x, y) + frame.TargetFrame:SetAnchor(category.Saved.Label.PositionTarget, GuiRoot, TOPLEFT, x, y) frame.MoveFrameUpdateText(frame, true) end newMoveFrame[moveFrame .. texts.Action.UpdateColor] = function(frame) @@ -118,8 +120,8 @@ function base.GetOrCreateMoveFrame(targetFrame, _type) newMoveFrame.labelCenter:SetVerticalAlignment(TEXT_ALIGN_CENTER) end - _type.MoveFrame = newMoveFrame + category.MoveFrame = newMoveFrame end - return _type.MoveFrame + return category.MoveFrame end diff --git a/CBs_Settings.lua b/CBs_Settings.lua index ed83caf..4be7e2e 100644 --- a/CBs_Settings.lua +++ b/CBs_Settings.lua @@ -19,27 +19,27 @@ function base.ToggleEnableSettings() base.RestoreCombineLabels() end -function base.SetupToggleSettings(_type) - local toggleSettings = GetControl(base.Addon.Abbreviation .. texts.Helpers.Lowdash .. texts.Components.HideAll .. _type.Name .. texts.Components.Toggle .. texts.Components.Settings) +function base.SetupToggleSettings(category) + local toggleSettings = GetControl(base.Addon.Abbreviation .. texts.Helpers.Lowdash .. texts.Components.HideAll .. category.Name .. texts.Components.Toggle .. texts.Components.Settings) if toggleSettings then - local hideAllSettingsFunc = function() base.ShowSettings(_type) end + local hideAllSettingsFunc = function() base.ShowSettings(category) end toggleSettings:SetHandler(texts.Action.OnClicked, hideAllSettingsFunc) end end -function base.UpdateToggleSettings(_type) +function base.UpdateToggleSettings(category) local offsetX = 0 if base.Global.EnableSettings then offsetX = -19 end - if _type.FrameLabel and _type.FrameToggleSettings then - _type.FrameToggleSettings:ClearAnchors() - _type.FrameToggleSettings:SetAnchor(TOPLEFT, _type.FrameLabel, TOPRIGHT, offsetX, 0) - _type.FrameToggleSettings:SetAnchor(BOTTOMRIGHT, _type.FrameLabel, BOTTOMRIGHT, 0, 0) + if category.FrameLabel and category.FrameToggleSettings then + category.FrameToggleSettings:ClearAnchors() + category.FrameToggleSettings:SetAnchor(TOPLEFT, category.FrameLabel, TOPRIGHT, offsetX, 0) + category.FrameToggleSettings:SetAnchor(BOTTOMRIGHT, category.FrameLabel, BOTTOMRIGHT, 0, 0) end - if _type.FrameLabel and _type.FrameLabelButton then - _type.FrameLabelButton:ClearAnchors() - _type.FrameLabelButton:SetAnchor(TOPLEFT, _type.FrameLabel, TOPLEFT, 0, 0) - _type.FrameLabelButton:SetAnchor(BOTTOMRIGHT, _type.FrameLabel, BOTTOMRIGHT, offsetX, 0) + if category.FrameLabel and category.FrameLabelButton then + category.FrameLabelButton:ClearAnchors() + category.FrameLabelButton:SetAnchor(TOPLEFT, category.FrameLabel, TOPLEFT, 0, 0) + category.FrameLabelButton:SetAnchor(BOTTOMRIGHT, category.FrameLabel, BOTTOMRIGHT, offsetX, 0) end end @@ -50,11 +50,11 @@ function base.SetupSettingsFrameHandlers(control, text, onClicked) control:SetHandler(texts.Action.OnMouseExit, function() ZO_Tooltips_HideTextTooltip() end) end -function base.SetupSetttingsFrame(_type) +function base.SetupSetttingsFrame(category) 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 .. texts.Components.Label) - base.Global.SettingsList = CBs_Settings_List:New(_type, base.Global.SettingsFrame) + base.Global.SettingsList = CBs_Settings_List:New(category, base.Global.SettingsFrame) local titleControl = GetControl(selector .. texts.Components.Title) titleControl:SetText(base.Addon.DisplayName .. texts.Helpers.Space .. texts.Components.Settings) @@ -76,9 +76,9 @@ function base.SetupSetttingsFrame(_type) 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.CreateCategory(base.Global.SettingsList._type) - base.RestoreFrame(base.Global.SettingsList._type) + if base.Global.SettingsList.category ~= nil then + base.CreateCategory(base.Global.SettingsList.category) + base.RestoreFrame(base.Global.SettingsList.category) end base.RestoreCombineLabels() base.Global.SettingsList:RefreshData() @@ -99,21 +99,21 @@ function base.SetupSettingsFilter(control, controlName, displayName) end end -function base.ShowSettings(_type) +function base.ShowSettings(category) local show = base.Global.SettingsFrame == nil - if show then base.SetupSetttingsFrame(_type) end + if show then base.SetupSetttingsFrame(category) end - show = show or base.Global.SettingsFrame:IsHidden() or _type ~= base.Global.SettingsList._type + show = show or base.Global.SettingsFrame:IsHidden() or category ~= base.Global.SettingsList.category base.Global.SettingsFrame:SetHidden(not show) - base.UpdateSettingsType(show, _type) + base.UpdateSettingsType(show, category) if show then - base.Global.SettingsList._type = show and _type or nil + base.Global.SettingsList.category = show and category or nil base.Global.SettingsList:RefreshData() end end -function base.UpdateSettingsType(show, _type) - if base.Global.SettingsList ~= nil then base.Global.SettingsList._type = _type end +function base.UpdateSettingsType(show, category) + if base.Global.SettingsList ~= nil then base.Global.SettingsList.category = category end - if base.Global.SettingsLabel ~= nil then base.Global.SettingsLabel:SetText(show and _type and _type.Name or texts.Components.Global) end + if base.Global.SettingsLabel ~= nil then base.Global.SettingsLabel:SetText(show and category and category.Name or texts.Components.Global) end end diff --git a/CBs_Settings.xml b/CBs_Settings.xml index 31df0a8..9df036a 100644 --- a/CBs_Settings.xml +++ b/CBs_Settings.xml @@ -33,12 +33,12 @@ <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)"> + <Button name="$(parent)Collectibles" inherits="ZO_DefaultButton" clickSound="Click" relativeTo="$(parent)"> <Anchor point="TOPLEFT" relativeTo="$(parent)Categories" relativePoint="TOPRIGHT" /> <Dimensions x="122" y="22" /> </Button> <Button name="$(parent)Category" inherits="ZO_DefaultButton" clickSound="Click" relativeTo="$(parent)"> - <Anchor point="TOPLEFT" relativeTo="$(parent)Selection" relativePoint="TOPRIGHT" /> + <Anchor point="TOPLEFT" relativeTo="$(parent)Collectibles" relativePoint="TOPRIGHT" /> <Dimensions x="122" y="22" /> </Button> <Button name="$(parent)Combined" inherits="ZO_DefaultButton" clickSound="Click" relativeTo="$(parent)"> diff --git a/CBs_Settings_Data.lua b/CBs_Settings_Data.lua index 27e7ac7..5efc149 100644 --- a/CBs_Settings_Data.lua +++ b/CBs_Settings_Data.lua @@ -11,8 +11,8 @@ local texts = base.Texts ------------------------------------------------------------------------------------------------- -- FUNCTIONS -- ------------------------------------------------------------------------------------------------- -function base.AppendMasterListTypeGeneral(self, typeSelection) - self:AppendRow_Checkbox(typeSelection, { +function base.AppendMasterListTypeGeneral(self, listType) + self:AppendRow_Checkbox(listType, { name = "Use account settings", tooltip = "When ON the account settings will be used. When OFF character settings will be used", funcGet = function() return base.Saved.UseAccountSettings end, @@ -24,7 +24,7 @@ function base.AppendMasterListTypeGeneral(self, typeSelection) base.Global.SettingsList:RefreshData() end }) - self:AppendRow_Button(typeSelection, { + self:AppendRow_Button(listType, { name = "Reset settings", buttonName = "Reset", funcSet = function() @@ -36,9 +36,9 @@ function base.AppendMasterListTypeGeneral(self, typeSelection) base.Global.SettingsList:RefreshData() end }) - self:AppendRow_Title(typeSelection, {name = "Position and size"}) - self:AppendRow_Divider(typeSelection, {}) - self:AppendRow_Checkbox(typeSelection, { + self:AppendRow_Title(listType, {name = "Position and size"}) + self:AppendRow_Divider(listType, {}) + self:AppendRow_Checkbox(listType, { 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 base.Global.IsMoveEnabled end, @@ -47,7 +47,7 @@ function base.AppendMasterListTypeGeneral(self, typeSelection) base.RestoreFrames() end }) - self:AppendRow_Slider(typeSelection, { + self:AppendRow_Slider(listType, { name = "Choose snap size when moving", tooltipText = "Choose snap size when moving", funcGet = function() return base.Saved.SnapSize end, @@ -64,7 +64,7 @@ function base.AppendMasterListTypeGeneral(self, typeSelection) valueFormat = texts.Format.Number, showValue = true }) - self:AppendRow_Slider(typeSelection, { + self:AppendRow_Slider(listType, { name = "Choose max bar depth", tooltipText = "Choose max bar depth\n(number of inverse rows/columns)", funcGet = function() return base.Saved.BarDepth end, @@ -81,7 +81,7 @@ function base.AppendMasterListTypeGeneral(self, typeSelection) valueFormat = texts.Format.Number, showValue = true }) - self:AppendRow_Slider(typeSelection, { + self:AppendRow_Slider(listType, { name = "Choose max bar height", tooltipText = "Choose max bar height\n(number of inverse rows/columns)", funcGet = function() return base.Saved.BarWidth end, @@ -98,7 +98,7 @@ function base.AppendMasterListTypeGeneral(self, typeSelection) valueFormat = texts.Format.Number, showValue = true }) - self:AppendRow_Checkbox(typeSelection, { + self:AppendRow_Checkbox(listType, { name = "Show binding's on bar", tooltipText = "When ON the binding's will be shown on the bar", funcGet = function() return base.Saved.ShowBinding end, @@ -107,7 +107,7 @@ function base.AppendMasterListTypeGeneral(self, typeSelection) base.RestoreFrames() end }) - self:AppendRow_Slider(typeSelection, { + self:AppendRow_Slider(listType, { name = "Choose button size", tooltipText = "Choose button size", funcGet = function() return base.Saved.ButtonXY end, @@ -126,9 +126,9 @@ function base.AppendMasterListTypeGeneral(self, typeSelection) }) local whenOnTheBar = "When ON the bar will show the bar " - self:AppendRow_Title(typeSelection, {name = "Visibility"}) - self:AppendRow_Divider(typeSelection, {}) - self:AppendRow_Checkbox(typeSelection, { + self:AppendRow_Title(listType, {name = "Visibility"}) + self:AppendRow_Divider(listType, {}) + self:AppendRow_Checkbox(listType, { name = "Show bar on main view/hud", tooltipText = string.format("%s on main view/hud", whenOnTheBar), funcGet = function() return base.Saved.ShowBarOnHud end, @@ -137,7 +137,7 @@ function base.AppendMasterListTypeGeneral(self, typeSelection) base.UpdateFragments("ShowBarOnHud") end }) - self:AppendRow_Checkbox(typeSelection, { + self:AppendRow_Checkbox(listType, { 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 base.Saved.ShowBarOnHudUI end, @@ -146,7 +146,7 @@ function base.AppendMasterListTypeGeneral(self, typeSelection) base.UpdateFragments("ShowBarOnHudUI") end }) - self:AppendRow_Checkbox(typeSelection, { + self:AppendRow_Checkbox(listType, { name = "Show bar in menu", tooltipText = string.format("%s in menu", whenOnTheBar), funcGet = function() return base.Saved.ShowBarInMenu end, @@ -155,7 +155,7 @@ function base.AppendMasterListTypeGeneral(self, typeSelection) base.UpdateFragments("ShowBarInMenu") end }) - self:AppendRow_Checkbox(typeSelection, { + self:AppendRow_Checkbox(listType, { name = "Show bar in the inventory", tooltipText = string.format("%s in the inventory", whenOnTheBar), funcGet = function() return base.Saved.ShowBarInInventory end, @@ -164,7 +164,7 @@ function base.AppendMasterListTypeGeneral(self, typeSelection) base.UpdateFragments("ShowBarInInventory") end }) - self:AppendRow_Checkbox(typeSelection, { + self:AppendRow_Checkbox(listType, { name = "Show bar in interactions", tooltipText = string.format("%s in interactions", whenOnTheBar), funcGet = function() return base.Saved.ShowBarInInteract end, @@ -173,7 +173,7 @@ function base.AppendMasterListTypeGeneral(self, typeSelection) base.UpdateFragments("ShowBarInInteract") end }) - self:AppendRow_Checkbox(typeSelection, { + self:AppendRow_Checkbox(listType, { name = "Show bar at a bank", tooltipText = string.format("%s at a bank", whenOnTheBar), funcGet = function() return base.Saved.ShowBarInBank end, @@ -182,7 +182,7 @@ function base.AppendMasterListTypeGeneral(self, typeSelection) base.UpdateFragments("ShowBarInBank") end }) - self:AppendRow_Checkbox(typeSelection, { + self:AppendRow_Checkbox(listType, { name = "Show bar at a fence", tooltipText = string.format("%s at a fence", whenOnTheBar), funcGet = function() return base.Saved.ShowBarInFence end, @@ -191,7 +191,7 @@ function base.AppendMasterListTypeGeneral(self, typeSelection) base.UpdateFragments("ShowBarInFence") end }) - self:AppendRow_Checkbox(typeSelection, { + self:AppendRow_Checkbox(listType, { name = "Show bar at a store", tooltipText = string.format("%s at a store", whenOnTheBar), funcGet = function() return base.Saved.ShowBarInStore end, @@ -201,9 +201,9 @@ function base.AppendMasterListTypeGeneral(self, typeSelection) end }) - self:AppendRow_Title(typeSelection, {name = "Active and activation"}) - self:AppendRow_Divider(typeSelection, {}) - self:AppendRow_Checkbox(typeSelection, { + self:AppendRow_Title(listType, {name = "Active and activation"}) + self:AppendRow_Divider(listType, {}) + self:AppendRow_Checkbox(listType, { name = "Show active and activation", tooltipText = "When ON the active collectibles will be highlighted, and activation animation will display", funcGet = function() return base.Saved.IsActiveActivationEnabled end, @@ -213,9 +213,9 @@ function base.AppendMasterListTypeGeneral(self, typeSelection) end }) - self:AppendRow_Title(typeSelection, {name = "Audio"}) - self:AppendRow_Divider(typeSelection, {}) - self:AppendRow_Checkbox(typeSelection, { + self:AppendRow_Title(listType, {name = "Audio"}) + self:AppendRow_Divider(listType, {}) + self:AppendRow_Checkbox(listType, { name = "Play hover audio", tooltipText = "When ON hover events on the bar, will play audio", funcGet = function() return base.Saved.IsAudioEnabled end, @@ -226,55 +226,55 @@ function base.AppendMasterListTypeGeneral(self, typeSelection) }) end -function base.AppendMasterListTypeCategories(self, typeSelection) - self:AppendRow_Title(typeSelection, {name = "Categories"}) - self:AppendRow_Divider(typeSelection, {}) +function base.AppendMasterListTypeCategories(self, listType) + self:AppendRow_Title(listType, {name = "Categories"}) + self:AppendRow_Divider(listType, {}) - for _, _type in ipairs(base.TypesOrdered or {}) do + for _, category in ipairs(base.CategoriesOrdered 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, + cId = category.Id, + icon = category.Icon, + name = string.format("Show %s", category.Name), + hasChildren = category.HasChildren, + parentKey = category.ParentKey, + tooltipText = string.format("When ON the collection category: %s will enabled\nPress the 'cog' to display collectible in: 'Collectibles' and 'Collection bar'", category.Name), + funcGet = function() return category.Saved.Enabled end, + disabledFunc = function() return category.Disabled end, funcSet = function(_, newValue) - _type.Saved.Enabled = newValue + category.Saved.Enabled = newValue if newValue then - base.InitializeType(_type) + base.InitializeCategory(category) else - base.RemoveLabel(_type) - base.RemoveFrame(_type) - if self._type == _type then - self._type = nil + base.RemoveLabel(category) + base.RemoveFrame(category) + if self.category == category then + self.category = nil base.UpdateSettingsType(true, nil) end end - if _type.Saved.IsCombined then base.RestoreCombineLabels() end + if category.Saved.IsCombined then base.RestoreCombineLabels() end base.Global.SettingsList:RefreshData() end, funcCog = function(_) - self._type = _type - base.UpdateSettingsType(true, _type) + self.category = category + base.UpdateSettingsType(true, category) base.Global.SettingsList:RefreshData() end } - if _type.HasChildren then - data.name = _type.Name - self:AppendRow_Category_Title(typeSelection, data) + if category.HasChildren then + data.name = category.Name + self:AppendRow_Category_Title(listType, data) else - self:AppendRow_Category_Checkbox(typeSelection, data) + self:AppendRow_Category_Checkbox(listType, data) end end end -function base.AppendMasterListTypeCombined(self, typeSelection) - self:AppendRow_Title(typeSelection, {name = "Display names and labels"}) - self:AppendRow_Divider(typeSelection, {}) - self:AppendRow_Slider(typeSelection, { +function base.AppendMasterListTypeCombined(self, listType) + self:AppendRow_Title(listType, {name = "Display names and labels"}) + self:AppendRow_Divider(listType, {}) + self:AppendRow_Slider(listType, { name = "Display name offset horizontal", tooltipText = "Display name offset horizontal\n(X)", funcGet = function() return base.Saved.Combine.Label.OffsetX end, @@ -291,7 +291,7 @@ function base.AppendMasterListTypeCombined(self, typeSelection) valueFormat = texts.Format.Number, showValue = true }) - self:AppendRow_Slider(typeSelection, { + self:AppendRow_Slider(listType, { name = "Display name offset vertical", tooltipText = "Display name offset vertical\n(Y)", funcGet = function() return base.Saved.Combine.Label.OffsetY end, @@ -308,7 +308,7 @@ function base.AppendMasterListTypeCombined(self, typeSelection) valueFormat = texts.Format.Number, showValue = true }) - self:AppendRow_Dropdown(typeSelection, { + self:AppendRow_Dropdown(listType, { name = "Display name anchor position on button", tooltipText = "Select display name anchor position on the button", funcGet = function() return base.GetLocationText(base.Saved.Combine.Label.PositionTarget) end, @@ -318,7 +318,7 @@ function base.AppendMasterListTypeCombined(self, typeSelection) base.RestoreCombineLabels() end }) - self:AppendRow_Dropdown(typeSelection, { + self:AppendRow_Dropdown(listType, { name = "Display name anchor position on label", tooltipText = "Select display name anchor position on the label", funcGet = function() return base.GetLocationText(base.Saved.Combine.Label.Position) end, @@ -328,9 +328,9 @@ function base.AppendMasterListTypeCombined(self, typeSelection) base.RestoreCombineLabels() end }) - self:AppendRow_Title(typeSelection, {name = "Position and size"}) - self:AppendRow_Divider(typeSelection, {}) - self:AppendRow_Slider(typeSelection, { + self:AppendRow_Title(listType, {name = "Position and size"}) + self:AppendRow_Divider(listType, {}) + self:AppendRow_Slider(listType, { name = "Choose default bar depth", tooltipText = "Choose default bar depth\n(number of rows/columns)", funcGet = function() return base.Saved.Combine.BarDepth end, @@ -347,7 +347,7 @@ function base.AppendMasterListTypeCombined(self, typeSelection) valueFormat = texts.Format.Number, showValue = true }) - self:AppendRow_Slider(typeSelection, { + self:AppendRow_Slider(listType, { name = "Choose max bar height", tooltipText = "Choose max bar height\n(number of inverse rows/columns)", funcGet = function() return base.Saved.Combine.BarWidth end, @@ -366,49 +366,49 @@ function base.AppendMasterListTypeCombined(self, typeSelection) }) end -function base.AppendMasterListTypeSelection(self, typeSelection) - 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, +function base.AppendMasterListTypeCollectibles(self, listType) + self:AppendRow_Title(listType, {name = texts.Components.Collectibles}) + self:AppendRow_Divider(listType, {}) + self:AppendRow_Checkbox(listType, { + name = string.format("Show disabled %s", self.category.Name), + tooltipText = string.format("When ON disabled elements will be shown for %s", self.category.Name), + funcGet = function() return self.category.Saved.MenuShowDisabled end, funcSet = function(_, newValue) - self._type.Saved.MenuShowDisabled = newValue - base.CreateCategory(self._type) + self.category.Saved.MenuShowDisabled = newValue + base.CreateCategory(self.category) 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 base.IsAllSelected(self._type) end, + self:AppendRow_Divider(listType, {}) + self:AppendRow_Checkbox(listType, { + name = string.format("Select all %s", self.category.Name), + tooltipText = string.format("When pressed all %s will either be selected or deselected", self.category.Name), + funcGet = function() return base.IsAllSelected(self.category) end, funcSet = function(_, newValue) - base.SelectAll(self._type, newValue) - base.RestoreFrame(self._type) + base.SelectAll(self.category, newValue) + base.RestoreFrame(self.category) base.RestoreCombineLabels() base.Global.SettingsList:RefreshData() end }) - self:AppendRow_Divider(typeSelection, {}) - 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, { + self:AppendRow_Divider(listType, {}) + for _, collectible in ipairs(self.category.CollectionOrdered or {}) do + if self.category.Saved.MenuShowDisabled and collectible.Disabled or not collectible.Disabled then + self:AppendRow_Checkbox(listType, { cId = collectible.Id, name = string.format("Show %s", collectible.Name), tooltipText = collectible.Tooltip, - funcGet = function() return self._type.Saved.Selected[collectible.Id] end, + funcGet = function() return self.category.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 if newValue == true then - self._type.Saved.Selected[control.data.cId] = newValue + self.category.Saved.Selected[control.data.cId] = newValue else - self._type.Saved.Selected[control.data.cId] = nil + self.category.Saved.Selected[control.data.cId] = nil end - base.RestoreFrame(self._type) + base.RestoreFrame(self.category) base.RestoreCombineLabels() base.Global.SettingsList:RefreshData() end @@ -419,256 +419,256 @@ function base.AppendMasterListTypeSelection(self, typeSelection) end end -function base.AppendMasterListTypeCategory(self, typeSelection) +function base.AppendMasterListTypeCategory(self, listType) local disabledWhenTooltipIsHidden = "Disabled when tooltip is not shown" local disabledWhenLabelIsHidden = "Disabled when label is not shown" local disabledWhenCombined = "Disabled when Collection is included in combine bar" - self:AppendRow_Title(typeSelection, {name = "Tooltip"}) - self:AppendRow_Divider(typeSelection, {}) - self:AppendRow_Checkbox(typeSelection, { + self:AppendRow_Title(listType, {name = "Tooltip"}) + self:AppendRow_Divider(listType, {}) + self:AppendRow_Checkbox(listType, { 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.category.Saved.Tooltip.Show end, funcSet = function(_, newValue) - self._type.Saved.Tooltip.Show = newValue - base.SetupButtons(self._type) + self.category.Saved.Tooltip.Show = newValue + base.SetupButtons(self.category) base.Global.SettingsList:RefreshData() end }) - self:AppendRow_Dropdown(typeSelection, { + self:AppendRow_Dropdown(listType, { name = "Show tooltip anchor position", tooltipText = string.format("Select tooltip anchor position\n%s", disabledWhenTooltipIsHidden), 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, + disabledFunc = function() return not self.category.Saved.Tooltip.Show end, + funcGet = function() return base.GetLocationText(self.category.Saved.Tooltip.Position) end, funcSet = function(_, newValue) - self._type.Saved.Tooltip.Position = base.GetLocationValue(newValue) - base.SetupButtons(self._type) + self.category.Saved.Tooltip.Position = base.GetLocationValue(newValue) + base.SetupButtons(self.category) end }) - self:AppendRow_Title(typeSelection, {name = "Display name and label"}) - self:AppendRow_Divider(typeSelection, {}) - self:AppendRow_Checkbox(typeSelection, { + self:AppendRow_Title(listType, {name = "Display name and label"}) + self:AppendRow_Divider(listType, {}) + self:AppendRow_Checkbox(listType, { 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.category.Saved.IsCombined end, funcSet = function(_, newValue) - self._type.Saved.IsCombined = newValue - base.RestoreFrame(self._type) + self.category.Saved.IsCombined = newValue + base.RestoreFrame(self.category) base.RestoreCombineLabels() base.Global.SettingsList:RefreshData() end }) - self:AppendRow_Divider(typeSelection, {}) - self:AppendRow_Checkbox(typeSelection, { + self:AppendRow_Divider(listType, {}) + self:AppendRow_Checkbox(listType, { 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.category.Saved.IsCombined end, + funcGet = function() return self.category.Saved.IsCombined or self.category.Saved.HideAllEnabled end, funcSet = function(_, newValue) if (not newValue) then - self._type.Saved.HideAll = newValue - base.RestoreFrame(self._type) + self.category.Saved.HideAll = newValue + base.RestoreFrame(self.category) end - self._type.Saved.HideAllEnabled = newValue - self._type.Saved.LabelShow = true - base.SetupLabel(self._type) - base.RestoreLabel(self._type) + self.category.Saved.HideAllEnabled = newValue + self.category.Saved.LabelShow = true + base.SetupLabel(self.category) + base.RestoreLabel(self.category) base.Global.SettingsList:RefreshData() end }) - self:AppendRow_Checkbox(typeSelection, { + self:AppendRow_Checkbox(listType, { 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.category.Saved.HideAllEnabled or self.category.Saved.IsCombined end, + funcGet = function() return self.category.Saved.LabelShow or self.category.Saved.IsCombined end, funcSet = function(_, newValue) - self._type.Saved.LabelShow = newValue - base.SetupLabel(self._type) - base.RestoreLabel(self._type) + self.category.Saved.LabelShow = newValue + base.SetupLabel(self.category) + base.RestoreLabel(self.category) base.Global.SettingsList:RefreshData() end }) - self:AppendRow_Dropdown(typeSelection, { + self:AppendRow_Dropdown(listType, { name = "Display name font", tooltipText = string.format("Change display name font\n%s", disabledWhenLabelIsHidden), - disabledFunc = function() return not self._type.Saved.LabelShow end, + disabledFunc = function() return not self.category.Saved.LabelShow end, choices = base.Global.AvailableFonts, - funcGet = function() return self._type.Saved.Label.Font end, + funcGet = function() return self.category.Saved.Label.Font end, funcSet = function(_, newValue) - self._type.Saved.Label.Font = newValue - base.RestoreFrame(self._type) + self.category.Saved.Label.Font = newValue + base.RestoreFrame(self.category) base.RestoreCombineLabels() end }) - self:AppendRow_Slider(typeSelection, { + self:AppendRow_Slider(listType, { 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.category.Saved.LabelShow end, + funcGet = function() return self.category.Saved.Label.Height end, funcSet = function(sliderControl, newValue) local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) if valueLabel then valueLabel:SetText(newValue) end - self._type.Saved.Label.Height = newValue - base.RestoreFrame(self._type) + self.category.Saved.Label.Height = newValue + base.RestoreFrame(self.category) base.RestoreCombineLabels() end, minValue = 0, maxValue = 100, valueStep = 1, - default = base.Default[self._type.Name].Label.Height, + default = base.Default[self.category.Name].Label.Height, valueFormat = texts.Format.Number, showValue = true }) - self:AppendRow_Slider(typeSelection, { + self:AppendRow_Slider(listType, { 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.category.Saved.LabelShow end, + funcGet = function() return self.category.Saved.Label.Width end, funcSet = function(sliderControl, newValue) local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) if valueLabel then valueLabel:SetText(newValue) end - self._type.Saved.Label.Width = newValue - base.RestoreFrame(self._type) + self.category.Saved.Label.Width = newValue + base.RestoreFrame(self.category) base.RestoreCombineLabels() end, minValue = 0, maxValue = 500, valueStep = 1, - default = base.Default[self._type.Name].Label.Width, + default = base.Default[self.category.Name].Label.Width, valueFormat = texts.Format.Number, showValue = true }) - self:AppendRow_Slider(typeSelection, { + self:AppendRow_Slider(listType, { 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.category.Saved.LabelShow end, + funcGet = function() return self.category.Saved.Label.OffsetX end, funcSet = function(sliderControl, newValue) local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) if valueLabel then valueLabel:SetText(newValue) end - self._type.Saved.Label.OffsetX = newValue - base.RestoreFrame(self._type) + self.category.Saved.Label.OffsetX = newValue + base.RestoreFrame(self.category) base.RestoreCombineLabels() end, minValue = -500, maxValue = 500, valueStep = 1, - default = base.Default[self._type.Name].Label.OffsetX, + default = base.Default[self.category.Name].Label.OffsetX, valueFormat = texts.Format.Number, showValue = true }) - self:AppendRow_Slider(typeSelection, { + self:AppendRow_Slider(listType, { 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.category.Saved.LabelShow end, + funcGet = function() return self.category.Saved.Label.OffsetY end, funcSet = function(sliderControl, newValue) local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) if valueLabel then valueLabel:SetText(newValue) end - self._type.Saved.Label.OffsetY = newValue - base.RestoreFrame(self._type) + self.category.Saved.Label.OffsetY = newValue + base.RestoreFrame(self.category) base.RestoreCombineLabels() end, minValue = -500, maxValue = 500, valueStep = 1, - default = base.Default[self._type.Name].Label.OffsetY, + default = base.Default[self.category.Name].Label.OffsetY, valueFormat = texts.Format.Number, showValue = true }) - self:AppendRow_Dropdown(typeSelection, { + self:AppendRow_Dropdown(listType, { 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.category.Saved.LabelShow or self.category.Saved.IsCombined end, funcGet = function() - if self._type.Saved.IsCombined then + if self.category.Saved.IsCombined then return base.GetLocationText(base.Saved.Combine.Label.PositionTarget) else - return base.GetLocationText(self._type.Saved.Label.PositionTarget) + return base.GetLocationText(self.category.Saved.Label.PositionTarget) end end, choices = base.Global.ChoiceLocations, funcSet = function(_, newValue) - self._type.Saved.Label.PositionTarget = base.GetLocationValue(newValue) - base.RestoreFrame(self._type) + self.category.Saved.Label.PositionTarget = base.GetLocationValue(newValue) + base.RestoreFrame(self.category) base.RestoreCombineLabels() end }) - self:AppendRow_Dropdown(typeSelection, { + self:AppendRow_Dropdown(listType, { 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.category.Saved.LabelShow or self.category.Saved.IsCombined end, funcGet = function() - if self._type.Saved.IsCombined then + if self.category.Saved.IsCombined then return base.GetLocationText(base.Saved.Combine.Label.Position) else - return base.GetLocationText(self._type.Saved.Label.Position) + return base.GetLocationText(self.category.Saved.Label.Position) end end, choices = base.Global.ChoiceLocations, funcSet = function(_, newValue) - self._type.Saved.Label.Position = base.GetLocationValue(newValue) - base.RestoreFrame(self._type) + self.category.Saved.Label.Position = base.GetLocationValue(newValue) + base.RestoreFrame(self.category) base.RestoreCombineLabels() end }) - self:AppendRow_Title(typeSelection, {name = "Position and size"}) - self:AppendRow_Divider(typeSelection, {}) - self:AppendRow_Slider(typeSelection, { + self:AppendRow_Title(listType, {name = "Position and size"}) + self:AppendRow_Divider(listType, {}) + self:AppendRow_Slider(listType, { 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.category.Saved.IsCombined end, + funcGet = function() return self.category.Saved.BarDepth end, funcSet = function(sliderControl, newValue) local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) if valueLabel then valueLabel:SetText(newValue) end - self._type.Saved.BarDepth = newValue - base.RestoreFrame(self._type) + self.category.Saved.BarDepth = newValue + base.RestoreFrame(self.category) base.RestoreCombineLabels() end, minValue = 0, - maxValue = self._type.Unlocked, + maxValue = self.category.Unlocked, valueStep = 1, - default = base.Default[self._type.Name].BarDepth, + default = base.Default[self.category.Name].BarDepth, valueFormat = texts.Format.Number, showValue = true }) - self:AppendRow_Slider(typeSelection, { + self:AppendRow_Slider(listType, { 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.category.Saved.IsCombined end, + funcGet = function() return self.category.Saved.BarWidth end, funcSet = function(sliderControl, newValue) local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) if valueLabel then valueLabel:SetText(newValue) end - self._type.Saved.BarWidth = newValue - base.RestoreFrame(self._type) + self.category.Saved.BarWidth = newValue + base.RestoreFrame(self.category) base.RestoreCombineLabels() end, minValue = 0, - maxValue = self._type.Unlocked, + maxValue = self.category.Unlocked, valueStep = 1, - default = base.Default[self._type.Name].BarWidth, + default = base.Default[self.category.Name].BarWidth, showValue = true }) - self:AppendRow_Checkbox(typeSelection, { + self:AppendRow_Checkbox(listType, { 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.category.Saved.IsCombined end, + funcGet = function() return self.category.Saved.Horizontal end, funcSet = function(_, newValue) - self._type.Saved.Horizontal = newValue - base.RestoreFrame(self._type) + self.category.Saved.Horizontal = newValue + base.RestoreFrame(self.category) base.RestoreCombineLabels() end }) end -function base.AppendMasterListTypeNoCategory(self, typeSelection) - self:AppendRow_Title(typeSelection, {name = "Select a category"}) - self:AppendRow_Divider(typeSelection, {}) +function base.AppendMasterListTypeNoCategory(self, listType) + self:AppendRow_Title(listType, {name = "Select a category"}) + self:AppendRow_Divider(listType, {}) end diff --git a/CBs_Settings_List.lua b/CBs_Settings_List.lua index bf456ae..a4a8adb 100644 --- a/CBs_Settings_List.lua +++ b/CBs_Settings_List.lua @@ -15,15 +15,15 @@ CBs_Settings_List = ZO_SortFilterList:Subclass() function CBs_Settings_List:New(...) self.list = ZO_SortFilterList.New(self, ...) - self.masterListType = texts.Components.Selection + self.masterListType = texts.Components.Collectibles return self.list end -function CBs_Settings_List:Initialize(_type, ...) +function CBs_Settings_List:Initialize(category, ...) ZO_SortFilterList.Initialize(self, ...) - self._type = _type + self.category = category self.masterList = {} - if not (self._type and self._type.Enabled) then self.masterListType = texts.Components.Categories end + if not (self.category and self.category.Enabled) then self.masterListType = texts.Components.Categories end self:SetAlternateRowBackgrounds(false) self:AppendDataTypes() @@ -55,8 +55,8 @@ end -- FUNCTIONS - Append and Setup RowTypes -- ------------------------------------------------------------------------------------------------- -function CBs_Settings_List:AppendRow_Checkbox(typeSelection, data) - data.type = typeSelection +function CBs_Settings_List:AppendRow_Checkbox(listType, data) + data.listType = listType data.dataTypeId = 10 table.insert(self.masterList, data) end @@ -82,8 +82,8 @@ function CBs_Settings_List:SetupRow_Checkbox(control, data) end end -function CBs_Settings_List:AppendRow_Category_Title(typeSelection, data) - data.type = typeSelection +function CBs_Settings_List:AppendRow_Category_Title(listType, data) + data.listType = listType data.dataTypeId = 11 table.insert(self.masterList, data) end @@ -104,8 +104,8 @@ function CBs_Settings_List:SetupRow_Category_Title(control, data) self.SetActiveOrInactive(control) end -function CBs_Settings_List:AppendRow_Category_Checkbox(typeSelection, data) - data.type = typeSelection +function CBs_Settings_List:AppendRow_Category_Checkbox(listType, data) + data.listType = listType data.dataTypeId = 15 table.insert(self.masterList, data) end @@ -129,8 +129,8 @@ function CBs_Settings_List:SetupRow_Category_Checkbox(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) - data.type = typeSelection +function CBs_Settings_List:AppendRow_Dropdown(listType, data) + data.listType = listType data.dataTypeId = 20 table.insert(self.masterList, data) end @@ -151,8 +151,8 @@ function CBs_Settings_List:SetupRow_Dropdown(control, data) self.SetActiveOrInactive(control) end -function CBs_Settings_List:AppendRow_Slider(typeSelection, data) - data.type = typeSelection +function CBs_Settings_List:AppendRow_Slider(listType, data) + data.listType = listType data.dataTypeId = 30 table.insert(self.masterList, data) end @@ -202,8 +202,8 @@ function CBs_Settings_List:SetupRow_Slider(control, data) self.SetActiveOrInactive(control) end -function CBs_Settings_List:AppendRow_EditBox(typeSelection, data) - data.type = typeSelection +function CBs_Settings_List:AppendRow_EditBox(listType, data) + data.listType = listType data.dataTypeId = 40 table.insert(self.masterList, data) end @@ -224,8 +224,8 @@ function CBs_Settings_List:SetupRow_EditBox(control, data) self.SetActiveOrInactive(control) end -function CBs_Settings_List:AppendRow_Title(typeSelection, data) - data.type = typeSelection +function CBs_Settings_List:AppendRow_Title(listType, data) + data.listType = listType data.dataTypeId = 50 table.insert(self.masterList, data) end @@ -240,8 +240,8 @@ function CBs_Settings_List:SetupRow_Title(control, data) self.SetActiveOrInactive(control) end -function CBs_Settings_List:AppendRow_Button(typeSelection, data) - data.type = typeSelection +function CBs_Settings_List:AppendRow_Button(listType, data) + data.listType = listType data.dataTypeId = 60 table.insert(self.masterList, data) end @@ -252,7 +252,7 @@ function CBs_Settings_List:SetupRow_Button(control, data) control.button = GetControl(control, texts.Components.Button) if control.button then - control.button:SetText(control.data.buttonName or texts.EmptyString) + control.button:SetText(control.data.buttonName or texts.Helpers.EmptyString) control.button:SetHandler(texts.Action.OnClicked, function() control.data.funcSet() end) end @@ -260,8 +260,8 @@ function CBs_Settings_List:SetupRow_Button(control, data) self.SetActiveOrInactive(control) end -function CBs_Settings_List:AppendRow_Divider(typeSelection, data) - data.type = typeSelection +function CBs_Settings_List:AppendRow_Divider(listType, data) + data.listType = listType data.dataTypeId = 100 table.insert(self.masterList, data) end @@ -290,7 +290,7 @@ function CBs_Settings_List.SetNameText(control, text, fontOverrides) control.label:SetFont(fontOverrides.font) control.label:SetModifyTextType(fontOverrides.modifyTextType) end - control.label:SetText(text or texts.EmptyString) + control.label:SetText(text or texts.Helpers.EmptyString) end end @@ -348,11 +348,11 @@ function CBs_Settings_List:BuildMasterList() base.AppendMasterListTypeGeneral(self, texts.Components.General) base.AppendMasterListTypeCategories(self, texts.Components.Categories) base.AppendMasterListTypeCombined(self, texts.Components.Combined) - if self._type then - base.AppendMasterListTypeSelection(self, texts.Components.Selection) + if self.category then + base.AppendMasterListTypeCollectibles(self, texts.Components.Collectibles) base.AppendMasterListTypeCategory(self, texts.Components.Category) else - base.AppendMasterListTypeNoCategory(self, texts.Components.Selection) + base.AppendMasterListTypeNoCategory(self, texts.Components.Collectibles) base.AppendMasterListTypeNoCategory(self, texts.Components.Category) end end @@ -362,7 +362,7 @@ function CBs_Settings_List:FilterScrollList() ZO_ClearNumericallyIndexedTable(scrollData) for i = 1, #self.masterList do - if self.masterListType == nil or self.masterListType == self.masterList[i].type then + if self.masterListType == nil or self.masterListType == self.masterList[i].listType then 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 diff --git a/Changelog b/Changelog index 85fd546..5904956 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,17 @@ ------------------------------------------------------------------------------- Collection bars ------------------------------------------------------------------------------- +Version 1.0.9 (25-05-2020) +- Renamed Selection to Collectibles +- If "Use account settings" is on it will no longer create Character settings. + The setting now sets "account wide" if account settings is used, not pr character. +- Collectibles are now also ordered and named the same as the "Collections tab". +-- TODO: Implement tooltip with icon, in much the same way as "Collections tab". + +Improvements: +- Streamlined naming through out the code +- Removed unused values + Version 1.0.8 (24-05-2020) - Updated APIVersion to 100030 diff --git a/CollectionBars.lua b/CollectionBars.lua index 299d8f3..eb80df1 100644 --- a/CollectionBars.lua +++ b/CollectionBars.lua @@ -31,19 +31,19 @@ function base.Initialize() end function base.InitializeWithSavedData() - for _, _type in pairs(base.Types) do - _type.Saved = base.Saved[_type.Name] - if _type.Saved.Enabled then base.InitializeType(_type) end + for _, category in pairs(base.Categories) do + category.Saved = base.Saved[category.Name] + if category.Saved.Enabled then base.InitializeCategory(category) end end base.InitializeCombine() base.RestoreCombine() end -function base.InitializeType(_type) - base.CreateCategory(_type) - base.SetupLabel(_type) - base.RestoreFrame(_type) +function base.InitializeCategory(category) + base.CreateCategory(category) + base.SetupLabel(category) + base.RestoreFrame(category) end function base.InitializeCombineFrame() @@ -53,65 +53,70 @@ function base.InitializeCombineFrame() base.Global.Combine.HideAll = base.GetFrame(frameNameHideAll, frameNameHideAll) end -function base.CreateCategory(_type) - local unlocked = GetTotalUnlockedCollectiblesByCategoryType(_type.CategoryType) - _type.Category = {} - _type.CategoryOrdered = {} - _type.Unlocked = unlocked - _type.Total = GetTotalCollectiblesByCategoryType(_type.CategoryType) - _type.IsUsable = IsCollectibleCategoryUsable(_type.CategoryType) - - if unlocked > base.Global.HighestUnlocked then base.Global.HighestUnlocked = unlocked end - - for index = 1, _type.Total do - local id = GetCollectibleIdFromType(_type.CategoryType, index) - local name, description, icon, _, _unlocked, _, _, _, hint, _ = GetCollectibleInfo(id) - if _unlocked or _type.Saved.MenuShowDisabled then - _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]) +function base.CreateCategory(category) + category.Collection = {} + category.CollectionOrdered = {} + category.Unlocked = GetTotalUnlockedCollectiblesByCategoryType(category.Type) + + if category.Unlocked > base.Global.HighestUnlocked then base.Global.HighestUnlocked = category.Unlocked end + + for index, collectibleData in ZO_CollectibleCategoryData.SortedCollectibleIterator(category.CategoryData, {ZO_CollectibleData.IsShownInCollection}) do + local isUnlocked = collectibleData:IsUnlocked() + if isUnlocked or category.Saved.MenuShowDisabled then + local collectibleId = collectibleData:GetId() + -- TODO: IMPLEMENT BETTER TOOLTIPS... function ZO_Tooltip:LayoutCollectible(collectibleId, deprecatedCollectionName, collectibleName, collectibleNickname, isPurchasable, description, hint, deprecatedArg, categoryType, showVisualLayerInfo, cooldownSecondsRemaining, showBlockReason) + category.Collection[collectibleId] = { + Id = collectibleId, + Name = collectibleData:GetName(), + EnabledTexture = collectibleData:GetIcon(), + Disabled = not isUnlocked, + Tooltip = string.format(texts.Tooltip.Main, collectibleData:GetDescription(), collectibleData:GetHint()), + CollectibleData = collectibleData + } + table.insert(category.CollectionOrdered, category.Collection[collectibleId]) end end - _type.Frame = base.GetFrame(_type.Name, base.Addon.Abbreviation .. texts.Helpers.Lowdash .. texts.Components.Frame) + category.Frame = base.GetFrame(category.Name, base.Addon.Abbreviation .. texts.Helpers.Lowdash .. texts.Components.Frame) end function base.RestoreFrames() - for _, _type in pairs(base.Types) do base.RestoreFrame(_type) end + for _, category in pairs(base.Categories) do base.RestoreFrame(category) end base.RestoreCombine() end -function base.HideOthers(newType) - 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) +function base.HideOthers(newCategory) + for _, category in pairs(base.Categories) do + if category.Saved.Enabled and category.Saved.IsCombined and not category.Saved.HideAll and category ~= newCategory then + category.Saved.HideAll = not category.Saved.HideAll + base.RestoreFrame(category) end end end -function base.RestoreFrame(_type) - if _type.Saved.Enabled then - base.RestoreLabel(_type) - base.SetFrameAndCombineSize(_type) - base.SetupButtons(_type) - base.RestorePosition(_type) - base.UpdateToggleSettings(_type) - base.UpdateMoveFrame(_type) - base.UpdateFragment(_type) +function base.RestoreFrame(category) + if category.Saved.Enabled then + base.RestoreLabel(category) + base.SetFrameAndCombineSize(category) + base.SetupButtons(category) + base.RestorePosition(category) + base.UpdateToggleSettings(category) + base.UpdateMoveFrame(category) + base.UpdateFragment(category) else - base.RemoveLabel(_type) - base.RemoveFrame(_type) + base.RemoveLabel(category) + base.RemoveFrame(category) end end -function base.RemoveFrame(_type) - base.RemoveFragments(_type) - for _, _value in ipairs(_type.CategoryOrdered) do +function base.RemoveFrame(category) + base.RemoveFragments(category) + for _, _value in ipairs(category.CollectionOrdered) 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 category.Frame ~= nil then category.Frame:SetHidden(true) end end function base.InitializeCombine() base.Global.Combine.Saved = base.Saved.Combine end diff --git a/CollectionBars.txt b/CollectionBars.txt index 50d3c40..77fbd2a 100644 --- a/CollectionBars.txt +++ b/CollectionBars.txt @@ -6,7 +6,7 @@ ## APIVersion: 100030 ## Title: Collection Bars -## Version: 1.0.8 +## Version: 1.0.9 ## Author: Jarth ## Description: Show collection bars and activate collections with key or button press. Shortcuts: Settings window: /cb ##