Ejemplo n.º 1
0
        public static List <DAT_Rom> Parse(string dat, int systemId)
        {
            List <DAT_Rom> list = new List <DAT_Rom>();

            // replace illegal characters
            dat = dat.Replace(" & ", " &amp; ").Replace(" and ", " &amp; ");

            // parse into an xml document
            XDocument xmlDoc = XDocument.Parse(dat);

            //var games = xmlDoc.Descendants("game");

            // iterate through each game
            foreach (XElement element in xmlDoc.Root.Elements("game"))
            {
                string nameString = (string)element.Attribute("name");

                DAT_Rom no = StringConverterNoIntro.ParseString(nameString);
                no.pid = systemId;

                no.cloneOf = (string)element.Attribute("cloneof");
                //no.Description = (string)element.Element("description");
                IEnumerable <XElement> roms = element.Elements("rom");

                foreach (XElement rom in roms)
                {
                    DAT_Rom n = new DAT_Rom
                    {
                        name      = no.name,
                        cloneOf   = no.cloneOf,
                        copyright = no.copyright,
                        country   = no.country,
                        crc       = (string)rom.Attribute("crc"),
                        //size = (string)rom.Attribute("size"),
                        md5  = (string)rom.Attribute("md5"),
                        sha1 = (string)rom.Attribute("sha1"),
                        developmentStatus = no.developmentStatus,
                        language          = no.language,
                        romName           = (string)rom.Attribute("name"),
                        pid           = no.pid,
                        otherFlags    = no.otherFlags,
                        publisher     = no.publisher,
                        description   = no.description,
                        year          = no.year,
                        datProviderId = 1,
                    };

                    list.Add(n);
                }
            }
            return(list);
        }
Ejemplo n.º 2
0
        private void LookupDAT()
        {
            // initial lookup to create the object
            var lookup = DATMerge.GetDAT(GameObj.CRC32);

            // psx
            if (GameObj.systemId == 9)
            {
                lookup = DATMerge.GetDATsBySN(9, GameObj.OtherFlags);
            }

            // saturn
            if (GameObj.systemId == 13)
            {
                lookup = DATMerge.GetDATsBySN(13, GameObj.OtherFlags);
            }


            if (lookup == null)
            {
                // no match found
            }
            else
            {
                tbDatData_Copyright.Text         = lookup.Copyright;
                tbDatData_Country.Text           = lookup.Country;
                tbDatData_Developer.Text         = lookup.Developer;
                tbDatData_DevelopmentStatus.Text = lookup.DevelopmentStatus;
                tbDatData_gameName.Text          = lookup.GameName;
                tbDatData_Language.Text          = lookup.Language;
                tbDatData_OtherFlags.Text        = lookup.OtherFlags;
                tbDatData_Publisher.Text         = lookup.Publisher;
                tbDatData_Year.Text = lookup.Year;

                // get other roms
                Roms = DAT_Rom.GetRoms(lookup.MD5);

                var staticItem = cmbRomChooser.Items[0];
                cmbRomChooser.Items.Clear();
                cmbRomChooser.Items.Add(staticItem);

                for (int i = 0; i < Roms.Count(); i++)
                {
                    ComboBoxItem cbi = new ComboBoxItem();
                    cbi.Content = Roms[i].romName;
                    cmbRomChooser.Items.Add(cbi);
                }
                cmbRomChooser.SelectedIndex = 0;
            }
        }
