dlgmpwolbuddies.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. /*
  2. ** Command & Conquer Renegade(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. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Combat *
  23. * *
  24. * $Archive:: /Commando/Code/Commando/dlgmpwolbuddies.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/15/02 3:35p $*
  29. * *
  30. * $Revision:: 28 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "DlgMPWolBuddies.h"
  36. #include "RenegadeDialogMgr.h"
  37. #include "WOLBuddyMgr.h"
  38. #include "DlgMPWolPageBuddy.h"
  39. #include "DlgMPWolAddBuddy.h"
  40. #include "DlgMPWoldeletebuddy.h"
  41. #include "DlgMPWolIgnoreList.h"
  42. #include "ww3d.h"
  43. #include "translatedb.h"
  44. #include "string_ids.h"
  45. #include <WWUI\ListCtrl.h>
  46. #include <WWUI\ComboBoxCtrl.h>
  47. #include <WWUI\DialogMgr.h>
  48. #include <WWUI\shortcutbarctrl.h>
  49. #include <WWOnline\WOLUser.h>
  50. #include <WWOnline\WOLSquad.h>
  51. ////////////////////////////////////////////////////////////////
  52. // Local constants
  53. ////////////////////////////////////////////////////////////////
  54. static enum
  55. {
  56. COL_NAME = 0,
  57. COL_CLAN,
  58. COL_LOCATION,
  59. COL_WINS,
  60. COL_DEATHS,
  61. COL_POINTS,
  62. COL_RANK
  63. };
  64. MPWolBuddiesMenuClass* MPWolBuddiesMenuClass::_mInstance = NULL;
  65. void MPWolBuddiesMenuClass::Display(void)
  66. {
  67. // Create the dialog if necessary, otherwise simply bring it to the front
  68. if (_mInstance == NULL) {
  69. MPWolBuddiesMenuClass* dialog = new MPWolBuddiesMenuClass;
  70. if (dialog) {
  71. dialog->Start_Dialog();
  72. dialog->Release_Ref();
  73. }
  74. } else {
  75. if (_mInstance->Is_Active_Menu() == false) {
  76. DialogMgrClass::Rollback(_mInstance);
  77. }
  78. }
  79. }
  80. ////////////////////////////////////////////////////////////////
  81. //
  82. // MPWolBuddiesMenuClass
  83. //
  84. ////////////////////////////////////////////////////////////////
  85. MPWolBuddiesMenuClass::MPWolBuddiesMenuClass (void) :
  86. MenuDialogClass(IDD_MP_WOL_BUDDIES),
  87. mBuddyListChanged(false),
  88. mBuddyInfoChanged(false)
  89. {
  90. WWDEBUG_SAY(("MPWolBuddiesMenuClass: Instantiated\n"));
  91. WWASSERT(_mInstance == NULL);
  92. _mInstance = this;
  93. // Get the buddy manager object
  94. mBuddyMgr = WOLBuddyMgr::GetInstance (true);
  95. WWASSERT_PRINT(mBuddyMgr, "WOLBuddyMgr failed to instantiate.");
  96. }
  97. ////////////////////////////////////////////////////////////////
  98. //
  99. // ~MPWolBuddiesMenuClass
  100. //
  101. ////////////////////////////////////////////////////////////////
  102. MPWolBuddiesMenuClass::~MPWolBuddiesMenuClass (void)
  103. {
  104. WWDEBUG_SAY(("MPWolBuddiesMenuClass: Destroyed\n"));
  105. REF_PTR_RELEASE (mBuddyMgr);
  106. _mInstance = NULL;
  107. }
  108. ////////////////////////////////////////////////////////////////
  109. //
  110. // On_Init_Dialog
  111. //
  112. ////////////////////////////////////////////////////////////////
  113. void
  114. MPWolBuddiesMenuClass::On_Init_Dialog (void)
  115. {
  116. // Configure the shortcut bar
  117. ShortcutBarCtrlClass *bar = (ShortcutBarCtrlClass *)Get_Dlg_Item (IDC_SHORTCUT_BAR);
  118. if (bar != NULL) {
  119. bar->Add_Button(IDC_MP_SHORTCUT_CHAT, TRANSLATE(IDS_MP_SHORTCUT_CHAT));
  120. bar->Add_Button(IDC_MP_SHORTCUT_GAMELIST, TRANSLATE(IDS_MENU_TEXT365));
  121. bar->Add_Button(IDC_MP_WOL_BUDDIES_IGNORE_BUTTON, TRANSLATE(IDS_MENU_TEXT378));
  122. bar->Add_Button(IDC_MP_SHORTCUT_INTERNET_OPTIONS, TRANSLATE(IDS_INTERNET_OPTIONS));
  123. #ifdef QUICKMATCH_OPTIONS
  124. bar->Add_Button(IDC_MP_SHORTCUT_QUICKMATCH_OPTIONS, TRANSLATE(IDS_MENU_TEXT364));
  125. #endif
  126. bar->Add_Button(IDC_MP_SHORTCUT_NEWS, TRANSLATE(IDS_MP_SHORTCUT_NEWS));
  127. bar->Add_Button(IDC_MP_SHORTCUT_CLANS, TRANSLATE(IDS_MP_SHORTCUT_CLANS));
  128. bar->Add_Button(IDC_MP_SHORTCUT_RANKINGS, TRANSLATE(IDS_MP_SHORTCUT_RANKINGS));
  129. bar->Add_Button(IDC_MP_SHORTCUT_NET_STATUS, TRANSLATE(IDS_MP_SHORTCUT_NET_STATUS));
  130. }
  131. // Get a pointer to the list control
  132. ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_BUDDY_LIST_CTRL);
  133. if (list_ctrl != NULL) {
  134. // Configure the columns
  135. list_ctrl->Add_Column(TRANSLATE(IDS_MP_BUDDY_LIST_NAME), 0.2F, Vector3 (1, 1, 1));
  136. list_ctrl->Add_Column(TRANSLATE (IDS_MENU_CLAN), 0.1F, Vector3 (1, 1, 1));
  137. list_ctrl->Add_Column(TRANSLATE(IDS_MP_BUDDY_LIST_LOCATION), 0.25F, Vector3 (1, 1, 1));
  138. list_ctrl->Add_Column(TRANSLATE(IDS_BUDDY_COL_WINS), 0.1F, Vector3 (1, 1, 1));
  139. list_ctrl->Add_Column(TRANSLATE(IDS_BUDDY_COL_DEATHS_KILLS), 0.15F, Vector3 (1, 1, 1));
  140. list_ctrl->Add_Column(TRANSLATE(IDS_BUDDY_COL_POINTS), 0.1F, Vector3 (1, 1, 1));
  141. list_ctrl->Add_Column(TRANSLATE(IDS_BUDDY_COL_RANK), 0.1F, Vector3 (1, 1, 1));
  142. list_ctrl->Allow_NoSelection(true);
  143. }
  144. ComboBoxCtrlClass* rankCombo = (ComboBoxCtrlClass*)Get_Dlg_Item(IDC_RANKTYPE);
  145. if (rankCombo) {
  146. int index = rankCombo->Add_String(TRANSLATE (IDS_MENU_INDIVIDUAL));
  147. rankCombo->Set_Item_Data(index, WWOnline::LadderType_Team);
  148. index = rankCombo->Add_String(TRANSLATE (IDS_MENU_CLAN));
  149. rankCombo->Set_Item_Data(index, WWOnline::LadderType_Clan);
  150. rankCombo->Set_Curr_Sel(0);
  151. }
  152. // Disable join, page and delete by default.
  153. Enable_Dlg_Item(IDC_MP_WOL_BUDDIES_JOIN_BUTTON, false);
  154. Enable_Dlg_Item(IDC_MP_WOL_BUDDIES_PAGE_BUTTON, false);
  155. Enable_Dlg_Item(IDC_MP_WOL_BUDDIES_DELETE_BUTTON, false);
  156. // Make sure we know about buddy events
  157. Observer<WOLBuddyMgrEvent>::NotifyMe (*mBuddyMgr);
  158. mBuddyMgr->RefreshBuddyList();
  159. MenuDialogClass::On_Init_Dialog ();
  160. }
  161. void MPWolBuddiesMenuClass::On_Frame_Update(void)
  162. {
  163. if (mBuddyListChanged) {
  164. Refresh_Buddy_List();
  165. }
  166. if (mBuddyInfoChanged) {
  167. Update_Buddy_List();
  168. }
  169. MenuDialogClass::On_Frame_Update();
  170. }
  171. ////////////////////////////////////////////////////////////////
  172. //
  173. // On_Command
  174. //
  175. ////////////////////////////////////////////////////////////////
  176. void
  177. MPWolBuddiesMenuClass::On_Command (int ctrl_id, int message_id, DWORD param)
  178. {
  179. switch (ctrl_id) {
  180. case IDC_MP_WOL_BUDDIES_PAGE_BUTTON:
  181. Page_Selected_User();
  182. break;
  183. case IDC_MP_WOL_BUDDIES_ADD_BUTTON:
  184. START_DIALOG(MPWolAddBuddyPopupClass);
  185. break;
  186. case IDC_MP_WOL_BUDDIES_REFRESH_BUTTON:
  187. mBuddyMgr->RefreshBuddyInfo();
  188. break;
  189. case IDC_MP_WOL_BUDDIES_DELETE_BUTTON: {
  190. // Get the name of the currently selected user so we can
  191. // pass it to the "Delete User" dialog
  192. WideStringClass buddy_name(0, true);
  193. Get_Selected_Buddy(buddy_name);
  194. // Display the dialog
  195. if (buddy_name.Is_Empty() == false) {
  196. MPWolDeleteBuddyPopupClass *dialog = new MPWolDeleteBuddyPopupClass;
  197. if (dialog) {
  198. dialog->Set_User_Name(buddy_name);
  199. dialog->Start_Dialog();
  200. REF_PTR_RELEASE (dialog);
  201. }
  202. }
  203. break;
  204. }
  205. case IDC_MP_WOL_BUDDIES_IGNORE_BUTTON:
  206. START_DIALOG(MPWolIgnoreListPopupClass);
  207. break;
  208. case IDC_MP_WOL_BUDDIES_JOIN_BUTTON: {
  209. // Get the name of the currently selected user so we can
  210. // pass it to the "Delete User" dialog
  211. WideStringClass buddy_name(0, true);
  212. Get_Selected_Buddy(buddy_name);
  213. // Try to join them
  214. if (buddy_name.Is_Empty() == false) {
  215. const RefPtr<WWOnline::UserData> buddy = mBuddyMgr->FindBuddy(buddy_name);
  216. mBuddyMgr->JoinUser(buddy);
  217. }
  218. break;
  219. }
  220. }
  221. MenuDialogClass::On_Command(ctrl_id, message_id, param);
  222. return ;
  223. }
  224. ////////////////////////////////////////////////////////////////
  225. //
  226. // Update_Buddy_Info
  227. //
  228. ////////////////////////////////////////////////////////////////
  229. void MPWolBuddiesMenuClass::Update_Buddy_Info(int index, const RefPtr<WWOnline::UserData>& user)
  230. {
  231. ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_BUDDY_LIST_CTRL);
  232. if (list_ctrl == NULL) {
  233. return ;
  234. }
  235. // Set the name
  236. list_ctrl->Set_Entry_Text(index, COL_NAME, user->GetName());
  237. // Set the clan
  238. RefPtr<WWOnline::SquadData> clan = user->GetSquad();
  239. if (clan.IsValid()) {
  240. WideStringClass clanName(0, true);
  241. clanName = clan->GetAbbr();
  242. list_ctrl->Set_Entry_Text(index, COL_CLAN, clanName);
  243. } else {
  244. list_ctrl->Set_Entry_Text(index, COL_CLAN, L"");
  245. }
  246. // Build a textual description of the user's location
  247. WideStringClass location_text(0, true);
  248. WOLBuddyMgr::GetLocationDescription(user, location_text);
  249. // Update the location column for this entry
  250. list_ctrl->Set_Entry_Text(index, COL_LOCATION, location_text);
  251. // Associate the user's location with this entry
  252. int location = user->GetLocation();
  253. list_ctrl->Set_Entry_Data(index, COL_LOCATION, location);
  254. }
  255. void MPWolBuddiesMenuClass::Update_Buddy_Ranking(int index, const RefPtr<WWOnline::UserData>& user)
  256. {
  257. ListCtrlClass* list = (ListCtrlClass*)Get_Dlg_Item(IDC_BUDDY_LIST_CTRL);
  258. if (list) {
  259. WWOnline::LadderType ladderType = WWOnline::LadderType_Team;
  260. ComboBoxCtrlClass* rankCombo = (ComboBoxCtrlClass*)Get_Dlg_Item(IDC_RANKTYPE);
  261. if (rankCombo) {
  262. int sel = rankCombo->Get_Curr_Sel();
  263. ladderType = (WWOnline::LadderType)rankCombo->Get_Item_Data(sel);
  264. }
  265. RefPtr<WWOnline::LadderData> ladder = user->GetLadderFromType(ladderType);
  266. if (ladder.IsValid()) {
  267. wchar_t text[64];
  268. swprintf(text, L"%d", ladder->GetWins());
  269. list->Set_Entry_Text(index, COL_WINS, text);
  270. swprintf(text, L"%d / %d", ladder->GetReserved1(), ladder->GetKills());
  271. list->Set_Entry_Text(index, COL_DEATHS, text);
  272. swprintf(text, L"%d", ladder->GetPoints());
  273. list->Set_Entry_Text(index, COL_POINTS, text);
  274. swprintf(text, L"%d", ladder->GetRung());
  275. list->Set_Entry_Text(index, COL_RANK, text);
  276. } else {
  277. list->Set_Entry_Text(index, COL_WINS, L"-");
  278. list->Set_Entry_Text(index, COL_DEATHS, L"- / -");
  279. list->Set_Entry_Text(index, COL_POINTS, L"-");
  280. list->Set_Entry_Text(index, COL_RANK, L"-");
  281. }
  282. }
  283. }
  284. ////////////////////////////////////////////////////////////////
  285. //
  286. // Refresh_Buddy_List
  287. //
  288. ////////////////////////////////////////////////////////////////
  289. void
  290. MPWolBuddiesMenuClass::Refresh_Buddy_List (void)
  291. {
  292. ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_BUDDY_LIST_CTRL);
  293. if (list_ctrl == NULL) {
  294. return ;
  295. }
  296. // Get the name of the currently selected user
  297. WideStringClass selected_user(0, true);
  298. int curr_sel = list_ctrl->Get_Curr_Sel();
  299. if (curr_sel != -1) {
  300. selected_user = list_ctrl->Get_Entry_Text(curr_sel, COL_NAME);
  301. }
  302. // Reset the list
  303. list_ctrl->Delete_All_Entries();
  304. // Loop over all the buddies
  305. const WWOnline::UserList& buddies = mBuddyMgr->GetBuddyList();
  306. const unsigned int count = buddies.size();
  307. for (unsigned int index = 0; index < count; ++index) {
  308. // Add the buddy to the list control
  309. int item_index = list_ctrl->Insert_Entry(list_ctrl->Get_Entry_Count() , L"");
  310. WWASSERT(item_index != -1);
  311. if (item_index != -1) {
  312. const RefPtr<WWOnline::UserData>& buddy = buddies[index];
  313. // Update this buddy's information
  314. Update_Buddy_Info(item_index, buddy);
  315. Update_Buddy_Ranking(item_index, buddy);
  316. // Do we need to select this user?
  317. if (selected_user.Compare_No_Case(buddy->GetName()) == 0) {
  318. list_ctrl->Set_Curr_Sel(item_index);
  319. Enable_Dlg_Item(IDC_MP_WOL_BUDDIES_DELETE_BUTTON, true);
  320. int location = buddy->GetLocation();
  321. Adjust_Buttons_For_Buddy_Location(location);
  322. }
  323. }
  324. }
  325. mBuddyListChanged = false;
  326. }
  327. void MPWolBuddiesMenuClass::Update_Buddy_List(void)
  328. {
  329. ListCtrlClass* list = (ListCtrlClass*)Get_Dlg_Item(IDC_BUDDY_LIST_CTRL);
  330. if (list) {
  331. int currSel = list->Get_Curr_Sel();
  332. // Loop over all the buddies
  333. const WWOnline::UserList& buddies = mBuddyMgr->GetBuddyList();
  334. unsigned int count = buddies.size();
  335. for (unsigned int index = 0; index < count; ++index) {
  336. const RefPtr<WWOnline::UserData>& buddy = buddies[index];
  337. // Add the buddy to the list control
  338. int item_index = list->Find_Entry(COL_NAME, buddy->GetName());
  339. if (item_index >= 0) {
  340. // Update this buddy's information
  341. Update_Buddy_Info(item_index, buddy);
  342. Update_Buddy_Ranking(item_index, buddy);
  343. // Do we need to select this user?
  344. if (item_index == currSel) {
  345. Enable_Dlg_Item(IDC_MP_WOL_BUDDIES_DELETE_BUTTON, true);
  346. int location = buddy->GetLocation();
  347. Adjust_Buttons_For_Buddy_Location(location);
  348. }
  349. }
  350. }
  351. }
  352. mBuddyInfoChanged = false;
  353. }
  354. ////////////////////////////////////////////////////////////////
  355. //
  356. // Get_Selected_Buddy
  357. //
  358. ////////////////////////////////////////////////////////////////
  359. void MPWolBuddiesMenuClass::Get_Selected_Buddy(WideStringClass& buddy_name)
  360. {
  361. // Get the index of the currently selected user in the list control
  362. ListCtrlClass* list_ctrl = (ListCtrlClass*)Get_Dlg_Item(IDC_BUDDY_LIST_CTRL);
  363. if (list_ctrl) {
  364. int curr_sel = list_ctrl->Get_Curr_Sel();
  365. if (curr_sel != -1) {
  366. // Return the user name to the caller
  367. buddy_name = list_ctrl->Get_Entry_Text(curr_sel, COL_NAME);
  368. }
  369. }
  370. }
  371. void MPWolBuddiesMenuClass::Adjust_Buttons_For_Buddy_Location(int location)
  372. {
  373. switch (location) {
  374. case WWOnline::USERLOCATION_NO_CHANNEL:
  375. // Allow paging if buddy is online
  376. Enable_Dlg_Item(IDC_MP_WOL_BUDDIES_PAGE_BUTTON, true);
  377. // Do not allow joining a buddy who is not in a channel.
  378. Enable_Dlg_Item(IDC_MP_WOL_BUDDIES_JOIN_BUTTON, false);
  379. break;
  380. case WWOnline::USERLOCATION_IN_CHANNEL:
  381. // Allow paging and joining of buddies in channels
  382. Enable_Dlg_Item(IDC_MP_WOL_BUDDIES_JOIN_BUTTON, true);
  383. Enable_Dlg_Item(IDC_MP_WOL_BUDDIES_PAGE_BUTTON, true);
  384. break;
  385. case WWOnline::USERLOCATION_OFFLINE:
  386. case WWOnline::USERLOCATION_HIDING:
  387. // Do not alllow joining or paging of buddies who are offline or hiding.
  388. Enable_Dlg_Item(IDC_MP_WOL_BUDDIES_JOIN_BUTTON, false);
  389. Enable_Dlg_Item(IDC_MP_WOL_BUDDIES_PAGE_BUTTON, false);
  390. break;
  391. default:
  392. break;
  393. }
  394. }
  395. ////////////////////////////////////////////////////////////////
  396. //
  397. // HandleNotification
  398. //
  399. ////////////////////////////////////////////////////////////////
  400. void
  401. MPWolBuddiesMenuClass::HandleNotification(WOLBuddyMgrEvent &event)
  402. {
  403. WOLBuddyMgrAction action = event.GetAction();
  404. if (BUDDYLIST_CHANGED == action) {
  405. mBuddyListChanged = true;
  406. } else if (BUDDYINFO_CHANGED == action) {
  407. mBuddyInfoChanged = true;
  408. }
  409. }
  410. ////////////////////////////////////////////////////////////////
  411. //
  412. // On_ListCtrl_Sel_Change
  413. //
  414. ////////////////////////////////////////////////////////////////
  415. void
  416. MPWolBuddiesMenuClass::On_ListCtrl_Sel_Change(ListCtrlClass* list, int id, int oldsel, int newsel)
  417. {
  418. if (IDC_BUDDY_LIST_CTRL == id) {
  419. if (newsel != -1) {
  420. Enable_Dlg_Item(IDC_MP_WOL_BUDDIES_DELETE_BUTTON, true);
  421. // Adjust the buttons based upon the location of the selected buddy.
  422. int location = list->Get_Entry_Data(newsel, COL_LOCATION);
  423. Adjust_Buttons_For_Buddy_Location(location);
  424. } else {
  425. // If unselecting then disable delete button
  426. Enable_Dlg_Item(IDC_MP_WOL_BUDDIES_DELETE_BUTTON, false);
  427. Adjust_Buttons_For_Buddy_Location(WWOnline::USERLOCATION_OFFLINE);
  428. }
  429. }
  430. }
  431. ////////////////////////////////////////////////////////////////
  432. //
  433. // On_ListCtrl_DblClk
  434. //
  435. ////////////////////////////////////////////////////////////////
  436. void
  437. MPWolBuddiesMenuClass::On_ListCtrl_DblClk(ListCtrlClass* list_ctrl, int ctrl_id, int item_index)
  438. {
  439. if (IDC_BUDDY_LIST_CTRL == ctrl_id) {
  440. // Get the index of the currently selected user in the list control
  441. int curr_sel = list_ctrl->Get_Curr_Sel();
  442. if (curr_sel != -1) {
  443. // Get the location associated with this entry
  444. int location = list_ctrl->Get_Entry_Data(curr_sel, COL_LOCATION);
  445. switch (location) {
  446. // Simply page the selected user
  447. case WWOnline::USERLOCATION_NO_CHANNEL:
  448. Page_Selected_User();
  449. break;
  450. // Join our buddy in the channel he is in.
  451. case WWOnline::USERLOCATION_IN_CHANNEL: {
  452. // Get the name of the selected user
  453. WideStringClass buddyName(64, true);
  454. Get_Selected_Buddy(buddyName);
  455. mPendingJoin = mBuddyMgr->FindBuddy(buddyName);
  456. if (mPendingJoin.IsValid()) {
  457. // Ask the user if they want to join this buddy
  458. WideStringClass message(0, true);
  459. message.Format(TRANSLATE (IDS_MENU_JOIN_REQUEST_MESSAGE), (const WCHAR*)buddyName);
  460. DlgMsgBox::DoDialog(0, message, DlgMsgBox::YesNo, this);
  461. }
  462. break;
  463. }
  464. // Do nothing for buddies who are offline or hiding.
  465. case WWOnline::USERLOCATION_OFFLINE:
  466. case WWOnline::USERLOCATION_HIDING:
  467. default:
  468. break;
  469. }
  470. }
  471. }
  472. }
  473. void MPWolBuddiesMenuClass::On_ComboBoxCtrl_Sel_Change(ComboBoxCtrlClass* , int id, int , int newsel)
  474. {
  475. if (id == IDC_RANKTYPE) {
  476. ListCtrlClass* list = (ListCtrlClass*)Get_Dlg_Item(IDC_BUDDY_LIST_CTRL);
  477. if (list) {
  478. int count = list->Get_Entry_Count();
  479. for (int index = 0; index < count; ++index) {
  480. const WCHAR* name = list->Get_Entry_Text(index, COL_NAME);
  481. RefPtr<WWOnline::UserData> buddy = mBuddyMgr->FindBuddy(name);
  482. if (buddy.IsValid()) {
  483. Update_Buddy_Ranking(index, buddy);
  484. }
  485. }
  486. }
  487. }
  488. }
  489. ////////////////////////////////////////////////////////////////
  490. //
  491. // HandleNotification
  492. //
  493. ////////////////////////////////////////////////////////////////
  494. void MPWolBuddiesMenuClass::HandleNotification(DlgMsgBoxEvent &event)
  495. {
  496. if (event.Event() == DlgMsgBoxEvent::Yes) {
  497. // Try to join this user
  498. if (mPendingJoin.IsValid()) {
  499. mBuddyMgr->JoinUser(mPendingJoin);
  500. }
  501. }
  502. mPendingJoin.Release();
  503. }
  504. ////////////////////////////////////////////////////////////////
  505. //
  506. // Page_Selected_User
  507. //
  508. ////////////////////////////////////////////////////////////////
  509. void MPWolBuddiesMenuClass::Page_Selected_User(void)
  510. {
  511. // Get the name of the currently selected user so we can
  512. // pass it to the page dialog
  513. WideStringClass buddy_name(64, true);
  514. Get_Selected_Buddy(buddy_name);
  515. // Show the dialog
  516. MPWolPageBuddyPopupClass* dialog = new MPWolPageBuddyPopupClass;
  517. WWASSERT(dialog && "Failed to create page buddy dialog");
  518. if (dialog) {
  519. dialog->Start_Dialog();
  520. dialog->Set_Buddy_Name(buddy_name);
  521. dialog->Release_Ref();
  522. }
  523. }