Exemplo n.º 1
0
        private RomData SelectRom(IReadOnlyEmulator emulator)
        {
            List <RomData> availableRoms = new List <RomData>();

            foreach (var consoleType in emulator.ConsoleNames)
            {
                availableRoms.AddRange(romMgr.GetRoms(consoleType));
            }

            Console.WriteLine(String.Format("The following games are available for {0}:", emulator.EmulatorName));
            for (int i = 1; i <= availableRoms.Count; i++)
            {
                var rom = availableRoms[i - 1];
                Console.WriteLine(String.Format("{0}) {1} (Time Played: {2})", i, rom.FriendlyName, rom.PrettyPrintPlayTime()));
            }

            int selectedRom;

            while (true)
            {
                Console.Write("Enter a game's number ('exit' to quit) > ");
                String input = Console.ReadLine();
                if (input == "exit")
                {
                    return(null);
                }
                if (int.TryParse(input, out selectedRom))
                {
                    if (selectedRom > 0 && selectedRom <= availableRoms.Count)
                    {
                        return(availableRoms[selectedRom - 1]);
                    }
                }
            }
        }
        private void HandleRightClickEmulator(IReadOnlyEmulator tag)
        {
            ContextMenuStrip ctxMenu = new ContextMenuStrip();

            ToolStripMenuItem menuItem = new ToolStripMenuItem();

            menuItem.Tag    = tag;
            menuItem.Text   = "Remove Emulator";
            menuItem.Click += RemoveCustomEmulator_Selected;
            ctxMenu.Items.Add(menuItem);

            treeView.ContextMenuStrip = ctxMenu;
        }
Exemplo n.º 3
0
 private void EmulatorTreeView_CustomRemovalRequested(Emulators.Interfaces.IReadOnlyEmulator emulator)
 {
     backgroundWorker1.DoWork += (sender, e) =>
     {
         IReadOnlyEmulator emu = (IReadOnlyEmulator)e.Argument;
         emuMgr.DeleteEmulator(emu);
     };
     backgroundWorker1.RunWorkerCompleted += (sender, e) =>
     {
         UpdateEmulatorList();
     };
     backgroundWorker1.RunWorkerAsync(emulator);
 }
        private void RemoveCustomEmulator(IReadOnlyEmulator emulator)
        {
            EmulatorManagerConfigKey key = new EmulatorManagerConfigKey()
            {
                EmulatorName    = emulator.EmulatorName,
                EmulatorVersion = emulator.Version
            };

            if (loadedConfig.ContainsKey(key))
            {
                loadedConfig.Remove(key);
            }
            if (availableEmulators.ContainsKey(emulator))
            {
                availableEmulators.Remove(emulator);
            }
            UpdateConfiguration();
        }
        private void UpdateConfigProperty(IReadOnlyEmulator emulator, Boolean installed)
        {
            EmulatorManagerConfig cfg;
            var key = new EmulatorManagerConfigKey()
            {
                EmulatorName    = emulator.EmulatorName,
                EmulatorVersion = emulator.Version
            };

            if (!loadedConfig.TryGetValue(key, out cfg))
            {
                cfg = new EmulatorManagerConfig();
                loadedConfig.Add(key, cfg);
            }
            cfg.Installed = installed;

            UpdateConfiguration();
        }
        public void RunEmulator(IReadOnlyEmulator emulator, RomData rom)
        {
            IEmulator emu;

            if (availableEmulators.TryGetValue(emulator, out emu))
            {
                Stopwatch timer = new Stopwatch();
                timer.Start();
                emu.ExecuteRom(rom);
                timer.Stop();
                rom.TimePlayed += timer.Elapsed;
                romMgr.UpdateRomData(rom);
            }
            else
            {
                throw new EmulatorManagerException(String.Format("The selected emulator {0} has not been installed", emulator.EmulatorName));
            }
        }
Exemplo n.º 7
0
        public static void RunWithArguments(Options args)
        {
            var emuMgr = EmulatorManager.Instance;
            var romMgr = RomManager.Instance;

            var emulators = emuMgr.GetAvailableEmulators();

            emulators = emulators.Where(e => { return(e.EmulatorName == args.Emulator); }).ToList();
            if (emulators.Count < 1)
            {
                throw new EmulationCoordinationException(String.Format("Emulator {0} not defined", args.Emulator));
            }

            IReadOnlyEmulator emulator = null;

            if (String.IsNullOrEmpty(args.Version))
            {
                emulator = emulators.First();
            }
            else
            {
                emulators = emulators.Where(e => { return(e.Version == args.Version); }).ToList();
                if (emulators.Count < 1)
                {
                    throw new EmulationCoordinationException(string.Format("{0}.{1} is not a defined emulator", args.Emulator, args.Version));
                }
                emulator = emulators.First();
            }

            List <RomData> roms = new List <RomData>();

            foreach (var console in emulator.ConsoleNames)
            {
                roms.AddRange(romMgr.GetRoms(console));
            }
            roms = roms.Where(r => { return(r.FriendlyName == args.Rom); }).ToList();
            if (roms.Count < 1)
            {
                throw new EmulationCoordinationException(string.Format("Rom {0} not available for emulator {1}", args.Rom, args.Emulator));
            }
            RomData rom = roms.First();

            emuMgr.RunEmulator(emulator, rom);
        }
        private void RemoveCustomEmulator_Selected(object sender, EventArgs e)
        {
            IReadOnlyEmulator emu = (IReadOnlyEmulator)((ToolStripMenuItem)sender).Tag;

            CustomRemovalRequested?.Invoke(emu);
        }
 public bool DeleteEmulator(IReadOnlyEmulator emulator)
 {
     RemoveCustomEmulator(emulator);
     return(true);
 }