Skip to content

Commit

Permalink
[Feature] Support changing texture/icon for the Rested Experience ind…
Browse files Browse the repository at this point in the history
…icator (#166)
  • Loading branch information
Krealle committed Dec 17, 2024
1 parent cbac929 commit 3831d72
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions Data/Constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ const.OPTION_KIND = {
TARGET_SEPARATOR = "targetSeparator",
TIME_TO_HOLD = "timeToHold",
INTERRUPTED_LABEL = "interruptedLabel",
ICON_TEXTURE = "iconTexture",
}

---@enum AURA_OPTION_KIND
Expand Down
1 change: 1 addition & 0 deletions Data/Defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ Defaults.Widgets = {
enabled = false,
frameLevel = 10,
hideAtMaxLevel = false,
iconTexture = "",
size = {
width = 20,
height = 20,
Expand Down
16 changes: 15 additions & 1 deletion Menu/Builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ Builder.MenuOptions = {
TotemOptions = 34,
HideAtMaxLevel = 35,
HideOutOfCombat = 36,
Glow = 37
Glow = 37,
IconTexture = 38,
}

local FAILED = FAILED or "Failed"
Expand Down Expand Up @@ -1294,6 +1295,18 @@ function Builder:CreateGlowOptions(parent, widgetName)
return f
end

function Builder:CreateIconTextureOptions(parent, widgetName)
---@class IconTextureOptions: OptionsFrame
local f = CUF:CreateFrame(nil, parent, 1, 1, true, true)
f.id = "IconTextureOptions"
f.optionHeight = 20

local texturePath = self:CreateEditBox(f, widgetName, L["Texture"], 350, const.OPTION_KIND.ICON_TEXTURE)
texturePath:SetPoint("TOPLEFT")

return f
end

-------------------------------------------------
-- MARK: Aura Icon
-------------------------------------------------
Expand Down Expand Up @@ -2173,4 +2186,5 @@ Builder.MenuFuncs = {
[Builder.MenuOptions.HideAtMaxLevel] = Builder.CreateHideAtMaxLevel,
[Builder.MenuOptions.HideOutOfCombat] = Builder.CreateHideOutOfCombat,
[Builder.MenuOptions.Glow] = Builder.CreateGlowOptions,
[Builder.MenuOptions.IconTexture] = Builder.CreateIconTextureOptions,
}
1 change: 1 addition & 0 deletions WidgetAnnotations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
---@field frameLevel number
---@field size SizeOpt
---@field hideAtMaxLevel boolean
---@field iconTexture string

---@class ReadyCheckIconWidgetTable
---@field enabled boolean
Expand Down
18 changes: 18 additions & 0 deletions Widgets/Icons/RestingIcon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ menu:AddWidget(const.WIDGET_KIND.RESTING_ICON,
Builder.MenuOptions.Anchor,
Builder.MenuOptions.SingleSize,
Builder.MenuOptions.HideAtMaxLevel,
Builder.MenuOptions.IconTexture,
Builder.MenuOptions.FrameLevel)

---@param button CUFUnitButton
Expand All @@ -37,6 +38,9 @@ function W.UpdateRestingIconWidget(button, unit, setting, subSetting)
restingIcon.hideAtMaxLevel = styleTable.hideAtMaxLevel
restingIcon:UpdateEventListeners()
end
if not setting or setting == const.OPTION_KIND.ICON_TEXTURE then
restingIcon:SetTexture(styleTable.iconTexture)
end

restingIcon.Update(button)
end
Expand Down Expand Up @@ -122,6 +126,18 @@ local function UpdateEventListeners(self)
end
end

---@param self RestingIconWidget
---@param texture string
local function SetTexture(self, texture)
if texture == "" then
self.tex:SetTexture("Interface\\CharacterFrame\\UI-StateIcon")
self.tex:SetTexCoord(0, .5, 0, .421875)
else
self.tex:SetTexture(texture)
self.tex:SetTexCoord(0, 1, 0, 1)
end
end

-------------------------------------------------
-- MARK: Create
-------------------------------------------------
Expand Down Expand Up @@ -154,6 +170,8 @@ function W:CreateRestingIcon(button)

restingIcon.UpdateEventListeners = UpdateEventListeners

restingIcon.SetTexture = SetTexture

restingIcon.SetEnabled = W.SetEnabled
restingIcon.SetPosition = W.SetPosition
restingIcon._SetIsSelected = W.SetIsSelected
Expand Down

0 comments on commit 3831d72

Please sign in to comment.