-
Notifications
You must be signed in to change notification settings - Fork 3
/
Main.pas
205 lines (190 loc) · 5.64 KB
/
Main.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
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, RzPrgres, jpeg, ExtCtrls, OleCtrls, SHDocVw, MSHTML, ShellApi, StdCtrls,
List32, Global, aebutton,
Fetcher,
CallBackes,
ConfigParser, PngImageList;
const
TH_MESSAGE = WM_USER + 1;
type
TMainFrm = class(TForm)
BG: TImage;
Nav: TWebBrowser;
ProgressBar: TRzProgressBar;
CancelBTN: TAEButton;
StartBTN: TAEButton;
ExitBTN: TAEButton;
Status: TLabel;
PngCollection: TPngImageCollection;
procedure StartBTNClick(Sender: TObject);
procedure CancelBTNClick(Sender: TObject);
procedure BGMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure BGMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure NavNavigateError(ASender: TObject; const pDisp: IDispatch;
var URL, Frame, StatusCode: OleVariant; var Cancel: WordBool);
procedure FormShow(Sender: TObject);
procedure NavNavigateComplete2(ASender: TObject; const pDisp: IDispatch;
var URL: OleVariant);
procedure NavDownloadComplete(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
procedure HandleMessage(var Message:TMessage); message TH_MESSAGE;
public
{ Public declarations }
end;
var
MainFrm: TMainFrm;
CriticalSection : TRTLCriticalSection;
dx, dy: integer;
ds : boolean = false;
implementation
uses
CRC32,
PListParser,
ace_lib,
Grf_Lib,fusion;
{$R *.dfm}
//------------------------------------------------------------------------------
procedure WB_SetBorderStyle(Sender: TObject; BorderStyle: string);
var
Document: IHTMLDocument2;
Element: IHTMLElement;
begin
Document := TWebBrowser(Sender).Document as IHTMLDocument2;
if Assigned(Document) then
begin
Element := Document.Body;
if Element <> nil then
begin
Element.Style.BorderStyle := BorderStyle;
end;
end;
end;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
procedure TMainFrm.FormCreate(Sender: TObject);
var
i : Integer;
begin
// SetWindowLong(application.handle, gwl_exstyle, ws_ex_toolwindow);
Nav.Hide; //Hide web broswer first, so we don't a white box
if (ParamStr(1) = '@idunno') and (ParamStr(2) <> '') then
begin
//I dont want to see you..
SetWindowLong(application.handle, gwl_exstyle, ws_ex_toolwindow);
Sleep(200);
for i:=1 to 10 do
if CopyFile(PChar(ParamStr(0)), PChar(ExtractFilePath(ParamStr(0)) + ParamStr(2)), False) then
break;
ShellExecute(Handle, 'open', PChar(ExtractFilePath(ParamStr(0)) + ParamStr(2)), '@ucu', nil, SW_SHOWNORMAL);
ds := True;
Application.Terminate;
end else
begin
if (ParamStr(1) = '@ucu') then begin
Sleep(200);
DeleteFile(ExtractFilePath(ParamStr(0)) + 'tmp.exe');
end;
Config := TConfig.Create;
ThreadList := TIntList32.Create;
PatchList := TPListParser.Create;
Ace := TAce.Create;
Grf := TGrf.Create;
Nav.Navigate(BASEURL + 'Notice.html');
end;
end;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
procedure TMainFrm.NavDownloadComplete(Sender: TObject);
begin
// Nav.Show; //Load complete? then show it!
end;
//------------------------------------------------------------------------------
procedure TMainFrm.NavNavigateComplete2(ASender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
begin
Nav.Show; //Load complete? then show it!
WB_SetBorderStyle(Nav, 'none');
end;
procedure TMainFrm.FormShow(Sender: TObject);
begin
if ds then Exit;
case Ace.LoadACE(AceFile) of //XD
//only success!
ACE_SUCCESS:
begin
AppFull := ParamStr(0);
AppPath := ExtractFilePath(ParamStr(0)); //i want keep at this spot XD
AppName := ExtractFilename(ParamStr(0));
MakeTable;
CurrentID := Ace.PatchVersion;
TFetcher.Create('main.txt', PMain, DownloadComplete);
end;
ACE_FILELOCKED: MainSwitch(SError, AceFile + ' is locked.');
ACE_INVALID: MainSwitch(SError, AceFile + ' is an invalid ACE file.');
ACE_UNIMPLEMENT_VERSION: MainSwitch(SError, 'Verion of ' + AceFile + ' is not supported');
end;
end;
procedure TMainFrm.NavNavigateError(ASender: TObject; const pDisp: IDispatch;
var URL, Frame, StatusCode: OleVariant; var Cancel: WordBool);
begin
Nav.Hide; //Error? HIDE!!
end;
procedure TMainFrm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
//var
// Idx : Integer;
// Thread : TThread;
begin
if not LockedDown then
begin
if assigned(Grf) then
Grf.Free;
if assigned(Ace) then
Ace.Free;
end else
CanClose := False;
// EnterCriticalSection(CriticalSection);
// for Idx := ThreadList.Count - 1 downto 0 do
// begin
// Thread := ThreadList.Objects[Idx] as TThread;
// Thread.Free;
// end;
// LeaveCriticalSection(CriticalSection);
// ThreadList.Free;
end;
procedure TMainFrm.BGMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
dx := X;
dy := y;
end;
procedure TMainFrm.BGMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if Shift = [ssleft] then begin
Left := Left + (X - dx);
Top := Top + (Y - dy);
end;
end;
procedure TMainFrm.CancelBTNClick(Sender: TObject);
begin
Close(); //just do it!
end;
procedure TMainFrm.HandleMessage(var Message:TMessage);
begin
Close;
end;
procedure TMainFrm.StartBTNClick(Sender: TObject);
begin
if CanStart then
begin
ShellExecute(Handle, 'open', PChar(AppPath + ClientFile), nil, PChar(AppPath), SW_SHOWNORMAL);
Close;
end;
end;
end.