Ejemplo n.º 3
0
        public static List <DAT_Rom> Go()
        {
            List <DAT_Rom> l = new List <DAT_Rom>();

            // load SaturnGames.json
            string            jsonPath = AppDomain.CurrentDomain.BaseDirectory + @"..\..\Data\System\SaturnGames.json";
            string            txt      = File.ReadAllText(jsonPath);
            List <SaturnGame> games    = JsonConvert.DeserializeObject <List <SaturnGame> >(txt);

            // iterate through
            foreach (var g in games)
            {
                DAT_Rom dr = new DAT_Rom();
                dr.name          = g.Title;
                dr.country       = g.Country;
                dr.otherFlags    = g.SerialNumber;
                dr.datProviderId = 6;
                dr.romName       = g.Title + " - " + g.Version;
                dr.pid           = 17;

                if (g.Country == "JPN")
                {
                    dr.language = "J";
                }
                if (g.Country == "USA")
                {
                    dr.language = "En";
                }
                if (g.Country == "EUR")
                {
                    dr.language = "En";
                }

                // get year
                string[] yArr = g.Date.Split('/');
                if (yArr.Length == 3)
                {
                    dr.year = yArr[2];
                }

                l.Add(dr);
            }
            l.Distinct();
            return(l);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// process psxdatacenter DB for every system
        /// </summary>
        /// <returns></returns>
        public static List <DAT_Rom> Go()
        {
            // create empty list
            List <DAT_Rom> l = new List <DAT_Rom>();

            // get all psx games from debug database
            List <PSX_Games> games = PSX_Games.GetGames();

            // iterate through each game and parse the information into a new object
            foreach (var g in games)
            {
                DAT_Rom dr = new DAT_Rom();
                dr.country       = g.region;
                dr.datProviderId = 5;
                dr.developer     = g.developer;
                dr.language      = g.languages;
                dr.pid           = 10;
                dr.publisher     = g.publisher;
                dr.year          = g.year;
                dr.otherFlags    = g.serial;

                // names
                dr.romName = g.name;
                dr.name    = g.name
                             .Replace("[Disc 1]", "")
                             .Replace("[Disc 2]", "")
                             .Replace("[Disc 3]", "")
                             .Replace("[Disc 4]", "")
                             .Replace("[Disc 5]", "")
                             .Replace("[Disc 6]", "")
                             .Replace("[Disc 7]", "")
                             .Replace("[Disc 8]", "")
                             .Replace("[Disc 9]", "")
                             .Replace("[Disc 10]", "")
                             .Trim();

                l.Add(dr);
            }

            l.Distinct();
            return(l);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Parses the name string from a nointro entry
        /// </summary>
        /// <param name="nameString"></param>
        /// <returns></returns>
        public static DAT_Rom ParseString(string nameString)
        {
            DAT_Rom no = new DAT_Rom();

            // get name without any options (integrating demo flag if available)
            //no.Name = nameString.Split(new string[] { " ) " }, StringSplitOptions.RemoveEmptyEntries)[0].Trim() + ")";

            // remove any unwanted options from string
            string a = RemoveUnneededOptions(nameString);

            // process data contained in ()
            string[] d = a.ToString().Split('(', ')');

            if (d.Length > 0)
            {
                no.name = d[0].Trim();
            }


            if (d.Length > 1)
            {
                if (d[1].Length >= 3)
                {
                    no.country = d[1].Trim();
                }
            }

            if (d.Length > 2)
            {
                // iterate through remaining array of () data and determine values
                for (int i = 2; i < d.Length; i++)
                {
                    string f = d[i].Trim();

                    // check for language
                    if (IsLanguageFlag(f) == true)
                    {
                        no.language = f;
                        continue;
                    }

                    // check version
                    if (IsVersion(f) == true)
                    {
                        no.otherFlags = f;
                    }

                    // check development status
                    if (IsDevelopmenttStatus(f) == true)
                    {
                        no.developmentStatus = f;
                        continue;
                    }

                    // check copyright status
                    if (IsCopyrightStatus(f) == true)
                    {
                        no.copyright = f;
                        continue;
                    }



                    // Media Type - ignore for now

                    // Media Label - ignore for now
                }

                if (no.copyright == null)
                {
                    no.copyright = "Commercial";
                }
                if (no.copyright == "Unl")
                {
                    no.copyright = "Unlicensed";
                }
                if (no.developmentStatus == null)
                {
                    no.developmentStatus = "Release";
                }
                if (no.language == null)
                {
                    no.language = "en";
                }
            }

            // process other flags


            /*
             * // process dump info flags and other info contained in []
             * if (nameString.Contains("[") && nameString.Contains("]"))
             * {
             *  List<string> e = nameString.ToString().Split('[', ']').ToList();
             *  if (e.Count > 0)
             *  {
             *      StringBuilder sb = new StringBuilder();
             *      int count = 0;
             *      foreach (string s in e)
             *      {
             *          if (count == 0 || s == "")
             *          {
             *              count++;
             *              continue;
             *          }
             *
             *
             *          sb.Append("[");
             *          sb.Append(s);
             *          sb.Append("]");
             *          count++;
             *      }
             *
             *      no.OtherFlags = sb.ToString().Trim();
             *  }
             * }
             */
            return(no);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Parses the name string from a tosec entry
        /// </summary>
        /// <param name="nameString"></param>
        /// <returns></returns>
        public static DAT_Rom ParseString(string nameString)
        {
            DAT_Rom no = new DAT_Rom();

            // remove any unwanted options from string
            string a = RemoveUnneededOptions(nameString);

            // process data contained in ()
            string[] d = a.ToString().Split('(', ')');

            if (d.Length > 0)
            {
                no.name = d[0].Trim();
            }


            if (d.Length > 1)
            {
                if (d[1].Length > 3)
                {
                    no.year = d[1].Substring(0, 4);     // take only the year (first 4 characters)
                }
            }


            if (d.Length > 3)
            {
                no.publisher = d[3].Trim();
            }


            if (d.Length > 4)
            {
                // iterate through remaining array of () data and determine values
                for (int i = 4; i < d.Length; i++)
                {
                    string f = d[i];

                    // Check for system field
                    if (f == "Aladdin Deck Enhancer" ||
                        f == "PlayChoice-10" ||
                        f == "VS DualSystem" ||
                        f == "VS UniSystem")
                    {
                        // ignore for now
                        continue;
                    }

                    // check for country/region flag
                    if (IsCountryFlag(f) == true)
                    {
                        no.country = f;
                        continue;
                    }

                    // check for language
                    if (IsLanguageFlag(f) == true)
                    {
                        no.language = f;
                        continue;
                    }

                    // check copyright status
                    if (IsCopyrightStatus(f) == true)
                    {
                        no.copyright = f;
                        continue;
                    }

                    // check development status
                    if (IsDevelopmenttStatus(f) == true)
                    {
                        no.developmentStatus = f;
                        continue;
                    }

                    // Media Type - ignore for now

                    // Media Label - ignore for now
                }

                if (no.copyright == null)
                {
                    no.copyright = "Commercial";
                }
                if (no.developmentStatus == null)
                {
                    no.developmentStatus = "Release";
                }
                if (no.language == null)
                {
                    no.language = "en";
                }
            }

            // process dump info flags and other info contained in []
            if (nameString.Contains("[") && nameString.Contains("]"))
            {
                List <string> e = nameString.ToString().Split('[', ']').ToList();
                if (e.Count > 0)
                {
                    StringBuilder sb    = new StringBuilder();
                    int           count = 0;
                    foreach (string s in e)
                    {
                        if (count == 0 || s == "")
                        {
                            count++;
                            continue;
                        }


                        sb.Append("[");
                        sb.Append(s);
                        sb.Append("]");
                        count++;
                    }

                    no.otherFlags = sb.ToString().Trim();
                }
            }
            return(no);
        }