Example #1
0
        public static Set FindGameProfileSet(string gameName, string gameProfileName)
        {
            if (string.IsNullOrWhiteSpace(gameName) || string.IsNullOrWhiteSpace(gameProfileName))
            {
                return(null);
            }

            if (GameConfiguration == null || GameConfiguration.Sets == null)
            {
                return(null);
            }

            Set gameSet = GameConfiguration.FindSet(gameName);

            if (gameSet == null)
            {
                return(null);
            }

            Set profilesSet = gameSet.FindSet("Profiles");

            if (profilesSet == null || profilesSet.Sets == null)
            {
                return(null);
            }

            return(profilesSet.FindSet(gameProfileName));
        }
Example #2
0
        static bool AddGameToXML(string gameName, string gameProfileName, string executablePath, string executableName, string parameters)
        {
            // not running, just edit the XML
            if (GameConfiguration == null)
            {
                // no existing XML.
                return(false);
            }

            Set gameSet = GameConfiguration.FindSet(gameName);

            if (gameSet == null)
            {
                gameSet = new Set(gameName);
                GameConfiguration.Add(gameSet);
                gameSet.Add(new Setting("OpenGL", "1"));
                gameSet.Add(new Setting("Direct3D8", "1"));
                gameSet.Add(new Setting("Direct3D9", "1"));
                gameSet.Add(new Setting("Win32I Keyboard", "1"));
                gameSet.Add(new Setting("Win32I Mouse", "1"));
                gameSet.Add(new Setting("DirectInput8 Keyboard", "1"));
                gameSet.Add(new Setting("DirectInput8 Mouse", "1"));
                gameSet.Add(new Setting("modules", "auto"));
                gameSet.Add(new Setting("Background Mouse", "1"));
                gameSet.Add(new Setting("Keystroke Delay", "1"));
            }

            Set gameProfilesSet = gameSet.FindSet("Profiles");

            if (gameProfilesSet == null)
            {
                gameProfilesSet = new Set("Profiles");
                gameSet.Add(gameProfilesSet);
            }

            Set gameProfileSet = gameSet.FindSet(gameProfileName);

            if (gameProfileSet == null)
            {
                gameProfileSet = new Set(gameProfileName);
                gameProfilesSet.Add(gameProfileSet);
            }

            Setting setting = gameProfileSet.FindSetting("Executable");

            if (setting == null)
            {
                gameProfileSet.Add(new Setting("Executable", executableName));
            }
            else
            {
                setting.Value = executableName;
            }

            setting = gameProfileSet.FindSetting("Path");
            if (setting == null)
            {
                gameProfileSet.Add(new Setting("Path", executablePath));
            }
            else
            {
                setting.Value = executablePath;
            }

            setting = gameProfileSet.FindSetting("Parameters");
            if (setting == null)
            {
                if (!string.IsNullOrEmpty(parameters))
                {
                    gameProfileSet.Add(new Setting("Parameters", parameters));
                }
            }
            else
            {
                if (string.IsNullOrEmpty(parameters))
                {
                    gameProfileSet.Settings.Remove(setting);
                }
                else
                {
                    setting.Value = parameters;
                }
            }

            if (GameProfiles.FirstOrDefault(q => q.GameProfile.Equals(gameProfileName)) == null)
            {
                GameProfiles.Add(new InnerSpaceGameProfile()
                {
                    Game = gameName, GameProfile = gameProfileName
                });
            }

            GameConfiguration.Store(ISPath + @"\GameConfiguration.XML");
            return(true);
        }