/// <summary>Initializes a new instance of the <see cref="MainViewModel" /> class.</summary> public MainViewModel() { AddGameProfileCommand = new RelayCommand <GameProfile>(async param => { param = await GameProfilesDataAccess.CreateNewGame(param); GameProfiles.Add(new ListItemMainPage { GameProfile = await GameProfilesDataAccess.GetGameProfileAsync(param.ID) }); }, param => param != null); EditCommand = new RelayCommand <GameProfile>(async param => { await GameProfilesDataAccess.EditGameProfileAsync(param); }, param => param != null); RefreshSaveGame = new RelayCommand <ListItemMainPage>(async param => { var success = await GameProfilesDataAccess.RefreshSaveGameAsync(param.GameProfile.ID); if (success) { param.GameProfile.SaveGame.Challenges.Clear(); } RefreshSaveDone.Invoke(this, new PropertyChangedEventArgs("RefreshSaveDone")); }, param => param != null); DeleteGameProfileCommand = new RelayCommand <ListItemMainPage>(async param => { if (await GameProfilesDataAccess.DeleteGameProfileAsync(param.GameProfile)) { GameProfiles.Remove(param); } }, param => param != null); }
public IEnumerator UpdateGameProfile_Success() { GameProfiles gameProfiles = AccelBytePlugin.GetGameProfiles(); this.gameProfile.label = "label test"; this.gameProfile.profileName = "profile name test"; Result <GameProfile> updateGameProfileResult = null; gameProfiles.UpdateGameProfile(this.gameProfile, result => { updateGameProfileResult = result; }); while (updateGameProfileResult == null) { Thread.Sleep(100); yield return(null); } TestHelper.LogResult(updateGameProfileResult, "Update game profile"); TestHelper.Assert.That(!updateGameProfileResult.IsError); var gameProfileResult = updateGameProfileResult.Value; TestHelper.Assert.That(this.gameProfile.label, Is.EqualTo(gameProfileResult.label)); TestHelper.Assert.That(this.gameProfile.profileName, Is.EqualTo(gameProfileResult.profileName)); }
public IEnumerator BatchGetGameProfile_Success() { GameProfiles gameProfiles = AccelBytePlugin.GetGameProfiles(); Result <UserGameProfiles[]> batchGetGameProfilesResults = null; string[] userIds = new string[] { this.user.Session.UserId, "some_random_user_id", "not_exist_user_id" }; gameProfiles.BatchGetGameProfiles(userIds, result => { batchGetGameProfilesResults = result; }); while (batchGetGameProfilesResults == null) { Thread.Sleep(100); yield return(null); } TestHelper.LogResult(batchGetGameProfilesResults, "Batch get game profiles"); Assert.That(!batchGetGameProfilesResults.IsError); bool gameProfileFound = false; bool notExistEmptyProfile = true; int notExistUserIdCount = 0; foreach (UserGameProfiles userGameProfile in batchGetGameProfilesResults.Value) { if (userGameProfile.userId == this.gameProfile.userId) { foreach (GameProfilePublicInfo profile in userGameProfile.gameProfiles) { if (profile.profileId == this.gameProfile.profileId) { gameProfileFound = true; } } } else if (userGameProfile.userId == "some_random_user_id") { notExistUserIdCount++; if (userGameProfile.gameProfiles.Length > 0) { notExistEmptyProfile = false; } } else if (userGameProfile.userId == "not_exist_user_id") { notExistUserIdCount++; if (userGameProfile.gameProfiles.Length > 0) { notExistEmptyProfile = false; } } } Assert.That(gameProfileFound); Assert.AreEqual(notExistUserIdCount, 2); Assert.That(notExistEmptyProfile); }
/// <summary>Loads the game profiles from database asynchronous.</summary> /// <returns></returns> internal async Task LoadGameProfilesFromDBAsync() { if (GameProfiles.Count == 0) { var gameProfiles = await GameProfilesDataAccess.GetGameProfilesAsync(); foreach (GameProfile gameProfile in gameProfiles) { GameProfiles.Add(new ListItemMainPage { GameProfile = gameProfile, DeleteCommandGameProfile = DeleteGameProfileCommand }); } } }
public GameRunning(string gameLocation, GameProfiles gameProfile, bool isTest, SettingsData settingsData, string testMenuString, JoystickMapping joystickMapping1, JoystickMapping joystickMapping2, XInputMapping xinputMapping1, XInputMapping xinputMapping2, bool testMenuIsExe = false, string testMenuExe = "") { InitializeComponent(); _gameLocation = gameLocation; InputCode.ButtonMode = gameProfile; _isTest = isTest; _serialPortHandler = new SerialPortHandler(); _settingsData = settingsData; _testMenuString = testMenuString; _joystickMapping1 = joystickMapping1; _joystickMapping2 = joystickMapping2; _xinputMapping1 = xinputMapping1; _xinputMapping2 = xinputMapping2; _testMenuIsExe = testMenuIsExe; _testMenuExe = testMenuExe; }
public IEnumerator DeleteGameProfile_Success() { GameProfiles gameProfiles = AccelBytePlugin.GetGameProfiles(); Result deleteGameProfileResult = null; gameProfiles.DeleteGameProfile(this.gameProfile.profileId, result => { deleteGameProfileResult = result; }); while (deleteGameProfileResult == null) { Thread.Sleep(100); yield return(null); } TestHelper.LogResult(deleteGameProfileResult, "Delete game profile"); TestHelper.Assert.That(!deleteGameProfileResult.IsError); }
public IEnumerator GetCreatedGameProfile_Success() { GameProfiles gameProfiles = AccelBytePlugin.GetGameProfiles(); Result <GameProfile> getGameProfileResult = null; gameProfiles.GetGameProfile(this.gameProfile.profileId, result => { getGameProfileResult = result; }); while (getGameProfileResult == null) { Thread.Sleep(100); yield return(null); } TestHelper.LogResult(getGameProfileResult, "Get game profile, after created"); Assert.That(!getGameProfileResult.IsError); }
/// <summary> /// Validates that the game exists and then runs it with the emulator. /// </summary> /// <param name="gameLocation">Game executable location.</param> /// <param name="gameProfile">Input profile.</param> /// <param name="testMenuString">Command to run test menu.</param> /// <param name="testMenuIsExe">If uses separate exe.</param> /// <param name="exeName">Test menu exe name.</param> private void ValidateAndRun(string gameLocation, GameProfiles gameProfile, string testMenuString, bool testMenuIsExe = false, string exeName = "") { if (!File.Exists(gameLocation)) { MessageBox.Show($"Cannot find game exe at: {gameLocation}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (!File.Exists("ParrotLoader.exe")) { MessageBox.Show($"Cannot find ParrotLoader.exe", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (!File.Exists("TeknoParrot.dll")) { MessageBox.Show($"Cannot find TeknoParrot.dll", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } var testMenu = ChkTestMenu.IsChecked != null && ChkTestMenu.IsChecked.Value; JoystickMapping jmap1 = null; JoystickMapping jmap2 = null; XInputMapping xmap1 = null; XInputMapping xmap2 = null; try { if (File.Exists("JoystickMapping1.xml")) { jmap1 = JoystickHelper.DeSerialize(1); } if (File.Exists("JoystickMapping2.xml")) { jmap2 = JoystickHelper.DeSerialize(2); } } catch (Exception ex) { MessageBox.Show($"Loading joystick mapping failed with error: {ex.InnerException} {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } try { if (File.Exists("XInputMapping1.xml")) { xmap1 = JoystickHelper.DeSerializeXInput(1); } if (File.Exists("XInputMapping2.xml")) { xmap2 = JoystickHelper.DeSerializeXInput(2); } } catch (Exception ex) { MessageBox.Show($"Loading joystick mapping failed with error: {ex.InnerException} {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (jmap1 == null) { jmap1 = new JoystickMapping(); } if (jmap2 == null) { jmap2 = new JoystickMapping(); } if (xmap1 == null) { xmap1 = new XInputMapping(); } if (xmap2 == null) { xmap2 = new XInputMapping(); } var gameRunning = new GameRunning(gameLocation, gameProfile, testMenu, _settingsData, testMenuString, jmap1, jmap2, xmap1, xmap2, testMenuIsExe, exeName); gameRunning.ShowDialog(); gameRunning.Close(); }