Example #1
0
        public ClawOptions()
        {
            InitializeComponent();

            CenterToScreen();

            String configPath = ClawLauncherForm.ClawConfigPath;

            m_ClawConfig = ParseClawConfig(configPath);

            SetupControlsFromConfig(m_ClawConfig);
        }
Example #2
0
        private ClawConfig ParseClawConfig(String configPath)
        {
            ClawConfig config = new ClawConfig();

            XmlDocument configDoc = new XmlDocument();

            configDoc.Load(configPath);

            XmlElement root = configDoc.DocumentElement;

            // ============= Video ==============
            XmlNode videoRoot = root.SelectSingleNode("Display");

            config.Resolution.X       = int.Parse(videoRoot.SelectSingleNode("Size").Attributes["width"].Value);
            config.Resolution.Y       = int.Parse(videoRoot.SelectSingleNode("Size").Attributes["height"].Value);
            config.Scale              = float.Parse(videoRoot.SelectSingleNode("Scale").InnerText);
            config.bVerticalSync      = bool.Parse(videoRoot.SelectSingleNode("UseVerticalSync").InnerText);
            config.bFullscreen        = bool.Parse(videoRoot.SelectSingleNode("IsFullscreen").InnerText);
            config.bFullscreenDesktop = bool.Parse(videoRoot.SelectSingleNode("IsFullscreenDesktop").InnerText);

            // ============= Audio ==============
            XmlNode audioRoot = root.SelectSingleNode("Audio");

            config.Frequency      = int.Parse(audioRoot.SelectSingleNode("Frequency").InnerText);
            config.SoundChannels  = int.Parse(audioRoot.SelectSingleNode("SoundChannels").InnerText);
            config.MixingChannels = int.Parse(audioRoot.SelectSingleNode("MixingChannels").InnerText);
            config.SoundVolume    = int.Parse(audioRoot.SelectSingleNode("SoundVolume").InnerText);
            config.MusicVolume    = int.Parse(audioRoot.SelectSingleNode("MusicVolume").InnerText);
            config.bSoundOn       = bool.Parse(audioRoot.SelectSingleNode("SoundOn").InnerText);
            config.bMusicOn       = bool.Parse(audioRoot.SelectSingleNode("MusicOn").InnerText);

            // ============= Assets ==============
            XmlNode assetsRoot = root.SelectSingleNode("Assets");

            config.RezArchivePath    = assetsRoot.SelectSingleNode("RezArchive").InnerText;
            config.ZipArchivePath    = assetsRoot.SelectSingleNode("CustomArchive").InnerText;
            config.SavesFilePath     = assetsRoot.SelectSingleNode("SavesFile").InnerText;
            config.ResourceCacheSize = int.Parse(assetsRoot.SelectSingleNode("ResourceCacheSize").InnerText);

            // ============= Console ==============
            XmlNode consoleRoot = root.SelectSingleNode("Console");

            // ============= Gameplay ==============
            XmlNode gameplayRoot = root.SelectSingleNode("Gameplay");

            return(config);
        }
Example #3
0
        void SetupControlsFromConfig(ClawConfig config)
        {
            // ============= Video ==============

            // Video Resolution
            Video_ResolutionComboBox.SelectedItem =
                Video_ResolutionComboBox.Items[Video_ResolutionComboBox.Items.Count - 1];
            string resolutionCmpText = config.Resolution.X + "x" + config.Resolution.Y;

            foreach (var item in Video_ResolutionComboBox.Items)
            {
                string cbItemStr = item.ToString();
                if (cbItemStr.Contains(resolutionCmpText))
                {
                    Video_ResolutionComboBox.SelectedItem = item;
                    break;
                }
            }

            // Video Scale
            Video_ScaleTextBox.Text = config.Scale.ToString();

            // Video Vertical Sync
            if (config.bVerticalSync)
            {
                Video_VerticalSyncCheckBox.Checked = true;
            }
            else
            {
                Video_VerticalSyncCheckBox.Checked = false;
            }

            // Video Display Mode
            if (!config.bFullscreen && !config.bFullscreenDesktop)
            {
                // Windowed
                Video_DisplayModeComboBox.SelectedItem =
                    Video_DisplayModeComboBox.Items[0];
            }
            else if (config.bFullscreen)
            {
                // Fullscreen Desktop
                Video_DisplayModeComboBox.SelectedItem =
                    Video_DisplayModeComboBox.Items[2];
            }
            else
            {
                // Fullscreen
                Video_DisplayModeComboBox.SelectedItem =
                    Video_DisplayModeComboBox.Items[1];
            }

            if (config.bFullscreen || config.bFullscreenDesktop)
            {
                // Custom resolution
                Video_ResolutionComboBox.SelectedItem =
                    Video_ResolutionComboBox.Items[Video_ResolutionComboBox.Items.Count - 1];

                Video_ResolutionComboBox.Enabled = false;
            }

            // ============= Audio ==============
            {
                // Frequency
                Audio_FrequencyComboBox.SelectedItem =
                    Audio_FrequencyComboBox.Items[Audio_FrequencyComboBox.Items.Count - 1];
                string cmpText = config.Frequency.ToString();
                foreach (var item in Audio_FrequencyComboBox.Items)
                {
                    string cbItemStr = item.ToString();
                    if (cbItemStr.Contains(cmpText))
                    {
                        Audio_FrequencyComboBox.SelectedItem = item;
                        break;
                    }
                }

                // 3D Sound Channles - fixed
                Audio_3DSoundChannelsComboBox.SelectedItem = Audio_3DSoundChannelsComboBox.Items[0];

                // Mixing Channels
                Audio_MixingChannelsSlider.Value = config.MixingChannels;
                Audio_MixingChannelsTextBox.Text = config.MixingChannels.ToString();

                // Sound Volume
                Audio_SoundVolumeSlider.Value = config.SoundVolume;
                Audio_SoundVolumeTextBox.Text = config.SoundVolume.ToString();

                // Music Volume
                Audio_MusicVolumeSlider.Value = config.MusicVolume;
                Audio_MusicVolumeTextBox.Text = config.MusicVolume.ToString();

                // Sound On
                Audio_SoundOnCheckBox.Checked = config.bSoundOn;

                // Music On
                Audio_MusicOnCheckBox.Checked = config.bMusicOn;
            }

            // ============= Assets ==============
            Assets_RezArchivePathTextBox.Text = config.RezArchivePath;
            Assets_ZipArchivePathTextBox.Text = config.ZipArchivePath;
            Assets_SavesFilePathTextBox.Text  = config.SavesFilePath;
            Assets_ResCacheSizeTextBox.Text   = config.ResourceCacheSize.ToString();
        }