| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- /*
- ** Command & Conquer Renegade(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /***********************************************************************************************
- *** 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 ***
- ***********************************************************************************************
- * *
- * Project Name : Combat *
- * *
- * $Archive:: /Commando/Code/commando/dlgmpwoladdbuddy.cpp $*
- * *
- * Author:: Patrick Smith *
- * *
- * $Modtime:: 12/14/01 5:40p $*
- * *
- * $Revision:: 9 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "DlgMPWOLAddBuddy.h"
- #include "WOLBuddyMgr.h"
- #include "WOLLogonMgr.h"
- #include "DlgMessageBox.h"
- #include <WWUI\EditCtrl.h>
- #include <WWDebug\WWDebug.h>
- #include "translatedb.h"
- #include "string_ids.h"
- ////////////////////////////////////////////////////////////////
- //
- // MPWolAddBuddyPopupClass
- //
- ////////////////////////////////////////////////////////////////
- MPWolAddBuddyPopupClass::MPWolAddBuddyPopupClass (void) :
- PopupDialogClass (IDD_MP_WOL_ADD_BUDDY)
- {
- WWDEBUG_SAY(("MPWolAddBuddyPopupClass: Instantiated\n"));
- mBuddyMgr = WOLBuddyMgr::GetInstance(false);
- WWASSERT_PRINT(mBuddyMgr, "WOLBuddyMgr not instantiated!");
- return ;
- }
- MPWolAddBuddyPopupClass::~MPWolAddBuddyPopupClass()
- {
- WWDEBUG_SAY(("MPWolAddBuddyPopupClass: Destroyed\n"));
- if (mBuddyMgr) {
- mBuddyMgr->Release_Ref();
- }
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Init_Dialog
- //
- ////////////////////////////////////////////////////////////////
- void
- MPWolAddBuddyPopupClass::On_Init_Dialog (void)
- {
- EditCtrlClass* edit = (EditCtrlClass*)Get_Dlg_Item(IDC_BUDDY_NAME_EDIT);
- if (edit) {
- // WOL logins have a 9 character maximum.
- edit->Set_Text_Limit(9);
- edit->Set_Text(DefaultUserName);
- }
- // Disable the add button if the default user is empty.
- if (DefaultUserName.Is_Empty()) {
- Enable_Dlg_Item(IDC_ADD_BUTTON, false);
- }
- PopupDialogClass::On_Init_Dialog ();
- return ;
- }
- void MPWolAddBuddyPopupClass::On_Activate (bool onoff)
- {
- PopupDialogClass::On_Activate(onoff);
- if (onoff == true) {
- EditCtrlClass* edit = (EditCtrlClass*)Get_Dlg_Item(IDC_BUDDY_NAME_EDIT);
- if (edit) {
- edit->Set_Focus();
- }
- }
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Command
- //
- ////////////////////////////////////////////////////////////////
- void
- MPWolAddBuddyPopupClass::On_Command (int ctrl_id, int message_id, DWORD param)
- {
- switch (ctrl_id)
- {
- case IDC_ADD_BUTTON:
- Add_Buddy();
- break;
- }
- PopupDialogClass::On_Command (ctrl_id, message_id, param);
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Add_Buddy
- //
- ////////////////////////////////////////////////////////////////
- void
- MPWolAddBuddyPopupClass::Add_Buddy (void)
- {
- WideStringClass buddy_name(0, true);
- buddy_name = Get_Dlg_Item_Text(IDC_BUDDY_NAME_EDIT);
- buddy_name.Trim();
- if (buddy_name.Is_Empty() == false) {
- WideStringClass loginName(0, true);
- WOLLogonMgr::GetLoginName(loginName);
- if (buddy_name.Compare_No_Case(loginName) != 0) {
- mBuddyMgr->AddBuddy(buddy_name);
- End_Dialog();
- } else {
- Set_Dlg_Item_Text(IDC_BUDDY_NAME_EDIT, L"");
- Enable_Dlg_Item(IDC_ADD_BUTTON, false);
- DlgMsgBox::DoDialog(TRANSLATE (IDS_MENU_ERROR), TRANSLATE (IDS_MENU_CANT_ADD_AS_BUDDY_MESSAGE));
- }
- }
- return ;
- }
- void MPWolAddBuddyPopupClass::On_EditCtrl_Change(EditCtrlClass* edit, int id)
- {
- if (IDC_BUDDY_NAME_EDIT == id) {
- // Do not allow leading or trailing whitespace
- WideStringClass text(0, true);
- text = edit->Get_Text();
- text.Trim();
- edit->Set_Text(text);
- bool enable (edit->Get_Text_Length() > 0);
- Enable_Dlg_Item(IDC_ADD_BUTTON, enable);
- }
- }
- void MPWolAddBuddyPopupClass::On_EditCtrl_Enter_Pressed(EditCtrlClass* edit, int id)
- {
- if (IDC_BUDDY_NAME_EDIT == id) {
- Add_Buddy();
- }
- }
|