dlgmpchangelannickname.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. *
  20. * FILE
  21. * $Archive: /Commando/Code/Commando/dlgmpchangelannickname.cpp $
  22. *
  23. * DESCRIPTION
  24. * Handle LAN nickname collision.
  25. *
  26. * PROGRAMMER
  27. * Tom
  28. *
  29. * VERSION INFO
  30. * $Revision: 1 $
  31. * $Modtime: 1/04/02 4:14p $
  32. *
  33. ******************************************************************************/
  34. #include "dlgmpchangelannickname.h"
  35. #include <WWUI\EditCtrl.h>
  36. #include "netinterface.h"
  37. #include "dlgmplangamelist.h"
  38. int DlgMpChangeLanNickname::DialogCount = 0;
  39. //-----------------------------------------------------------------------------
  40. bool DlgMpChangeLanNickname::DoDialog(void)
  41. {
  42. DlgMpChangeLanNickname* dialog = NULL;
  43. if (DialogCount == 0) {
  44. dialog = new DlgMpChangeLanNickname;
  45. }
  46. if (dialog)
  47. {
  48. dialog->Start_Dialog();
  49. dialog->Release_Ref();
  50. }
  51. return (dialog != NULL);
  52. }
  53. //-----------------------------------------------------------------------------
  54. DlgMpChangeLanNickname::DlgMpChangeLanNickname() :
  55. PopupDialogClass(IDD_MP_CHANGE_LAN_NICKNAME)
  56. {
  57. WWDEBUG_SAY(("DlgMpChangeLanNickname Instantiated\n"));
  58. DialogCount++;
  59. }
  60. //-----------------------------------------------------------------------------
  61. DlgMpChangeLanNickname::~DlgMpChangeLanNickname()
  62. {
  63. WWDEBUG_SAY(("DlgMpChangeLanNickname Destroyed\n"));
  64. DialogCount--;
  65. }
  66. //-----------------------------------------------------------------------------
  67. void DlgMpChangeLanNickname::On_Init_Dialog(void)
  68. {
  69. Enable_Dlg_Item(IDOK, false);
  70. EditCtrlClass* edit = (EditCtrlClass*)Get_Dlg_Item(IDC_NICKNAME_EDIT);
  71. if (edit)
  72. {
  73. edit->Set_Text_Limit(9);
  74. edit->Set_Text(cNetInterface::Get_Nickname());
  75. edit->Set_Focus();
  76. }
  77. PopupDialogClass::On_Init_Dialog();
  78. }
  79. //-----------------------------------------------------------------------------
  80. void DlgMpChangeLanNickname::On_Command(int ctrlID, int message, DWORD param)
  81. {
  82. if (IDOK == ctrlID)
  83. {
  84. WideStringClass nickname = Get_Dlg_Item_Text (IDC_NICKNAME_EDIT);
  85. cNetInterface::Set_Nickname (nickname);
  86. MPLanGameListMenuClass::Set_Update_Nickname();
  87. End_Dialog();
  88. }
  89. PopupDialogClass::On_Command(ctrlID, message, param);
  90. }
  91. //-----------------------------------------------------------------------------
  92. void DlgMpChangeLanNickname::On_EditCtrl_Change(EditCtrlClass* edit, int id)
  93. {
  94. if (IDC_NICKNAME_EDIT == id)
  95. {
  96. const WCHAR* text = edit->Get_Text();
  97. bool enableok = (text && (wcslen(text) > 0));
  98. Enable_Dlg_Item(IDOK, enableok);
  99. }
  100. }
  101. //-----------------------------------------------------------------------------
  102. void DlgMpChangeLanNickname::On_EditCtrl_Enter_Pressed(EditCtrlClass* edit, int id)
  103. {
  104. if ((IDC_NICKNAME_EDIT == id) && Is_Dlg_Item_Enabled(IDOK))
  105. {
  106. On_Command(IDOK, 0, 0);
  107. }
  108. }