Changeset 210 for branches/highdpi/Packages/CevoComponents/Directories.pas
- Timestamp:
- May 9, 2020, 4:02:07 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/Packages/CevoComponents/Directories.pas
r178 r210 4 4 5 5 var 6 HomeDir, DataDir: string; 6 HomeDir: string; 7 DataDir: string; 7 8 LocaleCode: string = ''; 8 9 LocaleCodeAuto: string = ''; 9 10 10 11 function LocalizedFilePath(const Path: string): string; 11 procedure InitUnit; 12 procedure UnitInit; 13 function GetSavedDir(Home: Boolean = False): string; 14 function GetMapsDir(Home: Boolean = False): string; 15 function GetGraphicsDir: string; 16 function GetSoundsDir: string; 17 function GetAiDir: string; 12 18 13 19 … … 27 33 28 34 if Lang = '' then begin 29 30 31 35 for i := 1 to Paramcount - 1 do 36 if (ParamStrUTF8(i) = '--LANG') or (ParamStrUTF8(i) = '-l') or 37 (ParamStrUTF8(i) = '--lang') then 32 38 Lang := ParamStrUTF8(i + 1); 33 39 end; 34 40 if Lang = '' then begin 41 T := ''; 35 42 LazGetLanguageIDs(Lang, T); 36 43 Lang := Copy(Lang, 1, 2); … … 51 58 if LocaleCode <> 'en' then begin 52 59 Result := HomeDir + 'Localization' + DirectorySeparator + LocaleCodeDir + DirectorySeparator + Path; 53 if not FileExists(Result) then60 if not DirectoryExists(Result) and not FileExists(Result) then 54 61 Result := HomeDir + Path; 55 62 end else Result := HomeDir + Path; 56 63 end; 57 64 58 procedure InitUnit;65 procedure UnitInit; 59 66 var 60 67 AppDataDir: string; … … 69 76 else 70 77 begin 71 if not DirectoryExists(AppDataDir) then 72 CreateDir(AppDataDir); 78 if not DirectoryExists(AppDataDir) then CreateDir(AppDataDir); 73 79 DataDir := AppDataDir; 74 80 end; 75 if not DirectoryExists(DataDir + 'Saved') then 76 CreateDir(DataDir + 'Saved'); 77 if not DirectoryExists(DataDir + 'Maps') then 78 CreateDir(DataDir + 'Maps'); 81 if not DirectoryExists(GetSavedDir) then CreateDir(GetSavedDir); 82 if not DirectoryExists(GetMapsDir) then CreateDir(GetMapsDir); 79 83 80 84 // Copy appdata if not done yet 81 if FindFirst( HomeDir + 'Saved'+ DirectorySeparator + '*.cevo', $21, src) = 0 then85 if FindFirst(GetSavedDir(True) + DirectorySeparator + '*.cevo', $21, src) = 0 then 82 86 repeat 83 if (FindFirst( DataDir + 'Saved'+ DirectorySeparator + src.Name, $21, dst) <> 0) or87 if (FindFirst(GetSavedDir(True) + DirectorySeparator + src.Name, $21, dst) <> 0) or 84 88 (dst.Time < src.Time) then 85 CopyFile(PChar( HomeDir + 'Saved'+ DirectorySeparator + src.Name),86 PChar( DataDir + 'Saved'+ DirectorySeparator + src.Name), false);89 CopyFile(PChar(GetSavedDir(True) + DirectorySeparator + src.Name), 90 PChar(GetSavedDir(True) + DirectorySeparator + src.Name), false); 87 91 FindClose(dst); 88 92 until FindNext(src) <> 0; … … 90 94 91 95 // Copy appdata if not done yet 92 if FindFirst( HomeDir + 'Maps'+ DirectorySeparator + '*.*', $21, src) = 0 then96 if FindFirst(GetMapsDir(True) + DirectorySeparator + '*.*', $21, src) = 0 then 93 97 repeat 94 if (FindFirst( DataDir + 'Maps'+ DirectorySeparator + src.Name, $21, dst) <> 0) or98 if (FindFirst(GetMapsDir(True) + DirectorySeparator + src.Name, $21, dst) <> 0) or 95 99 (dst.Time < src.Time) then 96 CopyFile(PChar( HomeDir + 'Maps'+ DirectorySeparator + src.Name),97 PChar( DataDir + 'Maps'+ DirectorySeparator + src.Name), false);100 CopyFile(PChar(GetMapsDir(True) + DirectorySeparator + src.Name), 101 PChar(GetMapsDir(True) + DirectorySeparator + src.Name), false); 98 102 FindClose(dst); 99 103 until FindNext(src) <> 0; … … 101 105 end; 102 106 107 function GetSavedDir(Home: Boolean = False): string; 108 begin 109 if Home then Result := HomeDir + 'Saved' 110 else Result := DataDir + 'Saved'; 111 end; 112 113 function GetMapsDir(Home: Boolean = False): string; 114 begin 115 if Home then Result := HomeDir + 'Maps' 116 else Result := DataDir + 'Maps'; 117 end; 118 119 function GetGraphicsDir: string; 120 begin 121 Result := HomeDir + 'Graphics'; 122 end; 123 124 function GetSoundsDir: string; 125 begin 126 Result := HomeDir + 'Sounds'; 127 end; 128 129 function GetAiDir: string; 130 begin 131 Result := HomeDir + 'AI'; 132 end; 133 103 134 end.
Note:
See TracChangeset
for help on using the changeset viewer.