PopupPlayerInfo.cpp 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. ///////////////////////////////////////////////////////////////////////////////////////
  24. // FILE: PopupPlayerInfo.cpp
  25. // Author: Matthew D. Campbell, July 2002
  26. // Description: Player info right-click popup screen
  27. ///////////////////////////////////////////////////////////////////////////////////////
  28. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  29. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  30. #include "Common/PlayerTemplate.h"
  31. #include "Common/BattleHonors.h"
  32. #include "Common/CustomMatchPreferences.h"
  33. #include "Common/GameSpyMiscPreferences.h"
  34. #include "Common/Filesystem.h"
  35. #include "GameClient/mouse.h"
  36. #include "GameClient/GameText.h"
  37. #include "GameClient/WindowLayout.h"
  38. #include "GameClient/Gadget.h"
  39. #include "GameClient/KeyDefs.h"
  40. #include "GameClient/GameWindowManager.h"
  41. #include "GameClient/GadgetListBox.h"
  42. #include "GameClient/GadgetCheckBox.h"
  43. #include "GameClient/GadgetProgressBar.h"
  44. #include "GameClient/GadgetStaticText.h"
  45. #include "GameClient/Display.h"
  46. #include "GameClient/MessageBox.h"
  47. #include "GameNetwork/GameSpyOverlay.h"
  48. #include "GameNetwork/GameSpy/PeerDefs.h"
  49. #include "GameNetwork/GameSpy/PeerThread.h"
  50. #include "GameNetwork/GameSpy/PersistentStorageDefs.h"
  51. #include "GameNetwork/GameSpy/PersistentStorageThread.h"
  52. #include "GameNetwork/RankPointValue.h"
  53. #include "GameNetwork/GameSpy/BuddyThread.h"
  54. #include "GameNetwork/GameSpy/GSConfig.h"
  55. #include "GameNetwork/GameSpy/LobbyUtils.h"
  56. #include "WWDownload/Registry.h"
  57. #ifdef _INTERNAL
  58. // for occasional debugging...
  59. //#pragma optimize("", off)
  60. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  61. #endif
  62. // PRIVATE DATA ///////////////////////////////////////////////////////////////////////////////////
  63. // window ids ------------------------------------------------------------------------------
  64. static NameKeyType parentID = NAMEKEY_INVALID;
  65. static NameKeyType listboxInfoID = NAMEKEY_INVALID;
  66. static NameKeyType buttonCloseID = NAMEKEY_INVALID;
  67. static NameKeyType buttonBuddiesID = NAMEKEY_INVALID;
  68. //static NameKeyType buttonOptionsID = NAMEKEY_INVALID;
  69. static NameKeyType buttonSetLocaleID = NAMEKEY_INVALID;
  70. static NameKeyType buttonDeleteAccountID = NAMEKEY_INVALID;
  71. static NameKeyType checkBoxAsianFontID = NAMEKEY_INVALID;
  72. static NameKeyType checkBoxNonAsianFontID = NAMEKEY_INVALID;
  73. // Window Pointers ------------------------------------------------------------------------
  74. static GameWindow *parent = NULL;
  75. static GameWindow *listboxInfo = NULL;
  76. static GameWindow *buttonClose = NULL;
  77. static GameWindow *buttonBuddies = NULL;
  78. //static GameWindow *buttonbuttonOptions = NULL;
  79. static GameWindow *buttonSetLocale = NULL;
  80. static GameWindow *buttonDeleteAccount = NULL;
  81. static GameWindow *checkBoxAsianFont = NULL;
  82. static GameWindow *checkBoxNonAsianFont = NULL;
  83. static Bool isOverlayActive = false;
  84. static Bool raiseMessageBox = false;
  85. static Int lookAtPlayerID = 0;
  86. static std::string lookAtPlayerName;
  87. static const char *rankNames[] = {
  88. "Private",
  89. "Corporal",
  90. "Sergeant",
  91. "Lieutenant",
  92. "Captain",
  93. "Major",
  94. "Colonel",
  95. "General",
  96. "Brigadier",
  97. "Commander",
  98. };
  99. static const Image* lookupRankImage(AsciiString side, Int rank)
  100. {
  101. if (side.isEmpty())
  102. return TheMappedImageCollection->findImageByName("NewPlayer");
  103. if (rank < 0 || rank >= MAX_RANKS)
  104. return NULL;
  105. // dirty hack rather than try to get artists to follow a naming convention
  106. if (side == "America")
  107. side = "_USA";
  108. else if (side == "China")
  109. side = "_China";
  110. else if (side == "GLA")
  111. side = "_GLA";
  112. else if (side == "Random")
  113. side = "Elite";
  114. AsciiString fullImageName;
  115. fullImageName.format("Rank_%s%s", rankNames[rank], side.str());
  116. if(strcmp(fullImageName.str(),"Rank_PrivateElite") == 0)
  117. fullImageName = "Rank";//_Private_Elite";
  118. const Image *img = TheMappedImageCollection->findImageByName(fullImageName);
  119. if (img)
  120. {
  121. DEBUG_LOG(("*** Loaded rank image '%s' from TheMappedImageCollection!\n", fullImageName.str()));
  122. }
  123. else
  124. {
  125. DEBUG_LOG(("*** Could not load rank image '%s' from TheMappedImageCollection!\n", fullImageName.str()));
  126. }
  127. return img;
  128. }
  129. static Int getTotalDisconnectsFromFile(Int playerID)
  130. {
  131. Int retval = 0;
  132. if (playerID == 0)
  133. {
  134. return 0;
  135. }
  136. UserPreferences pref;
  137. AsciiString userPrefFilename;
  138. userPrefFilename.format("GeneralsOnline\\MiscPref%d.ini", playerID);
  139. DEBUG_LOG(("setPersistentDataCallback - reading stats from file %s\n", userPrefFilename.str()));
  140. pref.load(userPrefFilename);
  141. // if there is a file override, use that data instead.
  142. if (pref.find("0") != pref.end()) {
  143. retval = atoi(pref.find("0")->second.str());
  144. }
  145. if (pref.find("1") != pref.end()) {
  146. retval += atoi(pref.find("1")->second.str());
  147. }
  148. if (pref.find("2") != pref.end()) {
  149. retval += atoi(pref.find("2")->second.str());
  150. }
  151. if (pref.find("3") != pref.end()) {
  152. retval += atoi(pref.find("3")->second.str());
  153. }
  154. if (pref.find("4") != pref.end()) {
  155. retval += atoi(pref.find("4")->second.str());
  156. }
  157. if (pref.find("5") != pref.end()) {
  158. retval += atoi(pref.find("5")->second.str());
  159. }
  160. return retval;
  161. }
  162. Int GetAdditionalDisconnectsFromUserFile(Int playerID)
  163. {
  164. Int retval = getTotalDisconnectsFromFile(playerID);
  165. if (playerID == 0) {
  166. return 0;
  167. }
  168. if (TheGameSpyInfo->getAdditionalDisconnects() > 0 && !retval)
  169. {
  170. DEBUG_LOG(("Clearing additional disconnects\n"));
  171. TheGameSpyInfo->clearAdditionalDisconnects();
  172. }
  173. if (TheGameSpyInfo->getAdditionalDisconnects() != -1)
  174. {
  175. return TheGameSpyInfo->getAdditionalDisconnects();
  176. }
  177. return retval;
  178. }
  179. void GetAdditionalDisconnectsFromUserFile(PSPlayerStats *stats)
  180. {
  181. if (!stats || stats->id == 0) {
  182. return;
  183. }
  184. if (TheGameSpyInfo->getAdditionalDisconnects() > 0 && !getTotalDisconnectsFromFile(stats->id))
  185. {
  186. DEBUG_LOG(("Clearing additional disconnects\n"));
  187. TheGameSpyInfo->clearAdditionalDisconnects();
  188. }
  189. if (TheGameSpyInfo->getAdditionalDisconnects() < 1)
  190. {
  191. return;
  192. }
  193. UserPreferences pref;
  194. AsciiString userPrefFilename;
  195. userPrefFilename.format("GeneralsOnline\\MiscPref%d.ini", stats->id);
  196. DEBUG_LOG(("setPersistentDataCallback - reading stats from file %s\n", userPrefFilename.str()));
  197. pref.load(userPrefFilename);
  198. // if there is a file override, use that data instead.
  199. if (pref.find("0") != pref.end()) {
  200. stats->desyncs[2] += abs(atoi(pref.find("0")->second.str()));
  201. }
  202. if (pref.find("1") != pref.end()) {
  203. stats->desyncs[3] += abs(atoi(pref.find("1")->second.str()));
  204. }
  205. if (pref.find("2") != pref.end()) {
  206. stats->desyncs[4] += abs(atoi(pref.find("2")->second.str()));
  207. }
  208. if (pref.find("3") != pref.end()) {
  209. stats->discons[2] += abs(atoi(pref.find("3")->second.str()));
  210. }
  211. if (pref.find("4") != pref.end()) {
  212. stats->discons[3] += abs(atoi(pref.find("4")->second.str()));
  213. }
  214. if (pref.find("5") != pref.end()) {
  215. stats->discons[4] += abs(atoi(pref.find("5")->second.str()));
  216. }
  217. }
  218. // default values
  219. RankPoints::RankPoints(void)
  220. {
  221. m_ranks[RANK_PRIVATE] = 0;
  222. m_ranks[RANK_CORPORAL] = TheGameSpyConfig->getPointsForRank(RANK_CORPORAL); // 5
  223. m_ranks[RANK_SERGEANT] = TheGameSpyConfig->getPointsForRank(RANK_SERGEANT); // 10
  224. m_ranks[RANK_LIEUTENANT] = TheGameSpyConfig->getPointsForRank(RANK_LIEUTENANT); // 20
  225. m_ranks[RANK_CAPTAIN] = TheGameSpyConfig->getPointsForRank(RANK_CAPTAIN); // 50
  226. m_ranks[RANK_MAJOR] = TheGameSpyConfig->getPointsForRank(RANK_MAJOR); // 100
  227. m_ranks[RANK_COLONEL] = TheGameSpyConfig->getPointsForRank(RANK_COLONEL); // 200
  228. m_ranks[RANK_BRIGADIER_GENERAL] = TheGameSpyConfig->getPointsForRank(RANK_BRIGADIER_GENERAL); // 500
  229. m_ranks[RANK_GENERAL] = TheGameSpyConfig->getPointsForRank(RANK_GENERAL); // 1000
  230. m_ranks[RANK_COMMANDER_IN_CHIEF] = TheGameSpyConfig->getPointsForRank(RANK_COMMANDER_IN_CHIEF); // 2000
  231. m_winMultiplier = 3.0f;
  232. m_lostMultiplier = 0.0f;
  233. m_hourSpentOnlineMultiplier = 1.0f;
  234. m_completedSoloCampaigns = 5.0f;
  235. m_disconnectMultiplier = -1.0f;
  236. #ifdef DEBUG_LOGGING
  237. AsciiStringList sidesList;
  238. ThePlayerTemplateStore->getAllSideStrings(&sidesList);
  239. for (AsciiStringList::iterator sit = sidesList.begin(); sit != sidesList.end(); ++sit)
  240. {
  241. for (Int i=0; i<MAX_RANKS; ++i)
  242. lookupRankImage(*sit, i);
  243. }
  244. for (Int i=0; i<MAX_RANKS; ++i)
  245. lookupRankImage("Random", i);
  246. #endif
  247. }
  248. RankPoints *TheRankPointValues = NULL;
  249. void SetLookAtPlayer( Int id, AsciiString nick)
  250. {
  251. lookAtPlayerID = id;
  252. lookAtPlayerName = nick.str();
  253. }
  254. // BATTLE_HONOR_LADDER_CHAMP = 0x0000001,
  255. // BATTLE_HONOR_STREAK_3 = 0x0000002,
  256. // BATTLE_HONOR_STREAK_5 = 0x0000004,
  257. // BATTLE_HONOR_STREAK_10 = 0x0000008,
  258. // BATTLE_HONOR_STREAK_20 = 0x0000010,
  259. // BATTLE_HONOR_LOYALTY_USA = 0x0000020,
  260. // BATTLE_HONOR_LOYALTY_CHINA = 0x0000040,
  261. // BATTLE_HONOR_LOYALTY_GLA = 0x0000060,
  262. // BATTLE_HONOR_BATTLE_TANK = 0x0000080,
  263. // BATTLE_HONOR_AIR_WING = 0x0000100,
  264. // BATTLE_HONOR_SPECIAL_FORCES = 0x0000200,
  265. // BATTLE_HONOR_ENDURANCE = 0x0000400,
  266. // BATTLE_HONOR_CAMPAIGN_USA = 0x0000800,
  267. // BATTLE_HONOR_CAMPAIGN_CHINA = 0x0001000,
  268. // BATTLE_HONOR_CAMPAIGN_GLA = 0x0002000,
  269. // BATTLE_HONOR_BLITZ5 = 0x0004000,
  270. // BATTLE_HONOR_BLITZ10 = 0x0008000,
  271. // BATTLE_HONOR_SOLO_USA_B = 0x0010000,
  272. // BATTLE_HONOR_SOLO_USA_S = 0x0020000,
  273. // BATTLE_HONOR_SOLO_USA_G = 0x0040000,
  274. // BATTLE_HONOR_SOLO_CHINA_B = 0x0080000,
  275. // BATTLE_HONOR_SOLO_CHINA_S = 0x0100000,
  276. // BATTLE_HONOR_SOLO_CHINA_G = 0x0200000,
  277. // BATTLE_HONOR_SOLO_GLA_B = 0x0400000,
  278. // BATTLE_HONOR_SOLO_GLA_S = 0x0800000,
  279. // BATTLE_HONOR_SOLO_GLA_G = 0x1000000,
  280. void BattleHonorTooltip(GameWindow *window,
  281. WinInstanceData *instData,
  282. UnsignedInt mouse)
  283. {
  284. Int x, y, row, col;
  285. x = LOLONGTOSHORT(mouse);
  286. y = HILONGTOSHORT(mouse);
  287. GadgetListBoxGetEntryBasedOnXY(window, x, y, row, col);
  288. if (row == -1 || col == -1)
  289. {
  290. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonors") );
  291. return;
  292. }
  293. Int battleHonor = (Int)GadgetListBoxGetItemData( window, row, col );
  294. if (battleHonor == 0)
  295. {
  296. //DEBUG_CRASH(("No Battle Honor in listbox row %d, col %d!", row, col));
  297. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonors") );
  298. return;
  299. }
  300. Real tooltipWidth = 1.5f;
  301. if (BitTest(battleHonor, BATTLE_HONOR_NOT_GAINED))
  302. {
  303. if(BitTest(battleHonor, BATTLE_HONOR_STREAK_3))
  304. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreak3Disabled"), -1, NULL, tooltipWidth );
  305. else if(BitTest(battleHonor, BATTLE_HONOR_LOYALTY_USA))
  306. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorLoyaltyUSADisabled"), -1, NULL, tooltipWidth );
  307. else if(BitTest(battleHonor, BATTLE_HONOR_LOYALTY_CHINA))
  308. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorLoyaltyChinaDisabled"), -1, NULL, tooltipWidth );
  309. else if(BitTest(battleHonor, BATTLE_HONOR_LOYALTY_GLA))
  310. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorLoyaltyGLADisabled"), -1, NULL, tooltipWidth );
  311. else if(BitTest(battleHonor, BATTLE_HONOR_BATTLE_TANK))
  312. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorBattleTankDisabled"), -1, NULL, tooltipWidth );
  313. else if(BitTest(battleHonor, BATTLE_HONOR_AIR_WING))
  314. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorAirWingDisabled"), -1, NULL, tooltipWidth );
  315. else if(BitTest(battleHonor, BATTLE_HONOR_ENDURANCE))
  316. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorEnduranceDisabled"), -1, NULL, tooltipWidth );
  317. else if(BitTest(battleHonor, BATTLE_HONOR_CAMPAIGN_USA))
  318. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorCampaignUSADisabled"), -1, NULL, tooltipWidth );
  319. else if(BitTest(battleHonor, BATTLE_HONOR_CAMPAIGN_CHINA))
  320. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorCampaignChinaDisabled"), -1, NULL, tooltipWidth );
  321. else if(BitTest(battleHonor, BATTLE_HONOR_CAMPAIGN_GLA))
  322. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorCampaignGLADisabled"), -1, NULL, tooltipWidth );
  323. else if(BitTest(battleHonor, BATTLE_HONOR_BLITZ10))
  324. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorBlitz10Disabled"), -1, NULL, tooltipWidth );
  325. else if(BitTest(battleHonor, BATTLE_HONOR_FAIR_PLAY))
  326. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorFairPlayDisabled"), -1, NULL, tooltipWidth );
  327. else if(BitTest(battleHonor, BATTLE_HONOR_APOCALYPSE))
  328. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorApocalypseDisabled"), -1, NULL, tooltipWidth );
  329. /*
  330. else if(BitTest(battleHonor, BATTLE_HONOR_SOLO_USA_B))
  331. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorSoloUSABDisabled"), -1, NULL, tooltipWidth );
  332. else if(BitTest(battleHonor, BATTLE_HONOR_SOLO_USA_S))
  333. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorSoloUSASDisabled"), -1, NULL, tooltipWidth );
  334. else if(BitTest(battleHonor, BATTLE_HONOR_SOLO_USA_G))
  335. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorSoloUSAGDisabled"), -1, NULL, tooltipWidth );
  336. else if(BitTest(battleHonor, BATTLE_HONOR_SOLO_CHINA_B))
  337. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorSoloChinaBDisabled"), -1, NULL, tooltipWidth );
  338. else if(BitTest(battleHonor, BATTLE_HONOR_SOLO_CHINA_S))
  339. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorSoloChinaSDisabled"), -1, NULL, tooltipWidth );
  340. else if(BitTest(battleHonor, BATTLE_HONOR_SOLO_CHINA_G))
  341. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorSoloChinaGDisabled"), -1, NULL, tooltipWidth );
  342. else if(BitTest(battleHonor, BATTLE_HONOR_SOLO_GLA_B))
  343. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorSoloGLABDisabled"), -1, NULL, tooltipWidth );
  344. else if(BitTest(battleHonor, BATTLE_HONOR_SOLO_GLA_S))
  345. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorSoloGLASDisabled"), -1, NULL, tooltipWidth );
  346. else if(BitTest(battleHonor, BATTLE_HONOR_SOLO_GLA_G))
  347. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorSoloGLAGDisabled"), -1, NULL, tooltipWidth );
  348. */
  349. else if(BitTest(battleHonor, BATTLE_HONOR_CHALLENGE))
  350. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorChallengeDisabled"), -1, NULL, tooltipWidth );
  351. }
  352. else
  353. {
  354. if(BitTest(battleHonor, BATTLE_HONOR_LADDER_CHAMP))
  355. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorLadderChamp"), -1, NULL, tooltipWidth );
  356. else if(BitTest(battleHonor, BATTLE_HONOR_STREAK_3))
  357. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreak3"), -1, NULL, tooltipWidth );
  358. //else if(BitTest(battleHonor, BATTLE_HONOR_STREAK_5))
  359. //TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreak5"), -1, NULL, tooltipWidth );
  360. else if(BitTest(battleHonor, BATTLE_HONOR_STREAK_10))
  361. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreak10"), -1, NULL, tooltipWidth );
  362. else if(BitTest(battleHonor, BATTLE_HONOR_STREAK_25))
  363. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreak25"), -1, NULL, tooltipWidth );
  364. else if(BitTest(battleHonor, BATTLE_HONOR_LOYALTY_USA))
  365. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorLoyaltyUSA"), -1, NULL, tooltipWidth );
  366. else if(BitTest(battleHonor, BATTLE_HONOR_LOYALTY_CHINA))
  367. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorLoyaltyChina"), -1, NULL, tooltipWidth );
  368. else if(BitTest(battleHonor, BATTLE_HONOR_LOYALTY_GLA))
  369. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorLoyaltyGLA"), -1, NULL, tooltipWidth );
  370. else if(BitTest(battleHonor, BATTLE_HONOR_BATTLE_TANK))
  371. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorBattleTank"), -1, NULL, tooltipWidth );
  372. else if(BitTest(battleHonor, BATTLE_HONOR_AIR_WING))
  373. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorAirWing"), -1, NULL, tooltipWidth );
  374. else if(BitTest(battleHonor, BATTLE_HONOR_ENDURANCE))
  375. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorEndurance"), -1, NULL, tooltipWidth );
  376. else if(BitTest(battleHonor, BATTLE_HONOR_CAMPAIGN_USA))
  377. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorCampaignUSA"), -1, NULL, tooltipWidth );
  378. else if(BitTest(battleHonor, BATTLE_HONOR_CAMPAIGN_CHINA))
  379. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorCampaignChina"), -1, NULL, tooltipWidth );
  380. else if(BitTest(battleHonor, BATTLE_HONOR_CAMPAIGN_GLA))
  381. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorCampaignGLA"), -1, NULL, tooltipWidth );
  382. else if(BitTest(battleHonor, BATTLE_HONOR_BLITZ5))
  383. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorBlitz5"), -1, NULL, tooltipWidth );
  384. else if(BitTest(battleHonor, BATTLE_HONOR_BLITZ10))
  385. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorBlitz10"), -1, NULL, tooltipWidth );
  386. else if(BitTest(battleHonor, BATTLE_HONOR_FAIR_PLAY))
  387. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorFairPlay"), -1, NULL, tooltipWidth );
  388. else if(BitTest(battleHonor, BATTLE_HONOR_APOCALYPSE))
  389. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorApocalypse"), -1, NULL, tooltipWidth );
  390. else if(BitTest(battleHonor, BATTLE_HONOR_OFFICERSCLUB))
  391. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorOfficersClub"), -1, NULL, tooltipWidth );
  392. /*
  393. else if(BitTest(battleHonor, BATTLE_HONOR_SOLO_USA_B))
  394. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorSoloUSAB"), -1, NULL, tooltipWidth );
  395. else if(BitTest(battleHonor, BATTLE_HONOR_SOLO_USA_S))
  396. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorSoloUSAS"), -1, NULL, tooltipWidth );
  397. else if(BitTest(battleHonor, BATTLE_HONOR_SOLO_USA_G))
  398. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorSoloUSAG"), -1, NULL, tooltipWidth );
  399. else if(BitTest(battleHonor, BATTLE_HONOR_SOLO_CHINA_B))
  400. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorSoloChinaB"), -1, NULL, tooltipWidth );
  401. else if(BitTest(battleHonor, BATTLE_HONOR_SOLO_CHINA_S))
  402. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorSoloChinaS"), -1, NULL, tooltipWidth );
  403. else if(BitTest(battleHonor, BATTLE_HONOR_SOLO_CHINA_G))
  404. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorSoloChinaG"), -1, NULL, tooltipWidth );
  405. else if(BitTest(battleHonor, BATTLE_HONOR_SOLO_GLA_B))
  406. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorSoloGLAB"), -1, NULL, tooltipWidth );
  407. else if(BitTest(battleHonor, BATTLE_HONOR_SOLO_GLA_S))
  408. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorSoloGLAS"), -1, NULL, tooltipWidth );
  409. else if(BitTest(battleHonor, BATTLE_HONOR_SOLO_GLA_G))
  410. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorSoloGLAG"), -1, NULL, tooltipWidth );
  411. */
  412. else if(BitTest(battleHonor, BATTLE_HONOR_CHALLENGE))
  413. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorChallenge"), -1, NULL, tooltipWidth );
  414. }
  415. }
  416. static Int rowsToSkip = 0;
  417. void ResetBattleHonorInsertion(void)
  418. {
  419. rowsToSkip = 0;
  420. }
  421. void InsertBattleHonor(GameWindow *list, const Image *image, Bool enabled, Int itemData, Int& row, Int& column, UnicodeString text = UnicodeString::TheEmptyString)
  422. {
  423. Int width = MAX_BATTLE_HONOR_IMAGE_WIDTH * (TheDisplay->getWidth() / 800.0f);
  424. Int height = MAX_BATTLE_HONOR_IMAGE_HEIGHT * (TheDisplay->getHeight() / 600.0f);
  425. static Int enabledColor = 0xFFFFFFFF;
  426. static Int disabledColor = GameMakeColor(80, 80, 80, 255);
  427. Int color;
  428. if (enabled)
  429. color = enabledColor;
  430. else
  431. color = disabledColor;
  432. if (!enabled)
  433. itemData |= BATTLE_HONOR_NOT_GAINED;
  434. GadgetListBoxAddEntryImage(list, image, row, column, height, width, TRUE, color);
  435. GadgetListBoxSetItemData(list, (void *)itemData, row, column );
  436. /*
  437. ** removing text, since every place that adds text has alternate displays of the same thing
  438. if (!text.isEmpty())
  439. {
  440. GadgetListBoxAddEntryText(list, text, GameSpyColor[GSCOLOR_DEFAULT], row+1, column, TRUE );
  441. GadgetListBoxSetItemData(list, (void *)itemData, row+1, column );
  442. rowsToSkip++;
  443. }
  444. */
  445. if(++column >= GadgetListBoxGetNumColumns(list))
  446. {
  447. column = 0;
  448. row = row + 1 + rowsToSkip;
  449. rowsToSkip = max(rowsToSkip-1, 0);
  450. }
  451. }
  452. static void populateBattleHonors(const PSPlayerStats& stats, Int battleHonors, Int gamesInRow, Int lastGen, Int challenge, GameWindow *list)
  453. {
  454. if( !list )
  455. return;
  456. list->winSetTooltipFunc(BattleHonorTooltip);
  457. GadgetListBoxReset( list );
  458. Int column = 0;
  459. Int row = 0;
  460. Bool isFairPlayer = FALSE;
  461. Int numGames = 0;
  462. Int numDiscons = 0;
  463. PerGeneralMap::const_iterator it;
  464. for(it = stats.games.begin(); it != stats.games.end(); ++it)
  465. {
  466. numGames += it->second;
  467. }
  468. for(it = stats.discons.begin(); it != stats.discons.end(); ++it)
  469. {
  470. numDiscons += it->second;
  471. }
  472. for(it = stats.desyncs.begin(); it != stats.desyncs.end(); ++it)
  473. {
  474. numDiscons += it->second;
  475. }
  476. if (numGames >= 10 && numDiscons * 10 < numGames)
  477. {
  478. isFairPlayer = TRUE;
  479. }
  480. ResetBattleHonorInsertion();
  481. GadgetListBoxAddEntryImage(list, NULL, 0, 0, 10, 10, TRUE, GameMakeColor(255,255,255,255));
  482. row = 1;
  483. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("FairPlay"), isFairPlayer,
  484. BATTLE_HONOR_FAIR_PLAY, row, column);
  485. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorAirWing"), BitTest(battleHonors, BATTLE_HONOR_AIR_WING),
  486. BATTLE_HONOR_AIR_WING, row, column);
  487. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorBattleTank"), BitTest(battleHonors, BATTLE_HONOR_BATTLE_TANK),
  488. BATTLE_HONOR_BATTLE_TANK, row, column);
  489. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Apocalypse"), BitTest(battleHonors, BATTLE_HONOR_APOCALYPSE),
  490. BATTLE_HONOR_APOCALYPSE, row, column);
  491. if (BitTest(battleHonors, BATTLE_HONOR_BLITZ5))
  492. {
  493. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorBlitz5"), TRUE,
  494. BATTLE_HONOR_BLITZ5, row, column);
  495. }
  496. else if (BitTest(battleHonors, BATTLE_HONOR_BLITZ10))
  497. {
  498. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorBlitz10"), TRUE,
  499. BATTLE_HONOR_BLITZ10, row, column);
  500. }
  501. else
  502. {
  503. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorBlitz10"), FALSE,
  504. BATTLE_HONOR_BLITZ10, row, column);
  505. }
  506. GadgetListBoxAddEntryImage(list, NULL, 2, 0, 10, 10, TRUE, GameMakeColor(255,255,255,255));
  507. row = 3;
  508. UnicodeString uStr;
  509. uStr.format(L"%10d", stats.maxWinsInARow);
  510. if(BitTest(battleHonors, BATTLE_HONOR_STREAK_25))
  511. {
  512. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorStreak_G"), TRUE,
  513. BATTLE_HONOR_STREAK_25, row, column, uStr);
  514. }
  515. else if(BitTest(battleHonors, BATTLE_HONOR_STREAK_10))
  516. {
  517. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorStreak_S"), TRUE,
  518. BATTLE_HONOR_STREAK_10, row, column, uStr);
  519. }
  520. else if(BitTest(battleHonors, BATTLE_HONOR_STREAK_3))
  521. {
  522. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorStreak_B"), TRUE,
  523. BATTLE_HONOR_STREAK_3, row, column, uStr);
  524. }
  525. else
  526. {
  527. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorStreak_B"), FALSE,
  528. BATTLE_HONOR_STREAK_3, row, column);
  529. }
  530. /*
  531. Bool isLoyal;
  532. isLoyal = ThePlayerTemplateStore->getNthPlayerTemplate(lastGen)->getSide().compareNoCase( "america") == 0 && gamesInRow >= 20;
  533. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Loyalty_USA"), isLoyal,
  534. BATTLE_HONOR_LOYALTY_USA, row, column);
  535. isLoyal = ThePlayerTemplateStore->getNthPlayerTemplate(lastGen)->getSide().compareNoCase( "china") == 0 && gamesInRow >= 20;
  536. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Loyalty_China"), isLoyal,
  537. BATTLE_HONOR_LOYALTY_CHINA, row, column);
  538. isLoyal = ThePlayerTemplateStore->getNthPlayerTemplate(lastGen)->getSide().compareNoCase( "gla") == 0 && gamesInRow >= 20;
  539. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Loyalty_GLA"), isLoyal,
  540. BATTLE_HONOR_LOYALTY_GLA, row, column);
  541. */
  542. //insertBattleHonor(list, TheMappedImageCollection->findImageByName("Endurance"), BitTest(battleHonors, BATTLE_HONOR_ENDURANCE),
  543. //BATTLE_HONOR_ENDURANCE, row, column);
  544. /*
  545. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Campaign_USA"), BitTest(battleHonors, BATTLE_HONOR_CAMPAIGN_USA),
  546. BATTLE_HONOR_CAMPAIGN_USA, row, column);
  547. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Campaign_China"), BitTest(battleHonors, BATTLE_HONOR_CAMPAIGN_CHINA),
  548. BATTLE_HONOR_CAMPAIGN_CHINA, row, column);
  549. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Campaign_GLA"), BitTest(battleHonors, BATTLE_HONOR_CAMPAIGN_GLA),
  550. BATTLE_HONOR_CAMPAIGN_GLA, row, column);
  551. */
  552. /*
  553. if(BitTest(challenge, BH_CHALLENGE_MASK_7))
  554. {
  555. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorChallenge7"), TRUE,
  556. BATTLE_HONOR_CHALLENGE, row, column);
  557. }
  558. else if (BitTest(challenge, BH_CHALLENGE_MASK_6))
  559. {
  560. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorChallenge6"), TRUE,
  561. BATTLE_HONOR_CHALLENGE, row, column);
  562. }
  563. else if (BitTest(challenge, BH_CHALLENGE_MASK_5))
  564. {
  565. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorChallenge5"), TRUE,
  566. BATTLE_HONOR_CHALLENGE, row, column);
  567. }
  568. else if (BitTest(challenge, BH_CHALLENGE_MASK_4))
  569. {
  570. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorChallenge4"), TRUE,
  571. BATTLE_HONOR_CHALLENGE, row, column);
  572. }
  573. else if (BitTest(challenge, BH_CHALLENGE_MASK_3))
  574. {
  575. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorChallenge3"), TRUE,
  576. BATTLE_HONOR_CHALLENGE, row, column);
  577. }
  578. else if (BitTest(challenge, BH_CHALLENGE_MASK_2))
  579. {
  580. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorChallenge2"), TRUE,
  581. BATTLE_HONOR_CHALLENGE, row, column);
  582. }
  583. else if (BitTest(challenge, BH_CHALLENGE_MASK_1))
  584. {
  585. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorChallenge1"), TRUE,
  586. BATTLE_HONOR_CHALLENGE, row, column);
  587. }
  588. else
  589. {
  590. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorChallenge1"), FALSE,
  591. BATTLE_HONOR_CHALLENGE, row, column);
  592. }
  593. */
  594. if (TheGameSpyInfo->didPlayerPreorder(stats.id))
  595. {
  596. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("OfficersClub"), TRUE,
  597. BATTLE_HONOR_OFFICERSCLUB, row, column);
  598. }
  599. }
  600. Int GetFavoriteSide( const PSPlayerStats& stats )
  601. {
  602. PerGeneralMap::const_iterator it;
  603. Int numGames = 0;
  604. Int favorite = 0;
  605. for(it =stats.games.begin(); it != stats.games.end(); ++it)
  606. {
  607. if(it->second >= numGames)
  608. {
  609. numGames = it->second;
  610. favorite = it->first;
  611. }
  612. }
  613. if(numGames == 0)
  614. return -1;
  615. else if( stats.gamesAsRandom >= numGames )
  616. return 0;
  617. return favorite;
  618. }
  619. Int CalculateRank( const PSPlayerStats& stats )
  620. {
  621. if(stats.id == 0 || !TheRankPointValues)
  622. return 0;
  623. PerGeneralMap::const_iterator it;
  624. Int rankPoints = 0;
  625. Int numGames = 0;
  626. for(it =stats.wins.begin(); it != stats.wins.end(); ++it)
  627. {
  628. numGames += it->second;
  629. }
  630. rankPoints += (numGames * TheRankPointValues->m_winMultiplier);
  631. numGames = 0;
  632. for(it =stats.losses.begin(); it != stats.losses.end(); ++it)
  633. {
  634. numGames += it->second;
  635. }
  636. rankPoints += (numGames * TheRankPointValues->m_lostMultiplier);
  637. numGames = 0;
  638. for(it =stats.duration.begin(); it != stats.duration.end(); ++it)
  639. {
  640. numGames += it->second;
  641. }
  642. rankPoints += (numGames / 60) * TheRankPointValues->m_hourSpentOnlineMultiplier;
  643. numGames = 0;
  644. for(it =stats.discons.begin(); it != stats.discons.end(); ++it)
  645. {
  646. numGames += it->second;
  647. }
  648. for(it =stats.desyncs.begin(); it != stats.desyncs.end(); ++it)
  649. {
  650. numGames += it->second;
  651. }
  652. rankPoints += numGames * TheRankPointValues->m_disconnectMultiplier;
  653. if(BitTest(stats.battleHonors, BATTLE_HONOR_CAMPAIGN_USA | BATTLE_HONOR_CAMPAIGN_CHINA |BATTLE_HONOR_CAMPAIGN_GLA))
  654. {
  655. rankPoints += 1 * TheRankPointValues->m_completedSoloCampaigns;
  656. }
  657. rankPoints = max(0, rankPoints); // clip off negative values, since discons can push us below 0.
  658. return rankPoints;
  659. }
  660. static GameWindow* findWindow(GameWindow *parent, AsciiString baseWindow, AsciiString gadgetName)
  661. {
  662. AsciiString fullPath;
  663. fullPath.format("%s:%s", baseWindow.str(), gadgetName.str());
  664. GameWindow *res = TheWindowManager->winGetWindowFromId(parent, NAMEKEY(fullPath));
  665. DEBUG_ASSERTLOG(res, ("Cannot find window %s\n", fullPath.str()));
  666. return res;
  667. }
  668. void PopulatePlayerInfoWindows( AsciiString parentWindowName )
  669. {
  670. Int lookupID = TheGameSpyInfo->getLocalProfileID();
  671. if(parentWindowName == "PopupPlayerInfo.wnd")
  672. {
  673. lookupID = lookAtPlayerID;
  674. if (lookAtPlayerID <= 0 || !parent)
  675. return;
  676. }
  677. PSPlayerStats stats = TheGameSpyPSMessageQueue->findPlayerStatsByID(lookupID);
  678. Bool weHaveStats = (stats.id != 0);
  679. // if we don't have the stats from the server, see if we have cached stats
  680. if( !weHaveStats && lookupID == TheGameSpyInfo->getLocalProfileID() )
  681. {
  682. stats = TheGameSpyInfo->getCachedLocalPlayerStats();
  683. weHaveStats = TRUE;
  684. }
  685. Int currentRank = 0;
  686. Int rankPoints = CalculateRank(stats);
  687. Int i = 0;
  688. while( rankPoints >= TheRankPointValues->m_ranks[i + 1])
  689. ++i;
  690. currentRank = i;
  691. PerGeneralMap::iterator it;
  692. Int numWins = 0;
  693. Int numLosses = 0;
  694. Int numDiscons = 0;
  695. Int numGames = 0;
  696. for(it =stats.wins.begin(); it != stats.wins.end(); ++it)
  697. {
  698. numWins += it->second;
  699. }
  700. for(it =stats.losses.begin(); it != stats.losses.end(); ++it)
  701. {
  702. numLosses += it->second;
  703. }
  704. for(it =stats.discons.begin(); it != stats.discons.end(); ++it)
  705. {
  706. numDiscons += it->second;
  707. }
  708. for(it =stats.desyncs.begin(); it != stats.desyncs.end(); ++it)
  709. {
  710. numDiscons += it->second;
  711. }
  712. numDiscons += GetAdditionalDisconnectsFromUserFile(lookupID);
  713. numGames = numWins + numLosses + numDiscons;
  714. GameWindow *win = NULL;
  715. UnicodeString uStr;
  716. win = findWindow(NULL, parentWindowName, "StaticTextPlayerStatisticsLabel");
  717. if(win)
  718. {
  719. AsciiString localeID = "WOL:Locale00";
  720. if (stats.locale >= LOC_MIN && stats.locale <= LOC_MAX)
  721. localeID.format("WOL:Locale%2.2d", stats.locale);
  722. uStr.format(TheGameText->fetch("GUI:PlayerStatistics"), lookAtPlayerName.c_str(), TheGameText->fetch(localeID).str());
  723. GadgetStaticTextSetText(win, uStr);
  724. }
  725. win = findWindow(NULL, parentWindowName, "StaticTextGamesPlayedValue");
  726. if(win)
  727. {
  728. uStr.format(L"%d", numGames);
  729. GadgetStaticTextSetText(win, uStr);
  730. }
  731. win = findWindow(NULL, parentWindowName, "StaticTextWinsValue");
  732. if(win)
  733. {
  734. uStr.format(L"%d", numWins);
  735. GadgetStaticTextSetText(win, uStr);
  736. }
  737. win = findWindow(NULL, parentWindowName, "StaticTextLossesValue");
  738. if(win)
  739. {
  740. uStr.format(L"%d", numLosses);
  741. GadgetStaticTextSetText(win, uStr);
  742. }
  743. win = findWindow(NULL, parentWindowName, "StaticTextDisconnectsValue");
  744. if(win)
  745. {
  746. uStr.format(L"%d", numDiscons);
  747. GadgetStaticTextSetText(win, uStr);
  748. }
  749. win = findWindow(NULL, parentWindowName, "StaticTextBestStreakValue");
  750. if (win)
  751. {
  752. uStr.format(L"%d", stats.maxWinsInARow);
  753. GadgetStaticTextSetText(win, uStr);
  754. }
  755. win = findWindow(NULL, parentWindowName, "StaticTextStreak");
  756. if (win)
  757. {
  758. if (stats.lossesInARow > 0)
  759. {
  760. GadgetStaticTextSetText(win, TheGameText->fetch("GUI:CurrentLossStreak"));
  761. }
  762. else
  763. {
  764. GadgetStaticTextSetText(win, TheGameText->fetch("GUI:CurrentWinStreak"));
  765. }
  766. }
  767. win = findWindow(NULL, parentWindowName, "StaticTextStreakValue");
  768. if(win)
  769. {
  770. Int streak = max(stats.lossesInARow, stats.winsInARow);
  771. uStr.format(L"%d", streak);
  772. GadgetStaticTextSetText(win, uStr);
  773. }
  774. AsciiString favoriteSide = "Random";
  775. win = findWindow(NULL, parentWindowName, "StaticTextFavoriteSideValue");
  776. {
  777. Int numGames = 0;
  778. Int favorite = 0;
  779. for(it =stats.games.begin(); it != stats.games.end(); ++it)
  780. {
  781. if(it->second >= numGames)
  782. {
  783. numGames = it->second;
  784. favorite = it->first;
  785. }
  786. }
  787. if(numGames == 0)
  788. GadgetStaticTextSetText(win, TheGameText->fetch("GUI:None"));
  789. else if( stats.gamesAsRandom >= numGames )
  790. GadgetStaticTextSetText(win, TheGameText->fetch("GUI:Random"));
  791. else
  792. {
  793. const PlayerTemplate *fac = ThePlayerTemplateStore->getNthPlayerTemplate(favorite);
  794. if (fac)
  795. {
  796. AsciiString side;
  797. side.format("SIDE:%s", fac->getSide().str());
  798. GadgetStaticTextSetText(win, TheGameText->fetch(side));
  799. favoriteSide = fac->getSide();
  800. }
  801. }
  802. }
  803. win = findWindow(NULL, parentWindowName, "StaticTextTotalKillsValue");
  804. if(win)
  805. {
  806. Int numGames = 0;
  807. for(it =stats.unitsKilled.begin(); it != stats.unitsKilled.end(); ++it)
  808. {
  809. numGames += it->second;
  810. }
  811. uStr.format(L"%d", numGames);
  812. GadgetStaticTextSetText(win, uStr);
  813. }
  814. win = findWindow(NULL, parentWindowName, "StaticTextTotalDeathsValue");
  815. if(win)
  816. {
  817. Int numGames = 0;
  818. for(it =stats.unitsLost.begin(); it != stats.unitsLost.end(); ++it)
  819. {
  820. numGames += it->second;
  821. }
  822. uStr.format(L"%d", numGames);
  823. GadgetStaticTextSetText(win, uStr);
  824. }
  825. win = findWindow(NULL, parentWindowName, "StaticTextTotalBuiltValue");
  826. if(win)
  827. {
  828. Int numGames = 0;
  829. for(it =stats.unitsBuilt.begin(); it != stats.unitsBuilt.end(); ++it)
  830. {
  831. numGames += it->second;
  832. }
  833. uStr.format(L"%d", numGames);
  834. GadgetStaticTextSetText(win, uStr);
  835. }
  836. win = findWindow(NULL, parentWindowName, "StaticTextBuildingsKilledValue");
  837. if(win)
  838. {
  839. Int numGames = 0;
  840. for(it =stats.buildingsKilled.begin(); it != stats.buildingsKilled.end(); ++it)
  841. {
  842. numGames += it->second;
  843. }
  844. uStr.format(L"%d", numGames);
  845. GadgetStaticTextSetText(win, uStr);
  846. }
  847. win = findWindow(NULL, parentWindowName, "StaticTextBuildingsLostValue");
  848. if(win)
  849. {
  850. Int numGames = 0;
  851. for(it =stats.buildingsLost.begin(); it != stats.buildingsLost.end(); ++it)
  852. {
  853. numGames += it->second;
  854. }
  855. uStr.format(L"%d", numGames);
  856. GadgetStaticTextSetText(win, uStr);
  857. }
  858. win = findWindow(NULL, parentWindowName, "StaticTextBuildingsBuiltValue");
  859. if(win)
  860. {
  861. Int numGames = 0;
  862. for(it =stats.buildingsBuilt.begin(); it != stats.buildingsBuilt.end(); ++it)
  863. {
  864. numGames += it->second;
  865. }
  866. uStr.format(L"%d", numGames);
  867. GadgetStaticTextSetText(win, uStr);
  868. }
  869. win = findWindow(NULL, parentWindowName, "StaticTextWinPercentValue");
  870. if(win)
  871. {
  872. uStr.format(TheGameText->fetch("GUI:WinPercent"), REAL_TO_INT(numWins/(Real)numGames*100.0f));
  873. GadgetStaticTextSetText(win, uStr);
  874. }
  875. win = findWindow(NULL, parentWindowName, "ProgressBarRank");
  876. if(win && TheRankPointValues)
  877. {
  878. if( currentRank == MAX_RANKS - 1)
  879. {
  880. // we've reached the max rank
  881. win->winHide(TRUE);
  882. }
  883. else
  884. {
  885. GadgetProgressBarSetProgress(win, 100 * INT_TO_REAL(rankPoints - TheRankPointValues->m_ranks[currentRank])/( TheRankPointValues->m_ranks[currentRank + 1] - TheRankPointValues->m_ranks[currentRank]));
  886. }
  887. }
  888. win = findWindow(NULL, parentWindowName, "WinRank");
  889. if(win && TheRankPointValues)
  890. {
  891. if (rankPoints == 0)
  892. win->winSetEnabledImage(0, lookupRankImage(AsciiString::TheEmptyString, 0));
  893. else
  894. win->winSetEnabledImage(0, lookupRankImage(favoriteSide, currentRank));
  895. }
  896. win = findWindow(NULL, parentWindowName, "StaticTextRank");
  897. if(win)
  898. {
  899. AsciiString rankStr;
  900. rankStr.format("GUI:GSRank%d", currentRank);
  901. GadgetStaticTextSetText(win, TheGameText->fetch(rankStr));
  902. }
  903. win = findWindow(NULL, parentWindowName, "StaticTextInProgress");
  904. if (win)
  905. {
  906. if (weHaveStats)
  907. {
  908. win->winHide(TRUE);
  909. }
  910. else
  911. {
  912. win->winHide(FALSE);
  913. GadgetStaticTextSetText(win, TheGameText->fetch("GUI:FetchingPlayerInfo"));
  914. }
  915. }
  916. win = findWindow(NULL, parentWindowName, "ListboxInfo");
  917. if(win)
  918. {
  919. populateBattleHonors(stats, stats.battleHonors,stats.gamesInRowWithLastGeneral,stats.lastGeneral,stats.challengeMedals, win);
  920. }
  921. }
  922. void HandlePersistentStorageResponses( void )
  923. {
  924. if (TheGameSpyPSMessageQueue)
  925. {
  926. PSResponse resp;
  927. if (TheGameSpyPSMessageQueue->getResponse( resp ))
  928. {
  929. switch (resp.responseType)
  930. {
  931. case PSResponse::PSRESPONSE_COULDNOTCONNECT:
  932. {
  933. // message box & hide the window
  934. GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:PSCannotConnect"), NULL);
  935. GameSpyCloseOverlay(GSOVERLAY_PLAYERINFO);
  936. }
  937. break;
  938. case PSResponse::PSRESPONSE_PREORDER:
  939. {
  940. if (resp.preorder)
  941. {
  942. SetUnsignedIntInRegistry("", "Preorder", 1);
  943. TheGameSpyInfo->markPlayerAsPreorder( TheGameSpyInfo->getLocalProfileID() );
  944. // force an update of our shtuff
  945. PSResponse newResp;
  946. newResp.responseType = PSResponse::PSRESPONSE_PLAYERSTATS;
  947. newResp.player = TheGameSpyPSMessageQueue->findPlayerStatsByID(TheGameSpyInfo->getLocalProfileID());
  948. TheGameSpyPSMessageQueue->addResponse(newResp);
  949. }
  950. }
  951. break;
  952. case PSResponse::PSRESPONSE_PLAYERSTATS:
  953. {
  954. DEBUG_LOG(("LocalProfileID %d, resp.player.id %d, resp.player.locale %d\n", TheGameSpyInfo->getLocalProfileID(), resp.player.id, resp.player.locale));
  955. /*
  956. if(resp.player.id == TheGameSpyInfo->getLocalProfileID() && resp.player.locale < LOC_MIN)
  957. {
  958. if (!GameSpyIsOverlayOpen(GSOVERLAY_LOCALESELECT))
  959. GameSpyOpenOverlay(GSOVERLAY_LOCALESELECT);
  960. }
  961. else
  962. */
  963. if (resp.player.id == TheGameSpyInfo->getLocalProfileID())
  964. {
  965. PeerRequest req;
  966. req.peerRequestType = PeerRequest::PEERREQUEST_PUSHSTATS;
  967. GameSpyMiscPreferences cPref;
  968. req.statsToPush.locale = cPref.getLocale();
  969. Int wins = 0, losses = 0;
  970. PerGeneralMap::const_iterator it;
  971. for (it = resp.player.wins.begin(); it != resp.player.wins.end(); ++it)
  972. {
  973. wins += it->second;
  974. }
  975. for (it = resp.player.losses.begin(); it != resp.player.losses.end(); ++it)
  976. {
  977. losses += it->second;
  978. }
  979. req.statsToPush.wins = wins;
  980. req.statsToPush.losses = losses;
  981. req.statsToPush.rankPoints = CalculateRank( resp.player );
  982. Int numGames = 0;
  983. Int favorite = 0;
  984. for(it =resp.player.games.begin(); it != resp.player.games.end(); ++it)
  985. {
  986. if(it->second >= numGames)
  987. {
  988. numGames = it->second;
  989. favorite = it->first;
  990. }
  991. }
  992. if(numGames == 0)
  993. req.statsToPush.side = 0;
  994. else if( resp.player.gamesAsRandom >= numGames )
  995. req.statsToPush.side = 0;
  996. else
  997. req.statsToPush.side = favorite;
  998. Bool isPreorder = TheGameSpyInfo->didPlayerPreorder( TheGameSpyInfo->getLocalProfileID() );
  999. req.statsToPush.preorder = isPreorder;
  1000. DEBUG_LOG(("PEERREQUEST_PUSHSTATS: stats will be %d,%d,%d,%d,%d,%d\n",
  1001. req.statsToPush.locale, req.statsToPush.wins, req.statsToPush.losses, req.statsToPush.rankPoints, req.statsToPush.side, req.statsToPush.preorder));
  1002. TheGameSpyPeerMessageQueue->addRequest(req);
  1003. }
  1004. TheGameSpyPSMessageQueue->trackPlayerStats(resp.player);
  1005. if (resp.player.id == TheGameSpyInfo->getLocalProfileID())
  1006. {
  1007. UpdateLocalPlayerStats();
  1008. }
  1009. DEBUG_LOG(("PopulatePlayerInfoWindows() - lookAtPlayerID is %d, got %d\n", lookAtPlayerID, resp.player.id));
  1010. PopulatePlayerInfoWindows("PopupPlayerInfo.wnd");
  1011. //GadgetListBoxAddEntryText(listboxInfo, UnicodeString(L"Got info!"), GameSpyColor[GSCOLOR_DEFAULT], -1);
  1012. // also update info for player list in lobby
  1013. PlayerInfoMap::iterator it = TheGameSpyInfo->getPlayerInfoMap()->begin();
  1014. while (it != TheGameSpyInfo->getPlayerInfoMap()->end())
  1015. {
  1016. PlayerInfo *info = &(it->second);
  1017. if (info && info->m_profileID == resp.player.id)
  1018. {
  1019. // update m_wins, m_losses, m_rankPoints
  1020. Int wins = 0, losses = 0;
  1021. PerGeneralMap::const_iterator it;
  1022. for (it = resp.player.wins.begin(); it != resp.player.wins.end(); ++it)
  1023. {
  1024. wins += it->second;
  1025. }
  1026. for (it = resp.player.losses.begin(); it != resp.player.losses.end(); ++it)
  1027. {
  1028. losses += it->second;
  1029. }
  1030. info->m_wins = wins;
  1031. info->m_losses = losses;
  1032. info->m_rankPoints = CalculateRank( resp.player );
  1033. Int numGames = 0;
  1034. Int favorite = 0;
  1035. for(it = resp.player.games.begin(); it != resp.player.games.end(); ++it)
  1036. {
  1037. if(it->second >= numGames)
  1038. {
  1039. numGames = it->second;
  1040. favorite = it->first;
  1041. }
  1042. }
  1043. if(numGames == 0)
  1044. info->m_side = 0;
  1045. else if( resp.player.gamesAsRandom >= numGames )
  1046. info->m_side = 0;
  1047. else
  1048. info->m_side = favorite;
  1049. PeerResponse r;
  1050. r.peerResponseType = PeerResponse::PEERRESPONSE_PLAYERINFO;
  1051. r.nick = info->m_name.str();
  1052. r.player.profileID = info->m_profileID;
  1053. r.player.flags = info->m_flags;
  1054. r.player.wins = info->m_wins;
  1055. r.player.losses = info->m_losses;
  1056. r.locale = info->m_locale.str();
  1057. r.player.rankPoints = info->m_rankPoints;
  1058. r.player.side = info->m_side;
  1059. r.player.preorder = info->m_preorder;
  1060. TheGameSpyPeerMessageQueue->addResponse(r);
  1061. break;
  1062. }
  1063. ++it;
  1064. }
  1065. }
  1066. break;
  1067. }
  1068. }
  1069. }
  1070. }
  1071. //-------------------------------------------------------------------------------------------------
  1072. /** Initialize the Overlay */
  1073. //-------------------------------------------------------------------------------------------------
  1074. void GameSpyPlayerInfoOverlayInit( WindowLayout *layout, void *userData )
  1075. {
  1076. parentID = TheNameKeyGenerator->nameToKey( "PopupPlayerInfo.wnd:PopupParent" );
  1077. buttonCloseID = TheNameKeyGenerator->nameToKey( "PopupPlayerInfo.wnd:ButtonClose" );
  1078. buttonBuddiesID = TheNameKeyGenerator->nameToKey( "PopupPlayerInfo.wnd:ButtonCommunicator" );
  1079. listboxInfoID = TheNameKeyGenerator->nameToKey( "PopupPlayerInfo.wnd:ListboxInfo" );
  1080. //buttonOptionsID = TheNameKeyGenerator->nameToKey( "PopupPlayerInfo.wnd:ButtonOptions" );
  1081. buttonSetLocaleID = TheNameKeyGenerator->nameToKey( "PopupPlayerInfo.wnd:ButtonSetLocale" );
  1082. buttonDeleteAccountID = TheNameKeyGenerator->nameToKey( "PopupPlayerInfo.wnd:ButtonDeleteAccount" );
  1083. checkBoxAsianFontID = TheNameKeyGenerator->nameToKey( "PopupPlayerInfo.wnd:CheckBoxAsianText" );
  1084. checkBoxNonAsianFontID = TheNameKeyGenerator->nameToKey( "PopupPlayerInfo.wnd:CheckBoxNonAsianText" );
  1085. parent = TheWindowManager->winGetWindowFromId( NULL, parentID );
  1086. buttonClose = TheWindowManager->winGetWindowFromId( parent, buttonCloseID);
  1087. buttonBuddies = TheWindowManager->winGetWindowFromId( parent, buttonBuddiesID);
  1088. listboxInfo = TheWindowManager->winGetWindowFromId( parent, listboxInfoID);
  1089. //buttonbuttonOptions = TheWindowManager->winGetWindowFromId( parent, buttonOptionsID);
  1090. buttonSetLocale = TheWindowManager->winGetWindowFromId( parent, buttonSetLocaleID);
  1091. buttonDeleteAccount = TheWindowManager->winGetWindowFromId( parent, buttonDeleteAccountID);
  1092. checkBoxAsianFont = TheWindowManager->winGetWindowFromId( parent, checkBoxAsianFontID);
  1093. checkBoxNonAsianFont = TheWindowManager->winGetWindowFromId( parent, checkBoxNonAsianFontID);
  1094. // Show Menu
  1095. layout->hide( FALSE );
  1096. // Set Keyboard to Main Parent
  1097. TheWindowManager->winSetFocus( parent );
  1098. isOverlayActive = true;
  1099. //GadgetListBoxAddEntryText(listboxInfo, UnicodeString(L"Working"), GameSpyColor[GSCOLOR_DEFAULT], -1);
  1100. GameSpyCloseOverlay(GSOVERLAY_BUDDY);
  1101. raiseMessageBox = true;
  1102. PopulatePlayerInfoWindows("PopupPlayerInfo.wnd");
  1103. // we're on the myinfo screen
  1104. if(lookAtPlayerID == TheGameSpyInfo->getLocalProfileID())
  1105. {
  1106. //buttonbuttonOptions->winHide(FALSE);
  1107. buttonSetLocale->winHide(FALSE);
  1108. buttonDeleteAccount->winHide(TRUE); // set back to false when we have this worked out.
  1109. checkBoxAsianFont->winHide(FALSE);
  1110. checkBoxNonAsianFont->winHide(FALSE);
  1111. }
  1112. else
  1113. {
  1114. //buttonbuttonOptions->winHide(TRUE);
  1115. buttonSetLocale->winHide(TRUE);
  1116. buttonDeleteAccount->winHide(TRUE);
  1117. checkBoxAsianFont->winHide(TRUE);
  1118. checkBoxNonAsianFont->winHide(TRUE);
  1119. }
  1120. // set the asian check boxes
  1121. CustomMatchPreferences pref;
  1122. GadgetCheckBoxSetChecked(checkBoxAsianFont,!pref.getDisallowAsianText());
  1123. GadgetCheckBoxSetChecked(checkBoxNonAsianFont,!pref.getDisallowNonAsianText());
  1124. OSVERSIONINFO osvi;
  1125. osvi.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
  1126. if (GetVersionEx(&osvi))
  1127. { //check if we're running Win9x variant since they may need different fonts
  1128. if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
  1129. {
  1130. if (checkBoxAsianFont)
  1131. checkBoxAsianFont->winEnable(FALSE);
  1132. if (checkBoxNonAsianFont)
  1133. checkBoxNonAsianFont->winEnable(FALSE);
  1134. }
  1135. }
  1136. //TheWindowManager->winSetModal(parent);
  1137. } // GameSpyPlayerInfoOverlayInit
  1138. //-------------------------------------------------------------------------------------------------
  1139. /** Overlay shutdown method */
  1140. //-------------------------------------------------------------------------------------------------
  1141. void GameSpyPlayerInfoOverlayShutdown( WindowLayout *layout, void *userData )
  1142. {
  1143. // hide menu
  1144. layout->hide( TRUE );
  1145. parent = NULL;
  1146. // our shutdown is complete
  1147. isOverlayActive = false;
  1148. } // GameSpyPlayerInfoOverlayShutdown
  1149. //-------------------------------------------------------------------------------------------------
  1150. /** Overlay update method */
  1151. //-------------------------------------------------------------------------------------------------
  1152. void GameSpyPlayerInfoOverlayUpdate( WindowLayout * layout, void *userData)
  1153. {
  1154. if (raiseMessageBox)
  1155. RaiseGSMessageBox();
  1156. raiseMessageBox = false;
  1157. }// GameSpyPlayerInfoOverlayUpdate
  1158. //-------------------------------------------------------------------------------------------------
  1159. /** Overlay input callback */
  1160. //-------------------------------------------------------------------------------------------------
  1161. WindowMsgHandledType GameSpyPlayerInfoOverlayInput( GameWindow *window, UnsignedInt msg,
  1162. WindowMsgData mData1, WindowMsgData mData2 )
  1163. {
  1164. switch( msg )
  1165. {
  1166. // --------------------------------------------------------------------------------------------
  1167. case GWM_CHAR:
  1168. {
  1169. UnsignedByte key = mData1;
  1170. UnsignedByte state = mData2;
  1171. switch( key )
  1172. {
  1173. // ----------------------------------------------------------------------------------------
  1174. case KEY_ESC:
  1175. {
  1176. //
  1177. // send a simulated selected event to the parent window of the
  1178. // back/exit button
  1179. //
  1180. if( BitTest( state, KEY_STATE_UP ) )
  1181. {
  1182. TheWindowManager->winSendSystemMsg( window, GBM_SELECTED,
  1183. (WindowMsgData)buttonClose, buttonCloseID );
  1184. } // end if
  1185. // don't let key fall through anywhere else
  1186. return MSG_HANDLED;
  1187. } // end escape
  1188. } // end switch( key )
  1189. } // end char
  1190. } // end switch( msg )
  1191. return MSG_IGNORED;
  1192. }// GameSpyPlayerInfoOverlayInput
  1193. void messageBoxYes( void );
  1194. //-------------------------------------------------------------------------------------------------
  1195. /** Overlay window system callback */
  1196. //-------------------------------------------------------------------------------------------------
  1197. WindowMsgHandledType GameSpyPlayerInfoOverlaySystem( GameWindow *window, UnsignedInt msg,
  1198. WindowMsgData mData1, WindowMsgData mData2 )
  1199. {
  1200. UnicodeString txtInput;
  1201. switch( msg )
  1202. {
  1203. case GWM_CREATE:
  1204. {
  1205. break;
  1206. } // case GWM_DESTROY:
  1207. case GWM_DESTROY:
  1208. {
  1209. break;
  1210. } // case GWM_DESTROY:
  1211. case GWM_INPUT_FOCUS:
  1212. {
  1213. // if we're givin the opportunity to take the keyboard focus we must say we want it
  1214. if( mData1 == TRUE )
  1215. *(Bool *)mData2 = TRUE;
  1216. return MSG_HANDLED;
  1217. }//case GWM_INPUT_FOCUS:
  1218. case GBM_SELECTED:
  1219. {
  1220. GameWindow *control = (GameWindow *)mData1;
  1221. Int controlID = control->winGetWindowId();
  1222. if (controlID == buttonCloseID)
  1223. {
  1224. RefreshGameListBoxes();
  1225. GameSpyCloseOverlay( GSOVERLAY_PLAYERINFO );
  1226. }
  1227. else if (controlID == buttonBuddiesID)
  1228. {
  1229. RefreshGameListBoxes();
  1230. //GameSpyCloseOverlay( GSOVERLAY_PLAYERINFO );
  1231. GameSpyOpenOverlay( GSOVERLAY_BUDDY );
  1232. }
  1233. // else if (controlID == buttonOptionsID)
  1234. // {
  1235. // RefreshGameListBoxes();
  1236. // GameSpyCloseOverlay( GSOVERLAY_PLAYERINFO );
  1237. // GameSpyOpenOverlay( GSOVERLAY_OPTIONS );
  1238. // }
  1239. else if (controlID == buttonSetLocaleID)
  1240. {
  1241. RefreshGameListBoxes();
  1242. GameSpyCloseOverlay( GSOVERLAY_PLAYERINFO );
  1243. if (!GameSpyIsOverlayOpen(GSOVERLAY_LOCALESELECT))
  1244. GameSpyOpenOverlay( GSOVERLAY_LOCALESELECT );
  1245. ReOpenPlayerInfo();
  1246. }
  1247. else if (controlID == buttonDeleteAccountID)
  1248. {
  1249. RefreshGameListBoxes();
  1250. GameSpyCloseOverlay( GSOVERLAY_PLAYERINFO );
  1251. MessageBoxYesNo(TheGameText->fetch("GUI:DeleteAccount"), TheGameText->fetch("GUI:AreYouSureDeleteAccount"),messageBoxYes, NULL);
  1252. }
  1253. else if (controlID == checkBoxAsianFontID)
  1254. {
  1255. Bool isChecked = !GadgetCheckBoxIsChecked(control);
  1256. CustomMatchPreferences pref;
  1257. pref.setDisallowAsianText(isChecked);
  1258. pref.write();
  1259. if(TheGameSpyInfo)
  1260. TheGameSpyInfo->setDisallowAsianText(isChecked);
  1261. if(isChecked && !GadgetCheckBoxIsChecked(checkBoxNonAsianFont))
  1262. {
  1263. GadgetCheckBoxSetChecked(checkBoxNonAsianFont, TRUE);
  1264. CustomMatchPreferences pref;
  1265. pref.setDisallowNonAsianText(FALSE);
  1266. pref.write();
  1267. if(TheGameSpyInfo)
  1268. TheGameSpyInfo->setDisallowNonAsianText(FALSE);
  1269. }
  1270. }
  1271. else if (controlID == checkBoxNonAsianFontID)
  1272. {
  1273. Bool isChecked = !GadgetCheckBoxIsChecked(control);
  1274. CustomMatchPreferences pref;
  1275. pref.setDisallowNonAsianText(isChecked);
  1276. pref.write();
  1277. if(TheGameSpyInfo)
  1278. TheGameSpyInfo->setDisallowNonAsianText(isChecked);
  1279. if(isChecked && !GadgetCheckBoxIsChecked(checkBoxAsianFont))
  1280. {
  1281. GadgetCheckBoxSetChecked(checkBoxAsianFont, TRUE);
  1282. CustomMatchPreferences pref;
  1283. pref.setDisallowAsianText(FALSE);
  1284. pref.write();
  1285. if(TheGameSpyInfo)
  1286. TheGameSpyInfo->setDisallowAsianText(FALSE);
  1287. }
  1288. }
  1289. break;
  1290. }// case GBM_SELECTED:
  1291. default:
  1292. return MSG_IGNORED;
  1293. }//Switch
  1294. return MSG_HANDLED;
  1295. }// GameSpyPlayerInfoOverlaySystem
  1296. static void messageBoxYes( void )
  1297. {
  1298. BuddyRequest breq;
  1299. breq.buddyRequestType = BuddyRequest::BUDDYREQUEST_DELETEACCT;
  1300. TheGameSpyBuddyMessageQueue->addRequest( breq );
  1301. TheGameSpyInfo->setLocalProfileID(0);
  1302. }