This repository was archived by the owner on Jan 23, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnit10.pas
More file actions
128 lines (115 loc) · 3.14 KB
/
Unit10.pas
File metadata and controls
128 lines (115 loc) · 3.14 KB
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
unit Unit10;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, ExtCtrls, Unit1, LevelEngine;
type
TPasteForm = class(TForm)
LabeledEdit1: TLabeledEdit;
SpeedButton1: TSpeedButton;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Bevel2: TBevel;
Label1: TLabel;
Apples: TCheckBox;
Label2: TLabel;
Bevel1: TBevel;
Killers: TCheckBox;
Flowers: TCheckBox;
Label3: TLabel;
Bevel3: TBevel;
Label4: TLabel;
Bevel4: TBevel;
NPolygons: TCheckBox;
GPolygons: TCheckBox;
NPictures: TCheckBox;
TPictures: TCheckBox;
OpenDialog1: TOpenDialog;
procedure FormDeactivate(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
function GetCoordinate(p:TRPoint):TRPoint;
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
PasteForm: TPasteForm;
implementation
{$R *.dfm}
procedure TPasteForm.FormDeactivate(Sender: TObject);
begin
ModalResult:=mrCancel;
Close;
end;
procedure TPasteForm.SpeedButton1Click(Sender: TObject);
begin
if OpenDialog1.Execute then LabeledEdit1.Text:=OpenDialog1.FileName;
end;
procedure TPasteForm.FormClose(Sender: TObject; var Action: TCloseAction);
var
pLevel:TLevel;
i,j:integer;
begin
if ModalResult<>mrOK then exit;
pLevel:=TLevel.Create(nil,0,0);
pLevel.Open(LabeledEdit1.Text);
//Select
with pLevel do begin
for i:=0 to High(Polygons) do with Polygons[i] do
for j:=0 to High(Vertices) do
Vertices[j].Selected:=true;
for i:=0 to High(Objects) do
Objects[i].Pos.Selected:=true;
for i:=0 to High(Pics) do
Pics[i].Pos.Selected:=true;
end;
//Add
Level.Modified:=true;
for i:=0 to High(pLevel.Objects) do
case pLevel.Objects[i].typ of
1: if Flowers.Checked then Level.AddObject(pLevel.Objects[i]);
2: if Apples.Checked then Level.AddObject(pLevel.Objects[i]);
3: if Killers.Checked then Level.AddObject(pLevel.Objects[i]);
end;
for i:=0 to High(pLevel.Pics) do
if pLevel.Pics[i].Name='' then begin
if NPictures.Checked then Level.AddPicture(pLevel.Pics[i]);
end else begin
if TPictures.Checked then Level.AddPicture(pLevel.Pics[i]);
end;
for i:=0 to High(pLevel.Polygons) do
case pLevel.Polygons[i].Grass of
0:if NPolygons.Checked then Level.AddPolygon(pLevel.Polygons[i]);
1:if GPolygons.Checked then Level.AddPolygon(pLevel.Polygons[i]);
end;
Level.CurrentLevel:=Level.CurrentLevel;
Level.SortPictures;
pLevel.Free;
end;
function TPasteForm.GetCoordinate(p: TRPoint): TRPoint;
begin
Result:=p;
end;
procedure TPasteForm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=VK_ESCAPE then begin
key:=0;
ModalResult:=mrCancel;
Close;
end;
if key=VK_RETURN then begin
key:=0;
BitBtn1.Click;
end;
end;
procedure TPasteForm.FormShow(Sender: TObject);
begin
OpenDialog1.InitialDir:=ExtractFileDir(LabeledEdit1.Text);
end;
end.