/// <summary> /// Default constructor /// </summary> /// <param name="game">The game to edit</param> public EducationalDosGameEditViewModel(EducationalDosBoxGameData game) { // Get the available launch modes AvailableLaunchModes = Directory.GetDirectories(game.InstallDir + "PCMAP", "*", SearchOption.TopDirectoryOnly).Select(x => new FileSystemPath(x).Name).ToArray(); MountPath = game.MountPath; LaunchMode = game.LaunchMode ?? AvailableLaunchModes.FirstOrDefault(); Name = game.Name; }
/// <summary> /// Default constructor /// </summary> /// <param name="parentVM">The parent view model</param> /// <param name="gameData">The game info</param> /// <param name="name">The game name</param> public EducationalDosBoxGameInfoViewModel(EducationalDosOptionsViewModel parentVM, EducationalDosBoxGameData gameData, string name) { ParentVM = parentVM; GameData = gameData; Name = name; EditGameCommand = new AsyncRelayCommand(EditGameAsync); OpenLocationCommand = new AsyncRelayCommand(OpenLocationAsync); RemoveGameCommand = new AsyncRelayCommand(RemoveGameAsync); }
/// <summary> /// Get new info for a new educational DOSBox game /// </summary> /// <param name="installDir">The install directory</param> /// <returns>The info</returns> public EducationalDosBoxGameData GetNewEducationalDosBoxGameInfo(FileSystemPath installDir) { // Find the launch name FileSystemPath launchName = Directory.EnumerateFiles(installDir, "*.exe", SearchOption.TopDirectoryOnly).FirstOrDefault(); // Create the collection if it doesn't exist if (RCPServices.Data.EducationalDosBoxGames == null) { RCPServices.Data.EducationalDosBoxGames = new List <EducationalDosBoxGameData>(); } // Create the game data var info = new EducationalDosBoxGameData(installDir, launchName.Name) { Name = installDir.Name }; return(info); }
/// <summary> /// Verifies if the game can launch /// </summary> /// <param name="game">The game</param> /// <returns>True if the game can launch, otherwise false</returns> public async Task <bool> VerifyCanLaunchAsync(EducationalDosBoxGameData game) { // Make sure the DosBox executable exists if (!File.Exists(RCPServices.Data.DosBoxPath)) { await Services.MessageUI.DisplayMessageAsync(Resources.LaunchGame_DosBoxNotFound, MessageType.Error); return(false); } // Make sure the mount path exists, unless the game is Rayman 1 and TPLS is enabled if (!game.MountPath.Exists) { await Services.MessageUI.DisplayMessageAsync(Resources.LaunchGame_MountPathNotFound, MessageType.Error); return(false); } return(true); }
/// <summary> /// Gets the launch info for the game /// </summary> /// <param name="game">The game</param> /// <returns>The launch info</returns> public GameLaunchInfo GetLaunchInfo(EducationalDosBoxGameData game) { return(new GameLaunchInfo(RCPServices.Data.DosBoxPath, GetDosBoxArguments(game.MountPath, $"{game.LaunchName} ver={game.LaunchMode}", game.InstallDir))); }