コード例 #1
0
        public void ResetMoves(Move defaultMove)
        {
            var moves = RomFunctions.GetMovesAtLevel(Pokemon, Level, defaultMove);

            Move1 = moves[0];
            Move2 = moves[1];
            Move3 = moves[2];
            Move4 = moves[3];
        }
コード例 #2
0
        public void MatchImage_TestMethod()
        {
            Dictionary <string, Region> imageRegion = new Dictionary <string, Region>();
            var item = @"D:\User\Downloads\1 - Super Famicom Boxart1\4 Nin Shogi.jpg";

            imageRegion.Add(RomFunctions.GetFileName(item), RomFunctions.DetectRegion(item));
            string imageFoundPath;
            var    found = RomFunctions.MatchImages(new string[] { item }, imageRegion, "4-nin Shougi", out imageFoundPath);

            Assert.IsTrue(found);
        }
コード例 #3
0
        private void buttonClean_Click(object sender, EventArgs e)
        {
            textBoxId.Text           = "";
            textBoxDBName.Text       = "";
            textBoxDescription.Text  = "";
            textBoxPublisher.Text    = "";
            textBoxDeveloper.Text    = "";
            textBoxYearReleased.Text = "";
            textBoxRating.Text       = "";

            textBoxRomName.Text = textBoxFileName.Text.Trim().Replace(RomFunctions.GetFileExtension(textBoxFileName.Text), string.Empty);
        }
コード例 #4
0
        protected void CopyUpEvolutionsHelper(Action <Pokemon> bpAction, Action <Pokemon, Pokemon, bool> epAction)
        {
            foreach (var pk in ValidPokemons)
            {
                if (pk != null)
                {
                    pk.TemporaryFlag = false;
                }
            }

            //  Get evolution data.
            var dontCopyPokes = RomFunctions.GetBasicOrNoCopyPokemon(ValidPokemons);
            var middleEvos    = RomFunctions.GetMiddleEvolutions(ValidPokemons);

            foreach (var pk in dontCopyPokes)
            {
                bpAction(pk);
                pk.TemporaryFlag = true;
            }

            //  go "up" evolutions looking for pre-evos to do first
            foreach (var pk in ValidPokemons)
            {
                if (pk == null || pk.TemporaryFlag)
                {
                    continue;
                }

                //  Non-randomized pokes at this point must have
                //  a linear chain of single evolutions down to
                //  a randomized poke.
                var currentStack = new Stack <Evolution>();
                var ev           = pk.EvolutionsTo[0];
                while (!ev.From.TemporaryFlag)
                {
                    currentStack.Push(ev);
                    ev = ev.From.EvolutionsTo[0];
                }

                //  Now "ev" is set to an evolution from a Pokemon that has had
                //  the base action done on it to one that hasn't.
                //  Do the evolution action for everything left on the stack.
                epAction(ev.From, ev.To, !middleEvos.Contains(ev.To));
                ev.To.TemporaryFlag = true;
                while (currentStack.Count != 0)
                {
                    ev = currentStack.Pop();
                    epAction(ev.From, ev.To, !middleEvos.Contains(ev.To));
                    ev.To.TemporaryFlag = true;
                }
            }
        }
コード例 #5
0
        private void buttonCopyToRom_Click(object sender, EventArgs e)
        {
            var ext = RomFunctions.GetFileExtension(textBoxFileName.Text);

            if (ext == "")
            {
                textBoxRomName.Text = textBoxFileName.Text.Trim();
            }
            else
            {
                textBoxRomName.Text = textBoxFileName.Text.Trim().Replace(ext, string.Empty);
            }
        }
コード例 #6
0
        private void buttonRemove_Click(object sender, EventArgs e)
        {
            Platform emu  = (Platform)comboBoxChoosePlatform.SelectedItem;
            var      roms = RomBusiness.GetAll().Where
                                (x =>
                                x.Platform != null &&
                                x.Platform.Name == emu.Name &&
                                (
                                    (radioButtonBoxart.Checked && !string.IsNullOrEmpty(RomFunctions.GetRomPicture(x, Values.BoxartFolder))) ||
                                    (radioButtonTitle.Checked && !string.IsNullOrEmpty(RomFunctions.GetRomPicture(x, Values.TitleFolder))) ||
                                    (radioButtonGameplay.Checked && !string.IsNullOrEmpty(RomFunctions.GetRomPicture(x, Values.GameplayFolder)))
                                )
                                ).ToList();

            int successfulFind = 0;

            string type = radioButtonBoxart.Checked ? Values.BoxartFolder : radioButtonTitle.Checked ? Values.TitleFolder : Values.GameplayFolder;

            foreach (var rom in roms)
            {
                if (type == Values.BoxartFolder)
                {
                    if (File.Exists(RomFunctions.GetRomPicture(rom, Values.BoxartFolder)))
                    {
                        File.Delete(RomFunctions.GetRomPicture(rom, Values.BoxartFolder));
                    }

                    successfulFind++;
                }
                else if (type == Values.TitleFolder)
                {
                    if (File.Exists(RomFunctions.GetRomPicture(rom, Values.TitleFolder)))
                    {
                        File.Delete(RomFunctions.GetRomPicture(rom, Values.TitleFolder));
                    }

                    successfulFind++;
                }
                else if (type == Values.GameplayFolder)
                {
                    if (File.Exists(RomFunctions.GetRomPicture(rom, Values.GameplayFolder)))
                    {
                        File.Delete(RomFunctions.GetRomPicture(rom, Values.GameplayFolder));
                    }

                    successfulFind++;
                }
            }

            FormCustomMessage.ShowSuccess("Number of successful rom pictures removed: " + successfulFind);
        }
