cdar

view unit_Editor_CreateAR.pas @ 0:ef71164288c1

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