Exemplo n.º 1
0
 public void AssignActiveMapping()
 {
     try
     {
         ActiveGamePadMapping = mappings.GamePadMappings.Where(g => g.Default == true).ToList().First();
         System.Diagnostics.Debug.WriteLine("assigned " + ActiveGamePadMapping);
     }
     catch
     {
         ActiveGamePadMapping = mappings.GamePadMappings.First();
     }
 }
Exemplo n.º 2
0
        public static GamePadMappingList ReadMappingsFile()
        {
            string             path = Launcher.rootDir + "GamePadMappingList.xml";
            GamePadMappingList readMappingList;

            Launcher.RestoreGamePadMappings();

            try
            {
                XmlSerializer serializer =
                    new XmlSerializer(typeof(GamePadMappingList));
                FileStream fs = new FileStream(path, FileMode.Open);

                readMappingList = (GamePadMappingList)serializer.Deserialize(fs);
                fs.Close();
            }
            catch (Exception)
            {
                GamePadMapping defaultMapping = new GamePadMapping
                {
                    Name          = "Default",
                    IsUp          = "Up",
                    IsDown        = "Down",
                    IsLeft        = "Left",
                    IsRight       = "Right",
                    A             = "1",
                    Y             = "2",
                    Back          = "3",
                    B             = "4",
                    X             = "5",
                    Start         = "6",
                    LeftStick     = "Coin",
                    RightStick    = "Start",
                    LeftShoulder  = "",
                    RightShoulder = "",
                    LeftTrigger   = "",
                    RightTrigger  = "",
                    BigButton     = "",
                    Button11      = "Coin",
                };
                readMappingList = new GamePadMappingList();
                readMappingList.GamePadMappings.Add(defaultMapping);

                // generates a new file if it does not exist
                System.Xml.Serialization.XmlSerializer serializer =
                    new System.Xml.Serialization.XmlSerializer(typeof(GamePadMappingList));
                StreamWriter writer = new StreamWriter(path);
                serializer.Serialize(writer.BaseStream, readMappingList);
                writer.Close();
            }
            return(readMappingList);
        }
        private Form LaunchControllerSetup(bool ExitOnClose = false)
        {
            ControllerControl cc = new ControllerControl(controller);
            Form window          = new Form
            {
                Text            = "Controller Setup",
                TopLevel        = true,
                FormBorderStyle = FormBorderStyle.Fixed3D,
                MaximizeBox     = false,
                MinimizeBox     = false,
                ClientSize      = cc.Size,
                Icon            = nullDCNetplayLauncher.Properties.Resources.icons8_game_controller_26_ico
            };

            if (ExitOnClose)
            {
                window.FormClosing += (sender, e) =>
                {
                    Application.Exit();
                };
            }

            window.Controls.Add(cc);
            cc.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
            window.ShowDialog();

            if (EnableMapper || cc.OldEnableMapper && cc.SetupUnfinished)
            {
                cc.SetupUnfinished = false;
                Launcher.mappings  = GamePadMapping.ReadMappingsFile();
                try
                {
                    Launcher.ActiveGamePadMapping = Launcher.mappings.GamePadMappings.Where(g => g.Default == true).ToList().First();
                }
                catch
                {
                    Launcher.ActiveGamePadMapping = Launcher.mappings.GamePadMappings.First();
                }
                StartMapper();
            }

            return(window);
        }