コード例 #7
0
        protected void ApplyCamelCaseNames()
        {
            var pokes = ValidPokemons;

            foreach (var pkmn in pokes)
            {
                if (pkmn == null)
                {
                    continue;
                }

                pkmn.Name = RomFunctions.CamelCase(pkmn.Name);
            }
        }
コード例 #8
0
        private void LoadPictures()
        {
            try
            {
                pictureBoxBoxart.Image   = null;
                pictureBoxTitle.Image    = null;
                pictureBoxGameplay.Image = null;

                if (dataGridView.SelectedRows.Count == 0)
                {
                    return;
                }

                Rom rom = (Rom)dataGridView.SelectedRows[0].Tag;

                if (rom == null)
                {
                    return;
                }

                if (rom.Platform == null)
                {
                    return;
                }

                var box      = RomFunctions.GetRomPicture(rom, Values.BoxartFolder);
                var title    = RomFunctions.GetRomPicture(rom, Values.TitleFolder);
                var gameplay = RomFunctions.GetRomPicture(rom, Values.GameplayFolder);

                if (!string.IsNullOrEmpty(box))
                {
                    pictureBoxBoxart.Image = Functions.CreateBitmap(box);
                }

                if (!string.IsNullOrEmpty(title))
                {
                    pictureBoxTitle.Image = Functions.CreateBitmap(title);
                }

                if (!string.IsNullOrEmpty(gameplay))
                {
                    pictureBoxGameplay.Image = Functions.CreateBitmap(gameplay);
                }
            }
            catch (Exception ex)
            {
                FormCustomMessage.ShowError(ex.Message);
            }
        }
コード例 #9
0
        private void buttonCopyDBName_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxDBName.Text.Trim()))
            {
                return;
            }

            string romName  = "";
            string fileName = "";

            RomFunctions.CopyDBName(textBoxDBName.Text, checkBoxKeepSuffix.Checked, textBoxRomName.Text, textBoxFileName.Text, out romName, out fileName);

            textBoxRomName.Text  = romName;
            textBoxFileName.Text = fileName;
        }
コード例 #10
0
        private void buttonCleanIncorrectRomPlatform_Click(object sender, EventArgs e)
        {
            if (comboBoxPlatform.Text == "" || comboBoxPlatform.Text == "none")
            {
                FormCustomMessage.ShowError("Select a platform");
            }

            var json = RomFunctions.GetPlatformJson(comboBoxPlatform.Text);

            if (json == "")
            {
                return;
            }

            var        roms       = RomBusiness.GetAll(PlatformBusiness.Get(comboBoxPlatform.Text));
            int        count      = 0;
            List <Rom> romsUpdate = new List <Rom>();

            foreach (var rom in roms)
            {
                if (string.IsNullOrEmpty(rom.Id))
                {
                    continue;
                }

                if (!json.Contains("\"id\": " + rom.Id + ","))
                {
                    rom.Id           = "";
                    rom.Name         = rom.FileNameNoExt;
                    rom.DBName       = "";
                    rom.Description  = "";
                    rom.IdLocked     = false;
                    rom.Publisher    = "";
                    rom.YearReleased = "";
                    rom.Developer    = "";
                    rom.Rating       = 0;

                    romsUpdate.Add(rom);

                    count++;
                    Updated = true;
                }
            }

            RomBusiness.SetRom(romsUpdate);

            FormCustomMessage.ShowSuccess("Roms updated successfully! " + count.ToString() + " roms cleaned");
        }
コード例 #11
0
 private void buttonGetMAMEName_Click(object sender, EventArgs e)
 {
     try
     {
         textBoxRomName.Text = RomFunctions.GetMAMENameFromCSV(RomFunctions.GetFileNameNoExtension(textBoxFileName.Text));
     }
     catch (Exception ex)
     {
         //FormWait.CloseWait();
         FormCustomMessage.ShowError(ex.Message);
     }
     finally
     {
         //FormWait.CloseWait();
     }
 }
コード例 #12
0
        private void toolStripButtonAddRom_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog open = new OpenFileDialog();
                open.InitialDirectory = Environment.CurrentDirectory;

                open.Filter = "Roms | *.zip;*.smc;*.fig;*.gba;*.gbc;*.gb;*.pce;*.n64;*.smd;*.sms;*.ccd;*.cue;*.bin;*.iso;*.gdi;*.cdi|" +
                              "Zip | *.zip|" +
                              "CD | *.cue|" +
                              "CD | *.ccd|" +
                              "CD ISO | *.iso|" +
                              "CD Image | *.bin|" +
                              "Dreamcast Image | *.cdi;*.gdi|" +
                              "Snes | *.smc|" +
                              "Snes | *.fig|" +
                              "GBA | *.gba|" +
                              "GBC | *.gbc|" +
                              "GB | *.gb|" +
                              "PC Engine | *.pce|" +
                              "N64 | *.n64|" +
                              "Mega Drive | *.smd|" +
                              "Master System | *.sms|" +
                              "All | *.*";
                open.Multiselect = true;

                if (open.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }

                if (open.FileNames.Length == 0)
                {
                    return;
                }

                Platform platform = null;
                FormChoose.ChoosePlatform(out platform);
                RomFunctions.AddRomsFiles(platform, open.FileNames);

                FilterRoms();
            }
            catch (Exception ex)
            {
                FormCustomMessage.ShowError(ex.Message);
            }
        }
