| 1 |
{ |
| 2 |
Copyright 2014-2022 Michalis Kamburelis. |
| 3 |
|
| 4 |
This file is part of "Castle Game Engine". |
| 5 |
|
| 6 |
"Castle Game Engine" is free software; see the file COPYING.txt, |
| 7 |
included in this distribution, for details about the copyright. |
| 8 |
|
| 9 |
"Castle Game Engine" is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 12 |
|
| 13 |
---------------------------------------------------------------------------- |
| 14 |
} |
| 15 |
|
| 16 |
{ Simple "menu" user interface, that allows to run the game or quit. } |
| 17 |
unit GameViewMenu; |
| 18 |
|
| 19 |
interface |
| 20 |
|
| 21 |
uses Classes, |
| 22 |
CastleComponentSerialize, CastleUIControls, CastleControls; |
| 23 |
|
| 24 |
type |
| 25 |
{ Simple "menu" user interface, that allows to run the game or quit. } |
| 26 |
TViewMenu = class(TCastleView) |
| 27 |
published |
| 28 |
{ Components designed using CGE editor. |
| 29 |
These fields will be automatically initialized at Start. } |
| 30 |
ButtonPlay, ButtonQuit: TCastleButton; |
| 31 |
private |
| 32 |
procedure ClickPlay(Sender: TObject); |
| 33 |
procedure ClickQuit(Sender: TObject); |
| 34 |
public |
| 35 |
constructor Create(AOwner: TComponent); override; |
| 36 |
procedure Start; override; |
| 37 |
end; |
| 38 |
|
| 39 |
var |
| 40 |
ViewMenu: TViewMenu; |
| 41 |
|
| 42 |
implementation |
| 43 |
|
| 44 |
uses CastleApplicationProperties, CastleWindow, |
| 45 |
GameViewPlay; |
| 46 |
|
| 47 |
{ TViewMenu ----------------------------------------------------------------- } |
| 48 |
|
| 49 |
constructor TViewMenu.Create(AOwner: TComponent); |
| 50 |
begin |
| 51 |
inherited; |
| 52 |
DesignUrl := 'castle-data:/gameviewmenu.castle-user-interface'; |
| 53 |
end; |
| 54 |
|
| 55 |
procedure TViewMenu.Start; |
| 56 |
begin |
| 57 |
inherited; |
| 58 |
ButtonPlay.OnClick := {$ifdef FPC}@{$endif} ClickPlay; |
| 59 |
ButtonQuit.OnClick := {$ifdef FPC}@{$endif} ClickQuit; |
| 60 |
// Hide "Quit" button on mobile/console platforms, where users don't expect such button |
| 61 |
ButtonQuit.Exists := ApplicationProperties.ShowUserInterfaceToQuit; |
| 62 |
end; |
| 63 |
|
| 64 |
procedure TViewMenu.ClickPlay(Sender: TObject); |
| 65 |
begin |
| 66 |
Container.View := ViewPlay; |
| 67 |
end; |
| 68 |
|
| 69 |
procedure TViewMenu.ClickQuit(Sender: TObject); |
| 70 |
begin |
| 71 |
Application.Terminate; |
| 72 |
end; |
| 73 |
|
| 74 |
end. |