comparison CensusPlus.lua @ 23:099a20159243 v4.2d FIN

Merge 4th try
author EmFor
date Sun, 14 Aug 2011 17:27:33 +0200
parents 77d2c7423ed5
children
comparison
equal deleted inserted replaced
22:68032715bc3c 23:099a20159243
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 --rm
45 -- guild to search (Extra button 'Take guild')
46 --local CensusPlus_MYGUILD = "The Last Journey";
47 --local CensusPlus_MYGUILD = "Worgengrauen";
48 CensusPlus_MYGUILD = "Flieht Ihr Narren";
49 ---------------------------------------------------------------------------------
44 -- 50 --
45 -- Constants 51 -- Constants
46 --rm 52 local CensusPlus_VERSION = "5.0.2"; -- version
47 local CensusPlus_MYGUILD = "The Last Journey"; -- Special guild to search
48 ---------------------------------------------------------------------------------
49 local CensusPlus_VERSION = "4.2.2"; -- version
50 local CensusPlus_MAXBARHEIGHT = 128; -- Length of blue bars 53 local CensusPlus_MAXBARHEIGHT = 128; -- Length of blue bars
51 local CensusPlus_NUMGUILDBUTTONS = 10; -- How many guild buttons are on the UI? 54 local CensusPlus_NUMGUILDBUTTONS = 10; -- How many guild buttons are on the UI?
52 local MAX_CHARACTER_LEVEL = 80; -- Maximum level a PC can attain 55 local MAX_CHARACTER_LEVEL = 85; -- Maximum level a PC can attain
53 --rm 56 --rm
54 local MAX_LEVEL_DISPLAY = 255; -- Maximum level a PC can attain 57 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 58 local MAX_WHO_RESULTS = 49; -- Maximum number of who results the server will return
56 CensusPlus_GUILDBUTTONSIZEY = 16; 59 CensusPlus_GUILDBUTTONSIZEY = 16;
57 local CensusPlus_UPDATEDELAY = 5; -- Delay time between /who messages 60 local CensusPlus_UPDATEDELAY = 5; -- Delay time between /who messages
58 local CP_MAX_TIMES = 50; 61 local CP_MAX_TIMES = 50;
59 62
60 local g_ServerPrefix = ""; -- US VERSION!! 63 local g_ServerPrefix = ""; -- formerly only US VERSION
61 --local g_ServerPrefix = "EU-"; -- EU VERSION!! 64 --local g_ServerPrefix = "EU-"; -- EU VERSION automatically
62 65
63 local wholib 66 local wholib
64 ---------------------------------------------------------------------------------- 67 ----------------------------------------------------------------------------------
65 -- 68 --
66 -- Print a string to the chat frame 69 -- Print a string to the chat frame
201 g_RaceClassList[CENSUSPlus_TAUREN] = 25; 204 g_RaceClassList[CENSUSPlus_TAUREN] = 25;
202 g_RaceClassList[CENSUSPlus_TROLL] = 26; 205 g_RaceClassList[CENSUSPlus_TROLL] = 26;
203 g_RaceClassList[CENSUSPlus_UNDEAD] = 27; 206 g_RaceClassList[CENSUSPlus_UNDEAD] = 27;
204 g_RaceClassList[CENSUSPlus_DRAENEI] = 28; 207 g_RaceClassList[CENSUSPlus_DRAENEI] = 28;
205 g_RaceClassList[CENSUSPlus_BLOODELF] = 29; 208 g_RaceClassList[CENSUSPlus_BLOODELF] = 29;
209 g_RaceClassList[CENSUSPlus_WORGEN] = 32;
210 g_RaceClassList[CENSUSPlus_GOBLIN] = 31;
211
206 212
207 g_TimeDatabase[CENSUSPlus_DRUID] = 0; 213 g_TimeDatabase[CENSUSPlus_DRUID] = 0;
208 g_TimeDatabase[CENSUSPlus_HUNTER] = 0; 214 g_TimeDatabase[CENSUSPlus_HUNTER] = 0;
209 g_TimeDatabase[CENSUSPlus_MAGE] = 0; 215 g_TimeDatabase[CENSUSPlus_MAGE] = 0;
210 g_TimeDatabase[CENSUSPlus_PRIEST] = 0; 216 g_TimeDatabase[CENSUSPlus_PRIEST] = 0;
227 g_FactionCheck[CENSUSPlus_ORC] = CENSUSPlus_HORDE; 233 g_FactionCheck[CENSUSPlus_ORC] = CENSUSPlus_HORDE;
228 g_FactionCheck[CENSUSPlus_TAUREN] = CENSUSPlus_HORDE; 234 g_FactionCheck[CENSUSPlus_TAUREN] = CENSUSPlus_HORDE;
229 g_FactionCheck[CENSUSPlus_TROLL] = CENSUSPlus_HORDE; 235 g_FactionCheck[CENSUSPlus_TROLL] = CENSUSPlus_HORDE;
230 g_FactionCheck[CENSUSPlus_UNDEAD] = CENSUSPlus_HORDE; 236 g_FactionCheck[CENSUSPlus_UNDEAD] = CENSUSPlus_HORDE;
231 g_FactionCheck[CENSUSPlus_BLOODELF] = CENSUSPlus_HORDE; 237 g_FactionCheck[CENSUSPlus_BLOODELF] = CENSUSPlus_HORDE;
238 g_FactionCheck[CENSUSPlus_GOBLIN] = CENSUSPlus_HORDE;
232 239
233 g_FactionCheck[CENSUSPlus_DWARF] = CENSUSPlus_ALLIANCE; 240 g_FactionCheck[CENSUSPlus_DWARF] = CENSUSPlus_ALLIANCE;
234 g_FactionCheck[CENSUSPlus_GNOME] = CENSUSPlus_ALLIANCE; 241 g_FactionCheck[CENSUSPlus_GNOME] = CENSUSPlus_ALLIANCE;
235 g_FactionCheck[CENSUSPlus_HUMAN] = CENSUSPlus_ALLIANCE; 242 g_FactionCheck[CENSUSPlus_HUMAN] = CENSUSPlus_ALLIANCE;
236 g_FactionCheck[CENSUSPlus_NIGHTELF] = CENSUSPlus_ALLIANCE; 243 g_FactionCheck[CENSUSPlus_NIGHTELF] = CENSUSPlus_ALLIANCE;
237 g_FactionCheck[CENSUSPlus_DRAENEI] = CENSUSPlus_ALLIANCE; 244 g_FactionCheck[CENSUSPlus_DRAENEI] = CENSUSPlus_ALLIANCE;
245 g_FactionCheck[CENSUSPlus_WORGEN] = CENSUSPlus_ALLIANCE;
238 local g_ReturnedZero = false; 246 local g_ReturnedZero = false;
239 247
240 do 248 do
241 -- HACK 249 -- HACK
242 --[[ 250 --[[
243 seeing as Blizzard improperly coded GuildControlPopupFrame_OnEvent to mess up when GUILD_ROSTER_EVENT is dispatched, 251 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. 252 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 253 Thanks to ckknight of wowace for this
246 ]] 254 ]]
247 GuildControlPopupFrame:SetScript("OnEvent", nil) 255 -- GuildControlPopupFrame:SetScript("OnEvent", nil)
248 end 256 end
249 257
250 258
251 ---------------------------------------------------------------------------------- 259 ----------------------------------------------------------------------------------
252 -- 260 --
418 -- 426 --
419 ----------------------------------------------------------------------------------- 427 -----------------------------------------------------------------------------------
420 function CensusPlus_GetFactionRaces(faction) 428 function CensusPlus_GetFactionRaces(faction)
421 local ret = {}; 429 local ret = {};
422 if (faction == CENSUSPlus_HORDE) then 430 if (faction == CENSUSPlus_HORDE) then
423 ret = {CENSUSPlus_ORC, CENSUSPlus_TAUREN, CENSUSPlus_TROLL, CENSUSPlus_UNDEAD, CENSUSPlus_BLOODELF}; 431 ret = {CENSUSPlus_ORC, CENSUSPlus_TAUREN, CENSUSPlus_TROLL, CENSUSPlus_UNDEAD, CENSUSPlus_BLOODELF, CENSUSPlus_GOBLIN};
424 elseif (faction == CENSUSPlus_ALLIANCE) then 432 elseif (faction == CENSUSPlus_ALLIANCE) then
425 ret = {CENSUSPlus_DWARF, CENSUSPlus_GNOME, CENSUSPlus_HUMAN, CENSUSPlus_NIGHTELF, CENSUSPlus_DRAENEI}; 433 ret = {CENSUSPlus_DWARF, CENSUSPlus_GNOME, CENSUSPlus_HUMAN, CENSUSPlus_NIGHTELF, CENSUSPlus_DRAENEI, CENSUSPlus_WORGEN};
426 end 434 end
427 return ret; 435 return ret;
428 end 436 end
429 437
430 ----------------------------------------------------------------------------------- 438 -----------------------------------------------------------------------------------
448 -- 456 --
449 ----------------------------------------------------------------------------------- 457 -----------------------------------------------------------------------------------
450 local function GetRaceClasses(race) 458 local function GetRaceClasses(race)
451 local ret = {}; 459 local ret = {};
452 if (race == CENSUSPlus_ORC) then 460 if (race == CENSUSPlus_ORC) then
453 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_SHAMAN, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT}; 461 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_MAGE, CENSUSPlus_SHAMAN, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT};
454 elseif (race == CENSUSPlus_TAUREN) then 462 elseif (race == CENSUSPlus_TAUREN) then
455 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_SHAMAN, CENSUSPlus_DRUID, CENSUSPlus_DEATHKNIGHT}; 463 ret = {CENSUSPlus_PALADIN, CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_SHAMAN, CENSUSPlus_PRIEST, CENSUSPlus_DRUID, CENSUSPlus_DEATHKNIGHT};
456 elseif (race == CENSUSPlus_TROLL) then 464 elseif (race == CENSUSPlus_TROLL) then
457 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_SHAMAN, CENSUSPlus_MAGE, CENSUSPlus_DEATHKNIGHT}; 465 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_SHAMAN, CENSUSPlus_MAGE, CENSUSPlus_DRUID, CENSUSPlus_DEATHKNIGHT};
458 elseif (race == CENSUSPlus_UNDEAD) then 466 elseif (race == CENSUSPlus_UNDEAD) then
459 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT}; 467 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT};
460 elseif (race == CENSUSPlus_DWARF) then 468 elseif (race == CENSUSPlus_DWARF) then
461 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_DEATHKNIGHT}; 469 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_SHAMAN, CENSUSPlus_DEATHKNIGHT};
462 elseif (race == CENSUSPlus_GNOME) then 470 elseif (race == CENSUSPlus_GNOME) then
463 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_ROGUE, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT}; 471 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_ROGUE, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT};
464 elseif (race == CENSUSPlus_HUMAN) then 472 elseif (race == CENSUSPlus_HUMAN) then
465 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT}; 473 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_PALADIN, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT};
466 elseif (race == CENSUSPlus_NIGHTELF) then 474 elseif (race == CENSUSPlus_NIGHTELF) then
467 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_DRUID, CENSUSPlus_DEATHKNIGHT}; 475 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_MAGE, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_DRUID, CENSUSPlus_DEATHKNIGHT};
468 elseif (race == CENSUSPlus_BLOODELF) then 476 elseif (race == CENSUSPlus_BLOODELF) then
469 ret = {CENSUSPlus_PALADIN, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT}; 477 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT};
470 elseif (race == CENSUSPlus_DRAENEI) then 478 elseif (race == CENSUSPlus_DRAENEI) then
471 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_HUNTER, CENSUSPlus_PRIEST, CENSUSPlus_SHAMAN, CENSUSPlus_MAGE, CENSUSPlus_DEATHKNIGHT}; 479 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_HUNTER, CENSUSPlus_PRIEST, CENSUSPlus_SHAMAN, CENSUSPlus_MAGE, CENSUSPlus_DEATHKNIGHT};
480 elseif (race == CENSUSPlus_WORGEN) then
481 ret = {CENSUSPlus_DEATHKNIGHT, CENSUSPlus_DRUID, CENSUSPlus_HUNTER, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_ROGUE, CENSUSPlus_WARLOCK, CENSUSPlus_WARRIOR};
482 elseif (race == CENSUSPlus_GOBLIN) then
483 ret = {CENSUSPlus_DEATHKNIGHT, CENSUSPlus_HUNTER, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_ROGUE, CENSUSPlus_SHAMAN, CENSUSPlus_WARLOCK, CENSUSPlus_WARRIOR};
472 end 484 end
473 return ret; 485 return ret;
474 end 486 end
475 487
476 ----------------------------------------------------------------------------------- 488 -----------------------------------------------------------------------------------
487 -- Return common letters found in names, may override this for other languages 499 -- Return common letters found in names, may override this for other languages
488 -- Worst case scenario is to do it for every letter in the alphabet 500 -- Worst case scenario is to do it for every letter in the alphabet
489 -- 501 --
490 ----------------------------------------------------------------------------------- 502 -----------------------------------------------------------------------------------
491 local function GetNameLetters() 503 local function GetNameLetters()
504 -- return { "a", "b", "c", "d", "e", "f", "g", "i", "o", "p", "r", "s", "t", "u", "y" };
492 --rm 505 --rm
493 -- return { "a", "b", "c", "d", "e", "f", "g", "i", "o", "p", "r", "s", "t", "u", "y" };
494 -- return { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "\195\134", "\195\164", "\195\182", "\195\188", "\195\152" }; 506 -- return { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "\195\134", "\195\164", "\195\182", "\195\188", "\195\152" };
495 return { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "\195\134", "\195\164", "\195\182", "\195\188", "\195\152", "\195\184" }; 507 return { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "\195\134", "\195\164", "\195\182", "\195\188", "\195\152", "\195\184" };
496 end 508 end
497 509
498 --------------------------------------------------------------------------------- 510 ---------------------------------------------------------------------------------
563 ----------------------------------------------------------------------------------- 575 -----------------------------------------------------------------------------------
564 -- 576 --
565 -- Called once on load 577 -- Called once on load
566 -- 578 --
567 ----------------------------------------------------------------------------------- 579 -----------------------------------------------------------------------------------
568 function CensusPlus_OnLoad() 580 function CensusPlus_OnLoad( this )
569 -- 581 --
570 -- Update the version number 582 -- Update the version number
571 -- 583 --
572 CensusPlusText:SetText("Census+ EmSpe\195\167ial v"..CensusPlus_VERSION .. " " .. g_CensusPlusLocale ); 584 CensusPlusText:SetText("Census+ EmSpe\195\167ial v"..CensusPlus_VERSION .. " " .. g_CensusPlusLocale );
573 CensusPlusText2:SetText( CENSUSPlus_UPLOAD ); 585 CensusPlusText2:SetText( CENSUSPlus_UPLOAD );
640 -- 652 --
641 -- Set up an empty frame to do updates 653 -- Set up an empty frame to do updates
642 -- 654 --
643 local updateFrame = CreateFrame("Frame"); 655 local updateFrame = CreateFrame("Frame");
644 updateFrame:SetScript("OnUpdate", CensusPlus_OnUpdate); 656 updateFrame:SetScript("OnUpdate", CensusPlus_OnUpdate);
645 CensusPlusTakeGuildButton:SetText( CENSUSPlus_TAKEGUILD.." \""..CensusPlus_MYGUILD.."\"" ); 657 end
646 end 658
647 659 function CensusPlus_FriendsFrame_OnEvent(self, event, ...)
648 function CensusPlus_FriendsFrame_OnEvent(...)
649 660
650 -- CensusPlus_Msg( "CP_FF_OE Message =>" .. event ); 661 -- CensusPlus_Msg( "CP_FF_OE Message =>" .. event );
651 662
652 if(wholib == nil and 663 if(wholib == nil and
653 event == "WHO_LIST_UPDATE" and g_IsCensusPlusInProgress and g_WaitingForWhoUpdate ) then 664 event == "WHO_LIST_UPDATE" and g_IsCensusPlusInProgress and g_WaitingForWhoUpdate ) then
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();
1504 1515
1505 --wholib.RegisterCallback("CensusPlus", "WHOLIB_QUERY_RESULT", CensusPlus_WhoLibEvent) 1516 --wholib.RegisterCallback("CensusPlus", "WHOLIB_QUERY_RESULT", CensusPlus_WhoLibEvent)
1506 1517
1507 end 1518 end
1508 end 1519 end
1520
1509 CensusPlusTakeButton:SetText( CENSUSPlus_PAUSE ); 1521 CensusPlusTakeButton:SetText( CENSUSPlus_PAUSE );
1522
1510 end 1523 end
1511 1524
1512 ----------------------------------------------------------------------------------- 1525 -----------------------------------------------------------------------------------
1513 -- 1526 --
1514 -- Stop a CensusPlus 1527 -- Stop a CensusPlus
2819 local factionGroup = UnitFactionGroup("player"); 2832 local factionGroup = UnitFactionGroup("player");
2820 if( factionGroup == nil ) then 2833 if( factionGroup == nil ) then
2821 return; 2834 return;
2822 end 2835 end
2823 2836
2837 --rm
2838 CensusPlusTakeGuildButton:SetText( CENSUSPlus_TAKEGUILD.." \""..CensusPlus_MYGUILD.."\"" );
2839
2824 CensusPlusFactionName:SetText(format(CENSUSPlus_FACTION, factionGroup)); 2840 CensusPlusFactionName:SetText(format(CENSUSPlus_FACTION, factionGroup));
2825 2841
2826 if( CensusPlus_Database["Info"]["Locale"] ~= nil ) then 2842 if( CensusPlus_Database["Info"]["Locale"] ~= nil ) then
2827 CensusPlusLocaleName:SetText(format(CENSUSPlus_LOCALE, CensusPlus_Database["Info"]["Locale"])); 2843 CensusPlusLocaleName:SetText(format(CENSUSPlus_LOCALE, CensusPlus_Database["Info"]["Locale"]));
2828 end 2844 end
2942 -- Update race bars 2958 -- Update race bars
2943 -- 2959 --
2944 for i = 1, numRaces, 1 do 2960 for i = 1, numRaces, 1 do
2945 local race = thisFactionRaces[i]; 2961 local race = thisFactionRaces[i];
2946 local buttonName = "CensusPlusRaceBar"..i; 2962 local buttonName = "CensusPlusRaceBar"..i;
2963
2947 local button = getglobal(buttonName); 2964 local button = getglobal(buttonName);
2948 local thisCount = g_RaceCount[i]; 2965 local thisCount = g_RaceCount[i];
2949 if ((thisCount ~= nil) and (thisCount > 0) and (maxCount > 0)) then 2966 if ((thisCount ~= nil) and (thisCount > 0) and (maxCount > 0)) then
2950 local height = floor((thisCount * CensusPlus_MAXBARHEIGHT / maxCount) ); 2967 local height = floor((thisCount * CensusPlus_MAXBARHEIGHT / maxCount) );
2951 if (height < 2 or height == nil ) then height = 2; end 2968 if (height < 2 or height == nil ) then height = 2; end
2953 button:Show(); 2970 button:Show();
2954 else 2971 else
2955 button:Hide(); 2972 button:Hide();
2956 end 2973 end
2957 local normalTextureName="Interface\\AddOns\\CensusPlus\\Skin\\CensusPlus_"..g_RaceClassList[race]; 2974 local normalTextureName="Interface\\AddOns\\CensusPlus\\Skin\\CensusPlus_"..g_RaceClassList[race];
2975
2976
2958 local legendName = "CensusPlusRaceLegend"..i; 2977 local legendName = "CensusPlusRaceLegend"..i;
2959 local legend = getglobal(legendName); 2978 local legend = getglobal(legendName);
2960 legend:SetNormalTexture(normalTextureName); 2979 legend:SetNormalTexture(normalTextureName);
2961 if (g_RaceSelected == i) then 2980 if (g_RaceSelected == i) then
2962 legend:LockHighlight(); 2981 legend:LockHighlight();
3081 end 3100 end
3082 3101
3083 if( CP_PlayerListWindow:IsVisible() ) then 3102 if( CP_PlayerListWindow:IsVisible() ) then
3084 CensusPlus_PlayerListOnShow(); 3103 CensusPlus_PlayerListOnShow();
3085 end 3104 end
3086
3087 3105
3088 debugprofilestop(); 3106 debugprofilestop();
3089 3107
3090 end 3108 end
3091 3109
3128 ---------------------------------------------------------------------------------- 3146 ----------------------------------------------------------------------------------
3129 -- 3147 --
3130 -- Race legend clicked 3148 -- Race legend clicked
3131 -- 3149 --
3132 --------------------------------------------------------------------------------- 3150 ---------------------------------------------------------------------------------
3133 function CensusPlus_OnClickRace() 3151 function CensusPlus_OnClickRace( this )
3134 local id = this:GetID(); 3152 local id = this:GetID();
3135 if (id == g_RaceSelected) then 3153 if (id == g_RaceSelected) then
3136 g_RaceSelected = 0; 3154 g_RaceSelected = 0;
3137 else 3155 else
3138 g_RaceSelected = id; 3156 g_RaceSelected = id;
3143 ---------------------------------------------------------------------------------- 3161 ----------------------------------------------------------------------------------
3144 -- 3162 --
3145 -- Class legend clicked 3163 -- Class legend clicked
3146 -- 3164 --
3147 --------------------------------------------------------------------------------- 3165 ---------------------------------------------------------------------------------
3148 function CensusPlus_OnClickClass() 3166 function CensusPlus_OnClickClass( this )
3149 local id = this:GetID(); 3167 local id = this:GetID();
3150 if (id == g_ClassSelected) then 3168 if (id == g_ClassSelected) then
3151 g_ClassSelected = 0; 3169 g_ClassSelected = 0;
3152 else 3170 else
3153 g_ClassSelected = id; 3171 g_ClassSelected = id;
3159 ---------------------------------------------------------------------------------- 3177 ----------------------------------------------------------------------------------
3160 -- 3178 --
3161 -- Level bar loaded 3179 -- Level bar loaded
3162 -- 3180 --
3163 --------------------------------------------------------------------------------- 3181 ---------------------------------------------------------------------------------
3164 function CensusPlus_OnLoadLevel() 3182 function CensusPlus_OnLoadLevel( self )
3165 this:RegisterForClicks("LeftButtonUp","RightButtonUp"); 3183 self:RegisterForClicks("LeftButtonUp","RightButtonUp");
3166 end 3184 end
3167 3185
3168 ---------------------------------------------------------------------------------- 3186 ----------------------------------------------------------------------------------
3169 -- 3187 --
3170 -- Level bar clicked 3188 -- Level bar clicked
3171 -- 3189 --
3172 --------------------------------------------------------------------------------- 3190 ---------------------------------------------------------------------------------
3173 function CensusPlus_OnClickLevel(button) 3191 function CensusPlus_OnClickLevel(this, button)
3174 local id = this:GetID(); 3192 local id = this:GetID();
3175 if (((button == "LeftButton") and (id == g_LevelSelected)) or ((button == "RightButton") and (id + g_LevelSelected == 0))) then 3193 if (((button == "LeftButton") and (id == g_LevelSelected)) or ((button == "RightButton") and (id + g_LevelSelected == 0))) then
3176 g_LevelSelected = 0; 3194 g_LevelSelected = 0;
3177 elseif (button == "RightButton") then 3195 elseif (button == "RightButton") then
3178 g_LevelSelected = 0 - id; 3196 g_LevelSelected = 0 - id;
3185 ---------------------------------------------------------------------------------- 3203 ----------------------------------------------------------------------------------
3186 -- 3204 --
3187 -- Race tooltip 3205 -- Race tooltip
3188 -- 3206 --
3189 --------------------------------------------------------------------------------- 3207 ---------------------------------------------------------------------------------
3190 function CensusPlus_OnEnterRace() 3208 function CensusPlus_OnEnterRace( this )
3191 local factionGroup = UnitFactionGroup("player"); 3209 local factionGroup = UnitFactionGroup("player");
3192 local thisFactionRaces = CensusPlus_GetFactionRaces(factionGroup); 3210 local thisFactionRaces = CensusPlus_GetFactionRaces(factionGroup);
3193 local id = this:GetID(); 3211 local id = this:GetID();
3194 local raceName = thisFactionRaces[id]; 3212 local raceName = thisFactionRaces[id];
3195 local count = g_RaceCount[id]; 3213 local count = g_RaceCount[id];
3204 ---------------------------------------------------------------------------------- 3222 ----------------------------------------------------------------------------------
3205 -- 3223 --
3206 -- Class tooltip 3224 -- Class tooltip
3207 -- 3225 --
3208 --------------------------------------------------------------------------------- 3226 ---------------------------------------------------------------------------------
3209 function CensusPlus_OnEnterClass() 3227 function CensusPlus_OnEnterClass( self )
3210 local factionGroup = UnitFactionGroup("player"); 3228 local factionGroup = UnitFactionGroup("player");
3211 local thisFactionClasses = CensusPlus_GetFactionClasses(factionGroup); 3229 local thisFactionClasses = CensusPlus_GetFactionClasses(factionGroup);
3212 local id = this:GetID(); 3230 local id = self:GetID();
3213 local className = thisFactionClasses[id]; 3231 local className = thisFactionClasses[id];
3214 local count = g_ClassCount[id]; 3232 local count = g_ClassCount[id];
3215 if (count ~= nil) then 3233 if (count ~= nil) then
3216 local percent = floor((count / g_TotalCount) * 100); 3234 local percent = floor((count / g_TotalCount) * 100);
3217 GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); 3235 GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
3218 GameTooltip:SetText(className.."\n"..count.."\n"..percent.."%", 1.0, 1.0, 1.0); 3236 GameTooltip:SetText(className.."\n"..count.."\n"..percent.."%", 1.0, 1.0, 1.0);
3219 GameTooltip:Show(); 3237 GameTooltip:Show();
3220 end 3238 end
3221 end 3239 end
3222 3240
3223 ---------------------------------------------------------------------------------- 3241 ----------------------------------------------------------------------------------
3224 -- 3242 --
3225 -- Level tooltip 3243 -- Level tooltip
3226 -- 3244 --
3227 --------------------------------------------------------------------------------- 3245 ---------------------------------------------------------------------------------
3228 function CensusPlus_OnEnterLevel() 3246 function CensusPlus_OnEnterLevel( this )
3229 local id = this:GetID(); 3247 local id = this:GetID();
3230 local count = g_LevelCount[id]; 3248 local count = g_LevelCount[id];
3231 if (count ~= nil) then 3249 if (count ~= nil) then
3232 local percent = floor(count * 100 / g_TotalCount); 3250 local percent = floor((count / g_TotalCount) * 100);
3233 GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); 3251 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
3234 GameTooltip:SetText("Level "..id.."\n"..count.."\n"..percent.."%", 1.0, 1.0, 1.0); 3252 GameTooltip:SetText("Level "..id.."\n"..count.."\n"..percent.."%", 1.0, 1.0, 1.0);
3235 GameTooltip:Show(); 3253 GameTooltip:Show();
3236 end 3254 end
3237 end 3255 end
3239 ---------------------------------------------------------------------------------- 3257 ----------------------------------------------------------------------------------
3240 -- 3258 --
3241 -- Clicked a guild button 3259 -- Clicked a guild button
3242 -- 3260 --
3243 --------------------------------------------------------------------------------- 3261 ---------------------------------------------------------------------------------
3244 function CensusPlus_GuildButton_OnClick() 3262 function CensusPlus_GuildButton_OnClick( this )
3245 local id = this:GetID(); 3263 local id = this:GetID();
3246 local offset = FauxScrollFrame_GetOffset(CensusPlusGuildScrollFrame); 3264 local offset = FauxScrollFrame_GetOffset(CensusPlusGuildScrollFrame);
3247 local newSelection = id + offset; 3265 local newSelection = id + offset;
3248 local guildKey = CensusPlus_Guilds[newSelection].m_Name; 3266 local guildKey = CensusPlus_Guilds[newSelection].m_Name;
3249 if (g_GuildSelected ~= guildKey) then 3267 if (g_GuildSelected ~= guildKey) then
3938 local name, lineid = strsplit(":", namelink); 3956 local name, lineid = strsplit(":", namelink);
3939 if ( name and (strlen(name) > 0) ) then 3957 if ( name and (strlen(name) > 0) ) then
3940 name = gsub(name, "([^%s]*)%s+([^%s]*)%s+([^%s]*)", "%3"); 3958 name = gsub(name, "([^%s]*)%s+([^%s]*)%s+([^%s]*)", "%3");
3941 name = gsub(name, "([^%s]*)%s+([^%s]*)", "%2"); 3959 name = gsub(name, "([^%s]*)%s+([^%s]*)", "%2");
3942 if ( IsShiftKeyDown() ) then 3960 if ( IsShiftKeyDown() ) then
3943 if ( not ChatFrameEditBox:IsVisible() ) then 3961 if ( not ChatFrame1EditBox:IsVisible() ) then
3944 -- 3962 --
3945 -- This is the part we need to snag 3963 -- This is the part we need to snag
3946 -- 3964 --
3947 3965
3948 -- 3966 --
4006 wholib:AskWho({query = msg, queue = wholib.WHOLIB_QUEUE_QUIET, callback = CP_ProcessWhoEvent }) 4024 wholib:AskWho({query = msg, queue = wholib.WHOLIB_QUEUE_QUIET, callback = CP_ProcessWhoEvent })
4007 else 4025 else
4008 SendWho( msg ); 4026 SendWho( msg );
4009 end 4027 end
4010 end 4028 end
4029 function CensusPlus_Options_OnMouseUp(self,...)
4030 CensusPlus_Msg('Mouse up');
4031 if ( self.isMoving ) then
4032 self:StopMovingOrSizing();
4033 self.isMoving = false;
4034 end
4035 end
4036 function CensusPlus_Options_OnMouseDown(self,arg1,arg2,arg3,...)
4037 if ( ( ( not self.isLocked ) or ( self.isLocked == 0 ) ) and ( arg1 == "LeftButton" ) ) then
4038 self:StartMoving();
4039 self.isMoving = true;
4040 end
4041 end
4042 function CensusPlus_Mini_OnMouseDown( self, arg1 )
4043 if ( ( ( not self.isLocked ) or ( self.isLocked == 0 ) ) and ( arg1 == "LeftButton" ) ) then
4044 self:StartMoving();
4045 self.isMoving = true;
4046 end
4047 end
4048 function CensusPlus_Census_OnMouseDown( self, arg1 )
4049 if ( ( ( not self.isLocked ) or ( self.isLocked == 0 ) ) and ( arg1 == "LeftButton" ) ) then
4050 self:StartMoving();
4051 self.isMoving = true;
4052 end
4053 end