Beispiel #1
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 #2
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;
        }