Subversion Repositories autosfx

Rev

Blame | Last modification | View Log | RSS feed

  1. (******************************************************************)
  2. (* SFX for DelZip v1.8                                            *)
  3. (* Copyright 2002-2004, 2008                                      *)
  4. (*                                                                *)
  5. (* written by Markus Stephany                                     *)
  6. (* modified by Russell Peters, Roger Aelbrecht
  7.  Copyright (C) 2009, 2010  by Russell J. Peters, Roger Aelbrecht,
  8.       Eric W. Engler and Chris Vleghert.
  9.  
  10.    This file is part of TZipMaster Version 1.9.
  11.  
  12.     TZipMaster is free software: you can redistribute it and/or modify
  13.     it under the terms of the GNU Lesser General Public License as published by
  14.     the Free Software Foundation, either version 3 of the License, or
  15.     (at your option) any later version.
  16.  
  17.     TZipMaster is distributed in the hope that it will be useful,
  18.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20.     GNU Lesser General Public License for more details.
  21.  
  22.     You should have received a copy of the GNU Lesser General Public License
  23.     along with TZipMaster.  If not, see <http://www.gnu.org/licenses/>.
  24.  
  25.     contact: problems@delphizip.org (include ZipMaster in the subject).
  26.     updates: http://www.delphizip.org
  27.     DelphiZip maillist subscribe at http://www.freelists.org/list/delphizip
  28.  
  29.   modified 30-Jan-2008
  30. ---------------------------------------------------------------------------*)
  31. unit ZMSFXStrings19;
  32.  
  33. {
  34. this unit contains localized strings
  35.  
  36. }
  37.  
  38. interface
  39.  
  40. uses Windows;
  41.        
  42. const
  43.   SFX_LVC_Filename = 1;//1024;   // 'Filename';
  44.   SFX_LVC_Filesize = 2;//1025;   // 'Size';
  45.  
  46.   // error messages
  47.   SFX_Err_CannotCloseFile = 3;//1040;   // 'Cannot close ><';
  48.   SFX_Err_Archive = 5;//1041;           // 'Error reading archive ><';
  49.   SFX_Err_InvalidFileName = 6;//1042;   // 'Invalid filename.';
  50.   SFX_Err_Directory = 7;//1043;         // 'Error in directory ><';
  51.   SFX_Err_ZipUnknownComp = 8;//1044;    // 'Unknown compression type';
  52.   SFX_Err_ArchiveCorrupted = 9;//1045;  // 'Archive corrupted, please try to download this file again.';
  53.   SFX_Err_CannotOpenFile = 10;//1046;    // 'Cannot open ><';
  54.   SFX_Err_CannotWriteFile = 11;//1047;   // 'Cannot write to ><';
  55.   SFX_Err_Run_Run = 12;//1048;           // 'Couldn''t run >< ><';
  56.   SFX_Err_Run_Inst = 13;//1049;          // 'Couldn''t install >< ><';
  57.   SFX_Err_CRC32 = 14;//1050;             // 'CRC32 Error in ><';
  58. //  SFX_Err_BadFilename = 15;
  59.  
  60.   // messages
  61.   SFX_Msg_RunCheckBox_Run = 16;//1072;   // 'After extraction, run: >< ><';
  62.   SFX_Msg_RunCheckBox_Inst = 17;//1073;  // 'After extraction, install: >< ><';
  63.   SFX_Msg_FileExists = 18;//1074;        // '>< already exists, overwrite ?';
  64.   SFX_Msg_AllExtracted = 19;//1075;      // 'All files have been extracted.';
  65.   SFX_Msg_SelNotExtracted = 20;//1076;   // 'The selected file(s) couldn''t get extracted.';
  66.   SFX_Msg_SomeNotExtracted = 21;//1077;  // 'Some file(s) couldn''t get extracted.';
  67.   SFX_Msg_QueryCancel = 22;//1078;       // 'Do you want to cancel extraction?';
  68.   SFX_Msg_InsertDiskVolume = 23;//1079;  // 'Please insert disk volume >< in drive ><';
  69.  
  70.   // about text
  71. //  SFX_Msg_About = 1088;
  72.   SFX_MSG_ABOUT0 = 60;
  73.   SFX_MSG_ABOUT1 = 61;
  74.   SFX_MSG_AUTHORS = 62;//1089;//'The authors';
  75.   SFX_MSG_ABOUT2 = 63;
  76.   SFX_MSG_CREDITS = 64;//1090;//'Credits to';
  77.   SFX_MSG_ABOUT3 = 65;
  78.   SFX_MSG_TRANSLATION = 66;//1091;//' ';
  79.  
  80.   // message / dialog box titles
  81.   SFX_Cap_Err = 28;//1104;               // 'Error...';
  82.   SFX_Cap_App = 29;//1105;               // 'DelZip Self-Extractor';
  83.   SFX_Cap_Browse = 30;//1106;            // 'Please choose the destination directory';
  84.   SFX_Cap_About = 31;//1107;             // 'About DelZip Self-Extractor...';
  85.   SFX_Cap_Finished = 32;//1108;          // 'Finished.';
  86.   SFX_Cap_Password = 33;//1109;          // 'Enter password for ><:';
  87.   // Main Dialog buttons
  88.   SFX_Btn_Start = 34;//1120;     // 1
  89.   SFX_Btn_Close = 35;//1121;     // 2
  90.   SFX_Btn_About = 36;//1122;     // 103
  91.   SFX_Btn_Files = 37;//1123;     // 501
  92.   SFX_Btn_Existing = 38;//1124;  // 602
  93.   SFX_Btn_ShowFiles = 39;//1125; // 105
  94.   SFX_Btn_ExtractTo = 40;//1126; // 601
  95.   SFX_Btn_OvrAsk = 41;//1127;    // 703
  96.   SFX_Btn_OvrSkip = 42;//1128;   // 702
  97.   SFX_Btn_OvrAll = 43;//1129;    // 701
  98.   // FileExists Dialog
  99.   SFX_Btn_Yes = 44;//1136;       // 1
  100.   SFX_Btn_No = 46;//1137;        // 2
  101.   SFX_Btn_DontAsk = 47;//1138;   // 301
  102.   // Password Dialog
  103.   SFX_Btn_Ok = 48;//1152;        // 1
  104.   SFX_Btn_Cancel = 49;//1153;    // 2
  105.   // Dialog titles
  106.   SFX_Ttl_Main = 50;//1068;
  107.   SFX_Ttl_File = 51;//1069;
  108.   SFX_Ttl_PWrd = 52;//1070;
  109.   // Language Dialog
  110.   SFX_Btn_Select = 53;//1085;
  111.  
  112.  
  113. Var
  114.   VRec_DefStrings: PByte = nil;   // pointer to table of strings
  115.   VRec_Strings: PByte = nil;   // pointer to table of strings
  116.  
  117. const
  118.   MaxStringLen = MAX_PATH * 2;
  119.  
  120. procedure SetDlgStrings(Dlg: hWnd; val: cardinal);
  121. function SFXString(id: integer): string;            
  122.  
  123. function To_Str(CP: Integer; Source: pAnsiChar; len: integer; IsName: Boolean;
  124.     var Bad: boolean): string;
  125.  
  126. // table format - ident: byte, strng[]: byte, 0: byte; ...;0
  127. function LoadSFXStr(ptbl: pByte; ident: Byte): String;
  128.  
  129. implementation
  130.  
  131. uses
  132.   ZMSFXDefs19;
  133.  
  134. type
  135.   IdTbleRec2 = packed record
  136.     DlgId: byte;
  137.     Ctrl: word;
  138.     StrId: byte;
  139.   end;
  140.  
  141. const
  142.   SOFF = 0;//1024;
  143.   IdTbl1: array [0..22] of IdTbleRec2 = (
  144.     (DlgID: SFX_DLG_MAIN; Ctrl: 0; StrId: SFX_Ttl_Main - SOFF),
  145.     (DlgID: SFX_DLG_MAIN; Ctrl: 1; StrId: SFX_Btn_Start - SOFF),
  146.     (DlgID: SFX_DLG_MAIN; Ctrl: 2; StrId: SFX_Btn_Close - SOFF),
  147.     (DlgID: SFX_DLG_MAIN; Ctrl: 103; StrId: SFX_Btn_About - SOFF),
  148.     (DlgID: SFX_DLG_MAIN; Ctrl: 501; StrId: SFX_Btn_Files - SOFF),
  149.     (DlgID: SFX_DLG_MAIN; Ctrl: 602; StrId: SFX_Btn_Existing - SOFF),
  150.     (DlgID: SFX_DLG_MAIN; Ctrl: 601; StrId: SFX_Btn_ExtractTo - SOFF),
  151.     (DlgID: SFX_DLG_MAIN; Ctrl: 105; StrId: SFX_Btn_ShowFiles - SOFF),
  152.     (DlgID: SFX_DLG_MAIN; Ctrl: 703; StrId: SFX_Btn_OVRAsk - SOFF),
  153.     (DlgID: SFX_DLG_MAIN; Ctrl: 702; StrId: SFX_Btn_OVRSkip - SOFF),
  154.     (DlgID: SFX_DLG_MAIN; Ctrl: 701; StrId: SFX_Btn_OVRAll - SOFF),
  155.     (DlgID: SFX_DLG_FILE; Ctrl: 0; StrId: SFX_Ttl_File - SOFF),
  156.     (DlgID: SFX_DLG_FILE; Ctrl: 1; StrId: SFX_Btn_Yes - SOFF),
  157.     (DlgID: SFX_DLG_FILE; Ctrl: 2; StrId: SFX_Btn_No - SOFF),
  158.     (DlgID: SFX_DLG_FILE; Ctrl: 301; StrId: SFX_Btn_DontAsk - SOFF),
  159.     (DlgID: SFX_DLG_PWRD; Ctrl: 0; StrId: SFX_Ttl_PWrd - SOFF),
  160.     (DlgID: SFX_DLG_PWRD; Ctrl: 1; StrId: SFX_Btn_Ok - SOFF),
  161.     (DlgID: SFX_DLG_PWRD; Ctrl: 2; StrId: SFX_Btn_Cancel - SOFF),
  162.     (DlgID: SFX_DLG_LANG; Ctrl: 0; StrId: SFX_Ttl_Main - SOFF),
  163.     (DlgID: SFX_DLG_LANG; Ctrl: 1; StrId: SFX_Btn_Ok - SOFF),
  164.     (DlgID: SFX_DLG_LANG; Ctrl: 2; StrId: SFX_Btn_Close - SOFF),
  165.     (DlgID: SFX_DLG_LANG; Ctrl: ID_LANG_SELECT; StrId: SFX_Btn_Select - SOFF),
  166.     (DlgID: 0; Ctrl: 0; StrId: 0)
  167.     );
  168.  
  169. procedure SetDlgStrings(Dlg: hWnd; val: cardinal);
  170. var
  171.   d: cardinal;
  172.   i: cardinal;
  173.   s: string;
  174.   x: cardinal;
  175. begin
  176.   i := 0;
  177.   repeat
  178.     d := IdTbl1[i].DlgId;
  179.     if d = val then
  180.     begin
  181.       s := SFXString(IdTbl1[i].StrId + SOFF);
  182.       if s <> '' then
  183.       begin
  184.         x := IdTbl1[i].Ctrl;
  185.         if x = 0 then
  186.           SetWindowText(Dlg, pChar(s))
  187.         else
  188.           SetDlgItemText(Dlg, x, PChar(s));
  189.       end;
  190.     end;
  191.     Inc(i);
  192.   until (d = 0) or (d > val);
  193. end;
  194.  
  195. function StrHasExt(Source: pAnsiChar; len: integer): Boolean;
  196. var
  197.   c: AnsiChar;
  198.   i: integer;
  199. begin
  200.   Result := false;
  201.   if len < 0 then
  202.     len := 4096;
  203.   for i := 1 to Len do
  204.   begin
  205.     c := Source^;
  206.     if c = #0 then
  207.       break;
  208.     if (c > #126) {or (c < #31)} then
  209.     begin
  210.       Result := True;
  211.       break;
  212.     end;
  213.     inc(Source);
  214.   end;
  215. end;
  216.  
  217.  
  218. function To_Str(CP: Integer; Source: pAnsiChar; len: integer; IsName: Boolean;
  219.     var Bad: boolean): string;
  220. const
  221.   WC_NO_BEST_FIT_CHARS = $00000400; // do not use best fit chars
  222. var
  223. {$IFNDEF UNICODE}
  224.   buffer: array [0..(MaxStringLen + 3)] of widechar;
  225.   cnt:   integer;
  226.   flg: cardinal;
  227.   notsup: longBool;
  228. {$ENDIF}
  229.   wcnt:  integer;
  230. begin
  231.   Result := '';
  232.   Bad := false;   // hopefully
  233.   if Source^ = #0 then
  234.     exit;
  235. {$IFNDEF UNICODE}
  236.   if (CP = 0) and (len > 0) then
  237.   begin
  238.     SetLength(Result, len);
  239.     Move(Source^, PChar(Result)^, len);
  240.     exit;
  241.   end;
  242.   wcnt := MultiByteToWideChar(CP, 0, Source, len, nil, 0);
  243.   if (wcnt > 0) and (wcnt < MaxStringLen) then
  244.   begin
  245.     wcnt := MultiByteToWideChar(CP, 0, Source, len,
  246.       pWideChar(@buffer[0]), MaxStringLen);
  247.     if wcnt > 0 then
  248.     begin
  249.       buffer[wcnt] := #0;
  250.       if IsName then
  251.         flg := WC_NO_BEST_FIT_CHARS
  252.       else
  253.         flg := 0;
  254.       cnt := WideCharToMultiByte(0, flg, pWideChar(@buffer[0]),
  255.                wcnt + 1, nil, 0, nil, @notsup);
  256.       Bad := IsName and notsup;
  257.       if (cnt > 0) then
  258.       begin
  259.         SetLength(Result, cnt);
  260.         cnt := WideCharToMultiByte(0, flg, pWideChar(@buffer[0]),
  261.                 wcnt + 1, PAnsiChar(Result), cnt, nil, nil);
  262.         if cnt = 0 then
  263.           Bad := True
  264.         else
  265.           Result := PAnsiChar(Result);
  266.       end;
  267.     end;
  268.   end;
  269. {$ELSE}
  270.   wcnt := MultiByteToWideChar(CP, 0, Source, len, nil, 0);
  271.   if (wcnt > 0) then
  272.   begin
  273.     SetLength(Result, wcnt);
  274.     wcnt := MultiByteToWideChar(CP, 0, Source, len, PChar(Result), wcnt);
  275.     if (wcnt > 0) then
  276.       Result := PWideChar(Result);   // don't want end 0
  277.   end
  278.   else
  279.     Bad := True;
  280. {$ENDIF}
  281. end;
  282.  
  283.  
  284. // table format - ident: byte, strng[]: byte, 0: byte; ...;0
  285. function LoadSFXStr(ptbl: pByte; ident: Byte): String;
  286. var
  287.   bad: Boolean;
  288.   id: Byte;
  289. begin
  290.   Result := '';
  291.   if (ptbl = nil) or (ident = 0) then
  292.     exit;
  293.   id := ptbl^;
  294.   while (id <> 0) and (id <> ident) do
  295.   begin
  296.     while ptbl^ <> 0 do
  297.       inc(ptbl);
  298.     inc(ptbl);
  299.     id := ptbl^;
  300.   end;
  301.   if id = ident then
  302.   begin
  303.     inc(ptbl);
  304.     Result := To_Str(CP_UTF8, pAnsiChar(ptbl), -1, false, bad);
  305.   end;
  306. end;
  307.  
  308. function SFXString(id: integer): string;
  309. begin
  310.   Result := '';
  311.   if VRec_Strings <> nil then
  312.     Result := LoadSFXStr(VRec_Strings, id);
  313.   if Result = '' then
  314. //    Result := LoadSFXStr(@StrBlok, {true,} id);
  315.   begin
  316.     if VRec_DefStrings <> nil then
  317.       Result := LoadSFXStr(VRec_DefStrings, id)
  318.     else
  319.     begin
  320.       MessageBox(0, 'Missing resource!', 'DelphiZip SFX', MB_ICONSTOP or MB_TASKMODAL);
  321.       Halt(2);
  322.     end;
  323.   end;
  324. end;
  325.  
  326. end.
  327.