cdar
diff unit_Editor_as.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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/unit_Editor_as.pas Sun Dec 03 21:54:43 2006 +0100 1.3 @@ -0,0 +1,245 @@ 1.4 +unit unit_Editor_as; 1.5 + 1.6 +interface//#################################################################################### 1.7 + 1.8 +uses 1.9 + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 1.10 + Dialogs, ExtCtrls, StdCtrls, ExtDlgs; 1.11 + 1.12 +type 1.13 + Tform_Editor_as = class(TForm) 1.14 + gbx_AutorunIcon: TGroupBox; 1.15 + btn_BrowseIcon: TButton; 1.16 + tbx_IconPath: TEdit; 1.17 + img_Icon: TImage; 1.18 + gbx_ZielDir: TGroupBox; 1.19 + tbx_CDRootPath: TEdit; 1.20 + btn_BrowseCDRoot: TButton; 1.21 + lbl_1: TLabel; 1.22 + lbl_2: TLabel; 1.23 + lbl_3: TLabel; 1.24 + btn_cancel: TButton; 1.25 + btn_apply: TButton; 1.26 + btn_restore: TButton; 1.27 + img_IconCDAR: TImage; 1.28 + GroupBox1: TGroupBox; 1.29 + lbl_4: TLabel; 1.30 + lbl_5: TLabel; 1.31 + tbx_StartsFD: TEdit; 1.32 + tbx_Warnings: TMemo; 1.33 + OpenDialog1: TOpenPictureDialog; 1.34 + procedure FormCreate(Sender: TObject); 1.35 + procedure FormClose(Sender: TObject; var Action: TCloseAction); 1.36 + procedure FormShow(Sender: TObject); 1.37 + procedure btn_BrowseIconClick(Sender: TObject); 1.38 + procedure btn_BrowseCDRootClick(Sender: TObject); 1.39 + procedure btn_restoreClick(Sender: TObject); 1.40 + procedure btn_applyClick(Sender: TObject); 1.41 + procedure btn_cancelClick(Sender: TObject); 1.42 + procedure tbx_StartsFDChange(Sender: TObject); 1.43 + procedure tbx_CDRootPathChange(Sender: TObject); 1.44 + private 1.45 + 1.46 + public 1.47 + { Public declarations } 1.48 + end; 1.49 + 1.50 +var 1.51 + form_Editor_as: Tform_Editor_as; 1.52 + 1.53 +implementation//############################################################################### 1.54 +uses unit_Editor, unit_Editor_as_BrowseDir; 1.55 +{$R *.dfm}//################################################################################### 1.56 + 1.57 +// forwardings 1.58 + procedure Warnings();forward; 1.59 + 1.60 +//------------------------------------------------------------------------------ form create 1.61 +procedure Tform_Editor_as.FormCreate(Sender: TObject); 1.62 +begin 1.63 + // set language 1.64 + if form_editor.englisch = true then 1.65 + begin // English 1.66 + form_editor_as.Caption := 'Autorun Settings'; 1.67 + btn_BrowseIcon.Caption := 'Browse'; 1.68 + btn_BrowseCDRoot.Caption := 'Browse'; 1.69 + lbl_1.Caption := 'Autorun-Icon of the CD'; 1.70 + lbl_2.Caption := 'Directory where the Files will be copied to'; 1.71 + lbl_3.Caption := '(This Directory represents the Root-Dir of the CD)'; 1.72 + btn_cancel.Caption := 'Cancel Changes'; 1.73 + btn_apply.Caption := 'Apply Changes'; 1.74 + btn_restore.Caption := 'CDAR-Icon'; 1.75 + lbl_4.Caption := 'Choose the File which will be started by CDAR'; 1.76 + lbl_5.Caption := '(Insert a Path relative to the CD-Root-Dir!)'; 1.77 + end 1.78 + else 1.79 + begin // German 1.80 + form_editor_as.Caption := 'Autorun Optionen'; 1.81 + btn_BrowseIcon.Caption := 'Durchsuchen'; 1.82 + btn_BrowseCDRoot.Caption := 'Durchsuchen'; 1.83 + lbl_1.Caption := 'Autorun-Icon der CD'; 1.84 + lbl_2.Caption := 'Ordner in den die Dateien kopiert werden'; 1.85 + lbl_3.Caption := '(Entspricht dem CD-Grund-Verzeichnis)'; 1.86 + btn_cancel.Caption := 'Abbrechen'; 1.87 + btn_apply.Caption := 'Übernehmen'; 1.88 + btn_restore.Caption := 'CDAR-Icon'; 1.89 + lbl_4.Caption := 'Datei, die von CDAR gestartet werden soll'; 1.90 + lbl_5.Caption := '(Pfad relativ zum CD-Grund-Verzeichnis)'; 1.91 + end; 1.92 + 1.93 + // set standard path in OpenDialog 1.94 + opendialog1.InitialDir := extractfilepath(paramstr(0)); 1.95 +end;//-------------------------------------------------------------------------- 1.96 +//------------------------------------------------------------------------------ form show 1.97 +procedure Tform_Editor_as.FormShow(Sender: TObject); 1.98 +begin 1.99 + // disable drag'n'drop 1.100 + form_editor.draggingstatus := 3; 1.101 + // disable menu 1.102 + form_editor.mnu_Tutorial.enabled := false; 1.103 + form_editor.mnu_WelcomeScreen.Enabled := false; 1.104 + form_editor.mnu_Autorun.Enabled := false; 1.105 + form_editor.mnu_CreateAR.enabled := false; 1.106 + form_editor.mnu_Sprache.enabled := false; 1.107 + 1.108 + // init 1.109 + tbx_IconPath.text := form_Editor.PfadIcon_alt; 1.110 + if form_Editor.PfadIcon_alt = '' then 1.111 + begin 1.112 + img_IconCDAR.show; 1.113 + img_icon.Hide; 1.114 + end 1.115 + else 1.116 + begin 1.117 + img_IconCDAR.hide; 1.118 + img_Icon.Show; 1.119 + img_icon.Picture.LoadFromFile(form_Editor.PfadIcon_alt); 1.120 + end; 1.121 + tbx_CDRootPath.text := form_Editor.CDRoot_alt; 1.122 + tbx_StartsFD.Text := form_Editor.StartsFD_alt; 1.123 +end;//-------------------------------------------------------------------------- 1.124 +//------------------------------------------------------------------------------ form close 1.125 +procedure Tform_Editor_as.FormClose(Sender: TObject; 1.126 + var Action: TCloseAction); 1.127 +begin 1.128 + // enable drag'n'drop 1.129 + form_editor.draggingstatus := 0; 1.130 + // enable menu 1.131 + form_editor.mnu_Tutorial.enabled := true; 1.132 + form_editor.mnu_WelcomeScreen.Enabled := true; 1.133 + form_editor.mnu_Autorun.Enabled := true; 1.134 + form_editor.mnu_CreateAR.enabled := true; 1.135 + form_editor.mnu_Sprache.enabled := true; 1.136 +end;//-------------------------------------------------------------------------- 1.137 + 1.138 +//############################################################################################# 1.139 + 1.140 +//------------------------------------------------------------------------------ browse icon 1.141 +procedure Tform_Editor_as.btn_BrowseIconClick(Sender: TObject); 1.142 +begin 1.143 + if opendialog1.Execute then 1.144 + begin 1.145 + tbx_IconPath.Text := opendialog1.FileName; 1.146 + // load picture 1.147 + img_Icon.Picture.LoadFromFile(tbx_IconPath.text); 1.148 + // show picture 1.149 + img_IconCDAR.hide; 1.150 + img_Icon.Show; 1.151 + end; 1.152 +end;//-------------------------------------------------------------------------- 1.153 +//------------------------------------------------------------------------------ restore icon 1.154 +procedure Tform_Editor_as.btn_restoreClick(Sender: TObject); 1.155 +begin 1.156 + img_IconCDAR.show; 1.157 + img_icon.Hide; 1.158 + tbx_IconPath.Text := ''; 1.159 +end;//-------------------------------------------------------------------------- 1.160 + 1.161 +//------------------------------------------------------------------------------ browse CD-root 1.162 +procedure Tform_Editor_as.btn_BrowseCDRootClick(Sender: TObject); 1.163 +begin 1.164 + application.CreateForm(tform_editor_as_browsedir, form_editor_as_browsedir); 1.165 + form_editor_as_browsedir.show; 1.166 +end;//-------------------------------------------------------------------------- 1.167 + 1.168 +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1.169 + 1.170 +//------------------------------------------------------------------------------ change CD-root 1.171 +procedure Tform_Editor_as.tbx_CDRootPathChange(Sender: TObject); 1.172 +begin 1.173 + // format check 1.174 + Warnings; 1.175 +end;//-------------------------------------------------------------------------- 1.176 +//------------------------------------------------------------------------------ change startsFD 1.177 +procedure Tform_Editor_as.tbx_StartsFDChange(Sender: TObject); 1.178 +begin 1.179 + // format check 1.180 + Warnings; 1.181 +end;//-------------------------------------------------------------------------- 1.182 + 1.183 +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1.184 + 1.185 +//------------------------------------------------------------------------------ apply 1.186 +procedure Tform_Editor_as.btn_applyClick(Sender: TObject); 1.187 +begin 1.188 + form_Editor.PfadIcon_alt := tbx_IconPath.text; 1.189 + 1.190 + if copy(tbx_CDRootPath.text, length(tbx_CDRootpath.text), 1) <> '\' then 1.191 + begin 1.192 + form_Editor.CDRoot_alt := tbx_CDRootPath.Text + '\'; 1.193 + end 1.194 + else 1.195 + begin 1.196 + form_Editor.CDRoot_alt := tbx_CDRootPath.Text; 1.197 + end; 1.198 + 1.199 + form_Editor.StartsFD_alt := tbx_startsFD.text; 1.200 + 1.201 + // close 1.202 + form_editor_as.Close; 1.203 +end;//-------------------------------------------------------------------------- 1.204 +//------------------------------------------------------------------------------ cancel 1.205 +procedure Tform_Editor_as.btn_cancelClick(Sender: TObject); 1.206 +begin 1.207 + // close 1.208 + form_editor_as.Close; 1.209 +end;//-------------------------------------------------------------------------- 1.210 + 1.211 +//############################################################################################# 1.212 + 1.213 +//------------------------------------------------------------------------------ warnings 1.214 +procedure Warnings(); 1.215 +begin 1.216 + with form_Editor_as do 1.217 + begin 1.218 + tbx_Warnings.lines.clear; 1.219 + 1.220 + if copy(tbx_CDRootPath.text, 2, 2) <> ':\' then 1.221 + begin 1.222 + btn_apply.Enabled := false; 1.223 + tbx_Warnings.Show; 1.224 + tbx_Warnings.Lines.Add('2nd Path must be ABSOLUTE'); 1.225 + if pos(':', tbx_StartsFD.text) <> 0 then 1.226 + begin 1.227 + tbx_Warnings.Lines.Add('3rd Path must be RELATIVE'); 1.228 + end; 1.229 + end 1.230 + else 1.231 + begin 1.232 + if pos(':', tbx_StartsFD.text) <> 0 then 1.233 + begin 1.234 + btn_apply.Enabled := false; 1.235 + tbx_Warnings.Show; 1.236 + tbx_Warnings.Lines.Add('3rd Path must be RELATIVE'); 1.237 + end 1.238 + else 1.239 + begin 1.240 + btn_apply.Enabled := true; 1.241 + tbx_Warnings.hide; 1.242 + end; 1.243 + end; 1.244 + tbx_Warnings.Text := copy(tbx_Warnings.text, 1, length(tbx_Warnings.text)-2); 1.245 + end; 1.246 +end;//-------------------------------------------------------------------------- 1.247 + 1.248 +end.//#########################################################################################