public override void Initialize()
        {
            base.Initialize();

            Name = "AudioOptionsPanel";

            var lblScoreVolume = new XNALabel(WindowManager);

            lblScoreVolume.Name            = "lblScoreVolume";
            lblScoreVolume.ClientRectangle = new Rectangle(12, 14, 0, 0);
            lblScoreVolume.Text            = "Music Volume:";

            lblScoreVolumeValue                 = new XNALabel(WindowManager);
            lblScoreVolumeValue.Name            = "lblScoreVolumeValue";
            lblScoreVolumeValue.FontIndex       = 1;
            lblScoreVolumeValue.Text            = "10";
            lblScoreVolumeValue.ClientRectangle = new Rectangle(
                ClientRectangle.Width - lblScoreVolumeValue.ClientRectangle.Width - 12,
                lblScoreVolume.ClientRectangle.Y, 0, 0);

            trbScoreVolume                 = new XNATrackbar(WindowManager);
            trbScoreVolume.Name            = "trbScoreVolume";
            trbScoreVolume.ClientRectangle = new Rectangle(
                lblScoreVolume.ClientRectangle.Right + 16,
                lblScoreVolume.ClientRectangle.Y - 2,
                lblScoreVolumeValue.ClientRectangle.X - lblScoreVolume.ClientRectangle.Right - 31,
                22);
            trbScoreVolume.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 2, 2);
            trbScoreVolume.MinValue          = 0;
            trbScoreVolume.MaxValue          = 10;
            trbScoreVolume.ValueChanged     += TrbScoreVolume_ValueChanged;

            var lblSoundVolume = new XNALabel(WindowManager);

            lblSoundVolume.Name            = "lblSoundVolume";
            lblSoundVolume.ClientRectangle = new Rectangle(lblScoreVolume.ClientRectangle.X,
                                                           lblScoreVolume.ClientRectangle.Bottom + 20, 0, 0);
            lblSoundVolume.Text = "Sound Volume:";

            lblSoundVolumeValue                 = new XNALabel(WindowManager);
            lblSoundVolumeValue.Name            = "lblSoundVolumeValue";
            lblSoundVolumeValue.FontIndex       = 1;
            lblSoundVolumeValue.Text            = "10";
            lblSoundVolumeValue.ClientRectangle = new Rectangle(
                lblScoreVolumeValue.ClientRectangle.X,
                lblSoundVolume.ClientRectangle.Y, 0, 0);

            trbSoundVolume                 = new XNATrackbar(WindowManager);
            trbSoundVolume.Name            = "trbSoundVolume";
            trbSoundVolume.ClientRectangle = new Rectangle(
                trbScoreVolume.ClientRectangle.X,
                lblSoundVolume.ClientRectangle.Y - 2,
                trbScoreVolume.ClientRectangle.Width,
                trbScoreVolume.ClientRectangle.Height);
            trbSoundVolume.BackgroundTexture = trbScoreVolume.BackgroundTexture;
            trbSoundVolume.MinValue          = 0;
            trbSoundVolume.MaxValue          = 10;
            trbSoundVolume.ValueChanged     += TrbSoundVolume_ValueChanged;

            var lblVoiceVolume = new XNALabel(WindowManager);

            lblVoiceVolume.Name            = "lblVoiceVolume";
            lblVoiceVolume.ClientRectangle = new Rectangle(lblScoreVolume.ClientRectangle.X,
                                                           lblSoundVolume.ClientRectangle.Bottom + 20, 0, 0);
            lblVoiceVolume.Text = "Voice Volume:";

            lblVoiceVolumeValue                 = new XNALabel(WindowManager);
            lblVoiceVolumeValue.Name            = "lblVoiceVolumeValue";
            lblVoiceVolumeValue.FontIndex       = 1;
            lblVoiceVolumeValue.Text            = "10";
            lblVoiceVolumeValue.ClientRectangle = new Rectangle(
                lblScoreVolumeValue.ClientRectangle.X,
                lblVoiceVolume.ClientRectangle.Y, 0, 0);

            trbVoiceVolume                 = new XNATrackbar(WindowManager);
            trbVoiceVolume.Name            = "trbVoiceVolume";
            trbVoiceVolume.ClientRectangle = new Rectangle(
                trbScoreVolume.ClientRectangle.X,
                lblVoiceVolume.ClientRectangle.Y - 2,
                trbScoreVolume.ClientRectangle.Width,
                trbScoreVolume.ClientRectangle.Height);
            trbVoiceVolume.BackgroundTexture = trbScoreVolume.BackgroundTexture;
            trbVoiceVolume.MinValue          = 0;
            trbVoiceVolume.MaxValue          = 10;
            trbVoiceVolume.ValueChanged     += TrbVoiceVolume_ValueChanged;

            chkScoreShuffle                 = new XNAClientCheckBox(WindowManager);
            chkScoreShuffle.Name            = "chkScoreShuffle";
            chkScoreShuffle.ClientRectangle = new Rectangle(
                lblScoreVolume.ClientRectangle.X,
                trbVoiceVolume.ClientRectangle.Bottom + 12, 0, 0);
            chkScoreShuffle.Text = "Shuffle Music";

            var lblClientVolume = new XNALabel(WindowManager);

            lblClientVolume.Name            = "lblClientVolume";
            lblClientVolume.ClientRectangle = new Rectangle(lblScoreVolume.ClientRectangle.X,
                                                            chkScoreShuffle.ClientRectangle.Bottom + 40, 0, 0);
            lblClientVolume.Text = "Client Volume:";

            lblClientVolumeValue                 = new XNALabel(WindowManager);
            lblClientVolumeValue.Name            = "lblClientVolumeValue";
            lblClientVolumeValue.FontIndex       = 1;
            lblClientVolumeValue.Text            = "10";
            lblClientVolumeValue.ClientRectangle = new Rectangle(
                lblScoreVolumeValue.ClientRectangle.X,
                lblClientVolume.ClientRectangle.Y, 0, 0);

            trbClientVolume                 = new XNATrackbar(WindowManager);
            trbClientVolume.Name            = "trbClientVolume";
            trbClientVolume.ClientRectangle = new Rectangle(
                trbScoreVolume.ClientRectangle.X,
                lblClientVolume.ClientRectangle.Y - 2,
                trbScoreVolume.ClientRectangle.Width,
                trbScoreVolume.ClientRectangle.Height);
            trbClientVolume.BackgroundTexture = trbScoreVolume.BackgroundTexture;
            trbClientVolume.MinValue          = 0;
            trbClientVolume.MaxValue          = 10;
            trbClientVolume.ValueChanged     += TrbClientVolume_ValueChanged;

            chkMainMenuMusic                 = new XNAClientCheckBox(WindowManager);
            chkMainMenuMusic.Name            = "chkMainMenuMusic";
            chkMainMenuMusic.ClientRectangle = new Rectangle(
                lblScoreVolume.ClientRectangle.X,
                trbClientVolume.ClientRectangle.Bottom + 12, 0, 0);
            chkMainMenuMusic.Text            = "Main menu music";
            chkMainMenuMusic.CheckedChanged += ChkMainMenuMusic_CheckedChanged;

            chkStopMusicOnMenu                 = new XNAClientCheckBox(WindowManager);
            chkStopMusicOnMenu.Name            = "chkStopMusicOnMenu";
            chkStopMusicOnMenu.ClientRectangle = new Rectangle(
                lblScoreVolume.ClientRectangle.X, chkMainMenuMusic.ClientRectangle.Bottom + 24, 0, 0);
            chkStopMusicOnMenu.Text = "Don't play main menu music in lobbies";

