Changeset 375 for trunk/Core.pas
- Timestamp:
- Jan 3, 2025, 2:43:39 PM (5 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Core.pas
r372 r375 74 74 GameLoaded: Boolean; 75 75 FormNewTabIndex: Integer; 76 BaseDir: string; 76 MapImagesDir: string; 77 GameSystemsDir: string; 77 78 procedure LoadRecentExecute(Sender: TObject); 78 79 procedure StartNewGame; … … 135 136 const 136 137 DefaultRegKey = '\Software\Chronosoft\xTactics'; 138 AutoSaveFileName = 'AutoSave' + GameFileExt; 139 GameSystemsDirName = 'Systems'; 140 LanguagesDirName = 'Languages'; 141 MapImagesDirName = 'Images' + DirectorySeparator + 'Maps'; 142 DefaultGameSystemName = 'Default'; 137 143 138 144 resourcestring … … 293 299 AGameEnd.Enabled := Game.Running; 294 300 AFullscreen.Checked := FormMain.FullScreen; 295 {$ ifdefDEBUG}301 {$IFDEF DEBUG} 296 302 ATests.Visible := True; 297 303 ATests.Enabled := True; 298 {$ else}304 {$ELSE} 299 305 ATests.Visible := False; 300 306 ATests.Enabled := False; 301 {$ endif}307 {$ENDIF} 302 308 end; 303 309 … … 518 524 519 525 procedure TCore.DataModuleCreate(Sender: TObject); 526 var 527 BaseDir: string; 520 528 {$IFDEF UNIX} 521 529 const 522 LanguagesDir = 'Languages'; 523 LinuxBaseDir = '/usr/share/xtactics'; 524 LinuxLanguagesDir = LinuxBaseDir + DirectorySeparator + LanguagesDir; 525 LinuxBaseDir2 = '/app/share/xtactics'; 526 LinuxLanguagesDir2 = LinuxBaseDir2 + DirectorySeparator + LanguagesDir; 530 LinuxRelativeDir = '../share/xtactics'; 531 var 532 NewDir: string; 527 533 {$ENDIF} 528 534 begin 529 BaseDir := ExtractFilePath(ParamStr(0)); 530 Translator1.POFilesFolder := BaseDir + DirectorySeparator + LanguagesDir; 535 BaseDir := ExcludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0))); 536 GameSystemsDir := CombinePaths(BaseDir, GameSystemsDirName); 537 MapImagesDir := CombinePaths(BaseDir, MapImagesDirName); 538 Translator1.POFilesFolder := CombinePaths(BaseDir, LanguagesDirName); 531 539 532 540 {$IFDEF UNIX} 533 // If installed in Linux system then use installation shared game directory for data files 534 if not DirectoryExists(BaseDir) and DirectoryExists(LinuxBaseDir) then 535 BaseDir := LinuxBaseDir; 536 537 if not DirectoryExists(BaseDir) and DirectoryExists(LinuxBaseDir2) then 538 BaseDir := LinuxBaseDir2; 541 // If installed in Linux system then use installation shared game directory for game systems 542 if not DirectoryExists(GameSystemsDir) then begin 543 NewDir := ExpandFileName(BaseDir + DirectorySeparator + LinuxRelativeDir + 544 DirectorySeparator + GameSystemsDirName); 545 if DirectoryExists(NewDir) then GameSystemsDir := NewDir; 546 end; 547 548 // If installed in Linux system then use installation shared game directory for map images 549 if not DirectoryExists(GameSystemsDir) then begin 550 NewDir := ExpandFileName(BaseDir + DirectorySeparator + LinuxRelativeDir + 551 DirectorySeparator + MapImagesDirName); 552 if DirectoryExists(NewDir) then MapImagesDir := NewDir; 553 end; 539 554 540 555 // If installed in Linux system then use installation directory for po files 541 if not DirectoryExists(Translator1.POFilesFolder) and DirectoryExists(LinuxLanguagesDir) then 542 Translator1.POFilesFolder := LinuxLanguagesDir; 543 if not DirectoryExists(Translator1.POFilesFolder) and DirectoryExists(LinuxLanguagesDir2) then 544 Translator1.POFilesFolder := LinuxLanguagesDir2; 556 if not DirectoryExists(Translator1.POFilesFolder) then begin 557 NewDir := ExpandFileName(BaseDir + DirectorySeparator + LinuxRelativeDir + 558 DirectorySeparator + LanguagesDirName); 559 if DirectoryExists(NewDir) then Translator1.POFilesFolder := NewDir; 560 end; 545 561 {$ENDIF} 546 562 … … 555 571 Game.OnNewTurn := GameNewTurnExecute; 556 572 Game.OnPlayerChange := DoPlayerChange; 557 Game.MapImageFileName := CombinePaths(BaseDir, 'Images' + DirectorySeparator + 'Maps' + DirectorySeparator + 'WorldMap.png');573 Game.MapImageFileName := MapImagesDir + DirectorySeparator + 'WorldMap.png'; 558 574 Server.Game := Game; 559 575 LocalClients.Game := Game; … … 680 696 NewGameSystem: TGameSystem; 681 697 NewUnitKind: TUnitKind; 682 SystemsDir: string; 683 const 684 GameSystemsDirName = 'Systems'; 685 DefaultGameSystemName = 'Default'; 686 begin 687 if BaseDir <> '' then 688 SystemsDir := BaseDir + DirectorySeparator + GameSystemsDirName 689 else SystemsDir := ExpandFileName(GameSystemsDirName); 690 if DirectoryExists(SystemsDir) then begin 691 GameSystems.LoadFromDir(SystemsDir); 698 begin 699 if DirectoryExists(GameSystemsDir) then begin 700 GameSystems.LoadFromDir(GameSystemsDir); 692 701 end else begin 693 702 // Create default game system if the directory with definitions was not found … … 696 705 NewUnitKind := TUnitKind.Create; 697 706 NewUnitKind.Name := 'Unit'; 707 NewUnitKind.Moves := 1; 708 NewUnitKind.Power := 99; 698 709 NewGameSystem.UnitKinds.Add(NewUnitKind); 699 710 GameSystems.Add(NewGameSystem); … … 707 718 function TCore.GetAutoSaveFileName: string; 708 719 begin 709 Result := GetAppConfigDir(False) + 'AutoSave' + GameFileExt;720 Result := GetAppConfigDir(False) + AutoSaveFileName; 710 721 end; 711 722
Note:
See TracChangeset
for help on using the changeset viewer.