Пример #1
0
        public static VsConfigInfo GetCurrentGameConfig(bool createNew)
        {
            string crc = InteropEmu.GetRomInfo().GetCrcString();

            foreach (VsConfigInfo config in ConfigManager.Config.VsConfig)
            {
                if (config.GameCrc == crc)
                {
                    return(config);
                }
            }

            VsConfigInfo newConfig = new VsConfigInfo();

            newConfig.GameCrc = crc;
            newConfig.GameID  = VsGameConfig.GetGameID();
            VsGameConfig gameConfig = VsGameConfig.GetGameConfig(newConfig.GameID);

            if (gameConfig != null)
            {
                newConfig.PpuModel    = gameConfig.PpuModel;
                newConfig.DipSwitches = gameConfig.DefaultDipSwitches;
                newConfig.InputType   = gameConfig.InputType;
            }

            if (createNew)
            {
                ConfigManager.Config.VsConfig.Add(newConfig);
            }

            return(newConfig);
        }
Пример #2
0
        static VsGameConfig()
        {
            XmlDocument config = new XmlDocument();

            config.Load(ResourceManager.GetZippedResource("VsSystem.xml"));

            foreach (XmlNode gameNode in config.SelectNodes("/VsSystemGames/Game"))
            {
                var gameConfig = new VsGameConfig();
                gameConfig.GameID   = gameNode.Attributes["ID"].Value;
                gameConfig.GameName = gameNode.Attributes["Localization"].Value;
                if (gameNode.Attributes["DefaultDip"] != null)
                {
                    gameConfig.DefaultDipSwitches = (byte)Int32.Parse(gameNode.Attributes["DefaultDip"].Value);
                }
                if (gameNode.Attributes["PpuModel"] != null)
                {
                    gameConfig.PpuModel = (InteropEmu.PpuModel)Enum.Parse(typeof(InteropEmu.PpuModel), gameNode.Attributes["PpuModel"].Value);
                }
                else
                {
                    gameConfig.PpuModel = InteropEmu.PpuModel.Ppu2C03;
                }
                if (gameNode.Attributes["InputType"] != null)
                {
                    gameConfig.InputType = (InteropEmu.VsInputType)Enum.Parse(typeof(InteropEmu.VsInputType), "Type" + gameNode.Attributes["InputType"].Value);
                }
                else
                {
                    gameConfig.InputType = InteropEmu.VsInputType.Default;
                }
                gameConfig.DipSwitches = new List <List <string> >();

                foreach (XmlNode dipSwitch in gameNode.SelectNodes("DipSwitch"))
                {
                    if (dipSwitch.Attributes["Localization"] != null)
                    {
                        var list = new List <string>();
                        gameConfig.DipSwitches.Add(list);

                        list.Add(dipSwitch.Attributes["Localization"].Value);
                        foreach (XmlNode option in dipSwitch.SelectNodes("Option"))
                        {
                            list.Add(option.InnerText);
                        }
                    }
                    else
                    {
                        var list = new List <string>();
                        gameConfig.DipSwitches.Add(list);

                        list.Add("Unknown");
                        list.Add("Off");
                        list.Add("On");
                    }
                }
                _gameConfigs[gameNode.Attributes["ID"].Value] = gameConfig;
            }
        }