////////////////////////////////////////////////////////////////////////////////
// private
bool LLMediaImplQuickTime::unload()
{
	if ( mMovieHandle )
	{
		StopMovie( mMovieHandle );
		if ( mMovieController )
		{
			MCMovieChanged( mMovieController, mMovieHandle );
		};
	};

	if ( mMovieController )
	{
		MCSetActionFilterWithRefCon( mMovieController, NULL, (long)this );
		DisposeMovieController( mMovieController );
		mMovieController = NULL;
	};

	if ( mMovieHandle )
	{
		SetMovieDrawingCompleteProc( mMovieHandle, movieDrawingCallWhenChanged, nil, ( long )this );
		DisposeMovie ( mMovieHandle );
		mMovieHandle = NULL;
	};

	if ( mGWorldHandle )
	{
		DisposeGWorld( mGWorldHandle );
		mGWorldHandle = NULL;
	};

	return true;
}
Пример #2
0
int PlayMovie(const char *filename) {

	char* str=malloc(1024);

	if(Movie.Status == Recording)
		StopMovie();


	if ((Movie.fp = fopen(filename, "r+b")) == NULL)
	{
		free(str);
		return -1;
	}

	strcpy(str, filename);
	Movie.filename=str;
	PlaybackFileOpened=1;
	framecounter=0;
	Movie.ReadOnly = 1;
	Movie.Status=Playback;
	Movie.Size = MovieGetSize(Movie.fp);
	strcpy(MovieStatus, "Playback Started");
	ReadHeader(Movie.fp);
	YabauseReset();
	return 0;
}
Пример #3
0
void LoadGameShort(char filename[256]) {
	pcejin.romLoaded = true;
	pcejin.started = true;
if(!MDFNI_LoadGame(filename)) {
			pcejin.started = false;
			pcejin.romLoaded = false;
			
		}
		if (AutoRWLoad)
		{
			//Open Ram Watch if its auto-load setting is checked
			OpenRWRecentFile(0);
			RamWatchHWnd = CreateDialog(winClass.hInstance, MAKEINTRESOURCE(IDD_RAMWATCH), g_hWnd, (DLGPROC) RamWatchProc);
		}
		StopMovie();
		RecentROMs.UpdateRecentItems(filename);

		std::string romname = noExtension(RemovePath(filename));
		GameName = romname;
		std::string temp = pcejin.versionName;
		temp.append(" ");
		temp.append(romname);
		
		SetWindowText(g_hWnd, temp.c_str());
	}
Пример #4
0
		void Tracker::Unload()
		{
			frame = 0;

			if (rewinder)
				rewinder->Unload();
			else
				StopMovie();
		}
Пример #5
0
		Result Tracker::Execute
		(
			Machine& machine,
			Video::Output* const video,
			Sound::Output* const sound,
			Input::Controllers* input
		)
		{
			if (machine.Is(Api::Machine::ON))
			{
				++frame;

				try
				{
					if (machine.Is(Api::Machine::GAME))
					{
						if (rewinder)
						{
							rewinder->Execute( video, sound, input );
							return RESULT_OK;
						}
						else if (movie)
						{
							if (!movie->Execute())
							{
								StopMovie();
							}
							else if (movie->IsPlaying())
							{
								input = NULL;
							}
						}
					}

					machine.Execute( video, sound, input );
					return RESULT_OK;
				}
				catch (Result result)
				{
					return machine.PowerOff( result );
				}
				catch (const std::bad_alloc&)
				{
					return machine.PowerOff( RESULT_ERR_OUT_OF_MEMORY );
				}
				catch (...)
				{
					return machine.PowerOff( RESULT_ERR_GENERIC );
				}
			}
			else
			{
				return RESULT_ERR_NOT_READY;
			}
		}
Пример #6
0
TLevelReader3gp::~TLevelReader3gp()
{
	StopMovie(m_movie);

	if (m_refNum)
		CloseMovieFile(m_refNum);
	if (m_movie)
		DisposeMovie(m_movie);
	//ExitMovies();
	//TerminateQTML();
}
//------------------------------------------------------------
void ofQuicktimeSoundPlayer::setPaused(bool bP){
	if (getIsPlaying() == true){
		bPaused = bP;
		if (bP == true){
			StopMovie(soundToPlay);
		} else {
			StartMovie(soundToPlay);
		}
		
	}
}
Пример #8
0
void wxOSXQuickTimeSoundData::DoStop()
{
    if( m_movie )
    {
        StopMovie(m_movie);
        DisposeMovie(m_movie);
        m_movie = NULL;
        wxSound::SoundStopped(this);
        wxExitQT();
    }
}
Пример #9
0
		Result Tracker::PlayMovie(Machine& emulator,std::istream& stream)
		{
			if (!emulator.Is(Api::Machine::GAME))
				return RESULT_ERR_NOT_READY;

			UpdateRewinderState( false );

			Result result;

			try
			{
				if (movie == NULL)
				{
					movie = new Movie
					(
						emulator,
						&Machine::LoadState,
						&Machine::SaveState,
						emulator.cpu,
						emulator.Is(Api::Machine::CARTRIDGE) ? emulator.image->GetPrgCrc() : 0
					);
				}

				if (movie->Play( stream ))
				{
					if (emulator.Is(Api::Machine::ON))
						emulator.Reset( true );

					return RESULT_OK;
				}
				else
				{
					return RESULT_NOP;
				}
			}
			catch (Result r)
			{
				result = r;
			}
			catch (const std::bad_alloc&)
			{
				result = RESULT_ERR_OUT_OF_MEMORY;
			}
			catch (...)
			{
				result = RESULT_ERR_GENERIC;
			}

			StopMovie();

			return result;
		}
