From f2966bbb52e9075336eb33184bfa48e0a6c14352 Mon Sep 17 00:00:00 2001 From: shagu Date: Wed, 17 Apr 2019 22:03:07 +0200 Subject: [PATCH] xpbar: add more layout and hide options --- api/config.lua | 17 ++++++++++++++++- modules/gui.lua | 19 ++++++++++++++++++- modules/xpbar.lua | 39 ++++++++++++++++++++++++++++----------- pfUI.toc | 2 +- 4 files changed, 63 insertions(+), 14 deletions(-) diff --git a/api/config.lua b/api/config.lua index 10d7536a..6114ecb2 100644 --- a/api/config.lua +++ b/api/config.lua @@ -750,8 +750,17 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("panel", "right", "right", "gold") pfUI:UpdateConfig("panel", "other", "minimap", "zone") pfUI:UpdateConfig("panel", "micro", "enable", "0") - pfUI:UpdateConfig("panel", "xp", "showalways", "0") pfUI:UpdateConfig("panel", "bag", "ignorespecial", "1") + 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_mode", "VERTICAL") + 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_mode", "VERTICAL") pfUI:UpdateConfig("castbar", "player", "hide_blizz", "1") pfUI:UpdateConfig("castbar", "player", "hide_pfui", "0") @@ -1208,5 +1217,11 @@ function pfUI:MigrateConfig() end end + -- migrate xp-showalways (> 4.0.2) + if checkversion(4, 0, 2) then + pfUI_config.panel.xp.xp_always = pfUI_config.panel.xp.showalways + pfUI_config.panel.xp.rep_always = pfUI_config.panel.xp.showalways + end + pfUI_config.version = pfUI.version.string end diff --git a/modules/gui.lua b/modules/gui.lua index cea523c4..9d478f5a 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -885,6 +885,10 @@ pfUI:RegisterModule("gui", 20400, function () "7:" .. T["Small"], "8:" .. T["Tiny (PixelPerfect)"], }, + ["orientation"] = { + "HORIZONTAL:" .. T["Horizontal"], + "VERTICAL:" .. T["Vertical"], + }, ["uf_animationspeed"] = { "1:" .. T["Instant"], "2:" .. T["Very Fast"], @@ -1734,11 +1738,24 @@ pfUI:RegisterModule("gui", 20400, function () CreateConfig(nil, T["Right Panel: Center"], C.panel.right, "center", "dropdown", pfUI.gui.dropdowns.panel_values) CreateConfig(nil, T["Right Panel: Right"], C.panel.right, "right", "dropdown", pfUI.gui.dropdowns.panel_values) CreateConfig(nil, T["Other Panel: Minimap"], C.panel.other, "minimap", "dropdown", pfUI.gui.dropdowns.panel_values) - CreateConfig(nil, T["Always Show Experience And Reputation Bar"], C.panel.xp, "showalways", "checkbox") CreateConfig(nil, T["Only Count Bagspace On Regular Bags"], C.panel.bag, "ignorespecial", "checkbox") CreateConfig(nil, T["Enable Micro Bar"], C.panel.micro, "enable", "checkbox") 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() diff --git a/modules/xpbar.lua b/modules/xpbar.lua index df5df3be..46111a69 100644 --- a/modules/xpbar.lua +++ b/modules/xpbar.lua @@ -1,6 +1,19 @@ pfUI:RegisterModule("xpbar", 20400, function () - pfUI.xp = CreateFrame("Frame",nil, UIParent) - pfUI.xp:SetWidth(5) + + 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 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 + + pfUI.xp = CreateFrame("Frame", "pfExperienceBar", UIParent) + pfUI.xp:SetWidth(xp_width) + pfUI.xp:SetHeight(xp_height) + if pfUI.chat then pfUI.xp:SetPoint("TOPLEFT", pfUI.chat.left, "TOPRIGHT", C.appearance.border.default*2, 0) pfUI.xp:SetPoint("BOTTOMLEFT", pfUI.chat.left, "BOTTOMRIGHT", C.appearance.border.default*2, 0) @@ -10,6 +23,8 @@ pfUI:RegisterModule("xpbar", 20400, function () end pfUI.xp:SetFrameStrata("BACKGROUND") CreateBackdrop(pfUI.xp) + UpdateMovable(pfUI.xp) + pfUI.xp:RegisterEvent("PLAYER_LEVEL_UP") pfUI.xp:RegisterEvent("PLAYER_XP_UPDATE") pfUI.xp:RegisterEvent("PLAYER_ENTERING_WORLD") @@ -36,7 +51,7 @@ pfUI:RegisterModule("xpbar", 20400, function () pfUI.xp.restedbar:Hide() end pfUI.xp:SetAlpha(1) - pfUI.xp.tick = GetTime() + 3.00 + pfUI.xp.tick = GetTime() + xp_timeout else pfUI.xp:Hide(0) @@ -44,7 +59,7 @@ pfUI:RegisterModule("xpbar", 20400, function () end) pfUI.xp:SetScript("OnUpdate",function() - if C.panel.xp.showalways == "1" then return end + if C.panel.xp.xp_always == "1" then return end if pfUI.xp:GetAlpha() == 0 or pfUI.xp.mouseover == true then return end if not pfUI.xp.tick then pfUI.xp.tick = GetTime() + 0.01 @@ -103,7 +118,7 @@ pfUI:RegisterModule("xpbar", 20400, function () pfUI.xp.bar:SetFrameStrata("LOW") pfUI.xp.bar:SetStatusBarColor(.25,.25,1,1) pfUI.xp.bar:SetMinMaxValues(0, 100) - pfUI.xp.bar:SetOrientation("VERTICAL") + pfUI.xp.bar:SetOrientation(xp_mode) pfUI.xp.bar:SetValue(59) pfUI.xp.restedbar = CreateFrame("StatusBar", nil, pfUI.xp) @@ -113,10 +128,11 @@ pfUI:RegisterModule("xpbar", 20400, function () pfUI.xp.restedbar:SetFrameStrata("MEDIUM") pfUI.xp.restedbar:SetStatusBarColor(1,.25,1,.5) pfUI.xp.restedbar:SetMinMaxValues(0, 100) - pfUI.xp.restedbar:SetOrientation("VERTICAL") + pfUI.xp.restedbar:SetOrientation(xp_mode) - pfUI.rep = CreateFrame("Frame",nil, UIParent) - pfUI.rep:SetWidth(5) + pfUI.rep = CreateFrame("Frame","pfReputationBar", UIParent) + pfUI.rep:SetWidth(rep_width) + pfUI.rep:SetHeight(rep_height) if pfUI.chat then pfUI.rep:SetPoint("TOPRIGHT",pfUI.chat.right,"TOPLEFT", -C.appearance.border.default*2, 0) pfUI.rep:SetPoint("BOTTOMRIGHT",pfUI.chat.right,"BOTTOMLEFT",-C.appearance.border.default*2, 0) @@ -126,13 +142,14 @@ pfUI:RegisterModule("xpbar", 20400, function () end pfUI.rep:SetFrameStrata("BACKGROUND") CreateBackdrop(pfUI.rep) + UpdateMovable(pfUI.rep) pfUI.rep.bar = CreateFrame("StatusBar", nil, pfUI.rep) pfUI.rep.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") pfUI.rep.bar:ClearAllPoints() pfUI.rep.bar:SetAllPoints(pfUI.rep) pfUI.rep.bar:SetMinMaxValues(0, 100) - pfUI.rep.bar:SetOrientation("VERTICAL") + pfUI.rep.bar:SetOrientation(rep_mode) pfUI.rep.bar:SetValue(59) pfUI.rep:RegisterEvent("UPDATE_FACTION") @@ -152,13 +169,13 @@ pfUI:RegisterModule("xpbar", 20400, function () local color = FACTION_BAR_COLORS[standingID] pfUI.rep.bar:SetStatusBarColor((color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5, 1) pfUI.rep:SetAlpha(1) - pfUI.rep.tick = GetTime() + 3.00 + pfUI.rep.tick = GetTime() + rep_timeout end end end) pfUI.rep:SetScript("OnUpdate",function() - if C.panel.xp.showalways == "1" then return end + if C.panel.xp.rep_always == "1" then return end if pfUI.rep:GetAlpha() == 0 or pfUI.rep.mouseover == true then return end if not pfUI.rep.tick then pfUI.rep.tick = GetTime() + 0.01 diff --git a/pfUI.toc b/pfUI.toc index a077d099..67ad9c7b 100644 --- a/pfUI.toc +++ b/pfUI.toc @@ -2,7 +2,7 @@ ## Title: |cff33ffccpf|cffffffffUI ## Author: Shagu ## Notes: A complete user interface replacement. -## Version: 4.0.2 +## Version: 4.0.3 ## SavedVariables: pfUI_profiles, pfUI_addon_profiles, pfUI_cache ## SavedVariablesPerCharacter: pfUI_config, pfUI_init, pfUI_playerDB