public override void ParseAttributeFromINI(IniFile iniFile, string key, string value)
        {
            switch (key)
            {
            case "Items":
                string[] items = value.Split(',');
                for (int i = 0; i < items.Length; i++)
                {
                    XNADropDownItem item = new XNADropDownItem();
                    item.Text = items[i];
                    AddItem(item);
                }
                return;

            case "DefaultValue":
                defaultValue = Conversions.IntFromString(value, 0);
                return;

            case "CheckAvailability":
                CheckAvailability = Conversions.BooleanFromString(value, false);
                return;

            case "ResetUnavailableValue":
                ResetUnavailableValue = Conversions.BooleanFromString(value, false);
                return;

            case "RestartRequired":
                RestartRequired = Conversions.BooleanFromString(value, false);
                return;
            }

            base.ParseAttributeFromINI(iniFile, key, value);
        }
Exemple #2
0
        public override void ParseAttributeFromINI(IniFile iniFile, string key, string value)
        {
            switch (key)
            {
            case "Items":
                string[] items      = value.Split(',');
                string[] itemlabels = iniFile.GetStringValue(Name, "ItemLabels", "").Split(',');
                for (int i = 0; i < items.Length; i++)
                {
                    XNADropDownItem item = new XNADropDownItem();
                    if (itemlabels.Length > i && !String.IsNullOrEmpty(itemlabels[i]))
                    {
                        item.Text = itemlabels[i];
                        item.Tag  = items[i];
                    }
                    else
                    {
                        item.Text = items[i];
                    }
                    AddItem(item);
                }
                return;

            case "DataWriteMode":
                if (value.ToUpper() == "INDEX")
                {
                    dataWriteMode = DropDownDataWriteMode.INDEX;
                }
                else if (value.ToUpper() == "BOOLEAN")
                {
                    dataWriteMode = DropDownDataWriteMode.BOOLEAN;
                }
                else if (value.ToUpper() == "MAPCODE")
                {
                    dataWriteMode = DropDownDataWriteMode.MAPCODE;
                }
                else
                {
                    dataWriteMode = DropDownDataWriteMode.STRING;
                }
                return;

            case "SpawnIniOption":
                spawnIniOption = value;
                return;

            case "DefaultIndex":
                SelectedIndex     = int.Parse(value);
                defaultIndex      = SelectedIndex;
                HostSelectedIndex = SelectedIndex;
                UserSelectedIndex = SelectedIndex;
                return;

            case "OptionName":
                OptionName = value;
                return;
            }

            base.ParseAttributeFromINI(iniFile, key, value);
        }
Exemple #3
0
        private void InitializeGameList()
        {
            int i = 0;

            foreach (var game in gameCollection.GameList)
            {
                if (!game.Supported)
                {
                    i++;
                    continue;
                }

                var item = new XNADropDownItem();
                item.Text      = game.UIName;
                item.TextColor = UISettings.AltColor;
                item.Texture   = game.Texture;

                ddCurrentChannel.AddItem(item);

                var chatChannel = connectionManager.FindChannel(game.ChatChannel);

                if (chatChannel == null)
                {
                    chatChannel = connectionManager.CreateChannel(game.UIName, game.ChatChannel,
                                                                  true, "ra1-derp");
                    connectionManager.AddChannel(chatChannel);
                }

                item.Tag = chatChannel;

                if (game.GameBroadcastChannel != null)
                {
                    var gameBroadcastChannel = connectionManager.FindChannel(game.GameBroadcastChannel);

                    if (gameBroadcastChannel == null)
                    {
                        gameBroadcastChannel = connectionManager.CreateChannel(game.UIName + " Broadcast Channel",
                                                                               game.GameBroadcastChannel, true, null);
                        connectionManager.AddChannel(gameBroadcastChannel);
                    }

                    gameBroadcastChannel.CTCPReceived += GameBroadcastChannel_CTCPReceived;
                }

                if (game.InternalName.ToUpper() == localGameID.ToUpper())
                {
                    ddCurrentChannel.SelectedIndex = i;
                }

                i++;
            }

            if (connectionManager.MainChannel == null)
            {
                // Set CnCNet channel as main channel if no channel found
                ddCurrentChannel.SelectedIndex = ddCurrentChannel.Items.Count - 1;
            }
        }
