Example #1
0
        public static bool SelectRom(ref ResourcePath resource)
        {
            List <ArchiveRomEntry> archiveRomList = ArchiveHelper.GetArchiveRomList(resource.Path);

            if (archiveRomList.Select(entry => entry.Filename).Contains(resource.InnerFile))
            {
                return(true);
            }

            if (archiveRomList.Count > 1)
            {
                using (frmSelectRom frm = new frmSelectRom(archiveRomList)) {
                    if (frm.ShowDialog(null, Application.OpenForms[0]) == DialogResult.OK)
                    {
                        ArchiveRomEntry entry = frm.lstRoms.SelectedItem as ArchiveRomEntry;
                        resource.InnerFile = entry.Filename;
                        if (!entry.IsUtf8)
                        {
                            resource.InnerFileIndex = archiveRomList.IndexOf(entry) + 1;
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else if (archiveRomList.Count == 1)
            {
                resource.InnerFile = archiveRomList[0].Filename;
                if (!archiveRomList[0].IsUtf8)
                {
                    resource.InnerFileIndex = 1;
                }
            }
            else
            {
                resource.InnerFile = "";
            }

            return(true);
        }
Example #2
0
        public static bool SelectRom(string filename, ref int archiveFileIndex, out string romName)
        {
            romName = "";

            List <string> archiveRomList = InteropEmu.GetArchiveRomList(filename);

            if (archiveRomList.Count > 1)
            {
                if (archiveFileIndex >= 0 && archiveFileIndex < archiveRomList.Count)
                {
                    romName = System.IO.Path.GetFileName(archiveRomList[archiveFileIndex]);
                    return(true);
                }
                else
                {
                    frmSelectRom frm = new frmSelectRom(archiveRomList);
                    if (frm.ShowDialog(null, Application.OpenForms[0]) == DialogResult.OK)
                    {
                        archiveFileIndex = frm.SelectedIndex;
                        romName          = System.IO.Path.GetFileName(frm.lstRoms.SelectedItem.ToString());
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else if (archiveRomList.Count == 1)
            {
                romName = System.IO.Path.GetFileName(archiveRomList[0]);
            }
            else
            {
                romName = System.IO.Path.GetFileName(filename);
            }

            return(true);
        }