| 1 |
{ |
| 2 |
Copyright 2016-2023 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 |
{ Game view with main menu. } |
| 17 |
unit GameViewMainMenu; |
| 18 |
|
| 19 |
interface |
| 20 |
|
| 21 |
uses Classes, CastleControls, CastleUIControls; |
| 22 |
|
| 23 |
type |
| 24 |
TViewMainMenu = class(TCastleView) |
| 25 |
published |
| 26 |
{ Components designed using CGE editor. |
| 27 |
These fields will be automatically initialized at Start. } |
| 28 |
ButtonNewGame, ButtonQuit: TCastleButton; |
| 29 |
strict private |
| 30 |
procedure ClickNewGame(Sender: TObject); |
| 31 |
procedure ClickQuit(Sender: TObject); |
| 32 |
public |
| 33 |
constructor Create(AOwner: TComponent); override; |
| 34 |
procedure Start; override; |
| 35 |
end; |
| 36 |
|
| 37 |
var |
| 38 |
ViewMainMenu: TViewMainMenu; |
| 39 |
|
| 40 |
implementation |
| 41 |
|
| 42 |
uses CastleColors, CastleWindow, CastleFilesUtils, CastleApplicationProperties, |
| 43 |
CastleUtils, CastleComponentSerialize, |
| 44 |
GameViewLoading; |
| 45 |
|
| 46 |
{ TViewMainMenu ------------------------------------------------------------- } |
| 47 |
|
| 48 |
constructor TViewMainMenu.Create(AOwner: TComponent); |
| 49 |
begin |
| 50 |
inherited; |
| 51 |
DesignUrl := 'castle-data:/gameviewmainmenu.castle-user-interface'; |
| 52 |
end; |
| 53 |
|
| 54 |
procedure TViewMainMenu.Start; |
| 55 |
begin |
| 56 |
inherited; |
| 57 |
|
| 58 |
{ attach events } |
| 59 |
ButtonNewGame.OnClick := {$ifdef FPC}@{$endif}ClickNewGame; |
| 60 |
ButtonQuit.OnClick := {$ifdef FPC}@{$endif}ClickQuit; |
| 61 |
|
| 62 |
// on some platforms, showing "Quit" button is not standard |
| 63 |
ButtonQuit.Exists := ApplicationProperties.ShowUserInterfaceToQuit; |
| 64 |
end; |
| 65 |
|
| 66 |
procedure TViewMainMenu.ClickNewGame(Sender: TObject); |
| 67 |
begin |
| 68 |
Container.View := ViewLoading; |
| 69 |
end; |
| 70 |
|
| 71 |
procedure TViewMainMenu.ClickQuit(Sender: TObject); |
| 72 |
begin |
| 73 |
Application.Terminate; |
| 74 |
end; |
| 75 |
|
| 76 |
end. |