mirror of
https://github.com/softdorothy/GliderPRO.git
synced 2024-11-29 07:49:46 +00:00
1 line
15 KiB
C
1 line
15 KiB
C
|
//============================================================================
//----------------------------------------------------------------------------
// HouseIO.c
//----------------------------------------------------------------------------
//============================================================================
#include <Aliases.h>
#include <Movies.h>
#include <Resources.h>
#include <StringCompare.h>
#include <TextUtils.h>
#include "Externs.h"
#include "Environ.h"
#include "House.h"
#include "ObjectEdit.h"
#define kSaveChangesAlert 1002
#define kSaveChanges 1
#define kDiscardChanges 2
void LoopMovie (void);
void OpenHouseMovie (void);
void CloseHouseMovie (void);
Boolean IsFileReadOnly (FSSpec *);
Movie theMovie;
Rect movieRect;
short houseRefNum, houseResFork, wasHouseVersion;
Boolean houseOpen, fileDirty, gameDirty;
Boolean changeLockStateOfHouse, saveHouseLocked, houseIsReadOnly;
Boolean hasMovie, tvInRoom;
extern FSSpecPtr theHousesSpecs;
extern short thisHouseIndex, tvWithMovieNumber;
extern short numberRooms, housesFound;
extern Boolean noRoomAtAll, quitting, wardBitSet;
extern Boolean phoneBitSet, bannerStarCountOn;
//============================================================== Functions
//-------------------------------------------------------------- LoopMovie
void LoopMovie (void)
{
Handle theLoop;
UserData theUserData;
short theCount;
theLoop = NewHandle(sizeof(long));
(** (long **) theLoop) = 0;
theUserData = GetMovieUserData(theMovie);
theCount = CountUserDataType(theUserData, 'LOOP');
while (theCount--)
{
RemoveUserData(theUserData, 'LOOP', 1);
}
AddUserData(theUserData, theLoop, 'LOOP');
}
//-------------------------------------------------------------- OpenHouseMovie
void OpenHouseMovie (void)
{
#ifdef COMPILEQT
TimeBase theTime;
FSSpec theSpec;
FInfo finderInfo;
Handle spaceSaver;
OSErr theErr;
short movieRefNum;
Boolean dataRefWasChanged;
if (thisMac.hasQT)
{
theSpec = theHousesSpecs[thisHouseIndex];
PasStringConcat(theSpec.name, "\p.mov");
theErr = FSpGetFInfo(&theSpec, &finderInfo);
if (theErr != noErr)
return;
theErr = OpenMovieFile(&theSpec, &movieRefNum, fsCurPerm);
if (theErr != noErr)
{
YellowAlert(kYellowQTMovieNotLoaded, theErr);
return;
}
theErr = NewMovieFromFile(&theMovie, movieRefNum, nil, theSpec.name,
newMovieActive, &dataRefWasChanged);
if (theErr != noErr)
{
YellowAlert(kYellowQTMovieNotLoaded, theErr);
theErr = CloseMovieFile(movieRefNum);
return;
}
theErr = CloseMovieFile(movieRefNum);
spaceSaver = NewHandle(307200L);
if (spaceSaver == nil)
{
YellowAlert(kYellowQTMovieNotLoaded, 749);
CloseHouseMovie();
return;
}
GoToBeginningOfMovie(theMovie);
theErr = LoadMovieIntoRam(theMovie,
GetMovieTime(theMovie, 0L), GetMovieDuration(theMovie), 0);
if (theErr != noErr)
{
YellowAlert(kYellowQTMovieNotLoaded, theErr);
DisposeHandle(spaceSaver);
CloseHouseMovie();
return;
}
DisposeHandle(spaceSaver);
theErr = PrerollMovie(theMovie, 0, 0x000F0000);
if (theErr != noErr)
{
YellowAlert(kYellowQTMovieNotLoaded, theErr);
CloseHouseMovie();
return;
}
theTime = GetMovieTimeBase(theMovie);
SetTimeBaseFlags(theTime, loopTimeBase);
SetMovieMasterTimeBase(theMovie, theTime, nil);
LoopMovie();
GetMovieBox(theMovie, &movieRect);
hasMovie = true;
}
#endif
}
//-------------------------------------------------------------- CloseHouseMovie
void CloseHouseMovie (void)
{
#ifdef COMPILEQT
OSErr theErr;
if ((thisMac.hasQT) && (hasMovie))
{
theErr = LoadMovieIntoRam(theMovie,
GetMovieTime(theMovie, 0L), GetMovieDuration(theMovie), flushFromRam);
DisposeMovie(theMovie);
}
#endif
hasMovie = false;
}
//-------------------------------------------------------------- OpenHouse
// Opens a house (whatever current selection is). Returns true if all went well.
Boolean OpenHouse (void)
{
OSErr theErr;
Boolean targetIsFolder, wasAliased;
if (houseOpen)
{
i
|