コード例 #13
0
        public static bool RescanRoms(Platform platform)
        {
            if (string.IsNullOrEmpty(platform.DefaultRomPath) || string.IsNullOrEmpty(platform.DefaultRomExtensions))
            {
                return(false);
            }

            var added           = RomFunctions.AddRomsFromDirectory(platform, platform.DefaultRomPath);
            var addedAnyRomPack = RomFunctions.AddRomPacksFromDirectory(platform, platform.DefaultRomPath);

            if (added || addedAnyRomPack)
            {
                XML.SaveXmlRoms(platform.Name);
            }

            return(added || addedAnyRomPack);
        }
コード例 #14
0
        private void buttonUpdateAllRomsNames_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBoxPlatform.Text == "" || comboBoxPlatform.Text == "none")
                {
                    FormCustomMessage.ShowError("Select a platform");
                }

                Platform   platform   = PlatformBusiness.Get(comboBoxPlatform.Text);
                var        roms       = RomBusiness.GetAll(platform);
                int        count      = 0;
                List <Rom> romsUpdate = new List <Rom>();

                foreach (var rom in roms)
                {
                    var name = RomFunctions.GetMAMENameFromCSV(rom.FileNameNoExt);

                    if (name == "")
                    {
                        continue;
                    }

                    if (rom.Name != name)
                    {
                        rom.Name = name;
                        romsUpdate.Add(rom);
                        count++;
                    }
                }

                RomBusiness.SetRom(romsUpdate);
                FormCustomMessage.ShowSuccess("Rom names updated successfully! Total:" + count.ToString());
                Updated = true;
            }
            catch (Exception ex)
            {
                //FormWait.CloseWait();
                FormCustomMessage.ShowError(ex.Message);
            }
            finally
            {
                //FormWait.CloseWait();
            }
        }
コード例 #15
0
        private void buttonShowMissingRoms_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBoxPlatform.Text == "" || comboBoxPlatform.Text == "none")
                {
                    FormCustomMessage.ShowError("Select a platform");
                }

                Platform platform = PlatformBusiness.Get(comboBoxPlatform.Text);
                var      json     = RomFunctions.GetPlatformJson(comboBoxPlatform.Text);

                if (string.IsNullOrEmpty(json))
                {
                    FormCustomMessage.ShowError("Json not found. Sync platform first");
                }

                var games = APIFunctions.GetGamesListByPlatform(platform.Id, json, platform.Name);
                var roms  = RomBusiness.GetAll(platform);

                StringBuilder builder = new StringBuilder("");

                foreach (var game in games)
                {
                    if (!roms.Any(x => x.Id == game.Id))
                    {
                        builder.Append(game.Id + "-" + game.DBName + Environment.NewLine);
                    }
                }

                FormInfo info = new FormInfo(builder.ToString());
                info.Show();

                Updated = true;
            }
            catch (Exception ex)
            {
                //FormWait.CloseWait();
                FormCustomMessage.ShowError(ex.Message);
            }
            finally
            {
                //FormWait.CloseWait();
            }
        }
コード例 #16
0
        private void deleteRomToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridView.SelectedRows.Count == 0)
                {
                    return;
                }

                DataGridViewRow row = dataGridView.SelectedRows[0];
                Rom             rom = (Rom)row.Tag;

                var message = string.Format("Do you want to remove \"{0}\" ? (Remove to recycle bin)", rom.Name);

                var result = MessageBox.Show(message, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result.ToString() == "No")
                {
                    return;
                }

                Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(rom.Platform.DefaultRomPath + "\\" + rom.FileName,
                                                                   Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
                                                                   Microsoft.VisualBasic.FileIO.RecycleOption.SendToRecycleBin);

                dataGridView.Rows.Remove(row);
                RomBusiness.DeleteRom(rom);
                RomFunctions.RemoveRomPics(rom);
                FilteredRoms.Remove(rom);
                labelTotalRomsCount.Text = FilteredRoms.Count.ToString();
            }
            catch (OperationCanceledException ioex)
            {
                return;
            }
            catch (Exception ex)
            {
                FormCustomMessage.ShowError(ex.Message);
            }
        }
コード例 #17
0
        protected override void SetForm()
        {
            base.SetForm();
            DataGridViewRow row      = dataGridView.SelectedRows[0];
            Platform        platform = (Platform)row.Tag;

            if (platform == null)
            {
                dataGridView.ClearSelection();
                return;
            }

            string iconPath = RomFunctions.GetPlatformPicture(((Platform)dataGridView.SelectedRows[0].Tag).Name);

            if (!string.IsNullOrEmpty(iconPath))
            {
                pictureBoxIcon.Load(iconPath);
            }

            checkBoxUseRetroarch.Checked      = platform.UseRetroarch;
            buttonSelectCore.Enabled          = platform.UseRetroarch;
            comboBoxPlatformsDB.SelectedValue = platform.Id == "" ? "0" : platform.Id;
            textBoxPlatformName.Text          = platform.Name;
            buttonColor.BackColor             = platform.Color;
            checkBoxShowInFilters.Checked     = platform.ShowInFilter;
            checkBoxShowInLinksList.Checked   = platform.ShowInList;
            textBoxDefaultRomPath.Text        = platform.DefaultRomPath;
            textBoxDefaultRomExtensions.Text  = platform.DefaultRomExtensions;
            defaultEmulator          = platform.DefaultEmulator;
            checkBoxArcade.Checked   = platform.Arcade;
            checkBoxConsole.Checked  = platform.Console;
            checkBoxHandheld.Checked = platform.Handheld;
            checkBoxCD.Checked       = platform.CD;
            emulators = platform.Emulators;
            dataGridViewEmulators.Rows.Clear();
            textBoxPlatformName.Enabled = false;
            FillGridEmulators();
        }
