예제 #1
0
        private void BuildList()
        {
            List <DisplayCaption> list = new List <DisplayCaption>();

            foreach (DirectoryInfo di in directory.GetDirectories())
            {
                DisplayCaption dc = new DisplayCaption(di.Name, DisplaySettings.folderIcon);
                dc.UserData = di.Name;
                list.Add(dc);
            }

            foreach (FileInfo fi in directory.GetFiles())
            {
                // Check if it"s a valid rom size
                if (!MapperFarm.AllowedSize((int)fi.Length))
                {
                    continue;
                }

                try
                {
                    byte[] data = new byte[fi.Length];

                    FileStream fo = File.OpenRead(fi.FullName);
                    fo.Read(data, 0, (int)data.Length);
                    fo.Close();

                    string hash = ProfileManager.GetHash(data);

                    if (ProfileManager.Profiled(hash))
                    {
                        ProfileManager.GameProfile profile = ProfileManager.GetProfile(hash);

                        DisplayCaption dc = new DisplayCaption(profile.name, DisplaySettings.binaryIcon);
                        dc.UserData = fi.Name;

                        list.Add(dc);
                    }
                    else
                    {
                        DisplayCaption dc = new DisplayCaption(fi.Name);
                        dc.UserData = fi.Name;

                        list.Add(dc);
                    }
                }
                catch
                {
                    Console.WriteLine("Failed to test: " + fi.FullName);
                }
            }

            guiList.List  = list;
            guiScroll.Max = guiList.List.Count - 1;
        }
예제 #2
0
        private void onLoad()
        {
            if (guiList.List.Count == 0)
            {
                return;
            }

            string name = Path.Combine(directory.FullName, (string)guiList.List[guiList.Selected].UserData);

            if (Directory.Exists(name))
            {
                directory = new DirectoryInfo(name);
                BuildList();
            }
            else if (File.Exists(name))
            {
                FileStream fi   = File.OpenRead(name);
                byte[]     data = new byte[fi.Length];
                fi.Read(data, 0, (int)fi.Length);
                fi.Close();

                string hash = ProfileManager.GetHash(data);

                if (ProfileManager.Profiled(hash))
                {
                    ProfileManager.GameProfile profile = ProfileManager.GetProfile(hash);

                    Mapper m = MapperFarm.CreateByName(profile.mapper, data);

                    // TODO: CREATE JOYSTICKS FROM PROFILE
                    // TODO: SET SIGNAL FROM PROFILE

                    baseDirectory = directory;

                    gui.Add(new EmulatorWindow(gui, profile.name, m, profile.signal), true);
                    gui.Remove(this);
                }
                else
                {
                    gui.Add(new ConfigureRom(gui, (string)guiList.List[guiList.Selected].UserData, hash, data.Length, guiList.List[guiList.Selected]), true);
                }
            }
        }
예제 #3
0
        public ConfigureRom(Compound gui, string file, string hash, int romSize, DisplayCaption caption)
            :
            base(gui, new Rectangle(0, 0, 273, 224), new DisplayCaption("Configure rom"), new List <Atom>())
        {
            gameHash = hash;

            List <DisplayCaption> controllers = new List <DisplayCaption>();
            List <DisplayCaption> mappers     = new List <DisplayCaption>();
            List <DisplayCaption> signals     = new List <DisplayCaption>();

            configCaption = caption;
            filename      = file;

            DisplayCaption s;

            s          = new DisplayCaption("NTSC");
            s.UserData = SignalType.VIDEO_NTSC;
            signals.Add(s);

            s          = new DisplayCaption("PAL");
            s.UserData = SignalType.VIDEO_PAL;
            signals.Add(s);

            s          = new DisplayCaption("SECAM");
            s.UserData = SignalType.VIDEO_SECAM;
            signals.Add(s);

            foreach (string m in MapperFarm.MappersBySize(romSize))
            {
                mappers.Add(new DisplayCaption(m));
            }

            // TODO: Retrieve from input farm
            controllers.Add(new DisplayCaption("Joystick"));

            name   = new EditBox(gui, new Rectangle(0, 0, 256, 24), file, null);
            mapper = new ListBox(gui, new Rectangle(124, 28, 132, 40), mappers, null);
            ctrl_a = new ListBox(gui, new Rectangle(124, 72, 132, 40), controllers, null);
            ctrl_b = new ListBox(gui, new Rectangle(124, 116, 132, 40), controllers, null);
            signal = new Radio(gui, new Rectangle(16, 44, 100, 0), signals, null);

            Add(new Button(gui, new Rectangle(192, 160, 64, 24), new DisplayCaption("Update"), doProfile));
            Add(new Button(gui, new Rectangle(192 - 68, 160, 64, 24), new DisplayCaption("Remove"), removeProfile));


            aLable = new Lable(gui, new Rectangle(110, 126, 0, 0), "B", Alignment.LEFT, DisplaySettings.captionColor, DisplaySettings.captionFont);
            bLable = new Lable(gui, new Rectangle(110, 84, 0, 0), "A", Alignment.LEFT, DisplaySettings.captionColor, DisplaySettings.captionFont);

            Add(aLable);
            Add(bLable);

            if (ProfileManager.Profiled(gameHash))
            {
                ProfileManager.GameProfile profile = ProfileManager.GetProfile(gameHash);

                name.Value = profile.name;

                for (int i = 0; i < signals.Count; i++)
                {
                    if ((SignalType)signals[i].UserData == profile.signal)
                    {
                        signal.Selection = i;
                        break;
                    }
                }

                for (int i = 0; i < ctrl_a.List.Count; i++)
                {
                    if (ctrl_a.List[i].Text == profile.controller_a)
                    {
                        ctrl_a.Selected = i;
                        break;
                    }
                }

                for (int i = 0; i < ctrl_b.List.Count; i++)
                {
                    if (ctrl_b.List[i].Text == profile.controller_b)
                    {
                        ctrl_b.Selected = i;
                        break;
                    }
                }

                for (int i = 0; i < mappers.Count; i++)
                {
                    if (mappers[i].Text == profile.mapper)
                    {
                        mapper.Selected = i;
                        break;
                    }
                }
            }

            Add(name);
            Add(mapper);
            Add(ctrl_a);
            Add(ctrl_b);
            Add(signal);
        }