mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-29 02:36:02 +00:00
xpbar: add option to anchor to different frames
This commit is contained in:
+7
-2
@@ -497,13 +497,18 @@ function pfUI:LoadConfig()
|
||||
pfUI:UpdateConfig("panel", "xp", "xp_always", "0")
|
||||
pfUI:UpdateConfig("panel", "xp", "xp_timeout", "5")
|
||||
pfUI:UpdateConfig("panel", "xp", "xp_width", "5")
|
||||
pfUI:UpdateConfig("panel", "xp", "xp_height", "100")
|
||||
pfUI:UpdateConfig("panel", "xp", "xp_height", "5")
|
||||
pfUI:UpdateConfig("panel", "xp", "xp_mode", "VERTICAL")
|
||||
pfUI:UpdateConfig("panel", "xp", "xp_anchor", "pfChatLeft")
|
||||
pfUI:UpdateConfig("panel", "xp", "xp_position", "RIGHT")
|
||||
|
||||
pfUI:UpdateConfig("panel", "xp", "rep_always", "0")
|
||||
pfUI:UpdateConfig("panel", "xp", "rep_timeout", "5")
|
||||
pfUI:UpdateConfig("panel", "xp", "rep_width", "5")
|
||||
pfUI:UpdateConfig("panel", "xp", "rep_height", "100")
|
||||
pfUI:UpdateConfig("panel", "xp", "rep_height", "5")
|
||||
pfUI:UpdateConfig("panel", "xp", "rep_mode", "VERTICAL")
|
||||
pfUI:UpdateConfig("panel", "xp", "rep_anchor", "pfChatRight")
|
||||
pfUI:UpdateConfig("panel", "xp", "rep_position", "LEFT")
|
||||
|
||||
pfUI:UpdateConfig("castbar", "player", "hide_blizz", "1")
|
||||
pfUI:UpdateConfig("castbar", "player", "hide_pfui", "0")
|
||||
|
||||
+42
-16
@@ -919,6 +919,21 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function ()
|
||||
"8:" .. T["Slow"],
|
||||
"13:" .. T["Very Slow"],
|
||||
},
|
||||
["xpanchors"] = {
|
||||
"__NONONIL__:" .. T["No Anchor"],
|
||||
"pfChatLeft:" .. T["Left Chat Frame"],
|
||||
"pfChatRight:" .. T["Right Chat Frame"],
|
||||
"pfActionBarMain:" .. T["Main Actionbar"],
|
||||
"pfActionBarTop:" .. T["Top Actionbar"],
|
||||
"pfActionBarLeft:" .. T["Left Actionbar"],
|
||||
"pfActionBarRight:" .. T["Right Actionbar"],
|
||||
"pfActionBarVertical:" .. T["Vertical Actionbar"],
|
||||
"pfExperienceBar:" .. T["Experience Bar"],
|
||||
"pfReputationBar:" .. T["Reputation Bar"],
|
||||
"pfPlayer:" .. T["Player Unitframe"],
|
||||
"pfMinimap:" .. T["Minimap"],
|
||||
"pfPanelMinimap:" .. T["Minimap Panel"],
|
||||
},
|
||||
["uf_bartexture"] = {
|
||||
"Interface\\AddOns\\pfUI\\img\\bar:pfUI",
|
||||
"Interface\\AddOns\\pfUI\\img\\bar_tukui:TukUI",
|
||||
@@ -1109,6 +1124,12 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function ()
|
||||
"top:" .. T["Top"],
|
||||
"right:" .. T["Right"]
|
||||
},
|
||||
["xp_position"] = {
|
||||
"BOTTOM:" .. T["Bottom"],
|
||||
"LEFT:" .. T["Left"],
|
||||
"TOP:" .. T["Top"],
|
||||
"RIGHT:" .. T["Right"]
|
||||
},
|
||||
}
|
||||
|
||||
-- add locale dependent client fonts to the list
|
||||
@@ -1907,28 +1928,33 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function ()
|
||||
CreateConfig(nil, T["Enable 24h Clock"], C.global, "twentyfour", "checkbox")
|
||||
CreateConfig(nil, T["Servertime"], C.global, "servertime", "checkbox")
|
||||
|
||||
CreateConfig(nil, T["Experience Bar"], nil, nil, "header")
|
||||
CreateConfig(nil, T["Always Show"], C.panel.xp, "xp_always", "checkbox")
|
||||
CreateConfig(nil, T["Hide Timeout"], C.panel.xp, "xp_timeout")
|
||||
CreateConfig(nil, T["Width"], C.panel.xp, "xp_width")
|
||||
CreateConfig(nil, T["Height"], C.panel.xp, "xp_height")
|
||||
CreateConfig(nil, T["Orientation"], C.panel.xp, "xp_mode", "dropdown", pfUI.gui.dropdowns.orientation)
|
||||
|
||||
CreateConfig(nil, T["Reputation Bar"], nil, nil, "header")
|
||||
CreateConfig(nil, T["Always Show"], C.panel.xp, "rep_always", "checkbox")
|
||||
CreateConfig(nil, T["Hide Timeout"], C.panel.xp, "rep_timeout")
|
||||
CreateConfig(nil, T["Width"], C.panel.xp, "rep_width")
|
||||
CreateConfig(nil, T["Height"], C.panel.xp, "rep_height")
|
||||
CreateConfig(nil, T["Orientation"], C.panel.xp, "rep_mode", "dropdown", pfUI.gui.dropdowns.orientation)
|
||||
end)
|
||||
|
||||
CreateGUIEntry(T["Panel"], T["Auto Hide"], function()
|
||||
CreateConfig(nil, T["Auto Hide"], nil, nil, "header")
|
||||
CreateConfig(nil, T["Enable Autohide For Left Chat Panel"], C.panel, "hide_leftchat", "checkbox")
|
||||
CreateConfig(nil, T["Enable Autohide For Right Chat Panel"], C.panel, "hide_rightchat", "checkbox")
|
||||
CreateConfig(nil, T["Enable Autohide For Minimap Panel"], C.panel, "hide_minimap", "checkbox")
|
||||
CreateConfig(nil, T["Enable Autohide For Microbar Panel"], C.panel, "hide_microbar", "checkbox")
|
||||
end)
|
||||
|
||||
CreateGUIEntry(T["XP Bar"], T["Experience Bar"], function()
|
||||
CreateConfig(U["xpbar"], T["Always Show"], C.panel.xp, "xp_always", "checkbox")
|
||||
CreateConfig(U["xpbar"], T["Hide Timeout"], C.panel.xp, "xp_timeout")
|
||||
CreateConfig(U["xpbar"], T["Width"], C.panel.xp, "xp_width")
|
||||
CreateConfig(U["xpbar"], T["Height"], C.panel.xp, "xp_height")
|
||||
CreateConfig(U["xpbar"], T["Orientation"], C.panel.xp, "xp_mode", "dropdown", pfUI.gui.dropdowns.orientation)
|
||||
CreateConfig(U["xpbar"], T["Frame Anchor"], C.panel.xp, "xp_anchor", "dropdown", pfUI.gui.dropdowns.xpanchors)
|
||||
CreateConfig(U["xpbar"], T["Aligned Position"], C.panel.xp, "xp_position", "dropdown", pfUI.gui.dropdowns.xp_position)
|
||||
end)
|
||||
|
||||
CreateGUIEntry(T["XP Bar"], T["Reputation Bar"], function()
|
||||
CreateConfig(U["xpbar"], T["Always Show"], C.panel.xp, "rep_always", "checkbox")
|
||||
CreateConfig(U["xpbar"], T["Hide Timeout"], C.panel.xp, "rep_timeout")
|
||||
CreateConfig(U["xpbar"], T["Width"], C.panel.xp, "rep_width")
|
||||
CreateConfig(U["xpbar"], T["Height"], C.panel.xp, "rep_height")
|
||||
CreateConfig(U["xpbar"], T["Orientation"], C.panel.xp, "rep_mode", "dropdown", pfUI.gui.dropdowns.orientation)
|
||||
CreateConfig(U["xpbar"], T["Frame Anchor"], C.panel.xp, "rep_anchor", "dropdown", pfUI.gui.dropdowns.xpanchors)
|
||||
CreateConfig(U["xpbar"], T["Aligned Position"], C.panel.xp, "rep_position", "dropdown", pfUI.gui.dropdowns.xp_position)
|
||||
end)
|
||||
|
||||
CreateGUIEntry(T["Tooltip"], nil, function()
|
||||
CreateConfig(nil, T["Tooltip Position"], C.tooltip, "position", "dropdown", pfUI.gui.dropdowns.tooltip_position)
|
||||
CreateConfig(nil, T["Cursor Tooltip Align"], C.tooltip, "cursoralign", "dropdown", pfUI.gui.dropdowns.tooltip_align)
|
||||
|
||||
+54
-31
@@ -1,51 +1,67 @@
|
||||
pfUI:RegisterModule("xpbar", "vanilla:tbc", function ()
|
||||
local rawborder, default_border = GetBorderSize()
|
||||
|
||||
local xp_timeout = tonumber(C.panel.xp.xp_timeout)
|
||||
local xp_width = C.panel.xp.xp_width
|
||||
local xp_height = C.panel.xp.xp_height
|
||||
local xp_mode = C.panel.xp.xp_mode
|
||||
local xp_always = C.panel.xp.xp_always == "1" and true or nil
|
||||
|
||||
local rep_timeout = tonumber(C.panel.xp.rep_timeout)
|
||||
local rep_width = C.panel.xp.rep_width
|
||||
local rep_height = C.panel.xp.rep_height
|
||||
local rep_mode = C.panel.xp.rep_mode
|
||||
local rep_always = C.panel.xp.rep_always == "1" and true or nil
|
||||
|
||||
local parse_faction = SanitizePattern(FACTION_STANDING_INCREASED)
|
||||
|
||||
local function AlignToPosition(frame, anchor, position)
|
||||
local pixel = GetPerfectPixel()
|
||||
frame:ClearAllPoints()
|
||||
if position == "TOP" and anchor then
|
||||
frame:SetPoint("BOTTOMLEFT", anchor, "TOPLEFT", 0, default_border*3)
|
||||
frame:SetPoint("BOTTOMRIGHT", anchor, "TOPRIGHT", 0, default_border*3)
|
||||
elseif position == "RIGHT" and anchor then
|
||||
frame:SetPoint("TOPLEFT", anchor, "TOPRIGHT", default_border*3, 0)
|
||||
frame:SetPoint("BOTTOMLEFT", anchor, "BOTTOMRIGHT", default_border*3, 0)
|
||||
elseif position == "BOTTOM" and anchor then
|
||||
frame:SetPoint("TOPLEFT", anchor, "BOTTOMLEFT", 0, -default_border*3)
|
||||
frame:SetPoint("TOPRIGHT", anchor, "BOTTOMRIGHT", 0, -default_border*3)
|
||||
elseif position == "LEFT" and anchor then
|
||||
frame:SetPoint("TOPRIGHT", anchor, "TOPLEFT", -default_border*3, 0)
|
||||
frame:SetPoint("BOTTOMRIGHT", anchor, "BOTTOMLEFT", -default_border*3, 0)
|
||||
else
|
||||
frame:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 0)
|
||||
frame:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", 0, 0)
|
||||
end
|
||||
UpdateMovable(frame, true)
|
||||
end
|
||||
|
||||
local function CreateBar(t)
|
||||
local xp_timeout = tonumber(C.panel.xp.xp_timeout)
|
||||
local xp_width = C.panel.xp.xp_width
|
||||
local xp_height = C.panel.xp.xp_height
|
||||
local xp_mode = C.panel.xp.xp_mode
|
||||
local xp_always = C.panel.xp.xp_always == "1" and true or nil
|
||||
local xp_position = C.panel.xp.xp_position
|
||||
local xp_anchor = C.panel.xp.xp_anchor
|
||||
|
||||
|
||||
local rep_timeout = tonumber(C.panel.xp.rep_timeout)
|
||||
local rep_width = C.panel.xp.rep_width
|
||||
local rep_height = C.panel.xp.rep_height
|
||||
local rep_mode = C.panel.xp.rep_mode
|
||||
local rep_always = C.panel.xp.rep_always == "1" and true or nil
|
||||
local rep_position = C.panel.xp.rep_position
|
||||
local rep_anchor = C.panel.xp.rep_anchor
|
||||
|
||||
local t = t
|
||||
local width = t == "XP" and xp_width or rep_width
|
||||
local height = t == "XP" and xp_height or rep_height
|
||||
local mode = t == "XP" and xp_mode or rep_mode
|
||||
local timeout = t == "XP" and xp_timeout or rep_timeout
|
||||
local always = t == "XP" and xp_always or rep_always
|
||||
|
||||
local name = t == "XP" and "pfExperienceBar" or "pfReputationBar"
|
||||
local anchor = t == "XP" and xp_anchor or rep_anchor
|
||||
local position = t == "XP" and xp_position or rep_position
|
||||
|
||||
local b = CreateFrame("Frame", name, UIParent)
|
||||
local b = _G[name] or CreateFrame("Frame", name, UIParent)
|
||||
b:SetWidth(width)
|
||||
b:SetHeight(height)
|
||||
b:SetFrameStrata("BACKGROUND")
|
||||
|
||||
if t == "XP" and pfUI.chat then
|
||||
b:SetPoint("TOPLEFT", pfUI.chat.left, "TOPRIGHT", default_border*2, 0)
|
||||
b:SetPoint("BOTTOMLEFT", pfUI.chat.left, "BOTTOMRIGHT", default_border*2, 0)
|
||||
elseif t == "REP" and pfUI.chat then
|
||||
b:SetPoint("TOPRIGHT",pfUI.chat.right,"TOPLEFT", -default_border*2, 0)
|
||||
b:SetPoint("BOTTOMRIGHT",pfUI.chat.right,"BOTTOMLEFT",-default_border*2, 0)
|
||||
else
|
||||
b:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 0)
|
||||
b:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", 0, 0)
|
||||
end
|
||||
|
||||
AlignToPosition(b, _G[anchor], position)
|
||||
CreateBackdrop(b)
|
||||
CreateBackdropShadow(b)
|
||||
UpdateMovable(b)
|
||||
|
||||
b.bar = CreateFrame("StatusBar", nil, b)
|
||||
b.bar = b.bar or CreateFrame("StatusBar", nil, b)
|
||||
b.bar:SetStatusBarTexture(pfUI.media["img:bar"])
|
||||
b.bar:ClearAllPoints()
|
||||
b.bar:SetAllPoints(b)
|
||||
@@ -55,7 +71,7 @@ pfUI:RegisterModule("xpbar", "vanilla:tbc", function ()
|
||||
b.bar:SetOrientation(mode)
|
||||
b.bar:SetValue(0)
|
||||
|
||||
b.restedbar = CreateFrame("StatusBar", nil, b)
|
||||
b.restedbar = b.restedbar or CreateFrame("StatusBar", nil, b)
|
||||
b.restedbar:SetStatusBarTexture(pfUI.media["img:bar"])
|
||||
b.restedbar:ClearAllPoints()
|
||||
b.restedbar:SetAllPoints(b)
|
||||
@@ -85,6 +101,9 @@ pfUI:RegisterModule("xpbar", "vanilla:tbc", function ()
|
||||
b:RegisterEvent("PLAYER_LEVEL_UP")
|
||||
b:RegisterEvent("UPDATE_FACTION")
|
||||
b:SetScript("OnEvent", function()
|
||||
-- realign when entering world to ensure all frames got loaded
|
||||
AlignToPosition(b, _G[anchor], position)
|
||||
|
||||
-- set either experience, reputation or flex-rep handler
|
||||
local mode = ( t == "XP" and UnitLevel("player") < MAX_LEVEL ) and "XP" or t == "REP" and "REP" or "FLEX"
|
||||
|
||||
@@ -215,6 +234,10 @@ pfUI:RegisterModule("xpbar", "vanilla:tbc", function ()
|
||||
return b
|
||||
end
|
||||
|
||||
pfUI.xp = CreateBar("XP")
|
||||
pfUI.rep = CreateBar("REP")
|
||||
pfUI.xpbar = { ["UpdateConfig"] = function()
|
||||
pfUI.xp = CreateBar("XP")
|
||||
pfUI.rep = CreateBar("REP")
|
||||
end}
|
||||
|
||||
pfUI.xpbar:UpdateConfig()
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user