| 1 |
{ |
| 2 |
Copyright 2018-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 |
{ Display main menu. } |
| 17 |
unit GameViewMainMenu; |
| 18 |
|
| 19 |
interface |
| 20 |
|
| 21 |
uses Classes, |
| 22 |
CastleControls, CastleWindow, CastleUIControls; |
| 23 |
|
| 24 |
type |
| 25 |
TViewMainMenu = class(TCastleView) |
| 26 |
published |
| 27 |
{ Components designed using CGE editor. |
| 28 |
These fields will be automatically initialized at Start. } |
| 29 |
ButtonPlayHexagonal: TCastleButton; |
| 30 |
ButtonPlayIsometricStaggered: TCastleButton; |
| 31 |
ButtonPlayIsometric: TCastleButton; |
| 32 |
ButtonPlayOrthogonal: TCastleButton; |
| 33 |
ButtonQuit: TCastleButton; |
| 34 |
strict private |
| 35 |
procedure ClickHexagonal(Sender: TObject); |
| 36 |
procedure ClickIsometricStaggered(Sender: TObject); |
| 37 |
procedure ClickIsometric(Sender: TObject); |
| 38 |
procedure ClickOrthogonal(Sender: TObject); |
| 39 |
procedure ClickQuit(Sender: TObject); |
| 40 |
public |
| 41 |
constructor Create(AOwner: TComponent); override; |
| 42 |
procedure Start; override; |
| 43 |
end; |
| 44 |
|
| 45 |
var |
| 46 |
ViewMainMenu: TViewMainMenu; |
| 47 |
|
| 48 |
implementation |
| 49 |
|
| 50 |
uses SysUtils, |
| 51 |
CastleComponentSerialize, CastleApplicationProperties, |
| 52 |
GameViewPlay; |
| 53 |
|
| 54 |
constructor TViewMainMenu.Create(AOwner: TComponent); |
| 55 |
begin |
| 56 |
inherited; |
| 57 |
DesignUrl := 'castle-data:/gameviewmainmenu.castle-user-interface'; |
| 58 |
end; |
| 59 |
|
| 60 |
procedure TViewMainMenu.Start; |
| 61 |
begin |
| 62 |
inherited; |
| 63 |
ButtonPlayHexagonal.OnClick := {$ifdef FPC}@{$endif}ClickHexagonal; |
| 64 |
ButtonPlayIsometricStaggered.OnClick := {$ifdef FPC}@{$endif}ClickIsometricStaggered; |
| 65 |
ButtonPlayIsometric.OnClick := {$ifdef FPC}@{$endif}ClickIsometric; |
| 66 |
ButtonPlayOrthogonal.OnClick := {$ifdef FPC}@{$endif}ClickOrthogonal; |
| 67 |
ButtonQuit.OnClick := {$ifdef FPC}@{$endif}ClickQuit; |
| 68 |
ButtonQuit.Exists := ApplicationProperties.ShowUserInterfaceToQuit; |
| 69 |
end; |
| 70 |
|
| 71 |
procedure TViewMainMenu.ClickHexagonal(Sender: TObject); |
| 72 |
begin |
| 73 |
ViewPlay.MapName := 'map-hexagonal'; |
| 74 |
Container.View := ViewPlay; |
| 75 |
end; |
| 76 |
|
| 77 |
procedure TViewMainMenu.ClickIsometricStaggered(Sender: TObject); |
| 78 |
begin |
| 79 |
ViewPlay.MapName := 'map-isometric-staggered'; |
| 80 |
Container.View := ViewPlay; |
| 81 |
end; |
| 82 |
|
| 83 |
procedure TViewMainMenu.ClickIsometric(Sender: TObject); |
| 84 |
begin |
| 85 |
ViewPlay.MapName := 'map-isometric'; |
| 86 |
Container.View := ViewPlay; |
| 87 |
end; |
| 88 |
|
| 89 |
procedure TViewMainMenu.ClickOrthogonal(Sender: TObject); |
| 90 |
begin |
| 91 |
ViewPlay.MapName := 'map-orthogonal'; |
| 92 |
Container.View := ViewPlay; |
| 93 |
end; |
| 94 |
|
| 95 |
procedure TViewMainMenu.ClickQuit(Sender: TObject); |
| 96 |
begin |
| 97 |
Application.Terminate; |
| 98 |
end; |
| 99 |
|
| 100 |
end. |