Changeset 310


Ignore:
Timestamp:
Aug 18, 2021, 4:02:44 PM (3 years ago)
Author:
chronos
Message:
  • Fixed: Use correct game data files directory on Linux.
  • Fixed: Copy Systems and Maps with with package.
  • Modified: Use fullscreen mode switching from Common package PersistentForm class.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.lfm

    r304 r310  
    1515  OnKeyUp = FormKeyUp
    1616  OnShow = FormShow
    17   LCLVersion = '2.0.2.0'
    18   WindowState = wsMaximized
     17  LCLVersion = '2.0.12.0'
    1918  object ToolBar1: TToolBar
    2019    Left = 0
     
    4645    end
    4746    object ToolButton5: TToolButton
    48       Left = 173
     47      Left = 171
    4948      Top = 2
    5049      Action = Core.ASettings
    5150    end
    5251    object ToolButton9: TToolButton
    53       Left = 167
     52      Left = 166
    5453      Height = 32
    5554      Top = 2
     
    5756    end
    5857    object ToolButton11: TToolButton
    59       Left = 103
     58      Left = 102
    6059      Top = 2
    6160      Action = Core.AGameLoad
    6261    end
    6362    object ToolButton12: TToolButton
    64       Left = 135
     63      Left = 134
    6564      Top = 2
    6665      Action = Core.AGameSave
    6766    end
    6867    object ToolButton13: TToolButton
    69       Left = 205
     68      Left = 203
    7069      Top = 2
    7170      Action = Core.AExit
     
    9089  object MainMenu1: TMainMenu
    9190    Images = Core.ImageListSmall
    92     left = 224
    93     top = 48
     91    Left = 224
     92    Top = 48
    9493    object MenuItem1: TMenuItem
    9594      Caption = 'Game'
     
    210209    Interval = 20
    211210    OnTimer = Timer1Timer
    212     left = 128
    213     top = 263
     211    Left = 128
     212    Top = 263
    214213  end
    215214  object ActionList1: TActionList
    216215    Images = Core.ImageListSmall
    217     left = 280
    218     top = 152
     216    Left = 280
     217    Top = 152
    219218    object AToolBarBigIcons: TAction
    220219      Caption = 'Toolbar big icons'
     
    239238  end
    240239  object PopupMenuToolbar: TPopupMenu
    241     left = 452
    242     top = 98
     240    Left = 452
     241    Top = 98
    243242    object MenuItem18: TMenuItem
    244243      Action = AToolBarBigIcons
  • trunk/Forms/UFormMain.pas

    r273 r310  
    9191    FormActivated: Boolean;
    9292    FormShown: Boolean;
     93    FullScreen: Boolean;
    9394    procedure ApplicationStart(Ptr: IntPtr);
    9495    procedure UpdateClientForms;
     
    284285    AUnitShapeVisible.Checked := Core.UnitShapeVisible;
    285286    Core.ScaleDPI;
    286     Core.PersistentForm.Load(Self, True);
     287    Core.PersistentForm.Load(Self);
     288    FullScreen := Core.PersistentForm.FormFullScreen;
    287289    Core.ThemeManager1.UseTheme(Self);
    288290    Core.Init;
  • trunk/Install/snap/snapcraft.yaml

    r309 r310  
    5252      install -d -m 755 $ROOT/usr/bin
    5353      install -s -m 755 xtactics $ROOT/usr/bin/xtactics
    54       install -d -m 755 $ROOT/usr/share/xtactics/languages
    55       install -m 755 Languages/xtactics.po $ROOT/usr/share/xtactics/languages
    56       install -m 755 Languages/xtactics.cs.po $ROOT/usr/share/xtactics/languages
     54      install -d -m 755 $ROOT/usr/share/xtactics/Languages
     55      install -m 755 Languages/xtactics.po $ROOT/usr/share/xtactics/Languages
     56      install -m 755 Languages/xtactics.cs.po $ROOT/usr/share/xtactics/Languages
     57      install -m 755 Languages/UFormAbout.po $ROOT/usr/share/xtactics/Languages
     58      install -m 755 Languages/UFormAbout.cs.po $ROOT/usr/share/xtactics/Languages
    5759      install -d -m 755 $ROOT/usr/share/applications
    5860      install -m 755 Install/snap/local/xtactics.desktop $ROOT/usr/share/applications
    5961      install -d -m 755 $ROOT/usr/share/pixmaps
    6062      install -m 755 Images/64x64/xtactics.png $ROOT/usr/share/pixmaps
     63      cp -r Systems $ROOT/usr/share/xtactics
     64      install -d -m 755 $ROOT/usr/share/xtactics/Images
     65      cp -r Images/Maps $ROOT/usr/share/xtactics/Images
    6166    stage:
    6267      #- etc
     
    107112      - desktop
    108113      - x11
    109       - opengl
    110114
    111115layout:
  • trunk/Packages/Common/UCommon.pas

    r308 r310  
    4040{$ENDIF}
    4141
    42 function IntToBin(Data: Int64; Count: Byte): string;
     42function AddLeadingZeroes(const aNumber, Length : integer) : string;
    4343function BinToInt(BinStr: string): Int64;
    44 function TryHexToInt(Data: string; var Value: Integer): Boolean;
    45 function TryBinToInt(Data: string; var Value: Integer): Boolean;
    4644function BinToHexString(Source: AnsiString): string;
    4745//function DelTree(DirName : string): Boolean;
     
    4947function BCDToInt(Value: Byte): Byte;
    5048function CompareByteArray(Data1, Data2: TArrayOfByte): Boolean;
     49procedure CopyStringArray(Dest: TStringArray; Source: array of string);
     50function CombinePaths(Path1, Path2: string): string;
     51function ComputerName: string;
     52procedure DeleteFiles(APath, AFileSpec: string);
     53procedure ExecuteProgram(Executable: string; Parameters: array of string);
     54procedure FileDialogUpdateFilterFileType(FileDialog: TOpenDialog);
     55procedure FreeThenNil(var Obj);
     56function GetDirCount(Dir: string): Integer;
    5157function GetUserName: string;
    52 function LoggedOnUserNameEx(Format: TUserNameFormat): string;
    53 function SplitString(var Text: string; Count: Word): string;
    5458function GetBitCount(Variable: QWord; MaxIndex: Integer): Integer;
    5559function GetBit(Variable: QWord; Index: Byte): Boolean;
     60function GetStringPart(var Text: string; Separator: string): string;
     61function GenerateNewName(OldName: string): string;
     62function GetFileFilterItemExt(Filter: string; Index: Integer): string;
     63function IntToBin(Data: Int64; Count: Byte): string;
     64function LastPos(const SubStr: String; const S: String): Integer;
     65function LoadFileToStr(const FileName: TFileName): AnsiString;
     66function LoggedOnUserNameEx(Format: TUserNameFormat): string;
     67function MergeArray(A, B: array of string): TArrayOfString;
     68function OccurenceOfChar(What: Char; Where: string): Integer;
     69procedure OpenWebPage(URL: string);
     70procedure OpenFileInShell(FileName: string);
     71function PosFromIndex(SubStr: string; Text: string;
     72  StartIndex: Integer): Integer;
     73function PosFromIndexReverse(SubStr: string; Text: string;
     74  StartIndex: Integer): Integer;
     75function RemoveQuotes(Text: string): string;
     76procedure SaveStringToFile(S, FileName: string);
    5677procedure SetBit(var Variable: Int64; Index: Byte; State: Boolean); overload;
    5778procedure SetBit(var Variable: QWord; Index: Byte; State: Boolean); overload;
    5879procedure SetBit(var Variable: Cardinal; Index: Byte; State: Boolean); overload;
    5980procedure SetBit(var Variable: Word; Index: Byte; State: Boolean); overload;
    60 function AddLeadingZeroes(const aNumber, Length : integer) : string;
    61 function LastPos(const SubStr: String; const S: String): Integer;
    62 function GenerateNewName(OldName: string): string;
    63 function GetFileFilterItemExt(Filter: string; Index: Integer): string;
    64 procedure FileDialogUpdateFilterFileType(FileDialog: TOpenDialog);
    65 procedure DeleteFiles(APath, AFileSpec: string);
    66 procedure OpenWebPage(URL: string);
    67 procedure OpenFileInShell(FileName: string);
    68 procedure ExecuteProgram(Executable: string; Parameters: array of string);
    69 procedure FreeThenNil(var Obj);
    70 function RemoveQuotes(Text: string): string;
    71 function ComputerName: string;
    72 function OccurenceOfChar(What: Char; Where: string): Integer;
    73 function GetDirCount(Dir: string): Integer;
    74 function MergeArray(A, B: array of string): TArrayOfString;
    75 function LoadFileToStr(const FileName: TFileName): AnsiString;
    76 procedure SaveStringToFile(S, FileName: string);
    7781procedure SearchFiles(AList: TStrings; Dir: string;
    7882  FilterMethod: TFilterMethod = nil; FileNameMethod: TFileNameMethod = nil);
    79 function GetStringPart(var Text: string; Separator: string): string;
     83function SplitString(var Text: string; Count: Word): string;
    8084function StripTags(const S: string): string;
    81 function PosFromIndex(SubStr: string; Text: string;
    82   StartIndex: Integer): Integer;
    83 function PosFromIndexReverse(SubStr: string; Text: string;
    84   StartIndex: Integer): Integer;
    85 procedure CopyStringArray(Dest: TStringArray; Source: array of string);
     85function TryHexToInt(Data: string; var Value: Integer): Boolean;
     86function TryBinToInt(Data: string; var Value: Integer): Boolean;
    8687
    8788
     
    669670end;
    670671
     672function CombinePaths(Path1, Path2: string): string;
     673begin
     674  Result := Path1;
     675  if Result <> '' then Result := Result + DirectorySeparator + Path2
     676    else Result := Path2;
     677end;
     678
    671679
    672680initialization
  • trunk/Packages/Common/UScaleDPI.pas

    r308 r310  
    227227    Temp[I] := TBitmap.Create;
    228228    Temp[I].SetSize(NewWidth, NewHeight);
     229    {$IFDEF Linux}
     230    Temp[I].PixelFormat := pf24bit;
     231    {$ELSE}
    229232    Temp[I].PixelFormat := pf32bit;
     233    {$ENDIF}
    230234    Temp[I].TransparentColor := TempBmp.TransparentColor;
    231235    //Temp[I].TransparentMode := TempBmp.TransparentMode;
  • trunk/UCore.pas

    r309 r310  
    1010  URegistry, ULastOpenedList, UTheme, UAboutDialog, Registry, Menus,
    1111  UFormClient, UPlayer, UGameServer, UGameClient, fgl, UServerList, UGameSystem,
    12   Graphics;
     12  Graphics, UUnit;
    1313
    1414type
     
    7575    FormNewTabIndex: Integer;
    7676    OldWindowState: TWindowState;
    77     InFullScreenMode: Boolean;
     77    FullScreen: Boolean;
     78    GameFilesDir: string;
    7879    procedure LoadRecentExecute(Sender: TObject);
    7980    procedure StartNewGame;
     
    9091    procedure FormClientActions;
    9192    procedure LoadGameSystems;
     93    procedure ToggleFullscreen;
    9294  public
    9395    Game: TGame;
     
    130132
    131133uses
    132   UFormMain, UFormNew, UFormSettings, UClientAI, UFormKeyShortcuts,
     134  UFormMain, UFormNew, UFormSettings, UClientAI, UFormKeyShortcuts, UCommon,
    133135  UFormHelp, UFormCharts, UFormUnitMoves, UFormPlayersStats, UClientGUI;
    134136
     
    303305procedure TCore.AFullscreenExecute(Sender: TObject);
    304306begin
    305   if InFullScreenMode then begin
    306     // Workaround: WindowState has sometimes wrong value under Linux.
    307     // Try to switch fullscreen again before switching back.
    308     if FormMain.WindowState <> wsFullScreen then begin
    309       FormMain.WindowState := wsFullScreen;
    310     end;
    311     {$IFDEF WINDOWS}
    312     FormMain.BorderStyle := bsSizeable;
    313     {$ENDIF}
    314     FormMain.WindowState := OldWindowState;
    315     InFullScreenMode := False;
    316   end else begin
    317     OldWindowState := FormMain.WindowState;
    318     {$IFDEF WINDOWS}
    319     FormMain.BorderStyle := bsNone;
    320     {$ENDIF}
    321     FormMain.WindowState := wsFullScreen;
    322     InFullScreenMode := True;
    323   end;
     307  ToggleFullscreen;
    324308end;
    325309
     
    402386  if FileExists(Game.FileName) then
    403387    Game.SaveToFile(Game.FileName)
    404     else AGameSave.Execute;
     388    else AGameSaveAs.Execute;
    405389end;
    406390
     
    476460procedure TCore.DataModuleCreate(Sender: TObject);
    477461const
    478   LinuxLanguagesDir = '/usr/share/xtactics/languages';
    479 begin
     462  LinuxGameFilesDir = '/usr/share/xtactics';
     463  LinuxLanguagesDir = LinuxGameFilesDir + '/Languages';
     464begin
     465  GameFilesDir := '';
    480466  {$IFDEF Linux}
     467  // If installed in Linux system then use installation shared game directory for data files
     468  if DirectoryExists(LinuxGameFilesDir) then
     469    GameFilesDir := LinuxGameFilesDir;
    481470  // If installed in Linux system then use installation directory for po files
    482471  if not DirectoryExists(CoolTranslator1.POFilesFolder) and DirectoryExists(LinuxLanguagesDir) then
     
    484473  {$ENDIF}
    485474 
    486     GameSystems := TGameSystems.Create;
     475  GameSystems := TGameSystems.Create;
    487476  Server := TServer.Create;
    488477  LocalClients := TClients.Create;
     
    494483  Game.OnNewTurn := GameNewTurnExecute;
    495484  Game.OnPlayerChange := DoPlayerChange;
     485  Game.MapImageFileName := CombinePaths(GameFilesDir, 'Images' + DirectorySeparator + 'Maps' + DirectorySeparator + 'WorldMap.png');
    496486  Server.Game := Game;
    497487  LocalClients.Game := Game;
     
    604594procedure TCore.LoadGameSystems;
    605595var
    606   NewItem: TGameSystem;
    607 begin
    608   if DirectoryExists('Systems') then begin
    609     GameSystems.LoadFromDir('Systems');
     596  NewGameSystem: TGameSystem;
     597  NewUnitKind: TUnitKind;
     598  SystemsDir: string;
     599begin
     600  if GameFilesDir <> '' then
     601    SystemsDir := GameFilesDir + DirectorySeparator + 'Systems'
     602    else SystemsDir := 'Systems';
     603  if DirectoryExists(SystemsDir) then begin
     604    GameSystems.LoadFromDir(SystemsDir);
    610605  end else begin
    611     NewItem := TGameSystem.Create;
    612     NewItem.FileName := 'Custom';
    613     GameSystems.Add(NewItem);
     606    // Create default game system if the directory with definitions was not found
     607    NewGameSystem := TGameSystem.Create;
     608    NewGameSystem.FileName := 'HexWars';
     609    NewUnitKind := TUnitKind.Create;
     610    NewUnitKind.Name := 'Unit';
     611    NewGameSystem.UnitKinds.Add(NewUnitKind);
     612    GameSystems.Add(NewGameSystem);
    614613  end;
    615614  if GameSystems.Count > 0 then begin
     
    617616    Game.GameSystem.Assign(GameSystems.First);
    618617  end;
     618end;
     619
     620procedure TCore.ToggleFullscreen;
     621begin
     622  FullScreen := not FullScreen;
     623  PersistentForm.Form := FormMain;
     624  PersistentForm.SetFullScreen(FullScreen);
     625  UpdateInterface;
    619626end;
    620627
  • trunk/UGame.pas

    r304 r310  
    860860
    861861  GeneratePlayers := True;
    862   MapImageFileName := 'Images/Maps/WorldMap.png';
     862  MapImageFileName := '';
    863863  Randomize;
    864864  StoredRandSeed := RandSeed;
Note: See TracChangeset for help on using the changeset viewer.