public void InstallGame(Game game) { logger.Info($"Installing {game.GetIdentifierInfo()}"); IGameController controller = null; try { controller = GameControllerFactory.GetGameBasedController(game, appSettings); Controllers.RemoveController(game.Id); Controllers.AddController(controller); UpdateGameState(game.Id, null, null, true, null, null); controller.Install(); } catch (Exception exc) when(!PlayniteEnvironment.ThrowAllErrors) { if (controller != null) { Controllers.RemoveController(game.Id); UpdateGameState(game.Id, null, null, false, null, null); } logger.Error(exc, "Cannot install game: "); dialogs.ShowMessage( string.Format(resources.FindString("LOCGameInstallError"), exc.Message), resources.FindString("LOCGameError"), MessageBoxButton.OK, MessageBoxImage.Error); } }
private void BootGame() { //Setting up controllers, databases, flow-stack etc. //Core functionality var viewDatabase = databaseHelper.Get <ViewDatabase>(); var viewController = new ViewController(viewDatabase); var flowStack = new FlowStack(); //Game, map, battle var tankDatabase = databaseHelper.Get <TankDatabase>(); var crewDatabase = databaseHelper.Get <CrewDatabase>(); var cardsDatabase = databaseHelper.Get <CardsDatabase>(); var activeCardsPanelLifecycleHandler = new ActiveCardsPanelLifecycleHandler(viewController); var abilitiesPanelLifecycleHandler = new AbilitiesPanelLifecycleHandler(tankDatabase); var tankPanelLifecycleHandler = new TankPanelLifecycleHandler(); var dragAndDropArrow = new DragAndDropArrowController(viewController); var battleHUD = new BattleHUD(viewController, activeCardsPanelLifecycleHandler, abilitiesPanelLifecycleHandler, tankPanelLifecycleHandler, dragAndDropArrow); var gameControllerFactory = new GameControllerFactory(flowStack, viewController, battleHUD, tankDatabase, crewDatabase, cardsDatabase); //Main menu var mainMenuControllerFactory = new MainMenuControllerFactory(flowStack, viewController, gameControllerFactory); //Start Flow var menuFlow = new MainMenuFlow(mainMenuControllerFactory); flowStack.Push(menuFlow); }
public void UnInstallGame(Game game) { if (game.State.Running || game.State.Launching) { dialogs.ShowMessage( resources.FindString("LOCGameUninstallRunningError"), resources.FindString("LOCGameError"), MessageBoxButton.OK, MessageBoxImage.Error); return; } try { var controller = GameControllerFactory.GetGameBasedController(game, appSettings); Controllers.RemoveController(game.Id); Controllers.AddController(controller); UpdateGameState(game.Id, null, null, null, true, null); controller.Uninstall(); } catch (Exception exc) when(!PlayniteEnvironment.ThrowAllErrors) { logger.Error(exc, "Cannot un-install game: "); dialogs.ShowMessage( string.Format(resources.FindString("LOCGameUninstallError"), exc.Message), resources.FindString("LOCGameError"), MessageBoxButton.OK, MessageBoxImage.Error); } }
public void InitializeCommandsTest() { var database = new GameDatabase(); var controllers = new GameControllerFactory(); var model = new MainViewModel( database, null, null, null, new PlayniteSettings(), new GamesEditor( new GameDatabase(), controllers, new PlayniteSettings(), null, null), null, new ExtensionFactory(database, controllers)); var props = typeof(MainViewModel).GetProperties(); foreach (var prop in props) { if (prop.Name.EndsWith("Command")) { var cmd = prop.GetValue(model, null); if (cmd == null) { Assert.Fail($"{prop.Name} is not defined."); } } } }
public void Execute(object parameter) { IGameControllerContext context = parameter as IGameControllerContext; IGameController gameController = GameControllerFactory.CreateGameController(context.GameMode); gameController.InitializeGame(context); }
public void Create_GameOptionsSetToLocalConnection_ReturnsLocalController() { var gameController = new GameControllerFactory().Create(new GameOptions { Connection = Enums.GameConnectionTypes.Local }, this.CreateGameControllerSetup()); gameController.ShouldBeOfType <LocalGameController>(); }
public void Execute(object parameter) { GameMode gameMode = (GameMode)parameter; IGameController gameController = GameControllerFactory.CreateGameController(gameMode); gameController.StartGame(); }
public void PlayGame(Game game) { if (!game.IsInstalled) { InstallGame(game); return; } logger.Info($"Starting {game.GetIdentifierInfo()}"); var dbGame = database.GetGame(game.Id); if (dbGame == null) { dialogs.ShowMessage( string.Format(resources.FindString("LOCGameStartErrorNoGame"), game.Name), resources.FindString("LOCGameError"), MessageBoxButton.OK, MessageBoxImage.Error); UpdateJumpList(); return; } IGameController controller = null; try { controller = GameControllerFactory.GetGameBasedController(game, appSettings); Controllers.RemoveController(game.Id); Controllers.AddController(controller); UpdateGameState(game.Id, null, null, null, null, true); controller.Play(database.GetEmulators()); } catch (Exception exc) when(!PlayniteEnvironment.ThrowAllErrors) { if (controller != null) { Controllers.RemoveController(game.Id); UpdateGameState(game.Id, null, null, null, null, false); } logger.Error(exc, "Cannot start game: "); dialogs.ShowMessage( string.Format(resources.FindString("LOCGameStartError"), exc.Message), resources.FindString("LOCGameError"), MessageBoxButton.OK, MessageBoxImage.Error); return; } try { UpdateJumpList(); } catch (Exception exc) when(!PlayniteEnvironment.ThrowAllErrors) { logger.Error(exc, "Failed to set jump list data: "); } }
public void Create_SetupWithAllHandlers_ControllerHasHandlersSet() { var gameControllerSetup = this.CreateGameControllerSetup(); var gameController = new GameControllerFactory().Create(null, gameControllerSetup); gameController.GameJoinedEvent.ShouldBe(gameControllerSetup.GameJoinedEventHandler); gameController.InitialBoardSetupEvent.ShouldBe(gameControllerSetup.InitialBoardSetupEventHandler); gameController.LoggedInEvent.ShouldBe(gameControllerSetup.LoggedInEventHandler); gameController.StartInitialSetupTurnEvent.ShouldBe(gameControllerSetup.StartInitialSetupTurnEvent); }
public GamesEditor(GameDatabase database, Settings appSettings, IDialogsFactory dialogs) { this.dialogs = dialogs; this.database = database; this.appSettings = appSettings; Controllers = new GameControllerFactory(database); Controllers.Installed += Controllers_Installed; Controllers.Uninstalled += Controllers_Uninstalled; Controllers.Started += Controllers_Started; Controllers.Stopped += Controllers_Stopped; }
public DesktopGamesEditor( GameDatabase database, GameControllerFactory controllerFactory, PlayniteSettings appSettings, IDialogsFactory dialogs, ExtensionFactory extensions, PlayniteApplication app) : base( database, controllerFactory, appSettings, dialogs, extensions, app) { }
public GamesEditor( GameDatabase database, GameControllerFactory controllerFactory, PlayniteSettings appSettings, IDialogsFactory dialogs, ExtensionFactory extensions) { this.dialogs = dialogs; this.database = database; this.appSettings = appSettings; this.extensions = extensions; controllers = controllerFactory; controllers.Installed += Controllers_Installed; controllers.Uninstalled += Controllers_Uninstalled; controllers.Started += Controllers_Started; controllers.Stopped += Controllers_Stopped; }
public GameHostWindow() { InitializeComponent(); myGameProvider.LoadGames(); IDictionary <string, IGame> myGames = myGameProvider.GetGames(); if (myGames.Any()) { GameControllerFactory.SetViewModel(myGameViewModel); myGameViewModel.Games = myGames; this.DataContext = myGameViewModel; } }
private void StartGameWithBuffs() { IGameController gameController = _gameController; if (gameController != null) { gameController.EndCurrentGame(); } _playerView = UnityEngine.Object.FindObjectsOfType <PlayerView>(); _uiView = UnityEngine.Object.FindObjectsOfType <UiView>(); IGameControllerFactory gameControllerFactory = new GameControllerFactory(TypeGame.GameWithBuffs); _gameController = gameControllerFactory.GameController; IPlayerControllerFactory playerControllerFactory = new PlayerControllerFactory(_playerView, playerPanelHierarchies, _gameController); IUiView[] uiView = _uiView; new UiControllerFactory(uiView, playerControllerFactory.PlayerController, _gameController); }
public void InitializeCommandsTest() { var database = new GameDatabase(); var controllers = new GameControllerFactory(); var model = new DesktopAppViewModel(); var props = typeof(DesktopAppViewModel).GetProperties(); foreach (var prop in props) { if (prop.Name.EndsWith("Command")) { var cmd = prop.GetValue(model, null); if (cmd == null) { Assert.Fail($"{prop.Name} is not defined."); } } } }
public GamesEditor( GameDatabase database, GameControllerFactory controllerFactory, PlayniteSettings appSettings, IDialogsFactory dialogs, ExtensionFactory extensions, PlayniteApplication app) { this.Dialogs = dialogs; this.Database = database; this.AppSettings = appSettings; this.Extensions = extensions; this.Application = app; controllers = controllerFactory; controllers.Installed += Controllers_Installed; controllers.Uninstalled += Controllers_Uninstalled; controllers.Started += Controllers_Started; controllers.Stopped += Controllers_Stopped; AppSettings.PropertyChanged += AppSettings_PropertyChanged; }
public GameHostWindow() { InitializeComponent(); myGameProvider.LoadGames(); IDictionary <string, IGame> myGames = myGameProvider.GetGames(); if (myGames.Any()) { myGameHost = GameControllerFactory.CreateGameController(GameMode.SinglePlayer); } IGameViewModel viewModel = myGameHost.GetGameViewModel(); viewModel.Games = myGames; viewModel.GameControllerCommand = new GameControllerCommand(myGameHost); viewModel.StartGameCommand = new StartGameCommand(myGameHost); this.DataContext = viewModel; }
public GameLibrary() { Controllers = new GameControllerFactory(); Api = new PlayniteAPI(null, null, null, paths: new PlaynitePathsAPI(), null, notifications: new NotificationsAPI()); LoadPlugins(); }
public void Create_DefaultGameOptions_ReturnsLocalController() { var gameController = new GameControllerFactory().Create(new GameOptions(), this.CreateGameControllerSetup()); gameController.ShouldBeOfType <LocalGameController>(); }
public void Create_NullParameter_ReturnsLocalController() { var gameController = new GameControllerFactory().Create(null, this.CreateGameControllerSetup()); gameController.ShouldBeOfType <LocalGameController>(); }
public MainMenuControllerFactory(FlowStack flowStack, ViewController viewController, GameControllerFactory gameControllerFactory) { this.flowStack = flowStack; this.viewController = viewController; this.gameControllerFactory = gameControllerFactory; }