-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoverlays.pas
113 lines (88 loc) · 2.78 KB
/
overlays.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
unit Overlays;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Math, CastleUIState,
{$ifndef cgeapp}
Forms, Controls, Graphics, Dialogs, CastleControl,
{$else}
CastleWindow,
{$endif}
CastleControls, CastleColors, CastleUIControls,
CastleTriangles, CastleShapes, CastleVectors,
CastleSceneCore, CastleScene, CastleTransform,
CastleViewport, CastleCameras, CastleProjection,
X3DNodes, X3DFields, X3DTIme, CastleNotifications,
CastleImages, CastleGLImages, CastleRectangles, CastleQuaternions,
CastleTextureImages, CastleLog,
CastleApplicationProperties, CastleTimeUtils, CastleKeysMouse,
CastleGLUtils, multimodel, staging, MiscFunctions;
type
{ TCastleOverlay }
TCastleOverlay = class(TUIState)
constructor Create(AOwner: TComponent); override;
procedure BeforeRender; override; // TCastleUserInterface
procedure Render; override; // TCastleUserInterface
procedure Resize; override; // TCastleUserInterface
procedure Update(const SecondsPassed: Single; var HandleInput: boolean); override; // TUIState
private
stateNotifications: TCastleNotifications;
Overlay: TCastleRectangleControl;
Screen: TCastleRectangleControl;
public
procedure Start; override; // TUIState
procedure Stop; override; // TUIState
procedure AddNote(const AMsg: String);
end;
implementation
uses MainGameUnit;
constructor TCastleOverlay.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FullSize := True;
Overlay := TCastleRectangleControl.Create(AOwner);
Overlay.FullSize := True;
Overlay.Color := Vector4(0, 0, 0, 0.25);
InsertFront(Overlay);
Screen := TCastleRectangleControl.Create(Overlay);
Screen.HorizontalAnchorParent := hpMiddle;
Screen.HorizontalAnchorSelf := hpMiddle;
Screen.VerticalAnchorParent := vpMiddle;
Screen.VerticalAnchorSelf := vpMiddle;
Screen.Width := Trunc(StateContainer.Width * 0.75);
Screen.Height := Trunc(StateContainer.Height * 0.75);
Screen.Color := HexToColor('C8C8C8');
Overlay.InsertFront(Screen);
stateNotifications := TCastleNotifications.Create(Screen);
stateNotifications.MaxMessages := 12;
stateNotifications.Anchor(hpLeft, 10);
stateNotifications.Anchor(vpBottom, 10);
Screen.InsertFront(stateNotifications);
end;
procedure TCastleOverlay.AddNote(const AMsg: String);
begin
stateNotifications.Show(AMsg);
end;
procedure TCastleOverlay.Start;
begin
inherited;
end;
procedure TCastleOverlay.Stop;
begin
end;
procedure TCastleOverlay.BeforeRender;
begin
end;
procedure TCastleOverlay.Render;
begin
end;
procedure TCastleOverlay.Resize;
begin
inherited;
Screen.Width := Trunc(StateContainer.Width * 0.75);
Screen.Height := Trunc(StateContainer.Height * 0.75);
end;
procedure TCastleOverlay.Update(const SecondsPassed: Single; var HandleInput: boolean);
begin
end;
end.