Exemplo n.º 4
0
        public Launcher()
        {
            MethodOptions["Frame Limit"] = 0;
            MethodOptions["Audio Sync"]  = 1;

            mappings = GamePadMapping.ReadMappingsFile();;
            AssignActiveMapping();

            NetQuery = new NetworkQuery();

            GamesJson = null;

            LoadRegionSettings();

            try
            {
                string GameJsonPath = Launcher.rootDir + "games.json";
                var    GamesJsonTxt = File.ReadAllText(GameJsonPath);
                GamesJson = JsonConvert.DeserializeObject <List <Launcher.Game> >(GamesJsonTxt);
            }
            catch (Exception) { };
        }
        public void DeleteMapping(string mappingName)
        {
            if (Launcher.mappings.GamePadMappings.Count > 1)
            {
                var toDelete = Launcher.mappings.GamePadMappings.FirstOrDefault(p => p.Name == mappingName);
                Launcher.mappings.GamePadMappings.Remove(toDelete);

                var path = Launcher.rootDir + "GamePadMappingList.xml";
                System.Xml.Serialization.XmlSerializer serializer =
                    new System.Xml.Serialization.XmlSerializer(typeof(GamePadMappingList));
                StreamWriter writer = new StreamWriter(path);
                serializer.Serialize(writer.BaseStream, Launcher.mappings);
                writer.Close();
                Launcher.mappings                = GamePadMapping.ReadMappingsFile();
                cboGamePadMappings.DataSource    = Launcher.mappings.GamePadMappings;
                cboGamePadMappings.SelectedIndex = 0;
                if (Launcher.mappings.GamePadMappings.Count == 1)
                {
                    btnDeleteMapping.Enabled = false;
                }
            }
        }
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            cfgLines    = File.ReadAllLines(Launcher.rootDir + "nulldc-1-0-4-en-win\\nullDC.cfg");
            player1_old = cfgLines.Where(s => s.Contains("player1=")).ToList().First();
            backup_old  = cfgLines.Where(s => s.Contains("backup=")).ToList().First();
            player2_old = cfgLines.Where(s => s.Contains("player2=")).ToList().First();

            Dictionary <string, string> InputOptions = new Dictionary <string, string>();

            InputOptions[""]           = "";
            InputOptions["Keyboard"]   = "keyboard";
            InputOptions["Joystick 1"] = "joy1";

            cboPlayer1.DataSource    = new BindingSource(InputOptions, null);
            cboPlayer1.DisplayMember = "Key";
            cboPlayer1.ValueMember   = "Value";

            p1Entry     = player1_old.Split('=')[1];
            backupEntry = backup_old.Split('=')[1];
            p2Entry     = player2_old.Split('=')[1];

            cboPlayer1.SelectedValue = p1Entry;

            var windowSettings = Launcher.LoadWindowSettings();

            if (windowSettings[3] == 1)
            {
                rdoStartMax.Checked = true;
            }
            else if (windowSettings[0] == 1)
            {
                rdoCustomSize.Checked = true;
            }
            else
            {
                rdoDefault.Checked = true;
            }

            txtWindowX.Text = windowSettings[1].ToString();
            txtWindowY.Text = windowSettings[2].ToString();

            string launcherCfgPath = Launcher.rootDir + "launcher.cfg";
            string launcherText    = File.ReadAllText(launcherCfgPath);

            if (launcherText.Contains("enable_mapper=1") || NetplayLaunchForm.EnableMapper == true)
            {
                chkEnableMapper.Checked = true;
            }
            else
            {
                chkEnableMapper.Checked = false;
            }

            if (launcherText.Contains("custom_cfg=1"))
            {
                chkCustomCFG.Checked = true;
            }

            Dictionary <string, string> RegionOptions = new Dictionary <string, string>();

            RegionOptions["Japan"] = "japan";
            RegionOptions["USA"]   = "usa";

            cboRegion.DataSource    = new BindingSource(RegionOptions, null);
            cboRegion.DisplayMember = "Key";
            cboRegion.ValueMember   = "Value";

            var launcherCfgLines = File.ReadAllLines(launcherCfgPath);
            var host_fps_old     = launcherCfgLines.Where(s => s.Contains("host_fps=")).ToList().First();
            var guest_fps_old    = launcherCfgLines.Where(s => s.Contains("guest_fps=")).ToList().First();
            var region_old       = launcherCfgLines.Where(s => s.Contains("region=")).ToList().First();

            var hostFpsEntry  = host_fps_old.Split('=')[1];
            var guestFpsEntry = guest_fps_old.Split('=')[1];
            var regionEntry   = region_old.Split('=')[1];

            numHostFPS.Value = Convert.ToInt32(hostFpsEntry);

            try
            {
                Launcher.mappings             = GamePadMapping.ReadMappingsFile();
                Launcher.ActiveGamePadMapping = Launcher.mappings.GamePadMappings.Where(g => g.Default == true).ToList().First();
            }
            catch
            {
                Launcher.ActiveGamePadMapping = Launcher.mappings.GamePadMappings.First();
            }

            cboGamePadMappings.DataSource    = Launcher.mappings.GamePadMappings;
            cboGamePadMappings.DisplayMember = Name;

            cboGamePadMappings.SelectedItem = Launcher.ActiveGamePadMapping;

            cboRegion.SelectedValue = regionEntry;

            var us_bios_path = Path.Combine(Launcher.rootDir, "nulldc-1-0-4-en-win", "data", "naomi_boot.bin");

            if (!File.Exists(us_bios_path) && !File.Exists($"{us_bios_path}.inactive"))
            {
                cboRegion.Enabled = false;
            }

            lblVersion.Text = Application.ProductVersion;
        }