Beispiel #1
0
        public static void StripFlagsFromTitle(Game game)
        {
            foreach (string filenameFlag in game.FilenameFlags)
                game.Name = game.Name.Replace(filenameFlag, "");

            while (game.Name.Contains("  "))
                game.Name = game.Name.Replace("  ", " ");
        }
Beispiel #2
0
        public static void PlayGame(Window owner, Game game, Func<string> getStatus = null, Action<string> setStatus = null)
        {
            if (game == null)
            {
                return;
            }

            string oldStatus = null;

            if (getStatus != null && setStatus != null)
            {
                oldStatus = getStatus();
                setStatus("starting " + game.Name);
            }

            try
            {
                var library = game.ParentGameLibrary;

                Emulator emulator = null;
                var emulatorOptions = library.Emulators.GetEmulatorChoices(game.Platform).ToList();

                if (emulatorOptions.Count == 1)
                {
                    emulator = emulatorOptions[0];
                }
                else
                {
                    if (emulatorOptions.Count == 0)
                        emulatorOptions = library.Emulators.ToList();

                    var dialog = new EmulatorSelectorWindow(owner, library.Emulators, emulatorOptions);
                    dialog.ShowDialog();

                    emulator = dialog.Result;
                }

                if (emulator == null)
                {
                    return;
                }

                emulator.OpenGame(game);
            }
            finally
            {
                if (setStatus != null && oldStatus != null)
                {
                    setStatus(oldStatus);
                }
            }
        }
Beispiel #3
0
        public bool GameIsMatch(Game game)
        {
            if (filterItems.Count == 0)
                return true;

            foreach (IFilterItem filterItem in filterItems)
            {
                if (filterItem.Matches(game))
                {
                    if (searchMode == SearchFilterMode.MatchSomeFilterItems)
                        return true;
                    if(searchMode == SearchFilterMode.MatchNoFilterItems)
                        return false;
                }
                else
                {
                    if (searchMode == SearchFilterMode.MatchAllFilterItems)
                        return false;
                }
            }
            throw new Exception("whaaaaa? problem with the search filter.");
        }
Beispiel #4
0
        public void Open(string path)
        {
            if (!File.Exists(GuiCommon.LibraryFilePath))
                {
                    MessageBoxGenerator.ShowError("Could not run ROM, because there is no library.");
                    return;
                }

                if (library == null)
                {
                    library = new ArcadiaLibrary();
                    library.ReadFromFile(GuiCommon.LibraryFilePath);
                }
                else
                {
                    library.LoadDefaultSettings();
                }

                var game = library.Games.GetByPath(path);

                if (game == null)
                {
                    var tempRepository = new Repository("Temporary Repository", library);
                    tempRepository.RootPath = Path.GetDirectoryName(path);
                    library.Add(tempRepository);

                    game = new Game(Path.GetFileNameWithoutExtension(path), library)
                    {
                        InnerPath = Path.GetFileName(path),
                        Repository = tempRepository
                    };
                    game.FillInInformation(true);

                    library.Remove(tempRepository);
                }

                GuiCommon.PlayGame(null, game);
        }
Beispiel #5
0
        public void OpenGame(Game game)
        {
            var process = new Process();
            process.StartInfo.FileName = this.Path;

            var pattern = ArgumentPatternIsSet ? ArgumentPattern : DefaultArgumentPattern;

            process.StartInfo.Arguments = pattern.Replace(ArgumentPatternFileVariable, game.FullPath);

            try
            {
                process.Start();
            }
            catch(Exception exception)
            {
                //TODO: throw more specific exception
                throw new Exception("Error starting emulator.", exception);
            }
        }
Beispiel #6
0
        private void playGame(Game game)
        {
            Func<string> getStatus = () =>
                this.windowTitle;

            Action<string> setStatus = (text) =>
                this.changeWindowTitle(text);

            GuiCommon.PlayGame(this, game, getStatus, setStatus);
        }
Beispiel #7
0
 bool IFilterItem.Matches(Game game)
 {
     return game.Platform.Equals(this);
 }
Beispiel #8
0
 public static void RemoveFileExtensionFromName(Game game)
 {
     game.Name = game.Name.Replace(System.IO.Path.GetExtension(game.Name), "");
 }
Beispiel #9
0
        public Game AddGame(string gamePath)
        {
            if (!gamePath.StartsWith(RootPath, StringComparison.InvariantCultureIgnoreCase))
            {
                //TODO: throw more specific exception
                throw new Exception("Game " + gamePath + " is not in the domain of this repository.");
            }

            var game = new Game(System.IO.Path.GetFileName(gamePath), ParentGameLibrary)
            {
                Repository = this,
                InnerPath = gamePath.Substring(RootPath.Length)
            };

            game.FillInInformation(true);

            ParentGameLibrary.Add(game);

            return game;
        }