コード例 #18
0
        private void pictureBoxGameplay_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            try
            {
                if (dataGridView.SelectedRows.Count == 0)
                {
                    return;
                }

                Rom rom = (Rom)dataGridView.SelectedRows[0].Tag;
                ProcessStartInfo sInfo = new ProcessStartInfo(RomFunctions.GetRomPicture(rom, Values.GameplayFolder));
                Process.Start(sInfo);
            }
            catch (Exception ex)
            {
                FormCustomMessage.ShowError(ex.Message);
            }
        }
コード例 #19
0
        private void comboBoxPlatform_SelectedIndexChanged(object sender, EventArgs e)
        {
            labelId.Text           = "-";
            labelGenre.Text        = "-";
            labelPublisher.Text    = "-";
            labelDeveloper.Text    = "-";
            labelDescription.Text  = "-";
            labelYearReleased.Text = "-";
            labelBoxart.Text       = "-";
            labelTitle.Text        = "-";
            labelGameplay.Text     = "-";

            Roms.Clear();
            Roms.AddRange(RomBusiness.GetAll().Where(r => r.Platform != null && r.Platform.Name == comboBoxPlatform.Text).ToList());

            labelId.Text           = Roms.Where(x => string.IsNullOrEmpty(x.Id)).Count().ToString();
            labelGenre.Text        = Roms.Where(x => x.Genre == null).Count().ToString();
            labelPublisher.Text    = Roms.Where(x => string.IsNullOrEmpty(x.Publisher)).Count().ToString();
            labelDeveloper.Text    = Roms.Where(x => string.IsNullOrEmpty(x.Developer)).Count().ToString();
            labelDescription.Text  = Roms.Where(x => string.IsNullOrEmpty(x.Description)).Count().ToString();
            labelYearReleased.Text = Roms.Where(x => string.IsNullOrEmpty(x.YearReleased)).Count().ToString();

            var boxartPictures   = RomFunctions.GetRomPicturesByPlatform(comboBoxPlatform.Text, Values.BoxartFolder);
            var titlePictures    = RomFunctions.GetRomPicturesByPlatform(comboBoxPlatform.Text, Values.TitleFolder);
            var gameplayPictures = RomFunctions.GetRomPicturesByPlatform(comboBoxPlatform.Text, Values.GameplayFolder);

            var romsList = Roms.Select(x => x.Name).ToList();

            missingBoxartPictures   = romsList.Except(boxartPictures).ToList();
            missingTitlePictures    = romsList.Except(titlePictures).ToList();
            missingGameplayPictures = romsList.Except(gameplayPictures).ToList();

            labelBoxart.Text   = missingBoxartPictures.Count().ToString();
            labelTitle.Text    = missingTitlePictures.Count().ToString();
            labelGameplay.Text = missingGameplayPictures.Count().ToString();
        }
コード例 #20
0
        private void buttonSelectCore_Click(object sender, EventArgs e)
        {
            var            config = ConfigBusiness.GetFolder(Folder.Retroarch);
            OpenFileDialog dialog = new OpenFileDialog();

            if (!string.IsNullOrEmpty(config))
            {
                config = config + "\\" + "cores";

                if (Directory.Exists(config))
                {
                    dialog.InitialDirectory = config;
                }
            }

            dialog.Filter = "Libreto Core | *.dll";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var corename = RomFunctions.GetFileName(dialog.FileName);
                textBoxCommand.Text = Values.RetroarchCommand.Replace("[CORE]", corename);
                textBoxEmuName.Text = RomFunctions.FillEmuName(textBoxEmuName.Text, textBoxPath.Text, checkBoxUseRetroarch.Checked, corename);
            }
        }
コード例 #21
0
        private void buttonRemoveUnused_Click(object sender, EventArgs e)
        {
            Platform emu            = (Platform)comboBoxChoosePlatform.SelectedItem;
            var      roms           = RomBusiness.GetAll().Where(x => x.Platform != null && x.Platform.Name == emu.Name).ToList();
            var      path           = Environment.CurrentDirectory + "\\" + Values.PlatformsPath + "\\" + emu.Name + "\\";
            int      successfulFind = 0;

            var images = new List <string>();

            if (radioButtonBoxart.Checked)
            {
                images = RomFunctions.GetRomPicturesByPlatformWithExt(comboBoxChoosePlatform.Text, Values.BoxartFolder);
                path  += Values.BoxartFolder + "\\";
            }
            else if (radioButtonTitle.Checked)
            {
                images = RomFunctions.GetRomPicturesByPlatformWithExt(comboBoxChoosePlatform.Text, Values.TitleFolder);
                path  += Values.TitleFolder + "\\";
            }
            else if (radioButtonGameplay.Checked)
            {
                images = RomFunctions.GetRomPicturesByPlatformWithExt(comboBoxChoosePlatform.Text, Values.GameplayFolder);
                path  += Values.GameplayFolder + "\\";
            }

            foreach (var image in images)
            {
                if (!roms.Any(x => x.FileNameNoExt.ToLower() == RomFunctions.GetFileNameNoExtension(image).ToLower()))
                {
                    File.Delete(path + image);
                    successfulFind++;
                }
            }

            FormCustomMessage.ShowSuccess("Number of successful unused rom pictures removed: " + successfulFind);
        }
