changeset 17:edb74cf488c4 beta-0.51

added party stat & fix small bug
author ShadowTheAge
date Fri, 13 Mar 2015 00:03:42 +0300
parents cb06c075c0d7
children 2de6ed94effb
files CrossRealmAssist.lua
diffstat 1 files changed, 19 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/CrossRealmAssist.lua	Thu Mar 12 23:08:30 2015 +0300
+++ b/CrossRealmAssist.lua	Fri Mar 13 00:03:42 2015 +0300
@@ -11,7 +11,7 @@
 local hintShown
 
 local tabs = {}
-local curRealmStat
+local curRealmStat, curPartyStat
 local scanstate=0
 local recentRealms={}
 local recentgroups={}
@@ -389,6 +389,7 @@
     scanstate = 0
     lfgScanInProgress = false
     addon:UnregisterEvent("ZONE_CHANGED_NEW_AREA")
+    addon:UnregisterEvent("SCENARIO_UPDATE")
     addon:UnregisterEvent("PLAYER_REGEN_ENABLED")
     addon:UnregisterEvent("LFG_LIST_SEARCH_RESULTS_RECEIVED")
     addon:UnregisterEvent("LFG_LIST_SEARCH_RESULT_UPDATED")
@@ -577,16 +578,16 @@
 end
 
 function addon:updatePartyInfo()
-    local realms = {}
+    curPartyStat = {}
     local inGroup = IsInGroup()
     if inGroup then
         if IsInRaid() then
             for i=1, MAX_RAID_MEMBERS do
-                addon:AddUnitIdStat("raid"..i, realms)
+                addon:AddUnitIdStat("raid"..i, curPartyStat)
             end
         else
             for i=1, MAX_PARTY_MEMBERS do
-                addon:AddUnitIdStat("party"..i, realms)
+                addon:AddUnitIdStat("party"..i, curPartyStat)
             end
         end
     end
@@ -731,7 +732,20 @@
 
 local LeaveGroup = {
     func = LeaveParty;
-    tooltip = "Leave current joined group",
+    tooltip = function(self)
+        local partyStat = addon:GetRealmStat(curPartyStat)
+        GameTooltip:AddLine("Players in party "..partyStat.players)
+        local max = partyStat.max;
+        for i=1,#partyStat do
+            local data = partyStat[i]
+            local percent = math.ceil(100 * data.count / partyStat.players - 0.5) .. "%";
+            local pmax = data.count/max;
+            local green = 0.5 + pmax * 0.5;
+            local gray = 0.5 * (1-pmax)
+            GameTooltip:AddDoubleLine(data.realm, percent, gray,green,gray,gray,green,gray)
+        end
+        GameTooltip:AddLine("Click to leave party",1,0.5,0)
+    end,
     text = "Leave group"
 }