Пример #10
0
void MIDI_Stop(void)
{
	if (!bMidiInited)	//Just to be safe
		return;

	if (midiTrack)
	{
		StopMovie (midiTrack);
		DisposeMovie (midiTrack);
		midiTrack = NULL;
		bPaused = false;
	}
}
Пример #11
0
void LoadGame(){

	char szChoice[MAX_PATH]={0};
	OPENFILENAME ofn;
	ZeroMemory(&ofn, sizeof(ofn));
	ofn.lStructSize = sizeof(ofn);
	ofn.hwndOwner = g_hWnd;
	ofn.lpstrFilter = "PC Engine Files (*.pce, *.cue, *.toc, *.sgx *.zip)\0*.pce;*.cue;*.toc;*.sgx;*.zip\0All files(*.*)\0*.*\0\0";
	ofn.lpstrFile = (LPSTR)szChoice;
	ofn.lpstrTitle = "Select a file to open";
	ofn.lpstrDefExt = "pce";
	ofn.nMaxFile = MAX_PATH;
	ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
	if(GetOpenFileName(&ofn)) {
		pcejin.romLoaded = true;
		pcejin.started = true;
		if(strlen(szChoice) > 4 && (!strcasecmp(szChoice + strlen(szChoice) - 4, ".cue") || !strcasecmp(szChoice + strlen(szChoice) - 4, ".toc"))) {
			char ret[MAX_PATH];
			GetPrivateProfileString("Main", "Bios", "pce.cdbios PATH NOT SET", ret, MAX_PATH, IniName);
			if(std::string(ret) == "pce.cdbios PATH NOT SET") {
				pcejin.started = false;
				pcejin.romLoaded = false;
				MDFN_DispMessage("specify your PCE CD bios");
				return;
			}
		}
		if(!MDFNI_LoadGame(szChoice)) {
			pcejin.started = false;
			pcejin.romLoaded = false;
			
		}
		if (AutoRWLoad)
		{
			//Open Ram Watch if its auto-load setting is checked
			OpenRWRecentFile(0);
			RamWatchHWnd = CreateDialog(winClass.hInstance, MAKEINTRESOURCE(IDD_RAMWATCH), g_hWnd, (DLGPROC) RamWatchProc);
		}
		StopMovie();
		ResetFrameCount();
		RecentROMs.UpdateRecentItems(szChoice);

		std::string romname = noExtension(RemovePath(szChoice));
		std::string temp = pcejin.versionName;
		GameName = romname;
		temp.append(" ");
		temp.append(romname);
		SetWindowText(g_hWnd, temp.c_str());
	}
}
Пример #12
0
void wxOSXQuickTimeSoundData::SoundTask()
{
    if(IsMovieDone(m_movie))
    {
        if (m_flags & wxSOUND_LOOP)
        {
            StopMovie(m_movie);
            GoToBeginningOfMovie(m_movie);
            StartMovie(m_movie);
        }
        else
            Stop();
    }
    else
        MoviesTask(m_movie, MOVIE_DELAY); //Give QT time to play movie
}
//--------------------------------------------------------
void ofVideoPlayer::stop(){

	//--------------------------------------
	#ifdef OF_VIDEO_PLAYER_QUICKTIME
	//--------------------------------------

	StopMovie (moviePtr);
	bPlaying = false;
	SetMovieActive (moviePtr, false);

	//--------------------------------------
	#endif
	//--------------------------------------


}
Пример #14
0
void MIDI_Pause(int mode)
{
	if (!midiTrack)
		return;

	if ((mode == MIDI_TOGGLE_PAUSE && bPaused) || mode == MIDI_ALWAYS_RESUME)
	{
		StartMovie (midiTrack);
		bPaused = false;
	}
	else
	{
		StopMovie (midiTrack);
		bPaused = true;
	}
}
Пример #15
0
    virtual ~wxQTTimer()
    {
        if(m_pbPlaying)
            *m_pbPlaying = false;

        StopMovie(m_movie);
        DisposeMovie(m_movie);
        Stop();

        //Note that ExitMovies() is not necessary, but
        //the docs are fuzzy on whether or not TerminateQTML is
        ExitMovies();

#ifndef __WXMAC__
        TerminateQTML();
#endif
    }
Пример #16
0
/**
 * Stops playing the current song, if the player is active.
 */
