Rev 12 | Rev 20 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 12 | Rev 19 | ||
---|---|---|---|
Line 20... | Line 20... | ||
20 | end; |
20 | end; |
21 | 21 | ||
22 | TShowPictureCallback = procedure(Game: TGame; AFilename: string; AType: TPictureType) of object; |
22 | TShowPictureCallback = procedure(Game: TGame; AFilename: string; AType: TPictureType) of object; |
23 | TPlaySoundCallback = procedure(Game: TGame; AFilename: string) of object; |
23 | TPlaySoundCallback = procedure(Game: TGame; AFilename: string) of object; |
24 | TSimpleCallback = procedure(Game: TGame) of object; |
24 | TSimpleCallback = procedure(Game: TGame) of object; |
25 | TWaitCallback = procedure(Game: TGame; AMilliseconds: integer) of object; |
25 | TWaitCallback = function(Game: TGame; AMilliseconds: integer): boolean of object; |
26 | TSetHotspotCallback = procedure(Game: TGame; AIndex: THotspotIndex; AHotspot: THotspot) of object; |
26 | TSetHotspotCallback = procedure(Game: TGame; AIndex: THotspotIndex; AHotspot: THotspot) of object; |
27 | TClearHotspotsCallback = procedure(Game: TGame) of object; |
27 | TClearHotspotsCallback = procedure(Game: TGame) of object; |
28 | 28 | ||
29 | TGame = class(TObject) |
29 | TGame = class(TObject) |
30 | private |
30 | private |
Line 39... | Line 39... | ||
39 | CurDecisionScene, LastDecisionScene: PSceneDef; |
39 | CurDecisionScene, LastDecisionScene: PSceneDef; |
40 | procedure TryExit; |
40 | procedure TryExit; |
41 | procedure PrevDecisionScene; |
41 | procedure PrevDecisionScene; |
42 | protected |
42 | protected |
43 | GameData: TGameBinFile; |
43 | GameData: TGameBinFile; |
44 | procedure Wait(AMilliseconds: integer); |
44 | function Wait(AMilliseconds: integer): boolean; |
45 | procedure PlayScene(scene: PSceneDef; goToDecision: boolean); |
45 | procedure PlayScene(scene: PSceneDef; goToDecision: boolean); |
46 | public |
46 | public |
47 | procedure PerformAction(action: PActionDef); |
47 | procedure PerformAction(action: PActionDef); |
48 | property PictureShowCallback: TShowPictureCallback read FPictureShowCallback write FPictureShowCallback; |
48 | property PictureShowCallback: TShowPictureCallback read FPictureShowCallback write FPictureShowCallback; |
49 | property AsyncSoundCallback: TPlaySoundCallback read FAsyncSoundCallback write FAsyncSoundCallback; |
49 | property AsyncSoundCallback: TPlaySoundCallback read FAsyncSoundCallback write FAsyncSoundCallback; |
Line 111... | Line 111... | ||
111 | raise Exception.CreateFmt('Scene %d was not found in GAME.BIN', [action^.nextSceneID]); |
111 | raise Exception.CreateFmt('Scene %d was not found in GAME.BIN', [action^.nextSceneID]); |
112 | *) |
112 | *) |
113 | end; |
113 | end; |
114 | end; |
114 | end; |
115 | 115 | ||
116 | procedure TGame.Wait(AMilliseconds: integer); |
116 | function TGame.Wait(AMilliseconds: integer): boolean; |
117 | begin |
117 | begin |
118 | if Assigned(WaitCallback) then |
118 | if Assigned(WaitCallback) then |
- | 119 | begin |
|
119 | WaitCallback(Self, AMilliseconds) |
120 | result := WaitCallback(Self, AMilliseconds) |
- | 121 | end |
|
120 | else |
122 | else |
- | 123 | begin |
|
121 | Sleep(AMilliseconds); |
124 | Sleep(AMilliseconds); |
- | 125 | result := false; // don't cancel |
|
- | 126 | end; |
|
122 | end; |
127 | end; |
123 | 128 | ||
124 | procedure TGame.PlayScene(scene: PSceneDef; goToDecision: boolean); |
129 | procedure TGame.PlayScene(scene: PSceneDef; goToDecision: boolean); |
125 | var |
130 | var |
126 | i: integer; |
131 | i: integer; |
Line 142... | Line 147... | ||
142 | if Assigned(PictureShowCallback) then |
147 | if Assigned(PictureShowCallback) then |
143 | begin |
148 | begin |
144 | PictureShowCallback(Self, IncludeTrailingPathDelimiter(FDirectory) + |
149 | PictureShowCallback(Self, IncludeTrailingPathDelimiter(FDirectory) + |
145 | scene^.szSceneFolder + PathDelim + GameData.pictures[i].szBitmapFile, ptDia); |
150 | scene^.szSceneFolder + PathDelim + GameData.pictures[i].szBitmapFile, ptDia); |
146 | end; |
151 | end; |
147 | Wait(GameData.pictures[i].duration * 100); |
152 | if Wait(GameData.pictures[i].duration * 100) then |
- | 153 | begin |
|
- | 154 | AsyncSoundCallback(Self, ''); |
|
- | 155 | break; |
|
- | 156 | end; |
|
148 | if Application.Terminated then Abort; |
157 | if Application.Terminated then Abort; |
149 | end; |
158 | end; |
150 | end; |
159 | end; |
151 | if scene^.szDecisionBmp <> '' then |
160 | if scene^.szDecisionBmp <> '' then |
152 | begin |
161 | begin |