#if DTA
            var chkRABuildingCrumbleSound = new FileSettingCheckBox(WindowManager,
                                                                    "Resources\\Ecache03.mix", "MIX\\Ecache03.mix", false);
            chkRABuildingCrumbleSound.Name            = "chkRABuildingCrumbleSound";
            chkRABuildingCrumbleSound.ClientRectangle = new Rectangle(
                chkStopMusicOnMenu.ClientRectangle.X,
                chkStopMusicOnMenu.ClientRectangle.Bottom + 24, 0, 0);
            chkRABuildingCrumbleSound.Text = "Use Red Alert building crumble sound";

            var chkReplaceRACannonSounds = new FileSettingCheckBox(WindowManager,
                                                                   "Resources\\Ecache02.mix", "MIX\\Ecache02.mix", false);
            chkReplaceRACannonSounds.Name            = "chkReplaceRACannonSounds";
            chkReplaceRACannonSounds.ClientRectangle = new Rectangle(
                chkMainMenuMusic.ClientRectangle.X,
                chkRABuildingCrumbleSound.ClientRectangle.Bottom + 24, 0, 0);
            chkReplaceRACannonSounds.Text = "Replace Red Alert cannon sounds with Tiberian Dawn cannon sounds";

            fileSettingCheckBoxes.Add(chkRABuildingCrumbleSound);
            fileSettingCheckBoxes.Add(chkReplaceRACannonSounds);