void MusicDriver_QtMidi::StopSong()
{
	if (!_quicktime_started) return;

	switch (_quicktime_state) {
		case QT_STATE_IDLE:
			FALLTHROUGH;

		case QT_STATE_STOP:
			DEBUG(driver, 3, "qtmidi: stop requested, but already idle");
			/* Do nothing. */
			break;

		case QT_STATE_PLAY:
			StopMovie(_quicktime_movie);
			_quicktime_state = QT_STATE_STOP;
			DEBUG(driver, 3, "qtmidi: player stopped");
	}
}
Пример #17
0
		Result Tracker::RecordMovie(Machine& emulator,std::iostream& stream,const bool append)
		{
			if (!emulator.Is(Api::Machine::GAME))
				return RESULT_ERR_NOT_READY;

			UpdateRewinderState( false );

			Result result;

			try
			{
				if (movie == NULL)
				{
					movie = new Movie
					(
						emulator,
						&Machine::LoadState,
						&Machine::SaveState,
						emulator.cpu,
						emulator.image->GetPrgCrc()
					);
				}

				return movie->Record( stream, append ) ? RESULT_OK : RESULT_NOP;
			}
			catch (Result r)
			{
				result = r;
			}
			catch (const std::bad_alloc&)
			{
				result = RESULT_ERR_OUT_OF_MEMORY;
			}
			catch (...)
			{
				result = RESULT_ERR_GENERIC;
			}

			StopMovie();

			return result;
		}
//--------------------------------------------------------
void ofQuickTimePlayer::stop(){
	if( !isLoaded() ){
		ofLog(OF_LOG_ERROR, "ofQuickTimePlayer: movie not loaded!");
		return;
	}
	
	//--------------------------------------
	#ifdef OF_VIDEO_PLAYER_QUICKTIME
	//--------------------------------------

	StopMovie (moviePtr);
	SetMovieActive (moviePtr, false);
	bStarted = false;

	//--------------------------------------
	#endif
	//--------------------------------------

	bPlaying = false;
}
//--------------------------------------------------------
void ofVideoPlayer::stop(){

	//--------------------------------------
	#ifdef OF_VIDEO_PLAYER_QUICKTIME
	//--------------------------------------

	StopMovie (moviePtr);
	SetMovieActive (moviePtr, false);
	bStarted = false;

	//--------------------------------------
	#else
	//--------------------------------------

	gstUtils.setPaused(true);

	//--------------------------------------
	#endif
	//--------------------------------------
}
Пример #20
0
int SaveMovie(const char *filename) {

    char* str=malloc(1024);

    if(Movie.Status == Playback)
        StopMovie();

    if ((Movie.fp = fopen(filename, "w+b")) == NULL)
        return -1;

    strcpy(str, filename);
    Movie.filename=str;
    RecordingFileOpened=1;
    framecounter=0;
    Movie.Status=Recording;
    strcpy(MovieStatus, "Recording Started");
    Movie.Rerecords=0;
    WriteHeader(Movie.fp);
    YabauseReset();
    return 0;
}
Пример #21
0
    void Notify()
    {
        if (m_pbPlaying && !*m_pbPlaying)
        {
            Shutdown();
        }

        if(IsMovieDone(m_movie))
        {
            if (!m_bLoop)
                Shutdown();
            else
            {
                StopMovie(m_movie);
                GoToBeginningOfMovie(m_movie);
                StartMovie(m_movie);
            }
        }
        else
            MoviesTask(m_movie, MOVIE_DELAY); //Give QT time to play movie
    }
Пример #22
0
		Result Tracker::Execute
		(
			Machine& emulator,
			Video::Output* const video,
			Sound::Output* const sound,
			Input::Controllers* input
		)
		{
			if (emulator.Is(Api::Machine::ON))
			{
				++frame;

				if (emulator.Is(Api::Machine::GAME))
				{
					if (rewinder)
					{
						rewinder->Execute( video, sound, input );
						return RESULT_OK;
					}
					else if (movie)
					{
						if (!movie->Execute())
						{
							StopMovie();
						}
						else if (movie->IsPlaying())
						{
							input = NULL;
						}
					}
				}

				emulator.Execute( video, sound, input );
				return RESULT_OK;
			}
			else
			{
				return RESULT_ERR_NOT_READY;
			}
		}
/*
 *  PsychQTDeleteMovie() -- Delete a movie object and release all associated ressources.
 */
void PsychQTDeleteMovie(int moviehandle)
{
    if (moviehandle < 0 || moviehandle >= PSYCH_MAX_MOVIES) {
        PsychErrorExitMsg(PsychError_user, "Invalid moviehandle provided!");
    }
    
    if (movieRecordBANK[moviehandle].theMovie == NULL) {
        PsychErrorExitMsg(PsychError_user, "Invalid moviehandle provided. No movie associated with this handle !!!");
    }
        
    // Stop movie playback immediately:
    MoviesTask(movieRecordBANK[moviehandle].theMovie, 0);
    StopMovie(movieRecordBANK[moviehandle].theMovie);
    glFinish();
    QTVisualContextTask(movieRecordBANK[moviehandle].QTMovieContext);
    MoviesTask(movieRecordBANK[moviehandle].theMovie, 0);
    QTVisualContextTask(movieRecordBANK[moviehandle].QTMovieContext);
    glFinish();
        
    // Delete movieobject for this handle:
    DisposeMovie(movieRecordBANK[moviehandle].theMovie);
    movieRecordBANK[moviehandle].theMovie=NULL;    

    // Delete GWorld if any:
    if (movieRecordBANK[moviehandle].QTMovieGWorld) DisposeGWorld(movieRecordBANK[moviehandle].QTMovieGWorld);
    movieRecordBANK[moviehandle].QTMovieGWorld = NULL;

    // Delete visual context for this movie:
    if (movieRecordBANK[moviehandle].QTMovieContext) QTVisualContextRelease(movieRecordBANK[moviehandle].QTMovieContext);
    movieRecordBANK[moviehandle].QTMovieContext = NULL;

    // Delete audio context for this movie:
    QTAudioContextRelease(movieRecordBANK[moviehandle].QTAudioContext);
    movieRecordBANK[moviehandle].QTAudioContext = NULL;
    
    // Decrease counter:
    if (numMovieRecords>0) numMovieRecords--;
        
    return;
}
/*
 *  PsychQTPlaybackRate() - Start- and stop movieplayback, set playback parameters.
 *
 *  moviehandle = Movie to start-/stop.
 *  playbackrate = zero == Stop playback, non-zero == Play movie with spec. rate,
 *                 e.g., 1 = forward, 2 = double speed forward, -1 = backward, ...
 *  loop = 0 = Play once. 1 = Loop, aka rewind at end of movie and restart.
 *  soundvolume = 0 == Mute sound playback, between 0.0 and 1.0 == Set volume to 0 - 100 %.
 *  Returns Number of dropped frames to keep playback in sync.
 */
