-
Notifications
You must be signed in to change notification settings - Fork 2
/
frm_preview.pas
300 lines (262 loc) · 8.63 KB
/
frm_preview.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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
//------------------------------------------------------------------------------
//
// DD_MODEL: DelphiDOOM Procedural Model Editor
// Copyright (C) 2017-2021 by Jim Valavanis
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
// DESCRIPTION:
// 3D preview Form
//
//------------------------------------------------------------------------------
// E-Mail: jimmyvalavanis@yahoo.gr
// Site : https://sourceforge.net/projects/delphidoom-procedural-modeler/
//------------------------------------------------------------------------------
unit frm_preview;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Buttons, ComCtrls;
type
TPreviewForm = class(TForm)
Panel1: TPanel;
PreviewToolbarPanel: TPanel;
Copy3dButton: TSpeedButton;
Save3dButton: TSpeedButton;
PaintBoxViewFront: TPaintBox;
PaintBoxViewTop: TPaintBox;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
xPosEdit: TEdit;
yPosEdit: TEdit;
zPosEdit: TEdit;
Panel2: TPanel;
ScrollBox1: TScrollBox;
OpenGLPanel: TPanel;
FramesListBox: TListBox;
Label1: TLabel;
EditorToolbarPanel: TPanel;
PrevFrameButton: TSpeedButton;
NextFrameButton: TSpeedButton;
PlayAnimationButton: TSpeedButton;
StopAnimationButton: TSpeedButton;
Label2: TLabel;
TrackBar1: TTrackBar;
AnimationTimer: TTimer;
procedure FormCreate(Sender: TObject);
procedure OpenGLPanelDblClick(Sender: TObject);
procedure OpenGLPanelMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure OpenGLPanelMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure OpenGLPanelMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure OpenGLPanelResize(Sender: TObject);
procedure Copy3dButtonClick(Sender: TObject);
procedure Save3dButtonClick(Sender: TObject);
procedure PaintBoxViewFrontMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure PaintBoxViewFrontMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
procedure PaintBoxViewFrontMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure PaintBoxViewFrontPaint(Sender: TObject);
procedure PaintBoxViewTopMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure PaintBoxViewTopMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
procedure PaintBoxViewTopMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure PaintBoxViewTopPaint(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure FormCanResize(Sender: TObject; var NewWidth,
NewHeight: Integer; var Resize: Boolean);
procedure PrevFrameButtonClick(Sender: TObject);
procedure NextFrameButtonClick(Sender: TObject);
procedure FramesListBoxClick(Sender: TObject);
procedure PlayAnimationButtonClick(Sender: TObject);
procedure StopAnimationButtonClick(Sender: TObject);
procedure AnimationTimerTimer(Sender: TObject);
procedure TrackBar1Change(Sender: TObject);
procedure UpdateFrameFromListBox;
private
{ Private declarations }
public
{ Public declarations }
end;
var
PreviewForm: TPreviewForm;
implementation
{$R *.dfm}
uses
main,
mdl_globals,
mdl_utils;
procedure TPreviewForm.FormCreate(Sender: TObject);
begin
Scaled := False;
PreviewToolbarPanel.PopupMenu := Form1.PreviewPopupMenu;
TrackBar1Change(Sender);
globals.PreviewFormCreated := True;
end;
procedure TPreviewForm.OpenGLPanelDblClick(Sender: TObject);
begin
Form1.OpenGLPanelDblClick(Sender);
end;
procedure TPreviewForm.OpenGLPanelMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Form1.OpenGLPanelMouseDown(Sender, Button, Shift, X, Y);
end;
procedure TPreviewForm.OpenGLPanelMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
Form1.OpenGLPanelMouseMove(Sender, Shift, X, Y);
end;
procedure TPreviewForm.OpenGLPanelMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Form1.OpenGLPanelMouseUp(Sender, Button, Shift, X, Y);
end;
procedure TPreviewForm.OpenGLPanelResize(Sender: TObject);
begin
Form1.OpenGLPanelResize(Sender);
end;
procedure TPreviewForm.Copy3dButtonClick(Sender: TObject);
begin
Form1.Copy3dButtonClick(Sender);
end;
procedure TPreviewForm.Save3dButtonClick(Sender: TObject);
begin
Form1.Save3dButtonClick(Sender);
end;
procedure TPreviewForm.PaintBoxViewFrontMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Form1.PaintBoxViewMouseDown(Sender, Button, Shift, X, Y);
end;
procedure TPreviewForm.PaintBoxViewFrontMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
Form1.PaintBoxViewMouseMove(Sender, Shift, X, Y);
end;
procedure TPreviewForm.PaintBoxViewFrontMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Form1.PaintBoxViewMouseUp(Sender, Button, Shift, X, Y);
end;
procedure TPreviewForm.PaintBoxViewFrontPaint(Sender: TObject);
begin
Form1.PaintBoxViewFrontPaint(Sender);
end;
procedure TPreviewForm.PaintBoxViewTopMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Form1.PaintBoxViewMouseDown(Sender, Button, Shift, X, Y);
end;
procedure TPreviewForm.PaintBoxViewTopMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
Form1.PaintBoxViewMouseMove(Sender, Shift, X, Y);
end;
procedure TPreviewForm.PaintBoxViewTopMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Form1.PaintBoxViewMouseUp(Sender, Button, Shift, X, Y);
end;
procedure TPreviewForm.PaintBoxViewTopPaint(Sender: TObject);
begin
Form1.PaintBoxViewTopPaint(Sender);
end;
procedure TPreviewForm.FormActivate(Sender: TObject);
begin
globals.glneedrefresh := True;
end;
procedure TPreviewForm.FormResize(Sender: TObject);
begin
globals.glneedrefresh := True;
end;
procedure TPreviewForm.FormCanResize(Sender: TObject; var NewWidth,
NewHeight: Integer; var Resize: Boolean);
begin
globals.glneedrefresh := True;
end;
procedure TPreviewForm.PrevFrameButtonClick(Sender: TObject);
var
frm: integer;
begin
frm := FramesListBox.ItemIndex;
if frm < 0 then
frm := 0
else if frm = 0 then
frm := FramesListBox.Items.Count - 1
else
frm := frm - 1;
if frm >= FramesListBox.Items.Count then
frm := FramesListBox.Items.Count - 1
else if frm < 0 then
frm := 0;
FramesListBox.ItemIndex := frm;
UpdateFrameFromListBox;
end;
procedure TPreviewForm.NextFrameButtonClick(Sender: TObject);
var
frm: integer;
begin
frm := FramesListBox.ItemIndex;
if frm < 0 then
frm := 0
else if frm >= FramesListBox.Items.Count - 1 then
frm := 0
else
frm := frm + 1;
if frm >= FramesListBox.Items.Count then
frm := FramesListBox.Items.Count - 1
else if frm < 0 then
frm := 0;
FramesListBox.ItemIndex := frm;
UpdateFrameFromListBox;
end;
procedure TPreviewForm.FramesListBoxClick(Sender: TObject);
begin
UpdateFrameFromListBox;
end;
procedure TPreviewForm.PlayAnimationButtonClick(Sender: TObject);
begin
AnimationTimer.Enabled := True;
end;
procedure TPreviewForm.StopAnimationButtonClick(Sender: TObject);
begin
AnimationTimer.Enabled := False;
end;
procedure TPreviewForm.AnimationTimerTimer(Sender: TObject);
begin
NextFrameButtonClick(Sender);
end;
procedure TPreviewForm.TrackBar1Change(Sender: TObject);
begin
AnimationTimer.Interval := (10 + TrackBar1.Max - TrackBar1.Position) * 5;
end;
procedure TPreviewForm.UpdateFrameFromListBox;
begin
if globals.mdl.Frames.Count > 0 then
Form1.SetCurrentFrame(globals.mdl.Frames.Numbers[GetIntInRange(FramesListBox.ItemIndex, 0, globals.mdl.Frames.Count - 1)])
else
Form1.SetCurrentFrame(0);
end;
end.