PopupPlayerInfo.cpp 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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 == "USA")
  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. DEBUG_ASSERTCRASH( img, ("Could not load rank image: %s", fullImageName.str()));
  120. return img;
  121. }
  122. static Int getTotalDisconnectsFromFile(Int playerID)
  123. {
  124. Int retval = 0;
  125. if (playerID == 0)
  126. {
  127. return 0;
  128. }
  129. UserPreferences pref;
  130. AsciiString userPrefFilename;
  131. userPrefFilename.format("GeneralsOnline\\MiscPref%d.ini", playerID);
  132. DEBUG_LOG(("getTotalDisconnectsFromFile - reading stats from file %s\n", userPrefFilename.str()));
  133. pref.load(userPrefFilename);
  134. // if there is a file override, use that data instead.
  135. if (pref.find("0") != pref.end()) {
  136. retval = atoi(pref.find("0")->second.str());
  137. }
  138. if (pref.find("1") != pref.end()) {
  139. retval += atoi(pref.find("1")->second.str());
  140. }
  141. if (pref.find("2") != pref.end()) {
  142. retval += atoi(pref.find("2")->second.str());
  143. }
  144. if (pref.find("3") != pref.end()) {
  145. retval += atoi(pref.find("3")->second.str());
  146. }
  147. if (pref.find("4") != pref.end()) {
  148. retval += atoi(pref.find("4")->second.str());
  149. }
  150. if (pref.find("5") != pref.end()) {
  151. retval += atoi(pref.find("5")->second.str());
  152. }
  153. return retval;
  154. }
  155. Int GetAdditionalDisconnectsFromUserFile(Int playerID)
  156. {
  157. Int retval = getTotalDisconnectsFromFile(playerID);
  158. if (playerID == 0) {
  159. return 0;
  160. }
  161. if (TheGameSpyInfo->getAdditionalDisconnects() > 0 && !retval)
  162. {
  163. DEBUG_LOG(("Clearing additional disconnects\n"));
  164. TheGameSpyInfo->clearAdditionalDisconnects();
  165. }
  166. if (TheGameSpyInfo->getAdditionalDisconnects() != -1)
  167. {
  168. return TheGameSpyInfo->getAdditionalDisconnects();
  169. }
  170. return retval;
  171. }
  172. void GetAdditionalDisconnectsFromUserFile(PSPlayerStats *stats)
  173. {
  174. if (!stats || stats->id == 0) {
  175. return;
  176. }
  177. if (TheGameSpyInfo->getAdditionalDisconnects() > 0 && !getTotalDisconnectsFromFile(stats->id))
  178. {
  179. DEBUG_LOG(("Clearing additional disconnects\n"));
  180. TheGameSpyInfo->clearAdditionalDisconnects();
  181. }
  182. if (TheGameSpyInfo->getAdditionalDisconnects() < 1)
  183. {
  184. return;
  185. }
  186. UserPreferences pref;
  187. AsciiString userPrefFilename;
  188. userPrefFilename.format("GeneralsOnline\\MiscPref%d.ini", stats->id);
  189. DEBUG_LOG(("GetAdditionalDisconnectsFromUserFile - reading stats from file %s\n", userPrefFilename.str()));
  190. pref.load(userPrefFilename);
  191. // if there is a file override, use that data instead.
  192. if (pref.find("0") != pref.end()) {
  193. stats->desyncs[2] += abs(atoi(pref.find("0")->second.str()));
  194. }
  195. if (pref.find("1") != pref.end()) {
  196. stats->desyncs[3] += abs(atoi(pref.find("1")->second.str()));
  197. }
  198. if (pref.find("2") != pref.end()) {
  199. stats->desyncs[4] += abs(atoi(pref.find("2")->second.str()));
  200. }
  201. if (pref.find("3") != pref.end()) {
  202. stats->discons[2] += abs(atoi(pref.find("3")->second.str()));
  203. }
  204. if (pref.find("4") != pref.end()) {
  205. stats->discons[3] += abs(atoi(pref.find("4")->second.str()));
  206. }
  207. if (pref.find("5") != pref.end()) {
  208. stats->discons[4] += abs(atoi(pref.find("5")->second.str()));
  209. }
  210. }
  211. // default values
  212. RankPoints::RankPoints(void)
  213. {
  214. m_ranks[RANK_PRIVATE] = 0;
  215. m_ranks[RANK_CORPORAL] = TheGameSpyConfig->getPointsForRank(RANK_CORPORAL); // 5
  216. m_ranks[RANK_SERGEANT] = TheGameSpyConfig->getPointsForRank(RANK_SERGEANT); // 10
  217. m_ranks[RANK_LIEUTENANT] = TheGameSpyConfig->getPointsForRank(RANK_LIEUTENANT); // 20
  218. m_ranks[RANK_CAPTAIN] = TheGameSpyConfig->getPointsForRank(RANK_CAPTAIN); // 50
  219. m_ranks[RANK_MAJOR] = TheGameSpyConfig->getPointsForRank(RANK_MAJOR); // 100
  220. m_ranks[RANK_COLONEL] = TheGameSpyConfig->getPointsForRank(RANK_COLONEL); // 200
  221. m_ranks[RANK_BRIGADIER_GENERAL] = TheGameSpyConfig->getPointsForRank(RANK_BRIGADIER_GENERAL); // 500
  222. m_ranks[RANK_GENERAL] = TheGameSpyConfig->getPointsForRank(RANK_GENERAL); // 1000
  223. m_ranks[RANK_COMMANDER_IN_CHIEF] = TheGameSpyConfig->getPointsForRank(RANK_COMMANDER_IN_CHIEF); // 2000
  224. m_winMultiplier = 3.0f;
  225. m_lostMultiplier = 0.0f;
  226. m_hourSpentOnlineMultiplier = 1.0f;
  227. m_completedSoloCampaigns = 5.0f;
  228. m_disconnectMultiplier = -1.0f;
  229. }
  230. RankPoints *TheRankPointValues = NULL;
  231. void SetLookAtPlayer( Int id, AsciiString nick)
  232. {
  233. lookAtPlayerID = id;
  234. lookAtPlayerName = nick.str();
  235. }
  236. // BATTLE_HONOR_LADDER_CHAMP = 0x0000001,
  237. // BATTLE_HONOR_STREAK = 0x0000002,
  238. // BATTLE_HONOR_STREAK_5 = 0x0000004,
  239. // BATTLE_HONOR_STREAK_10 = 0x0000008,
  240. // BATTLE_HONOR_STREAK_20 = 0x0000010,
  241. // BATTLE_HONOR_LOYALTY_USA = 0x0000020,
  242. // BATTLE_HONOR_LOYALTY_CHINA = 0x0000040,
  243. // BATTLE_HONOR_LOYALTY_GLA = 0x0000060,
  244. // BATTLE_HONOR_BATTLE_TANK = 0x0000080,
  245. // BATTLE_HONOR_AIR_WING = 0x0000100,
  246. // BATTLE_HONOR_SPECIAL_FORCES = 0x0000200,
  247. // BATTLE_HONOR_ENDURANCE = 0x0000400,
  248. // BATTLE_HONOR_CAMPAIGN_USA = 0x0000800,
  249. // BATTLE_HONOR_CAMPAIGN_CHINA = 0x0001000,
  250. // BATTLE_HONOR_CAMPAIGN_GLA = 0x0002000,
  251. // BATTLE_HONOR_BLITZ5 = 0x0004000,
  252. // BATTLE_HONOR_BLITZ10 = 0x0008000,
  253. // BATTLE_HONOR_DOMINATION = 0x0010000,
  254. // BATTLE_HONOR_CHALLENGE = 0x0020000,
  255. // BATTLE_HONOR_ULTIMATE = 0x0040000,
  256. // BATTLE_HONOR_GLOBAL_GENERAL = 0x0080000,
  257. // BATTLE_HONOR_DOMINATION_ONLINE = 0x0100000,
  258. // BATTLE_HONOR_SOLO_CHINA_G = 0x0200000,
  259. // BATTLE_HONOR_SOLO_GLA_B = 0x0400000,
  260. // BATTLE_HONOR_SOLO_GLA_S = 0x0800000,
  261. // BATTLE_HONOR_SOLO_GLA_G = 0x1000000,
  262. void BattleHonorTooltip(GameWindow *window,
  263. WinInstanceData *instData,
  264. UnsignedInt mouse)
  265. {
  266. Int x, y, row, col;
  267. x = LOLONGTOSHORT(mouse);
  268. y = HILONGTOSHORT(mouse);
  269. GadgetListBoxGetEntryBasedOnXY(window, x, y, row, col);
  270. if (row == -1 || col == -1)
  271. {
  272. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonors") );
  273. return;
  274. }
  275. Int battleHonor = (Int)GadgetListBoxGetItemData( window, row, col );
  276. Int extraValue = (Int)GadgetListBoxGetItemData( window, row - 1, col );
  277. if (battleHonor == 0)
  278. {
  279. //DEBUG_CRASH(("No Battle Honor in listbox row %d, col %d!", row, col));
  280. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonors") );
  281. return;
  282. }
  283. Real tooltipWidth = 1.5f;
  284. if (BitTest(battleHonor, BATTLE_HONOR_NOT_GAINED))
  285. {
  286. if(BitTest(battleHonor, BATTLE_HONOR_LOYALTY_USA))
  287. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorLoyaltyUSADisabled"), -1, NULL, tooltipWidth );
  288. else if(BitTest(battleHonor, BATTLE_HONOR_LOYALTY_CHINA))
  289. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorLoyaltyChinaDisabled"), -1, NULL, tooltipWidth );
  290. else if(BitTest(battleHonor, BATTLE_HONOR_LOYALTY_GLA))
  291. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorLoyaltyGLADisabled"), -1, NULL, tooltipWidth );
  292. else if(BitTest(battleHonor, BATTLE_HONOR_BATTLE_TANK))
  293. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorBattleTankDisabled"), -1, NULL, tooltipWidth );
  294. else if(BitTest(battleHonor, BATTLE_HONOR_AIR_WING))
  295. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorAirWingDisabled"), -1, NULL, tooltipWidth );
  296. else if(BitTest(battleHonor, BATTLE_HONOR_ENDURANCE))
  297. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorEnduranceDisabled"), -1, NULL, tooltipWidth );
  298. else if(BitTest(battleHonor, BATTLE_HONOR_CAMPAIGN_USA))
  299. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorCampaignUSADisabled"), -1, NULL, tooltipWidth );
  300. else if(BitTest(battleHonor, BATTLE_HONOR_CAMPAIGN_CHINA))
  301. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorCampaignChinaDisabled"), -1, NULL, tooltipWidth );
  302. else if(BitTest(battleHonor, BATTLE_HONOR_CAMPAIGN_GLA))
  303. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorCampaignGLADisabled"), -1, NULL, tooltipWidth );
  304. else if(BitTest(battleHonor, BATTLE_HONOR_BLITZ10))
  305. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorBlitzDisabled"), -1, NULL, tooltipWidth );
  306. else if(BitTest(battleHonor, BATTLE_HONOR_FAIR_PLAY))
  307. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorFairPlayDisabled"), -1, NULL, tooltipWidth );
  308. else if(BitTest(battleHonor, BATTLE_HONOR_APOCALYPSE))
  309. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorApocalypseDisabled"), -1, NULL, tooltipWidth );
  310. else if(BitTest(battleHonor, BATTLE_HONOR_CHALLENGE_MODE))
  311. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorCampaignChallengeDisabled"), -1, NULL, tooltipWidth );
  312. else if(BitTest(battleHonor, BATTLE_HONOR_ULTIMATE))
  313. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorUltimateDisabled"), -1, NULL, tooltipWidth );
  314. else if(BitTest(battleHonor, BATTLE_HONOR_GLOBAL_GENERAL))
  315. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorGlobalGeneralDisabled"), -1, NULL, tooltipWidth );
  316. else if(BitTest(battleHonor, BATTLE_HONOR_CHALLENGE))
  317. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorChallengeDisabled"), -1, NULL, tooltipWidth );
  318. else if(BitTest(battleHonor, BATTLE_HONOR_STREAK))
  319. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreakDisabled"), -1, NULL, tooltipWidth );
  320. else if(BitTest(battleHonor, BATTLE_HONOR_STREAK_ONLINE))
  321. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreakOnlineDisabled"), -1, NULL, tooltipWidth );
  322. else if(BitTest(battleHonor, BATTLE_HONOR_DOMINATION))
  323. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorDominationDisabled"), -1, NULL, tooltipWidth );
  324. else if(BitTest(battleHonor, BATTLE_HONOR_DOMINATION_ONLINE))
  325. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorDominationOnlineDisabled"), -1, NULL, tooltipWidth );
  326. }
  327. else
  328. {
  329. if(BitTest(battleHonor, BATTLE_HONOR_LOYALTY_USA))
  330. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorLoyaltyUSA"), -1, NULL, tooltipWidth );
  331. else if(BitTest(battleHonor, BATTLE_HONOR_LOYALTY_CHINA))
  332. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorLoyaltyChina"), -1, NULL, tooltipWidth );
  333. else if(BitTest(battleHonor, BATTLE_HONOR_LOYALTY_GLA))
  334. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorLoyaltyGLA"), -1, NULL, tooltipWidth );
  335. else if(BitTest(battleHonor, BATTLE_HONOR_BATTLE_TANK))
  336. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorBattleTank"), -1, NULL, tooltipWidth );
  337. else if(BitTest(battleHonor, BATTLE_HONOR_AIR_WING))
  338. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorAirWing"), -1, NULL, tooltipWidth );
  339. else if(BitTest(battleHonor, BATTLE_HONOR_ENDURANCE))
  340. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorEndurance"), -1, NULL, tooltipWidth );
  341. else if(BitTest(battleHonor, BATTLE_HONOR_CAMPAIGN_USA))
  342. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorCampaignUSA"), -1, NULL, tooltipWidth );
  343. else if(BitTest(battleHonor, BATTLE_HONOR_CAMPAIGN_CHINA))
  344. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorCampaignChina"), -1, NULL, tooltipWidth );
  345. else if(BitTest(battleHonor, BATTLE_HONOR_CAMPAIGN_GLA))
  346. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorCampaignGLA"), -1, NULL, tooltipWidth );
  347. else if(BitTest(battleHonor, BATTLE_HONOR_BLITZ5))
  348. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorBlitz5"), -1, NULL, tooltipWidth );
  349. else if(BitTest(battleHonor, BATTLE_HONOR_BLITZ10))
  350. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorBlitz10"), -1, NULL, tooltipWidth );
  351. else if(BitTest(battleHonor, BATTLE_HONOR_FAIR_PLAY))
  352. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorFairPlay"), -1, NULL, tooltipWidth );
  353. else if(BitTest(battleHonor, BATTLE_HONOR_APOCALYPSE))
  354. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorApocalypse"), -1, NULL, tooltipWidth );
  355. else if(BitTest(battleHonor, BATTLE_HONOR_OFFICERSCLUB))
  356. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorOfficersClub"), -1, NULL, tooltipWidth );
  357. else if(BitTest(battleHonor, BATTLE_HONOR_CHALLENGE_MODE))
  358. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorCampaignChallenge"), -1, NULL, tooltipWidth );
  359. else if(BitTest(battleHonor, BATTLE_HONOR_ULTIMATE))
  360. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorUltimate"), -1, NULL, tooltipWidth );
  361. else if(BitTest(battleHonor, BATTLE_HONOR_GLOBAL_GENERAL))
  362. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorGlobalGeneral"), -1, NULL, tooltipWidth );
  363. else if(BitTest(battleHonor, BATTLE_HONOR_CHALLENGE))
  364. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorChallenge"), -1, NULL, tooltipWidth );
  365. else if(BitTest(battleHonor, BATTLE_HONOR_STREAK))
  366. {
  367. if (extraValue >= 1000)
  368. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreak1000"), -1, NULL, tooltipWidth );
  369. else if (extraValue >= 500)
  370. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreak500"), -1, NULL, tooltipWidth );
  371. else if (extraValue >= 100)
  372. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreak100"), -1, NULL, tooltipWidth );
  373. else if (extraValue >= 25)
  374. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreak25"), -1, NULL, tooltipWidth );
  375. else if (extraValue >= 10)
  376. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreak10"), -1, NULL, tooltipWidth );
  377. else if (extraValue >= 3)
  378. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreak3"), -1, NULL, tooltipWidth );
  379. else
  380. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreakDisabled"), -1, NULL, tooltipWidth );
  381. }
  382. else if(BitTest(battleHonor, BATTLE_HONOR_STREAK_ONLINE))
  383. {
  384. if (extraValue >= 1000)
  385. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreak1000Online"), -1, NULL, tooltipWidth );
  386. else if (extraValue >= 500)
  387. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreak500Online"), -1, NULL, tooltipWidth );
  388. else if (extraValue >= 100)
  389. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreak100Online"), -1, NULL, tooltipWidth );
  390. else if (extraValue >= 25)
  391. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreak25Online"), -1, NULL, tooltipWidth );
  392. else if (extraValue >= 10)
  393. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreak10Online"), -1, NULL, tooltipWidth );
  394. else if (extraValue >= 3)
  395. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreak3Online"), -1, NULL, tooltipWidth );
  396. else
  397. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorStreakOnlineDisabled"), -1, NULL, tooltipWidth );
  398. }
  399. else if(BitTest(battleHonor, BATTLE_HONOR_DOMINATION))
  400. {
  401. if (extraValue >= 10000)
  402. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorDomination10000"), -1, NULL, tooltipWidth );
  403. else if (extraValue >= 1000)
  404. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorDomination1000"), -1, NULL, tooltipWidth );
  405. else if (extraValue >= 500)
  406. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorDomination500"), -1, NULL, tooltipWidth );
  407. else if (extraValue >= 100)
  408. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorDomination100"), -1, NULL, tooltipWidth );
  409. else
  410. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorDominationDisabled"), -1, NULL, tooltipWidth );
  411. }
  412. else if(BitTest(battleHonor, BATTLE_HONOR_DOMINATION_ONLINE))
  413. {
  414. if (extraValue >= 10000)
  415. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorDomination10000Online"), -1, NULL, tooltipWidth );
  416. else if (extraValue >= 1000)
  417. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorDomination1000Online"), -1, NULL, tooltipWidth );
  418. else if (extraValue >= 500)
  419. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorDomination500Online"), -1, NULL, tooltipWidth );
  420. else if (extraValue >= 100)
  421. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorDomination100Online"), -1, NULL, tooltipWidth );
  422. else
  423. TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:BattleHonorDominationOnlineDisabled"), -1, NULL, tooltipWidth );
  424. }
  425. }
  426. }
  427. static Int rowsToSkip = 0;
  428. void ResetBattleHonorInsertion(void)
  429. {
  430. rowsToSkip = 0;
  431. }
  432. void InsertBattleHonor(GameWindow *list, const Image *image, Bool enabled, Int itemData, Int& row, Int& column, UnicodeString text = UnicodeString::TheEmptyString, Int extra = 0)
  433. {
  434. Int width = MAX_BATTLE_HONOR_IMAGE_WIDTH * (TheDisplay->getWidth() / 800.0f);
  435. Int height = MAX_BATTLE_HONOR_IMAGE_HEIGHT * (TheDisplay->getHeight() / 600.0f);
  436. static Int enabledColor = 0xFFFFFFFF;
  437. static Int disabledColor = GameMakeColor(80, 80, 80, 255);
  438. Int color;
  439. if (enabled)
  440. color = enabledColor;
  441. else
  442. color = disabledColor;
  443. if (!enabled)
  444. itemData |= BATTLE_HONOR_NOT_GAINED;
  445. GadgetListBoxAddEntryImage(list, image, row, column, height, width, TRUE, color);
  446. GadgetListBoxSetItemData(list, (void *)itemData, row, column );
  447. GadgetListBoxSetItemData(list, (void *)extra, row - 1, column );
  448. /*
  449. ** removing text, since every place that adds text has alternate displays of the same thing
  450. if (!text.isEmpty())
  451. {
  452. GadgetListBoxAddEntryText(list, text, GameSpyColor[GSCOLOR_DEFAULT], row+1, column, TRUE );
  453. GadgetListBoxSetItemData(list, (void *)itemData, row+1, column );
  454. rowsToSkip++;
  455. }
  456. */
  457. if(++column >= GadgetListBoxGetNumColumns(list))
  458. {
  459. column = 0;
  460. row = row + 1 + rowsToSkip;
  461. rowsToSkip = max(rowsToSkip-1, 0);
  462. }
  463. }
  464. static void populateBattleHonors(const PSPlayerStats& stats, Int battleHonors, Int gamesInRow, Int lastGen, Int challenge, GameWindow *list)
  465. {
  466. if( !list )
  467. return;
  468. list->winSetTooltipFunc(BattleHonorTooltip);
  469. GadgetListBoxReset( list );
  470. Int column = 0;
  471. Int row = 0;
  472. Bool isFairPlayer = FALSE;
  473. Int numGames = 0;
  474. Int numDiscons = 0;
  475. PerGeneralMap::const_iterator it;
  476. for(it = stats.games.begin(); it != stats.games.end(); ++it)
  477. {
  478. numGames += it->second;
  479. }
  480. for(it = stats.discons.begin(); it != stats.discons.end(); ++it)
  481. {
  482. numDiscons += it->second;
  483. }
  484. for(it = stats.desyncs.begin(); it != stats.desyncs.end(); ++it)
  485. {
  486. numDiscons += it->second;
  487. }
  488. if (numGames >= 10 && numDiscons * 10 < numGames)
  489. {
  490. isFairPlayer = TRUE;
  491. }
  492. ResetBattleHonorInsertion();
  493. GadgetListBoxAddEntryImage(list, NULL, 0, 0, 10, 10, TRUE, GameMakeColor(255,255,255,255));
  494. row = 1;
  495. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("FairPlay"), isFairPlayer,
  496. BATTLE_HONOR_FAIR_PLAY, row, column);
  497. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorAirWing"), BitTest(battleHonors, BATTLE_HONOR_AIR_WING),
  498. BATTLE_HONOR_AIR_WING, row, column);
  499. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorBattleTank"), BitTest(battleHonors, BATTLE_HONOR_BATTLE_TANK),
  500. BATTLE_HONOR_BATTLE_TANK, row, column);
  501. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Apocalypse"), BitTest(battleHonors, BATTLE_HONOR_APOCALYPSE),
  502. BATTLE_HONOR_APOCALYPSE, row, column);
  503. // create a spacer for row 2 and start the images on row 3
  504. GadgetListBoxAddEntryImage(list, NULL, 2, 0, 10, 10, TRUE, GameMakeColor(255,255,255,255));
  505. row = 3;
  506. if (BitTest(battleHonors, BATTLE_HONOR_BLITZ5))
  507. {
  508. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorBlitz5"), TRUE,
  509. BATTLE_HONOR_BLITZ5, row, column);
  510. }
  511. else if (BitTest(battleHonors, BATTLE_HONOR_BLITZ10))
  512. {
  513. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorBlitz10"), TRUE,
  514. BATTLE_HONOR_BLITZ10, row, column);
  515. }
  516. else
  517. {
  518. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorBlitz10"), FALSE,
  519. BATTLE_HONOR_BLITZ10, row, column);
  520. }
  521. // TEST FOR STREAK HONOR
  522. UnicodeString uStr;
  523. Int streak = stats.winsInARow;
  524. uStr.format(L"%10d", streak);
  525. if (streak >= 1000)
  526. {
  527. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorStreak_1000"), TRUE,
  528. BATTLE_HONOR_STREAK_ONLINE, row, column, uStr);
  529. }
  530. else if (streak >= 500)
  531. {
  532. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorStreak_500"), TRUE,
  533. BATTLE_HONOR_STREAK_ONLINE, row, column, uStr);
  534. }
  535. else if (streak >= 100)
  536. {
  537. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorStreak_100"), TRUE,
  538. BATTLE_HONOR_STREAK_ONLINE, row, column, uStr);
  539. }
  540. else if (streak >= 25)
  541. {
  542. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorStreak_G"), TRUE,
  543. BATTLE_HONOR_STREAK_ONLINE, row, column, uStr);
  544. }
  545. else if (streak >= 10)
  546. {
  547. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorStreak_S"), TRUE,
  548. BATTLE_HONOR_STREAK_ONLINE, row, column, uStr);
  549. }
  550. else if (streak >= 3)
  551. {
  552. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorStreak_B"), TRUE,
  553. BATTLE_HONOR_STREAK_ONLINE, row, column, uStr);
  554. }
  555. else
  556. {
  557. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorStreak_B"), FALSE,
  558. BATTLE_HONOR_STREAK_ONLINE, row, column, uStr);
  559. }
  560. // TEST FOR DOMINATION HONOR
  561. Int totalWins = 0;
  562. PerGeneralMap::const_iterator pit;
  563. for(pit = stats.wins.begin(); pit != stats.wins.end(); ++pit)
  564. {
  565. totalWins += pit->second;
  566. }
  567. uStr.format(L"%10d", totalWins);
  568. if (totalWins >= 10000)
  569. {
  570. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Domination_10000"), TRUE,
  571. BATTLE_HONOR_DOMINATION_ONLINE, row, column, uStr, totalWins);
  572. }
  573. else if (totalWins >= 1000)
  574. {
  575. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Domination_1000"), TRUE,
  576. BATTLE_HONOR_DOMINATION_ONLINE, row, column, uStr, totalWins);
  577. }
  578. else if (totalWins >= 500)
  579. {
  580. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Domination_500"), TRUE,
  581. BATTLE_HONOR_DOMINATION_ONLINE, row, column, uStr, totalWins);
  582. }
  583. else if (totalWins >= 100)
  584. {
  585. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Domination_100"), TRUE,
  586. BATTLE_HONOR_DOMINATION_ONLINE, row, column, uStr, totalWins);
  587. }
  588. else
  589. {
  590. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Domination_100"), FALSE,
  591. BATTLE_HONOR_DOMINATION_ONLINE, row, column, uStr, totalWins);
  592. }
  593. // TEST FOR GLOBAL GENERAL HONOR
  594. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("GlobalGen"), BitTest(battleHonors, BATTLE_HONOR_GLOBAL_GENERAL),
  595. BATTLE_HONOR_GLOBAL_GENERAL, row, column);
  596. /*
  597. Bool isLoyal;
  598. isLoyal = ThePlayerTemplateStore->getNthPlayerTemplate(lastGen)->getSide().compareNoCase( "america") == 0 && gamesInRow >= 20;
  599. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Loyalty_USA"), isLoyal,
  600. BATTLE_HONOR_LOYALTY_USA, row, column);
  601. isLoyal = ThePlayerTemplateStore->getNthPlayerTemplate(lastGen)->getSide().compareNoCase( "china") == 0 && gamesInRow >= 20;
  602. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Loyalty_China"), isLoyal,
  603. BATTLE_HONOR_LOYALTY_CHINA, row, column);
  604. isLoyal = ThePlayerTemplateStore->getNthPlayerTemplate(lastGen)->getSide().compareNoCase( "gla") == 0 && gamesInRow >= 20;
  605. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Loyalty_GLA"), isLoyal,
  606. BATTLE_HONOR_LOYALTY_GLA, row, column);
  607. */
  608. //insertBattleHonor(list, TheMappedImageCollection->findImageByName("Endurance"), BitTest(battleHonors, BATTLE_HONOR_ENDURANCE),
  609. //BATTLE_HONOR_ENDURANCE, row, column);
  610. /*
  611. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Campaign_USA"), BitTest(battleHonors, BATTLE_HONOR_CAMPAIGN_USA),
  612. BATTLE_HONOR_CAMPAIGN_USA, row, column);
  613. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Campaign_China"), BitTest(battleHonors, BATTLE_HONOR_CAMPAIGN_CHINA),
  614. BATTLE_HONOR_CAMPAIGN_CHINA, row, column);
  615. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("Campaign_GLA"), BitTest(battleHonors, BATTLE_HONOR_CAMPAIGN_GLA),
  616. BATTLE_HONOR_CAMPAIGN_GLA, row, column);
  617. */
  618. /*
  619. if(BitTest(challenge, BH_CHALLENGE_MASK_7))
  620. {
  621. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorChallenge7"), TRUE,
  622. BATTLE_HONOR_CHALLENGE, row, column);
  623. }
  624. else if (BitTest(challenge, BH_CHALLENGE_MASK_6))
  625. {
  626. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorChallenge6"), TRUE,
  627. BATTLE_HONOR_CHALLENGE, row, column);
  628. }
  629. else if (BitTest(challenge, BH_CHALLENGE_MASK_5))
  630. {
  631. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorChallenge5"), TRUE,
  632. BATTLE_HONOR_CHALLENGE, row, column);
  633. }
  634. else if (BitTest(challenge, BH_CHALLENGE_MASK_4))
  635. {
  636. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorChallenge4"), TRUE,
  637. BATTLE_HONOR_CHALLENGE, row, column);
  638. }
  639. else if (BitTest(challenge, BH_CHALLENGE_MASK_3))
  640. {
  641. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorChallenge3"), TRUE,
  642. BATTLE_HONOR_CHALLENGE, row, column);
  643. }
  644. else if (BitTest(challenge, BH_CHALLENGE_MASK_2))
  645. {
  646. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorChallenge2"), TRUE,
  647. BATTLE_HONOR_CHALLENGE, row, column);
  648. }
  649. else if (BitTest(challenge, BH_CHALLENGE_MASK_1))
  650. {
  651. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorChallenge1"), TRUE,
  652. BATTLE_HONOR_CHALLENGE, row, column);
  653. }
  654. else
  655. {
  656. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("HonorChallenge1"), FALSE,
  657. BATTLE_HONOR_CHALLENGE, row, column);
  658. }
  659. */
  660. if (TheGameSpyInfo->didPlayerPreorder(stats.id))
  661. {
  662. InsertBattleHonor(list, TheMappedImageCollection->findImageByName("OfficersClub"), TRUE,
  663. BATTLE_HONOR_OFFICERSCLUB, row, column);
  664. }
  665. }
  666. Int GetFavoriteSide( const PSPlayerStats& stats )
  667. {
  668. PerGeneralMap::const_iterator it;
  669. Int numGames = 0;
  670. Int favorite = 0;
  671. for(it =stats.games.begin(); it != stats.games.end(); ++it)
  672. {
  673. if(it->second >= numGames)
  674. {
  675. numGames = it->second;
  676. favorite = it->first;
  677. }
  678. }
  679. if(numGames == 0)
  680. return -1;
  681. else if( stats.gamesAsRandom >= numGames )
  682. return 0;
  683. return favorite;
  684. }
  685. Int CalculateRank( const PSPlayerStats& stats )
  686. {
  687. if(stats.id == 0 || !TheRankPointValues)
  688. return 0;
  689. PerGeneralMap::const_iterator it;
  690. Int rankPoints = 0;
  691. Int numGames = 0;
  692. for(it =stats.wins.begin(); it != stats.wins.end(); ++it)
  693. {
  694. numGames += it->second;
  695. }
  696. rankPoints += (numGames * TheRankPointValues->m_winMultiplier);
  697. numGames = 0;
  698. for(it =stats.losses.begin(); it != stats.losses.end(); ++it)
  699. {
  700. numGames += it->second;
  701. }
  702. rankPoints += (numGames * TheRankPointValues->m_lostMultiplier);
  703. numGames = 0;
  704. for(it =stats.duration.begin(); it != stats.duration.end(); ++it)
  705. {
  706. numGames += it->second;
  707. }
  708. rankPoints += (numGames / 60) * TheRankPointValues->m_hourSpentOnlineMultiplier;
  709. numGames = 0;
  710. for(it =stats.discons.begin(); it != stats.discons.end(); ++it)
  711. {
  712. numGames += it->second;
  713. }
  714. for(it =stats.desyncs.begin(); it != stats.desyncs.end(); ++it)
  715. {
  716. numGames += it->second;
  717. }
  718. rankPoints += numGames * TheRankPointValues->m_disconnectMultiplier;
  719. if(BitTest(stats.battleHonors, BATTLE_HONOR_CAMPAIGN_USA | BATTLE_HONOR_CAMPAIGN_CHINA |BATTLE_HONOR_CAMPAIGN_GLA))
  720. {
  721. rankPoints += 1 * TheRankPointValues->m_completedSoloCampaigns;
  722. }
  723. rankPoints = max(0, rankPoints); // clip off negative values, since discons can push us below 0.
  724. return rankPoints;
  725. }
  726. static GameWindow* findWindow(GameWindow *parent, AsciiString baseWindow, AsciiString gadgetName)
  727. {
  728. AsciiString fullPath;
  729. fullPath.format("%s:%s", baseWindow.str(), gadgetName.str());
  730. GameWindow *res = TheWindowManager->winGetWindowFromId(parent, NAMEKEY(fullPath));
  731. DEBUG_ASSERTLOG(res, ("Cannot find window %s\n", fullPath.str()));
  732. return res;
  733. }
  734. void PopulatePlayerInfoWindows( AsciiString parentWindowName )
  735. {
  736. Int lookupID = TheGameSpyInfo->getLocalProfileID();
  737. if(parentWindowName == "PopupPlayerInfo.wnd")
  738. {
  739. lookupID = lookAtPlayerID;
  740. if (lookAtPlayerID <= 0 || !parent)
  741. return;
  742. }
  743. PSPlayerStats stats = TheGameSpyPSMessageQueue->findPlayerStatsByID(lookupID);
  744. Bool weHaveStats = (stats.id != 0);
  745. // if we don't have the stats from the server, see if we have cached stats
  746. if( !weHaveStats && lookupID == TheGameSpyInfo->getLocalProfileID() )
  747. {
  748. stats = TheGameSpyInfo->getCachedLocalPlayerStats();
  749. weHaveStats = TRUE;
  750. }
  751. Int currentRank = 0;
  752. Int rankPoints = CalculateRank(stats);
  753. Int i = 0;
  754. while( rankPoints >= TheRankPointValues->m_ranks[i + 1])
  755. ++i;
  756. currentRank = i;
  757. PerGeneralMap::iterator it;
  758. Int numWins = 0;
  759. Int numLosses = 0;
  760. Int numDiscons = 0;
  761. Int numGames = 0;
  762. for(it =stats.wins.begin(); it != stats.wins.end(); ++it)
  763. {
  764. numWins += it->second;
  765. }
  766. for(it =stats.losses.begin(); it != stats.losses.end(); ++it)
  767. {
  768. numLosses += it->second;
  769. }
  770. for(it =stats.discons.begin(); it != stats.discons.end(); ++it)
  771. {
  772. numDiscons += it->second;
  773. }
  774. for(it =stats.desyncs.begin(); it != stats.desyncs.end(); ++it)
  775. {
  776. numDiscons += it->second;
  777. }
  778. numDiscons += GetAdditionalDisconnectsFromUserFile(lookupID);
  779. numGames = numWins + numLosses + numDiscons;
  780. GameWindow *win = NULL;
  781. UnicodeString uStr;
  782. win = findWindow(NULL, parentWindowName, "StaticTextPlayerStatisticsLabel");
  783. if(win)
  784. {
  785. AsciiString localeID = "WOL:Locale00";
  786. if (stats.locale >= LOC_MIN && stats.locale <= LOC_MAX)
  787. localeID.format("WOL:Locale%2.2d", stats.locale);
  788. uStr.format(TheGameText->fetch("GUI:PlayerStatistics"), lookAtPlayerName.c_str(), TheGameText->fetch(localeID).str());
  789. GadgetStaticTextSetText(win, uStr);
  790. }
  791. win = findWindow(NULL, parentWindowName, "StaticTextGamesPlayedValue");
  792. if(win)
  793. {
  794. uStr.format(L"%d", numGames);
  795. GadgetStaticTextSetText(win, uStr);
  796. }
  797. win = findWindow(NULL, parentWindowName, "StaticTextWinsValue");
  798. if(win)
  799. {
  800. uStr.format(L"%d", numWins);
  801. GadgetStaticTextSetText(win, uStr);
  802. }
  803. win = findWindow(NULL, parentWindowName, "StaticTextLossesValue");
  804. if(win)
  805. {
  806. uStr.format(L"%d", numLosses);
  807. GadgetStaticTextSetText(win, uStr);
  808. }
  809. win = findWindow(NULL, parentWindowName, "StaticTextDisconnectsValue");
  810. if(win)
  811. {
  812. uStr.format(L"%d", numDiscons);
  813. GadgetStaticTextSetText(win, uStr);
  814. }
  815. win = findWindow(NULL, parentWindowName, "StaticTextBestStreakValue");
  816. if (win)
  817. {
  818. uStr.format(L"%d", stats.maxWinsInARow);
  819. GadgetStaticTextSetText(win, uStr);
  820. }
  821. win = findWindow(NULL, parentWindowName, "StaticTextStreak");
  822. if (win)
  823. {
  824. if (stats.lossesInARow > 0)
  825. {
  826. GadgetStaticTextSetText(win, TheGameText->fetch("GUI:CurrentLossStreak"));
  827. }
  828. else
  829. {
  830. GadgetStaticTextSetText(win, TheGameText->fetch("GUI:CurrentWinStreak"));
  831. }
  832. }
  833. win = findWindow(NULL, parentWindowName, "StaticTextStreakValue");
  834. if(win)
  835. {
  836. Int streak = max(stats.lossesInARow, stats.winsInARow);
  837. uStr.format(L"%d", streak);
  838. GadgetStaticTextSetText(win, uStr);
  839. }
  840. win = findWindow(NULL, parentWindowName, "StaticTextTotalKillsValue");
  841. if(win)
  842. {
  843. Int numGames = 0;
  844. for(it =stats.unitsKilled.begin(); it != stats.unitsKilled.end(); ++it)
  845. {
  846. numGames += it->second;
  847. }
  848. uStr.format(L"%d", numGames);
  849. GadgetStaticTextSetText(win, uStr);
  850. }
  851. win = findWindow(NULL, parentWindowName, "StaticTextTotalDeathsValue");
  852. if(win)
  853. {
  854. Int numGames = 0;
  855. for(it =stats.unitsLost.begin(); it != stats.unitsLost.end(); ++it)
  856. {
  857. numGames += it->second;
  858. }
  859. uStr.format(L"%d", numGames);
  860. GadgetStaticTextSetText(win, uStr);
  861. }
  862. win = findWindow(NULL, parentWindowName, "StaticTextTotalBuiltValue");
  863. if(win)
  864. {
  865. Int numGames = 0;
  866. for(it =stats.unitsBuilt.begin(); it != stats.unitsBuilt.end(); ++it)
  867. {
  868. numGames += it->second;
  869. }
  870. uStr.format(L"%d", numGames);
  871. GadgetStaticTextSetText(win, uStr);
  872. }
  873. win = findWindow(NULL, parentWindowName, "StaticTextBuildingsKilledValue");
  874. if(win)
  875. {
  876. Int numGames = 0;
  877. for(it =stats.buildingsKilled.begin(); it != stats.buildingsKilled.end(); ++it)
  878. {
  879. numGames += it->second;
  880. }
  881. uStr.format(L"%d", numGames);
  882. GadgetStaticTextSetText(win, uStr);
  883. }
  884. win = findWindow(NULL, parentWindowName, "StaticTextBuildingsLostValue");
  885. if(win)
  886. {
  887. Int numGames = 0;
  888. for(it =stats.buildingsLost.begin(); it != stats.buildingsLost.end(); ++it)
  889. {
  890. numGames += it->second;
  891. }
  892. uStr.format(L"%d", numGames);
  893. GadgetStaticTextSetText(win, uStr);
  894. }
  895. win = findWindow(NULL, parentWindowName, "StaticTextBuildingsBuiltValue");
  896. if(win)
  897. {
  898. Int numGames = 0;
  899. for(it =stats.buildingsBuilt.begin(); it != stats.buildingsBuilt.end(); ++it)
  900. {
  901. numGames += it->second;
  902. }
  903. uStr.format(L"%d", numGames);
  904. GadgetStaticTextSetText(win, uStr);
  905. }
  906. win = findWindow(NULL, parentWindowName, "StaticTextWinPercentValue");
  907. if(win)
  908. {
  909. //GS prevent divide by zero
  910. if( numGames > 0 )
  911. uStr.format(TheGameText->fetch("GUI:WinPercent"), REAL_TO_INT(numWins/(Real)numGames*100.0f));
  912. else
  913. uStr.format(TheGameText->fetch("GUI:WinPercent"), 0);
  914. GadgetStaticTextSetText(win, uStr);
  915. }
  916. win = findWindow(NULL, parentWindowName, "ProgressBarRank");
  917. if(win && TheRankPointValues)
  918. {
  919. if( currentRank == MAX_RANKS - 1)
  920. {
  921. // we've reached the max rank
  922. win->winHide(TRUE);
  923. }
  924. else
  925. {
  926. GadgetProgressBarSetProgress(win, 100 * INT_TO_REAL(rankPoints - TheRankPointValues->m_ranks[currentRank])/( TheRankPointValues->m_ranks[currentRank + 1] - TheRankPointValues->m_ranks[currentRank]));
  927. }
  928. }
  929. //calculate favorite side and rank overlay image
  930. UnicodeString rankStr; //, sideStr, sideRankStr;
  931. const PlayerTemplate* pPlayerTemplate = NULL; //NULL == newbie
  932. { //search all stats for side favorite side (highest numGames)
  933. Int mostGames = 0;
  934. Int favorite = 0;
  935. for(it =stats.games.begin(); it != stats.games.end(); ++it)
  936. {
  937. if(it->second >= mostGames)
  938. {
  939. mostGames = it->second;
  940. favorite = it->first;
  941. }
  942. }
  943. if( mostGames > 0 )
  944. pPlayerTemplate = ThePlayerTemplateStore->getNthPlayerTemplate(favorite);
  945. //rank (ex: Corporal)
  946. AsciiString rank;
  947. rank.format("GUI:GSRank%d", currentRank);
  948. rankStr = TheGameText->fetch(rank);
  949. // //favorite side (ex: Toxin, Tank, Stealth, etc.)
  950. // AsciiString side;
  951. // if( mostGames > 0 && pPlayerTemplate != NULL )
  952. // {
  953. // if( stats.gamesAsRandom >= mostGames )
  954. // side = "GUI:Random";
  955. // else
  956. // side.format("SIDE:%s", pPlayerTemplate->getSide().str());
  957. // }
  958. //
  959. // //combined text (Ex: Toxin Corporal)
  960. // sideStr = TheGameText->fetch(side);
  961. // sideRankStr.format(L"%s - %s", sideStr.str(), rankStr.str() );
  962. }
  963. //rank image; based on rank and primary faction (USA, China, GLA)
  964. win = findWindow(NULL, parentWindowName, "WinRank");
  965. if(win && TheRankPointValues)
  966. {
  967. if (rankPoints == 0 || pPlayerTemplate == NULL)
  968. win->winSetEnabledImage(0, TheMappedImageCollection->findImageByName("NewPlayer"));
  969. else
  970. win->winSetEnabledImage(0, lookupRankImage(pPlayerTemplate->getBaseSide(), currentRank));
  971. //x win->setTooltipText(rankStr); //ex: Corporal
  972. }
  973. //sub-faction overlay icon (ex: Tank General, Toxin General, etc.)
  974. win = findWindow(NULL, parentWindowName, "FactionImage");
  975. if(win && pPlayerTemplate && TheRankPointValues && rankPoints)
  976. {
  977. win->winSetEnabledImage(0, pPlayerTemplate->getGeneralImage());
  978. //x win->setTooltipText( sideStr ); //ex: Toxin General
  979. }
  980. //favorite side and rank text (Ex: Tank Corporal)
  981. win = findWindow(NULL, parentWindowName, "StaticTextRank");
  982. if(win)
  983. {
  984. GadgetStaticTextSetText(win, rankStr); //just rank
  985. //x win->setTooltipText(sideRankStr); //ex: Toxin General - Corporal
  986. }
  987. win = findWindow(NULL, parentWindowName, "StaticTextInProgress");
  988. if (win)
  989. {
  990. if (weHaveStats)
  991. {
  992. win->winHide(TRUE);
  993. }
  994. else
  995. {
  996. win->winHide(FALSE);
  997. GadgetStaticTextSetText(win, TheGameText->fetch("GUI:FetchingPlayerInfo"));
  998. }
  999. }
  1000. win = findWindow(NULL, parentWindowName, "ListboxInfo");
  1001. if(win)
  1002. {
  1003. populateBattleHonors(stats, stats.battleHonors,stats.gamesInRowWithLastGeneral,stats.lastGeneral,stats.challengeMedals, win);
  1004. }
  1005. }
  1006. void HandlePersistentStorageResponses( void )
  1007. {
  1008. if (TheGameSpyPSMessageQueue)
  1009. {
  1010. PSResponse resp;
  1011. if (TheGameSpyPSMessageQueue->getResponse( resp ))
  1012. {
  1013. switch (resp.responseType)
  1014. {
  1015. case PSResponse::PSRESPONSE_COULDNOTCONNECT:
  1016. {
  1017. // message box & hide the window
  1018. GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:PSCannotConnect"), NULL);
  1019. GameSpyCloseOverlay(GSOVERLAY_PLAYERINFO);
  1020. }
  1021. break;
  1022. case PSResponse::PSRESPONSE_PREORDER:
  1023. {
  1024. if (resp.preorder)
  1025. {
  1026. SetUnsignedIntInRegistry("", "Preorder", 1);
  1027. TheGameSpyInfo->markPlayerAsPreorder( TheGameSpyInfo->getLocalProfileID() );
  1028. // force an update of our shtuff
  1029. PSResponse newResp;
  1030. newResp.responseType = PSResponse::PSRESPONSE_PLAYERSTATS;
  1031. newResp.player = TheGameSpyPSMessageQueue->findPlayerStatsByID(TheGameSpyInfo->getLocalProfileID());
  1032. TheGameSpyPSMessageQueue->addResponse(newResp);
  1033. }
  1034. }
  1035. break;
  1036. case PSResponse::PSRESPONSE_PLAYERSTATS:
  1037. {
  1038. DEBUG_LOG(("LocalProfileID %d, resp.player.id %d, resp.player.locale %d\n", TheGameSpyInfo->getLocalProfileID(), resp.player.id, resp.player.locale));
  1039. /*
  1040. if(resp.player.id == TheGameSpyInfo->getLocalProfileID() && resp.player.locale < LOC_MIN)
  1041. {
  1042. if (!GameSpyIsOverlayOpen(GSOVERLAY_LOCALESELECT))
  1043. GameSpyOpenOverlay(GSOVERLAY_LOCALESELECT);
  1044. }
  1045. else
  1046. */
  1047. if (resp.player.id == TheGameSpyInfo->getLocalProfileID())
  1048. {
  1049. PeerRequest req;
  1050. req.peerRequestType = PeerRequest::PEERREQUEST_PUSHSTATS;
  1051. GameSpyMiscPreferences cPref;
  1052. req.statsToPush.locale = cPref.getLocale();
  1053. Int wins = 0, losses = 0;
  1054. PerGeneralMap::const_iterator it;
  1055. for (it = resp.player.wins.begin(); it != resp.player.wins.end(); ++it)
  1056. {
  1057. wins += it->second;
  1058. }
  1059. for (it = resp.player.losses.begin(); it != resp.player.losses.end(); ++it)
  1060. {
  1061. losses += it->second;
  1062. }
  1063. req.statsToPush.wins = wins;
  1064. req.statsToPush.losses = losses;
  1065. req.statsToPush.rankPoints = CalculateRank( resp.player );
  1066. Int numGames = 0;
  1067. Int favorite = 0;
  1068. for(it =resp.player.games.begin(); it != resp.player.games.end(); ++it)
  1069. {
  1070. if(it->second >= numGames)
  1071. {
  1072. numGames = it->second;
  1073. favorite = it->first;
  1074. }
  1075. }
  1076. if(numGames == 0)
  1077. req.statsToPush.side = 0;
  1078. else if( resp.player.gamesAsRandom >= numGames )
  1079. req.statsToPush.side = 0;
  1080. else
  1081. req.statsToPush.side = favorite;
  1082. Bool isPreorder = TheGameSpyInfo->didPlayerPreorder( TheGameSpyInfo->getLocalProfileID() );
  1083. req.statsToPush.preorder = isPreorder;
  1084. DEBUG_LOG(("PEERREQUEST_PUSHSTATS: stats will be %d,%d,%d,%d,%d,%d\n",
  1085. req.statsToPush.locale, req.statsToPush.wins, req.statsToPush.losses, req.statsToPush.rankPoints, req.statsToPush.side, req.statsToPush.preorder));
  1086. TheGameSpyPeerMessageQueue->addRequest(req);
  1087. }
  1088. TheGameSpyPSMessageQueue->trackPlayerStats(resp.player);
  1089. if (resp.player.id == TheGameSpyInfo->getLocalProfileID())
  1090. {
  1091. UpdateLocalPlayerStats();
  1092. }
  1093. DEBUG_LOG(("PopulatePlayerInfoWindows() - lookAtPlayerID is %d, got %d\n", lookAtPlayerID, resp.player.id));
  1094. PopulatePlayerInfoWindows("PopupPlayerInfo.wnd");
  1095. //GadgetListBoxAddEntryText(listboxInfo, UnicodeString(L"Got info!"), GameSpyColor[GSCOLOR_DEFAULT], -1);
  1096. // also update info for player list in lobby
  1097. PlayerInfoMap::iterator it = TheGameSpyInfo->getPlayerInfoMap()->begin();
  1098. while (it != TheGameSpyInfo->getPlayerInfoMap()->end())
  1099. {
  1100. PlayerInfo *info = &(it->second);
  1101. if (info && info->m_profileID == resp.player.id)
  1102. {
  1103. // update m_wins, m_losses, m_rankPoints
  1104. Int wins = 0, losses = 0;
  1105. PerGeneralMap::const_iterator it;
  1106. for (it = resp.player.wins.begin(); it != resp.player.wins.end(); ++it)
  1107. {
  1108. wins += it->second;
  1109. }
  1110. for (it = resp.player.losses.begin(); it != resp.player.losses.end(); ++it)
  1111. {
  1112. losses += it->second;
  1113. }
  1114. info->m_wins = wins;
  1115. info->m_losses = losses;
  1116. info->m_rankPoints = CalculateRank( resp.player );
  1117. Int numGames = 0;
  1118. Int favorite = 0;
  1119. for(it = resp.player.games.begin(); it != resp.player.games.end(); ++it)
  1120. {
  1121. if(it->second >= numGames)
  1122. {
  1123. numGames = it->second;
  1124. favorite = it->first;
  1125. }
  1126. }
  1127. if(numGames == 0)
  1128. info->m_side = 0;
  1129. else if( resp.player.gamesAsRandom >= numGames )
  1130. info->m_side = 0;
  1131. else
  1132. info->m_side = favorite;
  1133. PeerResponse r;
  1134. r.peerResponseType = PeerResponse::PEERRESPONSE_PLAYERINFO;
  1135. r.nick = info->m_name.str();
  1136. r.player.profileID = info->m_profileID;
  1137. r.player.flags = info->m_flags;
  1138. r.player.wins = info->m_wins;
  1139. r.player.losses = info->m_losses;
  1140. r.locale = info->m_locale.str();
  1141. r.player.rankPoints = info->m_rankPoints;
  1142. r.player.side = info->m_side;
  1143. r.player.preorder = info->m_preorder;
  1144. TheGameSpyPeerMessageQueue->addResponse(r);
  1145. break;
  1146. }
  1147. ++it;
  1148. }
  1149. }
  1150. break;
  1151. }
  1152. }
  1153. }
  1154. }
  1155. //-------------------------------------------------------------------------------------------------
  1156. /** Initialize the Overlay */
  1157. //-------------------------------------------------------------------------------------------------
  1158. void GameSpyPlayerInfoOverlayInit( WindowLayout *layout, void *userData )
  1159. {
  1160. parentID = TheNameKeyGenerator->nameToKey( "PopupPlayerInfo.wnd:PopupParent" );
  1161. buttonCloseID = TheNameKeyGenerator->nameToKey( "PopupPlayerInfo.wnd:ButtonClose" );
  1162. buttonBuddiesID = TheNameKeyGenerator->nameToKey( "PopupPlayerInfo.wnd:ButtonCommunicator" );
  1163. listboxInfoID = TheNameKeyGenerator->nameToKey( "PopupPlayerInfo.wnd:ListboxInfo" );
  1164. //buttonOptionsID = TheNameKeyGenerator->nameToKey( "PopupPlayerInfo.wnd:ButtonOptions" );
  1165. buttonSetLocaleID = TheNameKeyGenerator->nameToKey( "PopupPlayerInfo.wnd:ButtonSetLocale" );
  1166. buttonDeleteAccountID = TheNameKeyGenerator->nameToKey( "PopupPlayerInfo.wnd:ButtonDeleteAccount" );
  1167. checkBoxAsianFontID = TheNameKeyGenerator->nameToKey( "PopupPlayerInfo.wnd:CheckBoxAsianText" );
  1168. checkBoxNonAsianFontID = TheNameKeyGenerator->nameToKey( "PopupPlayerInfo.wnd:CheckBoxNonAsianText" );
  1169. parent = TheWindowManager->winGetWindowFromId( NULL, parentID );
  1170. buttonClose = TheWindowManager->winGetWindowFromId( parent, buttonCloseID);
  1171. buttonBuddies = TheWindowManager->winGetWindowFromId( parent, buttonBuddiesID);
  1172. listboxInfo = TheWindowManager->winGetWindowFromId( parent, listboxInfoID);
  1173. //buttonbuttonOptions = TheWindowManager->winGetWindowFromId( parent, buttonOptionsID);
  1174. buttonSetLocale = TheWindowManager->winGetWindowFromId( parent, buttonSetLocaleID);
  1175. buttonDeleteAccount = TheWindowManager->winGetWindowFromId( parent, buttonDeleteAccountID);
  1176. checkBoxAsianFont = TheWindowManager->winGetWindowFromId( parent, checkBoxAsianFontID);
  1177. checkBoxNonAsianFont = TheWindowManager->winGetWindowFromId( parent, checkBoxNonAsianFontID);
  1178. // Show Menu
  1179. layout->hide( FALSE );
  1180. // Set Keyboard to Main Parent
  1181. TheWindowManager->winSetFocus( parent );
  1182. isOverlayActive = true;
  1183. //GadgetListBoxAddEntryText(listboxInfo, UnicodeString(L"Working"), GameSpyColor[GSCOLOR_DEFAULT], -1);
  1184. GameSpyCloseOverlay(GSOVERLAY_BUDDY);
  1185. raiseMessageBox = true;
  1186. PopulatePlayerInfoWindows("PopupPlayerInfo.wnd");
  1187. // we're on the myinfo screen
  1188. if(lookAtPlayerID == TheGameSpyInfo->getLocalProfileID())
  1189. {
  1190. //buttonbuttonOptions->winHide(FALSE);
  1191. buttonSetLocale->winHide(FALSE);
  1192. buttonDeleteAccount->winHide(TRUE); // set back to false when we have this worked out.
  1193. checkBoxAsianFont->winHide(FALSE);
  1194. checkBoxNonAsianFont->winHide(FALSE);
  1195. }
  1196. else
  1197. {
  1198. //buttonbuttonOptions->winHide(TRUE);
  1199. buttonSetLocale->winHide(TRUE);
  1200. buttonDeleteAccount->winHide(TRUE);
  1201. checkBoxAsianFont->winHide(TRUE);
  1202. checkBoxNonAsianFont->winHide(TRUE);
  1203. }
  1204. // set the asian check boxes
  1205. CustomMatchPreferences pref;
  1206. GadgetCheckBoxSetChecked(checkBoxAsianFont,!pref.getDisallowAsianText());
  1207. GadgetCheckBoxSetChecked(checkBoxNonAsianFont,!pref.getDisallowNonAsianText());
  1208. OSVERSIONINFO osvi;
  1209. osvi.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
  1210. if (GetVersionEx(&osvi))
  1211. { //check if we're running Win9x variant since they may need different fonts
  1212. if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
  1213. {
  1214. if (checkBoxAsianFont)
  1215. checkBoxAsianFont->winEnable(FALSE);
  1216. if (checkBoxNonAsianFont)
  1217. checkBoxNonAsianFont->winEnable(FALSE);
  1218. }
  1219. }
  1220. //TheWindowManager->winSetModal(parent);
  1221. } // GameSpyPlayerInfoOverlayInit
  1222. //-------------------------------------------------------------------------------------------------
  1223. /** Overlay shutdown method */
  1224. //-------------------------------------------------------------------------------------------------
  1225. void GameSpyPlayerInfoOverlayShutdown( WindowLayout *layout, void *userData )
  1226. {
  1227. // hide menu
  1228. layout->hide( TRUE );
  1229. parent = NULL;
  1230. // our shutdown is complete
  1231. isOverlayActive = false;
  1232. } // GameSpyPlayerInfoOverlayShutdown
  1233. //-------------------------------------------------------------------------------------------------
  1234. /** Overlay update method */
  1235. //-------------------------------------------------------------------------------------------------
  1236. void GameSpyPlayerInfoOverlayUpdate( WindowLayout * layout, void *userData)
  1237. {
  1238. if (raiseMessageBox)
  1239. RaiseGSMessageBox();
  1240. raiseMessageBox = false;
  1241. }// GameSpyPlayerInfoOverlayUpdate
  1242. //-------------------------------------------------------------------------------------------------
  1243. /** Overlay input callback */
  1244. //-------------------------------------------------------------------------------------------------
  1245. WindowMsgHandledType GameSpyPlayerInfoOverlayInput( GameWindow *window, UnsignedInt msg,
  1246. WindowMsgData mData1, WindowMsgData mData2 )
  1247. {
  1248. switch( msg )
  1249. {
  1250. // --------------------------------------------------------------------------------------------
  1251. case GWM_CHAR:
  1252. {
  1253. UnsignedByte key = mData1;
  1254. UnsignedByte state = mData2;
  1255. switch( key )
  1256. {
  1257. // ----------------------------------------------------------------------------------------
  1258. case KEY_ESC:
  1259. {
  1260. //
  1261. // send a simulated selected event to the parent window of the
  1262. // back/exit button
  1263. //
  1264. if( BitTest( state, KEY_STATE_UP ) )
  1265. {
  1266. TheWindowManager->winSendSystemMsg( window, GBM_SELECTED,
  1267. (WindowMsgData)buttonClose, buttonCloseID );
  1268. } // end if
  1269. // don't let key fall through anywhere else
  1270. return MSG_HANDLED;
  1271. } // end escape
  1272. } // end switch( key )
  1273. } // end char
  1274. } // end switch( msg )
  1275. return MSG_IGNORED;
  1276. }// GameSpyPlayerInfoOverlayInput
  1277. void messageBoxYes( void );
  1278. //-------------------------------------------------------------------------------------------------
  1279. /** Overlay window system callback */
  1280. //-------------------------------------------------------------------------------------------------
  1281. WindowMsgHandledType GameSpyPlayerInfoOverlaySystem( GameWindow *window, UnsignedInt msg,
  1282. WindowMsgData mData1, WindowMsgData mData2 )
  1283. {
  1284. UnicodeString txtInput;
  1285. switch( msg )
  1286. {
  1287. case GWM_CREATE:
  1288. {
  1289. break;
  1290. } // case GWM_DESTROY:
  1291. case GWM_DESTROY:
  1292. {
  1293. break;
  1294. } // case GWM_DESTROY:
  1295. case GWM_INPUT_FOCUS:
  1296. {
  1297. // if we're givin the opportunity to take the keyboard focus we must say we want it
  1298. if( mData1 == TRUE )
  1299. *(Bool *)mData2 = TRUE;
  1300. return MSG_HANDLED;
  1301. }//case GWM_INPUT_FOCUS:
  1302. case GBM_SELECTED:
  1303. {
  1304. GameWindow *control = (GameWindow *)mData1;
  1305. Int controlID = control->winGetWindowId();
  1306. if (controlID == buttonCloseID)
  1307. {
  1308. RefreshGameListBoxes();
  1309. GameSpyCloseOverlay( GSOVERLAY_PLAYERINFO );
  1310. }
  1311. else if (controlID == buttonBuddiesID)
  1312. {
  1313. RefreshGameListBoxes();
  1314. //GameSpyCloseOverlay( GSOVERLAY_PLAYERINFO );
  1315. GameSpyOpenOverlay( GSOVERLAY_BUDDY );
  1316. }
  1317. // else if (controlID == buttonOptionsID)
  1318. // {
  1319. // RefreshGameListBoxes();
  1320. // GameSpyCloseOverlay( GSOVERLAY_PLAYERINFO );
  1321. // GameSpyOpenOverlay( GSOVERLAY_OPTIONS );
  1322. // }
  1323. else if (controlID == buttonSetLocaleID)
  1324. {
  1325. RefreshGameListBoxes();
  1326. GameSpyCloseOverlay( GSOVERLAY_PLAYERINFO );
  1327. if (!GameSpyIsOverlayOpen(GSOVERLAY_LOCALESELECT))
  1328. GameSpyOpenOverlay( GSOVERLAY_LOCALESELECT );
  1329. ReOpenPlayerInfo();
  1330. }
  1331. else if (controlID == buttonDeleteAccountID)
  1332. {
  1333. RefreshGameListBoxes();
  1334. GameSpyCloseOverlay( GSOVERLAY_PLAYERINFO );
  1335. MessageBoxYesNo(TheGameText->fetch("GUI:DeleteAccount"), TheGameText->fetch("GUI:AreYouSureDeleteAccount"),messageBoxYes, NULL);
  1336. }
  1337. else if (controlID == checkBoxAsianFontID)
  1338. {
  1339. Bool isChecked = !GadgetCheckBoxIsChecked(control);
  1340. CustomMatchPreferences pref;
  1341. pref.setDisallowAsianText(isChecked);
  1342. pref.write();
  1343. if(TheGameSpyInfo)
  1344. TheGameSpyInfo->setDisallowAsianText(isChecked);
  1345. if(isChecked && !GadgetCheckBoxIsChecked(checkBoxNonAsianFont))
  1346. {
  1347. GadgetCheckBoxSetChecked(checkBoxNonAsianFont, TRUE);
  1348. CustomMatchPreferences pref;
  1349. pref.setDisallowNonAsianText(FALSE);
  1350. pref.write();
  1351. if(TheGameSpyInfo)
  1352. TheGameSpyInfo->setDisallowNonAsianText(FALSE);
  1353. }
  1354. }
  1355. else if (controlID == checkBoxNonAsianFontID)
  1356. {
  1357. Bool isChecked = !GadgetCheckBoxIsChecked(control);
  1358. CustomMatchPreferences pref;
  1359. pref.setDisallowNonAsianText(isChecked);
  1360. pref.write();
  1361. if(TheGameSpyInfo)
  1362. TheGameSpyInfo->setDisallowNonAsianText(isChecked);
  1363. if(isChecked && !GadgetCheckBoxIsChecked(checkBoxAsianFont))
  1364. {
  1365. GadgetCheckBoxSetChecked(checkBoxAsianFont, TRUE);
  1366. CustomMatchPreferences pref;
  1367. pref.setDisallowAsianText(FALSE);
  1368. pref.write();
  1369. if(TheGameSpyInfo)
  1370. TheGameSpyInfo->setDisallowAsianText(FALSE);
  1371. }
  1372. }
  1373. break;
  1374. }// case GBM_SELECTED:
  1375. default:
  1376. return MSG_IGNORED;
  1377. }//Switch
  1378. return MSG_HANDLED;
  1379. }// GameSpyPlayerInfoOverlaySystem
  1380. static void messageBoxYes( void )
  1381. {
  1382. BuddyRequest breq;
  1383. breq.buddyRequestType = BuddyRequest::BUDDYREQUEST_DELETEACCT;
  1384. TheGameSpyBuddyMessageQueue->addRequest( breq );
  1385. TheGameSpyInfo->setLocalProfileID(0);
  1386. }