Skip to content

Commit

Permalink
Allow display frame strata/level to be set in options.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hekili committed Jan 12, 2020
1 parent eb4ce4e commit 21a2e49
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 5 deletions.
22 changes: 22 additions & 0 deletions Constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,25 @@ end
ns.getSpecializationID = function ( index )
return GetSpecializationInfo( index or GetSpecialization() or 0 )
end



ns.FrameStratas = {
"BACKGROUND",
"LOW",
"MEDIUM",
"HIGH",
"DIALOG",
"FULLSCREEN",
"FULLSCREEN_DIALOG",
"TOOLTIP",

BACKGROUND = 1,
LOW = 2,
MEDIUM = 3,
HIGH = 4,
DIALOG = 5,
FULLSCREEN = 6,
FULLSCREEN_DIALOG = 7,
TOOLTIP = 8
}
59 changes: 59 additions & 0 deletions Options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ local displayTemplate = {
keepAspectRatio = true,
zoom = 30,

frameStrata = "MEDIUM",
frameLevel = 10,

--[[ font = ElvUI and 'PT Sans Narrow' or 'Arial Narrow',
fontSize = 12,
fontStyle = "OUTLINE", ]]
Expand Down Expand Up @@ -765,6 +768,10 @@ do
shareDB.export = ""
end



local frameStratas = ns.FrameStratas

-- Display Config.
function Hekili:GetDisplayOption( info )
local n = #info
Expand All @@ -780,10 +787,13 @@ do
end

if option == 'color' then return unpack( conf.color ) end
if option == 'frameStrata' then return frameStratas[ conf.frameStrata ] or 3 end
if option == 'name' then return display end

return conf[ option ]
end


function Hekili:SetDisplayOption( info, val, v2, v3, v4 )
local n = #info
local display, category, option = info[ 2 ], info[ 3 ], info[ n ]
Expand All @@ -800,6 +810,9 @@ do
if option == 'color' then
conf.color = { val, v2, v3, v4 }
set = true
elseif option == 'frameStrata' then
conf.frameStrata = frameStratas[ val ] or "MEDIUM"
set = true
end

if not set then
Expand Down Expand Up @@ -1102,6 +1115,45 @@ do
},
},

advancedFrame = {
type = "group",
name = "Frame Layer",
inline = true,
order = 16,
args = {
frameStrata = {
type = "select",
name = "Strata",
desc = "Frame Strata determines which graphical layer that this display is drawn on.\n" ..
"The default layer is MEDIUM.",
values = {
"BACKGROUND",
"LOW",
"MEDIUM",
"HIGH",
"DIALOG",
"FULLSCREEN",
"FULLSCREEN_DIALOG",
"TOOLTIP"
},
width = 1.49,
order = 1,
},

frameLevel = {
type = "range",
name = "Level",
desc = "Frame Level determines the display's position within its current layer.\n\n" ..
"Default value is |cFFFFD10010|r.",
min = 1,
max = 10000,
step = 1,
width = 1.49,
order = 2,
}
}
},

zoom = {
type = "range",
name = "Icon Zoom",
Expand Down Expand Up @@ -2119,6 +2171,13 @@ do
name = "Fonts",
order = 960,
},

fontWarn = {
type = "description",
name = "Changing the font below will modify |cFFFF0000ALL|r text on all displays.\n" ..
"To modify one bit of text individually, select the Display (at left) and select the appropriate text.",
order = 960.01,
},

font = {
type = "select",
Expand Down
20 changes: 15 additions & 5 deletions UI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local FindUnitBuffByID, FindUnitDebuffByID = ns.FindUnitBuffByID, ns.FindUnitDeb
-- Atlas/Textures
local AddTexString, GetTexString, AtlasToString, GetAtlasFile, GetAtlasCoords = ns.AddTexString, ns.GetTexString, ns.AtlasToString, ns.GetAtlasFile, ns.GetAtlasCoords

local frameStratas = ns.FrameStratas
local getInverseDirection = ns.getInverseDirection
local multiUnpack = ns.multiUnpack
local orderedPairs = ns.orderedPairs
Expand Down Expand Up @@ -1375,14 +1376,20 @@ do
end

return left, right, top, bottom
end
end


local numDisplays = 0

function Hekili:CreateDisplay( id )
local conf = rawget( self.DB.profile.displays, id )
if not conf then return end

dPool[ id ] = dPool[ id ] or CreateFrame( "Frame", "HekiliDisplay" .. id, UIParent )
if not dPool[ id ] then
numDisplays = numDisplays + 1
dPool[ id ] = CreateFrame( "Frame", "HekiliDisplay" .. id, UIParent )
dPool[ id ].index = numDisplays
end
local d = dPool[ id ]

d.id = id
Expand All @@ -1395,7 +1402,8 @@ do

d:SetSize( scale * ( border + ( conf.primaryWidth or 50 ) ), scale * ( border + ( conf.primaryHeight or 50 ) ) )
d:SetPoint( "CENTER", nil, "CENTER", conf.x or 0, conf.y or -225 )
d:SetFrameStrata( "MEDIUM" )
d:SetFrameStrata( conf.frameStrata or "MEDIUM" )
d:SetFrameLevel( conf.frameLevel or ( 10 + d.index ) )
d:SetClampedToScreen( true )
d:EnableMouse( false )
d:SetMovable( true )
Expand Down Expand Up @@ -1757,10 +1765,12 @@ do

local framelevel = b:GetFrameLevel()
if framelevel > 0 then
b.Backdrop:SetFrameStrata( "MEDIUM" )
-- b.Backdrop:SetFrameStrata( "MEDIUM" )
b.Backdrop:SetFrameLevel( framelevel - 1 )
else
b.Backdrop:SetFrameStrata("LOW")
local lowerStrata = frameStratas[ b:GetFrameStrata() ]
lowerStrata = frameStratas[ lowerStrata - 1 ]
b.Backdrop:SetFrameStrata( lowerStrata or "LOW" )
end

b.Backdrop:SetPoint( "CENTER", b, "CENTER" )
Expand Down

0 comments on commit 21a2e49

Please sign in to comment.