Changeset 169
- Timestamp:
- Jun 15, 2019, 11:42:35 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GameServer.pas
r151 r169 556 556 s: string[255]; 557 557 begin 558 MapFile := TFileStream.Create( DataDir + 'Maps'+ DirectorySeparator + FileName,558 MapFile := TFileStream.Create(GetMapsDir + DirectorySeparator + FileName, 559 559 fmCreate or fmShareExclusive); 560 560 MapFile.Position := 0; … … 579 579 MapFile := nil; 580 580 try 581 MapFile := TFileStream.Create( DataDir + 'Maps'+ DirectorySeparator + FileName,581 MapFile := TFileStream.Create(GetMapsDir + DirectorySeparator + FileName, 582 582 fmOpenRead or fmShareExclusive); 583 583 MapFile.Position := 0; -
trunk/Packages/CevoComponents/Directories.pas
r113 r169 4 4 5 5 var 6 HomeDir, DataDir: string; 6 HomeDir: string; 7 DataDir: string; 7 8 LocaleCode: string = ''; 8 9 LocaleCodeAuto: string = ''; … … 10 11 function LocalizedFilePath(const Path: string): string; 11 12 procedure InitUnit; 13 function GetSavedDir(Home: Boolean = False): string; 14 function GetMapsDir(Home: Boolean = False): string; 12 15 13 16 … … 69 72 else 70 73 begin 71 if not DirectoryExists(AppDataDir) then 72 CreateDir(AppDataDir); 74 if not DirectoryExists(AppDataDir) then CreateDir(AppDataDir); 73 75 DataDir := AppDataDir; 74 76 end; 75 if not DirectoryExists(DataDir + 'Saved') then 76 CreateDir(DataDir + 'Saved'); 77 if not DirectoryExists(DataDir + 'Maps') then 78 CreateDir(DataDir + 'Maps'); 77 if not DirectoryExists(GetSavedDir) then CreateDir(GetSavedDir); 78 if not DirectoryExists(GetMapsDir) then CreateDir(GetMapsDir); 79 79 80 80 // Copy appdata if not done yet 81 if FindFirst( HomeDir + 'Saved'+ DirectorySeparator + '*.cevo', $21, src) = 0 then81 if FindFirst(GetSavedDir(True) + DirectorySeparator + '*.cevo', $21, src) = 0 then 82 82 repeat 83 if (FindFirst( DataDir + 'Saved'+ DirectorySeparator + src.Name, $21, dst) <> 0) or83 if (FindFirst(GetSavedDir(True) + DirectorySeparator + src.Name, $21, dst) <> 0) or 84 84 (dst.Time < src.Time) then 85 CopyFile(PChar( HomeDir + 'Saved'+ DirectorySeparator + src.Name),86 PChar( DataDir + 'Saved'+ DirectorySeparator + src.Name), false);85 CopyFile(PChar(GetSavedDir(True) + DirectorySeparator + src.Name), 86 PChar(GetSavedDir(True) + DirectorySeparator + src.Name), false); 87 87 FindClose(dst); 88 88 until FindNext(src) <> 0; … … 90 90 91 91 // Copy appdata if not done yet 92 if FindFirst( HomeDir + 'Maps'+ DirectorySeparator + '*.*', $21, src) = 0 then92 if FindFirst(GetMapsDir(True) + DirectorySeparator + '*.*', $21, src) = 0 then 93 93 repeat 94 if (FindFirst( DataDir + 'Maps'+ DirectorySeparator + src.Name, $21, dst) <> 0) or94 if (FindFirst(GetMapsDir(True) + DirectorySeparator + src.Name, $21, dst) <> 0) or 95 95 (dst.Time < src.Time) then 96 CopyFile(PChar( HomeDir + 'Maps'+ DirectorySeparator + src.Name),97 PChar( DataDir + 'Maps'+ DirectorySeparator + src.Name), false);96 CopyFile(PChar(GetMapsDir(True) + DirectorySeparator + src.Name), 97 PChar(GetMapsDir(True) + DirectorySeparator + src.Name), false); 98 98 FindClose(dst); 99 99 until FindNext(src) <> 0; … … 101 101 end; 102 102 103 function GetSavedDir(Home: Boolean = False): string; 104 begin 105 if Home then Result := HomeDir + 'Saved' 106 else Result := DataDir + 'Saved'; 107 end; 108 109 function GetMapsDir(Home: Boolean = False): string; 110 begin 111 if Home then Result := HomeDir + 'Maps' 112 else Result := DataDir + 'Maps'; 113 end; 114 103 115 end. -
trunk/Start.lfm
r124 r169 25 25 OnPaint = FormPaint 26 26 OnShow = FormShow 27 LCLVersion = ' 1.8.2.0'27 LCLVersion = '2.0.2.0' 28 28 object StartBtn: TButtonA 29 29 Tag = 15104 … … 199 199 TabOrder = 0 200 200 TabStop = False 201 TopIndex = -1 201 202 Visible = False 202 203 end -
trunk/Start.pas
r157 r169 72 72 procedure FormShow(Sender: TObject); 73 73 procedure FormHide(Sender: TObject); 74 procedure FormClose(Sender: TObject; var Action: TCloseAction); 74 75 procedure FormCreate(Sender: TObject); 75 76 procedure FormDestroy(Sender: TObject); 76 77 procedure BrainClick(Sender: TObject); 78 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 77 79 procedure FormMouseDown(Sender: TObject; Button: TMouseButton; 78 80 Shift: TShiftState; x, y: integer); 81 procedure FormMouseUp(Sender: TObject; Button: TMouseButton; 82 Shift: TShiftState; x, y: integer); 83 procedure FormMouseMove(Sender: TObject; Shift: TShiftState; x, y: integer); 79 84 procedure Up1BtnClick(Sender: TObject); 80 85 procedure Down1BtnClick(Sender: TObject); 81 procedure FormClose(Sender: TObject; var Action: TCloseAction);82 86 procedure ListClick(Sender: TObject); 83 87 procedure RenameBtnClick(Sender: TObject); … … 88 92 procedure Down2BtnClick(Sender: TObject); 89 93 procedure QuitBtnClick(Sender: TObject); 90 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);91 94 procedure CustomizeBtnClick(Sender: TObject); 92 95 procedure AutoDiffUpBtnClick(Sender: TObject); 93 96 procedure AutoDiffDownBtnClick(Sender: TObject); 94 procedure FormMouseUp(Sender: TObject; Button: TMouseButton;95 Shift: TShiftState; x, y: integer);96 procedure FormMouseMove(Sender: TObject; Shift: TShiftState; x, y: integer);97 97 procedure AutoEnemyUpBtnClick(Sender: TObject); 98 98 procedure AutoEnemyDownBtnClick(Sender: TObject); … … 926 926 begin // load 927 927 FileName := List.Items[List.ItemIndex]; 928 if LoadGame( DataDir + 'Saved'+ DirectorySeparator, FileName + CevoExt, LoadTurn, false)928 if LoadGame(GetSavedDir + DirectorySeparator, FileName + CevoExt, LoadTurn, false) 929 929 then 930 930 UnlistBackupFile(FileName) … … 1010 1010 end; 1011 1011 1012 StartNewGame( DataDir + 'Saved'+ DirectorySeparator, FileName + CevoExt, MapFileName,1012 StartNewGame(GetSavedDir + DirectorySeparator, FileName + CevoExt, MapFileName, 1013 1013 lxpre[WorldSize], lypre[WorldSize], StartLandMass, MaxTurn); 1014 1014 UnlistBackupFile(FileName); … … 1145 1145 pgLoad: 1146 1146 begin 1147 AssignFile(LogFile, DataDir + 'Saved'+ DirectorySeparator + List.Items[List.ItemIndex]1147 AssignFile(LogFile, GetSavedDir + DirectorySeparator + List.Items[List.ItemIndex] 1148 1148 + CevoExt); 1149 1149 try … … 1198 1198 if Page = pgEditMap then 1199 1199 MapFileName := List.Items[List.ItemIndex] + CevoMapExt; 1200 if LoadGraphicFile(Mini, DataDir + 'Maps'+ DirectorySeparator + Copy(MapFileName, 1,1200 if LoadGraphicFile(Mini, GetMapsDir + DirectorySeparator + Copy(MapFileName, 1, 1201 1201 Length(MapFileName) - 9) + '.png', gfNoError) then 1202 1202 begin … … 1215 1215 end; 1216 1216 1217 AssignFile(MapFile, DataDir + 'Maps'+ DirectorySeparator + MapFileName);1217 AssignFile(MapFile, GetMapsDir + DirectorySeparator + MapFileName); 1218 1218 try 1219 1219 Reset(MapFile, 4); … … 1395 1395 begin 1396 1396 FormerGames.Clear; 1397 if FindFirst( DataDir + 'Saved'+ DirectorySeparator + '*' + CevoExt, $21, F) = 0 then1397 if FindFirst(GetSavedDir + DirectorySeparator + '*' + CevoExt, $21, F) = 0 then 1398 1398 repeat 1399 1399 I := FormerGames.Count; … … 1415 1415 begin 1416 1416 Maps.Clear; 1417 if FindFirst( DataDir + 'Maps'+ DirectorySeparator + '*' + CevoMapExt, $21, f) = 0 then1417 if FindFirst(GetMapsDir + DirectorySeparator + '*' + CevoMapExt, $21, f) = 0 then 1418 1418 repeat 1419 1419 Maps.Add(Copy(f.Name, 1, Length(f.Name) - 9)); … … 1790 1790 end; 1791 1791 if Page = pgLoad then 1792 AssignFile(f, DataDir + 'Saved'+ DirectorySeparator + List.Items[List.ItemIndex] + CevoExt)1792 AssignFile(f, GetSavedDir + DirectorySeparator + List.Items[List.ItemIndex] + CevoExt) 1793 1793 else 1794 AssignFile(f, DataDir + 'Maps'+ DirectorySeparator + List.Items[List.ItemIndex] +1794 AssignFile(f, GetMapsDir + DirectorySeparator + List.Items[List.ItemIndex] + 1795 1795 CevoMapExt); 1796 1796 ok := true; 1797 1797 try 1798 1798 if Page = pgLoad then 1799 Rename(f, DataDir + 'Saved'+ DirectorySeparator + NewName + CevoExt)1799 Rename(f, GetSavedDir + DirectorySeparator + NewName + CevoExt) 1800 1800 else 1801 Rename(f, DataDir + 'Maps'+ DirectorySeparator + NewName + CevoMapExt);1801 Rename(f, GetMapsDir + DirectorySeparator + NewName + CevoMapExt); 1802 1802 except 1803 1803 // Play('INVALID'); … … 1806 1806 if Page <> pgLoad then 1807 1807 try // rename map picture 1808 AssignFile(f, DataDir + 'Maps'+ DirectorySeparator + List.Items[List.ItemIndex]1808 AssignFile(f, GetMapsDir + DirectorySeparator + List.Items[List.ItemIndex] 1809 1809 + '.png'); 1810 Rename(f, DataDir + 'Maps'+ DirectorySeparator + NewName + '.png');1810 Rename(f, GetMapsDir + DirectorySeparator + NewName + '.png'); 1811 1811 except 1812 1812 end; … … 1842 1842 begin 1843 1843 if Page = pgLoad then 1844 AssignFile(f, DataDir + 'Saved'+ DirectorySeparator + List.Items[List.ItemIndex] + CevoExt)1844 AssignFile(f, GetSavedDir + DirectorySeparator + List.Items[List.ItemIndex] + CevoExt) 1845 1845 else 1846 AssignFile(f, DataDir + 'Maps'+ DirectorySeparator + List.Items[List.ItemIndex] +1846 AssignFile(f, GetMapsDir + DirectorySeparator + List.Items[List.ItemIndex] + 1847 1847 CevoMapExt); 1848 1848 Erase(f); … … 2036 2036 procedure TStartDlg.ReplayBtnClick(Sender: TObject); 2037 2037 begin 2038 LoadGame( DataDir + 'Saved'+ DirectorySeparator, List.Items[List.ItemIndex] + CevoExt,2038 LoadGame(GetSavedDir + DirectorySeparator, List.Items[List.ItemIndex] + CevoExt, 2039 2039 LastTurn, True); 2040 2040 SlotAvailable := -1;
Note:
See TracChangeset
for help on using the changeset viewer.