| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- /*
- ** 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/>.
- */
- /******************************************************************************
- *
- * NAME
- * $Archive: /Commando/Code/Commando/DlgMessageBox.cpp $
- *
- * DESCRIPTION
- * Popup message dialog.
- *
- * PROGRAMMER
- * Denzil E. Long, Jr.
- * $Author: Denzil_l $
- *
- * VERSION INFO
- * $Revision: 7 $
- * $Modtime: 10/02/01 2:42p $
- *
- ******************************************************************************/
- #include "DlgMessageBox.h"
- #include "Resource.h"
- #include <WWTranslateDB\TranslateDB.h>
- #include "WWDebug.h"
- //
- // Class statics
- //
- int DlgMsgBox::CurrentCount = 0;
- /******************************************************************************
- *
- * NAME
- * DlgMsgBox::DoDialog
- *
- * DESCRIPTION
- * Create a Popup message box dialog.
- *
- * INPUTS
- * Title - Message box title
- * Text - Message content
- *
- * RESULT
- * Object - Instance of message box
- *
- ******************************************************************************/
- bool DlgMsgBox::DoDialog(const WCHAR* title, const WCHAR* text,
- DlgMsgBox::Type type, Observer<DlgMsgBoxEvent>* observer, unsigned long user_data)
- {
- DlgMsgBox* popup = new DlgMsgBox;
- if (popup)
- {
- popup->SetResourceType(type);
- popup->Start_Dialog();
- popup->Set_Title(title);
- popup->Set_Dlg_Item_Text(IDC_MESSAGE, text);
- popup->Set_User_Data(user_data);
- if (observer)
- {
- popup->AddObserver(*observer);
- }
- popup->Release_Ref();
- }
- return (popup != NULL);
- }
- /******************************************************************************
- *
- * NAME
- * DlgMsgBox::DoDialog
- *
- * DESCRIPTION
- * Create a Popup message box dialog.
- *
- * INPUTS
- * TitleID - ID of message box title
- * TextID - ID of message content
- *
- * RESULT
- * Object - Instance of message box
- *
- ******************************************************************************/
- bool DlgMsgBox::DoDialog(int titleID, int textID,
- DlgMsgBox::Type type, Observer<DlgMsgBoxEvent>* observer, unsigned long user_data)
- {
- const WCHAR* title = TranslateDBClass::Get_String(titleID);
- const WCHAR* text = TranslateDBClass::Get_String(textID);
- return DoDialog(title, text, type, observer, user_data);
- }
- /******************************************************************************
- *
- * NAME
- * DlgMsgBox::DlgMsgBox
- *
- * DESCRIPTION
- * Constructor
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- DlgMsgBox::DlgMsgBox() :
- mUserData(0),
- PopupDialogClass(IDD_MESSAGEBOX_OK)
- {
- CurrentCount++;
- }
- /******************************************************************************
- *
- * NAME
- * DlgMsgBox::~DlgMsgBox
- *
- * DESCRIPTION
- * Destructor
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- DlgMsgBox::~DlgMsgBox()
- {
- CurrentCount--;
- WWASSERT(CurrentCount >= 0);
- }
- /******************************************************************************
- *
- * NAME
- * DlgMsgBox::SetResourceType
- *
- * DESCRIPTION
- * Set the type of dialog box to use.
- *
- * INPUTS
- *
- * RESULT
- *
- ******************************************************************************/
- void DlgMsgBox::SetResourceType(DlgMsgBox::Type type)
- {
- static UINT _types[] =
- {
- IDD_MESSAGEBOX_OK,
- IDD_MESSAGEBOX_YESNO
- };
- DialogResID = _types[type];
- }
- /******************************************************************************
- *
- * NAME
- * DlgMsgBox::End_Dialog
- *
- * DESCRIPTION
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgMsgBox::End_Dialog(void)
- {
- Add_Ref();
- DlgMsgBoxEvent event(DlgMsgBoxEvent::Quitting, this, mUserData);
- NotifyObservers(event);
- Release_Ref();
- PopupDialogClass::End_Dialog();
- }
- /******************************************************************************
- *
- * NAME
- * DlgMsgBox::On_Command
- *
- * DESCRIPTION
- * Process command message
- *
- * INPUTS
- * Ctrl - ID of control
- * Message -
- * Param -
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgMsgBox::On_Command(int ctrl, int message, DWORD param)
- {
- switch (ctrl)
- {
- case IDOK:
- {
- Add_Ref();
-
- DlgMsgBoxEvent event(DlgMsgBoxEvent::Okay, this, mUserData);
- NotifyObservers(event);
-
- Release_Ref();
- End_Dialog();
- }
- break;
- case IDYES:
- {
- Add_Ref();
-
- DlgMsgBoxEvent event(DlgMsgBoxEvent::Yes, this, mUserData);
- NotifyObservers(event);
-
- Release_Ref();
- End_Dialog();
- }
- break;
- case IDNO:
- {
- Add_Ref();
-
- DlgMsgBoxEvent event(DlgMsgBoxEvent::No, this, mUserData);
- NotifyObservers(event);
- Release_Ref();
- End_Dialog();
- }
- break;
- default:
- PopupDialogClass::On_Command(ctrl, message, param);
- break;
- }
- }
|