private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
 {
     JoystickHelper.SerializeGameProfile(_gameProfile);
     _comboItem.Tag = _gameProfile;
     Application.Current.Windows.OfType <MainWindow>().Single().ShowMessage(string.Format(Properties.Resources.SuccessfullySaved, "Joystick Settings"));
     _contentControl.Content = _library;
 }
Пример #2
0
 private void BtnSaveSettings(object sender, RoutedEventArgs e)
 {
     try
     {
         var settingsData = new SettingsData
         {
             PlayerOneGuid        = FetchGuidFromComboBoxItem(P1JoystickComboBox.SelectedItem),
             PlayerTwoGuid        = FetchGuidFromComboBoxItem(P2JoystickComboBox.SelectedItem),
             UseKeyboard          = ChkUseKeyboard.IsChecked != null && ChkUseKeyboard.IsChecked.Value,
             SegaRacingClassicDir = TxtSrcLocation.Text,
             VirtuaTennis4Dir     = TxtVt4Location.Text,
             MeltyBloodDir        = TxtMeltyBloodLocation.Text,
             LgiDir              = TxtLgiLocation.Text,
             SegaSonicDir        = TxtSegaSonicLocation.Text,
             SegaDreamRaidersDir = TxtSdrLocation.Text,
             UseSto0ZDrivingHack = ChkUseSto0ZCheckBox.IsChecked != null && ChkUseSto0ZCheckBox.IsChecked.Value,
             UseMouse            = ChkUseMouse.IsChecked != null && ChkUseMouse.IsChecked.Value,
             InitialD6Dir        = TxtInitialD6Location.Text,
             XInputMode          = _xinputMode,
             GoldenGunDir        = TxtGoldenGunLocation.Text
         };
         JoystickHelper.Serialize(settingsData);
         _settingsData = settingsData;
         MessageBox.Show("Generation of SettingsData.xml was succesful!", "Save Complete", MessageBoxButton.OK,
                         MessageBoxImage.Information);
     }
     catch (Exception exception)
     {
         MessageBox.Show($"Exception happened during SettingsData.xml saving!{Environment.NewLine}{Environment.NewLine}{exception}", "Error", MessageBoxButton.OK,
                         MessageBoxImage.Error);
     }
     Hide();
 }
Пример #3
0
        public void reader_DataReceived(object sender, EndpointDataEventArgs e)
        {
            if (run)
            {
                var data   = e.Buffer;
                var input1 = ControllerState.deserialize(getFastInput1(ref data));

                if (gcn1ok)
                {
                    JoystickHelper.setJoystick(ref gcn1, input1, 1, gcn1DZ);
                }
            }
            else
            {
                reader.DataReceivedEnabled = false;

                if (GCNAdapter != null)
                {
                    if (GCNAdapter.IsOpen)
                    {
                        if (!ReferenceEquals(wholeGCNAdapter, null))
                        {
                            wholeGCNAdapter.ReleaseInterface(0);
                        }
                        GCNAdapter.Close();
                    }
                    GCNAdapter = null;
                    UsbDevice.Exit();
                    DriverLog(null, new Logging.LogEventArgs("Closing driver thread..."));
                }
                DriverLog(null, new Logging.LogEventArgs("Driver thread has been stopped."));
            }
        }
Пример #4
0
        private void PopulateJoysticks()
        {
            P1JoystickComboBox.Items.Clear();
            P2JoystickComboBox.Items.Clear();
            if (_settingsData != null)
            {
                if (_settingsData.PlayerOneGuid != Guid.Empty)
                {
                    P1JoystickComboBox.Items.Add(CreateJoystickItem(_settingsData.PlayerOneGuid, "Saved Joystick"));
                }

                if (_settingsData.PlayerTwoGuid != Guid.Empty)
                {
                    P2JoystickComboBox.Items.Add(CreateJoystickItem(_settingsData.PlayerTwoGuid, "Saved Joystick"));
                }
            }
            CreateJoystickProfileAndAdd(Guid.Empty, "No joystick");
            var joysticks = JoystickHelper.GetAvailableJoysticks();

            foreach (var joystickProfile in joysticks)
            {
                CreateJoystickProfileAndAdd(joystickProfile.InstanceGuid, joystickProfile.ProductName);
            }
            P1JoystickComboBox.SelectedIndex = 0;
            P2JoystickComboBox.SelectedIndex = 0;
        }
