-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainForm.pas
160 lines (145 loc) · 3.87 KB
/
MainForm.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
unit MainForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Menus, ComCtrls, StdCtrls, EushullyGame, Grids, ValEdit,
EushullyALF, EushullyFile, Eushullybin, GR32_Image, GR32, GR32_Resamplers,
EushullyAGF;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
Panel1: TPanel;
Panel3: TPanel;
StatusBar1: TStatusBar;
tv_files: TTreeView;
Label1: TLabel;
Panel2: TPanel;
Label2: TLabel;
m_log: TMemo;
N1: TMenuItem;
mm_open: TMenuItem;
OpenDialog1: TOpenDialog;
Splitter1: TSplitter;
Splitter2: TSplitter;
vleParams: TValueListEditor;
ImgView321: TImgView32;
PopupMenu1: TPopupMenu;
oo_extract: TMenuItem;
procedure mm_openClick(Sender: TObject);
procedure tv_filesClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure oo_extractClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
fGame: TEushullyGame;
fImage: TBitmap32;
procedure load(path: string);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
fImage := TBitmap32.Create;
ImgView321.Bitmap := fImage;
fGame := nil;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
if (fGame <> nil) then
fGame.Free;
end;
procedure TForm1.load(path: string);
begin
if (fGame <> nil) then
fGame.Free;
fGame := TEushullyGame.Create();
fGame.load(path);
Form1.Caption := 'AGEEditor: "' + fGame.Title + '"';
fGame.FS.MakeTree(tv_files, tv_files.Items.AddChild(nil, fGame.Title));
tv_files.Items.Item[0].data := fGame;
tv_files.SortType := stText
end;
procedure TForm1.mm_openClick(Sender: TObject);
begin
if (OpenDialog1.Execute()) then
begin
load(ExtractFilePath(OpenDialog1.FileName));
end;
end;
procedure TForm1.oo_extractClick(Sender: TObject);
var
i: integer;
f: TEushullyFile;
begin
if (tv_files.Selected = nil) then
Exit;
for i := 0 to tv_files.Items.Count - 1 do
if (tv_files.Items[i].Selected) and
(UInt32(tv_files.Items[i].data) < $100000) then
begin
f := fGame.FS.open(tv_files.Items[i].Text);
f.SaveToFile('.\' + tv_files.Items[i].Text);
f.Free;
end;
end;
procedure TForm1.tv_filesClick(Sender: TObject);
var
data: TObject;
i: integer;
alf: TEushullyALF;
f: TEushullyFile;
bmp: TEushullyAGF;
str: TMemoryStream;
begin
if (tv_files.Selected = nil) then
Exit;
data := TObject(tv_files.Selected.data);
vleParams.Strings.Clear;
if (UInt32(tv_files.Selected.data) < $100000) then
begin
// âûáðàí ôàéë
f := fGame.FS.open(tv_files.Selected.Text);
vleParams.Values['Ðàçìåð'] := IntToStr(f.Size);
if (TEushullyBIN.isFormat(f)) then
vleParams.Values['Òèï'] := 'Eushully Script File'
else if (TEushullyAGF.isFormat(f)) then
begin
bmp:=TEushullyAGF.Create;
bmp.load(f);
str:=bmp.toMemory();
str.Seek(0, soFromBeginning);
fImage.LoadFromStream(str);
ImgView321.Bitmap:=fImage;
str.Free;
bmp.Free;
end
else
vleParams.Values['Òèï'] := '-';
f.Free;
// ImgView321.
// fImage.lo
end
else if (data.ClassName = 'TEushullyALF') then
begin
// âûáðàí àðõèâ
alf := TEushullyALF(data);
vleParams.Values['Òèï'] := '-';
vleParams.Values['Çàãîëîâîê'] := alf.Title;
vleParams.Values['Ôàéëîâ'] := IntToStr(alf.FilesCount);
end
else if (data.ClassName = 'TEushullyGame') then
begin
// âûáðàíà èãðà
alf := fGame.FS.MainArchive;
for i := 0 to alf.SettingsCount - 1 do
begin
vleParams.Values[alf.SettingName[i]] := alf.Settings[i];
end;
end;
// vleParams.AutoSizeColumns();
end;
end.