rev |
line source |
meillo@0
|
1 unit unit_Editor_CreateAR;
|
meillo@0
|
2
|
meillo@0
|
3 interface//####################################################################################
|
meillo@0
|
4
|
meillo@0
|
5 uses
|
meillo@0
|
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
meillo@0
|
7 Dialogs, StdCtrls, Grids, ValEdit, ShellApi;
|
meillo@0
|
8
|
meillo@0
|
9 type
|
meillo@0
|
10 Tform_editor_CreateAR = class(TForm)
|
meillo@0
|
11 btn_Finish: TButton;
|
meillo@0
|
12 btn_Back: TButton;
|
meillo@0
|
13 FinalSettings: TValueListEditor;
|
meillo@0
|
14 procedure FormCreate(Sender: TObject);
|
meillo@0
|
15 procedure FormShow(Sender: TObject);
|
meillo@0
|
16 procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
meillo@0
|
17 procedure btn_BackClick(Sender: TObject);
|
meillo@0
|
18 procedure btn_FinishClick(Sender: TObject);
|
meillo@0
|
19 private
|
meillo@0
|
20 { Private declarations }
|
meillo@0
|
21 public
|
meillo@0
|
22 { Public declarations }
|
meillo@0
|
23 end;
|
meillo@0
|
24
|
meillo@0
|
25 var
|
meillo@0
|
26 form_editor_CreateAR: Tform_editor_CreateAR;
|
meillo@0
|
27
|
meillo@0
|
28 implementation//###############################################################################
|
meillo@0
|
29 uses unit_Editor, unit_Editor_tutorial, unit_Start;
|
meillo@0
|
30 {$R *.dfm}//###################################################################################
|
meillo@0
|
31 {$I-}
|
meillo@0
|
32
|
meillo@0
|
33 //------------------------------------------------------------------------------ form create
|
meillo@0
|
34 procedure Tform_editor_CreateAR.FormCreate(Sender: TObject);
|
meillo@0
|
35 begin
|
meillo@0
|
36 //
|
meillo@0
|
37 form_Editor_CreateAR.Caption := 'Create your CD-Autorunner';
|
meillo@0
|
38 btn_Finish.Caption := 'Finish';
|
meillo@0
|
39 btn_Back.Caption := 'Back';
|
meillo@0
|
40 FinalSettings.TitleCaptions.Strings[0] := ' Settings';
|
meillo@0
|
41 FinalSettings.TitleCaptions.Strings[1] := ' Value';
|
meillo@0
|
42 FinalSettings.Keys[1] := 'Background-Picture';
|
meillo@0
|
43 FinalSettings.Keys[2] := 'Enter-Picture';
|
meillo@0
|
44 FinalSettings.Keys[3] := 'Autorun-Icon';
|
meillo@0
|
45 FinalSettings.Keys[4] := 'CD-Root-Dir';
|
meillo@0
|
46 FinalSettings.Keys[6] := 'Enter X-Position';
|
meillo@0
|
47 FinalSettings.Keys[7] := 'Enter Y-Position';
|
meillo@0
|
48 FinalSettings.Keys[8] := 'Welcome-Kind';
|
meillo@0
|
49 FinalSettings.Keys[9] := 'Delay';
|
meillo@0
|
50 FinalSettings.Keys[10] := 'Starts File/Dir';
|
meillo@0
|
51 end;//--------------------------------------------------------------------------
|
meillo@0
|
52 //------------------------------------------------------------------------------ form show
|
meillo@0
|
53 procedure Tform_editor_CreateAR.FormShow(Sender: TObject);
|
meillo@0
|
54 begin
|
meillo@0
|
55 // disable drag'n'drop of 'img_button'
|
meillo@0
|
56 form_editor.draggingstatus := 3;
|
meillo@0
|
57 // disable menu
|
meillo@0
|
58 form_editor.mnu_Tutorial.enabled := false;
|
meillo@0
|
59 form_editor.mnu_WelcomeScreen.Enabled := false;
|
meillo@0
|
60 form_editor.mnu_Autorun.Enabled := false;
|
meillo@0
|
61 form_editor.mnu_CreateAR.enabled := false;
|
meillo@0
|
62 form_editor.mnu_Sprache.enabled := false;
|
meillo@0
|
63
|
meillo@0
|
64 // show final settings
|
meillo@0
|
65 finalsettings.Values['Background-Picture'] := form_Editor.PfadHG_alt;
|
meillo@0
|
66 finalsettings.Values['Enter-Picture'] := form_Editor.PfadEnter_alt;
|
meillo@0
|
67 finalsettings.values['Autorun-Icon'] := form_Editor.PfadIcon_alt;
|
meillo@0
|
68 finalsettings.Values['CD-Root-Dir'] := form_Editor.CDRoot_alt;
|
meillo@0
|
69
|
meillo@0
|
70 finalsettings.Values['Enter X-Position'] := inttostr(form_Editor.xEnter_alt);
|
meillo@0
|
71 finalsettings.Values['Enter Y-Position'] := inttostr(form_Editor.yEnter_alt);
|
meillo@0
|
72 finalsettings.Values['Welcome-Kind'] := form_Editor.WelcomeKind_alt;
|
meillo@0
|
73 finalsettings.Values['Delay'] := form_Editor.delay;
|
meillo@0
|
74 finalsettings.Values['Starts File/Dir'] := form_Editor.StartsFD_alt;
|
meillo@0
|
75
|
meillo@0
|
76 // disable everything not needed
|
meillo@0
|
77 if form_Editor.WelcomeKind_alt = 'none' then
|
meillo@0
|
78 begin
|
meillo@0
|
79 finalsettings.Values['Background-Picture'] := '< not used / nicht genutzt >';
|
meillo@0
|
80 finalsettings.Values['Enter-Picture'] := '< not used / nicht genutzt >';
|
meillo@0
|
81 finalsettings.Values['Enter X-Position'] := '< not used / nicht genutzt >';
|
meillo@0
|
82 finalsettings.Values['Enter Y-Position'] := '< not used / nicht genutzt >';
|
meillo@0
|
83 finalsettings.Values['Delay'] := '< not used / nicht genutzt >';
|
meillo@0
|
84 end
|
meillo@0
|
85 else
|
meillo@0
|
86 begin
|
meillo@0
|
87 if form_Editor.WelcomeKind_alt = 'time' then
|
meillo@0
|
88 begin
|
meillo@0
|
89 finalsettings.Values['Enter-Picture'] := '< not used / nicht genutzt >';
|
meillo@0
|
90 finalsettings.Values['Enter X-Position'] := '< not used / nicht genutzt >';
|
meillo@0
|
91 finalsettings.Values['Enter Y-Position'] := '< not used / nicht genutzt >';
|
meillo@0
|
92 if form_Editor.PfadHG_alt = '' then
|
meillo@0
|
93 begin
|
meillo@0
|
94 finalsettings.Values['Background-Picture'] := '#### missing / fehlt ####';
|
meillo@0
|
95 btn_finish.Enabled := false;
|
meillo@0
|
96 end;
|
meillo@0
|
97 end
|
meillo@0
|
98 else // klick
|
meillo@0
|
99 begin
|
meillo@0
|
100 finalsettings.Values['Delay'] := '< not used / nicht genutzt >';
|
meillo@0
|
101 if form_Editor.PfadHG_alt = '' then
|
meillo@0
|
102 begin
|
meillo@0
|
103 // if the 'enter'-picture is full size, then dont use the 'background'-picture
|
meillo@0
|
104 if (form_editor.img_button.Width = form_editor.img_Background.Width) and
|
meillo@0
|
105 (form_editor.img_button.Height = form_editor.img_Background.Height) then
|
meillo@0
|
106 begin
|
meillo@0
|
107 finalsettings.Values['Background-Picture'] := '< not used / nicht genutzt >';
|
meillo@0
|
108 end
|
meillo@0
|
109 else
|
meillo@0
|
110 begin
|
meillo@0
|
111 finalsettings.Values['Background-Picture'] := '#### missing / fehlt ####';
|
meillo@0
|
112 btn_finish.Enabled := false;
|
meillo@0
|
113 end;
|
meillo@0
|
114 end;
|
meillo@0
|
115 if form_Editor.PfadEnter_alt = '' then
|
meillo@0
|
116 begin
|
meillo@0
|
117 finalsettings.Values['Enter-Picture'] := '#### missing / fehlt ####';
|
meillo@0
|
118 btn_finish.Enabled := false;
|
meillo@0
|
119 end;
|
meillo@0
|
120 end;
|
meillo@0
|
121 end;
|
meillo@0
|
122
|
meillo@0
|
123 //
|
meillo@0
|
124 if form_Editor.pfadIcon_alt = '' then
|
meillo@0
|
125 begin
|
meillo@0
|
126 finalsettings.values['Autorun-Icon'] := '(The banana / Die Banane)';
|
meillo@0
|
127 end;
|
meillo@0
|
128
|
meillo@0
|
129 //
|
meillo@0
|
130 if form_Editor.StartsFD_alt = '' then
|
meillo@0
|
131 begin
|
meillo@0
|
132 finalsettings.Values['Starts File/Dir'] := '(CD-Root-Dir / CD-Wurzelverzeichnis)';
|
meillo@0
|
133 end;
|
meillo@0
|
134 //
|
meillo@0
|
135 if form_Editor.StartsFD_alt = '-' then
|
meillo@0
|
136 begin
|
meillo@0
|
137 if form_Editor.WelcomeKind_alt = 'none' then
|
meillo@0
|
138 begin
|
meillo@0
|
139 finalsettings.Values['Starts File/Dir'] := '#### CDAR does not do anything! / CDAR macht gar nichts! ####';
|
meillo@0
|
140 btn_finish.Enabled := false;
|
meillo@0
|
141 end
|
meillo@0
|
142 else
|
meillo@0
|
143 begin
|
meillo@0
|
144 finalsettings.Values['Starts File/Dir'] := '(Just shows Welcome-Screen / Zeigt nur ein Willkommensbild)';
|
meillo@0
|
145 end;
|
meillo@0
|
146 end;
|
meillo@0
|
147
|
meillo@0
|
148 // use German if set so
|
meillo@0
|
149 if form_editor.englisch = false then
|
meillo@0
|
150 begin
|
meillo@0
|
151 form_Editor_CreateAR.Caption := 'Autorunner erstellen';
|
meillo@0
|
152 btn_Finish.Caption := 'Fertigstellen';
|
meillo@0
|
153 btn_Back.caption := 'Zurück';
|
meillo@0
|
154 FinalSettings.TitleCaptions.Strings[0] := ' Einstellung';
|
meillo@0
|
155 FinalSettings.TitleCaptions.Strings[1] := ' Wert';
|
meillo@0
|
156 FinalSettings.Keys[1] := 'Hintergrundbild';
|
meillo@0
|
157 FinalSettings.Keys[2] := 'Enterbild';
|
meillo@0
|
158 FinalSettings.Keys[3] := 'Autorun-Icon';
|
meillo@0
|
159 FinalSettings.Keys[4] := 'CD-Grundverzeichnis';
|
meillo@0
|
160 FinalSettings.Keys[6] := 'Enter X-Position';
|
meillo@0
|
161 FinalSettings.Keys[7] := 'Enter Y-Position';
|
meillo@0
|
162 FinalSettings.Keys[8] := 'Willkommensart';
|
meillo@0
|
163 FinalSettings.Keys[9] := 'Zeitverzögerung';
|
meillo@0
|
164 FinalSettings.Keys[10] := 'Startet Datei/Verz.';
|
meillo@0
|
165 end;
|
meillo@0
|
166 end;//--------------------------------------------------------------------------
|
meillo@0
|
167 //------------------------------------------------------------------------------ Form Close
|
meillo@0
|
168 procedure Tform_editor_CreateAR.FormClose(Sender: TObject;
|
meillo@0
|
169 var Action: TCloseAction);
|
meillo@0
|
170 begin
|
meillo@0
|
171 // enable drag'n'drop of 'img_button' again
|
meillo@0
|
172 form_editor.draggingstatus := 0;
|
meillo@0
|
173 // enable menu again
|
meillo@0
|
174 form_editor.mnu_Tutorial.enabled := true;
|
meillo@0
|
175 form_editor.mnu_WelcomeScreen.Enabled := true;
|
meillo@0
|
176 form_editor.mnu_Autorun.Enabled := true;
|
meillo@0
|
177 form_editor.mnu_CreateAR.enabled := true;
|
meillo@0
|
178 form_editor.mnu_Sprache.enabled := true;
|
meillo@0
|
179 end;//--------------------------------------------------------------------------
|
meillo@0
|
180
|
meillo@0
|
181 //#############################################################################################
|
meillo@0
|
182
|
meillo@0
|
183 //------------------------------------------------------------------------------ Click Back
|
meillo@0
|
184 procedure Tform_editor_CreateAR.btn_BackClick(Sender: TObject);
|
meillo@0
|
185 begin
|
meillo@0
|
186 // close CreateAR
|
meillo@0
|
187 form_editor_createar.Close;
|
meillo@0
|
188 end;//--------------------------------------------------------------------------
|
meillo@0
|
189 //------------------------------------------------------------------------------ Click Finish
|
meillo@0
|
190 procedure Tform_editor_CreateAR.btn_FinishClick(Sender: TObject);
|
meillo@0
|
191 var f : textfile;
|
meillo@0
|
192 i : integer;
|
meillo@0
|
193 CDRoot1 : string;
|
meillo@0
|
194 CDRoot2 : string;
|
meillo@0
|
195 begin
|
meillo@0
|
196 // create 'CDRoot' directory if not exists
|
meillo@0
|
197 cdRoot1 := form_Editor.CDRoot_alt;
|
meillo@0
|
198
|
meillo@0
|
199 if DirectoryExists(CDRoot1) = false then
|
meillo@0
|
200 begin
|
meillo@0
|
201 for i := 5 to length(CDRoot1) do
|
meillo@0
|
202 begin
|
meillo@0
|
203 if copy(CDRoot1, i, 1) = '\' then
|
meillo@0
|
204 begin
|
meillo@0
|
205 CDRoot2 := copy(CDRoot1, 1, i);
|
meillo@0
|
206 if DirectoryExists(CDRoot2) = false then
|
meillo@0
|
207 begin
|
meillo@0
|
208 mkdir(cdroot2);
|
meillo@0
|
209 end;
|
meillo@0
|
210 end;
|
meillo@0
|
211 end;
|
meillo@0
|
212 end;
|
meillo@0
|
213
|
meillo@0
|
214
|
meillo@0
|
215 // create Autorun.inf
|
meillo@0
|
216 try
|
meillo@0
|
217 AssignFile(f, form_Editor.CDRoot_alt + 'Autorun.inf');
|
meillo@0
|
218 ReWrite(f);
|
meillo@0
|
219 Writeln(f, '[Autorun]');
|
meillo@0
|
220 Writeln(f, 'Open= "_CDAR\cdar.exe welcome"');
|
meillo@0
|
221 if finalsettings.Cells[1,3] = '(The banana / Die Banane)' then
|
meillo@0
|
222 begin
|
meillo@0
|
223 Writeln(f, 'Icon= "_CDAR\cdar.exe"');
|
meillo@0
|
224 end
|
meillo@0
|
225 else
|
meillo@0
|
226 begin
|
meillo@0
|
227 Writeln(f, 'Icon= "_CDAR\Autorun.ico"');
|
meillo@0
|
228 end;
|
meillo@0
|
229 CloseFile(f);
|
meillo@0
|
230 except
|
meillo@0
|
231 showmessage('"Autorun.inf" konnte nicht erstellt werden'+ #10
|
meillo@0
|
232 +'Vermutlich ist der Pfad zum CD-Wurzelverzeichnis ungültig'+ #10
|
meillo@0
|
233 + #10
|
meillo@0
|
234 +'"Autorun.inf" could not be created'+ #10
|
meillo@0
|
235 +'probably the path to the CD root directory is corrupt');
|
meillo@0
|
236 end;
|
meillo@0
|
237
|
meillo@0
|
238 // create directory '_CDAR' if not exists
|
meillo@0
|
239 if DirectoryExists(CDRoot1 + '_CDAR') = false then
|
meillo@0
|
240 begin
|
meillo@0
|
241 mkdir(form_Editor.CDRoot_alt + '_CDAR\');
|
meillo@0
|
242 end;
|
meillo@0
|
243
|
meillo@0
|
244 // create 'cdar.ini'
|
meillo@0
|
245 try
|
meillo@0
|
246 AssignFile(f, form_Editor.CDRoot_alt + '_CDAR\cdar.ini');
|
meillo@0
|
247 ReWrite(f);
|
meillo@0
|
248 Writeln(f, form_Editor.WelcomeKind_alt);
|
meillo@0
|
249 Writeln(f, form_Editor.Delay);
|
meillo@0
|
250 Writeln(f, inttostr(form_Editor.xEnter_alt));
|
meillo@0
|
251 Writeln(f, inttostr(form_Editor.yEnter_alt));
|
meillo@0
|
252 Writeln(f, '..\' + form_Editor.StartsFD_alt);
|
meillo@0
|
253 CloseFile(f);
|
meillo@0
|
254 except
|
meillo@0
|
255 showmessage('"cdar.ini" konnte nicht erstellt werden'+ #10
|
meillo@0
|
256 +'Vermutlich ist der Pfad zum CD-Wurzelverzeichnis ungültig'+ #10
|
meillo@0
|
257 + #10
|
meillo@0
|
258 +'"cdar.ini" could not be created'+ #10
|
meillo@0
|
259 +'probably the path to the CD root directory is corrupt');
|
meillo@0
|
260 end;
|
meillo@0
|
261
|
meillo@0
|
262 // create 'cdar.bat'
|
meillo@0
|
263 try
|
meillo@0
|
264 AssignFile(f, 'C:\cdar.bat');
|
meillo@0
|
265 ReWrite(f);
|
meillo@0
|
266 Writeln(f, 'Rem This File was built by CD-Autorunner');
|
meillo@0
|
267 Writeln(f, 'Rem It is not needed anymore you can delete it');
|
meillo@0
|
268 Writeln(f, 'Rem');
|
meillo@0
|
269 Writeln(f, 'Rem Diese Datei wurde von CD-Autorunner erzeugt');
|
meillo@0
|
270 Writeln(f, 'Rem Sie wird nicht mehr gebraucht und kann geloescht werden');
|
meillo@0
|
271 Writeln(f, 'Rem ###############################################');
|
meillo@0
|
272 Writeln(f, 'Rem');
|
meillo@0
|
273 Writeln(f, 'Rem');
|
meillo@0
|
274 // copy 'Autorun.ico' if necessary
|
meillo@0
|
275 if finalsettings.Cells[1,3] <> '(The banana / Die Banane)' then
|
meillo@0
|
276 begin
|
meillo@0
|
277 Writeln(f, 'Copy %1 %2');
|
meillo@0
|
278 end;
|
meillo@0
|
279 // copy 'background'-picture if necessary
|
meillo@0
|
280 if finalsettings.Cells[1,1] <> '< not used / nicht genutzt >' then
|
meillo@0
|
281 begin
|
meillo@0
|
282 Writeln(f, 'Copy %3 %4');
|
meillo@0
|
283 end;
|
meillo@0
|
284 // copy 'enter'-picture if necessary
|
meillo@0
|
285 if finalsettings.Cells[1,2] <> '< not used / nicht genutzt >' then
|
meillo@0
|
286 begin
|
meillo@0
|
287 Writeln(f, 'Copy %5 %6');
|
meillo@0
|
288 end;
|
meillo@0
|
289 // copy 'cdar.exe'
|
meillo@0
|
290 Writeln(f, 'Copy %7 %8');
|
meillo@0
|
291 // self destruction
|
meillo@0
|
292 Writeln(f, 'del "C:\cdar.bat"');
|
meillo@0
|
293 // exit script
|
meillo@0
|
294 Writeln(f, 'exit');
|
meillo@0
|
295 // close file
|
meillo@0
|
296 CloseFile(f);
|
meillo@0
|
297 except
|
meillo@0
|
298 showmessage('"cdar.bat" konnte nicht erstellt werden'+ #10#10
|
meillo@0
|
299 +'"cdar.bat" could not be created');
|
meillo@0
|
300 end;
|
meillo@0
|
301
|
meillo@0
|
302 try
|
meillo@0
|
303 ShellExecute(application.Handle, 'open', pchar('C:\cdar.bat'),
|
meillo@0
|
304 pchar('"'
|
meillo@0
|
305 + form_Editor.PfadIcon_alt + '" "' + form_Editor.CDRoot_alt + '_CDAR\Autorun.ico" "'
|
meillo@0
|
306 + form_Editor.PfadHG_alt + '" "' + form_Editor.CDRoot_alt + '_CDAR\Welcome.jpg" "'
|
meillo@0
|
307 + form_Editor.PfadEnter_alt + '" "' + form_Editor.CDRoot_alt + '_CDAR\Enter.jpg" "'
|
meillo@0
|
308 + paramstr(0) + '" "' + form_Editor.CDRoot_alt + '_CDAR\cdar.exe"'
|
meillo@0
|
309 ), nil, sw_shownormal);
|
meillo@0
|
310 except
|
meillo@0
|
311 showmessage('"cdar.bat" konnte nicht ausgeführt werden'+ #10#10
|
meillo@0
|
312 +'was not able to run "cdar.bat"');
|
meillo@0
|
313 end;
|
meillo@0
|
314
|
meillo@0
|
315 // return to 'form_Editor'
|
meillo@0
|
316 form_editor_createar.Close;
|
meillo@0
|
317 end;//--------------------------------------------------------------------------
|
meillo@0
|
318
|
meillo@0
|
319 end.//#########################################################################################
|