Пример #5
0
        private static void ExtractUserProfiles(string path)
        {
            StringBuilder sb = new StringBuilder();

            foreach (var file in Directory.GetFiles(Path.Combine(path, "UserProfiles")))
            {
                var zzz = JoystickHelper.DeSerializeGameProfile(file, false);
                if (zzz == null)
                {
                    continue;
                }

                string code = Path.GetFileNameWithoutExtension(zzz.FileName);
                if (executables.ContainsKey(code))
                {
                    continue;
                }

                string codeStr = "{ \"" + code + "\",";
                sb.Append(codeStr);
                sb.Append(new string(' ', Math.Max(1, 32 - code.Length)));
                sb.Append("@\"");
                sb.Append(zzz.GamePath);
                sb.AppendLine("\" },");
            }

            var str = sb.ToString();
        }
Пример #6
0
        public JoystickMode()
        {
            InitializeComponent();

            Application.Current.Exit += Current_Exit;

            gridSettings.DataContext = App.settings;

            joystickHelper  = new JoystickHelper();
            buttonsToColors = new ObservableCollection <JoystickButtonToColor>();
            pressedButtons  = new List <JoystickButtonToColor>();

            RefreshJoysticks();

            for (int i = 0; i < guids.Count; i++)
            {
                if (guids[i].ToString() == App.settings.JoystickSelected)
                {
                    combo_joysticks.SelectedIndex = i;
                    Start();
                }
            }

            DefaultColor.InitialColorBrush  = new Media.SolidColorBrush(Media.Color.FromArgb(0, Effects.Colors[0].R, Effects.Colors[0].G, Effects.Colors[0].B));
            DefaultColor.SelectedColorBrush = new Media.SolidColorBrush(Media.Color.FromArgb(0, Effects.Colors[0].R, Effects.Colors[0].G, Effects.Colors[0].B));
        }
