-
Notifications
You must be signed in to change notification settings - Fork 5
/
uscreens.pas
246 lines (207 loc) · 7.48 KB
/
uscreens.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
(******************************************************************************)
(* *)
(* Author : Uwe Schächterle (Corpsman) *)
(* *)
(* This file is part of Bridge builder *)
(* *)
(* See the file license.md, located under: *)
(* https://github.com/PascalCorpsman/Software_Licenses/blob/main/license.md *)
(* for details about the license. *)
(* *)
(* It is not allowed to change or remove this text from any *)
(* source file of the project. *)
(* *)
(******************************************************************************)
Unit uscreens;
{$MODE ObjFPC}{$H+}
Interface
Uses
Classes, SysUtils, uopengl_graphikengine, uopengl_widgetset, OpenGlcontext, uOpenGL_ASCII_Font;
Type
{ TMainScreen }
TMainScreen = Class
ExitButton: TOpenGl_Button;
LoadButton: TOpenGl_Button;
EditorButton: TOpenGl_Button;
private
fTexture: TGraphikItem;
Procedure SetVisible(AValue: Boolean);
public
Property Visible: Boolean write SetVisible;
Constructor Create(Owner: TOpenGLControl); virtual;
Destructor Destroy(); override;
Procedure Render;
End;
{ TEditorScreen }
TEditorScreen = Class
SetStartPoint: TOpenGL_Radiobutton;
EditCollider: TOpenGL_Radiobutton;
EditFixedPoints: TOpenGL_Radiobutton;
EditFinalZone: TOpenGL_Radiobutton;
EditInitialEdges: TOpenGL_Radiobutton;
EditDeadZones: TOpenGL_Radiobutton;
LoadBackGround: TOpenGl_Button;
private
Procedure SetVisible(AValue: Boolean);
public
Property Visible: Boolean write SetVisible;
Constructor Create(Owner: TOpenGLControl); virtual;
Destructor Destroy(); override;
Procedure Render;
End;
{ TInGameScreen }
TInGameScreen = Class
LeaveButton: TOpenGl_Button;
RunButton: TOpenGl_Button;
ResetButton: TOpenGl_Button;
private
Procedure SetVisible(AValue: Boolean);
public
Property Visible: Boolean write SetVisible;
Constructor Create(Owner: TOpenGLControl); virtual;
Destructor Destroy(); override;
Procedure Render;
End;
Implementation
Uses ubridge_builder, dglOpenGL;
{ TMainScreen }
Constructor TMainScreen.Create(Owner: TOpenGLControl);
Begin
fTexture := OpenGL_GraphikEngine.LoadAlphaGraphikItem('GFX' + PathDelim + 'MainMenu.png', smClamp);
LoadButton := TOpenGl_Button.Create(Owner);
LoadButton.LoadTextures('GFX' + PathDelim + 'Load.png', 'GFX' + PathDelim + 'Load_s.png', 'GFX' + PathDelim + 'Load_s.png');
LoadButton.Top := 250;
LoadButton.Left := (ScreenWidth - LoadButton.Width) Div 2;
EditorButton := TOpenGl_Button.Create(Owner);
EditorButton.LoadTextures('GFX' + PathDelim + 'Editor.png', 'GFX' + PathDelim + 'Editor_s.png', 'GFX' + PathDelim + 'Editor_s.png');
EditorButton.Top := 250 + LoadButton.Height + 24;
EditorButton.Left := (ScreenWidth - EditorButton.Width) Div 2;
ExitButton := TOpenGl_Button.Create(Owner);
ExitButton.LoadTextures('GFX' + PathDelim + 'Exit.png', 'GFX' + PathDelim + 'Exit_s.png', 'GFX' + PathDelim + 'Exit_s.png');
ExitButton.Top := ScreenHeight - ExitButton.Height - 24;
ExitButton.Left := (ScreenWidth - ExitButton.Width) Div 2;
End;
Destructor TMainScreen.Destroy;
Begin
ExitButton.Free;
End;
Procedure TMainScreen.SetVisible(AValue: Boolean);
Begin
ExitButton.Visible := AValue;
LoadButton.Visible := AValue;
EditorButton.Visible := AValue;
End;
Procedure TMainScreen.Render;
Var
s: String;
Begin
RenderAlphaQuad(0, 0, fTexture);
LoadButton.Render();
EditorButton.Render();
ExitButton.Render();
glBindTexture(GL_TEXTURE_2D, 0);
s := 'Version: ' + Version;
OpenGL_ASCII_Font.Textout(round(ScreenWidth - OpenGL_ASCII_Font.TextWidth(s)), round(ScreenHeight - OpenGL_ASCII_Font.TextHeight(s)), s);
End;
{ TEditorScreen }
Procedure TEditorScreen.SetVisible(AValue: Boolean);
Begin
SetStartPoint.Visible := AValue;
EditCollider.Visible := AValue;
EditFixedPoints.Visible := AValue;
EditFinalZone.Visible := AValue;
EditInitialEdges.Visible := AValue;
LoadBackGround.Visible := AValue;
End;
Constructor TEditorScreen.Create(Owner: TOpenGLControl);
Begin
Inherited Create;
setStartPoint := TOpenGL_Radiobutton.Create(Owner, '');
setStartPoint.Top := 10;
setStartPoint.Left := 10;
setStartPoint.Caption := 'Set startnode';
EditFixedPoints := TOpenGL_Radiobutton.Create(Owner, '');
EditFixedPoints.Top := setStartPoint.top + setStartPoint.Height + 5;
EditFixedPoints.Left := 10;
EditFixedPoints.Caption := 'Edit fixed points';
EditCollider := TOpenGL_Radiobutton.Create(Owner, '');
EditCollider.Top := EditFixedPoints.top + EditFixedPoints.Height + 5;
EditCollider.Left := 10;
EditCollider.Caption := 'Edit collider';
EditFinalZone := TOpenGL_Radiobutton.Create(Owner, '');
EditFinalZone.Top := EditCollider.top + EditCollider.Height + 5;
EditFinalZone.Left := 10;
EditFinalZone.Caption := 'Edit final zone';
EditInitialEdges := TOpenGL_Radiobutton.Create(Owner, '');
EditInitialEdges.Top := EditFinalZone.top + EditFinalZone.Height + 5;
EditInitialEdges.Left := 10;
EditInitialEdges.Caption := 'Edit initial edges';
EditDeadZones := TOpenGL_Radiobutton.Create(Owner, '');
EditDeadZones.Top := EditInitialEdges.top + EditInitialEdges.Height + 5;
EditDeadZones.Left := 10;
EditDeadZones.Caption := 'Edit dead zones';
LoadBackGround := TOpenGl_Button.Create(Owner);
LoadBackGround.caption := 'Load background';
LoadBackGround.top := 10;
LoadBackGround.width := round(OpenGL_ASCII_Font.TextWidth(LoadBackGround.caption)) + 20;
LoadBackGround.Left := ScreenWidth - LoadBackGround.width - 10;
End;
Destructor TEditorScreen.Destroy;
Begin
EditCollider.free;
EditFixedPoints.free;
EditFinalZone.free;
LoadBackGround.free;
setStartPoint.free;
EditInitialEdges.free;
EditDeadZones.free;
End;
Procedure TEditorScreen.Render;
Begin
EditCollider.Render();
EditFixedPoints.Render();
EditFinalZone.Render();
LoadBackGround.render();
setStartPoint.render();
EditInitialEdges.Render();
EditDeadZones.Render();
End;
{ TInGameScreen }
Constructor TInGameScreen.Create(Owner: TOpenGLControl);
Begin
Inherited Create;
LeaveButton := TOpenGl_Button.Create(Owner);
LeaveButton.Caption := 'Leave';
LeaveButton.Top := 10;
LeaveButton.Width := 50;
LeaveButton.Left := 10;
RunButton := TOpenGl_Button.Create(Owner);
RunButton.Caption := 'Run';
RunButton.Top := 10;
RunButton.Width := 50;
RunButton.Left := ScreenWidth - RunButton.Width - 10;
ResetButton := TOpenGl_Button.Create(Owner);
ResetButton.Caption := 'Reset';
ResetButton.Top := 10 + RunButton.Height + 10;
ResetButton.Width := 50;
ResetButton.Left := ScreenWidth - RunButton.Width - 10;
End;
Destructor TInGameScreen.Destroy;
Begin
LeaveButton.Free;
RunButton.Free;
ResetButton.Free;
End;
Procedure TInGameScreen.SetVisible(AValue: Boolean);
Begin
LeaveButton.visible := AValue;
RunButton.visible := AValue;
ResetButton.visible := AValue;
End;
Procedure TInGameScreen.Render;
Begin
LeaveButton.Render();
RunButton.Render();
ResetButton.Render();
End;
End.