Пример #1
0
        private void ChangeInstallation(GameInstallation installation)
        {
            _installation = installation;

            if (_fileSystem != null)
            {
                _fileSystem.Dispose();
                _fileSystem = null;
            }

            var launcherImagePath = installation.Game.LauncherImagePath;

            if (launcherImagePath != null)
            {
                var fullImagePath = Path.Combine(installation.Path, launcherImagePath);
                _installationImageView.Image = new Bitmap(fullImagePath);
            }
            else
            {
                _installationImageView.Image = null;
            }

            _fileSystem = installation.CreateFileSystem();

            InstallationChanged?.Invoke(this, new InstallationChangedEventArgs(installation, _fileSystem));
        }
Пример #2
0
        public void LoadGeneralsMaps()
        {
            var rootFolder   = InstalledFilesTestData.GetInstallationDirectory(SageGame.CncGenerals);
            var installation = new GameInstallation(new GeneralsDefinition(), rootFolder);
            var fileSystem   = installation.CreateFileSystem();

            var maps = fileSystem.GetFiles("maps").Where(x => x.FilePath.EndsWith(".map")).ToList();

            Platform.Start();

            using (var window = new GameWindow("OpenSAGE test runner", 100, 100, 800, 600, GraphicsBackend.Direct3D11))
            {
                using (var game = GameFactory.CreateGame(installation, fileSystem, GamePanel.FromGameWindow(window)))
                {
                    foreach (var map in maps)
                    {
                        _testOutputHelper.WriteLine($"Loading {map.FilePath}...");

                        var scene = game.ContentManager.Load <Scene3D>(map.FilePath);
                        Assert.NotNull(scene);

                        game.ContentManager.Unload();
                    }
                }
            }

            Platform.Stop();
        }
Пример #3
0
        private void ChangeInstallation(GameInstallation installation)
        {
            _installation = installation;

            if (_fileSystem != null)
            {
                _fileSystem.Dispose();
                _fileSystem = null;
            }

            if (_game != null)
            {
                _game.Dispose();
                _game = null;
            }

            _fileSystem = installation.CreateFileSystem();

            _game = new Game(
                HostPlatform.GraphicsDevice,
                HostPlatform.GraphicsDevice2D,
                _fileSystem,
                installation.Game);

            InstallationChanged?.Invoke(this, new InstallationChangedEventArgs(installation, _fileSystem));
        }
Пример #4
0
        private void ChangeInstallation(GameInstallation installation)
        {
            _selectedInstallation = installation;

            _imGuiRenderer.ClearCachedImageResources();

            RemoveAndDispose(ref _contentView);
            _files = null;
            RemoveAndDispose(ref _game);
            RemoveAndDispose(ref _gamePanel);
            RemoveAndDispose(ref _fileSystem);
            RemoveAndDispose(ref _launcherImage);

            if (installation == null)
            {
                _files = new List <FileSystemEntry>();
                return;
            }

            _fileSystem = AddDisposable(installation.CreateFileSystem());

            var launcherImagePath = installation.Game.LauncherImagePath;

            if (launcherImagePath != null)
            {
                var prefixLang = installation.Game.LauncherImagePrefixLang;
                if (prefixLang)
                {
                    var lang = LanguageUtility.ReadCurrentLanguage(installation.Game, _fileSystem.RootDirectory);
                    launcherImagePath = lang + launcherImagePath;
                }

                var launcherImageEntry = _fileSystem.GetFile(launcherImagePath);

                if (launcherImageEntry != null)
                {
                    _launcherImage = AddDisposable(new ImageSharpTexture(launcherImageEntry.Open()).CreateDeviceTexture(
                                                       _gameWindow.GraphicsDevice, _gameWindow.GraphicsDevice.ResourceFactory));
                }
            }

            _files = _fileSystem.Files.OrderBy(x => x.FilePath).ToList();

            _currentFile = -1;

            _gamePanel = AddDisposable(new ImGuiGamePanel(_gameWindow));
            _gamePanel.EnsureFrame(new Mathematics.Rectangle(0, 0, 100, 100));

            _game = AddDisposable(GameFactory.CreateGame(
                                      installation,
                                      _fileSystem,
                                      _gamePanel));

            //InstallationChanged?.Invoke(this, new InstallationChangedEventArgs(installation, _fileSystem));
        }
Пример #5
0
        private void ChangeInstallation(GameInstallation installation)
        {
            _selectedInstallation = installation;

            _imGuiRenderer.ClearCachedImageResources();

            RemoveAndDispose(ref _contentView);
            _files = null;
            RemoveAndDispose(ref _game);
            RemoveAndDispose(ref _gamePanel);
            RemoveAndDispose(ref _fileSystem);
            RemoveAndDispose(ref _launcherImage);

            if (installation == null)
            {
                _files = new List <FileSystemEntry>();
                return;
            }

            var launcherImagePath = installation.Game.LauncherImagePath;

            if (launcherImagePath != null)
            {
                var fullImagePath = Path.Combine(installation.Path, launcherImagePath);
                if (File.Exists(fullImagePath))
                {
                    _launcherImage = AddDisposable(new ImageSharpTexture(fullImagePath).CreateDeviceTexture(
                                                       _gameWindow.GraphicsDevice, _gameWindow.GraphicsDevice.ResourceFactory));
                }
            }

            _fileSystem = AddDisposable(installation.CreateFileSystem());

            _files = _fileSystem.Files.OrderBy(x => x.FilePath).ToList();

            _currentFile = -1;

            _gamePanel = AddDisposable(new ImGuiGamePanel(_gameWindow));
            _gamePanel.EnsureFrame(new Mathematics.Rectangle(0, 0, 100, 100));

            _game = AddDisposable(GameFactory.CreateGame(
                                      installation,
                                      _fileSystem,
                                      _gamePanel));

            //InstallationChanged?.Invoke(this, new InstallationChangedEventArgs(installation, _fileSystem));
        }