コード例 #22
0
        private void toolStripButtonRemoveInvalid_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBoxPlatform.SelectedValue != null)
                {
                    RomFunctions.RemoveInvalidRomsEntries(PlatformBusiness.Get(comboBoxPlatform.SelectedValue.ToString()));
                }
                else
                {
                    RomFunctions.RemoveInvalidRomsEntries();
                }

                FilterRoms();
            }
            catch (OperationCanceledException ioex)
            {
                return;
            }
            catch (Exception ex)
            {
                FormCustomMessage.ShowError(ex.Message);
            }
        }
コード例 #23
0
        private void buttonSync_Click(object sender, EventArgs e)
        {
            try
            {
                comboBoxPlatform.Enabled = false;
                buttonSync.Enabled       = false;
                platformId        = comboBoxPlatform.SelectedValue.ToString();
                textBoxLog.Text   = "";
                progressBar.Value = 0;

                if (checkBoxBasicSync.Checked)
                {
                    notSyncedRoms = Roms.Where(x => !x.IdLocked && (string.IsNullOrEmpty(x.Id))).ToList();
                }
                else
                {
                    notSyncedRoms = Roms.Where(x => !x.IdLocked && (string.IsNullOrEmpty(x.Id) || string.IsNullOrEmpty(x.YearReleased) || string.IsNullOrEmpty(x.DBName))).ToList();
                }

                LogMessage("GETTING GAMES LIST...");

                Updated = true;

                if (comboBoxPlatform.SelectedValue == null || string.IsNullOrEmpty(comboBoxPlatform.SelectedValue.ToString()) || comboBoxPlatform.SelectedValue.ToString() == "0")
                {
                    FormCustomMessage.ShowInfo(string.Format("The platform {0} doesn't have an associated TheGamesDB.net Id. Update the platform Id in the Platform screen first.", comboBoxPlatform.SelectedText));
                    comboBoxPlatform.Enabled = true;
                    buttonSync.Enabled       = true;
                    return;
                }

                var json = RomFunctions.GetPlatformJson(comboBoxPlatform.Text);

                games = APIFunctions.GetGamesListByPlatform(comboBoxPlatform.SelectedValue.ToString(), json, comboBoxPlatform.Text);

                if (games == null)
                {
                    FormCustomMessage.ShowError("An Error ocurred");
                    comboBoxPlatform.Enabled = true;
                    buttonSync.Enabled       = true;
                    return;
                }

                LogMessage(string.Format("{0} games found at online DB for the {1} platform", games.Count, comboBoxPlatform.Text));

                progressBar.Maximum = notSyncedRoms.Count * 2;

                new Thread(() =>
                {
                    if (radioButtonSyncAll.Checked)
                    {
                        //threadSetIdAndYear.Start();
                        SetIdAndYear();
                    }

                    int count  = 0;
                    int count2 = 0;
                    int count3 = 0;

                    count = syncRomsCount;

                    if (!checkBoxBasicSync.Checked)
                    {
                        if (radioButtonSyncAll.Checked)
                        {
                            //threadSetOtherProperties.Start();
                            SetOtherProperties();
                            count2 = syncRomsCount;
                        }

                        SetPictures();
                        count3 = syncRomsCount;
                    }

                    progressBar.Invoke((MethodInvoker) delegate
                    {
                        progressBar.Value = progressBar.Maximum;
                    });

                    LogMessage(count.ToString() + " roms Id/Year updated successfully!");
                    LogMessage(count2.ToString() + " roms details updated successfully!");
                    LogMessage(count3.ToString() + " roms images updated successfully!");

                    FormCustomMessage.ShowSuccess(count.ToString() + " roms Id/Year updated successfully!" + Environment.NewLine +
                                                  count2.ToString() + " roms details updated successfully!" + Environment.NewLine +
                                                  count3.ToString() + " roms images updated successfully!"
                                                  );

                    comboBoxPlatform_SelectedIndexChanged(sender, e);

                    comboBoxPlatform.Invoke((MethodInvoker) delegate
                    {
                        comboBoxPlatform.Enabled = true;
                    });

                    buttonSync.Invoke((MethodInvoker) delegate
                    {
                        buttonSync.Enabled = true;
                    });
                }).Start();
            }
            catch (Exception ex)
            {
                FormCustomMessage.ShowError(ex.Message);
                buttonStopProcess_Click(null, e);
                textBoxLog.Text = "";
            }
        }
