Changeset 375


Ignore:
Timestamp:
Jan 3, 2025, 2:43:39 PM (3 days ago)
Author:
chronos
Message:
  • Fixed: Default generated game system was not playable as units were not able to move.
  • Fixed: Wrong game data directories detection.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Core.pas

    r372 r375  
    7474    GameLoaded: Boolean;
    7575    FormNewTabIndex: Integer;
    76     BaseDir: string;
     76    MapImagesDir: string;
     77    GameSystemsDir: string;
    7778    procedure LoadRecentExecute(Sender: TObject);
    7879    procedure StartNewGame;
     
    135136const
    136137  DefaultRegKey = '\Software\Chronosoft\xTactics';
     138  AutoSaveFileName = 'AutoSave' + GameFileExt;
     139  GameSystemsDirName = 'Systems';
     140  LanguagesDirName = 'Languages';
     141  MapImagesDirName = 'Images' + DirectorySeparator + 'Maps';
     142  DefaultGameSystemName = 'Default';
    137143
    138144resourcestring
     
    293299  AGameEnd.Enabled := Game.Running;
    294300  AFullscreen.Checked := FormMain.FullScreen;
    295   {$ifdef DEBUG}
     301  {$IFDEF DEBUG}
    296302  ATests.Visible := True;
    297303  ATests.Enabled := True;
    298   {$else}
     304  {$ELSE}
    299305  ATests.Visible := False;
    300306  ATests.Enabled := False;
    301   {$endif}
     307  {$ENDIF}
    302308end;
    303309
     
    518524
    519525procedure TCore.DataModuleCreate(Sender: TObject);
     526var
     527  BaseDir: string;
    520528{$IFDEF UNIX}
    521529const
    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';
     531var
     532  NewDir: string;
    527533{$ENDIF}
    528534begin
    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);
    531539
    532540  {$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;
    539554
    540555  // 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;
    545561  {$ENDIF}
    546562
     
    555571  Game.OnNewTurn := GameNewTurnExecute;
    556572  Game.OnPlayerChange := DoPlayerChange;
    557   Game.MapImageFileName := CombinePaths(BaseDir, 'Images' + DirectorySeparator + 'Maps' + DirectorySeparator + 'WorldMap.png');
     573  Game.MapImageFileName := MapImagesDir + DirectorySeparator + 'WorldMap.png';
    558574  Server.Game := Game;
    559575  LocalClients.Game := Game;
     
    680696  NewGameSystem: TGameSystem;
    681697  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);
     698begin
     699  if DirectoryExists(GameSystemsDir) then begin
     700    GameSystems.LoadFromDir(GameSystemsDir);
    692701  end else begin
    693702    // Create default game system if the directory with definitions was not found
     
    696705    NewUnitKind := TUnitKind.Create;
    697706    NewUnitKind.Name := 'Unit';
     707    NewUnitKind.Moves := 1;
     708    NewUnitKind.Power := 99;
    698709    NewGameSystem.UnitKinds.Add(NewUnitKind);
    699710    GameSystems.Add(NewGameSystem);
     
    707718function TCore.GetAutoSaveFileName: string;
    708719begin
    709   Result := GetAppConfigDir(False) + 'AutoSave' + GameFileExt;
     720  Result := GetAppConfigDir(False) + AutoSaveFileName;
    710721end;
    711722
  • trunk/Forms/FormClient.pas

    r333 r375  
    427427procedure TFormClient.FormCreate(Sender: TObject);
    428428begin
    429   {$IFDEF Linux}
     429  {$IFDEF UNIX}
    430430  //PaintBox1.ControlStyle := PaintBox1.ControlStyle + [csOpaque];
    431431  {$ENDIF}
  • trunk/Install/deb/debian/rules

    r372 r375  
    1414
    1515override_dh_auto_install:
    16         install -d -m 755 $(ROOT)/usr/bin
    17         install -s -m 755 xtactics $(ROOT)/usr/bin
    18         install -d -m 755 $(ROOT)/usr/share/xtactics/Languages
    19         install -m 644 Languages/*.po $(ROOT)/usr/share/xtactics/Languages
    20         install -m 644 Packages/Common/Languages/*.po $(ROOT)/usr/share/xtactics/Languages
    21         install -m 644 Packages/CoolStreaming/Languages/*.po $(ROOT)/usr/share/xtactics/Languages
    22         install -d -m 755 $(ROOT)/usr/share/xtactics/images/maps
    23         install -m 644 Images/Maps/Europe.png $(ROOT)/usr/share/xtactics/images/maps
    24         install -m 644 Images/Maps/WorldMap.png $(ROOT)/usr/share/xtactics/images/maps
    25         install -d -m 755 $(ROOT)/usr/share/applications
    26         install -m 644 Install/deb/xtactics.desktop $(ROOT)/usr/share/applications
    27         install -d -m 755 $(ROOT)/usr/share/mime/packages
    28         install -m 644 Install/deb/xtactics.xml $(ROOT)/usr/share/mime/packages
    29         install -d -m 755 $(ROOT)/usr/share/pixmaps
    30         install -m 644 Images/128x128/xtactics.png $(ROOT)/usr/share/pixmaps
    31         install -m 644 Images/128x128/xtactics.png $(ROOT)/usr/share/pixmaps/application-xtg.png
    32         install -m 644 Images/128x128/xtactics.png $(ROOT)/usr/share/pixmaps/application-xts.png
     16        install -Dm755 xtactics -t $(ROOT)/usr/bin
     17        install -Dm644 Languages/*.po -t $(ROOT)/usr/share/xtactics/Languages
     18        install -Dm644 Packages/Common/Languages/*.po -t $(ROOT)/usr/share/xtactics/Languages
     19        install -Dm644 Packages/CoolStreaming/Languages/*.po -t $(ROOT)/usr/share/xtactics/Languages
     20        install -Dm644 Images/Maps/*.png -t $(ROOT)/usr/share/xtactics/Images/Maps
     21        install -Dm644 Systems/*.xts -t $(ROOT)/usr/share/xtactics/Systems
     22        install -Dm644 Install/deb/xtactics.desktop -t $(ROOT)/usr/share/applications
     23        install -Dm644 Install/deb/xtactics.xml -t $(ROOT)/usr/share/mime/packages
     24        install -Dm644 Images/128x128/xtactics.png -t $(ROOT)/usr/share/pixmaps
     25        install -Dm644 Images/128x128/xtactics.png $(ROOT)/usr/share/pixmaps/application-xtg.png
     26        install -Dm644 Images/128x128/xtactics.png $(ROOT)/usr/share/pixmaps/application-xts.png
    3327
    3428%:
  • trunk/Install/flatpak/net.zdechov.app.xTactics.yml

    r374 r375  
    2727      - type: svn
    2828        url: https://svn.zdechov.net/xtactics/trunk
    29         revision: r374
     29        revision: r375
    3030    buildsystem: simple
    3131    build-commands:
     
    3434        lazbuild --build-mode=Release --ws=qt5 xtactics.lpi
    3535      - install -Dm755 xtactics -t $FLATPAK_DEST/bin
    36       - install -Dm644 Install/deb/xtactics.desktop -t $FLATPAK_DEST/share/applications
    37       - install -Dm644 Install/deb/xtactics.xml $FLATPAK_DEST/share/mime/packages/$FLAPTAK_ID.xml
    3836      - install -Dm644 Languages/*.po -t $FLATPAK_DEST/share/xtactics/Languages
    3937      - install -Dm644 Packages/Common/Languages/*.po -t $FLATPAK_DEST/share/xtactics/Languages
    4038      - install -Dm644 Packages/CoolStreaming/Languages/*.po -t $FLATPAK_DEST/share/xtactics/Languages
    41       - cp -r Systems $FLATPAK_DEST/share/xtactics
    42       - install -d -m 755 $FLATPAK_DEST/share/xtactics/Images
    43       - cp -r Images/Maps $FLATPAK_DEST/share/xtactics/Images
     39      - install -Dm644 Images/Maps/*.png -t $FLATPAK_DEST/share/xtactics/Images/Maps
     40      - install -Dm644 Systems/*.xts -t $FLATPAK_DEST/share/xtactics/Systems
     41      - install -Dm644 Install/deb/xtactics.desktop -t $FLATPAK_DEST/share/applications
     42      - install -Dm644 Install/deb/xtactics.xml $FLATPAK_DEST/share/mime/packages/$FLAPTAK_ID.xml
    4443      - install -Dm644 Images/128x128/xtactics.png -t $FLATPAK_DEST/share/icons/hicolor/128x128/apps
     44      - install -Dm644 Images/128x128/xtactics.png $FLATPAK_DEST/share/pixmaps/application-xtg.png
     45      - install -Dm644 Images/128x128/xtactics.png $FLATPAK_DEST/share/pixmaps/application-xts.png
    4546      - install -Dm644 Install/flatpak/${FLATPAK_ID}.metainfo.xml -t $FLATPAK_DEST/share/metainfo
  • trunk/Install/rpm/xtactics.spec

    r372 r375  
    2626%install
    2727rm -rf $RPM_BUILD_ROOT
    28 install -d -m 755 $RPM_BUILD_ROOT/usr/bin
    29 install -s -m 755 xtactics $RPM_BUILD_ROOT/usr/bin
     28install -Dm755 xtactics -t $RPM_BUILD_ROOT/usr/bin
    3029install -Dm644 Languages/*.po -t $RPM_BUILD_ROOT/usr/share/xtactics/Languages
    31 install -Dm644 Packages/Common/Languages/*.po -t $(ROOT)/usr/share/xtactics/Languages
    32 install -Dm644 Packages/CoolStreaming/Languages/*.po -t $(ROOT)/usr/share/xtactics/Languages
    33 install -d -m 755 $RPM_BUILD_ROOT/usr/share/xtactics/images/maps
    34 install -Dm644 Images/Maps/Europe.png -t $RPM_BUILD_ROOT/usr/share/xtactics/Images/Maps
    35 install -Dm644 Images/Maps/WorldMap.png -t $RPM_BUILD_ROOT/usr/share/xtactics/Images/Maps
     30install -Dm644 Packages/Common/Languages/*.po -t $RPM_BUILD_ROOT/usr/share/xtactics/Languages
     31install -Dm644 Packages/CoolStreaming/Languages/*.po -t $RPM_BUILD_ROOT/usr/share/xtactics/Languages
     32install -Dm644 Images/Maps/*.png -t $RPM_BUILD_ROOT/usr/share/xtactics/Images/Maps
     33install -Dm644 Systems/*.xts -t $RPM_BUILD_ROOT/usr/share/xtactics/Systems
    3634install -Dm644 Install/deb/xtactics.desktop -t $RPM_BUILD_ROOT/usr/share/applications
     35install -Dm644 Install/deb/xtactics.xml -t $RPM_BUILD_ROOT/usr/share/mime/packages
    3736install -Dm644 Images/128x128/xtactics.png -t $RPM_BUILD_ROOT/usr/share/pixmaps
     37install -Dm644 Images/128x128/xtactics.png $RPM_BUILD_ROOT/usr/share/pixmaps/application-xtg.png
     38install -Dm644 Images/128x128/xtactics.png $RPM_BUILD_ROOT/usr/share/pixmaps/application-xts.png
    3839
    3940%clean
  • trunk/Install/snap/snapcraft.yaml

    r372 r375  
    5050      snapcraftctl build
    5151      lazbuild --build-mode=Release xtactics.lpi
    52       install -d -m 755 $SNAPCRAFT_PART_INSTALL/usr/bin
    53       install -s -m 755 xtactics $SNAPCRAFT_PART_INSTALL/usr/bin/xtactics
    54       install -d -m 755 $SNAPCRAFT_PART_INSTALL/usr/share/xtactics/Languages
    55       install -Dm644 Languages/*.po $SNAPCRAFT_PART_INSTALL/usr/share/xtactics/Languages
    56       install -Dm644 Packages/Common/Languages/*.po $SNAPCRAFT_PART_INSTALL/usr/share/xtactics/Languages
    57       install -Dm644 Packages/CoolStreaming/Languages/*.po $SNAPCRAFT_PART_INSTALL/usr/share/xtactics/Languages
     52      install -Dm755 xtactics -t $SNAPCRAFT_PART_INSTALL/usr/bin/xtactics
     53      install -Dm644 Languages/*.po -t $SNAPCRAFT_PART_INSTALL/usr/share/xtactics/Languages
     54      install -Dm644 Packages/Common/Languages/*.po -t $SNAPCRAFT_PART_INSTALL/usr/share/xtactics/Languages
     55      install -Dm644 Packages/CoolStreaming/Languages/*.po -t $SNAPCRAFT_PART_INSTALL/usr/share/xtactics/Languages
     56      install -Dm644 Images/Maps/*.png -t $SNAPCRAFT_PART_INSTALL/usr/share/xtactics/Images/Maps
     57      install -Dm644 Systems/*.xts -t $SNAPCRAFT_PART_INSTALL/usr/share/xtactics/Systems
    5858      install -Dm644 Install/deb/xtactics.desktop -t $SNAPCRAFT_PART_INSTALL/usr/share/applications
    5959      install -Dm644 Install/deb/xtactics.xml -t $SNAPCRAFT_PART_INSTALL/usr/share/mime/packages
    6060      install -Dm644 Images/128x128/xtactics.png -t $SNAPCRAFT_PART_INSTALL/usr/share/pixmaps
    61       install -Dm644 Images/128x128/xtactics.png -t $SNAPCRAFT_PART_INSTALL/usr/share/pixmaps/application-xtg.png
    62       install -Dm644 Images/128x128/xtactics.png -t $SNAPCRAFT_PART_INSTALL/usr/share/pixmaps/application-xts.png
    63       cp -r Systems $SNAPCRAFT_PART_INSTALL/usr/share/xtactics
    64       install -d -m 755 $SNAPCRAFT_PART_INSTALL/usr/share/xtactics/Images
    65       cp -r Images/Maps $SNAPCRAFT_PART_INSTALL/usr/share/xtactics/Images
     61      install -Dm644 Images/128x128/xtactics.png $SNAPCRAFT_PART_INSTALL/usr/share/pixmaps/application-xtg.png
     62      install -Dm644 Images/128x128/xtactics.png $SNAPCRAFT_PART_INSTALL/usr/share/pixmaps/application-xts.png
    6663    after:
    6764    - desktop-gtk2
  • trunk/Units.pas

    r353 r375  
    169169  OldValue := TCell(FMapCell);
    170170  FMapCell := nil;
    171   if Assigned(OldValue) then TCell(OldValue).OneUnit := nil;
     171  if Assigned(OldValue) then OldValue.OneUnit := nil;
    172172  FMapCell := AValue;
    173173  if Assigned(FMapCell) then TCell(FMapCell).OneUnit := Self;
  • trunk/xtactics.lpi

    r374 r375  
    2626      <MinorVersionNr Value="4"/>
    2727    </VersionInfo>
    28     <MacroValues Count="1">
    29       <Macro1 Name="LCLWidgetType" Value="qt5"/>
    30     </MacroValues>
    3128    <BuildModes Count="2">
    3229      <Item1 Name="Debug" Default="True"/>
Note: See TracChangeset for help on using the changeset viewer.