Example #1
0
        private void HostControl_Load(object sender, EventArgs e)
        {
            cboMethod.DataSource    = new BindingSource(Launcher.MethodOptions, null);
            cboMethod.DisplayMember = "Key";
            cboMethod.ValueMember   = "Value";


            cboHostIP.DataSource    = new BindingSource(Launcher.NetQuery.LocalIPsByNetwork, null);
            cboHostIP.DisplayMember = "Value";
            cboHostIP.ValueMember   = "Value";

            String hostIP;

            if (NetworkQuery.GetRadminHostIP() != null)
            {
                hostIP = NetworkQuery.GetRadminHostIP();
            }
            else if (NetworkQuery.GetExternalIP() != null)
            {
                hostIP = NetworkQuery.GetExternalIP();
            }
            else
            {
                hostIP = (string)Launcher.NetQuery.LocalIPsByNetwork.First().Value;
            }
            cboHostIP.SelectedValue = hostIP;
        }
Example #2
0
 private void txtOpponentIP_TextChanged(object sender, EventArgs e)
 {
     if (NetworkQuery.ValidateIPv4(txtOpponentIP.Text))
     {
         string hostIP;
         // if radmin ip not detected, changes host to external
         // falls back to local if external connection can not be made
         if (txtOpponentIP.Text.StartsWith("26"))
         {
             hostIP = NetworkQuery.GetRadminHostIP();
         }
         else
         {
             hostIP = NetworkQuery.GetExternalIP();
             if (hostIP == null)
             {
                 hostIP = (string)Launcher.NetQuery.LocalIPsByNetwork.First().Value;
             }
         }
         cboHostIP.SelectedValue = hostIP;
         GuessDelay(txtOpponentIP.Text);
     }
     else
     {
         txtOpponentIP.BackColor = Color.White;
     }
 }
        private void cboGameSelect_SelectedIndexChanged(object sender, EventArgs e)
        {
            string NullDir = Launcher.rootDir + "nulldc-1-0-4-en-win\\";
            string RomDir  = NullDir + "roms\\";

            bool ReferenceFound = false;

            if (Launcher.GamesJson != null && Launcher.GamesJson.Count > 0)
            {
                Launcher.Game SelectedGame = Launcher.GamesJson.Where(g => g.Name == cboGameSelect.Text).FirstOrDefault();
                if (SelectedGame != null)
                {
                    ReferenceFound = (SelectedGame.ReferenceUrl != null);
                }


                if ((string)cboGameSelect.Text != "" && (string)cboGameSelect.SelectedValue == "" && ReferenceFound)
                {
                    btnOffline.Enabled = false;
                    btnJoin.Enabled    = false;
                    btnHost.Enabled    = false;
                    DialogResult dialogResult = MessageBox.Show(
                        $"{cboGameSelect.Text} not installed.\nWould you like to retrieve it?",
                        "Missing ROM",
                        MessageBoxButtons.YesNo);
                    switch (dialogResult)
                    {
                    case (DialogResult.Yes):
                        Program.ShowConsoleWindow();
                        Console.Clear();
                        NetworkQuery.DownloadReferenceUrl(SelectedGame);
                        Program.HideConsoleWindow();
                        var previous = cboGameSelect.SelectedIndex;
                        ReloadRomList();
                        cboGameSelect.SelectedIndex = previous;
                        break;

                    case (DialogResult.No):
                        break;
                    }
                }
                else if (cboGameSelect.SelectedValue != null)
                {
                    btnOffline.Enabled    = true;
                    btnJoin.Enabled       = true;
                    btnHost.Enabled       = true;
                    Launcher.SelectedGame = cboGameSelect.SelectedValue.ToString();
                }
            }
        }
        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) { };
        }
        private void ReloadRomList()
        {
            cboGameSelect.SelectedIndexChanged -= new EventHandler(cboGameSelect_SelectedIndexChanged);
            var localRomDict = ScanRoms();

            if (File.Exists(Launcher.rootDir + "games.json") &&
                File.ReadAllText(Launcher.rootDir + "games.json").Contains("reference_url"))
            {
                localRomDict.Remove("");
                var jsonRomDict = ScanRomsFromJson();
                localRomDict.ToList().ForEach(r => jsonRomDict[r.Key] = r.Value);
                romDict = jsonRomDict;
            }
            else
            {
                romDict = ScanRoms();
            }

            cboGameSelect.DataSource    = new BindingSource(romDict, null);
            cboGameSelect.DisplayMember = "Key";
            cboGameSelect.ValueMember   = "Value";

            if (romDict.Count == 1 && romDict.First().Key == "")
            {
                btnOffline.Enabled    = false;
                btnHost.Enabled       = false;
                btnJoin.Enabled       = false;
                cboGameSelect.Enabled = false;
            }
            else if (romDict.Values.All(v => v == ""))
            {
                btnOffline.Enabled    = false;
                btnHost.Enabled       = false;
                btnJoin.Enabled       = false;
                cboGameSelect.Enabled = true;
            }
            else
            {
                try
                {
                    Launcher.SelectedGame       = romDict.Where(r => r.Value != "").First().Value;
                    cboGameSelect.SelectedValue = Launcher.SelectedGame;
                }
                catch (Exception)
                { }
                btnOffline.Enabled    = true;
                btnHost.Enabled       = true;
                btnJoin.Enabled       = true;
                cboGameSelect.Enabled = true;
            }

            if (Launcher.GamesJson != null)
            {
                var RootDir = Launcher.rootDir;

                var DataGamesJson = Launcher.GamesJson.Where(g => g.Root == "data" && g.ID.Contains("naomi")).ToList();

                if (!File.Exists(Path.Combine(Launcher.rootDir, "nulldc-1-0-4-en-win", "data", "naomi_bios.bin")) &&
                    File.ReadAllText(Launcher.rootDir + "games.json").Contains("reference_url"))
                {
                    if (DataGamesJson != null && DataGamesJson.Count() > 0)
                    {
                        List <Launcher.Game> dataEntries  = DataGamesJson.ToList();
                        DialogResult         dialogResult = MessageBox.Show(
                            "BIOS is not detected. Would you like to retrieve a reference set?",
                            "Missing BIOS",
                            MessageBoxButtons.YesNo);

                        if (dialogResult == DialogResult.Yes)
                        {
                            Program.ShowConsoleWindow();
                            Console.Clear();

                            foreach (Launcher.Game dataEntry in dataEntries)
                            {
                                NetworkQuery.DownloadReferenceUrl(dataEntry, false);
                                Console.WriteLine("");
                            }


                            Program.HideConsoleWindow();
                        }
                    }
                }

                DataGamesJson = Launcher.GamesJson.Where(g => g.Root == "data" && g.ID == "naomi_usa").ToList();
                if (DataGamesJson.Count() > 0 &&
                    !File.Exists(Path.Combine(Launcher.rootDir, "nulldc-1-0-4-en-win", "data", "naomi_boot.bin")) &&
                    !File.Exists(Path.Combine(Launcher.rootDir, "nulldc-1-0-4-en-win", "data", "naomi_boot.bin.inactive")) &&
                    File.ReadAllText(Launcher.rootDir + "games.json").Contains("reference_url"))
                {
                    List <Launcher.Game> dataEntries  = DataGamesJson.ToList();
                    DialogResult         dialogResult = MessageBox.Show(
                        "USA BIOS is not detected. Would you like to retrieve one?",
                        "Missing BIOS",
                        MessageBoxButtons.YesNo);

                    if (dialogResult == DialogResult.Yes)
                    {
                        Program.ShowConsoleWindow();
                        Console.Clear();

                        NetworkQuery.DownloadReferenceUrl(dataEntries.First(), false);

                        Program.HideConsoleWindow();
                    }
                }
            }
            cboGameSelect.SelectedIndexChanged += new EventHandler(cboGameSelect_SelectedIndexChanged);
            if ((string)cboGameSelect.SelectedValue == "")
            {
                btnOffline.Enabled = false;
                btnJoin.Enabled    = false;
                btnHost.Enabled    = false;
            }
        }