39 - Add XP tooltip for Stats plugin
What does the provided patch do?
Adds a tooltip to the Stats plugin showing things like current rank, time to level, rest percentage
Please provide any additional information below.
Here are the patch files:
*** waaghbar/WaaaghBar_Stats/WaaaghBar_Stats.mod Sun Oct 26 13:52:56 2008
--- waaghbar_new/WaaaghBar_Stats/WaaaghBar_Stats.mod Oct 26 12:49:27 2008
***************
*** 17,21 ****
--- 17,24 ----
<CallFunction name="WaaaghBar.Stats.Initialize"; />
</OnInitialize>
+ <OnUpdate>
+ <CallFunction name="WaaaghBar.Stats.OnUpdate"; />
+ </OnUpdate>
</UiMod>
</ModuleFile>
*** waaghbar/WaaaghBar_Stats/WaaaghBar_Stats.lua Oct 26 13:52:56 2008
--- waaghbar_new/WaaaghBar_Stats/WaaaghBar_Stats.lua Oct 26 12:51:21 2008
***************
*** 1,4 ****
! local Stats = {}
function Stats.Initialize()
Stats.Waaagh = WaaaghBar.NewPlugin("WaaaghBarStats")
--- 1,8 ----
! local Stats = {
! XpSession = 0;
! LastXpGain = 0;
! timer = 0;
! }
function Stats.Initialize()
Stats.Waaagh = WaaaghBar.NewPlugin("WaaaghBarStats")
***************
*** 6,16 ****
Stats.Rnw = Stats.Waaagh:NewElement("Rnw" 190, L"Rnw", { r = 255, g = 255, b = 255 }, 00045)
-- Events
RegisterEventHandler(SystemData.Events.PLAYER_EXP_UPDATED "WaaaghBar.Stats.OnPlayerExperienceUpdated";)
RegisterEventHandler(SystemData.Events.PLAYER_RENOWN_UPDATED "WaaaghBar.Stats.OnPlayerRenownUpdated";)
Stats.OnPlayerRenownUpdated()
! Stats.OnPlayerExperienceUpdated()
end
function Stats.OnPlayerRenownUpdated()
--- 10,38 ----
Stats.Rnw = Stats.Waaagh:NewElement("Rnw" 190, L"Rnw", { r = 255, g = 255, b = 255 }, 00045)
-- Events
+ WindowRegisterCoreEventHandler(Stats.Waaagh.name, "OnMouseOver", "WaaaghBar.Stats.OnXpMouseOver";)
+
RegisterEventHandler(SystemData.Events.PLAYER_EXP_UPDATED "WaaaghBar.Stats.OnPlayerExperienceUpdated";)
RegisterEventHandler(SystemData.Events.PLAYER_RENOWN_UPDATED "WaaaghBar.Stats.OnPlayerRenownUpdated";)
+ RegisterEventHandler(SystemData.Events.WORLD_OBJ_XP_GAINED "WaaaghBar.Stats.OnWorldXpGained"; )
Stats.OnPlayerRenownUpdated()
! Stats.OnPlayerExperienceUpdated(0)
! end
!
! function Stats.OnUpdate(timePassed)
! Stats.timer = Stats.timer + timePassed;
! end
!
! function Stats.OnWorldXpGained(id,amount)
! d("OnWorldXpGained Added xp from "..id.." "..amount);
! Stats.XpSession = Stats.XpSession + amount;
! Stats.LastXpGain = amount;
! end
!
! function Stats.OnTimerReset()
! d("XpSession reset");
! Stats.XpSession = 0;
end
function Stats.OnPlayerRenownUpdated()
***************
*** 21,30 ****
end
function Stats.OnPlayerExperienceUpdated()
! local curExperienceEarned = GameData.Player.Experience.curXpEarned
! local curExperienceNeeded = GameData.Player.Experience.curXpNeeded
! local curExperiencePrcent = curExperienceEarned / curExperienceNeeded * 100
! Stats.Exp:SetText(towstring(string.format("%i / %i (%.2f%%)", curExperienceEarned, curExperienceNeeded, curExperiencePrcent)))
end
WaaaghBar.Stats = Stats
--- 43,133 ----
end
function Stats.OnPlayerExperienceUpdated()
! local curExperienceEarned = GameData.Player.Experience.curXpEarned
! local curExperienceNeeded = GameData.Player.Experience.curXpNeeded
! local curExperiencePrcent = curExperienceEarned / curExperienceNeeded * 100;
! Stats.Exp:SetText(towstring(string.format("%i / %i (%.2f%%)", curExperienceEarned, curExperienceNeeded, curExperiencePrcent)));
! end
!
! function Stats.OnXpMouseOver()
! local curExperienceEarned = GameData.Player.Experience.curXpEarned
! local curExperienceNeeded = GameData.Player.Experience.curXpNeeded
! local curExperienceEarnPrc = 0;
! local curExperienceLeft = curExperienceNeeded - curExperienceEarned;
! local curExperienceLeftPrc = 0;
! local curRestBonus = GameData.Player.Experience.restXp
! local curRestBonusPrc = 0;
!
!
! if (curExperienceNeeded > 0)
! then
! curExperienceEarnPrc = curExperienceEarned / curExperienceNeeded * 100;
! curExperienceLeftPrc = curExperienceLeft / curExperienceNeeded * 100;
! curRestBonusPrc = curRestBonus / curExperienceNeeded * 100;
! end
!
! local xpPerHour = 0;
! local timer = Stats.timer
!
! if (timer > 0)
! then
! xpPerHour = Stats.XpSession * 3600 / timer;
! end
!
! local timeToLevel = 0;
! local textToLevel = L"N/A";
!
! if (xpPerHour > 0)
! then
! timeToLevel = math.floor( (curExperienceNeeded - curExperienceEarned) / (xpPerHour / 3600));
! if (timeToLevel > 0 and timeToLevel < 360000)
! then
! local ltime, _, _ = TimeUtils.FormatClock(timeToLevel);
! textToLevel = ltime;
! end
! end
!
! Tooltips.CreateTextOnlyTooltip( WaaaghBar.Stats.Waaagh.name, nil);
! Tooltips.AnchorTooltip( Tooltips.ANCHOR_WINDOW_BOTTOM );
! for i = 1,9
! do
! Tooltips.SetTooltipColor( i, 1, 236, 124, 5 );
! end
! Tooltips.SetTooltipText( 1, 1, towstring(string.format("; Rank %d", GameData.Player.level
! Tooltips.SetTooltipText( 2, 1, L"Needed XP:");
! Tooltips.SetTooltipText( 2, 2, towstring(string.format("%10d";, curExperienceNeeded)));
! Tooltips.SetTooltipText( 3, 1, L"XP Gained:");
! Tooltips.SetTooltipText( 3, 2, towstring(string.format("%10d (%.2f%%)", curExperienceEarned, curExperienceEarnPrc)));
! Tooltips.SetTooltipText( 4, 1, L"XP Left:");
! Tooltips.SetTooltipText( 4, 2, towstring(string.format("%10d (%.2f%%)", curExperienceLeft, curExperienceLeftPrc)));
! Tooltips.SetTooltipText( 5, 1, L"XP/Hr:");
! Tooltips.SetTooltipText( 5, 2, towstring(string.format("%10d";, xpPerHour)));
! Tooltips.SetTooltipText( 6, 1, L"Time to Level:");
! Tooltips.SetTooltipText( 6, 2, L""..textToLevel);
!
! local pos = 7;
!
! if (curRestBonus > 0)
! then
! for i = 7,9
! do
! Tooltips.SetTooltipColor(i, 1, 128, 128, 255);
! end
! Tooltips.SetTooltipText( pos, 1, L"Rest Bonus XP:");
! Tooltips.SetTooltipText( pos, 2, towstring(string.format("%10d (%.2f%%)", curRestBonus, curRestBonusPrc)));
! pos = pos + 1;
! end
!
! if (Stats.LastXpGain > 0)
! then
! Tooltips.SetTooltipText( pos, 1, L"Last XP Gain:");
! Tooltips.SetTooltipText( pos, 2, towstring(string.format("%10d";, Stats.LastXpGain
! pos = pos + 1;
! local killsLeft = curExperienceLeft / Stats.LastXpGain
! Tooltips.SetTooltipText( pos, 1, L"Kills till Level:");
! Tooltips.SetTooltipText( pos, 2, towstring(string.format("%10d";, killsLeft)));
! end
! Tooltips.Finalize();
end
WaaaghBar.Stats = Stats
| User | When | Change |
|---|---|---|
| Aerthan | Sun, 26 Oct 2008 19:02:55 | Create |
Facts
- Last updated on
- 26 Oct 2008
- Reported on
- 26 Oct 2008
- Status
- New - Issue has not had initial review yet.
- Type
- Patch - Source code patch for review
- Priority
- Medium - Normal priority.