Changeset 310 for trunk/UCore.pas
- Timestamp:
- Aug 18, 2021, 4:02:44 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r309 r310 10 10 URegistry, ULastOpenedList, UTheme, UAboutDialog, Registry, Menus, 11 11 UFormClient, UPlayer, UGameServer, UGameClient, fgl, UServerList, UGameSystem, 12 Graphics ;12 Graphics, UUnit; 13 13 14 14 type … … 75 75 FormNewTabIndex: Integer; 76 76 OldWindowState: TWindowState; 77 InFullScreenMode: Boolean; 77 FullScreen: Boolean; 78 GameFilesDir: string; 78 79 procedure LoadRecentExecute(Sender: TObject); 79 80 procedure StartNewGame; … … 90 91 procedure FormClientActions; 91 92 procedure LoadGameSystems; 93 procedure ToggleFullscreen; 92 94 public 93 95 Game: TGame; … … 130 132 131 133 uses 132 UFormMain, UFormNew, UFormSettings, UClientAI, UFormKeyShortcuts, 134 UFormMain, UFormNew, UFormSettings, UClientAI, UFormKeyShortcuts, UCommon, 133 135 UFormHelp, UFormCharts, UFormUnitMoves, UFormPlayersStats, UClientGUI; 134 136 … … 303 305 procedure TCore.AFullscreenExecute(Sender: TObject); 304 306 begin 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; 324 308 end; 325 309 … … 402 386 if FileExists(Game.FileName) then 403 387 Game.SaveToFile(Game.FileName) 404 else AGameSave .Execute;388 else AGameSaveAs.Execute; 405 389 end; 406 390 … … 476 460 procedure TCore.DataModuleCreate(Sender: TObject); 477 461 const 478 LinuxLanguagesDir = '/usr/share/xtactics/languages'; 479 begin 462 LinuxGameFilesDir = '/usr/share/xtactics'; 463 LinuxLanguagesDir = LinuxGameFilesDir + '/Languages'; 464 begin 465 GameFilesDir := ''; 480 466 {$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; 481 470 // If installed in Linux system then use installation directory for po files 482 471 if not DirectoryExists(CoolTranslator1.POFilesFolder) and DirectoryExists(LinuxLanguagesDir) then … … 484 473 {$ENDIF} 485 474 486 475 GameSystems := TGameSystems.Create; 487 476 Server := TServer.Create; 488 477 LocalClients := TClients.Create; … … 494 483 Game.OnNewTurn := GameNewTurnExecute; 495 484 Game.OnPlayerChange := DoPlayerChange; 485 Game.MapImageFileName := CombinePaths(GameFilesDir, 'Images' + DirectorySeparator + 'Maps' + DirectorySeparator + 'WorldMap.png'); 496 486 Server.Game := Game; 497 487 LocalClients.Game := Game; … … 604 594 procedure TCore.LoadGameSystems; 605 595 var 606 NewItem: TGameSystem; 607 begin 608 if DirectoryExists('Systems') then begin 609 GameSystems.LoadFromDir('Systems'); 596 NewGameSystem: TGameSystem; 597 NewUnitKind: TUnitKind; 598 SystemsDir: string; 599 begin 600 if GameFilesDir <> '' then 601 SystemsDir := GameFilesDir + DirectorySeparator + 'Systems' 602 else SystemsDir := 'Systems'; 603 if DirectoryExists(SystemsDir) then begin 604 GameSystems.LoadFromDir(SystemsDir); 610 605 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); 614 613 end; 615 614 if GameSystems.Count > 0 then begin … … 617 616 Game.GameSystem.Assign(GameSystems.First); 618 617 end; 618 end; 619 620 procedure TCore.ToggleFullscreen; 621 begin 622 FullScreen := not FullScreen; 623 PersistentForm.Form := FormMain; 624 PersistentForm.SetFullScreen(FullScreen); 625 UpdateInterface; 619 626 end; 620 627
Note:
See TracChangeset
for help on using the changeset viewer.