private void AddOverviewConentToGame(string tabName, string folder, string file_content, string gameID)
        {
            // Get the files
            string fileToAdd = tabName + "-" + gameID + ".txt";

            fileToAdd = Path.Combine(folder, fileToAdd);
            int i = 1;

            while (File.Exists(fileToAdd))
            {
                i++;
                fileToAdd = tabName + "-" + gameID + "_" + i + ".txt";
                fileToAdd = Path.Combine(folder, fileToAdd);
            }
            try
            {
                status_sub_sub = string.Format("[Saving file at {0} for {1}]", fileToAdd, tabName);
                File.WriteAllText(fileToAdd, file_content);
                Trace.WriteLine(string.Format("->File saved for '{0}' at '{1}'", tabName, fileToAdd), "Detect And Download From TheGamesDB.net");

                // Add it as detect
                // Make sure this file isn;t exist for selected game
                MyNesDetectEntryInfo[] detects = MyNesDB.GetDetects("INFOS", gameID);
                bool found = false;
                if (detects != null)
                {
                    foreach (MyNesDetectEntryInfo inf in detects)
                    {
                        if (inf.Path == fileToAdd)
                        {
                            found = true; break;
                        }
                    }
                }
                if (!found)
                {
                    // Add it !
                    MyNesDetectEntryInfo newDetect = new MyNesDetectEntryInfo();
                    newDetect.GameID   = gameID;
                    newDetect.Path     = fileToAdd;
                    newDetect.Name     = Path.GetFileNameWithoutExtension(fileToAdd);
                    newDetect.FileInfo = "";
                    MyNesDB.AddDetect("INFOS", newDetect);
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError(string.Format("XXX Unable to save file for '{0}' at '{1}'; " + ex.Message, tabName, fileToAdd));
            }
        }
Example #2
0
 public void RefreshForEntry(string id)
 {
     currentID = id;
     Clear();
     if (id == "")
     {
         return;
     }
     // Get images for given game id
     detects = MyNesDB.GetDetects("MANUALS", id);
     toolStripButton_add.Enabled = true;
     if (detects == null)
     {
         return;
     }
     if (detects.Length > 0)
     {
         fileIndex = 0;
     }
     ShowCurrentFile();
 }
Example #3
0
 public void RefreshForEntry(string id)
 {
     currentID = id;
     Clear();
     if (id == "")
     {
         return;
     }
     // Get files for given game id
     detects = MyNesDB.GetDetects("INFOS", id);
     toolStripButton_addMoreFiles.Enabled = true;
     toolStripButton_get_tgdb.Enabled     = true;
     toolStripButton_newFile.Enabled      = true;
     if (detects == null)
     {
         return;
     }
     if (detects.Length > 0)
     {
         fileIndex = 0;
     }
     ShowCurrentFile();
 }
Example #4
0
        public void RefreshForEntry(string id)
        {
            currentID = id;
            Clear();
            if (id == "")
            {
                return;
            }
            // Get info for selected game
            MyNesDBEntryInfo inf = MyNesDB.GetEntry(id);

            label_name.Text = inf.Name;
            toolTip1.SetToolTip(label_name, inf.Name);
            label_size.Text = GetSize(inf.Size);
            toolTip1.SetToolTip(label_size, label_size.Text);
            label_path.Text = inf.Path;
            toolTip1.SetToolTip(label_path, inf.Path);
            rating1.rating  = inf.Rating;
            rating1.Enabled = true;
            // Add images
            List <MyNesDetectEntryInfo> detects = new List <MyNesDetectEntryInfo>();

            detects.AddRange(MyNesDB.GetDetects("SNAPS", id));
            detects.AddRange(MyNesDB.GetDetects("COVERS", id));
            images = detects.ToArray();
            if (images.Length > 0)
            {
                fileIndex = 0;
            }
            if (Program.Settings.LauncherAutoCycleImagesInGameTab)
            {
                timer1.Start();
            }
            ShowCurrentFile();
            // Load data infos
            DataSet ds = MyNesDB.GetEntryDataSet(currentID);

            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
                if (ds.Tables[0].Columns[i].ToString() != "Id" && ds.Tables[0].Columns[i].ToString() != "IsDB")
                {
                    string colName = ds.Tables[0].Columns[i].ToString();
                    string subText = ds.Tables[0].Rows[0][ds.Tables[0].Columns[i].ToString()].ToString().Replace("&apos;", "'");
                    listView1.Items.Add(colName);
                    if (colName == "Played")
                    {
                        if (subText == "0")
                        {
                            subText = Program.ResourceManager.GetString("Text_NeverPlayed");
                        }
                        else if (subText == "1")
                        {
                            subText = Program.ResourceManager.GetString("Text_OneTime");
                        }
                        else
                        {
                            subText = subText + " " + Program.ResourceManager.GetString("Text_Times");
                        }
                    }
                    else if (colName == "Play Time")
                    {
                        if (subText == "0")
                        {
                            subText = Program.ResourceManager.GetString("Text_NeverPlayed");
                        }
                        else
                        {
                            int val = 0;
                            int.TryParse(subText, out val);
                            subText = TimeSpan.FromSeconds(val).ToString();
                        }
                    }
                    else if (colName == "Size")
                    {
                        int val = 0;
                        int.TryParse(subText, out val);
                        subText = GetSize(val);
                    }
                    else if (colName == "Last Played")
                    {
                        DateTime time = (DateTime)ds.Tables[0].Rows[0][colName];
                        if (time != DateTime.MinValue)
                        {
                            subText = time.ToLocalTime().ToString();
                        }
                        else
                        {
                            subText = Program.ResourceManager.GetString("Text_NeverPlayed");
                        }
                    }

                    listView1.Items[listView1.Items.Count - 1].SubItems.Add(subText);
                }
            }
        }
        private void SEARCH()
        {
            int           matchedRoms = 0;
            DataSet       set         = MyNesDB.GetDataSet("GAMES");
            List <string> files       = new List <string>();

            foreach (string folder in foldersToSearch)
            {
                files.AddRange(Directory.GetFiles(folder, "*",
                                                  includeSubFolders ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly));
            }
            // Clear detected files first ?
            if (clearOldRomDetectedFiles)
            {
                MyNesDB.DeleteDetects(mode.ToString());
            }
            // Start the operation, loop through roms
            for (int i = 0; i < set.Tables[0].Rows.Count; i++)
            {
                string id        = set.Tables[0].Rows[i]["Id"].ToString();
                string entryName = set.Tables[0].Rows[i]["Name"].ToString().Replace("&apos;", "'");
                string entryPath = set.Tables[0].Rows[i]["Path"].ToString().Replace("&apos;", "'");
                // Decode path
                if (entryPath.StartsWith("("))
                {
                    // Decode
                    string[] pathCodes = entryPath.Split(new char[] { '(', ')' });
                    entryPath = pathCodes[2];
                }
                // Loop through files, look for files for this rom
                for (int j = 0; j < files.Count; j++)
                {
                    if (!extensions.Contains(Path.GetExtension(files[j]).ToLower()))
                    {
                        Trace.WriteLine("File ignored (no match for extension): " + files[j], "Detect Files");
                        // Useless file ...
                        files.RemoveAt(j);
                        j--;
                        continue;
                    }
                    if (FilterSearch(entryName, entryPath, files[j]))
                    {
                        matchedRoms++;
                        // Add it !
                        // Make sure this file isn;t exist for selected game
                        MyNesDetectEntryInfo[] detects = MyNesDB.GetDetects(mode.ToString(), id);
                        bool found = false;
                        if (detects != null)
                        {
                            foreach (MyNesDetectEntryInfo inf in detects)
                            {
                                if (inf.Path == files[j])
                                {
                                    found = true; break;
                                }
                            }
                        }
                        if (!found)
                        {
                            // Add it !
                            MyNesDetectEntryInfo newDetect = new MyNesDetectEntryInfo();
                            newDetect.GameID   = id;
                            newDetect.Path     = files[j];
                            newDetect.Name     = Path.GetFileNameWithoutExtension(files[j]);
                            newDetect.FileInfo = "";
                            MyNesDB.AddDetect(mode.ToString(), newDetect);
                        }
                        // To reduce process, delete detected file
                        if (dontAllowSameFileDetectedByMoreThanOneRom)
                        {
                            files.RemoveAt(j);
                            j--;
                        }

                        if (oneFilePerRom)
                        {
                            break;
                        }
                    }
                }
                // Update progress
                process = (i * 100) / set.Tables[0].Rows.Count;
                status  = string.Format(Program.ResourceManager.GetString("Status_Detecting") +
                                        " {0} / {1} [{2} " + Program.ResourceManager.GetString("Status_Detected") + "][{3} %]", (i + 1),
                                        set.Tables[0].Rows.Count, matchedRoms, process);
            }
            // Done !
            Trace.WriteLine("Detect process finished at " + DateTime.Now.ToLocalTime().ToString(), "Detect Files");
            finished = true;
            Trace.WriteLine("----------------------------");
            CloseWin();
        }
        private void AddTabConentFilesToRom(string tabName, string downloads_folder, List <string> links, string gameID,
                                            string tableName)
        {
            // Download the files
            Trace.WriteLine(string.Format("Downloading files for '{0}'", tabName), "Detect And Download From TheGamesDB.net");
            string NameOfSavedFiles = tabName + "-" + gameID;

            int           c          = 1;
            List <string> filesToAdd = new List <string>();

            foreach (string link in links)
            {
                // Try downloading
                try
                {
                    Trace.WriteLine(string.Format("Downloading file from '{0}'", link), "Detect And Download From TheGamesDB.net");

                    Uri      uri     = new Uri(link);
                    string[] splited = link.Split(new char[] { '/' });
                    string   ext     = Path.GetExtension(splited[splited.Length - 1]);
                    int      j       = 0;
                    while (File.Exists(Path.GetFullPath(downloads_folder + "\\" + NameOfSavedFiles + "(" + (j + 1).ToString() + ")" + ext)))
                    {
                        j++;
                    }

                    client.DownloadFile(uri, Path.GetFullPath(downloads_folder + "\\" + NameOfSavedFiles + "(" + (j + 1).ToString() + ")" + ext));

                    filesToAdd.Add(downloads_folder + "\\" + NameOfSavedFiles + "(" + (j + 1).ToString() + ")" + ext);

                    status_sub_sub = string.Format("[Downloading file {0} of {1} from {2}]", c, links.Count, link);
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(string.Format("XXX Unable to download file from '{0}'; {1}", link, ex.Message), "Detect And Download From TheGamesDB.net");
                }
                c++;
            }
            // Add it !
            for (int j = 0; j < filesToAdd.Count; j++)
            {
                // Make sure this file isn;t exist for selected game
                MyNesDetectEntryInfo[] detects = MyNesDB.GetDetects(tableName, gameID);
                bool found = false;
                if (detects != null)
                {
                    foreach (MyNesDetectEntryInfo inf in detects)
                    {
                        if (inf.Path == filesToAdd[j])
                        {
                            found = true; break;
                        }
                    }
                }
                if (!found)
                {
                    // Add it !
                    MyNesDetectEntryInfo newDetect = new MyNesDetectEntryInfo();
                    newDetect.GameID   = gameID;
                    newDetect.Path     = filesToAdd[j];
                    newDetect.Name     = Path.GetFileNameWithoutExtension(filesToAdd[j]);
                    newDetect.FileInfo = "";
                    MyNesDB.AddDetect(tableName, newDetect);
                }
            }
        }