| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392 |
- /*
- ** 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/dlgmovieoptions.cpp $*
- * *
- * Author:: Patrick Smith *
- * *
- * $Modtime:: 1/15/02 9:28p $*
- * *
- * $Revision:: 7 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "dlgmovieoptions.h"
- #include "listctrl.h"
- #include "binkmovie.h"
- #include "registry.h"
- #include "translatedb.h"
- #include "_globals.h"
- #include "string_ids.h"
- #include "wwaudio.h"
- ////////////////////////////////////////////////////////////////
- //
- // MovieOptionsMenuClass
- //
- ////////////////////////////////////////////////////////////////
- MovieOptionsMenuClass::MovieOptionsMenuClass (void) :
- IsPlaying (false),
- MenuDialogClass (IDD_OPTIONS_MOVIES)
- {
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Init_Dialog
- //
- ////////////////////////////////////////////////////////////////
- void
- MovieOptionsMenuClass::On_Init_Dialog (void)
- {
- //
- // Get a pointer to the list control
- //
- ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_LIST_CTRL);
- if (list_ctrl != NULL) {
- //
- // Configure the list control
- //
- list_ctrl->Add_Column (TRANSLATE (IDS_MOVIE_COL_HEADER), 1.0F, Vector3 (1, 1, 1));
- //
- // Add the movies to the list...
- //
- RegistryClass registry (APPLICATION_SUB_KEY_NAME_MOVIES);
- if (registry.Is_Valid ()) {
- const char *INTRO_MOVIE = "DATA\\MOVIES\\R_INTRO.BIK";
-
- //
- // Insert the renegade intro movie by default...
- //
- int item_index = list_ctrl->Insert_Entry (0xFF, TRANSLATE (IDS_INTRO_MOVIE));
- if (item_index != -1) {
- list_ctrl->Set_Entry_Data (item_index, 0, (DWORD)new StringClass (INTRO_MOVIE));
- }
- //
- // Get the list of entries from the registry
- //
- DynamicVectorClass<StringClass> list;
- registry.Get_Value_List (list);
- //
- // Loop over all the movies in the registry
- //
- for (int index = 0; index < list.Count (); index ++) {
- StringClass string_id_des;
- registry.Get_String (list[index], string_id_des);
- //
- // Add an entry for this movie
- //
- const WCHAR *wide_desc = TRANSLATE_BY_DESC(string_id_des);
- int item_index = list_ctrl->Insert_Entry (0xFF, wide_desc);
- if (item_index != -1) {
- list_ctrl->Set_Entry_Data (item_index, 0, (DWORD)new StringClass (list[index]));
- }
- }
- }
- }
- MenuDialogClass::On_Init_Dialog ();
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Command
- //
- ////////////////////////////////////////////////////////////////
- void
- MovieOptionsMenuClass::On_Command (int ctrl_id, int message_id, DWORD param)
- {
- if (IsPlaying) {
- return ;
- }
- //
- // Play the movie if the user clicked the play button
- //
- if (ctrl_id == IDC_MENU_PLAY_MOVIE_BUTTON) {
- Begin_Play_Movie ();
- }
- MenuDialogClass::On_Command (ctrl_id, message_id, param);
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_ListCtrl_Delete_Entry
- //
- ////////////////////////////////////////////////////////////////
- void
- MovieOptionsMenuClass::On_ListCtrl_Delete_Entry
- (
- ListCtrlClass *list_ctrl,
- int ctrl_id,
- int item_index
- )
- {
- if (IsPlaying) {
- return ;
- }
- if (ctrl_id == IDC_LIST_CTRL) {
-
- //
- // Remove the data we associated with this entry
- //
- StringClass *filename = (StringClass *)list_ctrl->Get_Entry_Data (item_index, 0);
- list_ctrl->Set_Entry_Data (item_index, 0, 0);
- if (filename != NULL) {
- delete filename;
- }
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_ListCtrl_DblClk
- //
- ////////////////////////////////////////////////////////////////
- void
- MovieOptionsMenuClass::On_ListCtrl_DblClk
- (
- ListCtrlClass *list_ctrl,
- int ctrl_id,
- int item_index
- )
- {
- if (IsPlaying) {
- return ;
- }
- Begin_Play_Movie ();
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Begin_Play_Movie
- //
- ////////////////////////////////////////////////////////////////
- void
- MovieOptionsMenuClass::Begin_Play_Movie (void)
- {
- //
- // Get a pointer to the list control
- //
- ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_LIST_CTRL);
- if (list_ctrl == NULL) {
- return ;
- }
-
- //
- // Get the currently selected entry
- //
- int curr_sel = list_ctrl->Get_Curr_Sel ();
- if (curr_sel != -1) {
- StringClass *filename = (StringClass *)list_ctrl->Get_Entry_Data (curr_sel, 0);
-
- //
- // Play the movie (if it exists locally)
- //
- if (::GetFileAttributes (filename->Peek_Buffer ()) != 0xFFFFFFFF) {
- Play_Movie (filename->Peek_Buffer ());
- } else {
- //
- // Strip any path information off the filename
- //
- StringClass filename_only (filename->Peek_Buffer (), true);
- const char *delimiter = ::strrchr (filename->Peek_Buffer (), '\\');
- if (delimiter != NULL) {
- filename_only = delimiter + 1;
- }
- //
- // Try to find the CD...
- //
- StringClass cd_path;
- if (CDVerifier.Get_CD_Path (cd_path)) {
-
- //
- // Build a full-path to the movie on the CD
- //
- StringClass full_path = cd_path;
- if (cd_path[cd_path.Get_Length () - 1] != '\\') {
- full_path += "\\";
- }
- full_path += filename_only;
- Play_Movie (full_path);
- } else {
- PendingMovieFilename = filename_only;
- CDVerifier.Display_UI (this);
- }
- }
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Play_Movie
- //
- ////////////////////////////////////////////////////////////////
- void
- MovieOptionsMenuClass::Play_Movie (const char *filename)
- {
- WWAudioClass::Get_Instance ()->Temp_Disable_Audio (true);
-
- FontCharsClass* font = StyleMgrClass::Get_Font(StyleMgrClass::FONT_INGAME_SUBTITLE_TXT);
- BINKMovie::Play (filename, "data\\subtitle.ini", font);
-
- if (font) {
- font->Release_Ref();
- }
- IsPlaying = true;
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Render
- //
- ////////////////////////////////////////////////////////////////
- void
- MovieOptionsMenuClass::Render (void)
- {
- //
- // Render the movie or stop it from playing as necessary
- //
- if (IsPlaying) {
- if (BINKMovie::Is_Complete () == false) {
- BINKMovie::Render ();
- } else {
- WWAudioClass::Get_Instance ()->Temp_Disable_Audio (false);
- BINKMovie::Stop ();
- IsPlaying = false;
- }
- }
- MenuDialogClass::Render ();
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Frame_Update
- //
- ////////////////////////////////////////////////////////////////
- void
- MovieOptionsMenuClass::On_Frame_Update (void)
- {
- //
- // Let the movie update (if nececessary)
- //
- BINKMovie::Update ();
- MenuDialogClass::On_Frame_Update ();
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Key_Down
- //
- ////////////////////////////////////////////////////////////////
- bool
- MovieOptionsMenuClass::On_Key_Down (uint32 key_id, uint32 key_data)
- {
- bool retval = false;
-
- //
- // Stop playing the movie on any keypress
- //
- if (IsPlaying && key_id == VK_ESCAPE) {
- WWAudioClass::Get_Instance ()->Temp_Disable_Audio (false);
- BINKMovie::Stop ();
- IsPlaying = false;
- retval = true;
- } else if (IsPlaying == false) {
- retval = MenuDialogClass::On_Key_Down (key_id, key_data);
- }
- return retval;
- }
- ////////////////////////////////////////////////////////////////
- //
- // HandleNotification
- //
- ////////////////////////////////////////////////////////////////
- void
- MovieOptionsMenuClass::HandleNotification (CDVerifyEvent &event)
- {
- if (event.Event () == CDVerifyEvent::VERIFIED) {
- //
- // Get the path to the CD...
- //
- StringClass cd_path;
- if (CDVerifier.Get_CD_Path (cd_path)) {
-
- //
- // Build a full-path to the movie on the CD
- //
- StringClass full_path = cd_path;
- if (cd_path[cd_path.Get_Length () - 1] != '\\') {
- full_path += "\\";
- }
- full_path += PendingMovieFilename;
- Play_Movie (full_path);
- }
- }
- PendingMovieFilename = "";
- return ;
- }
|