コード例 #24
0
        private void SetIdAndYear()
        {
            syncRomsCount = 0;

            bool updated = false;

            ThreadStopped = false;
            bool       found            = false;
            string     gameNameToDelete = string.Empty;
            List <Rom> romList          = new List <Rom>();

            foreach (var rom in notSyncedRoms)
            {
                if (found && !string.IsNullOrEmpty(gameNameToDelete))
                {
                    games.RemoveAll(x => x.DBName == gameNameToDelete);
                    gameNameToDelete = string.Empty;
                }

                if (progressBar.Maximum > progressBar.Value)
                {
                    labelProgress.Invoke((MethodInvoker) delegate
                    {
                        progressBar.Value++;
                    });
                }

                if (StopThread)
                {
                    StopThread = false;
                    RomBusiness.SetRom(romList);
                    Thread.CurrentThread.Abort();
                    comboBoxPlatform_SelectedIndexChanged(null, new EventArgs());
                }

                var romName = RomFunctions.TrimRomName(rom.Name);
                found = false;

                foreach (var game in games)
                {
                    var gameName = RomFunctions.TrimRomName(game.DBName);

                    if (romName == gameName)
                    {
                        gameNameToDelete = game.DBName;
                        found            = true;

                        if (string.IsNullOrEmpty(rom.Id) && !string.IsNullOrEmpty(game.Id))
                        {
                            rom.Id  = game.Id;
                            updated = true;
                        }

                        if (string.IsNullOrEmpty(rom.YearReleased) && !string.IsNullOrEmpty(game.YearReleased))
                        {
                            rom.YearReleased = game.YearReleased;
                            updated          = true;
                        }

                        if (string.IsNullOrEmpty(rom.DBName) && !string.IsNullOrEmpty(game.DBName))
                        {
                            rom.DBName = game.DBName;
                            updated    = true;
                        }

                        if (updated)
                        {
                            syncRomsCount++;
                            LogMessage("ID AND YEAR SET - " + rom.Name);
                            romList.Add(rom);
                            updated = false;
                        }

                        break;
                    }
                }

                if (!found)
                {
                    LogMessage("NOT FOUND - " + rom.Name);

                    if (!checkBoxBasicSync.Checked)
                    {
                        LogMessage("TRYING BY NAME - " + rom.Name);
                        var gameName = Functions.RemoveSubstring(rom.Name, '(', ')');
                        gameName = Functions.RemoveSubstring(gameName, '[', ']').Trim();
                        string acessos = "";
                        var    game    = APIFunctions.GetGameByName(platformId, gameName, out acessos);

                        if (game == null)
                        {
                            LogMessage("REALLY NOT FOUND - " + rom.Name);
                            continue;
                        }

                        found = true;

                        if (string.IsNullOrEmpty(rom.Id) && !string.IsNullOrEmpty(game.Id))
                        {
                            rom.Id  = game.Id;
                            updated = true;
                        }

                        if (string.IsNullOrEmpty(rom.YearReleased) && !string.IsNullOrEmpty(game.YearReleased))
                        {
                            rom.YearReleased = game.YearReleased;
                            updated          = true;
                        }

                        if (string.IsNullOrEmpty(rom.DBName) && !string.IsNullOrEmpty(game.DBName))
                        {
                            rom.DBName = game.DBName;
                            updated    = true;
                        }

                        if (updated)
                        {
                            syncRomsCount++;
                            LogMessage("ID AND YEAR SET - " + rom.Name);
                            romList.Add(rom);
                            updated = false;
                        }
                    }
                }
            }

            RomBusiness.SetRom(romList);
            ThreadStopped = true;
        }
コード例 #25
0
 public string CamelCase() => RomFunctions.CamelCase(ToString());
コード例 #26
0
 private void buttonCopyToFile_Click(object sender, EventArgs e)
 {
     textBoxFileName.Text = textBoxRomName.Text.Trim() + RomFunctions.GetFileExtension(textBoxFileName.Text);
 }
コード例 #27
0
        public static void Fill()
        {
            platforms = new Dictionary <string, Platform>();

            if (!Directory.Exists(Values.PlatformsPath))
            {
                Directory.CreateDirectory(Values.PlatformsPath);
            }

            var platformnames = Directory.GetDirectories(Values.PlatformsPath);

            foreach (var platformname in platformnames)
            {
                var name         = platformname.Replace(Values.PlatformsPath + "\\", "");
                var platformNode = XML.GetPlatformNode(name);

                if (platformNode == null)
                {
                    continue;
                }

                Platform platform = new Platform();

                platform.Id                   = Functions.GetXmlAttribute(platformNode, "Id");
                platform.Name                 = Functions.GetXmlAttribute(platformNode, "Name");
                platform.ShowInList           = Convert.ToBoolean(Functions.GetXmlAttribute(platformNode, "ShowInList"));
                platform.ShowInFilter         = Convert.ToBoolean(Functions.GetXmlAttribute(platformNode, "ShowInFilter"));
                platform.DefaultRomPath       = Functions.GetXmlAttribute(platformNode, "DefaultRomPath");
                platform.DefaultRomExtensions = Functions.GetXmlAttribute(platformNode, "DefaultRomExtensions");
                platform.DefaultEmulator      = Functions.GetXmlAttribute(platformNode, "DefaultEmulator");
                platform.Color                = Color.FromArgb(Convert.ToInt32(Functions.GetXmlAttribute(platformNode, "Color")));
                string icon = RomFunctions.GetPlatformPicture(platform.Name);
                platform.Icon = Functions.CreateBitmap(icon);
                string useRetroarch = Functions.GetXmlAttribute(platformNode, "UseRetroarch");
                platform.UseRetroarch = string.IsNullOrEmpty(useRetroarch) ? false : Convert.ToBoolean(useRetroarch);

                string arcade = Functions.GetXmlAttribute(platformNode, "Arcade");
                platform.Arcade = string.IsNullOrEmpty(arcade) ? false : Convert.ToBoolean(arcade);

                string console = Functions.GetXmlAttribute(platformNode, "Console");
                platform.Console = string.IsNullOrEmpty(console) ? false : Convert.ToBoolean(console);

                string handheld = Functions.GetXmlAttribute(platformNode, "Handheld");
                platform.Handheld = string.IsNullOrEmpty(handheld) ? false : Convert.ToBoolean(handheld);

                string cd = Functions.GetXmlAttribute(platformNode, "CD");
                platform.CD = string.IsNullOrEmpty(cd) ? false : Convert.ToBoolean(cd);

                platforms.Add(platform.Name.ToLower(), platform);

                if (platformNode.ChildNodes[0] != null)
                {
                    foreach (XmlNode emuNode in platformNode.ChildNodes[0].ChildNodes)
                    {
                        var emu = new Emulator()
                        {
                            Name = emuNode.InnerText, Path = emuNode.Attributes["Path"].Value, Command = emuNode.Attributes["Command"].Value
                        };
                        platform.Emulators.Add(emu);
                    }
                }
            }
        }
