From 320e18b4f4ab54dbb647399fb65d27392525cdd4 Mon Sep 17 00:00:00 2001 From: Xruptor Date: Sun, 30 Sep 2012 15:37:39 -0400 Subject: [PATCH] -Added XP per Sec. -Added XP per Minute. -Added XP per Hour. -Added Time to Level. --- XanEXP.lua | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- XanEXP.toc | 2 +- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/XanEXP.lua b/XanEXP.lua index ab3dd9e..502d5b4 100644 --- a/XanEXP.lua +++ b/XanEXP.lua @@ -68,6 +68,36 @@ function xanEXP_SlashCommand(cmd) DEFAULT_CHAT_FRAME:AddMessage("/xanexp scale # - Set the scale of the xanEXP frame") end +local function FormatTime(sTime) + if type(sTime) == "number" and sTime > 0 then + local day = floor(sTime / 86400) + local hour = floor((sTime - (day * 86400)) / 3600) + local minute = floor((sTime - (day * 86400) - (hour * 3600)) / 60) + local second = floor(mod(sTime, 60)) + + if day < 0 then + return "Waiting..." + else + local sString = "" + if day > 0 then + sString = day .. "d " + end + if hour > 0 or sString ~= "" then + sString = sString .. hour .. "h " + end + if minute > 0 or sString ~= "" then + sString = sString .. minute .. "m " + end + if second > 0 or sString ~= "" then + sString = sString .. second .. "s" + end + return sString + end + else + return "Waiting..." + end +end + function f:CreateEXP_Frame() f:SetWidth(61) @@ -137,11 +167,26 @@ function f:CreateEXP_Frame() local remainXP = maxXP - (cur + restXP) local toLevelXPPercent = math.floor((maxXP - cur) / maxXP * 100) + local sessionTime = GetTime() - starttime + local xpGainedSession = (cur - start) + local xpPerSecond = xpGainedSession / sessionTime + local xpPerMinute = ceil(xpPerSecond * 60) + local xpPerHour = ceil(xpPerSecond * 3600) + local timeToLevel + if xpPerSecond <= 0 then + timeToLevel = "None" + else + timeToLevel = (maxXP - cur) / xpPerSecond + end GameTooltip:AddDoubleLine("EXP:", cur.."/"..max, nil,nil,nil, 1,1,1) GameTooltip:AddDoubleLine("Rest:", string.format("%d%%", (GetXPExhaustion() or 0)/max*100), nil,nil,nil, 1,1,1) GameTooltip:AddDoubleLine("TNL:", maxXP-cur..(" ("..toLevelXPPercent.."%)"), nil,nil,nil, 1,1,1) - GameTooltip:AddLine(string.format("%.1f hours played this session", (GetTime()-starttime)/3600), 1,1,1) - GameTooltip:AddLine((cur - start).." EXP gained this session", 1,1,1) + GameTooltip:AddDoubleLine("XP/Sec:", xpPerSecond, nil,nil,nil, 1,1,1) + GameTooltip:AddDoubleLine("XP/Minute:", xpPerMinute, nil,nil,nil, 1,1,1) + GameTooltip:AddDoubleLine("XP/Hour:", xpPerHour, nil,nil,nil, 1,1,1) + GameTooltip:AddDoubleLine("Time To Level:", FormatTime(timeToLevel), nil,nil,nil, 1,1,1) + GameTooltip:AddLine(string.format("%.1f hours played this session", sessionTime/3600), 1,1,1) + GameTooltip:AddLine(xpGainedSession.." EXP gained this session", 1,1,1) GameTooltip:AddLine(string.format("%.1f levels gained this session", UnitLevel("player") + cur/max - startlevel), 1,1,1) GameTooltip:Show() diff --git a/XanEXP.toc b/XanEXP.toc index 02c1c7a..4944e57 100644 --- a/XanEXP.toc +++ b/XanEXP.toc @@ -2,7 +2,7 @@ ## Title: xanEXP ## Notes: A small window display current xp and other xp information ## Author: Xruptor -## Version: 2.4 +## Version: 2.5 ## SavedVariablesPerCharacter: XanEXP_DB xanEXP.lua -- 1.7.9.5