Changeset 328


Ignore:
Timestamp:
Jul 19, 2024, 8:40:00 PM (4 months ago)
Author:
chronos
Message:
  • Fixed: Full screen switching on Windows.
  • Fixed: Main form was not visible on Windows task bar.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Core.lfm

    r317 r328  
    13151315    AppName = 'xTactics'
    13161316    Description = 'A turn-based strategy game inspired by classic Risk board game. The game is highly configurable to allow to adjust battle field and game rules.'
    1317     ReleaseDate = 44579
    1318     RegistryKey = '\Software\xTactics'
     1317    ReleaseDate = 45468
     1318    RegistryKey = '\Software\Chronosoft\xTactics'
    13191319    RegistryRoot = rrKeyCurrentUser
    13201320    License = 'CC0'
  • trunk/Core.pas

    r327 r328  
    77  Game, ApplicationInfo, PersistentForm, ScaleDPI, Translator, DOM,
    88  RegistryEx, LastOpenedList, Theme, Registry, Menus, FormCharts, FormMain,
    9   FormClient, Player, GameServer, GameClient, Generics.Collections,
    10   ServerList, GameSystem, Graphics, &Unit;
     9  FormClient, Player, GameServer, GameClient, ServerList, GameSystem, Graphics,
     10  &Unit;
    1111
    1212type
     
    486486
    487487procedure TCore.DataModuleCreate(Sender: TObject);
     488{$IFDEF Linux}
    488489const
    489490  LinuxGameFilesDir = '/usr/share/xtactics';
    490491  LinuxLanguagesDir = LinuxGameFilesDir + '/Languages';
     492{$ENDIF}
    491493begin
    492494  GameFilesDir := '';
     
    526528  TFormEx.PersistentForm := PersistentForm1;
    527529
    528   FormMain := TFormMain.Create(nil);
     530  Application.CreateForm(TFormMain, FormMain);
    529531  FormMain.Show;
    530532end;
     
    533535begin
    534536  FreeAndNil(ServerList);
    535   if Assigned(FormMain.FormPlayersStats) then FreeAndNil(FormMain.FormPlayersStats);
    536   if Assigned(FormMain.FormUnitMoves) then FreeAndNil(FormMain.FormUnitMoves);
    537   if Assigned(FormMain.FormCharts) then FreeAndNil(FormMain.FormCharts);
    538   if Assigned(FormMain.FormKeyShortcuts) then FreeAndNil(FormMain.FormKeyShortcuts);
    539537  FreeAndNil(FormClients);
    540538  FreeAndNil(StoredDimension);
     
    544542  FreeAndNil(GameSettings);
    545543  FreeAndNil(GameSystems);
    546   FreeAndNil(FormMain);
    547544end;
    548545
  • trunk/Forms/FormMain.pas

    r327 r328  
    9898    FormUnitMoves: TFormUnitMoves;
    9999    FormCharts: TFormCharts;
    100     FullScreen: Boolean;
    101100    procedure LoadConfig(Config: TXmlConfig; Path: string);
    102101    procedure SaveConfig(Config: TXmlConfig; Path: string);
     
    249248procedure TFormMain.FormDestroy(Sender: TObject);
    250249begin
     250  if Assigned(FormPlayersStats) then FreeAndNil(FormPlayersStats);
     251  if Assigned(FormUnitMoves) then FreeAndNil(FormUnitMoves);
     252  if Assigned(FormCharts) then FreeAndNil(FormCharts);
     253  if Assigned(FormKeyShortcuts) then FreeAndNil(FormKeyShortcuts);
    251254  FreeAndNil(FormClient);
    252255end;
  • trunk/Packages/Common/Common.pas

    r315 r328  
    5353function ComputerName: string;
    5454procedure DeleteFiles(APath, AFileSpec: string);
     55function EndsWith(Text, What: string): Boolean;
    5556function Explode(Separator: Char; Data: string): TStringArray;
    5657procedure ExecuteProgram(Executable: string; Parameters: array of string);
     
    8788procedure SearchFiles(AList: TStrings; Dir: string;
    8889  FilterMethod: TFilterMethod = nil; FileNameMethod: TFileNameMethod = nil);
     90procedure SortStrings(Strings: TStrings);
    8991function SplitString(var Text: string; Count: Word): string;
    9092function StripTags(const S: string): string;
     93function StartsWith(Text, What: string): Boolean;
    9194function TryHexToInt(Data: string; out Value: Integer): Boolean;
    9295function TryBinToInt(Data: string; out Value: Integer): Boolean;
    93 procedure SortStrings(Strings: TStrings);
    9496
    9597
    9698implementation
     99
     100function StartsWith(Text, What: string): Boolean;
     101begin
     102  Result := Copy(Text, 1, Length(Text)) = What;
     103end;
     104
     105function EndsWith(Text, What: string): Boolean;
     106begin
     107  Result := Copy(Text, Length(Text) - Length(What) + 1, MaxInt) = What;
     108end;
    97109
    98110function BinToInt(BinStr : string) : Int64;
  • trunk/Packages/Common/FormEx.pas

    r315 r328  
    1313  private
    1414    FCounter: Integer; static;
     15    FFirstShow: Boolean;
    1516  protected
    1617    procedure DoShow; override;
     
    1920    procedure DoDestroy; override;
    2021  public
     22    FullScreen: Boolean;
    2123    PersistentForm: TPersistentForm; static;
    2224    ThemeManager: TThemeManager; static;
     
    4446begin
    4547  inherited;
    46   PersistentForm.Load(Self);
     48  if not FFirstShow and (not (csDesigning in ComponentState)) then begin
     49    FFirstShow := True;
     50    PersistentForm.Load(Self);
     51    FullScreen := PersistentForm.FormFullScreen;
     52  end;
    4753end;
    4854
     
    7682procedure TFormEx.DoClose(var CloseAction: TCloseAction);
    7783begin
    78   PersistentForm.Save(Self);
     84  if  (not (csDesigning in ComponentState)) then begin
     85    PersistentForm.FormFullScreen := FullScreen;
     86    PersistentForm.Save(Self);
     87  end;
    7988  inherited;
    8089end;
  • trunk/Packages/Common/JobProgressView.pas

    r317 r328  
    339339  Caption := SPleaseWait + STerminate;
    340340end;
     341
    341342
    342343{ TJobProgressView }
  • trunk/Packages/Common/PersistentForm.pas

    r315 r328  
    1616    FMinVisiblePart: Integer;
    1717    FRegistryContext: TRegistryContext;
     18    FResizeEventOccured: Boolean;
    1819    procedure LoadControl(Control: TControl);
    1920    procedure SaveControl(Control: TControl);
     21    procedure WindowStateChange(Sender: TObject);
    2022  public
    2123    FormRestoredSize: TRect;
     
    301303
    302304procedure TPersistentForm.SetFullScreen(State: Boolean);
     305{$IFDEF UNIX}
     306var
     307  OldHandler: TNotifyEvent;
     308var
     309  I: Integer;
     310{$ENDIF}
    303311begin
    304312  if State then begin
     
    312320    end;
    313321    FormWindowState := Form.WindowState;
    314     Form.WindowState := wsMaximized;
    315     Form.WindowState := wsNormal;
    316     ShowWindow(Form.Handle, SW_SHOWFULLSCREEN);
    317322    {$IFDEF WINDOWS}
    318323    Form.BorderStyle := bsNone;
    319324    {$ENDIF}
     325    Form.WindowState := wsFullscreen;
     326    {$IFDEF UNIX}
     327    // Workaround on Linux, WindowState is rewriten by WMSize event to wsNormal.
     328    // We need for that even to occure
     329    OldHandler := Form.OnWindowStateChange;
     330    Form.OnWindowStateChange := WindowStateChange;
     331    FResizeEventOccured := False;
     332    for I := 0 to 10 do begin
     333      if FResizeEventOccured then Break;
     334      Application.ProcessMessages;
     335      Sleep(1);
     336    end;
     337    Form.OnWindowStateChange := OldHandler;
     338    {$ENDIF}
    320339  end else begin
    321340    FormFullScreen := False;
     341    Form.WindowState := wsNormal;
    322342    {$IFDEF WINDOWS}
    323343    Form.BorderStyle := bsSizeable;
    324344    {$ENDIF}
    325     ShowWindow(Form.Handle, SW_SHOWNORMAL);
    326345    if FormWindowState = wsNormal then begin
    327346      Form.WindowState := wsNormal;
     
    335354end;
    336355
     356procedure TPersistentForm.WindowStateChange(Sender: TObject);
     357begin
     358  Form.WindowState := wsFullscreen;
     359  FResizeEventOccured := True;
     360end;
     361
    337362end.
  • trunk/xtactics.lpr

    r317 r328  
    11program xtactics;
    2 
    3 {$mode objfpc}{$H+}
    42
    53uses
     
    86  {$ENDIF}
    97  Interfaces, // this includes the LCL widgetset
    10   Forms, tachartlazaruspkg, Game, Core, Common,
    11   TemplateGenerics
     8  Forms, tachartlazaruspkg, Game, Core, Common, TemplateGenerics
    129  { you can add units after this },
    1310  SysUtils, FormMain, CoolStreaming;
Note: See TracChangeset for help on using the changeset viewer.