コード例 #28
0
        private void showIncorrectPlatformAuditToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (!showIncorrectPlatformAuditToolStripMenuItem.Checked)
                {
                    ColumnIncorrectPlatform.Visible = false;
                    return;
                }

                if (comboBoxPlatform.Text == "" || comboBoxPlatform.Text == "none")
                {
                    FormCustomMessage.ShowError("Select a platform");
                }

                var json = RomFunctions.GetPlatformJson(comboBoxPlatform.Text);

                if (json == "")
                {
                    FormCustomMessage.ShowError("Json not found. Sync platform first");
                    showIncorrectPlatformAuditToolStripMenuItem.Checked = false;
                    ColumnIncorrectPlatform.Visible = false;
                    return;
                }


                dataGridView.SuspendLayout();

                foreach (DataGridViewRow row in dataGridView.Rows)
                {
                    Rom rom = (Rom)row.Tag;

                    if (string.IsNullOrEmpty(rom.Id))
                    {
                        row.Cells[ColumnIncorrectPlatform.Name].Style.BackColor = Color.Yellow;
                        continue;
                    }

                    if (json.Contains("\"id\": " + rom.Id + ","))
                    {
                        row.Cells[ColumnIncorrectPlatform.Name].Style.BackColor = Color.Green;
                        row.Cells[ColumnIncorrectPlatform.Name].Value           = "OK";
                    }
                    else
                    {
                        row.Cells[ColumnIncorrectPlatform.Name].Style.BackColor = Color.Red;
                        row.Cells[ColumnIncorrectPlatform.Name].Value           = "NOT OK";
                    }
                }

                dataGridView.ResumeLayout();

                ColumnIncorrectPlatform.Visible = showIncorrectPlatformAuditToolStripMenuItem.Checked;

                if (updating)
                {
                    return;
                }
            }
            catch (OperationCanceledException ioex)
            {
                return;
            }
            catch (Exception ex)
            {
                FormCustomMessage.ShowError(ex.Message);
            }
        }
