Changeset 647


Ignore:
Timestamp:
Feb 19, 2025, 9:18:32 AM (3 days ago)
Author:
chronos
Message:
  • Modified: Detect data files usr/share/c-evo directory on Linux as relative directory to usr/bin directory.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Install/appimage/AppRun

    r645 r647  
    11#!/bin/bash
    2 exec $APPDIR/usr/share/c-evo/c-evo
     2exec $APPDIR/usr/bin/c-evo
  • trunk/Install/appimage/build.sh

    r645 r647  
    44mv ../../AI/StdAI/libstdai.so ../../AI/StdAI/libstdai-amd64.so
    55lazbuild --build-mode=Release ../../Integrated.lpi
    6 install -Dm755 ../../c-evo -t AppDir/usr/share/c-evo
    7 install -d AppDir/usr/bin
    8 ln -s $FLATPAK_DEST/share/c-evo/c-evo AppDir/usr/bin/c-evo
     6install -Dm755 ../../c-evo -t AppDir/usr/bin
    97install -Dm644 ../../Language.txt -t AppDir/usr/share/c-evo
    108install -Dm644 ../../Language2.txt -t AppDir/usr/share/c-evo
  • trunk/LocalPlayer/Help.pas

    r550 r647  
    19821982      if Category = hkInternet then
    19831983        case Index of
    1984           1: OpenDocument(HomeDir + AITemplateFileName);
     1984          1: OpenDocument(GetAppShareFile(AITemplateFileName));
    19851985          2: OpenURL(CevoHomepage);
    19861986          3: OpenURL(CevoContact);
  • trunk/LocalPlayer/TechTree.pas

    r622 r647  
    176176    Image := TBitmap.Create;
    177177    Image.PixelFormat := TPixelFormat.pf24bit;
    178     LoadGraphicFile(Image, HomeDir + 'Help' + DirectorySeparator + 'AdvTree.png',
     178    LoadGraphicFile(Image, GetAppShareFile('Help' + DirectorySeparator + 'AdvTree.png'),
    179179      [gfNoGamma]);
    180180
  • trunk/LocalPlayer/Term.pas

    r646 r647  
    13861386    if AILogo[P] = nil then
    13871387      AILogo[P] := TBitmap.Create;
    1388     if not LoadGraphicFile(AILogo[P], HomeDir + Name + '.png', [gfNoError]) then
     1388    if not LoadGraphicFile(AILogo[P], GetAppShareFile(Name + '.png'), [gfNoError]) then
    13891389    begin
    13901390      FreeAndNil(AILogo[P]);
  • trunk/Packages/CevoComponents/Directories.pas

    r447 r647  
    44
    55var
    6   HomeDir: string;
    76  DataDir: string;
    87  LocaleCode: string = '';
     
    1615function GetSoundsDir: string;
    1716function GetAiDir: string;
     17function GetAppShareDir(Dir: string): string;
     18function GetAppShareFile(FileName: string): string;
    1819
    1920
     
    2122
    2223uses
    23   FileUtil, LCLIntf, LCLType, LCLProc, LazUTF8, SysUtils;
     24  FileUtil, LCLIntf, LCLType, LCLProc, LazUTF8, SysUtils, LazFileUtils, Forms;
     25
     26function GetAppShareDir(Dir: string): string;
     27{$IFDEF UNIX}
     28var
     29  NewDir: string;
     30{$ENDIF}
     31begin
     32  Result := ExtractFileDir(Application.ExeName) + DirectorySeparator + Dir;
     33  {$IFDEF UNIX}
     34  // If installed in Linux system then try to use different installation directory
     35  if not DirectoryExists(Result) then begin
     36    NewDir := ExtractFileDir(Application.ExeName) + DirectorySeparator + '..' +
     37      DirectorySeparator + 'share' + DirectorySeparator +
     38      ExtractFileNameOnly(Application.ExeName) + DirectorySeparator + Dir;
     39    if DirectoryExists(NewDir) then Result := NewDir;
     40  end;
     41  {$ENDIF}
     42end;
     43
     44function GetAppShareFile(FileName: string): string;
     45{$IFDEF UNIX}
     46var
     47  NewFile: string;
     48{$ENDIF}
     49begin
     50  Result := ExtractFileDir(Application.ExeName) + DirectorySeparator + FileName;
     51  {$IFDEF UNIX}
     52  // If installed in Linux system then try to use different installation directory
     53  if not FileExists(Result) then begin
     54    NewFile := ExtractFileDir(Application.ExeName) + DirectorySeparator + '..' +
     55      DirectorySeparator + 'share' + DirectorySeparator +
     56      ExtractFileNameOnly(Application.ExeName) + DirectorySeparator + FileName;
     57    if FileExists(NewFile) then Result := NewFile;
     58  end;
     59  {$ENDIF}
     60end;
    2461
    2562function GetLocale: string;
     
    5794
    5895  if LocaleCode <> 'en' then begin
    59     Result := HomeDir + 'Localization' + DirectorySeparator + LocaleCodeDir + DirectorySeparator + Path;
     96    Result := GetAppShareFile('Localization' + DirectorySeparator + LocaleCodeDir + DirectorySeparator + Path);
    6097    if not DirectoryExists(Result) and not FileExists(Result) then
    61       Result := HomeDir + Path;
    62   end else Result := HomeDir + Path;
     98      Result := GetAppShareFile(Path);
     99  end else Result := GetAppShareFile(Path);
    63100end;
    64101
     
    92129begin
    93130  LocaleCode := '';
    94   HomeDir := ExtractFilePath(ParamStr(0));
    95131
    96132  AppDataDir := GetAppConfigDir(False);
    97   if AppDataDir = '' then DataDir := HomeDir
     133  if AppDataDir = '' then DataDir := GetAppShareDir('')
    98134  else begin
    99135    if not DirectoryExists(AppDataDir) then ForceDirectories(AppDataDir);
     
    105141function GetSavedDir(Home: Boolean = False): string;
    106142begin
    107   if Home then Result := HomeDir + 'Saved'
     143  if Home then Result := GetAppShareDir('Saved')
    108144    else Result := DataDir + 'Saved';
    109145end;
     
    111147function GetMapsDir(Home: Boolean = False): string;
    112148begin
    113   if Home then Result := HomeDir + 'Maps'
     149  if Home then Result := GetAppShareDir('Maps')
    114150    else Result := DataDir + 'Maps';
    115151end;
     
    117153function GetGraphicsDir: string;
    118154begin
    119   Result := HomeDir + 'Graphics';
     155  Result := GetAppShareDir('Graphics');
    120156end;
    121157
    122158function GetSoundsDir: string;
    123159begin
    124   Result := HomeDir + 'Sounds';
     160  Result := GetAppShareDir('Sounds');
    125161end;
    126162
    127163function GetAiDir: string;
    128164begin
    129   Result := HomeDir + 'AI';
     165  Result := GetAppShareDir('AI');
    130166end;
    131167
  • trunk/Packages/CevoComponents/ScreenTools.pas

    r608 r647  
    16091609    else
    16101610    begin
    1611       Phrases2.LoadFromFile(HomeDir + 'Language2.txt');
     1611      Phrases2.LoadFromFile(GetAppShareFile('Language2.txt'));
    16121612      Phrases2FallenBackToEnglish := True;
    16131613    end;
     
    16151615  else
    16161616  begin
    1617     Phrases.LoadFromFile(HomeDir + 'Language.txt');
    1618     Phrases2.LoadFromFile(HomeDir + 'Language2.txt');
     1617    Phrases.LoadFromFile(GetAppShareFile('Language.txt'));
     1618    Phrases2.LoadFromFile(GetAppShareFile('Language2.txt'));
    16191619  end;
    16201620
  • trunk/Start.pas

    r622 r647  
    235235
    236236  ActionsOffered := [maConfig, maManual, maCredits, maWeb];
    237   if FileExists(HomeDir + AITemplateFileName) then
     237  if FileExists(GetAppShareFile(AITemplateFileName)) then
    238238    Include(ActionsOffered, maAIDev);
    239239
     
    484484    for I := 1 to Languages.Count - 1 do
    485485    with Languages[I] do begin
    486       Available := DirectoryExists(HomeDir + 'Localization' + DirectorySeparator + Code) or (Code = 'en');
     486      Available := DirectoryExists(GetAppShareDir('Localization' + DirectorySeparator + Code)) or (Code = 'en');
    487487    end;
    488488  end;
     
    15171517      maManual: DirectHelp(cStartHelp);
    15181518      maCredits: DirectHelp(cStartCredits);
    1519       maAIDev: OpenDocument(HomeDir + AITemplateFileName);
     1519      maAIDev: OpenDocument(GetAppShareFile(AITemplateFileName));
    15201520      maWeb: OpenURL(CevoHomepage);
    15211521    end;
Note: See TracChangeset for help on using the changeset viewer.