Exemple #1
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);
        }