int PsychQTPlaybackRate(int moviehandle, double playbackrate, int loop, double soundvolume)
{
    int dropped = 0;
    Movie   theMovie;
    
    if (moviehandle < 0 || moviehandle >= PSYCH_MAX_MOVIES) {
        PsychErrorExitMsg(PsychError_user, "Invalid moviehandle provided!");
    }
        
    // Fetch references to objects we need:
    theMovie = movieRecordBANK[moviehandle].theMovie;    
    if (theMovie == NULL) {
        PsychErrorExitMsg(PsychError_user, "Invalid moviehandle provided. No movie associated with this handle !!!");
    }
    
    if (playbackrate != 0) {
        // Start playback of movie:
        SetMovieAudioMute(theMovie, (soundvolume==0) ? TRUE : FALSE, 0);
        SetMovieVolume(theMovie, (short) (soundvolume * 255.0));
        movieRecordBANK[moviehandle].loopflag = loop;
        movieRecordBANK[moviehandle].last_pts = -1.0;
        movieRecordBANK[moviehandle].nr_droppedframes = 0;
        SetMoviePreferredRate(theMovie, FloatToFixed(playbackrate));
        StartMovie(theMovie);
        MoviesTask(theMovie, 10000);
    }
    else {
        // Stop playback of movie:
        StopMovie(theMovie);
        QTVisualContextTask(movieRecordBANK[moviehandle].QTMovieContext);

        // Output count of dropped frames:
        if ((dropped=movieRecordBANK[moviehandle].nr_droppedframes) > 0) {
            if (PsychPrefStateGet_Verbosity()>2) printf("PTB-INFO: Movie playback had to drop %i frames of movie %i to keep playback in sync.\n", movieRecordBANK[moviehandle].nr_droppedframes, moviehandle); 
        }
    }
    
    return(dropped);
}
Пример #25
0
//设置文件
bool CFlashActiveX::LoadMovieFile(LPCTSTR pszFileName)
{
	//效验参数
	ASSERT((m_pIFalshControl!=NULL)&&(m_pIOleObject!=NULL)&&(pszFileName!=NULL));
	if ((m_pIFalshControl==NULL)||(m_pIOleObject==NULL)||(pszFileName==NULL)) return false;

	//停止播放
	if (m_pIFalshControl->IsPlaying())
	{
		StopMovie();
	}

	//加载文件
	if (FAILED(m_pIFalshControl->LoadMovie(0,pszFileName)))
	{
		ASSERT(FALSE);
		return false;
	}

	//获取参数
	m_lTotalFrames=m_pIFalshControl->GetTotalFrames();

	return true;
}
Пример #26
0
		void Tracker::PowerOff()
		{
			StopMovie();
		}
