Debian Codegraph @

examples/tiled/strategy_game_demo/code/gameviewwin.pas

raw
1 {
2 Copyright 2018-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 { Display instructions. }
17 unit GameViewWin;
18
19 interface
20
21 uses CastleControls, CastleWindow, CastleUIControls,
22 CastleKeysMouse;
23
24 type
25 TViewWin = class(TCastleView)
26 public
27 HumansWin: Boolean; //< Set this before starting this view.
28 procedure Start; override;
29 function Press(const Event: TInputPressRelease): Boolean; override;
30 end;
31
32 var
33 ViewWin: TViewWin;
34
35 implementation
36
37 uses SysUtils, Classes,
38 CastleComponentSerialize,
39 GameViewMainMenu;
40
41 procedure TViewWin.Start;
42 begin
43 inherited;
44
45 { Load designed user interface }
46 if HumansWin then
47 DesignUrl := 'castle-data:/gameviewwinhumans.castle-user-interface'
48 else
49 DesignUrl := 'castle-data:/gameviewwinaliens.castle-user-interface';
50
51 { do not pass clicks to view underneath }
52 InterceptInput := true;
53 end;
54
55 function TViewWin.Press(const Event: TInputPressRelease): Boolean;
56 begin
57 Result := inherited;
58
59 if Event.IsMouseButton(buttonLeft) then
60 begin
61 Container.View := ViewMainMenu;
62 Exit(true);
63 end;
64 end;
65
66 end.