Пример #7
0
 private bool FetchProfile(string profile)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(profile))
         {
             return(false);
         }
         var a = profile.Substring(10, profile.Length - 10);
         if (string.IsNullOrWhiteSpace(a))
         {
             return(false);
         }
         var b = Path.Combine("GameProfiles\\", a);
         if (!File.Exists(b))
         {
             return(false);
         }
         if (File.Exists(Path.Combine("UserProfiles\\", a)))
         {
             _profile = JoystickHelper.DeSerializeGameProfile(Path.Combine("UserProfiles\\", a));
         }
         else
         {
             _profile = JoystickHelper.DeSerializeGameProfile(b);
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #8
0
        private void BtnSaveSettings(object sender, RoutedEventArgs e)
        {
            string inputApiString = _gameProfile.ConfigValues.Find(cv => cv.FieldName == "Input API")?.FieldValue;

            if (inputApiString != null)
            {
                _inputApi = (InputApi)Enum.Parse(typeof(InputApi), inputApiString);
            }

            foreach (var t in _gameProfile.JoystickButtons)
            {
                if (_inputApi == InputApi.DirectInput)
                {
                    t.BindName = t.BindNameDi;
                }
                else if (_inputApi == InputApi.XInput)
                {
                    t.BindName = t.BindNameXi;
                }
                else if (_inputApi == InputApi.RawInput)
                {
                    t.BindName = t.BindNameRi;
                }
            }
            JoystickHelper.SerializeGameProfile(_gameProfile);
            _gameProfile.GamePath = GamePathBox.Text;
            Lazydata.GamePath     = GamePathBox.Text;
            JoystickHelper.SerializeGameProfile(_gameProfile);
            _comboItem.Tag = _gameProfile;
            Application.Current.Windows.OfType <MainWindow>().Single().ShowMessage(string.Format(Properties.Resources.SuccessfullySaved, System.IO.Path.GetFileName(_gameProfile.FileName)));
            _contentControl.Content = _library;
        }
Пример #9
0
        private void BtnSaveSettings(object sender, RoutedEventArgs e)
        {
            try
            {
                Lazydata.ParrotData.UseSto0ZDrivingHack = ChkUseSto0ZCheckBox.IsChecked != null &&
                                                          ChkUseSto0ZCheckBox.IsChecked.Value;
                Lazydata.ParrotData.StoozPercent = (int)sTo0zZonePercent.Value;


                if (ChkFullAxisGas.IsChecked.HasValue)
                {
                    Lazydata.ParrotData.FullAxisGas = ChkFullAxisGas.IsChecked.Value;
                }
                if (ChkReverseAxisGas.IsChecked.HasValue)
                {
                    Lazydata.ParrotData.ReverseAxisGas = ChkReverseAxisGas.IsChecked.Value;
                }
                if (ChkFullAxisBrake.IsChecked.HasValue)
                {
                    Lazydata.ParrotData.FullAxisBrake = ChkFullAxisBrake.IsChecked.Value;
                }
                if (ChkReverseAxisBrake.IsChecked.HasValue)
                {
                    Lazydata.ParrotData.ReverseAxisBrake = ChkReverseAxisBrake.IsChecked.Value;
                }

                if (GunSensitivityPlayer1.Value != null)
                {
                    Lazydata.ParrotData.GunSensitivityPlayer1 = (int)GunSensitivityPlayer1.Value;
                }

                if (GunSensitivityPlayer2.Value != null)
                {
                    Lazydata.ParrotData.GunSensitivityPlayer2 = (int)GunSensitivityPlayer2.Value;
                }

                Lazydata.ParrotData.SaveLastPlayed  = ChkSaveLastPlayed.IsChecked.Value;
                Lazydata.ParrotData.UseDiscordRPC   = ChkUseDiscordRPC.IsChecked.Value;
                Lazydata.ParrotData.CheckForUpdates = ChkCheckForUpdates.IsChecked.Value;
                Lazydata.ParrotData.SilentMode      = ChkSilentMode.IsChecked.Value;
                Lazydata.ParrotData.ConfirmExit     = ChkConfirmExit.IsChecked.Value;
                Lazydata.ParrotData.DownloadIcons   = ChkDownloadIcons.IsChecked.Value;
                Lazydata.ParrotData.UiDisableHardwareAcceleration = ChkUiDisableHardwareAcceleration.IsChecked.Value;

                Lazydata.ParrotData.UiColour        = UiColour.SelectedItem.ToString();
                Lazydata.ParrotData.UiDarkMode      = ChkUiDarkMode.IsChecked.Value;
                Lazydata.ParrotData.UiHolidayThemes = ChkUiHolidayThemes.IsChecked.Value;

                DiscordRPC.StartOrShutdown();

                JoystickHelper.Serialize();

                Application.Current.Windows.OfType <MainWindow>().Single().ShowMessage(string.Format(Properties.Resources.SuccessfullySaved, "ParrotData.xml"));
                _contentControl.Content = _library;
            }
            catch (Exception exception)
            {
                MessageBoxHelper.ErrorOK(string.Format(Properties.Resources.ErrorCantSaveParrotData, exception.ToString()));
            }
        }
Пример #10
0
 /// <summary>
 /// Loads the settings data file.
 /// </summary>
 private void LoadParrotData()
 {
     try
     {
         if (!File.Exists("ParrotData.xml"))
         {
             MessageBox.Show("Seems this is first time you are running me, please set emulation settings.",
                             "Hello World", MessageBoxButton.OK, MessageBoxImage.Information);
             _parrotData         = new ParrotData();
             Lazydata.ParrotData = _parrotData;
             JoystickHelper.Serialize(_parrotData);
             return;
         }
         _parrotData = JoystickHelper.DeSerialize();
         if (_parrotData == null)
         {
             _parrotData         = new ParrotData();
             Lazydata.ParrotData = _parrotData;
             JoystickHelper.Serialize(_parrotData);
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(
             $"Exception happened during loading ParrotData.xml! Generate new one by saving!{Environment.NewLine}{Environment.NewLine}{e}",
             "Error", MessageBoxButton.OK,
             MessageBoxImage.Error);
     }
 }
Пример #11
0
        private void BtnSaveSettings(object sender, RoutedEventArgs e)
        {
            try
            {
                Lazydata.ParrotData.UseSto0ZDrivingHack = ChkUseSto0ZCheckBox.IsChecked != null &&
                                                          ChkUseSto0ZCheckBox.IsChecked.Value;
                Lazydata.ParrotData.StoozPercent = (int)sTo0zZonePercent.Value;


                if (ChkFullAxisGas.IsChecked.HasValue)
                {
                    Lazydata.ParrotData.FullAxisGas = ChkFullAxisGas.IsChecked.Value;
                }
                if (ChkReverseAxisGas.IsChecked.HasValue)
                {
                    Lazydata.ParrotData.ReverseAxisGas = ChkReverseAxisGas.IsChecked.Value;
                }
                if (ChkFullAxisBrake.IsChecked.HasValue)
                {
                    Lazydata.ParrotData.FullAxisBrake = ChkFullAxisBrake.IsChecked.Value;
                }
                if (ChkReverseAxisBrake.IsChecked.HasValue)
                {
                    Lazydata.ParrotData.ReverseAxisBrake = ChkReverseAxisBrake.IsChecked.Value;
                }

                if (GunSensitivityPlayer1.Value != null)
                {
                    Lazydata.ParrotData.GunSensitivityPlayer1 = (int)GunSensitivityPlayer1.Value;
                }

                if (GunSensitivityPlayer2.Value != null)
                {
                    Lazydata.ParrotData.GunSensitivityPlayer2 = (int)GunSensitivityPlayer2.Value;
                }

                Lazydata.ParrotData.SaveLastPlayed  = ChkSaveLastPlayed.IsChecked.Value;
                Lazydata.ParrotData.UseDiscordRPC   = ChkUseDiscordRPC.IsChecked.Value;
                Lazydata.ParrotData.CheckForUpdates = ChkCheckForUpdates.IsChecked.Value;
                Lazydata.ParrotData.SilentMode      = ChkSilentMode.IsChecked.Value;
                Lazydata.ParrotData.ConfirmExit     = ChkConfirmExit.IsChecked.Value;
                Lazydata.ParrotData.DownloadIcons   = ChkDownloadIcons.IsChecked.Value;
                Lazydata.ParrotData.UiDisableHardwareAcceleration = ChkUiDisableHardwareAcceleration.IsChecked.Value;

                Lazydata.ParrotData.UiColour   = UiColour.SelectedItem.ToString();
                Lazydata.ParrotData.UiDarkMode = ChkUiDarkMode.IsChecked.Value;

                DiscordRPC.StartOrShutdown();

                JoystickHelper.Serialize();

                MessageBox.Show("Successfully saved ParrotData.xml!");
            }
            catch (Exception exception)
            {
                MessageBox.Show($"Exception happened during ParrotData.xml saving!{Environment.NewLine}{Environment.NewLine}{exception}", "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
Пример #12
0
        public void GetMagnitude_FromJoyStickXYCoordinates(int x, int y, double expected)
        {
            double actual = JoystickHelper.GetMagnitudeFromXYCoordinate(x, y);

            const double delta = 0.0001f;

            Assert.AreEqual(expected, actual, delta);
        }
        private void BtnSaveSettings(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_parrotData == null)
                {
                    _parrotData         = new ParrotData();
                    Lazydata.ParrotData = _parrotData;
                }
                _parrotData.UseSto0ZDrivingHack = ChkUseSto0ZCheckBox.IsChecked != null &&
                                                  ChkUseSto0ZCheckBox.IsChecked.Value;
                _parrotData.StoozPercent = (int)sTo0zZonePercent.Value;


                if (ChkFullAxisGas.IsChecked.HasValue)
                {
                    _parrotData.FullAxisGas = ChkFullAxisGas.IsChecked.Value;
                }
                if (ChkReverseAxisGas.IsChecked.HasValue)
                {
                    _parrotData.ReverseAxisGas = ChkReverseAxisGas.IsChecked.Value;
                }
                if (ChkFullAxisBrake.IsChecked.HasValue)
                {
                    _parrotData.FullAxisBrake = ChkFullAxisBrake.IsChecked.Value;
                }
                if (ChkReverseAxisBrake.IsChecked.HasValue)
                {
                    _parrotData.ReverseAxisBrake = ChkReverseAxisBrake.IsChecked.Value;
                }

                if (GunSensitivityPlayer1.Value != null)
                {
                    _parrotData.GunSensitivityPlayer1 = (int)GunSensitivityPlayer1.Value;
                }

                if (GunSensitivityPlayer2.Value != null)
                {
                    _parrotData.GunSensitivityPlayer2 = (int)GunSensitivityPlayer2.Value;
                }

                _parrotData.SaveLastPlayed  = ChkSaveLastPlayed.IsChecked.Value;
                _parrotData.UseDiscordRPC   = ChkUseDiscordRPC.IsChecked.Value;
                _parrotData.CheckForUpdates = ChkCheckForUpdates.IsChecked.Value;
                _parrotData.SilentMode      = ChkSilentMode.IsChecked.Value;

                JoystickHelper.Serialize(_parrotData);
                DiscordRPC.Shutdown();
                string[] psargs = Environment.GetCommandLineArgs();
                System.Diagnostics.Process.Start(Application.ResourceAssembly.Location, psargs[0]);
                Application.Current.Shutdown();
            }
            catch (Exception exception)
            {
                MessageBox.Show($"Exception happened during ParrotData.xml saving!{Environment.NewLine}{Environment.NewLine}{exception}", "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
 private void BtnSaveSettings(object sender, RoutedEventArgs e)
 {
     _gameProfile.GamePath = GamePathBox.Text;
     Lazydata.GamePath     = GamePathBox.Text;
     JoystickHelper.SerializeGameProfile(_gameProfile);
     _comboItem.Tag = _gameProfile;
     MessageBox.Show($"Generation of {System.IO.Path.GetFileName(_gameProfile.FileName)} was succesful!", "Save Complete", MessageBoxButton.OK,
                     MessageBoxImage.Information);
 }
 private void BtnSaveSettings(object sender, RoutedEventArgs e)
 {
     _gameProfile.GamePath = GamePathBox.Text;
     Lazydata.GamePath     = GamePathBox.Text;
     JoystickHelper.SerializeGameProfile(_gameProfile);
     _comboItem.Tag = _gameProfile;
     Application.Current.Windows.OfType <MainWindow>().Single().ShowMessage(string.Format(Properties.Resources.SuccessfullySaved, System.IO.Path.GetFileName(_gameProfile.FileName)));
     _contentControl.Content = _library;
 }
Пример #16
0
        private void App_OnStartup(object sender, StartupEventArgs e)
        {
            if (SingleApplicationDetector.IsRunning())
            {
                if (MessageBox.Show(
                        "Detected already running TeknoParrot Ui, want me to close it for you?", "Error",
                        MessageBoxButton.YesNo, MessageBoxImage.Error) == MessageBoxResult.Yes)
                {
                    TerminateProcesses();
                }
                else
                {
                    Application.Current.Shutdown(0);
                    return;
                }
            }
            if (File.Exists("DumbJVSManager.exe"))
            {
                MessageBox.Show(
                    "Seems you have extracted me to directory of old TeknoParrot, please extract me to a new directory instead!",
                    "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown(0);
                return;
            }
            var parrotData = JoystickHelper.DeSerialize();

            if (parrotData == null)
            {
                StartApp();
                return;
            }
            if (e.Args.Length != 0)
            {
                // Process command args
                if (HandleArgs(e.Args))
                {
                    // Args ok, let's do stuff
                    if (_emuOnly)
                    {
                        TeknoParrotUi.Views.GameRunning g = new TeknoParrotUi.Views.GameRunning(_profile, _test, parrotData, _profile.TestMenuParameter,
                                                                                                _profile.TestMenuIsExecutable, _profile.TestMenuExtraParameters, true);
                        g.Show();
                        return;
                    }
                    else
                    {
                        TeknoParrotUi.Views.GameRunning g = new TeknoParrotUi.Views.GameRunning(_profile, _test, parrotData, _profile.TestMenuParameter,
                                                                                                _profile.TestMenuIsExecutable, _profile.TestMenuExtraParameters, false);
                        g.Show();
                        return;
                    }
                }
            }
            StartApp();
        }
 private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
 {
     // Save here, also save gamepath.
     if (Lazydata.GamePath != String.Empty)
     {
         _gameProfile.GamePath = Lazydata.GamePath;
     }
     JoystickHelper.SerializeGameProfile(_gameProfile);
     _comboItem.Tag = _gameProfile;
     MessageBox.Show("Save complete");
 }
Пример #18
0
        private void BtnSaveSettings(object sender, RoutedEventArgs e)
        {
            string inputApiString = _gameProfile.ConfigValues.Find(cv => cv.FieldName == "Input API")?.FieldValue;

            if (inputApiString != null)
            {
                _inputApi = (InputApi)Enum.Parse(typeof(InputApi), inputApiString);
            }

            foreach (var t in _gameProfile.JoystickButtons)
            {
                if (_inputApi == InputApi.DirectInput)
                {
                    t.BindName = t.BindNameDi;
                }
                else if (_inputApi == InputApi.XInput)
                {
                    t.BindName = t.BindNameXi;
                }
                else if (_inputApi == InputApi.RawInput)
                {
                    t.BindName = t.BindNameRi;
                }
            }

            string NameString = _gameProfile.ConfigValues.Find(cv => cv.FieldName == "Submission Name")?.FieldValue;

            if (NameString != null)
            {
                if (_gameProfile.ConfigValues.Any(x => x.FieldName == "Enable Submission (Patreon Only)" && x.FieldValue == "1"))
                {
                    if (_gameProfile.ConfigValues.Find(cv => cv.FieldName == "Submission Name").FieldValue == "")
                    {
                        MessageBox.Show("Score Submission requires a name!");
                    }
                }

                string[] badWords = new[] { "f**k", "c**t", "f*****t", "f*g", "dick", "shit", "c**k", "pussy", "ass", "asshole", "bitch", "h**o", "f****t", "a$$", "@ss", "f@g", "f****r", "f*****g", "fuk", "f****n", "fucken", "teknoparrot", "tp", "arse", "@rse", "@$$", "bastard", "crap", "effing", "god", "hell", "m**********r", "w***e", "twat", "gay", "g@y", "ash0le", "assh0le", "a$$hol", "anal", };

                NameString = Filter(NameString, badWords);
                _gameProfile.ConfigValues.Find(cv => cv.FieldName == "Submission Name").FieldValue = NameString;
            }

            JoystickHelper.SerializeGameProfile(_gameProfile);
            _gameProfile.GamePath = GamePathBox.Text;
            Lazydata.GamePath     = GamePathBox.Text;
            JoystickHelper.SerializeGameProfile(_gameProfile);
            _comboItem.Tag = _gameProfile;
            Application.Current.Windows.OfType <MainWindow>().Single().ShowMessage(string.Format(Properties.Resources.SuccessfullySaved, System.IO.Path.GetFileName(_gameProfile.FileName)));
            _library.ListUpdate(_gameProfile.GameName);
            _contentControl.Content = _library;
        }
Пример #19
0
        public AddButton(Guid _guid, JoystickHelper helper, ButtonTypeEnum _buttonType)
        {
            InitializeComponent();

            joystick   = helper.HookJoystick(_guid);
            buttonType = _buttonType;

            timer = new DispatcherTimer()
            {
                Interval = new TimeSpan(20)
            };
            timer.Tick += Timer_Tick;
            timer.Start();
        }
Пример #20
0
        public AddButton(Guid _guid, JoystickHelper helper, ControlTypeEnum _controlType)
        {
            InitializeComponent();

            joystick    = helper.HookJoystick(_guid);
            controlType = _controlType;
            toggle_ignore.DataContext = this;

            timer = new DispatcherTimer()
            {
                Interval = new TimeSpan(20)
            };
            timer.Tick += Timer_Tick;
            timer.Start();
        }
Пример #21
0
        private Application()
        {
            //_decoderManager = new DecoderManager();

            Container.RegisterType <IDecoderManager, DecoderManager>(new ContainerControlledLifetimeManager());
            Container.RegisterType <IFilterManager, FilterManager>(new ContainerControlledLifetimeManager());

            DecoderManager = Container.Resolve <DecoderManager>();
            FilterManager  = Container.Resolve <FilterManager>();

            JoystickHelper.Initialize();
            JoystickInteraction.Initialize();

            //TODO: Remove, this is only for testing...
            AudioHelper.Instance.DataAvailable += AudioDataAvailable;
        }
Пример #22
0
    public static void StartOrShutdown()
    {
        // download the DLL if it doesn't exist
        if (!File.Exists(RPC_PATH))
        {
            try
            {
                var request = (HttpWebRequest)WebRequest.Create("https://github.com/discordapp/discord-rpc/releases/download/v3.4.0/discord-rpc-win.zip");
                request.Timeout = 10000;
                request.Proxy   = null;

                using (var response = request.GetResponse().GetResponseStream())
                    using (var zip = new ZipArchive(response, ZipArchiveMode.Read))
                    {
                        foreach (var entry in zip.Entries)
                        {
                            if (entry.FullName == "discord-rpc/win32-dynamic/bin/discord-rpc.dll")
                            {
                                using (var entryStream = entry.Open())
                                    using (var dll = File.Create(RPC_PATH))
                                    {
                                        entryStream.CopyTo(dll);
                                    }
                            }
                        }
                    }
            }
            catch (Exception e)
            {
                // don't bother showing a messagebox or anything
                Lazydata.ParrotData.UseDiscordRPC = false;
                JoystickHelper.Serialize();
                return;
            }
        }

        // calling Initialize / Shutdown if the library is already/hasn't been initialized is fine.
        if (Lazydata.ParrotData.UseDiscordRPC)
        {
            Initialize(APP_ID, IntPtr.Zero, false, null);
        }
        else
        {
            Shutdown();
        }
    }
Пример #23
0
        private async void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            cbGameList.ItemsSource = _library._gameNames;
            if (modList.Children.Count <= 0)
            {
                WebClient wc = new WebClient();

                byte[] modXML =
                    await wc.DownloadDataTaskAsync(
                        "https://github.com/nzgamer41/tpgamemods/releases/latest/download/mods.xml");

                List <ModData> mods = ReadFromXmlFile <List <ModData> >(modXML);
                if (File.Exists("InstalledMods.xml"))
                {
                    installedGUIDs = ReadFromXmlFile <List <string> >(File.ReadAllBytes("InstalledMods.xml"));
                }
                else
                {
                    installedGUIDs = new List <string>();
                }

                foreach (ModData m in mods)
                {
                    if (File.Exists("UserProfiles\\" + m.GameXML))
                    {
                        GameProfile gp  = JoystickHelper.DeSerializeGameProfile("UserProfiles\\" + m.GameXML, true);
                        string      url = "https://github.com/nzgamer41/tpgamemods/raw/master/" + m.GUID + ".zip";
                        ModControl  mc  = new ModControl(m.ModName, gp.GameName, m.Description, url, m.Creator, gp, this);
                        if (installedGUIDs.Contains(m.GUID))
                        {
                            mc.buttonDl.IsEnabled = false;
                        }
                        modList.Children.Add(mc);
                        modControls.Add(mc);
                    }
                }

                if (modList.Children.Count == 0)
                {
                    Application.Current.Windows.OfType <MainWindow>().Single().ShowMessage("You have no games added that have mods available!");
                }
            }
        }
        public SettingsControl(ContentControl control, Views.Library library)
        {
            InitializeComponent();

            // reload ParrotData from file
            JoystickHelper.DeSerialize();

            ChkUseSto0ZCheckBox.IsChecked = Lazydata.ParrotData.UseSto0ZDrivingHack;
            sTo0zZonePercent.Value        = Lazydata.ParrotData.StoozPercent;
            ChkSaveLastPlayed.IsChecked   = Lazydata.ParrotData.SaveLastPlayed;
            ChkUseDiscordRPC.IsChecked    = Lazydata.ParrotData.UseDiscordRPC;
            ChkConfirmExit.IsChecked      = Lazydata.ParrotData.ConfirmExit;
            ChkCheckForUpdates.IsChecked  = Lazydata.ParrotData.CheckForUpdates;
            ChkDownloadIcons.IsChecked    = Lazydata.ParrotData.DownloadIcons;
            ChkSilentMode.IsChecked       = Lazydata.ParrotData.SilentMode;
            ChkUiDisableHardwareAcceleration.IsChecked = Lazydata.ParrotData.UiDisableHardwareAcceleration;
            ChkFullAxisGas.IsChecked      = Lazydata.ParrotData.FullAxisGas;
            ChkFullAxisBrake.IsChecked    = Lazydata.ParrotData.FullAxisBrake;
            ChkReverseAxisGas.IsChecked   = Lazydata.ParrotData.ReverseAxisGas;
            ChkReverseAxisBrake.IsChecked = Lazydata.ParrotData.ReverseAxisBrake;
            textBoxExitGameKey.Text       = Lazydata.ParrotData.ExitGameKey;
            textBoxPauseGameKey.Text      = Lazydata.ParrotData.PauseGameKey;
            textBoxScoreSubmissionID.Text = Lazydata.ParrotData.ScoreSubmissionID;
            textBoxScoreCollapseKey.Text  = Lazydata.ParrotData.ScoreCollapseGUIKey;

            UiColour.ItemsSource         = new SwatchesProvider().Swatches.Select(a => a.Name).ToList();
            UiColour.SelectedItem        = Lazydata.ParrotData.UiColour;
            ChkUiDarkMode.IsChecked      = Lazydata.ParrotData.UiDarkMode;
            ChkUiHolidayThemes.IsChecked = Lazydata.ParrotData.UiHolidayThemes;

            if (App.IsPatreon())
            {
                UiPatreon.Visibility = Visibility.Visible;
            }
            else
            {
                UiPatreon.Visibility = Visibility.Collapsed;
            }

            _contentControl = control;
            _library        = library;
        }
Пример #25
0
        /// <summary>
        /// This updates the listbox when called
        /// </summary>
        public void ListUpdate(bool fromAddGame)
        {
            GameProfileLoader.LoadProfiles(true);
            gameList.SelectedIndex = _listIndex;
            _gameNames.Clear();
            gameList.Items.Clear();
            foreach (var gameProfile in GameProfileLoader.UserProfiles)
            {
                var item = new ListBoxItem
                {
                    Content = gameProfile.GameName + (gameProfile.Patreon ? " (Patreon Only)" : string.Empty),
                    Tag     = gameProfile
                };

                gameProfile.GameInfo = JoystickHelper.DeSerializeDescription(gameProfile.FileName);

                _gameNames.Add(gameProfile);
                gameList.Items.Add(item);

                if (fromAddGame || (Lazydata.ParrotData.SaveLastPlayed && gameProfile.GameName == Lazydata.ParrotData.LastPlayed))
                {
                    gameList.SelectedItem = item;
                    gameList.Focus();
                }
                else
                {
                    gameList.SelectedIndex = _listIndex;
                    gameList.Focus();
                }
            }

            if (gameList.Items.Count != 0)
            {
                return;
            }
            if (MessageBox.Show("Looks like you have no games set up. Do you want to add one now?",
                                "No games found", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
            {
                Application.Current.Windows.OfType <MainWindow>().Single().contentControl.Content = new AddGame(_contentControl, this);
            }
        }
Пример #26
0
        private void BtnStartGame(object sender, RoutedEventArgs e)
        {
            if (GameListComboBox.Items.Count == 0)
            {
                return;
            }

            var gameProfile = (GameProfile)((ComboBoxItem)GameListComboBox.SelectedItem).Tag;

            if (_parrotData.SaveLastPlayed)
            {
                _parrotData.LastPlayed = gameProfile.GameName;
                JoystickHelper.Serialize(_parrotData);
            }

            var testMenuExe = gameProfile.TestMenuIsExecutable ? gameProfile.TestMenuParameter : "";

            var testStr = gameProfile.TestMenuIsExecutable ? gameProfile.TestMenuExtraParameters : gameProfile.TestMenuParameter;

            ValidateAndRun(gameProfile, testStr, testMenuExe);
        }
Пример #27
0
        /// <summary>
        /// This updates the listbox when called
        /// </summary>
        private void ListUpdate()
        {
            gameList.Items.Clear();
            foreach (var gameProfile in GameProfileLoader.UserProfiles)
            {
                var item = new ListBoxItem
                {
                    Content = gameProfile.GameName,
                    Tag     = gameProfile
                };

                gameProfile.GameInfo = JoystickHelper.DeSerializeDescription(gameProfile.FileName);

                _gameNames.Add(gameProfile);
                gameList.Items.Add(item);

                if (MainWindow.ParrotData.SaveLastPlayed && gameProfile.GameName == MainWindow.ParrotData.LastPlayed)
                {
                    gameList.SelectedItem = item;
                }
                else
                {
                    gameList.SelectedIndex = 0;
                }
            }

            if (gameList.Items.Count != 0)
            {
                return;
            }
            if (MessageBox.Show("Looks like you have no games set up. Do you want to add one now?",
                                "No games found", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
            {
                Application.Current.Windows.OfType <MainWindow>().Single().contentControl.Content = new AddGame();
            }
            else
            {
                Application.Current.Shutdown();
            }
        }
Пример #28
0
        /// <summary>
        /// This button actually launches the game selected
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            if (gameList.Items.Count == 0)
            {
                return;
            }

            var gameProfile = (GameProfile)((ListBoxItem)gameList.SelectedItem).Tag;

            if (MainWindow.ParrotData.SaveLastPlayed)
            {
                MainWindow.ParrotData.LastPlayed = gameProfile.GameName;
                JoystickHelper.Serialize(MainWindow.ParrotData);
            }

            var testMenuExe = gameProfile.TestMenuIsExecutable ? gameProfile.TestMenuParameter : "";

            var testStr = gameProfile.TestMenuIsExecutable
                ? gameProfile.TestMenuExtraParameters
                : gameProfile.TestMenuParameter;

            ValidateAndRun(gameProfile, testStr, testMenuExe);
        }
Пример #29
0
        /// <summary>
        /// This button actually launches the game selected
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnLaunchGame(object sender, RoutedEventArgs e)
        {
            if (gameList.Items.Count == 0)
            {
                return;
            }

            var gameProfile = (GameProfile)((ListBoxItem)gameList.SelectedItem).Tag;

            if (Lazydata.ParrotData.SaveLastPlayed)
            {
                Lazydata.ParrotData.LastPlayed = gameProfile.GameName;
                JoystickHelper.Serialize();
            }

            if (ValidateAndRun(gameProfile, out var loader, out var dll))
            {
                var testMenu = ChkTestMenu.IsChecked;

                var gameRunning = new GameRunning(gameProfile, loader, dll, testMenu, false, false, this);
                Application.Current.Windows.OfType <MainWindow>().Single().contentControl.Content = gameRunning;
            }
        }
Пример #30
0
 /// <summary>
 /// Loads the settings data file.
 /// </summary>
 private static bool LoadSettingsData()
 {
     try
     {
         if (!File.Exists("SettingsData.xml"))
         {
             Console.WriteLine("Please use the UI to set config!");
             return(false);
         }
         _settingsData = JoystickHelper.DeSerialize();
         if (_settingsData == null)
         {
             _settingsData = new SettingsData();
             JoystickHelper.Serialize(_settingsData);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine($"Exception happened during loading SettingsData.xml! Generate new one by saving!{Environment.NewLine}{Environment.NewLine}{e}");
         return(false);
     }
     return(true);
 }