| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361 |
- /*
- ** 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/DlgWebPage.cpp $
- *
- * DESCRIPTION
- * Web Browser dialog
- *
- * PROGRAMMER
- * Denzil E. Long, Jr.
- * $Author: Denzil_l $
- *
- * VERSION INFO
- * $Revision: 9 $
- * $Modtime: 10/30/01 10:08p $
- *
- ******************************************************************************/
- #include "DlgWebPage.h"
- #include "WebBrowser.h"
- #include <WWUI\PopupDialog.h>
- #include <WWUI\DialogControl.h>
- #include <Combat\DirectInput.h>
- #include <WW3D2\WW3D.h>
- #include "DlgMessageBox.h"
- #include "Resource.h"
- #include <Combat\String_IDs.h>
- #include "WWDebug.h"
- /******************************************************************************
- *
- * NAME
- * DlgWebPage::DoDialog
- *
- * DESCRIPTION
- * Show the specified web page.
- *
- * INPUTS
- * Page - Page to display.
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgWebPage::DoDialog(char* page)
- {
- WWASSERT_PRINT(page && (strlen(page) > 0), "Invalid parameter.\n");
- if ((page == NULL) || (strlen(page) == 0))
- {
- return;
- }
- DlgWebPage* dialog = new DlgWebPage;
- if (dialog)
- {
- bool success = dialog->FinalizeCreate();
- if (success)
- {
- // If we are using the embedded browser then show the webpage. Otherwise
- // ask the user if they want to launch an external browser to view the page.
- if (dialog->mBrowser->UsingEmbeddedBrowser())
- {
- dialog->Start_Dialog();
- dialog->mBrowser->ShowWebPage(page);
- }
- else
- {
- // Increment the dialog reference so the dialog will be around for the
- // message box result.
- dialog->Add_Ref();
- dialog->mPage = page;
- DlgMsgBox::DoDialog(0, IDS_WEB_LAUNCHBROWSER,
- DlgMsgBox::YesNo, static_cast< Observer<DlgMsgBoxEvent>* >(dialog));
- }
- }
- // The dialog manager keeps a referenece to the dialog.
- dialog->Release_Ref();
- }
- }
- /******************************************************************************
- *
- * NAME
- * DlgWebPage::DlgWebPage
- *
- * DESCRIPTION
- * Default constructor
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- DlgWebPage::DlgWebPage() :
- DialogBaseClass(IDD_WEBPAGE),
- mBrowser(NULL)
- {
- WWDEBUG_SAY(("Instantiating DlgWebPage\n"));
- }
- /******************************************************************************
- *
- * NAME
- * DlgWebPage::~DlgWebPage
- *
- * DESCRIPTION
- * Destructor
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- DlgWebPage::~DlgWebPage()
- {
- WWDEBUG_SAY(("Destroying DlgWebPage\n"));
- if (mBrowser)
- {
- mBrowser->Release();
- }
- }
- /******************************************************************************
- *
- * NAME
- * DlgWebPage::FinalizeCreate
- *
- * DESCRIPTION
- * Finalize object creation. (Initialize object)
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * Success - True if successful; False if failed.
- *
- ******************************************************************************/
- bool DlgWebPage::FinalizeCreate(void)
- {
- mBrowser = WebBrowser::CreateInstance(MainWindow);
- if (mBrowser)
- {
- Observer<WebEvent>::NotifyMe(*mBrowser);
- return true;
- }
- return false;
- }
- /******************************************************************************
- *
- * NAME
- * DlgWebPage::Start_Dialog
- *
- * DESCRIPTION
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgWebPage::Start_Dialog(void)
- {
- DirectInput::Unacquire();
- WW3D::Flip_To_Primary();
- DialogBaseClass::Start_Dialog();
- }
- /******************************************************************************
- *
- * NAME
- * DlgWebPage::End_Dialog
- *
- * DESCRIPTION
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgWebPage::End_Dialog(void)
- {
- DirectInput::Acquire();
- DialogBaseClass::End_Dialog();
- SetFocus(MainWindow);
- }
- /******************************************************************************
- *
- * NAME
- * DlgWebPage::On_Frame_Update
- *
- * DESCRIPTION
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgWebPage::On_Frame_Update(void)
- {
- DialogBaseClass::On_Frame_Update();
- if (mBrowser)
- {
- bool usingEmbedded = mBrowser->UsingEmbeddedBrowser();
- if (!usingEmbedded)
- {
- bool externalRunning = mBrowser->IsExternalBrowserRunning();
- bool gameActivated = (GameInFocus || (GetTopWindow(NULL) == MainWindow)
- || (GetForegroundWindow() == MainWindow));
- if (!externalRunning || gameActivated)
- {
- WWDEBUG_SAY(("***** Reactivating Game *****\n"));
- HWND topWindow = GetTopWindow(NULL);
- if (topWindow != MainWindow)
- {
- SetForegroundWindow(MainWindow);
- ShowWindow(MainWindow, SW_RESTORE);
- }
- End_Dialog();
- }
- }
- }
- }
- /******************************************************************************
- *
- * NAME
- * DlgWebPage::HandleNotification(WebEvent)
- *
- * DESCRIPTION
- * Handle web event notifications
- *
- * INPUTS
- * WebEvent - WebEvent to handle
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgWebPage::HandleNotification(WebEvent& event)
- {
- switch (event.Event())
- {
- case WebEvent::Quit:
- End_Dialog();
- break;
- case WebEvent::CertificationFailed:
- {
- WebBrowser* browser = event.Subject();
- browser->Hide();
- DlgMsgBox::DoDialog(IDS_WEB_ERROR, IDS_WEB_PAGEFAILED);
- End_Dialog();
- }
- break;
- default:
- break;
- }
- }
- /******************************************************************************
- *
- * NAME
- * DlgWebPage::HandleNotification(DlgMsgBoxEvent)
- *
- * DESCRIPTION
- * Handle message box dialog event notifications
- *
- * INPUTS
- * DlgMsgBoxEvent - Message box event to handle.
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgWebPage::HandleNotification(DlgMsgBoxEvent& event)
- {
- switch (event.Event())
- {
- case DlgMsgBoxEvent::Yes:
- // Start the dialog to monitor the external browser.
- Start_Dialog();
- mBrowser->ShowWebPage(mPage);
- // Release the reference we added to keep the dialog alive until this point.
- Release_Ref();
- break;
- case DlgMsgBoxEvent::No:
- // Release the reference we added to keep the dialog alive until this point.
- Release_Ref();
- break;
- default:
- break;
- }
- }
|