| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419 |
- /*
- ** 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/dlgmpwolpagereply.cpp $*
- * *
- * Author:: Patrick Smith *
- * *
- * $Modtime:: 8/26/02 4:31p $*
- * *
- * $Revision:: 14 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "DlgMPWOLPageReply.h"
- #include "DlgMPWOLAddBuddy.h"
- #include "DlgMPWOLAddIgnoreEntry.h"
- #include "WOLLogonMgr.h"
- #include "Resource.h"
- #include "consolemode.h"
- #include <WWUI\ListCtrl.h>
- DlgWOLPageReply* DlgWOLPageReply::_mInstance = NULL;
- /******************************************************************************
- *
- * NAME
- * DlgWOLPageReply::DoDialog
- *
- * DESCRIPTION
- * Start page reply dialog. There can only be one page reply dialog present
- * at a time therefore if a page reply dialog is already displayed it will
- * brought forward.
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * True if dialog created successfully.
- *
- ******************************************************************************/
- bool DlgWOLPageReply::DoDialog(void)
- {
- DlgWOLPageReply* dialog = _mInstance;
- if (dialog == NULL)
- {
- dialog = new DlgWOLPageReply;
- if (dialog)
- {
- if (dialog->FinalizeCreate())
- {
- dialog->Start_Dialog();
- }
- dialog->Release_Ref();
- }
- }
- return (dialog != NULL);
- }
- /******************************************************************************
- *
- * NAME
- * DlgWOLPageReply::IsOpen
- *
- * DESCRIPTION
- * Default constructor
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- bool DlgWOLPageReply::IsOpen(void)
- {
- return (NULL != _mInstance);
- }
- /******************************************************************************
- *
- * NAME
- * DlgWOLPageReply::DlgWOLPageReply
- *
- * DESCRIPTION
- * Default constructor
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- DlgWOLPageReply::DlgWOLPageReply(void) :
- PopupDialogClass(IDD_MP_WOL_PAGE_REPLY),
- mBuddyMgr(NULL)
- {
- WWDEBUG_SAY(("DlgWOLPageReply Instantiated\n"));
- WWASSERT(_mInstance == NULL);
- _mInstance = this;
- }
- /******************************************************************************
- *
- * NAME
- * DlgWOLPageReply::~DlgWOLPageReply
- *
- * DESCRIPTION
- * Destructor
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- DlgWOLPageReply::~DlgWOLPageReply()
- {
- WWDEBUG_SAY(("DlgWOLPageReply Destroyed\n"));
- if (mBuddyMgr)
- {
- mBuddyMgr->Release_Ref();
- }
- _mInstance = NULL;
- }
- /******************************************************************************
- *
- * NAME
- * DlgWOLPageReply::FinalizeCreate
- *
- * DESCRIPTION
- * Post creation initialization.
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * True if successful
- *
- ******************************************************************************/
- bool DlgWOLPageReply::FinalizeCreate(void)
- {
- mBuddyMgr = WOLBuddyMgr::GetInstance(false);
- return (mBuddyMgr != NULL);
- }
- /******************************************************************************
- *
- * NAME
- * DlgWOLPageReply::On_Init_Dialog
- *
- * DESCRIPTION
- * One time dialog initialization
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgWOLPageReply::On_Init_Dialog(void)
- {
- // Configure the list control that shows the page messages
- ListCtrlClass* list = (ListCtrlClass*)Get_Dlg_Item(IDC_MESSAGE_LIST);
- if (list)
- {
- list->Add_Column(L"", 1.0F, Vector3(1, 1, 1));
- list->Allow_Selection(false);
- }
- // Enable the invite button if we are in a situation to invite users.
- bool canInvite = mBuddyMgr->CanInviteUsers();
- Enable_Dlg_Item(IDC_INVITE_BUDDY_BUTTON, canInvite);
- Observer<WOLPagedEvent>::NotifyMe(*mBuddyMgr);
- PopupDialogClass::On_Init_Dialog();
- }
- /******************************************************************************
- *
- * NAME
- * DlgWOLPageReply::On_Command
- *
- * DESCRIPTION
- * Handle commands from dialog controls
- *
- * INPUTS
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgWOLPageReply::On_Command(int ctrlID, int message, DWORD param)
- {
- switch (ctrlID)
- {
- case IDC_ADD_BUDDY_BUTTON:
- {
- MPWolAddBuddyPopupClass* dialog = new MPWolAddBuddyPopupClass;
- if (dialog)
- {
- const WCHAR* pagersName = mBuddyMgr->GetLastPagersName();
- dialog->Set_Default_User_Name(pagersName);
- dialog->Start_Dialog();
- dialog->Release_Ref();
- }
- break;
- }
- case IDC_IGNORE_PLAYER_BUTTON:
- {
- const WCHAR* pagersName = mBuddyMgr->GetLastPagersName();
- MPWolAddIgnoreEntry::DoDialog(pagersName);
- }
- break;
- case IDC_INVITE_BUDDY_BUTTON:
- {
- const WCHAR* pagersName = mBuddyMgr->GetLastPagersName();
- mBuddyMgr->InviteUser(pagersName, Get_Dlg_Item_Text(IDC_REPLY_EDIT));
- End_Dialog();
- }
- break;
- case IDOK:
- case IDC_REPLY_BUTTON:
- Send_Reply();
- break;
- }
- PopupDialogClass::On_Command(ctrlID, message, param);
- }
- /******************************************************************************
- *
- * NAME
- * DlgWOLPageReply::Send_Reply
- *
- * DESCRIPTION
- * Send reply message to the last user who paged.
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgWOLPageReply::Send_Reply(void)
- {
- const WCHAR* pagersName = mBuddyMgr->GetLastPagersName();
- if (pagersName && (wcslen(pagersName) > 0))
- {
- WideStringClass reply(0, true);
- reply = Get_Dlg_Item_Text(IDC_REPLY_EDIT);
- reply.Trim();
- if (reply.Is_Empty() == false)
- {
- // Send the reply and clear the text
- mBuddyMgr->PageUser(pagersName, reply);
- // Add this message to the list
- WideStringClass name(0, true);
- WOLLogonMgr::GetLoginName(name);
- Add_Message(name, reply);
- }
- Set_Dlg_Item_Text(IDC_REPLY_EDIT, L"");
- }
- }
- /******************************************************************************
- *
- * NAME
- * DlgWOLPageReply::Add_Message
- *
- * DESCRIPTION
- * Add a message to the message display area.
- *
- * INPUTS
- * Username - Name of user message is from.
- * Message - Message text.
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgWOLPageReply::Add_Message(const WCHAR* username, const WCHAR* message)
- {
- ListCtrlClass* list = (ListCtrlClass*)Get_Dlg_Item(IDC_MESSAGE_LIST);
- if (list)
- {
- // Build the message
- if (username) {
- WideStringClass text(255, true);
- text.Format(L"%s: %s", username, message);
- list->Insert_Entry(list->Get_Entry_Count(), text);
- } else {
- list->Insert_Entry(list->Get_Entry_Count(), message);
- }
- // Scroll to the end of the list
- list->Scroll_To_End();
- }
- }
- /******************************************************************************
- *
- * NAME
- * DlgWOLPageReply::HandleNotification(WOLPagedEvent)
- *
- * DESCRIPTION
- * Handle page message events.
- *
- * INPUTS
- * Event - Page event.
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgWOLPageReply::HandleNotification(WOLPagedEvent& event)
- {
- WWOnline::PageMessage* page = event.Subject();
- WWASSERT(page && "NULL page in WOLPagedEvent");
- const WCHAR* pager = NULL;
- if (!ConsoleBox.Is_Exclusive())
- {
- if (PAGE_RECEIVED == event.GetAction())
- {
- pager = page->GetPagersName();
- }
- Add_Message(pager, page->GetPageMessage());
- }
- }
- /******************************************************************************
- *
- * NAME
- * DlgWOLPageReply::On_EditCtrl_Enter_Pressed
- *
- * DESCRIPTION
- * Handle enter key being pressed in edit control. Use this notification
- * to send the reply text automatically without requiring the user to click
- * the reply button.
- *
- * INPUTS
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgWOLPageReply::On_EditCtrl_Enter_Pressed(EditCtrlClass* edit, int id)
- {
- if (IDC_REPLY_EDIT == id)
- {
- Send_Reply();
- }
- }
|