| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- /*
- ** 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/>.
- */
- /******************************************************************************
- *
- * FILE
- * $Archive: /Commando/Code/Commando/DlgPasswordPrompt.cpp $
- *
- * DESCRIPTION
- * General purpose password entry dialog for joining a game.
- *
- * PROGRAMMER
- * Denzil E. Long, Jr.
- * $Author: Denzil_l $
- *
- * VERSION INFO
- * $Revision: 3 $
- * $Modtime: 11/29/01 9:19p $
- *
- ******************************************************************************/
- #include "DlgPasswordPrompt.h"
- #include <WWUI\EditCtrl.h>
- /******************************************************************************
- *
- * NAME
- * DlgPasswordPrompt::DoDialog
- *
- * DESCRIPTION
- * Create a dialog to prompt the user to enter a password.
- *
- * INPUTS
- * Target - Target to receive signal that a password was entered.
- *
- * RESULT
- * True if dialog created successfully.
- *
- ******************************************************************************/
- bool DlgPasswordPrompt::DoDialog(Signaler<DlgPasswordPrompt>* target)
- {
- DlgPasswordPrompt* dialog = new DlgPasswordPrompt;
- if (dialog)
- {
- dialog->Start_Dialog();
- if (target)
- {
- dialog->SignalMe(*target);
- }
- dialog->Release_Ref();
- }
- return (dialog != NULL);
- }
- /******************************************************************************
- *
- * NAME
- * DlgPasswordPrompt::DlgPasswordPrompt
- *
- * DESCRIPTION
- * Constructor
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- DlgPasswordPrompt::DlgPasswordPrompt() :
- PopupDialogClass(IDD_MP_JOIN_PASSWORD)
- {
- WWDEBUG_SAY(("DlgPasswordPrompt Instantiated\n"));
- }
- /******************************************************************************
- *
- * NAME
- * DlgPasswordPrompt::~DlgPasswordPrompt
- *
- * DESCRIPTION
- * Destructor
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- DlgPasswordPrompt::~DlgPasswordPrompt()
- {
- WWDEBUG_SAY(("DlgPasswordPrompt Destroyed\n"));
- }
- /******************************************************************************
- *
- * NAME
- * DlgPasswordPrompt::GetPassword
- *
- * DESCRIPTION
- * Retrieve the password entered by the user.
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * Password - Pointer to password string.
- *
- ******************************************************************************/
- const WCHAR* DlgPasswordPrompt::GetPassword(void) const
- {
- return Get_Dlg_Item_Text(IDC_PASSWORD_EDIT);
- }
- /******************************************************************************
- *
- * NAME
- * DlgPasswordPrompt::On_Init_Dialog
- *
- * DESCRIPTION
- * One time dialog initialization.
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgPasswordPrompt::On_Init_Dialog(void)
- {
- // Disable the join button until the user enters text.
- Enable_Dlg_Item(IDC_JOIN_GAME_BUTTON, false);
- EditCtrlClass* edit = (EditCtrlClass*)Get_Dlg_Item(IDC_PASSWORD_EDIT);
- if (edit)
- {
- edit->Set_Focus();
- }
- PopupDialogClass::On_Init_Dialog();
- }
- /******************************************************************************
- *
- * NAME
- * DlgPasswordPrompt::On_Command
- *
- * DESCRIPTION
- * Handle command messages from dialog controls.
- *
- * INPUTS
- * CtrlID - ID of control sending command.
- * Message - Message identifier.
- * Param - Message parameter
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgPasswordPrompt::On_Command(int ctrlID, int message, DWORD param)
- {
- if (IDC_JOIN_GAME_BUTTON == ctrlID)
- {
- Signaler<DlgPasswordPrompt>::SendSignal(*this);
- End_Dialog();
- }
- PopupDialogClass::On_Command(ctrlID, message, param);
- }
- /******************************************************************************
- *
- * NAME
- * DlgPasswordPrompt::On_EditCtrl_Change
- *
- * DESCRIPTION
- * Handle notification that the contents of the edit control has changed.
- *
- * INPUTS
- * Edit - Pointer to edit control whose contents has changed.
- * ID - Identifier of control.
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgPasswordPrompt::On_EditCtrl_Change(EditCtrlClass* edit, int id)
- {
- if (IDC_PASSWORD_EDIT == id)
- {
- const WCHAR* text = edit->Get_Text();
- bool enableJoin = (text && (wcslen(text) > 0));
- Enable_Dlg_Item(IDC_JOIN_GAME_BUTTON, enableJoin);
- }
- }
- /******************************************************************************
- *
- * NAME
- * DlgPasswordPrompt::On_EditCtrl_Enter_Pressed
- *
- * DESCRIPTION
- * Handle notification that the enter key was pressed in an edit control.
- *
- * INPUTS
- * Edit - Pointer to edit control whose contents has changed.
- * ID - Identifier of control.
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgPasswordPrompt::On_EditCtrl_Enter_Pressed(EditCtrlClass* edit, int id)
- {
- if ((IDC_PASSWORD_EDIT == id) && Is_Dlg_Item_Enabled(IDC_JOIN_GAME_BUTTON))
- {
- On_Command(IDC_JOIN_GAME_BUTTON, 0, 0);
- }
- }
|