Exemplo n.º 1
0
 private void LoadPlayerKeys(int playerNumber)
 {
     try
     {
         if (playerNumber == 1)
         {
             if (File.Exists("XInputMapping1.xml"))
             {
                 var map = JoystickHelper.DeSerializeXInput(1);
                 GetJoystickInformation(TxtButton1, map.Button1);
                 GetJoystickInformation(TxtButton2, map.Button2);
                 GetJoystickInformation(TxtButton3, map.Button3);
                 GetJoystickInformation(TxtButton4, map.Button4);
                 GetJoystickInformation(TxtButton5, map.Button5);
                 GetJoystickInformation(TxtButton6, map.Button6);
                 GetJoystickInformation(TxtStart, map.Start);
                 GetJoystickInformation(TxtService, map.Service);
                 GetJoystickInformation(TxtTestSw, map.Test);
                 GetJoystickInformation(TxtUp, map.Up);
                 GetJoystickInformation(TxtDown, map.Down);
                 GetJoystickInformation(TxtLeft, map.Left);
                 GetJoystickInformation(TxtRight, map.Right);
                 GetJoystickInformation(TxtSrcGearChange1, map.SrcGearChange1);
                 GetJoystickInformation(TxtSrcGearChange2, map.SrcGearChange2);
                 GetJoystickInformation(TxtSrcGearChange3, map.SrcGearChange3);
                 GetJoystickInformation(TxtSrcGearChange4, map.SrcGearChange4);
                 GetJoystickInformation(TxtSrcViewChange1, map.SrcViewChange1);
                 GetJoystickInformation(TxtSrcViewChange2, map.SrcViewChange2);
                 GetJoystickInformation(TxtSrcViewChange3, map.SrcViewChange3);
                 GetJoystickInformation(TxtSrcViewChange4, map.SrcViewChange4);
                 GetJoystickInformation(TxtSonicItemButton, map.SonicItem);
                 GetJoystickInformation(TxtGunTrigger, map.GunTrigger);
                 GetJoystickInformation(TxtLgiLeft, map.GunLeft);
                 GetJoystickInformation(TxtLgiRight, map.GunRight);
                 GetJoystickInformation(TxtLgiUp, map.GunUp);
                 GetJoystickInformation(TxtLgiDown, map.GunDown);
                 GetJoystickInformation(TxtWheel, map.WheelAxis);
                 GetJoystickInformation(TxtGas, map.GasAxis, false, true);
                 GetJoystickInformation(TxtBrake, map.BrakeAxis, true);
                 GetJoystickInformation(TxtInitialD6ShiftUp, map.InitialD6ShiftUp);
                 GetJoystickInformation(TxtInitialD6ShiftDown, map.InitialD6ShiftDown);
                 GetJoystickInformation(TxtInitialD6ViewChange, map.InitialD6ViewChange);
                 GetJoystickInformation(TxtInitialD6MenuDown, map.InitialD6MenuDown);
                 GetJoystickInformation(TxtInitialD6MenuUp, map.InitialD6MenuUp);
                 GetJoystickInformation(TxtInitialD6MenuLeft, map.InitialD6MenuLeft);
                 GetJoystickInformation(TxtInitialD6MenuRight, map.InitialD6MenuRight);
                 if (map.GunMultiplier >= 1 && map.GunMultiplier <= 10)
                 {
                     IUpDownMovementMultiplier.Value = map.GunMultiplier;
                 }
                 else
                 {
                     IUpDownMovementMultiplier.Value = 1;
                 }
             }
         }
         else if (playerNumber == 2)
         {
             if (File.Exists("XInputMapping2.xml"))
             {
                 var map = JoystickHelper.DeSerializeXInput(2);
                 GetJoystickInformation(TxtButton1, map.Button1);
                 GetJoystickInformation(TxtButton2, map.Button2);
                 GetJoystickInformation(TxtButton3, map.Button3);
                 GetJoystickInformation(TxtButton4, map.Button4);
                 GetJoystickInformation(TxtButton5, map.Button5);
                 GetJoystickInformation(TxtButton6, map.Button6);
                 GetJoystickInformation(TxtStart, map.Start);
                 GetJoystickInformation(TxtService, map.Service);
                 GetJoystickInformation(TxtTestSw, map.Test);
                 GetJoystickInformation(TxtUp, map.Up);
                 GetJoystickInformation(TxtDown, map.Down);
                 GetJoystickInformation(TxtLeft, map.Left);
                 GetJoystickInformation(TxtRight, map.Right);
                 GetJoystickInformation(TxtGunTrigger, map.GunTrigger);
                 GetJoystickInformation(TxtLgiLeft, map.GunLeft);
                 GetJoystickInformation(TxtLgiRight, map.GunRight);
                 GetJoystickInformation(TxtLgiUp, map.GunUp);
                 GetJoystickInformation(TxtLgiDown, map.GunDown);
                 if (map.GunMultiplier >= 1 && map.GunMultiplier <= 10)
                 {
                     IUpDownMovementMultiplier.Value = map.GunMultiplier;
                 }
                 else
                 {
                     IUpDownMovementMultiplier.Value = 1;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show($"Loading failed with error: {ex.InnerException} {ex.Message}", "Error", MessageBoxButton.OK,
                         MessageBoxImage.Error);
     }
 }
Exemplo n.º 2
0
        /// <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();
        }