Пример #1
0
        /// <summary>
        /// Validates the specified consoles assets.
        /// </summary>
        /// <param name="console">The console.</param>
        /// <returns></returns>
        public ConsoleStatus Validate(HyperValidator.Models.Console console)
        {
            var status = new ConsoleStatus()
            {
                Video    = ValidateVideo(console),
                Theme    = ValidateTheme(console),
                WheelArt = ValidateWheelArt(console)
            };

            return(status);
        }
Пример #2
0
        /// <summary>
        /// Validates if this console has a theme available.
        /// </summary>
        /// <param name="console">The console.</param>
        /// <returns></returns>
        protected Boolean ValidateTheme(HyperValidator.Models.Console console)
        {
            var location = PathUtility.Combine(Settings.HyperSpinRootLocation, "Media\\Main Menu\\Themes");

            foreach (var fileType in Settings.ThemeFileTypes)
            {
                location = PathUtility.Combine(location, $"{console.Name}.{fileType}");
                if (FileUtility.Exists(location))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #3
0
        /// <summary>
        /// Validates all of the assets associated with a game in Hyperspin.
        /// </summary>
        /// <param name="console">The console.</param>
        /// <param name="game">The game.</param>
        /// <returns></returns>
        public GameStatus Validate(HyperValidator.Models.Console console, Game game)
        {
            var status = new GameStatus()
            {
                Name       = game.Name,
                Artwork1   = ValidateArtwork1(console, game),
                Artwork2   = ValidateArtwork2(console, game),
                Artwork3   = ValidateArtwork3(console, game),
                Artwork4   = ValidateArtwork4(console, game),
                Rom        = ValidateRom(console, game),
                Theme      = ValidateTheme(console, game),
                Video      = ValidateVideo(console, game),
                WheelArt   = ValidateWheelArt(console, game),
                Background = ValidateBackground(console, game),
                Enabled    = game.Enabled
            };

            return(status);
        }
Пример #4
0
        /// <summary>
        /// Validates the rom.
        /// </summary>
        /// <param name="console">The console.</param>
        /// <param name="game">The game.</param>
        /// <returns></returns>
        protected virtual Boolean?ValidateRom(HyperValidator.Models.Console console, Game game)
        {
            if (!Settings.ValidateRoms)
            {
                return(null);
            }

            foreach (var fileType in Settings.RomFileTypes)
            {
                var location = PathUtility.Combine(Settings.RomLocation, console.Name);
                location = PathUtility.Combine(location, $"{game.Name}.{fileType}");
                if (FileUtility.Exists(location))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #5
0
        /// <summary>
        /// Validates the background folder.
        /// </summary>
        /// <param name="console">The console.</param>
        /// <param name="game">The game.</param>
        /// <returns></returns>
        protected virtual Boolean?ValidateBackground(HyperValidator.Models.Console console, Game game)
        {
            if (!Settings.ValidateBackgrounds)
            {
                return(null);
            }

            foreach (var fileType in Settings.ImageFileTypes)
            {
                var location = PathUtility.Combine(Settings.HyperSpinRootLocation, "Media", console.Name, "Images\\Backgrounds");
                location = PathUtility.Combine(location, $"{game.Name}.{fileType}");
                if (FileUtility.Exists(location))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #6
0
        /// <summary>
        /// Gets the the settings for the hyperspin system.
        /// </summary>
        /// <returns></returns>
        public HyperSpin Get()
        {
            var hyperspin = new HyperSpin();

            var databasePath = PathUtility.Combine(Settings.HyperSpinRootLocation, "Databases\\Main Menu\\Main Menu.xml");
            var xml          = FileUtility.ReadAllText(databasePath);
            var database     = XDocument.Parse(xml);

            var menu = database.Document.Element(XName.Get("menu"));

            foreach (var item in menu.Elements())
            {
                var name    = item.Attribute(XName.Get("name")).Value;
                var console = new HyperValidator.Models.Console()
                {
                    Name = name
                };
                hyperspin.Consoles.Add(console);
            }
            return(hyperspin);
        }
Пример #7
0
        /// <summary>
        /// Gets the specified console using it's name as an identifier.
        /// </summary>
        /// <param name="name">The name of the console to get.</param>
        /// <param name="validate">if set to <c>true</c> [validate].</param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public HyperValidator.Models.Console Get(String name, Boolean validate = false)
        {
            var console = new HyperValidator.Models.Console()
            {
                Name = name
            };

            var databasePath = PathUtility.Combine(Settings.HyperSpinRootLocation, "databases", console.Name, $"{console.Name}.xml");
            var database     = DatabaseSerializer.DeserializeFromFile(databasePath);

            console.Database = database;

            var settingsPath = PathUtility.Combine(Settings.HyperSpinRootLocation, "settings", $"{console.Name}.ini");

            if (!FileUtility.Exists(settingsPath))
            {
                throw new Exception($"Failed to find settings file for {name}");
            }

            var settings = ConsoleSerializer.DeserializeFromFile(settingsPath);

            console.Settings = settings;

            console.Status = ConsoleValidator.Validate(console);

            if (validate)
            {
                foreach (var game in console.Database.Games)
                {
                    var status = GameValidator.Validate(console, game);
                    OnGameValidated(status);
                    game.Status = status;
                }
                OnValidationComplete();
            }

            return(console);
        }