コード例 #29
0
        private void buttonGetRomData_Click(object sender, EventArgs e)
        {
            try
            {
                //FormWait.ShowWait(this);

                if (textBoxId.Text == string.Empty)
                {
                    textBoxId.Text = SyncDataFunctions.DiscoverGameId(SelectedRom);

                    if (string.IsNullOrEmpty(textBoxId.Text))
                    {
                        FormCustomMessage.ShowError("Could not discover TheGamesDB Id");
                        return;
                    }
                }

                var access = "";
                var game   = APIFunctions.GetGameDetails(textBoxId.Text, SelectedRom.Platform, out access);

                if (game == null)
                {
                    FormCustomMessage.ShowError("Could not get rom data");
                    return;
                }

                textBoxDBName.Text = game.DBName;

                if (radioButtonOnlyMissing.Checked)
                {
                    if (string.IsNullOrEmpty(textBoxPublisher.Text))
                    {
                        textBoxPublisher.Text = game.Publisher;
                    }

                    if (string.IsNullOrEmpty(textBoxDeveloper.Text))
                    {
                        textBoxDeveloper.Text = game.Developer;
                    }

                    if (string.IsNullOrEmpty(textBoxDescription.Text))
                    {
                        textBoxDescription.Text = game.Description;
                    }

                    if (string.IsNullOrEmpty(textBoxYearReleased.Text))
                    {
                        textBoxYearReleased.Text = game.YearReleased;
                    }

                    if (string.IsNullOrEmpty(textBoxRating.Text))
                    {
                        textBoxRating.Text = game.Rating.ToString("#.#");
                    }

                    if (string.IsNullOrEmpty(comboBoxGenre.Text))
                    {
                        comboBoxGenre.SelectedValue = game.Genre != null ? game.Genre.Name : string.Empty;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(game.Publisher))
                    {
                        textBoxPublisher.Text = game.Publisher;
                    }

                    if (!string.IsNullOrEmpty(game.Developer))
                    {
                        textBoxDeveloper.Text = game.Developer;
                    }

                    if (!string.IsNullOrEmpty(game.Description))
                    {
                        textBoxDescription.Text = game.Description;
                    }

                    if (!string.IsNullOrEmpty(game.YearReleased))
                    {
                        textBoxYearReleased.Text = game.YearReleased;
                    }

                    if (game.Rating != 0)
                    {
                        textBoxRating.Text = game.Rating.ToString("#.#");
                    }
                }

                var box      = RomFunctions.GetRomPicture(SelectedRom, Values.BoxartFolder);
                var title    = RomFunctions.GetRomPicture(SelectedRom, Values.TitleFolder);
                var gameplay = RomFunctions.GetRomPicture(SelectedRom, Values.GameplayFolder);

                bool missingBox      = string.IsNullOrEmpty(box);
                bool missingTitle    = string.IsNullOrEmpty(title);
                bool missingGameplay = string.IsNullOrEmpty(gameplay);

                if (!missingBox && !missingTitle && !missingGameplay)
                {
                    //FormWait.CloseWait();
                    return;
                }

                string boxUrl      = string.Empty;
                string titleUrl    = string.Empty;
                string gameplayUrl = string.Empty;

                var found = APIFunctions.GetGameArtUrls(textBoxId.Text, out boxUrl, out titleUrl, out gameplayUrl, out access);

                if (!found)
                {
                    //FormWait.CloseWait();
                    return;
                }

                if (missingBox)
                {
                    Functions.SavePictureFromUrl(SelectedRom, boxUrl, Values.BoxartFolder, checkBoxSaveAsJpg.Checked);
                    boxToDeleteIfCanceled = RomFunctions.GetRomPicture(SelectedRom, Values.BoxartFolder);
                }

                if (missingTitle && !string.IsNullOrEmpty(titleUrl))
                {
                    Functions.SavePictureFromUrl(SelectedRom, titleUrl, Values.TitleFolder, checkBoxSaveAsJpg.Checked);
                    titleToDeleteIfCanceled = RomFunctions.GetRomPicture(SelectedRom, Values.TitleFolder);
                }

                if (missingGameplay && !string.IsNullOrEmpty(gameplayUrl))
                {
                    Functions.SavePictureFromUrl(SelectedRom, gameplayUrl, Values.GameplayFolder, checkBoxSaveAsJpg.Checked);
                    gameplayToDeleteIfCanceled = RomFunctions.GetRomPicture(SelectedRom, Values.GameplayFolder);
                }

                MessageBox.Show("Remaining access: " + access);
            }
            catch (Exception ex)
            {
                //FormWait.CloseWait();
                FormCustomMessage.ShowError(ex.Message);
            }
            finally
            {
                //FormWait.CloseWait();
            }
        }
コード例 #30
0
        private void showMissingPicsAuditToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (!showMissingPicsAuditToolStripMenuItem.Checked)
                {
                    ColumnMissingPics.Visible = false;
                    return;
                }

                if (comboBoxPlatform.Text == "" || comboBoxPlatform.Text == "none")
                {
                    FormCustomMessage.ShowError("Select a platform first");
                    return;
                }

                var boxpics      = RomFunctions.GetPics(comboBoxPlatform.Text, PicType.BoxArt, false, true);
                var titlepics    = RomFunctions.GetPics(comboBoxPlatform.Text, PicType.Title, false, true);
                var gameplaypics = RomFunctions.GetPics(comboBoxPlatform.Text, PicType.Gameplay, false, true);

                dataGridView.SuspendLayout();

                foreach (DataGridViewRow row in dataGridView.Rows)
                {
                    Rom rom = (Rom)row.Tag;

                    bool boxExists      = boxpics.Any(x => x.ToLower() == rom.FileNameNoExt.ToLower());
                    bool titleExists    = titlepics.Any(x => x.ToLower() == rom.FileNameNoExt.ToLower());
                    bool gameplayExists = gameplaypics.Any(x => x.ToLower() == rom.FileNameNoExt.ToLower());

                    int missing = 0;

                    if (!boxExists)
                    {
                        missing++;
                    }

                    if (!titleExists)
                    {
                        missing++;
                    }

                    if (!gameplayExists)
                    {
                        missing++;
                    }

                    if (missing == 0)
                    {
                        row.Cells[ColumnMissingPics.Name].Style.BackColor = Color.Green;
                        row.Cells[ColumnMissingPics.Name].Value           = "ALL";
                    }
                    else if (missing == 1)
                    {
                        row.Cells[ColumnMissingPics.Name].Style.BackColor = Color.Yellow;
                        row.Cells[ColumnMissingPics.Name].Value           = "Missing 1";
                    }
                    else if (missing == 2)
                    {
                        row.Cells[ColumnMissingPics.Name].Style.BackColor = Color.Orange;
                        row.Cells[ColumnMissingPics.Name].Value           = "Missing 2";
                    }
                    else if (missing == 3)
                    {
                        row.Cells[ColumnMissingPics.Name].Style.BackColor = Color.Red;
                        row.Cells[ColumnMissingPics.Name].Value           = "Missing 3";
                    }
                }

                dataGridView.ResumeLayout();

                ColumnMissingPics.Visible = showMissingPicsAuditToolStripMenuItem.Checked;

                if (updating)
                {
                    return;
                }
            }
            catch (OperationCanceledException ioex)
            {
                return;
            }
            catch (Exception ex)
            {
                FormCustomMessage.ShowError(ex.Message);
            }
        }