Rev 12 | Rev 17 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 12 | Rev 16 | ||
---|---|---|---|
Line 20... | Line 20... | ||
20 | 20 | ||
21 | interface |
21 | interface |
22 | 22 | ||
23 | uses |
23 | uses |
24 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, |
24 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, |
25 | Dialogs, ExtCtrls, StdCtrls, Game; |
25 | Dialogs, ExtCtrls, StdCtrls, Game, MPlayer; |
26 | 26 | ||
27 | type |
27 | type |
28 | TMainForm = class(TForm) |
28 | TMainForm = class(TForm) |
29 | Image1: TImage; |
29 | Image1: TImage; |
30 | Panel1: TPanel; |
30 | Panel1: TPanel; |
31 | StartupTimer: TTimer; |
31 | StartupTimer: TTimer; |
- | 32 | MediaPlayer1: TMediaPlayer; |
|
- | 33 | Panel2: TPanel; |
|
32 | procedure FormCreate(Sender: TObject); |
34 | procedure FormCreate(Sender: TObject); |
33 | procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); |
35 | procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); |
34 | procedure StartupTimerTimer(Sender: TObject); |
36 | procedure StartupTimerTimer(Sender: TObject); |
35 | procedure ControlClick(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); |
37 | procedure ControlClick(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); |
36 | procedure FormDestroy(Sender: TObject); |
38 | procedure FormDestroy(Sender: TObject); |
Line 211... | Line 213... | ||
211 | FreeAndNil(ini); |
213 | FreeAndNil(ini); |
212 | end; |
214 | end; |
213 | end; |
215 | end; |
214 | 216 | ||
215 | try |
217 | try |
216 | Game := TGame.Create('.'); |
- | |
217 | Game.PictureShowCallback := cbPictureShow; |
- | |
218 | Game.AsyncSoundCallback := cbAsyncSound; |
- | |
219 | Game.ExitCallback := cbExit; |
- | |
220 | Game.WaitCallback := cbWait; |
- | |
221 | Game.SetHotspotCallback := cbSetHotspot; |
- | |
222 | Game.ClearHotspotsCallback := cbClearHotspots; |
- | |
223 | StartupTimer.Enabled := true; |
218 | StartupTimer.Enabled := true; |
224 | except |
219 | except |
225 | Application.Terminate; |
220 | Application.Terminate; |
226 | end; |
221 | end; |
227 | end; |
222 | end; |
Line 234... | Line 229... | ||
234 | end; |
229 | end; |
235 | 230 | ||
236 | procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word; |
231 | procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word; |
237 | Shift: TShiftState); |
232 | Shift: TShiftState); |
238 | begin |
233 | begin |
- | 234 | if Key = VK_SPACE then |
|
- | 235 | begin |
|
- | 236 | if MediaPlayer1.Mode = mpPlaying then MediaPlayer1.Stop; |
|
- | 237 | end; |
|
239 | if Key = VK_ESCAPE then Close; |
238 | if Key = VK_ESCAPE then Close; |
240 | end; |
239 | end; |
241 | 240 | ||
242 | procedure TMainForm.ClickEvent(X, Y: Integer); |
241 | procedure TMainForm.ClickEvent(X, Y: Integer); |
243 | var |
242 | var |
Line 268... | Line 267... | ||
268 | end; |
267 | end; |
269 | 268 | ||
270 | procedure TMainForm.StartupTimerTimer(Sender: TObject); |
269 | procedure TMainForm.StartupTimerTimer(Sender: TObject); |
271 | begin |
270 | begin |
272 | StartupTimer.Enabled := false; |
271 | StartupTimer.Enabled := false; |
- | 272 | ||
- | 273 | if FileExists('INTRO.AVI') then |
|
- | 274 | begin |
|
- | 275 | MediaPlayer1.FileName := 'INTRO.AVI'; |
|
- | 276 | MediaPlayer1.Open; |
|
- | 277 | ||
- | 278 | Panel2.Visible := true; |
|
- | 279 | Panel2.Top := 0; |
|
- | 280 | Panel2.Left := 0; |
|
- | 281 | Panel2.Width := MediaPlayer1.DisplayRect.Right; |
|
- | 282 | Panel2.Height := MediaPlayer1.DisplayRect.Bottom; |
|
- | 283 | ||
- | 284 | ClientWidth := Panel2.Width; |
|
- | 285 | if (ClientWidth >= Screen.Width) then FullscreenMode := true; |
|
- | 286 | ClientHeight := Panel2.Height; |
|
- | 287 | if (ClientHeight >= Screen.Height) then FullscreenMode := true; |
|
- | 288 | Position := poScreenCenter; |
|
- | 289 | ||
- | 290 | if FullScreenMode then |
|
- | 291 | begin |
|
- | 292 | BorderStyle := bsNone; |
|
- | 293 | FormStyle := fsStayOnTop; |
|
- | 294 | Screen.Cursor := -1; |
|
- | 295 | end; |
|
- | 296 | ||
- | 297 | // For some reason, "Position := poScreenCenter" causes the video handle to break! |
|
- | 298 | // we need to close+open it again! |
|
- | 299 | MediaPlayer1.Close; |
|
- | 300 | MediaPlayer1.Open; |
|
- | 301 | ||
- | 302 | MediaPlayer1.Play; |
|
- | 303 | while MediaPlayer1.Mode <> mpStopped do |
|
- | 304 | begin |
|
- | 305 | Sleep(100); |
|
- | 306 | Application.ProcessMessages; |
|
- | 307 | if Application.Terminated then break; |
|
- | 308 | end; |
|
- | 309 | ||
- | 310 | MediaPlayer1.Close; |
|
- | 311 | Panel2.Visible := false; |
|
- | 312 | Screen.Cursor := 0; |
|
- | 313 | end; |
|
- | 314 | ||
- | 315 | try |
|
- | 316 | Game := TGame.Create('.'); |
|
- | 317 | try |
|
- | 318 | Game.PictureShowCallback := cbPictureShow; |
|
- | 319 | Game.AsyncSoundCallback := cbAsyncSound; |
|
- | 320 | Game.ExitCallback := cbExit; |
|
- | 321 | Game.WaitCallback := cbWait; |
|
- | 322 | Game.SetHotspotCallback := cbSetHotspot; |
|
- | 323 | Game.ClearHotspotsCallback := cbClearHotspots; |
|
273 | Game.Run; |
324 | Game.Run; |
- | 325 | finally |
|
- | 326 | FreeAndNil(Game); |
|
- | 327 | end; |
|
- | 328 | except |
|
- | 329 | on E: Exception do |
|
- | 330 | begin |
|
- | 331 | MessageDlg(E.Message, mtError, [mbOK], 0); |
|
- | 332 | Close; |
|
- | 333 | end; |
|
- | 334 | end; |
|
274 | end; |
335 | end; |
275 | 336 | ||
276 | end. |
337 | end. |