Exemple #4
0
        /// <summary>
        /// Draws the drop-down.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            if (PreferredItemIndex > -1 && PreferredItemIndex < Items.Count)
            {
                XNADropDownItem preferredItem             = Items[PreferredItemIndex];
                string          preferredItemOriginalText = preferredItem.Text;
                preferredItem.Text += " " + PreferredItemLabel;

                base.Draw(gameTime);

                preferredItem.Text = preferredItemOriginalText;
            }
            else
            {
                base.Draw(gameTime);
            }
        }
Exemple #5
0
        /// <summary>
        /// Draws the drop-down.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            if (PreferredItemIndexes.Count > 0)
            {
                PreferredItemIndexes.ForEach(i =>
                {
                    XNADropDownItem preferredItem    = Items[i];
                    string preferredItemOriginalText = preferredItem.Text;
                    preferredItem.Text += " " + PreferredItemLabel;
                });

                base.Draw(gameTime);

                PreferredItemIndexes.ForEach(i =>
                {
                    XNADropDownItem preferredItem = Items[i];
                    preferredItem.Text            = preferredItem.Text.Substring(0, preferredItem.Text.Length - PreferredItemLabel.Length - 1);
                });
            }
            else
            {
                base.Draw(gameTime);
            }
        }
        //private bool FinalSunCompatFixDeclined = false;
