Ejemplo n.º 1
0
        /// <summary>
        /// Create a Help Overlay component with the default positioning and scale.
        /// 
        /// (Center Screen, fixed scale)
        /// </summary>
        public HelpOverlay()
        {
            Vector2 screenCenter = new Vector2(ServiceManager.Game.GraphicsDevice.Viewport.Width / 2,
                ServiceManager.Game.GraphicsDevice.Viewport.Height / 2);

            int leftBound = (int)screenCenter.X - width / 2 - padding;
            int topBound = (int)screenCenter.Y - height / 2 + padding;

            displayRect = new Rectangle(leftBound-padding,
                                        topBound-padding,
                                        width + padding*2,
                                        height + padding*2);

            options = ServiceManager.Game.Options;

            this.Enabled = false;

            separatorLine = new Texture2D(ServiceManager.Game.GraphicsDevice, 1, 1);
            separatorLine.SetData<Color>(new Color[] { Color.White });

            helpText = new List<string[]>();
            LoadHelpText();
        }
Ejemplo n.º 2
0
        public static void WriteOptions(Options options)
        {
            KeysConverter kc = new KeysConverter();
            string filename = GetConfigFilePath();
            Xmlconfig config = new Xmlconfig();

            config.Settings["ServerAddress"].Value = options.ServerAddress;
            config.Settings["ServerPort"].intValue = options.ServerPort;
            config.Settings["DefaultAccount"].Value = options.DefaultAccount;
            config.Settings["MapsFolder"].Value = options.MapsFolder;
            config.Settings["options/video/Resolution"].Value = options.Video.Resolution;
            config.Settings["options/video/Windowed"].boolValue = options.Video.Windowed;
            config.Settings["options/video/TextureQuality"].Value = options.Video.TextureQuality;
            config.Settings["options/video/AntiAliasing"].Value = options.Video.AntiAliasing;
            config.Settings["options/video/ShadingEnabled"].boolValue = options.Video.ShadingEnabled;
            config.Settings["options/audio/ambientSound/Volume"].intValue = options.Audio.ambientSound.Volume;
            config.Settings["options/audio/ambientSound/Muted"].boolValue = options.Audio.ambientSound.Muted;
            config.Settings["options/audio/backgroundSound/Volume"].intValue = options.Audio.backgroundSound.Volume;
            config.Settings["options/audio/backgroundSound/Muted"].boolValue = options.Audio.backgroundSound.Muted;
            config.Settings["options/gameplay/ShowNames"].boolValue = options.GamePlay.ShowNames;
            config.Settings["options/gameplay/ProfanityFilter"].boolValue = options.GamePlay.ProfanityFilter;
            config.Settings["options/gameplay/InterfacePlugin"].Value = options.GamePlay.InterfacePlugin;
            config.Settings["options/keybindings/Forward"].Value = kc.ConvertToString(options.KeySettings.Forward);
            config.Settings["options/keybindings/Backward"].Value = kc.ConvertToString(options.KeySettings.Backward);
            config.Settings["options/keybindings/RotateLeft"].Value = kc.ConvertToString(options.KeySettings.RotateLeft);
            config.Settings["options/keybindings/RotateRight"].Value = kc.ConvertToString(options.KeySettings.RotateRight);
            //config.Settings["options/keybindings/FirePrimary"].Value = kc.ConvertToString(options.KeySettings.FirePrimary);
            //config.Settings["options/keybindings/FireSecondary"].Value = kc.ConvertToString(options.KeySettings.FireSecondary);
            config.Settings["options/keybindings/Menu"].Value = kc.ConvertToString(options.KeySettings.Menu);
            config.Settings["options/keybindings/Minimap"].Value = kc.ConvertToString(options.KeySettings.Minimap);
            config.Settings["options/keybindings/Score"].Value = kc.ConvertToString(options.KeySettings.Score);
            config.Settings["options/keybindings/Camera"].Value = kc.ConvertToString(options.KeySettings.Camera);
            config.Settings["options/keybindings/Pointer"].Value = options.KeySettings.Pointer;

            /*if (!System.IO.File.Exists(filename))
            {
                System.IO.FileStream stream = System.IO.File.Create(filename);
                stream.Close();
            }

            ExeConfigurationFileMap map = new ExeConfigurationFileMap();
            map.ExeConfigFilename = filename;

            Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(
                map, ConfigurationUserLevel.None);

            foreach (String key in ConfigurationManager.AppSettings.AllKeys)
            {
                configuration.AppSettings.Settings[key].Value =
                    ConfigurationManager.AppSettings[key];
            }

            configuration.Save(ConfigurationSaveMode.Modified);

            ConfigurationManager.RefreshSection("appSettings");*/

            if (!config.Commit())
                config.Save(filename);
        }
