Ejemplo n.º 1
0
        private void btSaveIni_Click(object sender, EventArgs e)
        {
            if (null != slLogger)
            {
                slLogger.Trace(">> Save Game.ini Click");
            }
            String s1 = ClPbHelper.RemoveQuotes(tbGeneTitle.Text); // have to be not empty
            String s2 = ClPbHelper.RemoveQuotes(tbGeneDiscs.Text); // have to be not empty

            if ((!String.IsNullOrEmpty(s1)) && (!(String.IsNullOrEmpty(s2))))
            {
                String s3   = ClPbHelper.RemoveQuotes(tbGenePublisher.Text);
                String s3_5 = ClPbHelper.RemoveQuotes(tbGeneDeveloper.Text);
                String s4   = ClPbHelper.RemoveQuotes(tbGeneAlphaTitle.Text);
                int    i1   = (int)(nuGenePlayers.Value);
                int    i2   = (int)(nuGeneYear.Value);
                if (!String.IsNullOrEmpty(_currentFilePathIni))
                {
                    String sFileName = _currentFilePathIni;
                    try
                    {
                        Dictionary <String, String> dcTosave = new Dictionary <string, string>();
                        dcTosave.Add("title", s1);
                        dcTosave.Add("discs", s2);
                        dcTosave.Add("publisher", s3);
                        dcTosave.Add("developer", s3_5);
                        dcTosave.Add("alphatitle", s4);
                        dcTosave.Add("players", i1.ToString());
                        dcTosave.Add("year", i2.ToString());
                        if (null != newGame)
                        {
                            dcTosave.Add("automation", newGame.ABautomation);
                            dcTosave.Add("highres", newGame.ABhighres);
                            dcTosave.Add("imagetype", newGame.ABimagetype);
                            dcTosave.Add("memcard", newGame.ABmemcard);
                        }
                        ClPbHelper.SaveGameIni(sFileName, dcTosave, slLogger);

                        _currentFilePathIni        = sFileName;
                        lbCurrentGameIniFile.Text  = _currentFilePathIni;
                        btSaveIni.Enabled          = true;
                        btReloadTitleDiscs.Enabled = true;
                        btIniReload.Enabled        = true;

                        if (null == newGame)
                        {
                            newGame = new ClGameStructure("", true, true);
                        }
                        newGame.IniMissing = false;
                        newGame.Title      = s1;
                        newGame.Discs      = s2;
                        newGame.Publisher  = s3;
                        newGame.Developer  = s3_5;
                        newGame.Alphatitle = s4;
                        try
                        {
                            newGame.Players = i1.ToString();
                        }
                        catch (Exception ex)
                        {
                            //
                        }
                        try
                        {
                            newGame.Year = i2.ToString();
                        }
                        catch (Exception ex)
                        {
                            //
                        }
                    }
                    catch (Exception ex)
                    {
                        if (null != slLogger)
                        {
                            slLogger.Fatal(ex.Message);
                        }
                    }
                }
            }
            else
            {
                FlexibleMessageBox.Show("You have to enter at least Title and Discs to continue...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            if (null != slLogger)
            {
                slLogger.Trace("<< Save Game.ini Click");
            }
        }
Ejemplo n.º 2
0
 private void btLoadIni_Click(object sender, EventArgs e)
 {
     if (null != slLogger)
     {
         slLogger.Trace(">> Load Game.ini Click");
     }
     if (!String.IsNullOrEmpty(_currentFilePathIni))
     {
         ofdGeneLoadIni.InitialDirectory = _currentFilePathIni.Substring(0, _currentFilePathIni.LastIndexOf("\\"));
     }
     else
     if (Directory.Exists(_folderPath))
     {
         ofdGeneLoadIni.InitialDirectory = _folderPath;
     }
     if (DialogResult.OK == ofdGeneLoadIni.ShowDialog())
     {
         String sFileName = ofdGeneLoadIni.FileName;
         try
         {
             using (StreamReader sr = new StreamReader(sFileName))
             {
                 String s;
                 tbGeneDiscs.Clear();
                 tbGeneTitle.Clear();
                 tbGeneAlphaTitle.Clear();
                 tbGenePublisher.Clear();
                 tbGeneDeveloper.Clear();
                 nuGenePlayers.Value = (decimal)1;
                 nuGeneYear.Value    = (decimal)1995;
                 while ((s = sr.ReadLine()) != null)
                 {
                     if (s.StartsWith("Discs="))
                     {
                         tbGeneDiscs.Text = ClPbHelper.RemoveQuotes(s.Substring(6));
                     }
                     else
                     if (s.StartsWith("Title="))
                     {
                         tbGeneTitle.Text = ClPbHelper.RemoveQuotes(s.Substring(6));
                     }
                     else
                     if (s.StartsWith("Publisher="))
                     {
                         tbGenePublisher.Text = ClPbHelper.RemoveQuotes(s.Substring(10));
                     }
                     else
                     if (s.StartsWith("Developer="))
                     {
                         tbGeneDeveloper.Text = ClPbHelper.RemoveQuotes(s.Substring(10));
                     }
                     else
                     if (s.StartsWith("Players="))
                     {
                         try
                         {
                             nuGenePlayers.Value = (decimal)(int.Parse(ClPbHelper.RemoveQuotes(s.Substring(8))));
                         }
                         catch (Exception ex)
                         {
                             //
                         }
                     }
                     else
                     if (s.StartsWith("Year="))
                     {
                         try
                         {
                             nuGeneYear.Value = (decimal)(int.Parse(ClPbHelper.RemoveQuotes(s.Substring(5))));
                         }
                         catch (Exception ex)
                         {
                             //
                         }
                     }
                     else
                     if (s.StartsWith("AlphaTitle="))
                     {
                         tbGeneAlphaTitle.Text = ClPbHelper.RemoveQuotes(s.Substring(11));
                     }
                 }
             }
             if (null == newGame)
             {
                 newGame = new ClGameStructure("", true, true);
             }
             newGame.IniMissing = false;
             newGame.Title      = tbGeneTitle.Text;
             newGame.Discs      = tbGeneDiscs.Text;
             newGame.Publisher  = tbGenePublisher.Text;
             newGame.Developer  = tbGeneDeveloper.Text;
             newGame.Alphatitle = tbGeneAlphaTitle.Text;
             try
             {
                 newGame.Players = ((int)(nuGenePlayers.Value)).ToString();
             }
             catch (Exception ex)
             {
                 //
             }
             try
             {
                 newGame.Year = ((int)nuGeneYear.Value).ToString();
             }
             catch (Exception ex)
             {
                 //
             }
             _currentFilePathIni        = sFileName;
             lbCurrentGameIniFile.Text  = _currentFilePathIni;
             btSaveIni.Enabled          = true;
             btReloadTitleDiscs.Enabled = true;
             btIniReload.Enabled        = true;
         }
         catch (Exception ex)
         {
             if (null != slLogger)
             {
                 slLogger.Fatal(ex.Message);
             }
         }
     }
     if (null != slLogger)
     {
         slLogger.Trace("<< Load Game.ini Click");
     }
 }