#endif


        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.Right + 12,
                lblIngameResolution.Y - 2, 120, 19);

            var clientConfig = ClientConfiguration.Instance;

            var resolutions = GetResolutions(clientConfig.MinimumIngameWidth,
                                             clientConfig.MinimumIngameHeight,
                                             clientConfig.MaximumIngameWidth, clientConfig.MaximumIngameHeight);

            resolutions.Sort();

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

            var lblDetailLevel = new XNALabel(WindowManager);

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

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

            var lblRenderer = new XNALabel(WindowManager);

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

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

            GetRenderers();

            var localOS = ClientConfiguration.Instance.GetOperatingSystemVersion();

            foreach (var renderer in renderers)
            {
                if (renderer.IsCompatibleWithOS(localOS) && !renderer.Hidden)
                {
                    ddRenderer.AddItem(new XNADropDownItem()
                    {
                        Text = renderer.UIName,
                        Tag  = renderer
                    });
                }
            }

            //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.X,
                                                            ddRenderer.Bottom + 16, 0, 0);
            chkWindowedMode.Text            = "Windowed Mode";
            chkWindowedMode.CheckedChanged += ChkWindowedMode_CheckedChanged;

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

            chkBackBufferInVRAM                 = new XNAClientCheckBox(WindowManager);
            chkBackBufferInVRAM.Name            = "chkBackBufferInVRAM";
            chkBackBufferInVRAM.ClientRectangle = new Rectangle(
                lblDetailLevel.X,
                chkBorderlessWindowedMode.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 XNAClientPreferredItemDropDown(WindowManager);
            ddClientResolution.Name            = "ddClientResolution";
            ddClientResolution.ClientRectangle = new Rectangle(
                lblClientResolution.Right + 12,
                lblClientResolution.Y - 2,
                Width - (lblClientResolution.Right + 24),
                ddIngameResolution.Height);
            ddClientResolution.AllowDropDown      = false;
            ddClientResolution.PreferredItemLabel = "(recommended)";

            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();
                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)
            {
                ddClientResolution.PreferredItemIndex = optimalWindowedResIndex;
            }

            chkBorderlessClient                 = new XNAClientCheckBox(WindowManager);
            chkBorderlessClient.Name            = "chkBorderlessClient";
            chkBorderlessClient.ClientRectangle = new Rectangle(
                lblClientResolution.X,
                lblDetailLevel.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.X,
                lblRenderer.Y, 0, 0);
            lblClientTheme.Text = "Client Theme:";

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

            int themeCount = ClientConfiguration.Instance.ThemeCount;

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

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

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

            btnGameCompatibilityFix                 = new XNAClientButton(WindowManager);
            btnGameCompatibilityFix.Name            = "btnGameCompatibilityFix";
            btnGameCompatibilityFix.ClientRectangle = new Rectangle(
                lblGameCompatibilityFix.Right + 20,
                lblGameCompatibilityFix.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.X,
                lblGameCompatibilityFix.Bottom + 20, 0, 0);
            lblMapEditorCompatibilityFix.Text = "FinalSun Compatibility Fix:";

            btnMapEditorCompatibilityFix                 = new XNAClientButton(WindowManager);
            btnMapEditorCompatibilityFix.Name            = "btnMapEditorCompatibilityFix";
            btnMapEditorCompatibilityFix.ClientRectangle = new Rectangle(
                btnGameCompatibilityFix.X,
                lblMapEditorCompatibilityFix.Y - 4,
                btnGameCompatibilityFix.Width,
                btnGameCompatibilityFix.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);
        }
        public LoadOrSaveGameOptionPresetWindow(WindowManager windowManager) : base(windowManager)
        {
            ClientRectangle = new Rectangle(0, 0, 325, 185);

            var margin = 10;

            lblHeader                 = new XNALabel(WindowManager);
            lblHeader.Name            = nameof(lblHeader);
            lblHeader.FontIndex       = 1;
            lblHeader.ClientRectangle = new Rectangle(
                margin, margin,
                150, 22
                );

            var lblPresetName = new XNALabel(WindowManager);

            lblPresetName.Name            = nameof(lblPresetName);
            lblPresetName.Text            = "Preset Name";
            lblPresetName.ClientRectangle = new Rectangle(
                margin, lblHeader.Bottom + margin,
                150, 18
                );

            ddiCreatePresetItem      = new XNADropDownItem();
            ddiCreatePresetItem.Text = "[Create New]";

            ddiSelectPresetItem            = new XNADropDownItem();
            ddiSelectPresetItem.Text       = "[Select Preset]";
            ddiSelectPresetItem.Selectable = false;

            ddPresetSelect                 = new XNAClientDropDown(WindowManager);
            ddPresetSelect.Name            = nameof(ddPresetSelect);
            ddPresetSelect.ClientRectangle = new Rectangle(
                10, lblPresetName.Bottom + 2,
                150, 22
                );
            ddPresetSelect.SelectedIndexChanged += DropDownPresetSelect_SelectedIndexChanged;

            lblNewPresetName                 = new XNALabel(WindowManager);
            lblNewPresetName.Name            = nameof(lblNewPresetName);
            lblNewPresetName.Text            = "New Preset Name";
            lblNewPresetName.ClientRectangle = new Rectangle(
                margin, ddPresetSelect.Bottom + margin,
                150, 18
                );

            tbNewPresetName                 = new XNATextBox(WindowManager);
            tbNewPresetName.Name            = nameof(tbNewPresetName);
            tbNewPresetName.ClientRectangle = new Rectangle(
                10, lblNewPresetName.Bottom + 2,
                150, 22
                );
            tbNewPresetName.TextChanged += (sender, args) => RefreshButtons();

            btnLoadSave                 = new XNAClientButton(WindowManager);
            btnLoadSave.Name            = nameof(btnLoadSave);
            btnLoadSave.LeftClick      += BtnLoadSave_LeftClick;
            btnLoadSave.ClientRectangle = new Rectangle(
                margin,
                Height - UIDesignConstants.BUTTON_HEIGHT - margin,
                UIDesignConstants.BUTTON_WIDTH_92,
                UIDesignConstants.BUTTON_HEIGHT
                );

            btnDelete                 = new XNAClientButton(WindowManager);
            btnDelete.Name            = nameof(btnDelete);
            btnDelete.Text            = "Delete";
            btnDelete.LeftClick      += BtnDelete_LeftClick;
            btnDelete.ClientRectangle = new Rectangle(
                btnLoadSave.Right + margin,
                btnLoadSave.Y,
                UIDesignConstants.BUTTON_WIDTH_92,
                UIDesignConstants.BUTTON_HEIGHT
                );

            var btnCancel = new XNAClientButton(WindowManager);

            btnCancel.Text            = "Cancel";
            btnCancel.ClientRectangle = new Rectangle(
                btnDelete.Right + margin,
                btnLoadSave.Y,
                UIDesignConstants.BUTTON_WIDTH_92,
                UIDesignConstants.BUTTON_HEIGHT
                );
            btnCancel.LeftClick += (sender, args) => Disable();

            AddChild(lblHeader);
            AddChild(lblPresetName);
            AddChild(ddPresetSelect);
            AddChild(lblNewPresetName);
            AddChild(tbNewPresetName);
            AddChild(btnLoadSave);
            AddChild(btnDelete);
            AddChild(btnCancel);

            Disable();
        }
