comparison CensusPlus.lua @ 6:10c85be19b56

rebase on CensusPlus-40000-4.3.2.zip; added worgen added 81 - 85
author EmFor
date Fri, 10 Dec 2010 15:47:23 +0100
parents edfa01041183
children 663f782bd903
comparison
equal deleted inserted replaced
5:39067cee234d 6:10c85be19b56
31 ---------------------------------------------------------------------------------- 31 ----------------------------------------------------------------------------------
32 -- 32 --
33 -- EURO vs US localization problem workaround for common server names 33 -- EURO vs US localization problem workaround for common server names
34 -- 34 --
35 --------------------------------------------------------------------------------- 35 ---------------------------------------------------------------------------------
36 local g_InterfaceVersion = 30000; 36 local g_InterfaceVersion = 40000;
37 g_CensusPlusLocale = "N/A"; -- Must read either US or EU 37 g_CensusPlusLocale = "N/A"; -- Must read either US or EU
38 g_CensusPlusTZOffset = -999; 38 g_CensusPlusTZOffset = -999;
39 local g_LocaleSet = false; 39 local g_LocaleSet = false;
40 local g_TZWarningSent = false; 40 local g_TZWarningSent = false;
41 41
42 42
43 ---------------------------------------------------------------------------------- 43 ----------------------------------------------------------------------------------
44 -- 44 --
45 -- Constants 45 -- Constants
46 --rm 46 --rm
47 local CensusPlus_MYGUILD = "The Last Journey"; -- Special guild to search 47 -- Special guild to search
48 --local CensusPlus_MYGUILD = "The Last Journey";
49 local CensusPlus_MYGUILD = "Worgengrauen";
48 --------------------------------------------------------------------------------- 50 ---------------------------------------------------------------------------------
49 local CensusPlus_VERSION = "4.2.2"; -- version 51 local CensusPlus_VERSION = "4.3.2"; -- version
50 local CensusPlus_MAXBARHEIGHT = 128; -- Length of blue bars 52 local CensusPlus_MAXBARHEIGHT = 128; -- Length of blue bars
51 local CensusPlus_NUMGUILDBUTTONS = 10; -- How many guild buttons are on the UI? 53 local CensusPlus_NUMGUILDBUTTONS = 10; -- How many guild buttons are on the UI?
52 local MAX_CHARACTER_LEVEL = 80; -- Maximum level a PC can attain 54 local MAX_CHARACTER_LEVEL = 85; -- Maximum level a PC can attain
53 --rm 55 --rm
54 local MAX_LEVEL_DISPLAY = 255; -- Maximum level a PC can attain 56 local MAX_LEVEL_DISPLAY = 255; -- Maximum level a PC can attain
55 local MAX_WHO_RESULTS = 45; -- Maximum number of who results the server will return 57 local MAX_WHO_RESULTS = 48; -- Maximum number of who results the server will return
56 CensusPlus_GUILDBUTTONSIZEY = 16; 58 CensusPlus_GUILDBUTTONSIZEY = 16;
57 local CensusPlus_UPDATEDELAY = 5; -- Delay time between /who messages 59 local CensusPlus_UPDATEDELAY = 5; -- Delay time between /who messages
58 local CP_MAX_TIMES = 50; 60 local CP_MAX_TIMES = 50;
59 61
60 local g_ServerPrefix = ""; -- US VERSION!! 62 local g_ServerPrefix = ""; -- US VERSION!!
201 g_RaceClassList[CENSUSPlus_TAUREN] = 25; 203 g_RaceClassList[CENSUSPlus_TAUREN] = 25;
202 g_RaceClassList[CENSUSPlus_TROLL] = 26; 204 g_RaceClassList[CENSUSPlus_TROLL] = 26;
203 g_RaceClassList[CENSUSPlus_UNDEAD] = 27; 205 g_RaceClassList[CENSUSPlus_UNDEAD] = 27;
204 g_RaceClassList[CENSUSPlus_DRAENEI] = 28; 206 g_RaceClassList[CENSUSPlus_DRAENEI] = 28;
205 g_RaceClassList[CENSUSPlus_BLOODELF] = 29; 207 g_RaceClassList[CENSUSPlus_BLOODELF] = 29;
208 g_RaceClassList[CENSUSPlus_WORGEN] = 31;
209 g_RaceClassList[CENSUSPlus_GOBLIN] = 32;
206 210
207 g_TimeDatabase[CENSUSPlus_DRUID] = 0; 211 g_TimeDatabase[CENSUSPlus_DRUID] = 0;
208 g_TimeDatabase[CENSUSPlus_HUNTER] = 0; 212 g_TimeDatabase[CENSUSPlus_HUNTER] = 0;
209 g_TimeDatabase[CENSUSPlus_MAGE] = 0; 213 g_TimeDatabase[CENSUSPlus_MAGE] = 0;
210 g_TimeDatabase[CENSUSPlus_PRIEST] = 0; 214 g_TimeDatabase[CENSUSPlus_PRIEST] = 0;
227 g_FactionCheck[CENSUSPlus_ORC] = CENSUSPlus_HORDE; 231 g_FactionCheck[CENSUSPlus_ORC] = CENSUSPlus_HORDE;
228 g_FactionCheck[CENSUSPlus_TAUREN] = CENSUSPlus_HORDE; 232 g_FactionCheck[CENSUSPlus_TAUREN] = CENSUSPlus_HORDE;
229 g_FactionCheck[CENSUSPlus_TROLL] = CENSUSPlus_HORDE; 233 g_FactionCheck[CENSUSPlus_TROLL] = CENSUSPlus_HORDE;
230 g_FactionCheck[CENSUSPlus_UNDEAD] = CENSUSPlus_HORDE; 234 g_FactionCheck[CENSUSPlus_UNDEAD] = CENSUSPlus_HORDE;
231 g_FactionCheck[CENSUSPlus_BLOODELF] = CENSUSPlus_HORDE; 235 g_FactionCheck[CENSUSPlus_BLOODELF] = CENSUSPlus_HORDE;
236 g_FactionCheck[CENSUSPlus_GOBLIN] = CENSUSPlus_HORDE;
232 237
233 g_FactionCheck[CENSUSPlus_DWARF] = CENSUSPlus_ALLIANCE; 238 g_FactionCheck[CENSUSPlus_DWARF] = CENSUSPlus_ALLIANCE;
234 g_FactionCheck[CENSUSPlus_GNOME] = CENSUSPlus_ALLIANCE; 239 g_FactionCheck[CENSUSPlus_GNOME] = CENSUSPlus_ALLIANCE;
235 g_FactionCheck[CENSUSPlus_HUMAN] = CENSUSPlus_ALLIANCE; 240 g_FactionCheck[CENSUSPlus_HUMAN] = CENSUSPlus_ALLIANCE;
236 g_FactionCheck[CENSUSPlus_NIGHTELF] = CENSUSPlus_ALLIANCE; 241 g_FactionCheck[CENSUSPlus_NIGHTELF] = CENSUSPlus_ALLIANCE;
237 g_FactionCheck[CENSUSPlus_DRAENEI] = CENSUSPlus_ALLIANCE; 242 g_FactionCheck[CENSUSPlus_DRAENEI] = CENSUSPlus_ALLIANCE;
243 g_FactionCheck[CENSUSPlus_WORGEN] = CENSUSPlus_ALLIANCE;
238 local g_ReturnedZero = false; 244 local g_ReturnedZero = false;
239 245
240 do 246 do
241 -- HACK 247 -- HACK
242 --[[ 248 --[[
243 seeing as Blizzard improperly coded GuildControlPopupFrame_OnEvent to mess up when GUILD_ROSTER_EVENT is dispatched, 249 seeing as Blizzard improperly coded GuildControlPopupFrame_OnEvent to mess up when GUILD_ROSTER_EVENT is dispatched,
244 and there is no real harm in removing the handler entirely, that's what's happening. If and when Blizzard decides to fix it, this should be removed. 250 and there is no real harm in removing the handler entirely, that's what's happening. If and when Blizzard decides to fix it, this should be removed.
245 Thanks to ckknight of wowace for this 251 Thanks to ckknight of wowace for this
246 ]] 252 ]]
247 GuildControlPopupFrame:SetScript("OnEvent", nil) 253 -- GuildControlPopupFrame:SetScript("OnEvent", nil)
248 end 254 end
249 255
250 256
251 ---------------------------------------------------------------------------------- 257 ----------------------------------------------------------------------------------
252 -- 258 --
418 -- 424 --
419 ----------------------------------------------------------------------------------- 425 -----------------------------------------------------------------------------------
420 function CensusPlus_GetFactionRaces(faction) 426 function CensusPlus_GetFactionRaces(faction)
421 local ret = {}; 427 local ret = {};
422 if (faction == CENSUSPlus_HORDE) then 428 if (faction == CENSUSPlus_HORDE) then
423 ret = {CENSUSPlus_ORC, CENSUSPlus_TAUREN, CENSUSPlus_TROLL, CENSUSPlus_UNDEAD, CENSUSPlus_BLOODELF}; 429 ret = {CENSUSPlus_ORC, CENSUSPlus_TAUREN, CENSUSPlus_TROLL, CENSUSPlus_UNDEAD, CENSUSPlus_BLOODELF, CENSUSPlus_GOBLIN};
424 elseif (faction == CENSUSPlus_ALLIANCE) then 430 elseif (faction == CENSUSPlus_ALLIANCE) then
425 ret = {CENSUSPlus_DWARF, CENSUSPlus_GNOME, CENSUSPlus_HUMAN, CENSUSPlus_NIGHTELF, CENSUSPlus_DRAENEI}; 431 ret = {CENSUSPlus_DWARF, CENSUSPlus_GNOME, CENSUSPlus_HUMAN, CENSUSPlus_NIGHTELF, CENSUSPlus_DRAENEI, CENSUSPlus_WORGEN};
426 end 432 end
427 return ret; 433 return ret;
428 end 434 end
429 435
430 ----------------------------------------------------------------------------------- 436 -----------------------------------------------------------------------------------
448 -- 454 --
449 ----------------------------------------------------------------------------------- 455 -----------------------------------------------------------------------------------
450 local function GetRaceClasses(race) 456 local function GetRaceClasses(race)
451 local ret = {}; 457 local ret = {};
452 if (race == CENSUSPlus_ORC) then 458 if (race == CENSUSPlus_ORC) then
453 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_SHAMAN, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT}; 459 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_MAGE, CENSUSPlus_SHAMAN, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT};
454 elseif (race == CENSUSPlus_TAUREN) then 460 elseif (race == CENSUSPlus_TAUREN) then
455 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_SHAMAN, CENSUSPlus_DRUID, CENSUSPlus_DEATHKNIGHT}; 461 ret = {CENSUSPlus_PALADIN, CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_SHAMAN, CENSUSPlus_PRIEST, CENSUSPlus_DRUID, CENSUSPlus_DEATHKNIGHT};
456 elseif (race == CENSUSPlus_TROLL) then 462 elseif (race == CENSUSPlus_TROLL) then
457 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_SHAMAN, CENSUSPlus_MAGE, CENSUSPlus_DEATHKNIGHT}; 463 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_SHAMAN, CENSUSPlus_MAGE, CENSUSPlus_DRUID, CENSUSPlus_DEATHKNIGHT};
458 elseif (race == CENSUSPlus_UNDEAD) then 464 elseif (race == CENSUSPlus_UNDEAD) then
459 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT}; 465 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT};
460 elseif (race == CENSUSPlus_DWARF) then 466 elseif (race == CENSUSPlus_DWARF) then
461 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_DEATHKNIGHT}; 467 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_SHAMAN, CENSUSPlus_DEATHKNIGHT};
462 elseif (race == CENSUSPlus_GNOME) then 468 elseif (race == CENSUSPlus_GNOME) then
463 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_ROGUE, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT}; 469 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_ROGUE, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT};
464 elseif (race == CENSUSPlus_HUMAN) then 470 elseif (race == CENSUSPlus_HUMAN) then
465 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT}; 471 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_PALADIN, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT};
466 elseif (race == CENSUSPlus_NIGHTELF) then 472 elseif (race == CENSUSPlus_NIGHTELF) then
467 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_DRUID, CENSUSPlus_DEATHKNIGHT}; 473 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_MAGE, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_DRUID, CENSUSPlus_DEATHKNIGHT};
468 elseif (race == CENSUSPlus_BLOODELF) then 474 elseif (race == CENSUSPlus_BLOODELF) then
469 ret = {CENSUSPlus_PALADIN, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT}; 475 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT};
470 elseif (race == CENSUSPlus_DRAENEI) then 476 elseif (race == CENSUSPlus_DRAENEI) then
471 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_HUNTER, CENSUSPlus_PRIEST, CENSUSPlus_SHAMAN, CENSUSPlus_MAGE, CENSUSPlus_DEATHKNIGHT}; 477 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_HUNTER, CENSUSPlus_PRIEST, CENSUSPlus_SHAMAN, CENSUSPlus_MAGE, CENSUSPlus_DEATHKNIGHT};
478 elseif (race == CENSUSPlus_WORGEN) then
479 ret = {CENSUSPlus_DEATHKNIGHT, CENSUSPlus_DRUID, CENSUSPlus_HUNTER, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_ROGUE, CENSUSPlus_WARLOCK, CENSUSPlus_WARRIOR};
480 elseif (race == CENSUSPlus_GOBLIN) then
481 ret = {CENSUSPlus_DEATHKNIGHT, CENSUSPlus_HUNTER, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_ROGUE, CENSUSPlus_SHAMAN, CENSUSPlus_WARLOCK, CENSUSPlus_WARRIOR};
472 end 482 end
473 return ret; 483 return ret;
474 end 484 end
475 485
476 ----------------------------------------------------------------------------------- 486 -----------------------------------------------------------------------------------
563 ----------------------------------------------------------------------------------- 573 -----------------------------------------------------------------------------------
564 -- 574 --
565 -- Called once on load 575 -- Called once on load
566 -- 576 --
567 ----------------------------------------------------------------------------------- 577 -----------------------------------------------------------------------------------
568 function CensusPlus_OnLoad() 578 function CensusPlus_OnLoad( this )
569 -- 579 --
570 -- Update the version number 580 -- Update the version number
571 -- 581 --
572 CensusPlusText:SetText("Census+ EmSpe\195\167ial v"..CensusPlus_VERSION .. " " .. g_CensusPlusLocale ); 582 CensusPlusText:SetText("Census+ EmSpe\195\167ial v"..CensusPlus_VERSION .. " " .. g_CensusPlusLocale );
573 CensusPlusText2:SetText( CENSUSPlus_UPLOAD ); 583 CensusPlusText2:SetText( CENSUSPlus_UPLOAD );
643 local updateFrame = CreateFrame("Frame"); 653 local updateFrame = CreateFrame("Frame");
644 updateFrame:SetScript("OnUpdate", CensusPlus_OnUpdate); 654 updateFrame:SetScript("OnUpdate", CensusPlus_OnUpdate);
645 CensusPlusTakeGuildButton:SetText( CENSUSPlus_TAKEGUILD.." \""..CensusPlus_MYGUILD.."\"" ); 655 CensusPlusTakeGuildButton:SetText( CENSUSPlus_TAKEGUILD.." \""..CensusPlus_MYGUILD.."\"" );
646 end 656 end
647 657
648 function CensusPlus_FriendsFrame_OnEvent(...) 658 function CensusPlus_FriendsFrame_OnEvent(self, event, ...)
649 659
650 -- CensusPlus_Msg( "CP_FF_OE Message =>" .. event ); 660 -- CensusPlus_Msg( "CP_FF_OE Message =>" .. event );
651 661
652 if(wholib == nil and 662 if(wholib == nil and
653 event == "WHO_LIST_UPDATE" and g_IsCensusPlusInProgress and g_WaitingForWhoUpdate ) then 663 event == "WHO_LIST_UPDATE" and g_IsCensusPlusInProgress and g_WaitingForWhoUpdate ) then
664 -- g_Pre_WhoList_UpdateOverride(); 674 -- g_Pre_WhoList_UpdateOverride();
665 675
666 676
667 g_WaitingForWhoUpdate = false; 677 g_WaitingForWhoUpdate = false;
668 CP_Pre_OnEvent(...); 678 CP_Pre_OnEvent(...);
679
669 -- 680 --
670 -- If we opened the who window, do a manual pause and open a dialog 681 -- If we opened the who window, do a manual pause and open a dialog
671 -- 682 --
672 g_CensusPlusManuallyPaused = true; 683 g_CensusPlusManuallyPaused = true;
673 CensusPlusTakeButton:SetText( CENSUSPlus_UNPAUSE ); 684 CensusPlusTakeButton:SetText( CENSUSPlus_UNPAUSE );
695 706
696 return; 707 return;
697 708
698 end 709 end
699 710
700 CP_Pre_OnEvent(...); 711 CP_Pre_OnEvent(self, event, ...);
701 712
702 end 713 end
703 714
704 function CP_ProcessWhoEvent(query, ...) 715 function CP_ProcessWhoEvent(query, ...)
705 local numWhoResults = GetNumWhoResults(); 716 local numWhoResults = GetNumWhoResults();
1178 ----------------------------------------------------------------------------------- 1189 -----------------------------------------------------------------------------------
1179 -- 1190 --
1180 -- Display a tooltip for the take button 1191 -- Display a tooltip for the take button
1181 -- 1192 --
1182 ----------------------------------------------------------------------------------- 1193 -----------------------------------------------------------------------------------
1183 function CensusPlus_Take_OnEnter() 1194 function CensusPlus_Take_OnEnter( this )
1184 if (g_IsCensusPlusInProgress) then 1195 if (g_IsCensusPlusInProgress) then
1185 if (g_CensusPlusManuallyPaused) then 1196 if (g_CensusPlusManuallyPaused) then
1186 GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); 1197 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
1187 GameTooltip:SetText(CENSUSPlus_UNPAUSECENSUS, 1.0, 1.0, 1.0); 1198 GameTooltip:SetText(CENSUSPlus_UNPAUSECENSUS, 1.0, 1.0, 1.0);
1188 GameTooltip:Show(); 1199 GameTooltip:Show();
1200 1211
1201 --rm 1212 --rm
1202 ----------------------------------------------------------------------------------- 1213 -----------------------------------------------------------------------------------
1203 -- Display a tooltip for the take guild button 1214 -- Display a tooltip for the take guild button
1204 ----------------------------------------------------------------------------------- 1215 -----------------------------------------------------------------------------------
1205 function CensusPlus_TakeGuild_OnEnter() 1216 function CensusPlus_TakeGuild_OnEnter( this )
1206 if (g_IsCensusPlusInProgress) then 1217 if (g_IsCensusPlusInProgress) then
1207 if (g_CensusPlusManuallyPaused) then 1218 if (g_CensusPlusManuallyPaused) then
1208 GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); 1219 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
1209 GameTooltip:SetText(CENSUSPlus_UNPAUSECENSUS, 1.0, 1.0, 1.0); 1220 GameTooltip:SetText(CENSUSPlus_UNPAUSECENSUS, 1.0, 1.0, 1.0);
1210 GameTooltip:Show(); 1221 GameTooltip:Show();
3128 ---------------------------------------------------------------------------------- 3139 ----------------------------------------------------------------------------------
3129 -- 3140 --
3130 -- Race legend clicked 3141 -- Race legend clicked
3131 -- 3142 --
3132 --------------------------------------------------------------------------------- 3143 ---------------------------------------------------------------------------------
3133 function CensusPlus_OnClickRace() 3144 function CensusPlus_OnClickRace( this )
3134 local id = this:GetID(); 3145 local id = this:GetID();
3135 if (id == g_RaceSelected) then 3146 if (id == g_RaceSelected) then
3136 g_RaceSelected = 0; 3147 g_RaceSelected = 0;
3137 else 3148 else
3138 g_RaceSelected = id; 3149 g_RaceSelected = id;
3143 ---------------------------------------------------------------------------------- 3154 ----------------------------------------------------------------------------------
3144 -- 3155 --
3145 -- Class legend clicked 3156 -- Class legend clicked
3146 -- 3157 --
3147 --------------------------------------------------------------------------------- 3158 ---------------------------------------------------------------------------------
3148 function CensusPlus_OnClickClass() 3159 function CensusPlus_OnClickClass( this )
3149 local id = this:GetID(); 3160 local id = this:GetID();
3150 if (id == g_ClassSelected) then 3161 if (id == g_ClassSelected) then
3151 g_ClassSelected = 0; 3162 g_ClassSelected = 0;
3152 else 3163 else
3153 g_ClassSelected = id; 3164 g_ClassSelected = id;
3159 ---------------------------------------------------------------------------------- 3170 ----------------------------------------------------------------------------------
3160 -- 3171 --
3161 -- Level bar loaded 3172 -- Level bar loaded
3162 -- 3173 --
3163 --------------------------------------------------------------------------------- 3174 ---------------------------------------------------------------------------------
3164 function CensusPlus_OnLoadLevel() 3175 function CensusPlus_OnLoadLevel( self )
3165 this:RegisterForClicks("LeftButtonUp","RightButtonUp"); 3176 self:RegisterForClicks("LeftButtonUp","RightButtonUp");
3166 end 3177 end
3167 3178
3168 ---------------------------------------------------------------------------------- 3179 ----------------------------------------------------------------------------------
3169 -- 3180 --
3170 -- Level bar clicked 3181 -- Level bar clicked
3171 -- 3182 --
3172 --------------------------------------------------------------------------------- 3183 ---------------------------------------------------------------------------------
3173 function CensusPlus_OnClickLevel(button) 3184 function CensusPlus_OnClickLevel(this, button)
3174 local id = this:GetID(); 3185 local id = this:GetID();
3175 if (((button == "LeftButton") and (id == g_LevelSelected)) or ((button == "RightButton") and (id + g_LevelSelected == 0))) then 3186 if (((button == "LeftButton") and (id == g_LevelSelected)) or ((button == "RightButton") and (id + g_LevelSelected == 0))) then
3176 g_LevelSelected = 0; 3187 g_LevelSelected = 0;
3177 elseif (button == "RightButton") then 3188 elseif (button == "RightButton") then
3178 g_LevelSelected = 0 - id; 3189 g_LevelSelected = 0 - id;
3185 ---------------------------------------------------------------------------------- 3196 ----------------------------------------------------------------------------------
3186 -- 3197 --
3187 -- Race tooltip 3198 -- Race tooltip
3188 -- 3199 --
3189 --------------------------------------------------------------------------------- 3200 ---------------------------------------------------------------------------------
3190 function CensusPlus_OnEnterRace() 3201 function CensusPlus_OnEnterRace( this )
3191 local factionGroup = UnitFactionGroup("player"); 3202 local factionGroup = UnitFactionGroup("player");
3192 local thisFactionRaces = CensusPlus_GetFactionRaces(factionGroup); 3203 local thisFactionRaces = CensusPlus_GetFactionRaces(factionGroup);
3193 local id = this:GetID(); 3204 local id = this:GetID();
3194 local raceName = thisFactionRaces[id]; 3205 local raceName = thisFactionRaces[id];
3195 local count = g_RaceCount[id]; 3206 local count = g_RaceCount[id];
3204 ---------------------------------------------------------------------------------- 3215 ----------------------------------------------------------------------------------
3205 -- 3216 --
3206 -- Class tooltip 3217 -- Class tooltip
3207 -- 3218 --
3208 --------------------------------------------------------------------------------- 3219 ---------------------------------------------------------------------------------
3209 function CensusPlus_OnEnterClass() 3220 function CensusPlus_OnEnterClass( self )
3210 local factionGroup = UnitFactionGroup("player"); 3221 local factionGroup = UnitFactionGroup("player");
3211 local thisFactionClasses = CensusPlus_GetFactionClasses(factionGroup); 3222 local thisFactionClasses = CensusPlus_GetFactionClasses(factionGroup);
3212 local id = this:GetID(); 3223 local id = self:GetID();
3213 local className = thisFactionClasses[id]; 3224 local className = thisFactionClasses[id];
3214 local count = g_ClassCount[id]; 3225 local count = g_ClassCount[id];
3215 if (count ~= nil) then 3226 if (count ~= nil) then
3216 local percent = floor((count / g_TotalCount) * 100); 3227 local percent = floor((count / g_TotalCount) * 100);
3217 GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); 3228 GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
3218 GameTooltip:SetText(className.."\n"..count.."\n"..percent.."%", 1.0, 1.0, 1.0); 3229 GameTooltip:SetText(className.."\n"..count.."\n"..percent.."%", 1.0, 1.0, 1.0);
3219 GameTooltip:Show(); 3230 GameTooltip:Show();
3220 end 3231 end
3221 end 3232 end
3222 3233
3223 ---------------------------------------------------------------------------------- 3234 ----------------------------------------------------------------------------------
3224 -- 3235 --
3225 -- Level tooltip 3236 -- Level tooltip
3226 -- 3237 --
3227 --------------------------------------------------------------------------------- 3238 ---------------------------------------------------------------------------------
3228 function CensusPlus_OnEnterLevel() 3239 function CensusPlus_OnEnterLevel( this )
3229 local id = this:GetID(); 3240 local id = this:GetID();
3230 local count = g_LevelCount[id]; 3241 local count = g_LevelCount[id];
3231 if (count ~= nil) then 3242 if (count ~= nil) then
3232 local percent = floor(count * 100 / g_TotalCount); 3243 local percent = floor((count / g_TotalCount) * 100);
3233 GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); 3244 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
3234 GameTooltip:SetText("Level "..id.."\n"..count.."\n"..percent.."%", 1.0, 1.0, 1.0); 3245 GameTooltip:SetText("Level "..id.."\n"..count.."\n"..percent.."%", 1.0, 1.0, 1.0);
3235 GameTooltip:Show(); 3246 GameTooltip:Show();
3236 end 3247 end
3237 end 3248 end
3239 ---------------------------------------------------------------------------------- 3250 ----------------------------------------------------------------------------------
3240 -- 3251 --
3241 -- Clicked a guild button 3252 -- Clicked a guild button
3242 -- 3253 --
3243 --------------------------------------------------------------------------------- 3254 ---------------------------------------------------------------------------------
3244 function CensusPlus_GuildButton_OnClick() 3255 function CensusPlus_GuildButton_OnClick( this )
3245 local id = this:GetID(); 3256 local id = this:GetID();
3246 local offset = FauxScrollFrame_GetOffset(CensusPlusGuildScrollFrame); 3257 local offset = FauxScrollFrame_GetOffset(CensusPlusGuildScrollFrame);
3247 local newSelection = id + offset; 3258 local newSelection = id + offset;
3248 local guildKey = CensusPlus_Guilds[newSelection].m_Name; 3259 local guildKey = CensusPlus_Guilds[newSelection].m_Name;
3249 if (g_GuildSelected ~= guildKey) then 3260 if (g_GuildSelected ~= guildKey) then
3938 local name, lineid = strsplit(":", namelink); 3949 local name, lineid = strsplit(":", namelink);
3939 if ( name and (strlen(name) > 0) ) then 3950 if ( name and (strlen(name) > 0) ) then
3940 name = gsub(name, "([^%s]*)%s+([^%s]*)%s+([^%s]*)", "%3"); 3951 name = gsub(name, "([^%s]*)%s+([^%s]*)%s+([^%s]*)", "%3");
3941 name = gsub(name, "([^%s]*)%s+([^%s]*)", "%2"); 3952 name = gsub(name, "([^%s]*)%s+([^%s]*)", "%2");
3942 if ( IsShiftKeyDown() ) then 3953 if ( IsShiftKeyDown() ) then
3943 if ( not ChatFrameEditBox:IsVisible() ) then 3954 if ( not ChatFrame1EditBox:IsVisible() ) then
3944 -- 3955 --
3945 -- This is the part we need to snag 3956 -- This is the part we need to snag
3946 -- 3957 --
3947 3958
3948 -- 3959 --
4006 wholib:AskWho({query = msg, queue = wholib.WHOLIB_QUEUE_QUIET, callback = CP_ProcessWhoEvent }) 4017 wholib:AskWho({query = msg, queue = wholib.WHOLIB_QUEUE_QUIET, callback = CP_ProcessWhoEvent })
4007 else 4018 else
4008 SendWho( msg ); 4019 SendWho( msg );
4009 end 4020 end
4010 end 4021 end
4022
4023 function CensusPlus_Options_OnMouseUp(self,...)
4024 CensusPlus_Msg('Mouse up');
4025
4026 if ( self.isMoving ) then
4027 self:StopMovingOrSizing();
4028 self.isMoving = false;
4029 end
4030 end
4031
4032 function CensusPlus_Options_OnMouseDown(self,arg1,arg2,arg3,...)
4033 if ( ( ( not self.isLocked ) or ( self.isLocked == 0 ) ) and ( arg1 == "LeftButton" ) ) then
4034 self:StartMoving();
4035 self.isMoving = true;
4036 end
4037 end
4038
4039 function CensusPlus_Mini_OnMouseDown( self, arg1 )
4040 if ( ( ( not self.isLocked ) or ( self.isLocked == 0 ) ) and ( arg1 == "LeftButton" ) ) then
4041 self:StartMoving();
4042 self.isMoving = true;
4043 end
4044 end
4045
4046 function CensusPlus_Census_OnMouseDown( self, arg1 )
4047 if ( ( ( not self.isLocked ) or ( self.isLocked == 0 ) ) and ( arg1 == "LeftButton" ) ) then
4048 self:StartMoving();
4049 self.isMoving = true;
4050 end
4051 end