-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNedry.c
281 lines (209 loc) · 6.4 KB
/
Nedry.c
1
#include <Movies.h> void InitializeToolbox( void );void SetUpMenuBar( void ); void DrawAbout(void);void HandleMouseDown( EventRecord );void HandleMenuChoice( long );void HandleAppleChoice( short );void HandleFileChoice( short );Movie GetMovieFromFile( void );void AdjustMovieWindow( Movie, WindowPtr );void CloseOneMovie( Movie, WindowPtr, MovieController );#define rMenuBar 128#define mApple 128#define iAbout 1#define mFile 129#define iPlayAlert 3#define iQuit 1Boolean gDone = false;MovieController gController = nil;Rect aboutRect;Movie theMovie = nil;WindowPtr theWindow;//____________________________________________________________void main( void ){ EventRecord theEvent; ComponentResult movieRelatedEvent; InitializeToolbox(); SetUpMenuBar(); theMovie = GetMovieFromFile(); if ( theMovie == nil ) ExitToShell(); theWindow = GetNewCWindow( 129, nil, (WindowPtr)-1L ); AdjustMovieWindow( theMovie, theWindow ); MCDoAction( gController, mcActionSetLooping, (Ptr)true ); while ( gDone == false ) { WaitNextEvent( everyEvent, &theEvent, 15L, nil ); if(!MCIsPlayerEvent( gController, &theEvent )) { switch ( theEvent.what ) { case mouseDown: HandleMouseDown( theEvent ); break; } } } CloseOneMovie( theMovie, theWindow, gController );}//____________________________________________________________void SetUpMenuBar( void ) { Handle theMenuBar; MenuHandle theAppleMenu; theMenuBar = GetNewMBar( rMenuBar ); SetMenuBar( theMenuBar ); DisposeHandle( theMenuBar ); theAppleMenu = GetMenuHandle( mApple ); AppendResMenu( theAppleMenu, 'DRVR' ); DrawMenuBar(); }//____________________________________________________________void HandleMouseDown( EventRecord theEvent ){ WindowPtr theWindow; short thePart; long theChoice; thePart = FindWindow( theEvent.where, &theWindow ); switch ( thePart ) { case inMenuBar: theChoice = MenuSelect( theEvent.where ); if ( theChoice != 0 ) HandleMenuChoice( theChoice ); break; }}//____________________________________________________________void DrawAbout(void){ short AboutWindow = 128; short AboutPicture = 128; WindowPtr aboutWindow; PicHandle thePicture; aboutWindow = GetNewWindow(AboutWindow, nil, (WindowPtr)-1L); thePicture = GetPicture(AboutPicture); aboutRect = (**thePicture).picFrame; OffsetRect(&aboutRect, -aboutRect.left, -aboutRect.top); SizeWindow(aboutWindow, aboutRect.right, aboutRect.bottom, true); ShowWindow(aboutWindow); SetPort(aboutWindow); DrawPicture(thePicture,&aboutRect);}//____________________________________________________________void HandleMenuChoice( long theChoice ) { short theMenu; short theMenuItem; theMenu = HiWord( theChoice ); theMenuItem = LoWord( theChoice ); switch ( theMenu ) { case mApple: HandleAppleChoice( theMenuItem ); break; case mFile: HandleFileChoice( theMenuItem ); break; } HiliteMenu(0); }//____________________________________________________________void HandleAppleChoice( short theMenuItem ){ Str255 theItemName; short theItemNumber; MenuHandle theAppleMenu; switch ( theMenuItem ) { case iAbout: DrawAbout(); break; default: theAppleMenu = GetMenuHandle( mApple ); GetMenuItemText( theAppleMenu, theMenuItem, theItemName ); theItemNumber = OpenDeskAcc( theItemName ); break; }}//____________________________________________________________void HandleFileChoice( short theItem ){ switch ( theItem ) { case iQuit: gDone = true; ExitToShell(); break; }}//____________________________________________________________Movie GetMovieFromFile( void ){ OSErr theError; FSSpec MooVFSSpec; SFTypeList typeList = { MovieFileType, 0, 0, 0 }; Movie getMovie = nil; short moovRefNum; short moovResID = 0; Str255 movieName; Boolean wasChanged; theError = FSMakeFSSpec(0,0,"\pThe King", &MooVFSSpec); if ( theError == noErr ) { theError = OpenMovieFile( &MooVFSSpec, &moovRefNum, fsRdPerm ); if ( theError == noErr ) { theError = NewMovieFromFile( &getMovie, moovRefNum, &moovResID, movieName, newMovieActive, &wasChanged ); CloseMovieFile( moovRefNum ); } } return ( getMovie );}//____________________________________________________________void AdjustMovieWindow( Movie theMovie, WindowPtr theWindow ){ Rect movieBox; Rect windowRect; SetMovieGWorld( theMovie, (CGrafPtr)theWindow, nil ); GetMovieBox( theMovie, &movieBox ); gController = NewMovieController( theMovie, &movieBox, mcNotVisible ); MCGetControllerBoundsRect( gController, &windowRect ); SizeWindow( theWindow, windowRect.right, windowRect.bottom, true ); ShowWindow( theWindow ); SetWTitle(theWindow, "\pThe King"); GoToBeginningOfMovie(theMovie); StartMovie(theMovie);}//____________________________________________________________void CloseOneMovie( Movie theMovie, WindowPtr theWindow, MovieController theController ){ DisposeMovieController( theController ); DisposeMovie( theMovie ); DisposeWindow( theWindow );}//____________________________________________________________void InitializeToolbox( void ){ OSErr theError; long theResult; InitGraf( &qd.thePort ); InitFonts(); InitWindows(); InitMenus(); TEInit(); InitDialogs( 0L ); FlushEvents( everyEvent, 0 ); InitCursor(); theError = Gestalt( gestaltQuickTime, &theResult ); if ( theError != noErr ) ExitToShell(); theError = EnterMovies(); if ( theError != noErr ) ExitToShell(); }