Пример #27
0
LRESULT CALLBACK QTFrame_MovieWndProc (HWND theWnd, UINT theMessage, UINT wParam, LONG lParam)
{
	WPARAM				myWidth, myHeight;
	MovieController		myMC = NULL;
	Movie				myMovie = NULL;
	WindowObject		myWindowObject = NULL;
	MSG					myMsg = {0};
	EventRecord			myMacEvent;
	Boolean				myIsHandled = false;

	// get the window object, movie, and movie controller for this window
	myWindowObject = QTFrame_GetWindowObjectFromWindow(theWnd);
	if (myWindowObject != NULL) {
		myMC = (**myWindowObject).fController;
		myMovie = (**myWindowObject).fMovie;
	}

	// give the movie controller this message first
	if ((!gShuttingDown) && (theMessage != WM_COMMAND)) {
		LONG			myPoints = GetMessagePos();

		myMsg.hwnd = theWnd;
		myMsg.message = theMessage;
		myMsg.wParam = wParam;
		myMsg.lParam = lParam;
		myMsg.time = GetMessageTime();
		myMsg.pt.x = LOWORD(myPoints);
		myMsg.pt.y = HIWORD(myPoints);

		// translate a Windows event to a Mac event
		WinEventToMacEvent(&myMsg, &myMacEvent);

		// let the application-specific code have a chance to intercept the event
		myIsHandled = QTApp_HandleEvent(&myMacEvent);
		
		// pass the Mac event to the movie controller, but only if the movie window isn't minimized
		if (!myIsHandled)
			if (myMC != NULL)
				if (!IsIconic(theWnd))
					myIsHandled = MCIsPlayerEvent(myMC, (EventRecord *)&myMacEvent);
	}

	switch (theMessage) {
		case WM_CREATE: {
				LONG		myStyles;
				
				// create a new window object associated with the new window
				QTFrame_CreateWindowObject(theWnd);
			
				// disable the maximize button
				myStyles = GetWindowLong(theWnd, GWL_STYLE);
				myStyles &= ~WS_MAXIMIZEBOX;
				SetWindowLong(theWnd, GWL_STYLE, myStyles);
			}
			break;

		case WM_WINDOWPOSCHANGING:
			// don't show the window until we have created a movie and
			// can therefore properly size the window to contain the movie
			if (gWeAreCreatingWindow) {
				WINDOWPOS	*lpWindowPos = (WINDOWPOS*)lParam;
				
				lpWindowPos->flags &= ~SWP_SHOWWINDOW;
			}
			break;

		case WM_WINDOWPOSCHANGED:
			// if a movie window has become minimized, stop the movie
			if (IsIconic(theWnd))
				StopMovie(myMovie);
			break;

		case WM_SIZE:
			// resize the movie and controller to fit the window
			myWidth = LOWORD(lParam);
			myHeight = HIWORD(lParam);
			
			// we do NOT want to resize the movie controller if the window is minimized,
			// if there is no movie controller, or if we are in the middle of resizing the window
			if (!gWeAreSizingWindow && (myMC != NULL) && (wParam != SIZE_MINIMIZED)) {
				Rect		myRect;
				
				myRect.top = 0;
				myRect.left = 0;
				myRect.right = myWidth;
				myRect.bottom = myHeight;
				
				MCSetControllerBoundsRect(myMC, &myRect);
			}
			break;

		case WM_MOUSEMOVE:
			// for QuickTime movies (but NOT for QuickTime VR movies), set the cursor to the arrow cursor
			if (myWindowObject != NULL)
				if (!(**myWindowObject).fIsQTVRMovie)
					SetCursor(LoadCursor(NULL, IDC_ARROW));
			break;

		case WM_PUMPMOVIE:
			// we receive this message only to task the movie
			break;

		case WM_LBUTTONDOWN:
			// do any application-specific mouse-button handling, but only if the message hasn't already been handled
			if (!myIsHandled)
				QTApp_HandleContentClick(theWnd, &myMacEvent);
			break;

		case WM_CHAR:
			// do any application-specific key press handling
			QTApp_HandleKeyPress((char)wParam);
			break;

		case WM_PAINT: {
			// do any application-specific drawing in the window
				PAINTSTRUCT		myPaintStruct;

				BeginPaint(theWnd, &myPaintStruct);

				// if the window contains an image, draw it using GraphicsImportDraw
				if (myWindowObject != NULL)
					if ((**myWindowObject).fGraphicsImporter != NULL)
						GraphicsImportDraw((**myWindowObject).fGraphicsImporter);
			
				QTApp_Draw(theWnd);
				
				EndPaint(theWnd, &myPaintStruct);
			}
			break;

		case WM_MDIACTIVATE:
			// activate or deactivate the movie controller in the specified window
			QTFrame_ActivateController(theWnd, (HWND)theWnd == (HWND)lParam);
			break;

		case WM_COMMAND: {

			switch (LOWORD(wParam)) {
							
				case IDM_FILESAVE:
				case IDM_FILESAVEAS:
					QTFrame_HandleFileMenuItem(theWnd, LOWORD(wParam));
					break;

				case IDM_EDITUNDO:
				case IDM_EDITCUT:
				case IDM_EDITCOPY:
				case IDM_EDITPASTE:
				case IDM_EDITCLEAR:
				case IDM_EDITSELECTALL:
				case IDM_EDITSELECTNONE:
					QTFrame_HandleEditMenuItem(theWnd, LOWORD(wParam));
					break;
					
				default:
					// do any application-specific menu handling
					QTApp_HandleMenu((UInt16)LOWORD(wParam));
					break;
			}
			
			break;
		}	// case WM_COMMAND

		case WM_GETMINMAXINFO:
			QTFrame_CalcWindowMinMaxInfo(theWnd, (LPMINMAXINFO)lParam);
			return(0);

		case WM_CLOSE:
			// prepare to close the window, making sure that any changed data is saved or explicitly discarded;
			// we can still cancel the window closing here
			if (myWindowObject != NULL) {
			
				// if the window's data is "dirty", give the user a chance to save it
				if ((**myWindowObject).fIsDirty) {
					int			myItem;
					char		myText[256];
					UINT		myAction;
		
					// get the title of the window
					GetWindowText(theWnd, myText, sizeof(myText));
		
					// specify the action
					myAction = gShuttingDown ? IDS_SAVEONQUIT : IDS_SAVEONCLOSE;
		
					// display the "Save changes" dialog box
					myItem = QTFrame_ShowCautionAlert(theWnd, myAction, MB_ICONEXCLAMATION, MB_YESNOCANCEL, gAppName, myText);
					switch (myItem) {
						case kSaveChanges:
							// save the data in the window
							QTFrame_UpdateMovieFile(theWnd);
							break;
							
						case kCancelClose:
							// do not close the window and do not quit the application
							gShuttingDown = false;
							return(0);
						
						case kDontSaveChanges:
							// discard any unsaved changes (that is, don't do anything)
							break;
							
						default:
							// unexpected item selected; just return
							return(0);
					}
				}
			} // if (myWindowObject != NULL)
			
			// if we got to this point, it's okay to close and destroy the window
			SendMessage(ghWndMDIClient, WM_MDIDESTROY, (WPARAM)theWnd, 0L);
			break;

		case WM_DESTROY:
			// when we get this message,
			// the window has been removed from the screen and its associated data must be destroyed
			if (myWindowObject != NULL)
				QTFrame_CloseWindowObject(myWindowObject);
		
			SetWindowLong(theWnd, GWL_USERDATA, 0);

			// destroy the port association
			DestroyPortAssociation((CGrafPtr)GetHWNDPort(theWnd));
			
			break;
	}

	return(DefMDIChildProc(theWnd, theMessage, wParam, lParam));
}
Пример #28
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	HWND hDlg;
	switch(Message)
	{
	case WM_KEYDOWN:
		if(wParam != VK_PAUSE)
			break;
		// case WM_SYSKEYDOWN:
	case WM_CUSTKEYDOWN:
		{
			int modifiers = GetModifiers(wParam);
			if(!HandleKeyMessage(wParam,lParam, modifiers))
				return 0;
			break;
		}
	case WM_KEYUP:
		if(wParam != VK_PAUSE)
			break;
	case WM_SYSKEYUP:
	case WM_CUSTKEYUP:
		{
			int modifiers = GetModifiers(wParam);
			HandleKeyUp(wParam, lParam, modifiers);
		}
		break;
	case WM_SIZE:
		switch(wParam)
		{
		case SIZE_MINIMIZED:
			break;
		case SIZE_MAXIMIZED:
			pcejin.maximized = true;
			break;
		case SIZE_RESTORED:
			pcejin.maximized = false;
			break;
		default:
			break;
		}
		return 0;
	case WM_MOVE:
		RECT rect;
		GetWindowRect(hWnd,&rect);
		WndX = rect.left;
		WndY = rect.top;
		return 0;
	case WM_DROPFILES:
		{
			char filename[MAX_PATH] = "";
			DragQueryFile((HDROP)wParam,0,filename,MAX_PATH);
			DragFinish((HDROP)wParam);
			
			std::string fileDropped = filename;
			//-------------------------------------------------------
			//Check if mcm file, if so auto-convert and play
			//-------------------------------------------------------
			if (!(fileDropped.find(".mcm") == std::string::npos) && (fileDropped.find(".mcm") == fileDropped.length()-4))
			{
				if (!pcejin.romLoaded)	//If no ROM is loaded, prompt for one
				{
					soundDriver->pause();
					LoadGame();
					pcejin.tempUnPause();
				}
				if (pcejin.romLoaded && !(fileDropped.find(".mcm") == std::string::npos))	
					LoadMCM(fileDropped.c_str(), true);
			}
			//-------------------------------------------------------
			//Check if Movie file
			//-------------------------------------------------------
			else if (!(fileDropped.find(".mc2") == std::string::npos) && (fileDropped.find(".mc2") == fileDropped.length()-4))
			{
				if (!pcejin.romLoaded)	//If no ROM is loaded, prompt for one
				{
					soundDriver->pause();
					LoadGame();
					pcejin.tempUnPause();
				}
				if (pcejin.romLoaded && !(fileDropped.find(".mc2") == std::string::npos))
				{
					LoadMovie(fileDropped.c_str(), 1, false, false);
					RecentMovies.UpdateRecentItems(fileDropped);
				}
			}
			
			//-------------------------------------------------------
			//Check if Savestate file
			//-------------------------------------------------------
			else if (!(fileDropped.find(".nc") == std::string::npos))
			{
				if (fileDropped.find(".nc") == fileDropped.length()-4)
				{
					if ((fileDropped[fileDropped.length()-1] >= '0' && fileDropped[fileDropped.length()-1] <= '9'))
					{
						MDFNSS_Load(filename, NULL);
						UpdateToolWindows();
					}
				}
			}
			
			//-------------------------------------------------------
			//Check if Lua script file
			//-------------------------------------------------------
			else if (!(fileDropped.find(".lua") == std::string::npos) && (fileDropped.find(".lua") == fileDropped.length()-4))	 //ROM is already loaded and .dsm in filename
			{
				if(LuaScriptHWnds.size() < 16)
				{
					char temp [1024];
					strcpy(temp, fileDropped.c_str());
					HWND IsScriptFileOpen(const char* Path);
					RecentLua.UpdateRecentItems(fileDropped);
					if(!IsScriptFileOpen(temp))
					{
						HWND hDlg = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_LUA), hWnd, (DLGPROC) LuaScriptProc);
						SendDlgItemMessage(hDlg,IDC_EDIT_LUAPATH,WM_SETTEXT,0,(LPARAM)temp);
					}
				}
			}
			
			//-------------------------------------------------------
			//Check if watchlist file
			//-------------------------------------------------------
			else if (!(fileDropped.find(".wch") == std::string::npos) && (fileDropped.find(".wch") == fileDropped.length()-4))	 //ROM is already loaded and .dsm in filename
			{
				if(!RamWatchHWnd)
				{
					RamWatchHWnd = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_RAMWATCH), hWnd, (DLGPROC) RamWatchProc);
				}
				else
					SetForegroundWindow(RamWatchHWnd);
				Load_Watches(true, fileDropped.c_str());
			}
			
			//-------------------------------------------------------
			//Else load it as a ROM
			//-------------------------------------------------------
			
			else
			{
				ALoad(fileDropped.c_str());
			}
		}
		return 0;
	case WM_ENTERMENULOOP:
		soundDriver->pause();
		EnableMenuItem(GetMenu(hWnd), IDM_RECORD_MOVIE, MF_BYCOMMAND | (movieMode == MOVIEMODE_INACTIVE && pcejin.romLoaded) ? MF_ENABLED : MF_GRAYED);
		EnableMenuItem(GetMenu(hWnd), IDM_PLAY_MOVIE, MF_BYCOMMAND | (movieMode == MOVIEMODE_INACTIVE && pcejin.romLoaded) ? MF_ENABLED : MF_GRAYED);
		EnableMenuItem(GetMenu(hWnd), IDM_STOPMOVIE, MF_BYCOMMAND | (movieMode != MOVIEMODE_INACTIVE) ? MF_ENABLED : MF_GRAYED);
		EnableMenuItem(GetMenu(hWnd), IDM_RESTARTMOVIE, MF_BYCOMMAND | (movieMode != MOVIEMODE_INACTIVE) ? MF_ENABLED : MF_GRAYED);
		EnableMenuItem(GetMenu(hWnd), IDM_FILE_STOPAVI, MF_BYCOMMAND | (DRV_AviIsRecording()) ? MF_ENABLED : MF_GRAYED);
		EnableMenuItem(GetMenu(hWnd), IDM_FILE_RECORDAVI, MF_BYCOMMAND | (!DRV_AviIsRecording()) ? MF_ENABLED : MF_GRAYED);
		
		//Window Size
		checkMenu(IDC_WINDOW1X, ((pcejin.windowSize==1)));
		checkMenu(IDC_WINDOW2X, ((pcejin.windowSize==2)));
		checkMenu(IDC_WINDOW3X, ((pcejin.windowSize==3)));
		checkMenu(IDC_WINDOW4X, ((pcejin.windowSize==4)));
		checkMenu(IDC_ASPECT, ((pcejin.aspectRatio)));
		checkMenu(ID_VIEW_FRAMECOUNTER,Hud.FrameCounterDisplay);
		checkMenu(ID_VIEW_DISPLAYINPUT,Hud.ShowInputDisplay);
		checkMenu(ID_VIEW_DISPLAYSTATESLOTS,Hud.DisplayStateSlots);
		checkMenu(ID_VIEW_DISPLAYLAG,Hud.ShowLagFrameCounter);
		checkMenu(IDM_MUTE,soundDriver->userMute);
		break;
	case WM_EXITMENULOOP:
		pcejin.tempUnPause();
		break;

	case WM_CLOSE:
		{
			SaveIniSettings();
			PostQuitMessage(0);
		}

	case WM_DESTROY:
		{
			PostQuitMessage(0);
		}
		// HANDLE_MSG(hWnd, WM_DESTROY, OnDestroy);
		// HANDLE_MSG(hWnd, WM_PAINT, OnPaint);
		// HANDLE_MSG(hwnd, WM_COMMAND, OnCommand);
	case WM_COMMAND:
			//Recent ROMs
			if(wParam >= RECENTROM_START && wParam <= RECENTROM_START + RecentROMs.MAX_RECENT_ITEMS - 1)
			{
				ALoad(RecentROMs.GetRecentItem(wParam - RECENTROM_START).c_str());
				break;
			}
			else if (wParam == RecentROMs.GetClearID())
			{
				RecentROMs.ClearRecentItems();
				break;
			}
			else if (wParam == RecentROMs.GetAutoloadID())
			{
				RecentROMs.FlipAutoLoad();
				break;
			}
			//Recent Movies
			if(wParam >= RECENTMOVIE_START && wParam <= RECENTMOVIE_START + RecentMovies.MAX_RECENT_ITEMS - 1)
			{
				strcpy(Tmp_Str, RecentMovies.GetRecentItem(wParam - RECENTMOVIE_START).c_str());
				RecentMovies.UpdateRecentItems(Tmp_Str);
				//WIN32_StartMovieReplay(Str_Tmp);
				break;
			}
			else if (wParam == RecentMovies.GetClearID())
			{
				RecentMovies.ClearRecentItems();
				break;
			}
			else if (wParam == RecentMovies.GetAutoloadID())
			{
				RecentMovies.FlipAutoLoad();
				break;
			}
			//Recent Lua
			if(wParam >= RECENTLUA_START && wParam <= RECENTLUA_START + RecentLua.MAX_RECENT_ITEMS - 1)
			{
				if(LuaScriptHWnds.size() < 16)
				{
					char temp [1024];
					strcpy(temp, RecentLua.GetRecentItem(wParam - RECENTLUA_START).c_str());
					HWND IsScriptFileOpen(const char* Path);
					RecentLua.UpdateRecentItems(temp);
					if(!IsScriptFileOpen(temp))
					{
						HWND hDlg = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_LUA), hWnd, (DLGPROC) LuaScriptProc);
						SendDlgItemMessage(hDlg,IDC_EDIT_LUAPATH,WM_SETTEXT,0,(LPARAM)temp);
					}
				}

				break;
			}
			else if (wParam == RecentLua.GetClearID())
			{
				RecentLua.ClearRecentItems();
				break;
			}
			else if (wParam == RecentLua.GetAutoloadID())
			{
				RecentLua.FlipAutoLoad();
				break;
			}
		wmId = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDC_WINDOW1X:
			pcejin.windowSize=1;
			ScaleScreen(pcejin.windowSize);
			break;
		case IDC_WINDOW2X:
			pcejin.windowSize=2;
			ScaleScreen(pcejin.windowSize);
			break;
		case IDC_WINDOW3X:
			pcejin.windowSize=3;
			ScaleScreen(pcejin.windowSize);
			break;
		case IDC_WINDOW4X:
			pcejin.windowSize=4;
			ScaleScreen(pcejin.windowSize);
			break;
		case IDC_ASPECT:
			pcejin.aspectRatio ^= 1;
			ScaleScreen(pcejin.windowSize);
			break;
		case IDM_EXIT:
			SaveIniSettings();
			PostQuitMessage(0);
			break;
		case IDM_RESET:
			PCE_Power();
			break;
		case IDM_OPEN_ROM:
			soundDriver->pause();
			LoadGame();
			pcejin.tempUnPause();
			break;
		case IDM_RECORD_MOVIE:
			soundDriver->pause();
			MovieRecordTo();
			pcejin.tempUnPause();
			return 0;
		case IDM_PLAY_MOVIE:
			soundDriver->pause();
			Replay_LoadMovie();
			pcejin.tempUnPause();
			return 0;
		case IDM_INPUT_CONFIG:
			soundDriver->pause();
			DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_INPUTCONFIG), hWnd, DlgInputConfig);
			pcejin.tempUnPause();
			// RunInputConfig();
			break;
		case IDM_HOTKEY_CONFIG:
			{
				soundDriver->pause();

				DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_KEYCUSTOM), hWnd, DlgHotkeyConfig);
				pcejin.tempUnPause();

			}
			break;

		case IDM_BIOS_CONFIG:
			soundDriver->pause();

			DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_BIOS), hWnd, (DLGPROC) BiosSettingsDlgProc);
			// DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_KEYCUSTOM), hWnd, BiosSettingsDlgProc);
			pcejin.tempUnPause();
			break;
		case ID_VIEW_FRAMECOUNTER:
			Hud.FrameCounterDisplay ^= true;
			WritePrivateProfileBool("Display", "FrameCounter", Hud.FrameCounterDisplay, IniName);
			return 0;

		case ID_VIEW_DISPLAYINPUT:
			Hud.ShowInputDisplay ^= true;
			WritePrivateProfileBool("Display", "Display Input", Hud.ShowInputDisplay, IniName);
			osd->clear();
			return 0;

		case ID_VIEW_DISPLAYSTATESLOTS:
			Hud.DisplayStateSlots ^= true;
			WritePrivateProfileBool("Display", "Display State Slots", Hud.DisplayStateSlots, IniName);
			osd->clear();
			return 0;

		case ID_VIEW_DISPLAYLAG:
			Hud.ShowLagFrameCounter ^= true;
			WritePrivateProfileBool("Display", "Display Lag Counter", Hud.ShowLagFrameCounter, IniName);
			osd->clear();
			return 0;
		case IDC_NEW_LUA_SCRIPT:
			if(LuaScriptHWnds.size() < 16)
			{
				CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_LUA), g_hWnd, (DLGPROC) LuaScriptProc);
			}
			break;
		case IDM_CONVERT_MCM:
			ConvertMCM(hWnd);

			break;
		case IDM_MUTE:
			soundDriver->doUserMute();
			break;
		case IDM_STOPMOVIE:
			StopMovie();
			return 0;
			break;
		case IDM_RESTARTMOVIE:
			PCE_Power();
			ResetFrameCount();
			movieMode = MOVIEMODE_PLAY;
			movie_readonly = true;
			return 0;
			break; 
		case ID_RAM_SEARCH:
			if(!RamSearchHWnd)
			{
				InitRamSearch();
				RamSearchHWnd = CreateDialog(winClass.hInstance, MAKEINTRESOURCE(IDD_RAMSEARCH), hWnd, (DLGPROC) RamSearchProc);
			}
			else
				SetForegroundWindow(RamSearchHWnd);
			break;

		case ID_RAM_WATCH:
			if(!RamWatchHWnd)
			{
				RamWatchHWnd = CreateDialog(winClass.hInstance, MAKEINTRESOURCE(IDD_RAMWATCH), hWnd, (DLGPROC) RamWatchProc);
			}
			else
				SetForegroundWindow(RamWatchHWnd);
			return 0;
		case IDM_MEMORY:
			if (!RegWndClass("MemView_ViewBox", MemView_ViewBoxProc, 0, sizeof(CMemView*)))
				return 0;

			OpenToolWindow(new CMemView());
			return 0;
		case IDM_ABOUT:
			soundDriver->pause();

			DialogBox(winClass.hInstance, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			pcejin.tempUnPause();
			break;
		case IDM_FILE_RECORDAVI:
			soundDriver->pause();
			RecordAvi();
			pcejin.tempUnPause();
			break;
		case IDM_FILE_STOPAVI:
			StopAvi();
			break;
		}
		break;
	}
	return DefWindowProc(hWnd, Message, wParam, lParam);
}
// ----------------------------------------------------------------------------
void ofQuicktimeSoundPlayer::stop(){
	StopMovie(soundToPlay);
}
Пример #30
0
void platformStopSound (long theSound)
{
#ifdef QuickTimeInstalled
	StopMovie((Movie)theSound);
#endif // QuickTimeInstalled
}