#endif

            fileSettingCheckBoxes.ForEach(chkBox => AddChild(chkBox));

            AddChild(lblScoreVolume);
            AddChild(lblScoreVolumeValue);
            AddChild(trbScoreVolume);
            AddChild(lblSoundVolume);
            AddChild(lblSoundVolumeValue);
            AddChild(trbSoundVolume);
            AddChild(lblVoiceVolume);
            AddChild(lblVoiceVolumeValue);
            AddChild(trbVoiceVolume);

            AddChild(chkScoreShuffle);

            AddChild(lblClientVolume);
            AddChild(lblClientVolumeValue);
            AddChild(trbClientVolume);

            AddChild(chkMainMenuMusic);
            AddChild(chkStopMusicOnMenu);

            lblScoreVolumeValue.Text  = trbScoreVolume.Value.ToString();
            lblSoundVolumeValue.Text  = trbSoundVolume.Value.ToString();
            lblVoiceVolumeValue.Text  = trbVoiceVolume.Value.ToString();
            lblClientVolumeValue.Text = trbClientVolume.Value.ToString();
            AudioMaster.SetVolume(trbClientVolume.Value / 10.0f);
        }
Exemplo n.º 2
0
        public override void Initialize()
        {
            base.Initialize();

            Name = "DisplayOptionsPanel";

            var lblIngameResolution = new XNALabel(WindowManager);

            lblIngameResolution.Name            = "lblIngameResolution";
            lblIngameResolution.ClientRectangle = new Rectangle(12, 14, 0, 0);
            lblIngameResolution.Text            = "In-game Resolution:";

            ddIngameResolution                 = new XNAClientDropDown(WindowManager);
            ddIngameResolution.Name            = "ddIngameResolution";
            ddIngameResolution.ClientRectangle = new Rectangle(
                lblIngameResolution.ClientRectangle.Right + 12,
                lblIngameResolution.ClientRectangle.Y - 2, 120, 19);

#if TI
            var resolutions = GetResolutions(800, 600, 4096, 4096);
#else
            var resolutions = GetResolutions(640, 480, 4096, 4096);
#endif
            resolutions.Sort();

            foreach (var res in resolutions)
            {
                ddIngameResolution.AddItem(res.ToString());
            }

            var lblDetailLevel = new XNALabel(WindowManager);
            lblDetailLevel.Name            = "lblDetailLevel";
            lblDetailLevel.ClientRectangle = new Rectangle(lblIngameResolution.ClientRectangle.X,
                                                           ddIngameResolution.ClientRectangle.Bottom + 16, 0, 0);
            lblDetailLevel.Text = "Detail Level:";

            ddDetailLevel                 = new XNAClientDropDown(WindowManager);
            ddDetailLevel.Name            = "ddDetailLevel";
            ddDetailLevel.ClientRectangle = new Rectangle(
                ddIngameResolution.ClientRectangle.X,
                lblDetailLevel.ClientRectangle.Y - 2,
                ddIngameResolution.ClientRectangle.Width,
                ddIngameResolution.ClientRectangle.Height);
            ddDetailLevel.AddItem("Low");
            ddDetailLevel.AddItem("Medium");
            ddDetailLevel.AddItem("High");

            var lblRenderer = new XNALabel(WindowManager);
            lblRenderer.Name            = "lblRenderer";
            lblRenderer.ClientRectangle = new Rectangle(lblDetailLevel.ClientRectangle.X,
                                                        ddDetailLevel.ClientRectangle.Bottom + 16, 0, 0);
            lblRenderer.Text = "Renderer:";

            ddRenderer                 = new XNAClientDropDown(WindowManager);
            ddRenderer.Name            = "ddRenderer";
            ddRenderer.ClientRectangle = new Rectangle(
                ddDetailLevel.ClientRectangle.X,
                lblRenderer.ClientRectangle.Y - 2,
                ddDetailLevel.ClientRectangle.Width,
                ddDetailLevel.ClientRectangle.Height);

            ddRenderer.AddItem("Default");
            ddRenderer.AddItem("IE-DDRAW");
            ddRenderer.AddItem("TS-DDRAW");
            ddRenderer.AddItem("DDWrapper");
            ddRenderer.AddItem("DxWnd");
            if (ClientConfiguration.Instance.GetOperatingSystemVersion() == OSVersion.WINXP)
            {
                ddRenderer.AddItem("Software");
            }

            chkWindowedMode                 = new XNAClientCheckBox(WindowManager);
            chkWindowedMode.Name            = "chkWindowedMode";
            chkWindowedMode.ClientRectangle = new Rectangle(lblDetailLevel.ClientRectangle.X,
                                                            ddRenderer.ClientRectangle.Bottom + 16, 0, 0);
            chkWindowedMode.Text            = "Windowed Mode";
            chkWindowedMode.CheckedChanged += ChkWindowedMode_CheckedChanged;

            chkBorderlessWindowedMode                 = new XNAClientCheckBox(WindowManager);
            chkBorderlessWindowedMode.Name            = "chkBorderlessWindowedMode";
            chkBorderlessWindowedMode.ClientRectangle = new Rectangle(
                chkWindowedMode.ClientRectangle.X + 50,
                chkWindowedMode.ClientRectangle.Bottom + 24, 0, 0);
            chkBorderlessWindowedMode.Text          = "Borderless Windowed Mode";
            chkBorderlessWindowedMode.AllowChecking = false;

            chkBackBufferInVRAM                 = new XNAClientCheckBox(WindowManager);
            chkBackBufferInVRAM.Name            = "chkBackBufferInVRAM";
            chkBackBufferInVRAM.ClientRectangle = new Rectangle(
                lblDetailLevel.ClientRectangle.X,
                chkBorderlessWindowedMode.ClientRectangle.Bottom + 28, 0, 0);
            chkBackBufferInVRAM.Text = "Back Buffer in Video Memory" + Environment.NewLine +
                                       "(lower performance, but is" + Environment.NewLine + "necessary on some systems)";

            var lblClientResolution = new XNALabel(WindowManager);
            lblClientResolution.Name            = "lblClientResolution";
            lblClientResolution.ClientRectangle = new Rectangle(
                285, 14, 0, 0);
            lblClientResolution.Text = "Client Resolution:";

            ddClientResolution                 = new XNAClientDropDown(WindowManager);
            ddClientResolution.Name            = "ddClientResolution";
            ddClientResolution.ClientRectangle = new Rectangle(
                lblClientResolution.ClientRectangle.Right + 12,
                lblClientResolution.ClientRectangle.Y - 2,
                ClientRectangle.Width - (lblClientResolution.ClientRectangle.Right + 24),
                ddIngameResolution.ClientRectangle.Height);
            ddClientResolution.AllowDropDown = false;

            var screenBounds = Screen.PrimaryScreen.Bounds;

            resolutions = GetResolutions(800, 600,
                                         screenBounds.Width, screenBounds.Height);

            // Add "optimal" client resolutions for windowed mode
            // if they're not supported in fullscreen mode

            AddResolutionIfFitting(1024, 600, resolutions);
            AddResolutionIfFitting(1024, 720, resolutions);
            AddResolutionIfFitting(1280, 600, resolutions);
            AddResolutionIfFitting(1280, 720, resolutions);
            AddResolutionIfFitting(1280, 768, resolutions);
            AddResolutionIfFitting(1280, 800, resolutions);

            resolutions.Sort();

            foreach (var res in resolutions)
            {
                var item = new XNADropDownItem();
                item.Text      = res.ToString();
                item.Tag       = res.ToString();
                item.TextColor = UISettings.AltColor;
                ddClientResolution.AddItem(item);
            }

            // So we add the optimal resolutions to the list, sort it and then find
            // out the optimal resolution index - it's inefficient, but works

            int optimalWindowedResIndex = resolutions.FindIndex(res => res.ToString() == "1280x800");
            if (optimalWindowedResIndex == -1)
            {
                optimalWindowedResIndex = resolutions.FindIndex(res => res.ToString() == "1280x768");
            }

            if (optimalWindowedResIndex > -1)
            {
                var item = ddClientResolution.Items[optimalWindowedResIndex];
                item.Text = item.Text + " (recommended)";
            }

            chkBorderlessClient                 = new XNAClientCheckBox(WindowManager);
            chkBorderlessClient.Name            = "chkBorderlessClient";
            chkBorderlessClient.ClientRectangle = new Rectangle(
                lblClientResolution.ClientRectangle.X,
                lblDetailLevel.ClientRectangle.Y, 0, 0);
            chkBorderlessClient.Text            = "Fullscreen Client";
            chkBorderlessClient.CheckedChanged += ChkBorderlessMenu_CheckedChanged;
            chkBorderlessClient.Checked         = true;

            var lblClientTheme = new XNALabel(WindowManager);
            lblClientTheme.Name            = "lblClientTheme";
            lblClientTheme.ClientRectangle = new Rectangle(
                lblClientResolution.ClientRectangle.X,
                lblRenderer.ClientRectangle.Y, 0, 0);
            lblClientTheme.Text = "Client Theme:";

            ddClientTheme                 = new XNAClientDropDown(WindowManager);
            ddClientTheme.Name            = "ddClientTheme";
            ddClientTheme.ClientRectangle = new Rectangle(
                ddClientResolution.ClientRectangle.X,
                ddRenderer.ClientRectangle.Y,
                ddClientResolution.ClientRectangle.Width,
                ddRenderer.ClientRectangle.Height);

            int themeCount = ClientConfiguration.Instance.ThemeCount;

            for (int i = 0; i < themeCount; i++)
            {
                ddClientTheme.AddItem(ClientConfiguration.Instance.GetThemeInfoFromIndex(i)[0]);
            }

#if DTA
            chkEnableCannonTracers = new FileSettingCheckBox(WindowManager,
                                                             "Resources\\ECache91.mix", "MIX\\ECache91.mix", true);
            chkEnableCannonTracers.Name            = "chkEnableCannonTracers";
            chkEnableCannonTracers.ClientRectangle = new Rectangle(
                chkBorderlessClient.ClientRectangle.X,
                chkWindowedMode.ClientRectangle.Y, 0, 0);
            chkEnableCannonTracers.Text = "Use Cannon Tracers";

            AddChild(chkEnableCannonTracers);

            fileSettingCheckBoxes.Add(chkEnableCannonTracers);
#elif TI
            chkSmallerVehicleGraphics = new FileSettingCheckBox(WindowManager,
                                                                "Resources\\ecache02.mix", "MIX\\ecache02.mix", false);
            chkSmallerVehicleGraphics.AddFile("Resources\\expand02.mix", "MIX\\expand02.mix");
            chkSmallerVehicleGraphics.Name            = "chkSmallerVehicleGraphics";
            chkSmallerVehicleGraphics.ClientRectangle = new Rectangle(
                chkBorderlessClient.ClientRectangle.X,
                chkWindowedMode.ClientRectangle.Y, 0, 0);
            chkSmallerVehicleGraphics.Text = "Smaller Vehicle Graphics";

            AddChild(chkSmallerVehicleGraphics);
            fileSettingCheckBoxes.Add(chkSmallerVehicleGraphics);

            chkLargerInfantryGraphics = new FileSettingCheckBox(WindowManager,
                                                                "Resources\\ecache01.mix", "MIX\\ecache01.mix", false);
            chkLargerInfantryGraphics.Name            = "chkLargerInfantryGraphics";
            chkLargerInfantryGraphics.ClientRectangle = new Rectangle(
                chkSmallerVehicleGraphics.ClientRectangle.X,
                chkBorderlessWindowedMode.ClientRectangle.Y, 0, 0);
            chkLargerInfantryGraphics.Text = "Larger Infantry Graphics";

            AddChild(chkLargerInfantryGraphics);
            fileSettingCheckBoxes.Add(chkLargerInfantryGraphics);
#endif

#if !YR
            lblCompatibilityFixes           = new XNALabel(WindowManager);
            lblCompatibilityFixes.Name      = "lblCompatibilityFixes";
            lblCompatibilityFixes.FontIndex = 1;
            lblCompatibilityFixes.Text      = "Compatibility Fixes (advanced):";
            AddChild(lblCompatibilityFixes);
            lblCompatibilityFixes.CenterOnParent();
            lblCompatibilityFixes.ClientRectangle = new Rectangle(
                lblCompatibilityFixes.ClientRectangle.X,
                ClientRectangle.Height - 103,
                lblCompatibilityFixes.ClientRectangle.Width,
                lblCompatibilityFixes.ClientRectangle.Height);

            lblGameCompatibilityFix                 = new XNALabel(WindowManager);
            lblGameCompatibilityFix.Name            = "lblGameCompatibilityFix";
            lblGameCompatibilityFix.ClientRectangle = new Rectangle(132,
                                                                    lblCompatibilityFixes.ClientRectangle.Bottom + 20, 0, 0);
            lblGameCompatibilityFix.Text = "DTA/TI/TS Compatibility Fix:";

            btnGameCompatibilityFix                 = new XNAClientButton(WindowManager);
            btnGameCompatibilityFix.Name            = "btnGameCompatibilityFix";
            btnGameCompatibilityFix.ClientRectangle = new Rectangle(
                lblGameCompatibilityFix.ClientRectangle.Right + 20,
                lblGameCompatibilityFix.ClientRectangle.Y - 4, 133, 23);
            btnGameCompatibilityFix.FontIndex  = 1;
            btnGameCompatibilityFix.Text       = "Enable";
            btnGameCompatibilityFix.LeftClick += BtnGameCompatibilityFix_LeftClick;

            lblMapEditorCompatibilityFix                 = new XNALabel(WindowManager);
            lblMapEditorCompatibilityFix.Name            = "lblMapEditorCompatibilityFix";
            lblMapEditorCompatibilityFix.ClientRectangle = new Rectangle(
                lblGameCompatibilityFix.ClientRectangle.X,
                lblGameCompatibilityFix.ClientRectangle.Bottom + 20, 0, 0);
            lblMapEditorCompatibilityFix.Text = "FinalSun Compatibility Fix:";

            btnMapEditorCompatibilityFix                 = new XNAClientButton(WindowManager);
            btnMapEditorCompatibilityFix.Name            = "btnMapEditorCompatibilityFix";
            btnMapEditorCompatibilityFix.ClientRectangle = new Rectangle(
                btnGameCompatibilityFix.ClientRectangle.X,
                lblMapEditorCompatibilityFix.ClientRectangle.Y - 4,
                btnGameCompatibilityFix.ClientRectangle.Width,
                btnGameCompatibilityFix.ClientRectangle.Height);
            btnMapEditorCompatibilityFix.FontIndex  = 1;
            btnMapEditorCompatibilityFix.Text       = "Enable";
            btnMapEditorCompatibilityFix.LeftClick += BtnMapEditorCompatibilityFix_LeftClick;

            AddChild(lblGameCompatibilityFix);
            AddChild(btnGameCompatibilityFix);
            AddChild(lblMapEditorCompatibilityFix);
            AddChild(btnMapEditorCompatibilityFix);
#endif

            AddChild(chkWindowedMode);
            AddChild(chkBorderlessWindowedMode);
            AddChild(chkBackBufferInVRAM);
            AddChild(chkBorderlessClient);
            AddChild(lblClientTheme);
            AddChild(ddClientTheme);
            AddChild(lblClientResolution);
            AddChild(ddClientResolution);
            AddChild(lblRenderer);
            AddChild(ddRenderer);
            AddChild(lblDetailLevel);
            AddChild(ddDetailLevel);
            AddChild(lblIngameResolution);
            AddChild(ddIngameResolution);
        }