Ejemplo n.º 3
0
        public static Options ReadOptions()
        {
            bool doCommit = false;
            Options options = new Options();
            KeysConverter kc = new KeysConverter();

            VideoOptions defaultVideo = getDefaultVideoOptions();
            AudioOptions defaultAudio = getDefaultAudioOptions();
            GamePlayOptions defaultGame = getDefaultGamePlayOptions();
            KeyBindings defaultKeys = getDefaultKeyBindings();

            string filename = GetConfigFilePath();
            if (!File.Exists(filename))
                doCommit = true;
            Xmlconfig config = new Xmlconfig(filename, true);
            try
            {
                if (config.Settings.Name == "configuration")
                {
                    // Old configuration file. Port to new configuration type.
                    config.NewXml("xml");
                    doCommit = true;
                    ConvertFromLegacyConfig(config, filename);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Warning: Your old configuration settings have been lost due to an unforeseen error.",
                    "Old configuration settings lost!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            options.ServerAddress = Get(config, "ServerAddress", "glacier2a.cis.vtc.edu");
            options.ServerPort = int.Parse(Get(config, "ServerPort", "4063"));
            options.DefaultAccount = Get(config, "DefaultAccount");
            options.MapsFolder = Get(config, "MapsFolder", "maps");
            options.Video.Resolution = Get(config, "options/video/Resolution", defaultVideo.Resolution);
            options.Video.Windowed = bool.Parse(Get(config, "options/video/Windowed", defaultVideo.Windowed.ToString()));
            options.Video.TextureQuality = Get(config, "options/video/TextureQuality", defaultVideo.TextureQuality);
            options.Video.AntiAliasing = Get(config, "options/video/AntiAliasing", defaultVideo.AntiAliasing);
            options.Video.ShadingEnabled = bool.Parse(Get(config, "options/video/ShadingEnabled", defaultVideo.ShadingEnabled.ToString()));
            options.Audio.ambientSound.Volume = int.Parse(Get(config, "options/audio/ambientSound/Volume", defaultAudio.ambientSound.Volume.ToString()));
            options.Audio.ambientSound.Muted = bool.Parse(Get(config, "options/audio/ambientSound/Muted", defaultAudio.ambientSound.Muted.ToString()));
            options.Audio.backgroundSound.Volume = int.Parse(Get(config, "options/audio/backgroundSound/Volume", defaultAudio.backgroundSound.Volume.ToString()));
            options.Audio.backgroundSound.Muted = bool.Parse(Get(config, "options/audio/backgroundSound/Muted", defaultAudio.backgroundSound.Muted.ToString()));
            options.GamePlay.ShowNames = bool.Parse(Get(config, "options/gameplay/ShowNames", defaultGame.ShowNames.ToString()));
            options.GamePlay.ProfanityFilter = bool.Parse(Get(config, "options/gameplay/ProfanityFilter", defaultGame.ProfanityFilter.ToString()));
            options.GamePlay.InterfacePlugin = Get(config, "options/gameplay/InterfacePlugin", defaultGame.InterfacePlugin);
            options.KeySettings.Forward = (Keys)kc.ConvertFromString(Get(config, "options/keybindings/Forward", defaultKeys.Forward.ToString()));
            options.KeySettings.Backward = (Keys)kc.ConvertFromString(Get(config, "options/keybindings/Backward", defaultKeys.Backward.ToString()));
            options.KeySettings.RotateLeft = (Keys)kc.ConvertFromString(Get(config, "options/keybindings/RotateLeft", defaultKeys.RotateLeft.ToString()));
            options.KeySettings.RotateRight = (Keys)kc.ConvertFromString(Get(config, "options/keybindings/RotateRight", defaultKeys.RotateRight.ToString()));
            //options.KeySettings.FirePrimary = (Keys)kc.ConvertFromString(Get(config, "options/keysettings/FirePrimary", ""));
            //options.KeySettings.FireSecondary = (Keys)kc.ConvertFromString(Get(config, "options/keysettings/FireSecondary", ""));
            options.KeySettings.Menu = (Keys)kc.ConvertFromString(Get(config, "options/keybindings/Menu", defaultKeys.Menu.ToString()));
            options.KeySettings.Minimap = (Keys)kc.ConvertFromString(Get(config, "options/keybindings/Minimap", defaultKeys.Minimap.ToString()));
            options.KeySettings.Score = (Keys)kc.ConvertFromString(Get(config, "options/keybindings/Score", defaultKeys.Score.ToString()));
            options.KeySettings.Camera = (Keys)kc.ConvertFromString(Get(config, "options/keybindings/Camera", defaultKeys.Camera.ToString()));
            options.KeySettings.Pointer = Get(config, "options/keybindings/Pointer", defaultKeys.Pointer);

            if (doCommit)
                WriteOptions(options);

            return options;
        }