diff --git a/CBs_Bindings.lua b/CBs_Bindings.lua index 9451dd4..5ce4273 100644 --- a/CBs_Bindings.lua +++ b/CBs_Bindings.lua @@ -47,9 +47,8 @@ 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 ZO_CreateStringId(bindingsName .. key, base.Addon.Abbreviation .. texts.Helpers.Lowdash .. key) end + ZO_CreateStringId(string.format(texts.FormatBindingName, "Settings"), "Settings") + for key, _ in ipairs(base.Saved.Bindings) do ZO_CreateStringId(string.format(texts.FormatBindingName, key), string.format(texts.FormatAbbreviationLowDash, 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 end end diff --git a/CBs_Button.lua b/CBs_Button.lua index 3840a56..2ba94a4 100644 --- a/CBs_Button.lua +++ b/CBs_Button.lua @@ -17,24 +17,23 @@ 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(category.Name .. lowdashButton, frame, base.Addon.Abbreviation .. lowdashButton, cId) + local ctrl = CreateControlFromVirtual(string.format("%s_Button", category.Name), frame, string.format(CollectionBars.Texts.FormatAbbreviationLowDash, "Button"), cId) newB.cId = cId newB.category = category newB.saved = saved newB.ctrl = ctrl newB.ctrl.cId = cId - newB.button = ctrl:GetNamedChild(texts.Components.Button) + newB.button = ctrl:GetNamedChild("Button") newB.button:SetId(cId) 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) - 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.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.inCooldown = false newB.showingCooldown = false newB.playSounds = false @@ -60,15 +59,15 @@ function CBs_Button:Setup() self.cooldownIcon:SetDesaturation(1) end - self.button:SetHandler(texts.Action.OnClicked, function() base.Activate(self) end) - self.button:SetHandler(texts.Action.OnMouseEnter, function() + self.button:SetHandler("OnClicked", function() base.Activate(self) end) + self.button:SetHandler("OnMouseEnter", function() if self.playSounds then PlaySound(SOUNDS.QUICKSLOT_MOUSEOVER) end 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) + self.button:SetHandler("OnMouseExit", function() ZO_Tooltips_HideTextTooltip() end) end function CBs_Button:SetShowBindingText(visible) self.buttonText:SetHidden(not visible) end @@ -85,13 +84,13 @@ function CBs_Button:SetBindingText(show, cId) if self.buttonText ~= nil then ZO_Keybindings_UnregisterLabelForBindingUpdate(self.buttonText) self.buttonText:ClearAnchors() - self.buttonText:SetText(texts.Helpers.EmptyString) + self.buttonText:SetText("") if keyId ~= nil and show then ZO_Keybindings_UnregisterLabelForBindingUpdate(self.buttonText) self.buttonText:SetHeight(self.ctrl:GetHeight()) self.buttonText:SetWidth(self.ctrl:GetWidth()) self.buttonText:SetAnchor(BOTTOM, self.ctrl, BOTTOM, 0, 0) - ZO_Keybindings_RegisterLabelForBindingUpdate(self.buttonText, base.Addon.Abbreviation .. texts.Helpers.Lowdash .. keyId, false) + ZO_Keybindings_RegisterLabelForBindingUpdate(self.buttonText, string.format(CollectionBars.Texts.FormatAbbreviationLowDash, keyId), false) end end end @@ -131,7 +130,7 @@ function CBs_Button:UpdateCooldown(remaining, duration, cooldown) self.cooldown:StartCooldown(remaining, duration, CD_TYPE_RADIAL, nil, NO_LEADING_EDGE) if self.cooldownCompleteAnim.animation then self.cooldownCompleteAnim.animation:GetTimeline():PlayInstantlyToStart() end self.cooldown:SetHidden(false) - self.ctrl:SetHandler(texts.Action.OnUpdate, function() self:RefreshCooldown(remaining, duration, cooldown) end) + self.ctrl:SetHandler("OnUpdate", function() self:RefreshCooldown(remaining, duration, cooldown) end) else if self.showingCooldown then if self.playSounds then PlaySound(SOUNDS.ABILITY_READY) end @@ -146,7 +145,7 @@ function CBs_Button:UpdateCooldown(remaining, duration, cooldown) end self.icon.percentComplete = 1 - self.ctrl:SetHandler(texts.Action.OnUpdate, nil) + self.ctrl:SetHandler("OnUpdate", nil) self.cooldown:ResetCooldown() end diff --git a/CBs_Buttons.lua b/CBs_Buttons.lua index decdbf1..887f723 100644 --- a/CBs_Buttons.lua +++ b/CBs_Buttons.lua @@ -94,9 +94,9 @@ function base.UpdateButtonsCooldown(category, remaining, duration, cooldown) end function base.GetCooldownText(countDown, duration) - local cooldown = texts.Helpers.EmptyString + local cooldown = "" - if type(duration) == texts.Helpers.Number and countDown.StartTime ~= nil then + if type(duration) == "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) @@ -120,10 +120,11 @@ end function base.Activate(button) if base.IsCollectibleUsable(button) then if button and base.Saved.IsActiveActivationEnabled then - EVENT_MANAGER:UnregisterForEvent(base.Addon.Abbreviation .. button.category.Name .. tostring(button.category.EventTS), EVENT_COLLECTIBLE_USE_RESULT) + local formatCategoryEvent = string.format(texts.FormatAbbreviation .. "%%s", button.category.Name) + local activeEventName = string.format(formatCategoryEvent, tostring(button.category.EventTS)) + EVENT_MANAGER:UnregisterForEvent(activeEventName, 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) + EVENT_MANAGER:RegisterForEvent(activeEventName, EVENT_COLLECTIBLE_USE_RESULT, function(_, result, isAttemptingActivation) local countDown = button.category.Cooldown local success = false @@ -136,11 +137,12 @@ function base.Activate(button) local successActivate = isAttemptingActivation and success countDown.StartTime = GetFrameTimeMilliseconds() - EVENT_MANAGER:UnregisterForEvent(base.Addon.Abbreviation .. button.category.Name .. tostring(button.category.EventTS), EVENT_COLLECTIBLE_USE_RESULT) + EVENT_MANAGER:UnregisterForEvent(activeEventName, EVENT_COLLECTIBLE_USE_RESULT) if success then - 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 countDownEvent = string.format(formatCategoryEvent, countDown.Event) + EVENT_MANAGER:UnregisterForUpdate(countDownEvent) + EVENT_MANAGER:RegisterForUpdate(countDownEvent, countDown.Tick, function() local remaining, duration = GetCollectibleCooldownAndDuration(countDown.CollectibleId) local cooldown = base.GetCooldownText(countDown, duration) @@ -149,7 +151,7 @@ function base.Activate(button) countDown.StartTime = nil local isActive = successActivate or IsCollectibleActive(button.cId) base.UpdateButtonsState(button.category, button.cId, isActive) - EVENT_MANAGER:UnregisterForUpdate(base.Addon.Abbreviation .. button.category.Name .. countDown.Event) + EVENT_MANAGER:UnregisterForUpdate(countDownEvent) end end) end diff --git a/CBs_Constants.lua b/CBs_Constants.lua index 8d45559..6d9f643 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.10, SettingsSlash = "/cb", Author = "Jarth"}, + Addon = {Name = "CollectionBars", DisplayName = "Collection Bars", Abbreviation = "CBs", Version = 1.0, MinorVersion = 11, SettingsSlash = "/cb", Author = "Jarth"}, Buttons = {}, Default = { BarDepth = 5, @@ -75,73 +75,33 @@ CollectionBars = { Categories = {}, CategoriesOrdered = {}, 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", - Collectibles = "Collectibles", - 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", + BottomLeft = "bottomleft", + BottomRight = "bottomright", + Center = "center", + Left = "left", + Right = "right", + Top = "top", + TopLeft = "topleft", + TopRight = "topright" }, - Location = {Bottom = "bottom", Center = "center", Left = "left", Right = "right", Top = "top"}, - 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)"} } } +CollectionBars.Texts.FormatAbbreviation = string.format("%s%%s", CollectionBars.Addon.Abbreviation) +CollectionBars.Texts.FormatAbbreviationLowDash = string.format("%s_%%s", CollectionBars.Addon.Abbreviation) +CollectionBars.Texts.FormatBindingName = string.format("SI_BINDING_NAME_%s", CollectionBars.Texts.FormatAbbreviationLowDash) + +CollectionBars.Texts.CombineFrameName = string.format(CollectionBars.Texts.FormatAbbreviationLowDash, "CombineFrame") +CollectionBars.Texts.CombineFrameNameHideAll = string.format("%s%s", CollectionBars.Texts.CombineFrameName, "HideAll") + +CollectionBars.Texts.AccountKey = string.format("%s_Account", CollectionBars.Addon.Name) +CollectionBars.Texts.CharacterKey = string.format("%s_Character", CollectionBars.Addon.Name) + ------------------------------------------------------------------------------------------------- -- FUNCTIONS -- ------------------------------------------------------------------------------------------------- @@ -199,7 +159,7 @@ function CollectionBars.AddCategory(type, categoryData, parentIcons, hasChildren Frame = nil, BarDepth = 0, BarWidth = nil, - Cooldown = {Event = "Cooldown" .. categoryName, CollectibleId = nil, StartTime = nil, Tick = 100}, + Cooldown = {Event = string.format("Cooldown%s", categoryName), CollectibleId = nil, StartTime = nil, Tick = 100}, Fragment = nil } table.insert(CollectionBars.CategoriesOrdered, CollectionBars.Categories[categoryName]) diff --git a/CBs_Fragment.lua b/CBs_Fragment.lua index 5052bc2..f3f3df6 100644 --- a/CBs_Fragment.lua +++ b/CBs_Fragment.lua @@ -18,7 +18,7 @@ end function base.UpdateFragment(category, fragmentType) local currentScene = SCENE_MANAGER:GetCurrentScene() - local isHidden = (currentScene == nil or currentScene:GetName() == texts.Helpers.Empty) and not base.Saved.ShowBarOnHud + local isHidden = (currentScene == nil or currentScene:GetName() == "empty") and not base.Saved.ShowBarOnHud if category.Fragment == nil then category.Fragment = ZO_HUDFadeSceneFragment:New(category.Frame) end diff --git a/CBs_Helpers.lua b/CBs_Helpers.lua index 69192e5..58ca6c2 100644 --- a/CBs_Helpers.lua +++ b/CBs_Helpers.lua @@ -16,9 +16,9 @@ function base.GetLocationValue(value) if value == texts.Location.Bottom then result = BOTTOM - elseif value == (texts.Location.Bottom .. texts.Location.Left) then + elseif value == texts.Location.BottomLeft then result = BOTTOMLEFT - elseif value == (texts.Location.Bottom .. texts.Location.Right) then + elseif value == texts.Location.BottomRight then result = BOTTOMRIGHT elseif value == texts.Location.Center then result = CENTER @@ -28,9 +28,9 @@ function base.GetLocationValue(value) result = RIGHT elseif value == texts.Location.Top then result = TOP - elseif value == (texts.Location.Top .. texts.Location.Left) then + elseif value == texts.Location.TopLeft then result = TOPLEFT - elseif value == (texts.Location.Top .. texts.Location.Right) then + elseif value == texts.Location.TopRight then result = TOPRIGHT end @@ -43,9 +43,9 @@ function base.GetLocationText(value) if value == BOTTOM then result = texts.Location.Bottom elseif value == BOTTOMLEFT then - result = (texts.Location.Bottom .. texts.Location.Left) + result = texts.Location.BottomLeft elseif value == BOTTOMRIGHT then - result = (texts.Location.Bottom .. texts.Location.Right) + result = texts.Location.BottomRight elseif value == CENTER then result = texts.Location.Center elseif value == LEFT then @@ -55,9 +55,9 @@ function base.GetLocationText(value) elseif value == TOP then result = texts.Location.Top elseif value == TOPLEFT then - result = (texts.Location.Top .. texts.Location.Left) + result = texts.Location.TopLeft elseif value == TOPRIGHT then - result = (texts.Location.Top .. texts.Location.Right) + result = texts.Location.TopRight end return result @@ -78,12 +78,12 @@ function base.RestorePosition(category) end function base.GetLabelPostFix(category) - local postFix = texts.Helpers.EmptyString + local postFix = "" if category.Saved.HideAllEnabled then if not category.Saved.HideAll then - postFix = texts.Helpers.Space .. texts.Helpers.Minus + postFix = " -" else - postFix = texts.Helpers.Space .. texts.Helpers.Plus + postFix = " +" end end return postFix @@ -111,38 +111,37 @@ function base.SelectAll(category, newValue) end end -function base.GetVersion(showMinor) - if showMinor == false or base.Addon.MinorVersion == nil then return tostring(base.Addon.Version) end - - return tostring(base.Addon.Version) .. texts.Helpers.Dot .. tostring(base.Addon.MinorVersion) -end - function base.SetAndUpdateAccountSettings(newUseAccountSettings) - local accountKey = base.Addon.Name .. texts.Helpers.Lowdash .. texts.Components.Account - base.Saved = ZO_SavedVars:NewAccountWide(accountKey, base.Addon.Version, nil, base.Default) + base.Saved = ZO_SavedVars:NewAccountWide(texts.AccountKey, base.Addon.Version, nil, base.Default) if newUseAccountSettings ~= nil then base.Saved.UseAccountSettings = newUseAccountSettings end local useAccountSettings = base.Saved.UseAccountSettings 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 = ZO_SavedVars:NewCharacterNameSettings(texts.CharacterKey, base.Addon.Version, nil, base.Default) base.Saved.UseAccountSettings = useAccountSettings end end +function base.GetCharacterSettingsDisabledState() + local result = BSTATE_DISABLED + if base.Saved.UseAccountSettings and _G[texts.CharacterKey] ~= nil then result = BSTATE_NORMAL end + + return result == BSTATE_DISABLED +end + function base.ResetAccountSettings() if base.Saved.UseAccountSettings then - 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) + _G[texts.AccountKey] = nil + base.Saved = ZO_SavedVars:NewAccountWide(texts.AccountKey, base.Addon.Version, nil, base.Default) else - 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) + _G[texts.CharacterKey] = nil + base.Saved = ZO_SavedVars:NewCharacterNameSettings(texts.CharacterKey, base.Addon.Version, nil, base.Default) end end +function base.RemoveCharacterSettings() if base.Saved.UseAccountSettings then _G[texts.CharacterKey] = nil end end + function base.GetBarWidthHeight(category) local width, height, count = 0, 0, 0 @@ -160,7 +159,7 @@ function base.GetBarWidthHeight(category) return barConstraintXY end - category.BarDepth, category.BarWidth = GetBarMaxCount(texts.Helpers.BarDepth), GetBarMaxCount(texts.Helpers.BarWidth) + category.BarDepth, category.BarWidth = GetBarMaxCount("BarDepth"), GetBarMaxCount("BarWidth") if count > 0 then local barWidth = math.ceil(count / category.BarDepth) diff --git a/CBs_Labels.lua b/CBs_Labels.lua index 4656c42..e01d580 100644 --- a/CBs_Labels.lua +++ b/CBs_Labels.lua @@ -12,18 +12,19 @@ local texts = base.Texts -- FUNCTIONS -- ------------------------------------------------------------------------------------------------- function base.SetupLabel(category) - local hideAllId = base.Addon.Abbreviation .. texts.Helpers.Lowdash .. texts.Components.HideAll + local hideAllId = string.format(texts.FormatAbbreviationLowDash, "HideAll") + local hideAllCategory = string.format("%s%s", hideAllId, category.Name) if category.FrameLabel == nil then - category.FrameLabel = GetControl(hideAllId .. category.Name) + category.FrameLabel = GetControl(hideAllCategory) if category.FrameLabel == nil then category.FrameLabel = base.WM:CreateControlFromVirtual(hideAllId, category.Frame, hideAllId, category.Name) end end category.FrameLabel:SetHidden(not category.Saved.LabelShow and not category.Saved.IsCombined) - category.FrameToggleSettings = GetControl(hideAllId .. category.Name .. texts.Components.Toggle .. texts.Components.Settings) - category.FrameLabelButton = GetControl(hideAllId .. category.Name .. texts.Components.Button) + category.FrameToggleSettings = GetControl(string.format("%sToggleSettings", hideAllCategory)) + category.FrameLabelButton = GetControl(string.format("%sButton", hideAllCategory)) if category.FrameLabelButton ~= nil then - category.FrameLabelButton:SetHandler(texts.Action.OnClicked, function(_, button) + category.FrameLabelButton:SetHandler("OnClicked", function(_, button) if button == MOUSE_BUTTON_INDEX_RIGHT then base.ToggleEnableSettings() elseif button == MOUSE_BUTTON_INDEX_LEFT and category.Saved.HideAllEnabled or category.Saved.IsCombined then @@ -56,7 +57,7 @@ function base.RestoreLabel(category) frameLabelButton:SetFont(label.Font) frameLabelButton:SetHorizontalAlignment(TEXT_ALIGN_LEFT) frameLabelButton:SetVerticalAlignment(TOP) - frameLabelButton:SetText(tostring(category.Saved.Display) .. base.GetLabelPostFix(category)) + frameLabelButton:SetText(string.format("%s%s", tostring(category.Saved.Display), base.GetLabelPostFix(category))) end local frameLabelToggleSettings = category.FrameToggleSettings diff --git a/CBs_MoveFrame.lua b/CBs_MoveFrame.lua index 6cfd443..a1c1a06 100644 --- a/CBs_MoveFrame.lua +++ b/CBs_MoveFrame.lua @@ -38,26 +38,26 @@ function base.UpdateMoveFrame(category) local targetFrame = category.Frame local onMouseEnter, onMouseExit, onMouseDown, onMouseUp = nil, nil, nil, nil - if base.Global.IsMoveEnabled and (category.Name == texts.Components.Combine or not category.IsEmpty and not category.Saved.IsCombined) then + if base.Global.IsMoveEnabled and (category.Name == "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 + onMouseDown = function(frame) frame:SetHandler("OnUpdate", frame.MoveFrameOnUpdate) end onMouseUp = function(frame) local saved = frame.category.Saved frame.MoveFrameOnUpdate(frame) frame.MoveFrameUpdateText(frame, false) - frame:SetHandler(texts.Action.OnUpdate, nil) + frame:SetHandler("OnUpdate", nil) saved.X, saved.Y = base.GetMoveFrameSnapPosition(frame, category.Saved.Label.PositionTarget, frame.Saved.SnapSize) end end if moveFrame then - 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:SetHandler("OnMouseEnter", onMouseEnter) + moveFrame:SetHandler("OnMouseExit", onMouseExit) + moveFrame:SetHandler("OnMouseDown", onMouseDown) + moveFrame:SetHandler("OnMouseUp", onMouseUp) moveFrame:SetHidden(not base.Global.IsMoveEnabled) moveFrame.overlay:SetHidden(not base.Global.IsMoveEnabled) moveFrame.labelCenter:SetHidden(not base.Global.IsMoveEnabled) @@ -72,17 +72,15 @@ end 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 = category.Name .. lowdashMoveFrame - local newMoveFrame = base.WM:CreateControlFromVirtual(moveFrameName, GuiRoot, base.Addon.Abbreviation .. lowdashMoveFrame) + local moveFrameName = string.format("%s_MoveFrame", category.Name) + local newMoveFrame = base.WM:CreateControlFromVirtual(moveFrameName, GuiRoot, string.format(texts.FormatAbbreviationLowDash, "MoveFrame")) -- Variable is used to define what savedVariable the Frame refers to. newMoveFrame.TargetFrame = targetFrame newMoveFrame.Saved = base.Saved newMoveFrame.category = category - newMoveFrame[moveFrame .. texts.Action.UpdateText] = function(frame, position) - local labelTextTopLeft = texts.Helpers.EmptyString + newMoveFrame["MoveFrameUpdateText"] = function(frame, position) + local labelTextTopLeft = "" if (position) then labelTextTopLeft = string.format(texts.Format.Comma, base.GetMoveFrameSnapPosition(frame.TargetFrame, category.Saved.Label.PositionTarget, frame.Saved.SnapSize)) @@ -91,13 +89,13 @@ function base.GetOrCreateMoveFrame(targetFrame, category) frame.labelCenter:SetText(string.format(texts.Format.Comma, frame:GetWidth(), frame:GetHeight())) frame.labelTopLeft:SetText(labelTextTopLeft) end - newMoveFrame[moveFrame .. texts.Action.OnUpdate] = function(frame) + newMoveFrame["MoveFrameOnUpdate"] = function(frame) local x, y = base.GetMoveFrameSnapPosition(frame, category.Saved.Label.PositionTarget, frame.Saved.SnapSize) frame.TargetFrame:ClearAnchors() frame.TargetFrame:SetAnchor(category.Saved.Label.PositionTarget, GuiRoot, TOPLEFT, x, y) frame.MoveFrameUpdateText(frame, true) end - newMoveFrame[moveFrame .. texts.Action.UpdateColor] = function(frame) + newMoveFrame["MoveFrameUpdateColor"] = 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) @@ -107,15 +105,15 @@ function base.GetOrCreateMoveFrame(targetFrame, category) newMoveFrame:SetParent(GuiRoot) -- -- overlay - if newMoveFrame.overlay == nil then newMoveFrame.overlay = GetControl(moveFrameName .. texts.Components.BG) end + if newMoveFrame.overlay == nil then newMoveFrame.overlay = GetControl(string.format("%sBG", moveFrameName)) end -- labels if newMoveFrame.labelTopLeft == nil or newMoveFrame.labelCenter == nil then - newMoveFrame.labelTopLeft = GetControl(moveFrameName .. texts.Components.Label .. texts.Components.Top .. texts.Components.Left) + newMoveFrame.labelTopLeft = GetControl(string.format("%sLabelTopLeft", moveFrameName)) newMoveFrame.labelTopLeft:SetHorizontalAlignment(TEXT_ALIGN_LEFT) newMoveFrame.labelTopLeft:SetVerticalAlignment(TEXT_ALIGN_TOP) - newMoveFrame.labelCenter = GetControl(moveFrameName .. texts.Components.Label .. texts.Components.Center) + newMoveFrame.labelCenter = GetControl(string.format("%sLabelCenter", moveFrameName)) newMoveFrame.labelCenter:SetHorizontalAlignment(TEXT_ALIGN_CENTER) newMoveFrame.labelCenter:SetVerticalAlignment(TEXT_ALIGN_CENTER) end diff --git a/CBs_Settings.lua b/CBs_Settings.lua index 57e07d1..e0ba2c0 100644 --- a/CBs_Settings.lua +++ b/CBs_Settings.lua @@ -14,7 +14,7 @@ local texts = base.Texts function base.InitializeSettingsSlash() SLASH_COMMANDS[base.Addon.SettingsSlash] = function() base.ToggleEnableSettings(base.ShowSettings()) end end function base.ToggleEnableSettings(forceShow) - if not (forceShow == nil) then + if forceShow ~= nil then base.Global.EnableSettings = forceShow else base.Global.EnableSettings = not base.Global.EnableSettings @@ -24,10 +24,10 @@ function base.ToggleEnableSettings(forceShow) end function base.SetupToggleSettings(category) - local toggleSettings = GetControl(base.Addon.Abbreviation .. texts.Helpers.Lowdash .. texts.Components.HideAll .. category.Name .. texts.Components.Toggle .. texts.Components.Settings) + local toggleSettings = GetControl(string.format(texts.FormatAbbreviationLowDash .. "%sToggleSettings", "HideAll", category.Name)) if toggleSettings then local hideAllSettingsFunc = function() base.ShowSettings(category) end - toggleSettings:SetHandler(texts.Action.OnClicked, hideAllSettingsFunc) + toggleSettings:SetHandler("OnClicked", hideAllSettingsFunc) end end @@ -49,26 +49,26 @@ end function base.SetupSettingsFrameHandlers(control, text, onClicked) control.tooltipText = text - 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) + 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) end function base.SetupSetttingsFrame(category) - local selector = base.Addon.Abbreviation .. texts.Helpers.Lowdash .. texts.Components.Settings + local selector = string.format(texts.FormatAbbreviationLowDash, "Settings") base.Global.SettingsFrame = base.WM:CreateControlFromVirtual(selector, GuiRoot, selector) - base.Global.SettingsLabel = GetControl(selector .. texts.Components.Label) + base.Global.SettingsLabel = GetControl(string.format("%sLabel", selector)) 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) + local titleControl = GetControl(string.format("%sTitle", selector)) + titleControl:SetText(string.format("%s Settings", base.Addon.DisplayName)) - if base.Global.SettingsFrame.closeFrame == nil then base.Global.SettingsFrame.closeFrame = GetControl(base.Global.SettingsFrame, texts.Components.Close) end + if base.Global.SettingsFrame.closeFrame == nil then base.Global.SettingsFrame.closeFrame = GetControl(base.Global.SettingsFrame, "Close") end if base.Global.SettingsFrame.closeFrame then - base.SetupSettingsFrameHandlers(base.Global.SettingsFrame.closeFrame, texts.Components.Close, function(buttonControl) buttonControl:GetParent():SetHidden(true) end) + base.SetupSettingsFrameHandlers(base.Global.SettingsFrame.closeFrame, "Close", function(buttonControl) buttonControl:GetParent():SetHidden(true) end) end - if base.Global.SettingsFrame.moveFrame == nil then base.Global.SettingsFrame.moveFrame = GetControl(base.Global.SettingsFrame, texts.Components.Move) end + if base.Global.SettingsFrame.moveFrame == nil then base.Global.SettingsFrame.moveFrame = GetControl(base.Global.SettingsFrame, "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 @@ -77,7 +77,7 @@ function base.SetupSetttingsFrame(category) end) end - if base.Global.SettingsFrame.refreshFrame == nil then base.Global.SettingsFrame.refreshFrame = GetControl(base.Global.SettingsFrame, texts.Components.Refresh) end + if base.Global.SettingsFrame.refreshFrame == nil then base.Global.SettingsFrame.refreshFrame = GetControl(base.Global.SettingsFrame, "Refresh") end if base.Global.SettingsFrame.refreshFrame then base.SetupSettingsFrameHandlers(base.Global.SettingsFrame.refreshFrame, texts.Settings.ReloadText, function() if base.Global.SettingsList.category ~= nil then @@ -96,7 +96,7 @@ function base.SetupSettingsFilter(control, controlName, displayName) local filterControl = GetControl(control, controlName) if filterControl then base.SetControlText(filterControl, displayName) - filterControl:SetHandler(texts.Action.OnClicked, function() + filterControl:SetHandler("OnClicked", function() base.Global.SettingsList.masterListType = controlName base.Global.SettingsList:RefreshFilters() end) @@ -120,5 +120,5 @@ 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 category and category.Name or texts.Components.Global) end + if base.Global.SettingsLabel ~= nil then base.Global.SettingsLabel:SetText(show and category and category.Name or "Global") end end diff --git a/CBs_Settings.xml b/CBs_Settings.xml index 9df036a..9d8b004 100644 --- a/CBs_Settings.xml +++ b/CBs_Settings.xml @@ -107,6 +107,8 @@ </Texture> <Button name="$(parent)Button" relativeTo="$(parent)"> <Dimensions x="26" y="26" /> + <MouseButton button="1" enabled="true" /> + <MouseButton button="2" enabled="true" /> <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" /> diff --git a/CBs_Settings_Data.lua b/CBs_Settings_Data.lua index 5efc149..78dc382 100644 --- a/CBs_Settings_Data.lua +++ b/CBs_Settings_Data.lua @@ -25,6 +25,15 @@ function base.AppendMasterListTypeGeneral(self, listType) end }) self:AppendRow_Button(listType, { + name = "Remove character settings", + buttonName = "Remove", + disabledFunc = base.GetCharacterSettingsDisabledState, + funcSet = function() + base.RemoveCharacterSettings() + base.Global.SettingsList:RefreshData() + end + }) + self:AppendRow_Button(listType, { name = "Reset settings", buttonName = "Reset", funcSet = function() @@ -52,7 +61,7 @@ function base.AppendMasterListTypeGeneral(self, listType) tooltipText = "Choose snap size when moving", funcGet = function() return base.Saved.SnapSize end, funcSet = function(sliderControl, newValue) - local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") if valueLabel then valueLabel:SetText(newValue) end base.Saved.SnapSize = newValue base.RestoreFrames() @@ -69,7 +78,7 @@ function base.AppendMasterListTypeGeneral(self, listType) tooltipText = "Choose max bar depth\n(number of inverse rows/columns)", funcGet = function() return base.Saved.BarDepth end, funcSet = function(sliderControl, newValue) - local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") if valueLabel then valueLabel:SetText(newValue) end base.Saved.BarDepth = newValue base.RestoreFrames() @@ -86,7 +95,7 @@ function base.AppendMasterListTypeGeneral(self, listType) tooltipText = "Choose max bar height\n(number of inverse rows/columns)", funcGet = function() return base.Saved.BarWidth end, funcSet = function(sliderControl, newValue) - local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") if valueLabel then valueLabel:SetText(newValue) end base.Saved.BarWidth = newValue base.RestoreFrames() @@ -112,7 +121,7 @@ function base.AppendMasterListTypeGeneral(self, listType) tooltipText = "Choose button size", funcGet = function() return base.Saved.ButtonXY end, funcSet = function(sliderControl, newValue) - local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") if valueLabel then valueLabel:SetText(newValue) end base.Saved.ButtonXY = newValue base.RestoreFrames() @@ -237,7 +246,7 @@ function base.AppendMasterListTypeCategories(self, listType) 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), + tooltipText = string.format("When ON the collection category:\n%s will enabled\n\nPress the 'cog' to display collectible in the tabs: 'Collectibles' and 'Category'\n and Right click wil also change the tab", category.Name), funcGet = function() return category.Saved.Enabled end, disabledFunc = function() return category.Disabled end, funcSet = function(_, newValue) @@ -255,10 +264,14 @@ function base.AppendMasterListTypeCategories(self, listType) if category.Saved.IsCombined then base.RestoreCombineLabels() end base.Global.SettingsList:RefreshData() end, - funcCog = function(_) + funcCog = function(button) self.category = category base.UpdateSettingsType(true, category) base.Global.SettingsList:RefreshData() + if button == MOUSE_BUTTON_INDEX_RIGHT then + base.Global.SettingsList.masterListType = "Collectibles" + base.Global.SettingsList:RefreshFilters() + end end } @@ -279,7 +292,7 @@ function base.AppendMasterListTypeCombined(self, listType) tooltipText = "Display name offset horizontal\n(X)", funcGet = function() return base.Saved.Combine.Label.OffsetX end, funcSet = function(sliderControl, newValue) - local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") if valueLabel then valueLabel:SetText(newValue) end base.Saved.Combine.Label.OffsetX = newValue base.RestoreCombineLabels() @@ -296,7 +309,7 @@ function base.AppendMasterListTypeCombined(self, listType) tooltipText = "Display name offset vertical\n(Y)", funcGet = function() return base.Saved.Combine.Label.OffsetY end, funcSet = function(sliderControl, newValue) - local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") if valueLabel then valueLabel:SetText(newValue) end base.Saved.Combine.Label.OffsetY = newValue base.RestoreCombineLabels() @@ -335,7 +348,7 @@ function base.AppendMasterListTypeCombined(self, listType) tooltipText = "Choose default bar depth\n(number of rows/columns)", funcGet = function() return base.Saved.Combine.BarDepth end, funcSet = function(sliderControl, newValue) - local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") if valueLabel then valueLabel:SetText(newValue) end base.Saved.Combine.BarDepth = newValue base.RestoreFrames() @@ -352,7 +365,7 @@ function base.AppendMasterListTypeCombined(self, listType) tooltipText = "Choose max bar height\n(number of inverse rows/columns)", funcGet = function() return base.Saved.Combine.BarWidth end, funcSet = function(sliderControl, newValue) - local valueLabel = GetControl(sliderControl:GetParent(), texts.Components.Value .. texts.Components.Label) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") if valueLabel then valueLabel:SetText(newValue) end base.Saved.Combine.BarWidth = newValue base.RestoreFrames() @@ -367,7 +380,7 @@ function base.AppendMasterListTypeCombined(self, listType) end function base.AppendMasterListTypeCollectibles(self, listType) - self:AppendRow_Title(listType, {name = texts.Components.Collectibles}) + self:AppendRow_Title(listType, {name = "Collectibles"}) self:AppendRow_Divider(listType, {}) self:AppendRow_Checkbox(listType, { name = string.format("Show disabled %s", self.category.Name), @@ -491,6 +504,21 @@ function base.AppendMasterListTypeCategory(self, listType) base.Global.SettingsList:RefreshData() end }) + self:AppendRow_EditBox(listType, { + name = "Display name", + tooltipText = string.format("Change displayname used on the label\n%s", disabledWhenLabelIsHidden), + disabledFunc = function() + return not self.category.Saved.LabelShow + end, + funcGet = function() + return tostring(self.category.Saved.Display) + end, + funcSet = function(control) + self.category.Saved.Display = control:GetText() or "" + base.RestoreFrame(self.category) + base.RestoreCombineLabels() + end + }) self:AppendRow_Dropdown(listType, { name = "Display name font", tooltipText = string.format("Change display name font\n%s", disabledWhenLabelIsHidden), @@ -509,7 +537,7 @@ function base.AppendMasterListTypeCategory(self, listType) 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) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") if valueLabel then valueLabel:SetText(newValue) end self.category.Saved.Label.Height = newValue base.RestoreFrame(self.category) @@ -528,7 +556,7 @@ function base.AppendMasterListTypeCategory(self, listType) 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) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") if valueLabel then valueLabel:SetText(newValue) end self.category.Saved.Label.Width = newValue base.RestoreFrame(self.category) @@ -547,7 +575,7 @@ function base.AppendMasterListTypeCategory(self, listType) 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) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") if valueLabel then valueLabel:SetText(newValue) end self.category.Saved.Label.OffsetX = newValue base.RestoreFrame(self.category) @@ -566,7 +594,7 @@ function base.AppendMasterListTypeCategory(self, listType) 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) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") if valueLabel then valueLabel:SetText(newValue) end self.category.Saved.Label.OffsetY = newValue base.RestoreFrame(self.category) @@ -624,7 +652,7 @@ function base.AppendMasterListTypeCategory(self, listType) 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) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") if valueLabel then valueLabel:SetText(newValue) end self.category.Saved.BarDepth = newValue base.RestoreFrame(self.category) @@ -643,7 +671,7 @@ function base.AppendMasterListTypeCategory(self, listType) 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) + local valueLabel = GetControl(sliderControl:GetParent(), "ValueLabel") if valueLabel then valueLabel:SetText(newValue) end self.category.Saved.BarWidth = newValue base.RestoreFrame(self.category) diff --git a/CBs_Settings_List.lua b/CBs_Settings_List.lua index a4a8adb..276840d 100644 --- a/CBs_Settings_List.lua +++ b/CBs_Settings_List.lua @@ -15,7 +15,7 @@ CBs_Settings_List = ZO_SortFilterList:Subclass() function CBs_Settings_List:New(...) self.list = ZO_SortFilterList.New(self, ...) - self.masterListType = texts.Components.Collectibles + self.masterListType = "Collectibles" return self.list end @@ -23,7 +23,7 @@ function CBs_Settings_List:Initialize(category, ...) ZO_SortFilterList.Initialize(self, ...) self.category = category self.masterList = {} - if not (self.category and self.category.Enabled) then self.masterListType = texts.Components.Categories end + if not (self.category and self.category.Enabled) then self.masterListType = "Categories" end self:SetAlternateRowBackgrounds(false) self:AppendDataTypes() @@ -34,18 +34,17 @@ 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 listRowAnd = string.format(texts.FormatAbbreviationLowDash .. "_ListRow_%%s", "Settings") local dataTypes = { - [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} + [10] = {name = string.format(listRowAnd, "Checkbox"), height = 40, func = function(...) self:SetupRow_Checkbox(...) end}, + [11] = {name = string.format(listRowAnd, "Category_Title"), height = 40, func = function(...) self:SetupRow_Category_Title(...) end}, + [15] = {name = string.format(listRowAnd, "Category_Checkbox"), height = 40, func = function(...) self:SetupRow_Category_Checkbox(...) end}, + [20] = {name = string.format(listRowAnd, "Dropdown"), height = 40, func = function(...) self:SetupRow_Dropdown(...) end}, + [30] = {name = string.format(listRowAnd, "Slider"), height = 40, func = function(...) self:SetupRow_Slider(...) end}, + [40] = {name = string.format(listRowAnd, "EditBox"), height = 40, func = function(...) self:SetupRow_EditBox(...) end}, + [50] = {name = string.format(listRowAnd, "Title"), height = 40, func = function(...) self:SetupRow_Title(...) end}, + [60] = {name = string.format(listRowAnd, "Button"), height = 40, func = function(...) self:SetupRow_Button(...) end}, + [100] = {name = string.format(listRowAnd, "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 @@ -65,7 +64,7 @@ function CBs_Settings_List:SetupRow_Checkbox(control, data) control.data = data ZO_SortFilterList.SetupRow(self, control, data) - control.checkbox = GetControl(control, texts.Components.Checkbox) + control.checkbox = GetControl(control, "Checkbox") if control.checkbox then control.checkbox.tooltipText = data.tooltipText ZO_CheckButton_SetCheckState(control.checkbox, control.data.funcGet and control.data.funcGet()) @@ -91,7 +90,7 @@ 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() + control:SetHandler("OnMouseUp", function() local savedTypeData = base.Saved[data.name] if savedTypeData ~= nil then savedTypeData.ShowChildren = not savedTypeData.ShowChildren @@ -113,15 +112,15 @@ end function CBs_Settings_List:SetupRow_Category_Checkbox(control, data) control.data = data self:SetupRow_Checkbox(control, data) - control.button = GetControl(control, texts.Components.Button) + control.button = GetControl(control, "Button") if control.button then control.button:SetHidden(false) local isEnabled = control.data.funcGet and control.data.funcGet() ZO_CheckButton_SetEnableState(control.button, isEnabled) control.button:SetAlpha(isEnabled and 1 or 0.5) - base.SetupSettingsFrameHandlers(control.button, data.tooltipText, function() + base.SetupSettingsFrameHandlers(control.button, data.tooltipText, function(_, button) PlaySound(SOUNDS.SINGLE_SETTING_RESET_TO_DEFAULT) - control.data.funcCog(control.slider, data.default) + control.data.funcCog(button) end) end @@ -139,7 +138,7 @@ function CBs_Settings_List:SetupRow_Dropdown(control, data) control.data = data ZO_SortFilterList.SetupRow(self, control, data) - control.dropdown = GetControl(control, texts.Components.Dropdown) + control.dropdown = GetControl(control, "Dropdown") control.comboBox = ZO_ComboBox_ObjectFromContainer(control.dropdown) control.comboBox:SetSortsItems(false) control.comboBox:SetFont(texts.Font.ZoFontWinT1) @@ -161,30 +160,27 @@ function CBs_Settings_List:SetupRow_Slider(control, data) control.data = data ZO_SortFilterList.SetupRow(self, control, control.data) - control.slider = GetControl(control, texts.Components.Slider) + control.slider = GetControl(control, "Slider") -- Need to override the existing value changed handler first so it doesn't run when we do the SetMinMax - control.slider:SetHandler(texts.Action.OnValueChanged, nil) + control.slider:SetHandler("OnValueChanged", nil) control.slider:SetMinMax(control.data.minValue, control.data.maxValue) control.slider:SetValueStep(control.data.valueStep or 1) control.slider:SetValue(data.funcGet()) - control.slider:SetHandler(texts.Action.OnValueChanged, control.data.funcSet) + control.slider:SetHandler("OnValueChanged", control.data.funcSet) if data.default then - if control.defaultMarkerControl == nil then - local defaultMarker = texts.Components.Default .. texts.Components.Marker - control.defaultMarkerControl = CreateControlFromVirtual(texts.Components.Parent .. defaultMarker, control.slider, texts.Components.ZOOptions .. defaultMarker) - end + if control.defaultMarkerControl == nil then control.defaultMarkerControl = CreateControlFromVirtual("$(parent)DefaultMarker", control.slider, "ZO_Options_DefaultMarker") end local offsetX = zo_clampedPercentBetween(data.minValue, data.maxValue, data.default) * control.slider:GetWidth() control.defaultMarkerControl:SetAnchor(TOP, control.slider, LEFT, offsetX + .25, 6) - control.defaultMarkerControl:SetHandler(texts.Action.OnClicked, function() + control.defaultMarkerControl:SetHandler("OnClicked", function() PlaySound(SOUNDS.SINGLE_SETTING_RESET_TO_DEFAULT) control.slider:SetValue(data.default) control.data.funcSet(control.slider, data.default) end) end - local valueLabelControl = GetControl(control, texts.Components.Value .. texts.Components.Label) + local valueLabelControl = GetControl(control, "ValueLabel") if valueLabelControl and data.showValue then local shownVal = data.funcGet() if data.valueMin and data.valueMax and data.valueMax > data.valueMin then @@ -212,12 +208,12 @@ function CBs_Settings_List:SetupRow_EditBox(control, data) control.data = data ZO_SortFilterList.SetupRow(self, control, control.data) - control.editBox = GetControl(control, texts.Components.EditBox) + control.editBox = GetControl(control, "EditBox") if control.editBox then ZO_EditDefaultText_Initialize(control.editBox) - control.editBox:SetHandler(texts.Action.OnTextChanged, nil) + control.editBox:SetHandler("OnTextChanged", nil) control.editBox:SetText(data.funcGet()) - control.editBox:SetHandler(texts.Action.OnTextChanged, function() data.funcSet(control.editBox) end) + control.editBox:SetHandler("OnTextChanged", function() data.funcSet(control.editBox) end) end self.SetNameText(control, control.data.name) @@ -250,10 +246,10 @@ function CBs_Settings_List:SetupRow_Button(control, data) control.data = data ZO_SortFilterList.SetupRow(self, control, control.data) - control.button = GetControl(control, texts.Components.Button) + control.button = GetControl(control, "Button") if control.button then - control.button:SetText(control.data.buttonName or texts.Helpers.EmptyString) - control.button:SetHandler(texts.Action.OnClicked, function() control.data.funcSet() end) + control.button:SetText(control.data.buttonName or "") + control.button:SetHandler("OnClicked", function() control.data.funcSet() end) end self.SetNameText(control, control.data.name) @@ -284,26 +280,26 @@ function CBs_Settings_List.RepopulateDropdownOptions(control) end 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 control.label = GetControl(control, "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.Helpers.EmptyString) + control.label:SetText(text or "") 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 control.icon = GetControl(control, "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) + control:SetHandler("OnMouseEnter", function() control.icon:SetTexture(data.icon[3]) end) + control:SetHandler("OnMouseExit", function() control.icon:SetTexture(data.icon[1]) end) end return hasIcon end @@ -312,7 +308,7 @@ end function CBs_Settings_List.SetActiveOrInactive(control) local disabled = control.data.disabledFunc and control.data.disabledFunc() - control.label = GetControl(control, texts.Components.Name) + control.label = GetControl(control, "Name") if control.label then if disabled then control.label:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) @@ -321,7 +317,7 @@ function CBs_Settings_List.SetActiveOrInactive(control) end end - control.valueLabelControl = GetControl(control, texts.Components.Value .. texts.Components.Label) + control.valueLabelControl = GetControl(control, "ValueLabel") if control.valueLabelControl then if disabled then control.valueLabelControl:SetColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) @@ -345,15 +341,15 @@ end function CBs_Settings_List:BuildMasterList() self.masterList = {} - base.AppendMasterListTypeGeneral(self, texts.Components.General) - base.AppendMasterListTypeCategories(self, texts.Components.Categories) - base.AppendMasterListTypeCombined(self, texts.Components.Combined) + base.AppendMasterListTypeGeneral(self, "General") + base.AppendMasterListTypeCategories(self, "Categories") + base.AppendMasterListTypeCombined(self, "Combined") if self.category then - base.AppendMasterListTypeCollectibles(self, texts.Components.Collectibles) - base.AppendMasterListTypeCategory(self, texts.Components.Category) + base.AppendMasterListTypeCollectibles(self, "Collectibles") + base.AppendMasterListTypeCategory(self, "Category") else - base.AppendMasterListTypeNoCategory(self, texts.Components.Collectibles) - base.AppendMasterListTypeNoCategory(self, texts.Components.Category) + base.AppendMasterListTypeNoCategory(self, "Collectibles") + base.AppendMasterListTypeNoCategory(self, "Category") end end @@ -363,7 +359,7 @@ function CBs_Settings_List:FilterScrollList() for i = 1, #self.masterList do 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 + if self.masterListType == "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]) diff --git a/Changelog b/Changelog index 26d48a9..c0e20a6 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,16 @@ ------------------------------------------------------------------------------- Collection bars ------------------------------------------------------------------------------- +Version 1.0.11 (01-06-2020) +Highlights: +- It is now possible to alter the displayname of categories (again) +- In the categories tab, right click on the "cog"-icon for an enabled category, will navigate to the "Collectibles" tab. +- If account settings are used, and there exists character settings, these can now be deleted in the global settings tab. +-- At this time, these settings are not used + +Reintroduced string format, as it gives better performance, and makes the code easier to navigate +Added formatter/formatted strings for central teksts making them reusable though out the code + Version 1.0.10 (27-05-2020) - Updated APIVersion to 100031 - Now always show labels when opening the settings window by slash command or hotkey diff --git a/CollectionBars.lua b/CollectionBars.lua index eb80df1..95d9297 100644 --- a/CollectionBars.lua +++ b/CollectionBars.lua @@ -47,10 +47,8 @@ function base.InitializeCategory(category) end function base.InitializeCombineFrame() - 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) + base.Global.Combine.Frame = base.GetFrame(texts.CombineFrameName, texts.CombineFrameName) + base.Global.Combine.HideAll = base.GetFrame(texts.CombineFrameNameHideAll, texts.CombineFrameNameHideAll) end function base.CreateCategory(category) @@ -70,14 +68,14 @@ function base.CreateCategory(category) Name = collectibleData:GetName(), EnabledTexture = collectibleData:GetIcon(), Disabled = not isUnlocked, - Tooltip = string.format(texts.Tooltip.Main, collectibleData:GetDescription(), collectibleData:GetHint()), + Tooltip = string.format("%s\n%s", collectibleData:GetDescription(), collectibleData:GetHint()), CollectibleData = collectibleData } table.insert(category.CollectionOrdered, category.Collection[collectibleId]) end end - category.Frame = base.GetFrame(category.Name, base.Addon.Abbreviation .. texts.Helpers.Lowdash .. texts.Components.Frame) + category.Frame = base.GetFrame(category.Name, string.format(texts.FormatAbbreviationLowDash, "Frame")) end function base.RestoreFrames() diff --git a/CollectionBars.txt b/CollectionBars.txt index 87e38b4..c8e7f63 100644 --- a/CollectionBars.txt +++ b/CollectionBars.txt @@ -6,7 +6,7 @@ ## APIVersion: 100031 ## Title: Collection Bars -## Version: 1.0.10 +## Version: 1.0.11 ## Author: Jarth ## Description: Show collection bars and activate collections with key or button press. Shortcuts: Settings window: /cb ##