Skip to content

Commit

Permalink
New color picker
Browse files Browse the repository at this point in the history
  • Loading branch information
TravisSpomer committed Feb 3, 2024
1 parent ad567a6 commit 75e4162
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
38 changes: 27 additions & 11 deletions PawnUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -914,24 +914,40 @@ function PawnUIFrame_GetCurrentScaleColor()
end

function PawnUIFrame_ScaleColorSwatch_OnClick()
-- Get the color of the current scale.
local r, g, b = PawnUIFrame_GetCurrentScaleColor()
ColorPickerFrame.func = PawnUIFrame_ScaleColorSwatch_OnChange
ColorPickerFrame.cancelFunc = PawnUIFrame_ScaleColorSwatch_OnCancel
ColorPickerFrame.previousValues = { r, g, b }
ColorPickerFrame.hasOpacity = false
ColorPickerFrame:SetColorRGB(r, g, b)
ShowUIPanel(ColorPickerFrame)
local info = {}
info.swatchFunc = PawnUIFrame_ScaleColorSwatch_OnChange
info.hasOpacity = false
info.r, info.g, info.b = PawnUIFrame_GetCurrentScaleColor()
info.cancelFunc = PawnUIFrame_ScaleColorSwatch_OnCancel

if ColorPickerFrame.SetupColorPickerAndShow then
-- Dragonflight 10.2.5 and later
ColorPickerFrame:SetupColorPickerAndShow(info)
else
-- Classic
ColorPickerFrame.func = info.swatchFunc
ColorPickerFrame.cancelFunc = info.cancelFunc
ColorPickerFrame.previousValues = { r = info.r, g = info.g, b = info.b }
ColorPickerFrame.hasOpacity = info.hasOpacity
ColorPickerFrame:SetColorRGB(info.r, info.g, info.b)
ShowUIPanel(ColorPickerFrame)
end
end

function PawnUIFrame_ScaleColorSwatch_OnChange()
local r, g, b = ColorPickerFrame:GetColorRGB()
PawnUIFrame_ScaleColorSwatch_SetColor(r, g, b)
end

function PawnUIFrame_ScaleColorSwatch_OnCancel(rgb)
---@diagnostic disable-next-line: deprecated
local r, g, b = unpack(rgb)
function PawnUIFrame_ScaleColorSwatch_OnCancel()
local r, g, b
if ColorPickerFrame.GetPreviousValues then
-- Dragonflight 10.2.5 and later
r, g, b = ColorPickerFrame:GetPreviousValues()
else
-- Classic
r, g, b = ColorPicker_GetPreviousValues()
end
PawnUIFrame_ScaleColorSwatch_SetColor(r, g, b)
end

Expand Down
1 change: 1 addition & 0 deletions Readme.htm
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ <h2>Updates</h2>
<h3>Version 2.8.9</h3>
<ul>
<li>Dragonflight: Updated stat weights for all classes and specs.</li>
<li>Dragonflight: Updated Pawn's scale color button to work with the new patch 10.2.5 color picker.</li>
</ul>
<h3>Version 2.8.8</h3>
<ul>
Expand Down

0 comments on commit 75e4162

Please sign in to comment.