home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-02-14 | 27.9 KB | 862 lines | [TEXT/PJMM] |
- {****************************************************}
- {}
- { ShIntf.p }
- {}
- { Interface file for the Showwit! application. }
- {}
- { Showwit! is based on "Flippit" for the Amiga, as seen at Scitech Discovery }
- { Centre. Showwit! uses the Sprite Animation Toolkit by Ingemar Ragnemalm. }
- {}
- { Showwit! }
- { Copyright © 1996 by Patrick C Hew. All rights reserved. }
- {}
- { CBartenderHelpMenu }
- { Copyright © 1995 Patrick C Hew. All rights reserved. }
- {}
- { CHandlePrefs }
- { Copyright © 1993 by Peter Broadribb. All rights reserved. }
- {}
- { CPixMap and CPixMapPane }
- { Copyright © 1996 by Patrick C Hew. All rights reserved. }
- {}
- { CProgressBar }
- { Copyright © 1994 by Johns Hopkins University. All rights reserved. }
- {}
- { Sprite Animation Toolkit }
- { Copyright © 1992-1994 by Ingemar Ragnemalm. All rights reserved. }
- {}
- { THINK Class Library 1.1.2 }
- { Copyright © 1989 by Symantec Corporation. All rights reserved. }
- {}
- { Revision History: }
- {}
- { Version: 1.0a1 for TCL 1.1.2 and SAT 2.3b4 }
- { Date: 29 December 1995 }
- { Author: Patrick C Hew <phew@ucc.gu.uwa.edu.au> }
- { Notes: First alpha . }
- {}
- { Version: 1.0b1 for TCL 1.1.2 and SAT 2.3b4 }
- { Date: 27 January 1996 }
- { Author: Patrick C Hew <phew@ucc.gu.uwa.edu.au> }
- { Notes: First beta . }
- {}
- { Version: 1.0b2 for TCL 1.1.2 and SAT 2.3b4 }
- { Date: 4 February 1996 }
- { Author: Patrick C Hew <phew@ucc.gu.uwa.edu.au> }
- { Notes: Second beta . }
- {}
- { Version: 1.0b3 for TCL 1.1.2 and SAT 2.3b4 }
- { Date: 11 February 1996 }
- { Author: Patrick C Hew <phew@ucc.gu.uwa.edu.au> }
- { Notes: Third beta / Preview release . }
- {}
- { Version: 1.0 for TCL 1.1.2 and SAT 2.3b4 }
- { Date: 16 February 1996 }
- { Author: Patrick C Hew <phew@ucc.gu.uwa.edu.au> }
- { Notes: First release . }
- {}
- {****************************************************}
-
-
- unit ShIntf;
-
- interface
-
- uses
- TCL, MoreTCL, TCL_Controls, TCL_Dialogs, TCL_Tables, CBartenderHelpMenu, CHandlePrefs, CPixMapPane, CProgressBar, SAT;
-
- const
-
- { Command and resource IDs. Although we only need to put them }
- { in the required files, we do it this way to avoid clashes. }
- { Values for the application start with 2 (including about box). }
- { Values for the game director start with 3. }
- { Values for the documents start with 4. }
- { Values for the best player dialog start with 5. }
- { Values for the about/help dialog start with 6. }
-
- { Command IDs. }
-
- cmdReadDefLevels = 2000;
- cmdClearBestPlayers = 2001; { Also used by levels table, activated by game director. }
- cmdHelp = 2002;
-
- cmdStartGame = 3000;
- cmdClickStart = 3001;
- cmdAbortGame = 3002;
- cmdPauseGame = 3003;
- cmdResumeGame = 3004;
- cmdAnimationOn = 3005;
- cmdSoundOn = 3006;
- cmdChangeTargetPicture = 3007;
- cmdResetTiles = 3008;
-
- cmdAboutScreen = 6000;
- cmdHelpScreen = 6001;
- cmdCreditsScreen = 6002;
-
- { Resource IDs. }
-
- cicnHelp = 3000;
- cicnPause = 3001;
- cicnResume = 3002;
- cicnAbort = 3003;
- cicnTile = 3004;
-
- ALRTGamePlayingSoCannotOpen = 2000;
-
- DLOGNewBest = 5000;
- DLOGAboutAndHelp = 6000;
-
- LEVLDefStart = 128; { Easier to create levels with ResEdit if starting at 128. }
- BESTDefStart = LEVLDefStart;
-
- PICTReaderColour = 2000;
- PICTReaderBW = 2001;
- PICTTitleColour = 3000;
- PICTTitleBW = 3001;
- PICTGameColour = 3002;
- PICTGameBW = 3003;
- PICTNewBestPlayerColour = 5000;
- PICTNewBestPlayerBW = 5001;
- PICTAboutColour = 6000;
- PICTAboutBW = 6001;
- PICTHelpColour = 6002;
- PICTHelpBW = 6003;
- PICTCreditsColour = 6004;
- PICTCreditsBW = 6005;
- PICTTargetColourBase = 10000; { PICTs with IDs from 10000 may be used as targets. }
- PICTTargetBWBase = 25000; { If no colour quickdraw, assume B&W above this value. }
-
- STRlistAppMessages = 2000;
- STRlistPrefMessages = 2001;
- STRlistAppHelpMenu = 2002;
- STRlistGameMessages = 3000;
-
- sndWelcome = 2000;
- sndGameStarting = 3000;
- sndGameComplete = 3001;
- sndGameAborted = 3002;
- sndNewBestPlayer = 5000;
- sndFlipBase = 10000; { snds with IDs from 10000 may be used in flipping. }
-
- WINDReader = 2000; { One resource for both the application and document readers. Windows are identical. }
- WINDGame = 3000;
-
- { The same sized window is used by the application and document level readers. }
-
- kReaderWindh = 300;
- kReaderWindv = 100;
-
- kReaderTextLenh = kReaderWindh - 20;
- kReaderTextLenv = 20;
- kReaderTextPosh = 10;
- kReaderTextPosv = 10;
-
- kReaderProgBarLenh = 260;
- kReaderProgBarLenv = 20;
- kReaderProgBarPosh = 20;
- kReaderProgBarPosv = 40;
-
- kSTRAppReading = 1;
-
- { Size of the target pictures, and the tiles used to hide it. }
-
- kTileSize = 64;
- kTargetSize = kTileSize * 4;
-
- { Structuring constants. }
-
- kMaxGridAcross = 4; { Showwit! tile grid is 4x4. Change this only }
- kMaxGridDown = 4; { if you want to change all graphics and data! }
- kMaxTiles = kMaxGridAcross * kMaxGridDown;
-
- kNullTile = 0;
-
- kNoLevel = 0;
-
- { Resource Types. }
-
- kBESTResType = 'BEST';
- kLEVLResType = 'LEVL';
-
- { File Signatures. }
-
- kSignatureApplication = 'ShwI';
- kSignatureLevelsFiles = 'ShwL';
- kSignaturePreferencesFile = 'PREF';
-
- { Preferences. }
-
- kNumberOfPrefs = 4;
- kPrefAnimationOn = 1;
- kPrefSoundOn = 2;
- kPrefBestPlayers = 3;
- kPrefNumBest = 4;
-
-
- type
-
- { Think of the 4x4 grid as being 1 to 16, from numbered in the usual L-R, T-B manner. }
- { This requires parsing the level resource for the starting and target configurations, }
- { but overall, this is easier in terms of accessing arrays. }
-
- RowRange = 1..kMaxGridDown;
- ColRange = 1..kMaxGridAcross;
- TileRange = 1..kMaxTiles;
-
- LevelsRange = kNoLevel..maxInt; { Positive integers… don't really want an upper bound. }
-
- { A level has a name and rules for how flipping a given tile affects the others. }
- { We also store the details of the best performance for that level. }
-
- { In the original game (as seen at Scitech Discovery Centre, written by Arilia }
- { Software), tiles were flipped from a starting to target configuration. In this }
- { game, I've adopted an idea from Ingemar Ragnemalm to reveal a picture. Thus }
- { without loss of generality, we can assume that we are going from some }
- { starting configuration to all FALSE. }
-
- ConfigType = packed array[TileRange] of Boolean;
-
- DependantsType = array[TileRange] of TileRange;
- TileRuleType = record
- theNumDep: TileRange; { Including itself. }
- theDep: DependantsType; { Array being valid from 1..theNumDep. }
- end;
- RulesType = array[TileRange] of TileRuleType;
-
-
- {****************************************************}
- {}
- { CShApp }
- {}
- { Application class for the Showwit! application. }
- {}
- {****************************************************}
-
- type
- HandleArray = array[1..1] of Handle;
- HandleArrayP = ^HandleArray;
- HandleArrayH = ^HandleArrayP;
-
- { Application is responsible for preparing sounds, which are used wherever necessary. }
-
- var
- gSoundWelcome: Handle;
- gSoundGameStarting, gSoundGameComplete, gSoundGameAborted: Handle;
- gSoundNewBestPlayer: Handle;
- gFlipSoundHandles: HandleArrayH;
- gNumFlipSounds: Integer;
-
- type
- CShApp = object(CApplication)
-
- { Pointer to the application levels reader, when active. }
- itsAppLevelsDirector: CShAppLevelsDirector;
-
- { Pointer to the director which looks after the game window. }
- itsGameDirector: CShGameDirector;
-
- { Pointer to any open levels file. Only one level file is open at a time, if any. }
- itsLevelsDoc: CShLevelsDoc;
-
- { Pointer to the preferences file. This is owned by the application, }
- { since there is no real need for a preferences director. The application }
- { levels reader also communicates with this object. }
- itsPrefsFile: CHandlePrefs;
-
- { Construction of the application object, the application levels reader, }
- { the preferences file, the game director and initialization of the sounds. }
- procedure IShApp;
-
- { Build a bartender which can handle the application help menu. }
- procedure MakeBartender;
- override;
-
- { Recognized file types and the application signature. }
- procedure SetUpFileParameters;
- override;
-
- { Insert the items into the application help menu. }
- procedure SetUpMenus;
- override;
-
- { The application is responsible for calling up the about/help dialog, }
- { for calling the default levels reader, and for communicating with }
- { the levels document or preferences file about the best players. }
- procedure DoCommand (theCommand: longint);
- override;
-
- { Handle the core apple events. The way in which we do so is }
- { different to that for a conventional application. }
- procedure DoAppleEvent (anAppleEvent: CAppleEvent);
- override;
-
- { Handle the kAEOpenApplication AppleEvent, by loading the default levels. }
- procedure DoOpenAppEvent (anAppleEvent: CAppleEvent);
-
- { Handle the kAEOpenDocuments AppleEvent, by the loading the first }
- { of any levels files. We only load the first, because only one file }
- { is open at any time. }
- procedure DoOpenOrPrintDocEvent (theEvent: CAppleEvent);
- override;
-
- { The application is responsible for file commands, including the use }
- { of default levels. It also handles the help command. }
- procedure UpdateMenus;
- override;
-
- { Loads the first of any preloaded levels files, then call StartUpAction. }
- { We only load the first, because only one file is open at any time. }
- procedure Preload;
- override;
-
- { If there were no preloaded files, load the default levels. }
- procedure StartUpAction (numPreloads: Integer);
- override;
-
- { We set our pointers to nil before exiting the application. The objects }
- { to which they were pointing will be disposed of in inherited methods. }
- { Also dispose of the sounds and close the preferences file. }
- procedure ExitApp;
- override;
-
- { Opens the given levels document. If a previous document is open, }
- { it needs to be closed first. }
- procedure OpenDocument (macSFReply: SFReply);
- override;
-
- { Returns the director of the main game window. This is to allow }
- { documents to send the list of levels to the game director. }
- function GameDirector: CShGameDirector;
-
- { Returns the preferences file object. This allows access by both }
- { the application and the reader of the default application levels. }
- function PreferencesFile: CHandlePrefs;
-
- { The default levels have been read from the application resource, and }
- { send to the game director. This is called at startup if necessary, or }
- { as a menu command. }
- procedure ReadDefaultLevels;
-
- { Tells the application levels director, or the active document, }
- { to store the best player. }
- procedure StoreBestPlayer (aLevelNum: LevelsRange; aPlayer: Str15; aMoves: Integer; aTime: LongInt);
-
- end; { CShApp }
-
-
- {****************************************************}
- {}
- { CShAppLevelsDirector }
- {}
- { Director class for reading in the default levels. Reads the levels from the }
- { application resource, and the best players from the preferences file. }
- {}
- { Although nominally this is a responsibility of the application, because we }
- { draw a progress dialog, we need a separate director. This also brings us into }
- { line with the CShLevelsDoc, in that a separate object reads the levels and }
- { sends them to the game director. }
- {}
- {****************************************************}
-
- { For obtaining best player information from the preferences file. }
-
- type
- BestPlayerRec = record
- theLevelNum: LevelsRange;
- thePlayer: Str15;
- theMoves: Integer;
- theTime: LongInt;
- end;
- BestPlayerArray = array[1..1] of BestPlayerRec;
- BestArrayPtr = ^BestPlayerArray;
- BestArrayHand = ^BestArrayPtr;
-
- type
- CShAppLevelsDirector = object(CDirector)
-
- { Because the preferences file is a resource file, we need to store a }
- { reference to the original application resource file. }
- itsAppResFile: Integer;
-
- { Pointer to the application object, so that we can get to the }
- { preferences object. }
- itsShApp: CShApp;
-
- { Progress bar, indicating how far through we are. }
- itsProgBar: CProgressBar;
-
- { Construction of the application levels reader object. }
- procedure IShAppLevelsDirector (aSupervisor: CShApp; aAppResFile: Integer);
-
- { Destruction of the application levels reader object. We set our pointers }
- { to nil, for the objects to which they were pointing will be disposed of in }
- { inherited methods. }
- procedure Free;
- override;
-
- { Builds the window of the reader. }
- procedure BuildWindow;
-
- { Returns the list of application levels, with best players as they exist. }
- { Updates the progress bar whilst doing so. }
- function AppLevels: CList;
-
- { Stores the specified best player to the preferences file. }
- procedure StoreBestPlayer (aLevelNum: LevelsRange; aPlayer: Str15; aMoves: Integer; aTime: LongInt);
-
- end; { CShAppLevelsDirector }
-
-
- {****************************************************}
- {}
- { CShBestPlayDirector }
- {}
- { DLOGDirector class for the director which gets the name of a best player. }
- {}
- {****************************************************}
-
- CShBestPlayDirector = object(CDLOGDirector)
-
- { Construct the director and dialog. }
- procedure IShBestPlayDirector (aSupervisor: CShGameDirector);
-
- { Use a modal dialog to get the name of the best player. }
- procedure GetPlayerName (var aName: Str15);
-
- end; { CShBestPlayDirector }
-
-
- {****************************************************}
- {}
- { CShTile }
- {}
- { Pane class for the Showwit! tiles. When clicked, these tiles flip between hiding }
- { and showing a target picture. The target is a PixMap pane, and the pane is a }
- { "window" into the part of the picture concealed by the tile. The hiding side is }
- { a color icon, at the centre of the pane. We override the DrawAll method to }
- { draw only one of these panes. We use a color icon so that the hiding side of the }
- { tile automatically adapts to the correct screen depth. If Color QuickDraw is }
- { not present, then the color icon pane uses the black and white icons anyway. }
- {}
- {****************************************************}
-
- type
- TileState = (Showing, Hiding);
-
- type
- CShTile = object(CPane)
-
- { On one side is the PixMap pane, on the other side, the icon. }
- { In this way, the icon is draw at the correct depth. }
- itsPixMapPane: CPixMapPane;
- itsIcon: CIconPane;
-
- { Whether we are showing or hiding the picture. }
- itsState: TileState;
-
- { Position in the playing grid. }
- itsGridPos: TileRange;
-
- { Pointer to the game director. }
- itsGameDirector: CShGameDirector;
-
- { Construction of the Showwit! Tile object. }
- procedure IShTile (anEnclosure: CView; aSupervisor: CShGameDirector; aHEncl, aVEncl: integer; aHSizing, aVSizing: SizingOption);
-
- { Destruction of the Showwit! Tile object. We set our pointers }
- { to nil, for he objects to which they were pointing will be disposed of in }
- { inherited methods. }
- procedure Free;
- override;
-
- { Returns the current state of the tile, whether showing or hiding. }
- function GetState: TileState;
-
- { Sets the state of the tile to showing or hiding as appropriate. }
- procedure SetState (aState: TileState);
-
- { The position of the tile in the grid has been set. }
- procedure SetGridPos (aGridPos: TileRange);
-
- { Draw the target picture into the offscreen PixMap. }
- procedure SetTargetPICT (aPICTid: Integer);
-
- { Draws either the hiding state or the target picture, as appropriate. }
- { Is essentially a pirate of the normal DrawAll method. }
- procedure DrawAll (var area: Rect);
- override;
-
- { Sends a message to the game director to say that it has been clicked. }
- procedure DoClick (hitPt: Point; modifierKeys: integer; when: longint);
- override;
-
- { Flips the tile, with animation and sound as appropriate. Sound on/off }
- { is controlled by SAT. }
- procedure DoFlip (aAnimate: Boolean);
-
- end; { CShTile }
-
-
- {****************************************************}
- {}
- { CShGameDirector }
- {}
- { Director for the main, game playing window of the Showwit! application. }
- {}
- {****************************************************}
-
- const
- kNotPlaying = FALSE;
- kPlaying = TRUE;
-
- kNotPaused = FALSE;
- kPaused = TRUE;
-
- kNoSound = FALSE;
- kSound = TRUE;
-
- kNoAnimation = FALSE;
- kAnimation = TRUE;
-
- type
- GameScreenType = (TitleScreen, GameScreen);
-
- type
- TileGridType = array[TileRange] of CShTile;
-
- type
- Str2 = string[2]; { For time. }
-
- type
- IDArrayType = array[1..1] of Integer;
- IDArrayP = ^IDArrayType;
- IDArrayH = ^IDArrayP;
-
- type
- CShGameDirector = object(CDirector)
-
- { Pointer to the application. }
- itsShApp: CShApp;
-
- { Level to start when the user says so. }
- itsStartLevel: LevelsRange;
-
- { Current screen being displayed. }
- itsScreen: GameScreenType;
-
- { When switching between screens, the window has different things showing. }
- { We thus need to keep a reference to the background picture. }
-
- itsMainPicture: CPicture;
-
- { Title screen panes, for hiding and showing. }
-
- { We keep a reference of the levels table in order to know which level is }
- { selected, for the start button to be updated and to start the right level. }
- { The levels table owns the list of levels. }
- itsLevelsPane: CScrollPane;
- itsLevelsTable: CShLevelsTable;
-
- { When clicked, the game starts. }
- itsStartButton: CButton;
-
- { Game screen panes, for hiding and showing. }
-
- { The level being played, and the players performance. }
- itsPlayData: CPane;
- itsNameText, itsMovesText, itsHoursText, itsMinutesText, itsSecondsText: CEditText;
- itsHoursStr, itsMinutesStr, itsSecondsStr: Str2;
-
- { Controls for pausing, resuming and aborting play. }
- { Note that the help icon is always visible, so we do not need a reference for it. }
- itsPlayControls: CPane;
- itsPauseIcon, itsResumeIcon: CIconPane;
-
- { The Showwit! tiles. }
- itsTiles: TileGridType;
-
- { Target picture resource IDs. }
-
- { Array of PICT ids for targets. }
- itsTargetPICTIDs: IDArrayH;
- itsNumTargetPICTs: Integer;
-
- { When randomly selecting targets, avoid choosing the same one }
- { twice in a row. }
- itsLastPICTindex: Integer;
-
- { Flags for whether playing or not, and if so, whether paused or not. }
- fPlaying, fPaused: Boolean;
-
- { Record of the players performance. }
- itsMoves: Integer;
- itsLastStartTime, itsTimeBeforeLastStart, itsTimeSinceLastStart, itsTimeSinceLastStartOld: LongInt;
-
- { Flags for special effects. }
- fAnimate, fSound: Boolean;
-
- { We play the welcoming startup sound once and only once. }
- fWelcomingSoundPlayed: Boolean;
-
- { Construction of the game director object. }
- procedure IShGameDirector (aSupervisor: CShApp);
-
- { Destruction of the game director object. We set our pointers }
- { to nil, for the objects to which they were pointing will be disposed of in }
- { inherited methods. }
- procedure Free;
- override;
-
- { The game director is responsible for reacting to game controls. }
- { It also checks for the Help item being selected from the Help Menu. }
- procedure DoCommand (theCommand: longint);
- override;
-
- { Check for the help key being pressed. }
- procedure DoKeyDown (theChar: char; keyCode: Byte; macEvent: EventRecord);
- override;
-
- { Respond to a click on the given tile. }
- procedure DoTileClicked (aTileNum: TileRange);
-
- { Display the title screen. Possible cases are on startup, after a level is }
- { completed, or a game is aborted. }
- procedure DisplayTitleScreen (aCompletedLevel: Boolean);
-
- { The game director is responsible for all commands related to playing the game, }
- { and the user preferences for animation and sound. }
- procedure UpdateMenus;
- override;
-
- { The levels table communicates with the game director through the provider }
- { changed mechanism. If the list of levels has changed its selection, it records }
- { the fact and informs the start button. }
- procedure ProviderChanged (aProvider: CCollaborator; reason: Longint; info: univ Ptr);
- override;
-
- { If the game is progressing, update the clock. }
- procedure Dawdle (var maxSleep: longint);
- override;
-
- { Installs the specified list of levels in the table. }
- procedure SetLevels (aLevels: CList);
-
- { Returns TRUE if playing, FALSE otherwise. }
- function IsPlaying: Boolean;
-
- end; { CShGameDirector }
-
-
- {****************************************************}
- {}
- { CShHelpDirector }
- {}
- { DLOGDirector class for the director which handles the about/help dialog. }
- {}
- {****************************************************}
-
- type
- HelpScreenType = (AboutScreen, HelpScreen, CreditsScreen);
-
- type
- CShHelpDirector = object(CDLOGDirector)
-
- { Single picture in which everything will be placed. }
- itsPicture: CPicture;
-
- { Buttons for changing screens, or closing the dialog. }
- itsAboutButton, itsHelpButton, itsCreditsButton: CButton;
-
- { Construction of the help director object. }
- procedure IShHelpDirector (aSupervisor: CShApp);
-
- { Destruction of the help director object. We set our pointers to nil, for the }
- { objects to which they were pointing will be disposed of in inherited methods. }
- procedure Free;
- override;
-
- { The help director is responsible for changing between help screens. }
- procedure DoCommand (theCommand: longint);
- override;
-
- { Continuous scrolling of the credits. }
- procedure Dawdle (var maxSleep: longint);
- override;
-
- { Set up the panes for each of the possible screens. }
- procedure SetDialogPanes (aScreenType: HelpScreenType);
-
- { Enter the about/help dialog, starting from the given first screen. }
- procedure DoAboutAndHelp (aFirstScreen: HelpScreenType);
-
- end; { CShHelpDirector }
-
-
- {****************************************************}
- {}
- { CShLevel }
- {}
- { Object class for a level in the Showwit! game. }
- {}
- {****************************************************}
-
- { Resource template for best player is used by the application to store to the }
- { preferences file, by the levels documents to store to their own files, and }
- { by the levels objects when reading in. }
-
- type
- BESTtemplate = record
- thePlayer: Str15;
- theMoves: Integer;
- theTime: LongInt;
- end;
- BESTtemplateP = ^BESTtemplate;
- BESTtemplateH = ^BESTtemplateP;
-
- CShLevel = object(CObject)
-
- { Information about the level. }
-
- itsName: Str15;
- itsStart: ConfigType;
- itsRules: RulesType;
-
- { Information about the best player. }
-
- itsPlayer: Str15;
- itsMoves: Integer;
- itsTime: LongInt;
-
- { Set the level details from a LEVL resource. }
- procedure SetLEVL (LEVLid: Integer);
-
- { Set the best player details from a BEST resource. }
- procedure SetBEST (BESTid: Integer);
-
- { Set the best player details to some safe, default values. }
- procedure SetDefaultBestPlayer;
-
- { Returns the name of the level. }
- function GetName: Str15;
-
- { Returns the starting configuration of the level. }
- function GetStart: ConfigType;
-
- { Returns the rules for the level. }
- function GetRules: RulesType;
-
- { Returns the name of the current best player of the level. }
- function GetPlayer: Str15;
-
- { Sets the name of the current best player of the level. }
- procedure SetPlayer (aPlayer: Str15);
-
- { Returns the moves taken by the current best player of the level. }
- function GetMoves: Integer;
-
- { Sets the moves taken by the current best player of the level. }
- procedure SetMoves (aMoves: Integer);
-
- { Returns the time taken by the current best player of the level. }
- function GetTime: LongInt;
-
- { Sets the time taken by the current best player of the level. }
- procedure SetTime (aTime: LongInt);
-
- end; { CShLevel }
-
-
- {****************************************************}
- {}
- { CShLevelsDoc }
- {}
- { Document class for the Showwit! application. Documents store levels }
- { which can be played. }
- {}
- {****************************************************}
-
- type
- CShLevelsDoc = object(CDocument)
-
- { Pointer to the application, so that we can send it the levels. }
- itsShApp: CShApp;
-
- { Pointer to the file. }
- itsShLevelsFile: CResFile;
-
- { Pointer to the progress bar. }
- itsProgBar: CProgressBar;
-
- { Construction of the levels document object. }
- procedure IShLevelsDoc (aSupervisor: CShApp);
-
- { Destruction of the levels document object. We set our pointers to nil, for the }
- { objects to which they were pointing will be disposed of in inherited methods. }
- procedure Free;
- override;
-
- { Opens the levels file, reads the levels and then closes the document (we do }
- { not need the file open afterwards). Updates the progress bar whilst doing so. }
- procedure OpenFile (macSFReply: SFReply);
- override;
-
- { Stores the specified best player to the levels file. }
- procedure StoreBestPlayer (aLevelNum: LevelsRange; aPlayer: Str15; aMoves: Integer; aTime: LongInt);
-
- { Clears the best players from the levels file. }
- procedure ClearBestPlayers;
-
- end; { CShLevelsDoc }
-
-
- {****************************************************}
- {}
- { CShLevelsTable }
- {}
- { Array pane class for displaying the list of levels held by the game director. }
- {}
- {****************************************************}
-
- type
- CShLevelsTable = object(CArrayPane)
-
- { Pointer to the game director. }
- itsGameDirector: CShGameDirector;
-
- { Construction of the levels table object. }
- procedure CShLevelsTable.IShLevelsTable (anEnclosure: CView; aSupervisor: CShGameDirector; aWidth, aHeight, aHEncl, aVEncl: Integer; aHSizing, aVSizing: SizingOption);
-
- { Destruction of the levels table object. We set our pointers to nil, for the }
- { objects to which they were pointing will be disposed of in inherited methods. }
- procedure Free;
- override;
-
- { The levels table is responsible for clearing the players from its array, }
- { and then bouncing the command to the game director. }
- procedure DoCommand (theCommand: longint);
- override;
-
- { The levels table is responsible for enabling the clear best players command. }
- procedure UpdateMenus;
- override;
-
- { Do the double click command if return/enter is pressed. }
- procedure DoKeyDown (theChar: Char; keyCode: Byte; macEvent: EventRecord);
- override;
-
- { Draw the level number, name and best player statistics. }
- procedure DrawCell (theCell: Cell; cellRect: Rect);
- override;
-
- { Returns the index of the row in the table which is selected, 0 if none. }
- function RowSelected: LevelsRange;
-
- end; { CShLevelsTable }
-
-
- implementation
-
-
- end. { ShIntf }