Exemple #8
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);
        }
Exemple #9
0
        public override void Initialize()
        {
            ClientRectangle = new Rectangle(0, 0, WindowManager.RenderResolutionX - 64,
                                            WindowManager.RenderResolutionY - 64);

            Name = "CnCNetLobby";
            BackgroundTexture = AssetLoader.LoadTexture("cncnetlobbybg.png");
            localGameID       = ClientConfiguration.Instance.LocalGame;
            localGame         = gameCollection.GameList.Find(g => g.InternalName.ToUpper() == localGameID.ToUpper());

            btnNewGame                 = new XNAClientButton(WindowManager);
            btnNewGame.Name            = "btnNewGame";
            btnNewGame.ClientRectangle = new Rectangle(12, ClientRectangle.Height - 29, 133, 23);
            btnNewGame.Text            = "Create Game";
            btnNewGame.AllowClick      = false;
            btnNewGame.LeftClick      += BtnNewGame_LeftClick;

            btnJoinGame                 = new XNAClientButton(WindowManager);
            btnJoinGame.Name            = "btnJoinGame";
            btnJoinGame.ClientRectangle = new Rectangle(btnNewGame.ClientRectangle.Right + 12,
                                                        btnNewGame.ClientRectangle.Y, 133, 23);
            btnJoinGame.Text       = "Join Game";
            btnJoinGame.AllowClick = false;
            btnJoinGame.LeftClick += BtnJoinGame_LeftClick;

            btnLogout                 = new XNAClientButton(WindowManager);
            btnLogout.Name            = "btnLogout";
            btnLogout.ClientRectangle = new Rectangle(ClientRectangle.Width - 145, btnNewGame.ClientRectangle.Y,
                                                      133, 23);
            btnLogout.Text       = "Log Out";
            btnLogout.LeftClick += BtnLogout_LeftClick;

            lbGameList                 = new GameListBox(WindowManager, localGameID);
            lbGameList.Name            = "lbGameList";
            lbGameList.ClientRectangle = new Rectangle(btnNewGame.ClientRectangle.X,
                                                       41, btnJoinGame.ClientRectangle.Right - btnNewGame.ClientRectangle.X,
                                                       btnNewGame.ClientRectangle.Top - 47);
            lbGameList.DrawMode            = PanelBackgroundImageDrawMode.STRETCHED;
            lbGameList.BackgroundTexture   = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbGameList.DoubleLeftClick    += LbGameList_DoubleLeftClick;
            lbGameList.AllowMultiLineItems = false;

            lbPlayerList                 = new XNAListBox(WindowManager);
            lbPlayerList.Name            = "lbPlayerList";
            lbPlayerList.ClientRectangle = new Rectangle(ClientRectangle.Width - 202,
                                                         20, 190,
                                                         btnLogout.ClientRectangle.Top - 26);
            lbPlayerList.DrawMode          = PanelBackgroundImageDrawMode.STRETCHED;
            lbPlayerList.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbPlayerList.LineHeight        = 16;
            lbPlayerList.DoubleLeftClick  += LbPlayerList_DoubleLeftClick;
            lbPlayerList.RightClick       += LbPlayerList_RightClick;

            playerContextMenu                 = new PlayerContextMenu(WindowManager);
            playerContextMenu.Name            = "playerContextMenu";
            playerContextMenu.ClientRectangle = new Rectangle(0, 0, 150, 2);
            playerContextMenu.Enabled         = false;
            playerContextMenu.Visible         = false;
            playerContextMenu.AddItem("Private Message");
            playerContextMenu.AddItem("Add Friend");
            playerContextMenu.OptionSelected += PlayerContextMenu_OptionSelected;

            lbChatMessages                 = new ChatListBox(WindowManager);
            lbChatMessages.Name            = "lbChatMessages";
            lbChatMessages.ClientRectangle = new Rectangle(lbGameList.ClientRectangle.Right + 12, lbGameList.ClientRectangle.Y,
                                                           lbPlayerList.ClientRectangle.Left - lbGameList.ClientRectangle.Right - 24, lbPlayerList.ClientRectangle.Height);
            lbChatMessages.DrawMode          = PanelBackgroundImageDrawMode.STRETCHED;
            lbChatMessages.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbChatMessages.LineHeight        = 16;

            tbChatInput                 = new XNATextBox(WindowManager);
            tbChatInput.Name            = "tbChatInput";
            tbChatInput.ClientRectangle = new Rectangle(lbChatMessages.ClientRectangle.X,
                                                        btnNewGame.ClientRectangle.Y, lbChatMessages.ClientRectangle.Width,
                                                        btnNewGame.ClientRectangle.Height);
            tbChatInput.Enabled           = false;
            tbChatInput.MaximumTextLength = 200;
            tbChatInput.EnterPressed     += TbChatInput_EnterPressed;

            lblColor                 = new XNALabel(WindowManager);
            lblColor.Name            = "lblColor";
            lblColor.ClientRectangle = new Rectangle(lbChatMessages.ClientRectangle.X, 14, 0, 0);
            lblColor.FontIndex       = 1;
            lblColor.Text            = "YOUR COLOR:";

            ddColor                 = new XNAClientDropDown(WindowManager);
            ddColor.Name            = "ddColor";
            ddColor.ClientRectangle = new Rectangle(lblColor.ClientRectangle.X + 95, 12,
                                                    150, 21);

            chatColors = connectionManager.GetIRCColors();

            foreach (IRCColor color in connectionManager.GetIRCColors())
            {
                if (!color.Selectable)
                {
                    continue;
                }

                XNADropDownItem ddItem = new XNADropDownItem();
                ddItem.Text      = color.Name;
                ddItem.TextColor = color.XnaColor;
                ddItem.Tag       = color;

                ddColor.AddItem(ddItem);
            }

            int selectedColor = UserINISettings.Instance.ChatColor;

            ddColor.SelectedIndex = selectedColor >= ddColor.Items.Count || selectedColor < 0
                ? ClientConfiguration.Instance.DefaultPersonalChatColorIndex:
                                    selectedColor;
            SetChatColor();
            ddColor.SelectedIndexChanged += DdColor_SelectedIndexChanged;

            ddCurrentChannel                 = new XNAClientDropDown(WindowManager);
            ddCurrentChannel.Name            = "ddCurrentChannel";
            ddCurrentChannel.ClientRectangle = new Rectangle(
                lbChatMessages.ClientRectangle.Right - 200,
                ddColor.ClientRectangle.Y, 200, 21);
            ddCurrentChannel.SelectedIndexChanged += DdCurrentChannel_SelectedIndexChanged;
            ddCurrentChannel.AllowDropDown         = false;

            lblCurrentChannel                 = new XNALabel(WindowManager);
            lblCurrentChannel.Name            = "lblCurrentChannel";
            lblCurrentChannel.ClientRectangle = new Rectangle(
                ddCurrentChannel.ClientRectangle.X - 150,
                ddCurrentChannel.ClientRectangle.Y + 2, 0, 0);
            lblCurrentChannel.FontIndex = 1;
            lblCurrentChannel.Text      = "CURRENT CHANNEL:";

            InitializeGameList();

            AddChild(btnNewGame);
            AddChild(btnJoinGame);
            AddChild(btnLogout);

            AddChild(lbPlayerList);
            AddChild(lbChatMessages);
            AddChild(lbGameList);
            AddChild(tbChatInput);
            AddChild(lblColor);
            AddChild(ddColor);
            AddChild(lblCurrentChannel);
            AddChild(ddCurrentChannel);
            AddChild(playerContextMenu);

            base.Initialize();

            WindowManager.CenterControlOnScreen(this);

            PostUIInit();
        }