dlgmpwolbuddylistpopup.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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/dlgmpwolbuddylistpopup.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 12/01/01 7:35p $*
  29. * *
  30. * $Revision:: 7 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "dlgmpwolbuddylistpopup.h"
  36. #include "dlgmpwolpagebuddy.h"
  37. #include "WOLBuddyMgr.h"
  38. #include "listctrl.h"
  39. ////////////////////////////////////////////////////////////////
  40. //
  41. // MPWolBuddyListPopupClass
  42. //
  43. ////////////////////////////////////////////////////////////////
  44. MPWolBuddyListPopupClass::MPWolBuddyListPopupClass (void) :
  45. Observer (NULL),
  46. PopupDialogClass (IDD_MP_WOL_BUDDY_LIST_POPUP)
  47. {
  48. return ;
  49. }
  50. ////////////////////////////////////////////////////////////////
  51. //
  52. // On_Init_Dialog
  53. //
  54. ////////////////////////////////////////////////////////////////
  55. void
  56. MPWolBuddyListPopupClass::On_Init_Dialog (void)
  57. {
  58. //
  59. // Configure the list ctrl
  60. //
  61. ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_BUDDY_LIST_CTRL);
  62. if (list_ctrl != NULL) {
  63. list_ctrl->Add_Column (L"", 1.0F, Vector3 (1, 1, 1));
  64. //
  65. // Loop over all the buddies
  66. //
  67. WOLBuddyMgr* buddyMgr = WOLBuddyMgr::GetInstance(false);
  68. if (buddyMgr) {
  69. const WWOnline::UserList& list = buddyMgr->GetBuddyList();
  70. const unsigned int count = list.size();
  71. for (unsigned int index = 0; index < count; ++index) {
  72. const RefPtr<WWOnline::UserData>& user = list[index];
  73. if (user->GetLocation() != WWOnline::USERLOCATION_OFFLINE) {
  74. list_ctrl->Insert_Entry(index, user->GetName());
  75. }
  76. }
  77. buddyMgr->Release_Ref();
  78. }
  79. }
  80. PopupDialogClass::On_Init_Dialog ();
  81. return ;
  82. }
  83. ////////////////////////////////////////////////////////////////
  84. //
  85. // On_Command
  86. //
  87. ////////////////////////////////////////////////////////////////
  88. void
  89. MPWolBuddyListPopupClass::On_Command (int ctrl_id, int message_id, DWORD param)
  90. {
  91. switch (ctrl_id)
  92. {
  93. case IDC_SELECT_BUTTON:
  94. On_Select ();
  95. break;
  96. }
  97. PopupDialogClass::On_Command (ctrl_id, message_id, param);
  98. return ;
  99. }
  100. ////////////////////////////////////////////////////////////////
  101. //
  102. // On_ListCtrl_DblClk
  103. //
  104. ////////////////////////////////////////////////////////////////
  105. void
  106. MPWolBuddyListPopupClass::On_ListCtrl_DblClk
  107. (
  108. ListCtrlClass *list_ctrl,
  109. int ctrl_id,
  110. int item_index
  111. )
  112. {
  113. On_Select ();
  114. return ;
  115. }
  116. ////////////////////////////////////////////////////////////////
  117. //
  118. // On_Select
  119. //
  120. ////////////////////////////////////////////////////////////////
  121. void
  122. MPWolBuddyListPopupClass::On_Select (void)
  123. {
  124. ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_BUDDY_LIST_CTRL);
  125. if (list_ctrl == NULL) {
  126. return ;
  127. }
  128. //
  129. // Get the currently selected entry from the list control
  130. //
  131. int curr_sel = list_ctrl->Get_Curr_Sel ();
  132. if (curr_sel != -1) {
  133. //
  134. // Record the name of the entry
  135. //
  136. SelectedUserName = list_ctrl->Get_Entry_Text (curr_sel, 0);
  137. //
  138. // Notify the observer (if necessary)
  139. //
  140. if (Observer != NULL) {
  141. Observer->Set_Buddy_Name(SelectedUserName);
  142. }
  143. End_Dialog ();
  144. }
  145. return ;
  146. }