Beispiel #1
0
        public GameLibraryViewModel()
        {
            _gameSignatures = new HashSet<string>();
            _games = new ObservableCollection<GameViewModel>();
            _addCommand = new DelegateCommand(Scan);

            GameDetector = new GameDetector();
            GameDetector.Add(new ScummMetaEngine());
            GameDetector.Add(new SkyMetaEngine());
            GameDetector.Add(new Sword1.Sword1MetaEngine());

            LoadGameLibrary();
        }
Beispiel #2
0
        static int Main(string[] args)
        {
            var musicDriver = "adlib";
            var showVersion = false;
            var showHelp = false;
            var listAudioDevices = false;
            var bootParam = 0;
            var copyProtection = false;
            string switches = null;
            var options = new OptionSet
            {
                { "v|version", "Display NScumm version information and exit", v => showVersion = v != null },
                { "h|help", "Display a brief help text and exit", h => showHelp = h != null },
                { "e|music-driver=", "Select music driver", d => musicDriver = d },
                { "list-audio-devices", "List all available audio devices", b => listAudioDevices = b != null },
                { "b|boot-param=", "Pass number to the boot script (boot param)", (int b) => bootParam = b },
                { "debugflags=", "Enable engine specific debug flags (separated by commas)", d => switches = d },
                { "copy_protection", "Enable copy protection in SCUMM games, when NScumm disables it by default.", b => copyProtection = b != null }
            };

            try
            {
                var extras = options.Parse(args);
                Initialize(switches);
                if (showVersion)
                {
                    ShowVersion();
                }
                else if (showHelp)
                {
                    Usage(options);
                }
                else if (listAudioDevices)
                {
                    ListAudioDevices();
                }
                else if (extras.Count == 1)
                {
                    var path = ScummHelper.NormalizePath(extras[0]);
                    if (File.Exists(path))
                    {
                        var pluginsdDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins");
                        var gd = new GameDetector();
                        gd.AddPluginsFromDirectory(pluginsdDirectory);
                        var info = gd.DetectGame(path);
                        if (info == null)
                        {
                            Console.Error.WriteLine("This game is not supported, sorry please contact me if you want to support this game.");
                        }
                        else
                        {
                            ((AudioManager)ServiceLocator.AudioManager).Directory = Path.GetDirectoryName(info.Game.Path);
                            var settings = new GameSettings(info.Game, info.Engine) { AudioDevice = musicDriver, CopyProtection = copyProtection, BootParam = bootParam };
                            var game = new ScummGame(settings);
                            game.Services.AddService<IMenuService>(new MenuService(game));
                            game.Run();
                        }
                    }
                    else
                    {
                        Console.Error.WriteLine("The file {0} does not exist.", path);
                    }
                }
                else
                {
                    Usage(options);
                    return 1;
                }
            }
            catch (ArgumentException)
            {
                Usage(options);
                return 1;
            }
            catch (OptionException)
            {
                Usage(options);
                return 1;
            }
            return 0;
        }