Ejemplo n.º 1
0
        public override void Initialize()
        {
            Name              = "OptionsWindow";
            ClientRectangle   = new Rectangle(0, 0, 576, 435);
            BackgroundTexture = AssetLoader.LoadTextureUncached("optionsbg.png");

            tabControl                 = new XNAClientTabControl(WindowManager);
            tabControl.Name            = "tabControl";
            tabControl.ClientRectangle = new Rectangle(12, 12, 0, 23);
            tabControl.FontIndex       = 1;
            tabControl.ClickSound      = new EnhancedSoundEffect("button.wav");
            tabControl.AddTab("Display", 92);
            tabControl.AddTab("Audio", 92);
            tabControl.AddTab("Game", 92);
            tabControl.AddTab("CnCNet", 92);
            tabControl.AddTab("Updater", 92);
            tabControl.AddTab("Components", 92);
            tabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged;

            var btnCancel = new XNAClientButton(WindowManager);

            btnCancel.Name            = "btnCancel";
            btnCancel.ClientRectangle = new Rectangle(Width - 104,
                                                      Height - 35, 92, 23);
            btnCancel.Text       = "Cancel";
            btnCancel.LeftClick += BtnBack_LeftClick;

            var btnSave = new XNAClientButton(WindowManager);

            btnSave.Name            = "btnSave";
            btnSave.ClientRectangle = new Rectangle(12, btnCancel.Y, 92, 23);
            btnSave.Text            = "Save";
            btnSave.LeftClick      += BtnSave_LeftClick;

            displayOptionsPanel = new DisplayOptionsPanel(WindowManager, UserINISettings.Instance);
            componentsPanel     = new ComponentsPanel(WindowManager, UserINISettings.Instance);
            var updaterOptionsPanel = new UpdaterOptionsPanel(WindowManager, UserINISettings.Instance);

            updaterOptionsPanel.OnForceUpdate += (s, e) => { Disable(); OnForceUpdate?.Invoke(this, EventArgs.Empty); };

            optionsPanels = new XNAOptionsPanel[]
            {
                displayOptionsPanel,
                new AudioOptionsPanel(WindowManager, UserINISettings.Instance),
                new GameOptionsPanel(WindowManager, UserINISettings.Instance, topBar),
                new CnCNetOptionsPanel(WindowManager, UserINISettings.Instance, gameCollection),
                updaterOptionsPanel,
                componentsPanel
            };

            if (ClientConfiguration.Instance.ModMode || CUpdater.UPDATEMIRRORS == null || CUpdater.UPDATEMIRRORS.Count < 1)
            {
                tabControl.MakeUnselectable(4);
                tabControl.MakeUnselectable(5);
            }
            else if (CUpdater.CustomComponents == null || CUpdater.CustomComponents.Length < 1)
            {
                tabControl.MakeUnselectable(5);
            }

            foreach (var panel in optionsPanels)
            {
                AddChild(panel);
                panel.Load();
                panel.Disable();
            }

            optionsPanels[0].Enable();

            AddChild(tabControl);
            AddChild(btnCancel);
            AddChild(btnSave);

            base.Initialize();

            CenterOnParent();
        }
Ejemplo n.º 2
0
        public override void Initialize()
        {
            Name              = "OptionsWindow";
            ClientRectangle   = new Rectangle(0, 0, 576, 435);
            BackgroundTexture = AssetLoader.LoadTextureUncached("optionsbg.png");

            tabControl                 = new XNAClientTabControl(WindowManager);
            tabControl.Name            = "tabControl";
            tabControl.ClientRectangle = new Rectangle(12, 12, 0, 23);
            tabControl.FontIndex       = 1;
            tabControl.ClickSound      = new EnhancedSoundEffect("button.wav");
            tabControl.AddTab("Display", 92);
            tabControl.AddTab("Audio", 92);
            tabControl.AddTab("Game", 92);
            tabControl.AddTab("CnCNet", 92);
            if (!ClientConfiguration.Instance.DisableUpdaterOptions)
            {
                tabControl.AddTab("Updater", 92);
                if (!ClientConfiguration.Instance.DisableComponentOptions)
                {
                    tabControl.AddTab("Components", 92);
                }
            }
            tabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged;

            var btnCancel = new XNAClientButton(WindowManager);

            btnCancel.Name            = "btnCancel";
            btnCancel.ClientRectangle = new Rectangle(Width - 104,
                                                      Height - 35, 92, 23);
            btnCancel.Text       = "Cancel";
            btnCancel.LeftClick += BtnBack_LeftClick;

            var btnSave = new XNAClientButton(WindowManager);

            btnSave.Name            = "btnSave";
            btnSave.ClientRectangle = new Rectangle(12, btnCancel.Y, 92, 23);
            btnSave.Text            = "Save";
            btnSave.LeftClick      += BtnSave_LeftClick;

            displayOptionsPanel = new DisplayOptionsPanel(WindowManager, UserINISettings.Instance);
            componentsPanel     = new ComponentsPanel(WindowManager, UserINISettings.Instance);

            optionsPanels = new XNAOptionsPanel[]
            {
                displayOptionsPanel,
                new AudioOptionsPanel(WindowManager, UserINISettings.Instance),
                new GameOptionsPanel(WindowManager, UserINISettings.Instance, topBar),
                new CnCNetOptionsPanel(WindowManager, UserINISettings.Instance, gameCollection),
                new UpdaterOptionsPanel(WindowManager, UserINISettings.Instance),
                componentsPanel
            };

            foreach (var panel in optionsPanels)
            {
                AddChild(panel);
                panel.Load();
                panel.Disable();
            }

            optionsPanels[0].Enable();

            AddChild(tabControl);
            AddChild(btnCancel);
            AddChild(btnSave);

            base.Initialize();

            CenterOnParent();
        }