From 8c995d90547b5ff5d54bd9251c3524630d29138c Mon Sep 17 00:00:00 2001 From: Miziak Date: Fri, 19 Dec 2014 15:46:02 +0100 Subject: [PATCH] little changes --- IronMicroExperience.lua | 381 +++++++++++++++++++++++++++++++++++++++++++++++ IronMicroExperience.toc | 7 + MicroExperience.lua | 381 ----------------------------------------------- MicroExperience.toc | 7 - 4 files changed, 388 insertions(+), 388 deletions(-) create mode 100644 IronMicroExperience.lua create mode 100644 IronMicroExperience.toc delete mode 100644 MicroExperience.lua delete mode 100644 MicroExperience.toc diff --git a/IronMicroExperience.lua b/IronMicroExperience.lua new file mode 100644 index 0000000..f7c3fd1 --- /dev/null +++ b/IronMicroExperience.lua @@ -0,0 +1,381 @@ +--[[ + Title: MicroExperience + Version: 40000.06 + Author: Sáulhudson +]]-- + + +------------------------------------------------------------------------ +-- Basic configuration section. Width, height, anchor point etc ... +------------------------------------------------------------------------ + +-- Bar settings +local width = 436 +local height = 10 +local anchor = "BOTTOM" +local xoffset = 0 +local yoffset = 0 + +-- Tooltip settings +local ttanchorpoint = "BOTTOMLEFT" +local ttanchorframe = "BOTTOMRIGHT" +local ttxoffset = 5 +local ttyoffset = -2 + +------------------------------------------------------------------------ +-- End of configuration +------------------------------------------------------------------------ + + +-- Local variables +local gained , sessionxp, min, max +local name, standing, minrep, maxrep, value +local factions = {} +local flen = 0 + +local _, class = UnitClass("player") +local r, g, b = RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b + +local TEXTURE = [[Interface\AddOns\IronMicroExperience\textures\minimalist]] +local BACKDROP = { + bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], + insets = {top = -1, left = -1, bottom = -1, right = -1}, +} +local shadows = { + edgeFile = "Interface\\AddOns\\IronMicroExperience\\textures\\glowTex", + edgeSize = 4, + insets = { left = 3, right = 3, top = 3, bottom = 3 } +} + +local reaction = { + [1] = { r = 222/255, g = 95/255, b = 95/255 }, -- Hated + [2] = { r = 222/255, g = 95/255, b = 95/255 }, -- Hostile + [3] = { r = 222/255, g = 95/255, b = 95/255 }, -- Unfriendly + [4] = { r = 218/255, g = 197/255, b = 92/255 }, -- Neutral + [5] = { r = 75/255, g = 175/255, b = 76/255 }, -- Friendly + [6] = { r = 75/255, g = 175/255, b = 76/255 }, -- Honored + [7] = { r = 0/255, g = 112/255, b = 221/255 }, -- Revered + [8] = { r = 163/255, g = 53/255, b = 238/255 }, -- Exalted +} +local repstanding = { + [1] = "Hated", + [2] = "Hostile", + [3] = "Unfriendly", + [4] = "Neutral", + [5] = "Friendly", + [6] = "Honored", + [7] = "Revered", + [8] = "Exalted", +} + +local font = CreateFont("xpBarFont") +font:SetFontObject(GameFontHighlightSmall) +font:SetTextColor(r, g, b) + +local function truncate(value) + if(value > 9999) then + return string.format("|cffffffff%.0f|rk", value / 1e3) + else + return "|cffffffff"..value.."|r" + end +end + +local function OnEnter(self) + if UnitAffectingCombat("player") then return end -- don't display tooltip in combat + + -- Create the tooltip + -- GameTooltip:SetOwner(self, 'ANCHOR_NONE') + -- GameTooltip:SetPoint(ttanchorpoint, self, ttanchorframe, ttxoffset, ttyoffset) + GameTooltip_SetDefaultAnchor( GameTooltip, UIParent ) + GameTooltip:AddLine('Iron Micro Experience', r, g, b) + GameTooltip:AddLine(' ') + + name, standing, minrep, maxrep, value = GetWatchedFactionInfo() + + -- Tooltip for tracking experience + if (name == nil) then + local min = UnitXP("player") + local max = UnitXPMax("player") + local retVal = GetXPExhaustion() + + -- Display basic experience information + GameTooltip:AddLine(format('Experience: %s / %s (%.1f%%)', truncate(min), truncate(max), min / max * 100)) + GameTooltip:AddLine(format('Remaining: %s (%.1f%%)', truncate(max-min), 100 - (min / max * 100))) + GameTooltip:AddLine(format('Bars: |cffffffff%.1f|r complete / |cffffffff%.1f|r remaining', min/(max/20), 20-(min/(max/20)))) + + if (retVal) then + GameTooltip:AddLine(format('|cff1369caRested: %s (|cffffffff%.1f|r%%)', truncate(retVal), retVal / max * 100)) + end + + -- Get completed quest experience + local questxp, completedquests = 0, 0 + local numEntries, numQuests = GetNumQuestLogEntries() + for i = 0, numQuests do + questLogTitleText, level, questTag, suggestedGroup, isHeader, isCollapsed, isComplete, isDaily, questID = GetQuestLogTitle(i) + SelectQuestLogEntry(i) + if (isComplete) then + questxp = questxp + GetQuestLogRewardXP() + completedquests = completedquests + 1 + end + end + + -- Display if the players quest log contains completed entries + if (questxp > 0) then + GameTooltip:AddLine(' ') + GameTooltip:AddLine(format('Quest Experience: |cffffffff%d|r (%d)', questxp, completedquests)) + if (min + questxp > max ) then + GameTooltip:AddLine(format('Remaining inc Quests: |cffffffff%s|r', truncate(max-(min + questxp)))) + else + GameTooltip:AddLine(format('Remaining inc Quests: |cffffffff%s (%.1f%%)|r', truncate(max-(min + questxp)), 100 - ((min + questxp) / max * 100))) + end + end + + -- Display session experience gains + if (sessionxp > 0) then + GameTooltip:AddLine(' ') + GameTooltip:AddLine(format('Last Gained: |cffffffff%.0f|r', gained)) + GameTooltip:AddLine(format('Total Gained: |cffffffff%.0f|r', sessionxp)) + end + + -- Tooltip for tracking reputation + else + maxrep = (maxrep-minrep) + minrep = (value-minrep) + + -- Display basic reputation information + GameTooltip:AddLine(format('Watched Faction: |cffffffff%s|r', name)) + GameTooltip:AddLine(format('Current Standing: |cFF%02x%02x%02x%s|r', reaction[standing].r*255, reaction[standing].g*255, reaction[standing].b*255, repstanding[standing])) + GameTooltip:AddLine(format('Value: |cffffffff%d|r / |cffffffff%d|r %.1f%%', minrep, maxrep, minrep/maxrep*100)) + + -- Display any reputation gains during the session + local header = false + for i = 1, GetNumFactions() do + name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild = GetFactionInfo(i) + + for key, value in pairs(factions) do + + if ( name == key ) then + if ( barValue ~= value and not header ) then + GameTooltip:AddLine(' ') + GameTooltip:AddLine('Session Info', r, g, b) + GameTooltip:AddLine(' ') + GameTooltip:AddLine(format('|cffffffff%s|r +%d', name, barValue - value)) + header = true + elseif ( barValue ~= value and header ) then + GameTooltip:AddLine(format('|cffffffff%s|r +%d', name, barValue - value)) + end + end + + end + + end + + end + + GameTooltip:Show() +end + +local function OnLeave(self) + GameTooltip:Hide() +end + +--[[ + Create Functions +--]] + +local function CreateInnerBorder(f) + if f.iborder then return end + f.iborder = CreateFrame("Frame", nil, f) + f.iborder:SetPoint("TOPLEFT", 1, -1) + f.iborder:SetPoint("BOTTOMRIGHT", -1, 1) + f.iborder:SetFrameLevel(f:GetFrameLevel()) + f.iborder:SetBackdrop({ + edgeFile = "Interface\\Buttons\\WHITE8x8", edgeSize = 1, + insets = { left = -1, right = -1, top = -1, bottom = -1} + }) + f.iborder:SetBackdropBorderColor(0, 0, 0) + return f.iborder +end + +local function CreateOuterBorder(f) + if f.oborder then return end + f.oborder = CreateFrame("Frame", nil, f) + f.oborder:SetPoint("TOPLEFT", -1, 1) + f.oborder:SetPoint("BOTTOMRIGHT", 1, -1) + f.oborder:SetFrameLevel(f:GetFrameLevel()) + f.oborder:SetBackdrop({ + edgeFile = "Interface\\Buttons\\WHITE8x8", edgeSize = 1, + insets = { left = -1, right = -1, top = -1, bottom = -1} + }) + f.oborder:SetBackdropBorderColor(0, 0, 0) + return f.oborder +end + +local function CreatePanel(f, w, h, a1, p, a2, x, y) + f:SetFrameLevel(1) + f:SetHeight(h) + f:SetWidth(w) + f:SetFrameStrata("BACKGROUND") + f:SetPoint(a1, p, a2, x, y) + f:SetBackdrop({ + bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], + edgeFile = "Interface\\Buttons\\WHITE8x8", + tile = false, tileSize = 0, edgeSize = 1, + insets = { left = -1, right = -1, top = -1, bottom = -1} + }) + f:SetBackdropColor(.1,.1,.1,1) + f:SetBackdropBorderColor(.3,.3,.3,1) + + CreateOuterBorder(f) + CreateInnerBorder(f) +end + +local function CreateShadow(f) + if f.shadow then return end + local shadow = CreateFrame("Frame", nil, f) + shadow:SetFrameLevel(1) + shadow:SetFrameStrata(f:GetFrameStrata()) + shadow:SetPoint("TOPLEFT", -4, 4) + shadow:SetPoint("BOTTOMRIGHT", 4, -4) + shadow:SetBackdrop(shadows) + shadow:SetBackdropColor(0, 0, 0, 0) + shadow:SetBackdropBorderColor(0, 0, 0, 1) + f.shadow = shadow + return shadow +end + +-- Create the panel and bars +local xpbarp = CreateFrame("Frame", nil, UIParent) +CreatePanel(xpbarp, width, height, anchor, xoffset, yoffset) +CreateShadow(xpbarp) + +local xpbar = CreateFrame("statusbar", nil, UIParent) +xpbar:SetPoint("CENTER", xpbarp, "CENTER", 0, 0) +xpbar:SetWidth(width - 4) +xpbar:SetHeight(height - 4) +xpbar:SetStatusBarTexture(TEXTURE) +xpbar:SetStatusBarColor(r, g, b, 1) +xpbar:SetFrameLevel(2) +xpbar:EnableMouse() +xpbar:HookScript("OnLeave", OnLeave) +xpbar:HookScript("OnEnter", OnEnter) + +local rested = CreateFrame('StatusBar', nil, Experience) +rested:SetAllPoints(xpbar) +rested:SetStatusBarTexture(TEXTURE) +rested:SetStatusBarColor(r, g, b, 0.4) +rested:SetBackdrop(BACKDROP) +rested:SetBackdropColor(0.1, 0.1, 0.1) +rested:SetFrameLevel(1) + +bg = rested:CreateTexture(nil, "BACKGROUND") +bg:SetAllPoints(xpbar) +bg:SetVertexColor(0.3, 0.3, 0.3) + +local text = xpbar:CreateFontString(nil, "OVERLAY") +text:SetPoint("CENTER", xpbar, "CENTER", 0, 0) +text:SetFontObject(font) + +--[[ + Update Functions +--]] + +function xpbar:PLAYER_LOGIN() + gained = 0 + sessionxp = 0 + min = UnitXP("player") + max = UnitXPMax("player") + end + +function xpbar:PLAYER_XP_UPDATE() + + -- Prevent game loading errors + if (min == nil or max == nil) then + return + end + + -- Handle the counting of gained experience even after the player has levelled up + if ( UnitXP("player") >= min ) then + gained = UnitXP("player") - min + else + gained = UnitXP("player") + (max - min) + end + + sessionxp = sessionxp + gained + min = UnitXP("player") + max = UnitXPMax("player") + + -- Discover if a faction is curently being watched if so return nil + name, standing, minrep, maxrep, value = GetWatchedFactionInfo() + if (name ~= nil) then + return nil + end + + -- Set the xpbar colour and values + xpbar:SetStatusBarColor(r, g, b, 1) + xpbar:SetMinMaxValues(0, max) + xpbar:SetValue(min) + + -- If the player has just gained some experience display this on the main bar else just display current experience information + if (gained == 0) then + text:SetFormattedText("%s / %s |cffffffff%.1f|r%%", truncate(min), truncate(max), min/max*100) + else + text:SetFormattedText("%s / %s |cffffffff%.1f|r%% +|cffffffff%.0f|r", truncate(min), truncate(max), min/max*100, gained) + end + + -- Display rested bar if the player is rested + local retVal = GetXPExhaustion() + if (retVal) then + rested:SetMinMaxValues(0, max) + rested:SetValue(min + retVal) + rested:Show() + else + rested:Hide() + end + +end + +function xpbar:UPDATE_FACTION() + + -- This event fires before the reputation panel is loaded so if the panel isn't ready return nil + if ( GetNumFactions() == 0 ) then return nil end + + -- If the factions table hasn't been loaded load it to compare against during the session + if ( flen == 0 ) then + for i=1, GetNumFactions() do + name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild = GetFactionInfo(i) + if ( not isHeader ) then + factions[name] = barValue + end + end + for key, value in pairs(factions) do + flen = flen + 1 + end + end + + -- Discover if a faction is curently being watched if so PLAYER_XP_UPDATE() then return nil + name, standing, minrep, maxrep, value = GetWatchedFactionInfo() + if (name == nil) then + self:PLAYER_XP_UPDATE() + return nil + end + + maxrep = (maxrep-minrep) + minrep = (value-minrep) + + xpbar:SetStatusBarColor(reaction[standing].r, reaction[standing].g, reaction[standing].b) + xpbar:SetMinMaxValues(0, maxrep) + xpbar:SetValue(minrep) + rested:Hide() + + text:SetFormattedText("|cffffffff %s %.1f%%|r", name, minrep/maxrep*100) + +end + +-- RegisterEvents +xpbar:SetScript("OnEvent", function(self, event, ...) self[event](self, event, ...); end) +xpbar:SetScript("OnEnter", OnEnter) +xpbar:SetScript("OnLeave", OnLeave) +xpbar:RegisterEvent("PLAYER_LOGIN") +xpbar:RegisterEvent("PLAYER_XP_UPDATE") +xpbar:RegisterEvent('UPDATE_FACTION') \ No newline at end of file diff --git a/IronMicroExperience.toc b/IronMicroExperience.toc new file mode 100644 index 0000000..6bb76a2 --- /dev/null +++ b/IronMicroExperience.toc @@ -0,0 +1,7 @@ +## Interface: 60000 +## Title: IronMicroExperience +## Author: sáulhudson updated by Miziak +## Version: 40000.7 +## Notes: Simple, clean and lite exp and rep bar + +IronMicroExperience.lua \ No newline at end of file diff --git a/MicroExperience.lua b/MicroExperience.lua deleted file mode 100644 index 78fba4d..0000000 --- a/MicroExperience.lua +++ /dev/null @@ -1,381 +0,0 @@ ---[[ - Title: MicroExperience - Version: 40000.06 - Author: Sáulhudson -]]-- - - ------------------------------------------------------------------------- --- Basic configuration section. Width, height, anchor point etc ... ------------------------------------------------------------------------- - --- Bar settings -local width = 436 -local height = 10 -local anchor = "BOTTOM" -local xoffset = 0 -local yoffset = 0 - --- Tooltip settings -local ttanchorpoint = "BOTTOMLEFT" -local ttanchorframe = "BOTTOMRIGHT" -local ttxoffset = 5 -local ttyoffset = -2 - ------------------------------------------------------------------------- --- End of configuration ------------------------------------------------------------------------- - - --- Local variables -local gained , sessionxp, min, max -local name, standing, minrep, maxrep, value -local factions = {} -local flen = 0 - -local _, class = UnitClass("player") -local r, g, b = RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b - -local TEXTURE = [[Interface\AddOns\MicroExperience\textures\minimalist]] -local BACKDROP = { - bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], - insets = {top = -1, left = -1, bottom = -1, right = -1}, -} -local shadows = { - edgeFile = "Interface\\AddOns\\MicroExperience\\textures\\glowTex", - edgeSize = 4, - insets = { left = 3, right = 3, top = 3, bottom = 3 } -} - -local reaction = { - [1] = { r = 222/255, g = 95/255, b = 95/255 }, -- Hated - [2] = { r = 222/255, g = 95/255, b = 95/255 }, -- Hostile - [3] = { r = 222/255, g = 95/255, b = 95/255 }, -- Unfriendly - [4] = { r = 218/255, g = 197/255, b = 92/255 }, -- Neutral - [5] = { r = 75/255, g = 175/255, b = 76/255 }, -- Friendly - [6] = { r = 75/255, g = 175/255, b = 76/255 }, -- Honored - [7] = { r = 0/255, g = 112/255, b = 221/255 }, -- Revered - [8] = { r = 163/255, g = 53/255, b = 238/255 }, -- Exalted -} -local repstanding = { - [1] = "Hated", - [2] = "Hostile", - [3] = "Unfriendly", - [4] = "Neutral", - [5] = "Friendly", - [6] = "Honored", - [7] = "Revered", - [8] = "Exalted", -} - -local font = CreateFont("xpBarFont") -font:SetFontObject(GameFontHighlightSmall) -font:SetTextColor(r, g, b) - -local function truncate(value) - if(value > 9999) then - return string.format("|cffffffff%.0f|rk", value / 1e3) - else - return "|cffffffff"..value.."|r" - end -end - -local function OnEnter(self) - if UnitAffectingCombat("player") then return end -- don't display tooltip in combat - - -- Create the tooltip - -- GameTooltip:SetOwner(self, 'ANCHOR_NONE') - -- GameTooltip:SetPoint(ttanchorpoint, self, ttanchorframe, ttxoffset, ttyoffset) - GameTooltip_SetDefaultAnchor( GameTooltip, UIParent ) - GameTooltip:AddLine('Micro Experience', r, g, b) - GameTooltip:AddLine(' ') - - name, standing, minrep, maxrep, value = GetWatchedFactionInfo() - - -- Tooltip for tracking experience - if (name == nil) then - local min = UnitXP("player") - local max = UnitXPMax("player") - local retVal = GetXPExhaustion() - - -- Display basic experience information - GameTooltip:AddLine(format('Experience: %s / %s (%.1f%%)', truncate(min), truncate(max), min / max * 100)) - GameTooltip:AddLine(format('Remaining: %s (%.1f%%)', truncate(max-min), 100 - (min / max * 100))) - GameTooltip:AddLine(format('Bars: |cffffffff%.1f|r complete / |cffffffff%.1f|r remaining', min/(max/20), 20-(min/(max/20)))) - - if (retVal) then - GameTooltip:AddLine(format('|cff1369caRested: %s (|cffffffff%.1f|r%%)', truncate(retVal), retVal / max * 100)) - end - - -- Get completed quest experience - local questxp, completedquests = 0, 0 - local numEntries, numQuests = GetNumQuestLogEntries() - for i = 0, numQuests do - questLogTitleText, level, questTag, suggestedGroup, isHeader, isCollapsed, isComplete, isDaily, questID = GetQuestLogTitle(i) - SelectQuestLogEntry(i) - if (isComplete) then - questxp = questxp + GetQuestLogRewardXP() - completedquests = completedquests + 1 - end - end - - -- Display if the players quest log contains completed entries - if (questxp > 0) then - GameTooltip:AddLine(' ') - GameTooltip:AddLine(format('Quest Experience: |cffffffff%d|r (%d)', questxp, completedquests)) - if (min + questxp > max ) then - GameTooltip:AddLine(format('Remaining inc Quests: |cffffffff%s|r', truncate(max-(min + questxp)))) - else - GameTooltip:AddLine(format('Remaining inc Quests: |cffffffff%s (%.1f%%)|r', truncate(max-(min + questxp)), 100 - ((min + questxp) / max * 100))) - end - end - - -- Display session experience gains - if (sessionxp > 0) then - GameTooltip:AddLine(' ') - GameTooltip:AddLine(format('Last Gained: |cffffffff%.0f|r', gained)) - GameTooltip:AddLine(format('Total Gained: |cffffffff%.0f|r', sessionxp)) - end - - -- Tooltip for tracking reputation - else - maxrep = (maxrep-minrep) - minrep = (value-minrep) - - -- Display basic reputation information - GameTooltip:AddLine(format('Watched Faction: |cffffffff%s|r', name)) - GameTooltip:AddLine(format('Current Standing: |cFF%02x%02x%02x%s|r', reaction[standing].r*255, reaction[standing].g*255, reaction[standing].b*255, repstanding[standing])) - GameTooltip:AddLine(format('Value: |cffffffff%d|r / |cffffffff%d|r %.1f%%', minrep, maxrep, minrep/maxrep*100)) - - -- Display any reputation gains during the session - local header = false - for i = 1, GetNumFactions() do - name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild = GetFactionInfo(i) - - for key, value in pairs(factions) do - - if ( name == key ) then - if ( barValue ~= value and not header ) then - GameTooltip:AddLine(' ') - GameTooltip:AddLine('Session Info', r, g, b) - GameTooltip:AddLine(' ') - GameTooltip:AddLine(format('|cffffffff%s|r +%d', name, barValue - value)) - header = true - elseif ( barValue ~= value and header ) then - GameTooltip:AddLine(format('|cffffffff%s|r +%d', name, barValue - value)) - end - end - - end - - end - - end - - GameTooltip:Show() -end - -local function OnLeave(self) - GameTooltip:Hide() -end - ---[[ - Create Functions ---]] - -local function CreateInnerBorder(f) - if f.iborder then return end - f.iborder = CreateFrame("Frame", nil, f) - f.iborder:SetPoint("TOPLEFT", 1, -1) - f.iborder:SetPoint("BOTTOMRIGHT", -1, 1) - f.iborder:SetFrameLevel(f:GetFrameLevel()) - f.iborder:SetBackdrop({ - edgeFile = "Interface\\Buttons\\WHITE8x8", edgeSize = 1, - insets = { left = -1, right = -1, top = -1, bottom = -1} - }) - f.iborder:SetBackdropBorderColor(0, 0, 0) - return f.iborder -end - -local function CreateOuterBorder(f) - if f.oborder then return end - f.oborder = CreateFrame("Frame", nil, f) - f.oborder:SetPoint("TOPLEFT", -1, 1) - f.oborder:SetPoint("BOTTOMRIGHT", 1, -1) - f.oborder:SetFrameLevel(f:GetFrameLevel()) - f.oborder:SetBackdrop({ - edgeFile = "Interface\\Buttons\\WHITE8x8", edgeSize = 1, - insets = { left = -1, right = -1, top = -1, bottom = -1} - }) - f.oborder:SetBackdropBorderColor(0, 0, 0) - return f.oborder -end - -local function CreatePanel(f, w, h, a1, p, a2, x, y) - f:SetFrameLevel(1) - f:SetHeight(h) - f:SetWidth(w) - f:SetFrameStrata("BACKGROUND") - f:SetPoint(a1, p, a2, x, y) - f:SetBackdrop({ - bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], - edgeFile = "Interface\\Buttons\\WHITE8x8", - tile = false, tileSize = 0, edgeSize = 1, - insets = { left = -1, right = -1, top = -1, bottom = -1} - }) - f:SetBackdropColor(.1,.1,.1,1) - f:SetBackdropBorderColor(.3,.3,.3,1) - - CreateOuterBorder(f) - CreateInnerBorder(f) -end - -local function CreateShadow(f) - if f.shadow then return end - local shadow = CreateFrame("Frame", nil, f) - shadow:SetFrameLevel(1) - shadow:SetFrameStrata(f:GetFrameStrata()) - shadow:SetPoint("TOPLEFT", -4, 4) - shadow:SetPoint("BOTTOMRIGHT", 4, -4) - shadow:SetBackdrop(shadows) - shadow:SetBackdropColor(0, 0, 0, 0) - shadow:SetBackdropBorderColor(0, 0, 0, 1) - f.shadow = shadow - return shadow -end - --- Create the panel and bars -local xpbarp = CreateFrame("Frame", nil, UIParent) -CreatePanel(xpbarp, width, height, anchor, xoffset, yoffset) -CreateShadow(xpbarp) - -local xpbar = CreateFrame("statusbar", nil, UIParent) -xpbar:SetPoint("CENTER", xpbarp, "CENTER", 0, 0) -xpbar:SetWidth(width - 4) -xpbar:SetHeight(height - 4) -xpbar:SetStatusBarTexture(TEXTURE) -xpbar:SetStatusBarColor(r, g, b, 1) -xpbar:SetFrameLevel(2) -xpbar:EnableMouse() -xpbar:HookScript("OnLeave", OnLeave) -xpbar:HookScript("OnEnter", OnEnter) - -local rested = CreateFrame('StatusBar', nil, Experience) -rested:SetAllPoints(xpbar) -rested:SetStatusBarTexture(TEXTURE) -rested:SetStatusBarColor(r, g, b, 0.4) -rested:SetBackdrop(BACKDROP) -rested:SetBackdropColor(0.1, 0.1, 0.1) -rested:SetFrameLevel(1) - -bg = rested:CreateTexture(nil, "BACKGROUND") -bg:SetAllPoints(xpbar) -bg:SetVertexColor(0.3, 0.3, 0.3) - -local text = xpbar:CreateFontString(nil, "OVERLAY") -text:SetPoint("CENTER", xpbar, "CENTER", 0, 0) -text:SetFontObject(font) - ---[[ - Update Functions ---]] - -function xpbar:PLAYER_LOGIN() - gained = 0 - sessionxp = 0 - min = UnitXP("player") - max = UnitXPMax("player") - end - -function xpbar:PLAYER_XP_UPDATE() - - -- Prevent game loading errors - if (min == nil or max == nil) then - return - end - - -- Handle the counting of gained experience even after the player has levelled up - if ( UnitXP("player") >= min ) then - gained = UnitXP("player") - min - else - gained = UnitXP("player") + (max - min) - end - - sessionxp = sessionxp + gained - min = UnitXP("player") - max = UnitXPMax("player") - - -- Discover if a faction is curently being watched if so return nil - name, standing, minrep, maxrep, value = GetWatchedFactionInfo() - if (name ~= nil) then - return nil - end - - -- Set the xpbar colour and values - xpbar:SetStatusBarColor(r, g, b, 1) - xpbar:SetMinMaxValues(0, max) - xpbar:SetValue(min) - - -- If the player has just gained some experience display this on the main bar else just display current experience information - if (gained == 0) then - text:SetFormattedText("%s / %s |cffffffff%.1f|r%%", truncate(min), truncate(max), min/max*100) - else - text:SetFormattedText("%s / %s |cffffffff%.1f|r%% +|cffffffff%.0f|r", truncate(min), truncate(max), min/max*100, gained) - end - - -- Display rested bar if the player is rested - local retVal = GetXPExhaustion() - if (retVal) then - rested:SetMinMaxValues(0, max) - rested:SetValue(min + retVal) - rested:Show() - else - rested:Hide() - end - -end - -function xpbar:UPDATE_FACTION() - - -- This event fires before the reputation panel is loaded so if the panel isn't ready return nil - if ( GetNumFactions() == 0 ) then return nil end - - -- If the factions table hasn't been loaded load it to compare against during the session - if ( flen == 0 ) then - for i=1, GetNumFactions() do - name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild = GetFactionInfo(i) - if ( not isHeader ) then - factions[name] = barValue - end - end - for key, value in pairs(factions) do - flen = flen + 1 - end - end - - -- Discover if a faction is curently being watched if so PLAYER_XP_UPDATE() then return nil - name, standing, minrep, maxrep, value = GetWatchedFactionInfo() - if (name == nil) then - self:PLAYER_XP_UPDATE() - return nil - end - - maxrep = (maxrep-minrep) - minrep = (value-minrep) - - xpbar:SetStatusBarColor(reaction[standing].r, reaction[standing].g, reaction[standing].b) - xpbar:SetMinMaxValues(0, maxrep) - xpbar:SetValue(minrep) - rested:Hide() - - text:SetFormattedText("|cffffffff %s %.1f%%|r", name, minrep/maxrep*100) - -end - --- RegisterEvents -xpbar:SetScript("OnEvent", function(self, event, ...) self[event](self, event, ...); end) -xpbar:SetScript("OnEnter", OnEnter) -xpbar:SetScript("OnLeave", OnLeave) -xpbar:RegisterEvent("PLAYER_LOGIN") -xpbar:RegisterEvent("PLAYER_XP_UPDATE") -xpbar:RegisterEvent('UPDATE_FACTION') \ No newline at end of file diff --git a/MicroExperience.toc b/MicroExperience.toc deleted file mode 100644 index 6c2e0b5..0000000 --- a/MicroExperience.toc +++ /dev/null @@ -1,7 +0,0 @@ -## Interface: 60000 -## Title: MicroExperience -## Author: sáulhudson updated by Miziak -## Version: 40000.7 -## Notes: Simple, clean and lite exp and rep bar - -MicroExperience.lua \ No newline at end of file -- 1.7.9.5