pfUI:RegisterModule("xpbar", 20400, function () 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) else pfUI.xp:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 0, 0) pfUI.xp:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 0, 0) 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") pfUI.xp:SetScript("OnEvent", function() if event == "PLAYER_ENTERING_WORLD" then pfUI.xp.starttime = GetTime() pfUI.xp.startxp = UnitXP("player") end if event == "PLAYER_LEVEL_UP" then -- add previously gained experience to the session pfUI.xp.startxp = pfUI.xp.startxp - UnitXPMax("player") end if UnitXPMax("player") ~= 0 then pfUI.xp.bar:SetMinMaxValues(0, UnitXPMax("player")) pfUI.xp.bar:SetValue(UnitXP("player")) if GetXPExhaustion() then pfUI.xp.restedbar:Show() pfUI.xp.restedbar:SetMinMaxValues(0, UnitXPMax("player")) pfUI.xp.restedbar:SetValue(UnitXP("player") + GetXPExhaustion()) else pfUI.xp.restedbar:Hide() end pfUI.xp:SetAlpha(1) pfUI.xp.tick = GetTime() + xp_timeout else pfUI.xp:Hide(0) end end) pfUI.xp:SetScript("OnUpdate",function() 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 end if GetTime() >= pfUI.xp.tick then pfUI.xp.tick = nil pfUI.xp:SetAlpha(pfUI.xp:GetAlpha() - .05) end end) pfUI.xp:EnableMouse() pfUI.xp:SetScript("OnEnter", function() pfUI.xp.mouseover = true pfUI.xp:SetAlpha(1) local xp, xpmax, exh = UnitXP("player"), UnitXPMax("player"), GetXPExhaustion() local xp_perc = round(xp / xpmax * 100) local remaining = xpmax - xp local remaining_perc = round(remaining / xpmax * 100) local exh_perc = 0 local xp_persec = ((xp - pfUI.xp.startxp)/(GetTime() - pfUI.xp.starttime)) if GetXPExhaustion() then exh_perc = round(GetXPExhaustion() / xpmax * 100) end GameTooltip:ClearLines() GameTooltip_SetDefaultAnchor(GameTooltip, this) GameTooltip:SetOwner(this, "ANCHOR_CURSOR") GameTooltip:AddDoubleLine("|cff555555" .. T["Experience"]) GameTooltip:AddDoubleLine(T["XP"], "|cffffffff" .. xp .. " / " .. xpmax .. " (" .. xp_perc .. "%)") GameTooltip:AddDoubleLine(T["Remaining"], "|cffffffff" .. remaining .. " (" .. remaining_perc .. "%)") if IsResting() then GameTooltip:AddDoubleLine(T["Status"], "|cffffffff" .. T["Resting"]) end if GetXPExhaustion() then GameTooltip:AddDoubleLine(T["Rested"], "|cff5555ff+" .. exh .. " (" .. exh_perc .. "%)") end GameTooltip:AddLine(" ") GameTooltip:AddDoubleLine(T["This Session"], "|cffffffff" .. UnitXP("player") - pfUI.xp.startxp) GameTooltip:AddDoubleLine(T["Average Per Hour"], "|cffffffff" .. floor(((UnitXP("player") - pfUI.xp.startxp) / (GetTime() - pfUI.xp.starttime)) * 60 * 60)) GameTooltip:AddDoubleLine(T["Time Remaining"], "|cffffffff" .. (xp_persec > 0 and SecondsToTime(remaining/xp_persec) or 0)) GameTooltip:Show() end) pfUI.xp:SetScript("OnLeave", function() pfUI.xp.mouseover = false pfUI.xp.tick = GetTime() + 3.00 GameTooltip:Hide() end) pfUI.xp.bar = CreateFrame("StatusBar", nil, pfUI.xp) pfUI.xp.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") pfUI.xp.bar:ClearAllPoints() pfUI.xp.bar:SetAllPoints(pfUI.xp) pfUI.xp.bar:SetFrameStrata("LOW") pfUI.xp.bar:SetStatusBarColor(.25,.25,1,1) pfUI.xp.bar:SetMinMaxValues(0, 100) pfUI.xp.bar:SetOrientation(xp_mode) pfUI.xp.bar:SetValue(59) pfUI.xp.restedbar = CreateFrame("StatusBar", nil, pfUI.xp) pfUI.xp.restedbar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") pfUI.xp.restedbar:ClearAllPoints() pfUI.xp.restedbar:SetAllPoints(pfUI.xp) pfUI.xp.restedbar:SetFrameStrata("MEDIUM") pfUI.xp.restedbar:SetStatusBarColor(1,.25,1,.5) pfUI.xp.restedbar:SetMinMaxValues(0, 100) pfUI.xp.restedbar:SetOrientation(xp_mode) 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) else pfUI.rep:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 0) pfUI.rep:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", 0, 0) 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(rep_mode) pfUI.rep.bar:SetValue(59) pfUI.rep:RegisterEvent("UPDATE_FACTION") pfUI.rep:RegisterEvent("PLAYER_ENTERING_WORLD") pfUI.rep:SetScript("OnEvent", function() pfUI.rep:SetAlpha(0) for i=1, GetNumFactions() do local name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, isWatched = GetFactionInfo(i) if isWatched then barMax = barMax - barMin barValue = barValue - barMin barMin = 0 pfUI.rep.bar:SetMinMaxValues(barMin, barMax) pfUI.rep.bar:SetValue(barValue) 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() + rep_timeout end end end) pfUI.rep:SetScript("OnUpdate",function() 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 end if GetTime() >= pfUI.rep.tick then pfUI.rep.tick = nil pfUI.rep:SetAlpha(pfUI.rep:GetAlpha() - .05) end end) pfUI.rep:EnableMouse() pfUI.rep:SetScript("OnEnter", function() for i=1, GetNumFactions() do local name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, isWatched = GetFactionInfo(i) if isWatched then barMax = barMax - barMin barValue = barValue - barMin barMin = 0 local color = FACTION_BAR_COLORS[standingID] if not color then color = 1,1,1 end GameTooltip:ClearLines() GameTooltip_SetDefaultAnchor(GameTooltip, this) GameTooltip:SetOwner(this, "ANCHOR_CURSOR") GameTooltip:AddLine("|cff555555" .. T["Reputation"]) GameTooltip:AddLine(name .. " (" .. GetText("FACTION_STANDING_LABEL"..standingID, gender) .. ")", color.r + .3, color.g + .3, color.b + .3) GameTooltip:AddLine(barValue .. " / " .. barMax .. " (" .. round(barValue / barMax * 100) .. "%)",1,1,1) GameTooltip:Show() pfUI.rep.mouseover = true pfUI.rep:SetAlpha(1) end end end) pfUI.rep:SetScript("OnLeave", function() pfUI.rep.mouseover = false pfUI.rep.tick = GetTime() + 3.00 GameTooltip:Hide() end) end)