Ejemplo n.º 1
0
        public override void Initialize()
        {
            BackgroundTexture = AssetLoader.LoadTexture("missionselectorbg.png");
            ClientRectangle   = new Rectangle(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT);
            BorderColor       = UISettings.ActiveSettings.PanelBorderColor;

            Name = "CampaignSelector";

            var lblSelectCampaign = new XNALabel(WindowManager);

            lblSelectCampaign.Name            = "lblSelectCampaign";
            lblSelectCampaign.FontIndex       = 1;
            lblSelectCampaign.ClientRectangle = new Rectangle(12, 12, 0, 0);
            lblSelectCampaign.Text            = "MISSIONS:";

            lbCampaignList      = new XNAListBox(WindowManager);
            lbCampaignList.Name = "lbCampaignList";
            lbCampaignList.BackgroundTexture       = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 2, 2);
            lbCampaignList.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            lbCampaignList.ClientRectangle         = new Rectangle(12,
                                                                   lblSelectCampaign.Bottom + 6, 300, 516);
            lbCampaignList.SelectedIndexChanged += LbCampaignList_SelectedIndexChanged;

            var lblMissionDescriptionHeader = new XNALabel(WindowManager);

            lblMissionDescriptionHeader.Name            = "lblMissionDescriptionHeader";
            lblMissionDescriptionHeader.FontIndex       = 1;
            lblMissionDescriptionHeader.ClientRectangle = new Rectangle(
                lbCampaignList.Right + 12,
                lblSelectCampaign.Y, 0, 0);
            lblMissionDescriptionHeader.Text = "MISSION DESCRIPTION:";

            tbMissionDescription                 = new XNATextBlock(WindowManager);
            tbMissionDescription.Name            = "tbMissionDescription";
            tbMissionDescription.ClientRectangle = new Rectangle(
                lblMissionDescriptionHeader.X,
                lblMissionDescriptionHeader.Bottom + 6,
                Width - 24 - lbCampaignList.Right, 430);
            tbMissionDescription.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            tbMissionDescription.Alpha = 1.0f;

            tbMissionDescription.BackgroundTexture = AssetLoader.CreateTexture(AssetLoader.GetColorFromString(ClientConfiguration.Instance.AltUIBackgroundColor),
                                                                               tbMissionDescription.Width, tbMissionDescription.Height);

            var lblDifficultyLevel = new XNALabel(WindowManager);

            lblDifficultyLevel.Name      = "lblDifficultyLevel";
            lblDifficultyLevel.Text      = "DIFFICULTY LEVEL";
            lblDifficultyLevel.FontIndex = 1;
            Vector2 textSize = Renderer.GetTextDimensions(lblDifficultyLevel.Text, lblDifficultyLevel.FontIndex);

            lblDifficultyLevel.ClientRectangle = new Rectangle(
                tbMissionDescription.X + (tbMissionDescription.Width - (int)textSize.X) / 2,
                tbMissionDescription.Bottom + 12, (int)textSize.X, (int)textSize.Y);

            trbDifficultySelector                 = new XNATrackbar(WindowManager);
            trbDifficultySelector.Name            = "trbDifficultySelector";
            trbDifficultySelector.ClientRectangle = new Rectangle(
                tbMissionDescription.X, lblDifficultyLevel.Bottom + 6,
                tbMissionDescription.Width, 30);
            trbDifficultySelector.MinValue          = 0;
            trbDifficultySelector.MaxValue          = 2;
            trbDifficultySelector.BackgroundTexture = AssetLoader.CreateTexture(
                new Color(0, 0, 0, 128), 2, 2);
            trbDifficultySelector.ButtonTexture = AssetLoader.LoadTextureUncached(
                "trackbarButton_difficulty.png");

            var lblEasy = new XNALabel(WindowManager);

            lblEasy.Name            = "lblEasy";
            lblEasy.FontIndex       = 1;
            lblEasy.Text            = "EASY";
            lblEasy.ClientRectangle = new Rectangle(trbDifficultySelector.X,
                                                    trbDifficultySelector.Bottom + 6, 1, 1);

            var lblNormal = new XNALabel(WindowManager);

            lblNormal.Name            = "lblNormal";
            lblNormal.FontIndex       = 1;
            lblNormal.Text            = "NORMAL";
            textSize                  = Renderer.GetTextDimensions(lblNormal.Text, lblNormal.FontIndex);
            lblNormal.ClientRectangle = new Rectangle(
                tbMissionDescription.X + (tbMissionDescription.Width - (int)textSize.X) / 2,
                lblEasy.Y, (int)textSize.X, (int)textSize.Y);

            var lblHard = new XNALabel(WindowManager);

            lblHard.Name            = "lblHard";
            lblHard.FontIndex       = 1;
            lblHard.Text            = "HARD";
            lblHard.ClientRectangle = new Rectangle(
                tbMissionDescription.Right - lblHard.Width,
                lblEasy.Y, 1, 1);

            btnLaunch                 = new XNAClientButton(WindowManager);
            btnLaunch.Name            = "btnLaunch";
            btnLaunch.ClientRectangle = new Rectangle(12, Height - 35, UIDesignConstants.BUTTON_WIDTH_133, UIDesignConstants.BUTTON_HEIGHT);
            btnLaunch.Text            = "Launch";
            btnLaunch.AllowClick      = false;
            btnLaunch.LeftClick      += BtnLaunch_LeftClick;

            var btnCancel = new XNAClientButton(WindowManager);

            btnCancel.Name            = "btnCancel";
            btnCancel.ClientRectangle = new Rectangle(Width - 145,
                                                      btnLaunch.Y, UIDesignConstants.BUTTON_WIDTH_133, UIDesignConstants.BUTTON_HEIGHT);
            btnCancel.Text       = "Cancel";
            btnCancel.LeftClick += BtnCancel_LeftClick;

            AddChild(lblSelectCampaign);
            AddChild(lblMissionDescriptionHeader);
            AddChild(lbCampaignList);
            AddChild(tbMissionDescription);
            AddChild(lblDifficultyLevel);
            AddChild(btnLaunch);
            AddChild(btnCancel);
            AddChild(trbDifficultySelector);
            AddChild(lblEasy);
            AddChild(lblNormal);
            AddChild(lblHard);

            // Set control attributes from INI file
            base.Initialize();

            // Center on screen
            CenterOnParent();

            trbDifficultySelector.Value = UserINISettings.Instance.Difficulty;

            ParseBattleIni("INI/Battle.ini");
            ParseBattleIni("INI/" + ClientConfiguration.Instance.BattleFSFileName);

            cheaterWindow = new CheaterWindow(WindowManager);
            DarkeningPanel dp = new DarkeningPanel(WindowManager);

            dp.AddChild(cheaterWindow);
            AddChild(dp);
            dp.CenterOnParent();
            cheaterWindow.CenterOnParent();
            cheaterWindow.YesClicked += CheaterWindow_YesClicked;
            cheaterWindow.Disable();
        }
Ejemplo n.º 2
0
        public override void Initialize()
        {
            BackgroundTexture = AssetLoader.LoadTexture("missionselectorbg.png");
            ClientRectangle   = new Rectangle(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT);
            BorderColor       = UISettings.ActiveSettings.PanelBorderColor;

            Name = "CampaignSelector";

            var lblSelectCampaign = new XNALabel(WindowManager);

            lblSelectCampaign.Name            = "lblSelectCampaign";
            lblSelectCampaign.FontIndex       = 1;
            lblSelectCampaign.ClientRectangle = new Rectangle(12, 12, 0, 0);
            lblSelectCampaign.Text            = "MISSIONS:";

            lbCampaignList      = new BattleListBox(WindowManager);
            lbCampaignList.Name = "lbCampaignList";
            lbCampaignList.BackgroundTexture       = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 2, 2);
            lbCampaignList.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            lbCampaignList.ClientRectangle         = new Rectangle(12,
                                                                   lblSelectCampaign.Bottom + 6, 300, 516);
            lbCampaignList.SelectedIndexChanged += LbCampaignList_SelectedIndexChanged;

            var lblMissionDescriptionHeader = new XNALabel(WindowManager);

            lblMissionDescriptionHeader.Name            = "lblMissionDescriptionHeader";
            lblMissionDescriptionHeader.FontIndex       = 1;
            lblMissionDescriptionHeader.ClientRectangle = new Rectangle(
                lbCampaignList.Right + 12,
                lblSelectCampaign.Y, 0, 0);
            lblMissionDescriptionHeader.Text = "MISSION DESCRIPTION:";

            tbMissionDescription                 = new MissionDescriptionBox(WindowManager);
            tbMissionDescription.Name            = "tbMissionDescription";
            tbMissionDescription.ClientRectangle = new Rectangle(
                lblMissionDescriptionHeader.X,
                lblMissionDescriptionHeader.Bottom + 6,
                Width - 24 - lbCampaignList.Right, 430);
            tbMissionDescription.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            tbMissionDescription.Alpha = 1.0f;

            tbMissionDescription.BackgroundTexture = AssetLoader.CreateTexture(AssetLoader.GetColorFromString(ClientConfiguration.Instance.AltUIBackgroundColor),
                                                                               tbMissionDescription.Width, tbMissionDescription.Height);

            var lblDifficultyLevel = new XNALabel(WindowManager);

            lblDifficultyLevel.Name      = "lblDifficultyLevel";
            lblDifficultyLevel.Text      = "DIFFICULTY LEVEL";
            lblDifficultyLevel.FontIndex = 1;
            Vector2 textSize = Renderer.GetTextDimensions(lblDifficultyLevel.Text, lblDifficultyLevel.FontIndex);

            lblDifficultyLevel.ClientRectangle = new Rectangle(
                tbMissionDescription.X + (tbMissionDescription.Width - (int)textSize.X) / 2,
                tbMissionDescription.Bottom + 12, (int)textSize.X, (int)textSize.Y);

            trbDifficultySelector                 = new XNATrackbar(WindowManager);
            trbDifficultySelector.Name            = "trbDifficultySelector";
            trbDifficultySelector.ClientRectangle = new Rectangle(
                tbMissionDescription.X, lblDifficultyLevel.Bottom + 6,
                tbMissionDescription.Width, 30);
            trbDifficultySelector.MinValue          = 0;
            trbDifficultySelector.MaxValue          = 2;
            trbDifficultySelector.BackgroundTexture = AssetLoader.CreateTexture(
                new Color(0, 0, 0, 128), 2, 2);
            trbDifficultySelector.ButtonTexture = AssetLoader.LoadTextureUncached(
                "trackbarButton_difficulty.png");

            int y = lblDifficultyLevel.Y - UIDesignConstants.EMPTY_SPACE_BOTTOM;

            // Create controls for global variable customization
            // The indexes increase from bottom to top, meaning
            // that with 4 lines the global indexes go like this:
            // global slot #3
            // global slot #2
            // global slot #1
            // global slot #0
            for (int i = 0; i < MAX_GLOBAL_COUNT; i++)
            {
                globalVariableValues[i]       = new XNADropDown(WindowManager);
                globalVariableValues[i].Name  = "globalVariableValue" + i;
                globalVariableValues[i].X     = trbDifficultySelector.X;
                globalVariableValues[i].Width = trbDifficultySelector.Width;
                globalVariableValues[i].AddItem("Disabled");
                globalVariableValues[i].AddItem("Enabled");
                AddChild(globalVariableValues[i]);
                globalVariableValues[i].Y = y - (UIDesignConstants.EMPTY_SPACE_BOTTOM * 2) - globalVariableValues[i].Height;
                globalVariableValues[i].Disable();

                globalVariableNames[i]             = new XNALabel(WindowManager);
                globalVariableNames[i].Name        = "globalVariableName" + i;
                globalVariableNames[i].Text        = "Global Variable #" + i;
                globalVariableNames[i].TextAnchor  = LabelTextAnchorInfo.RIGHT;
                globalVariableNames[i].AnchorPoint = new Vector2(globalVariableValues[i].X, globalVariableValues[i].Y - globalVariableNames[i].Height);
                AddChild(globalVariableNames[i]);
                globalVariableNames[i].Disable();

                y = globalVariableNames[i].Y;
            }

            lblPreconditionsHeader             = new XNALabel(WindowManager);
            lblPreconditionsHeader.Name        = nameof(lblPreconditionsHeader);
            lblPreconditionsHeader.FontIndex   = UIDesignConstants.BOLD_FONT_INDEX;
            lblPreconditionsHeader.TextAnchor  = LabelTextAnchorInfo.HORIZONTAL_CENTER;
            lblPreconditionsHeader.AnchorPoint = new Vector2(trbDifficultySelector.ClientRectangle.Center.X,
                                                             globalVariableNames[0].Y - UIDesignConstants.CONTROL_VERTICAL_MARGIN * 2);
            lblPreconditionsHeader.Text = "PRECONDITIONS";
            AddChild(lblPreconditionsHeader);
            lblPreconditionsHeader.Disable();

            PreconditionUIConfig(null);

            lblEasy             = new XNALabel(WindowManager);
            lblEasy.Name        = "lblEasy";
            lblEasy.TextAnchor  = LabelTextAnchorInfo.RIGHT;
            lblEasy.AnchorPoint = new Vector2(trbDifficultySelector.X,
                                              trbDifficultySelector.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN);
            lblEasy.FontIndex = 1;
            lblEasy.Text      = DifficultyNamesUIDefault[0];

            lblNormal             = new XNALabel(WindowManager);
            lblNormal.Name        = "lblNormal";
            lblNormal.TextAnchor  = LabelTextAnchorInfo.HORIZONTAL_CENTER;
            lblNormal.AnchorPoint = new Vector2(trbDifficultySelector.ClientRectangle.Center.X, lblEasy.AnchorPoint.Y);
            lblNormal.FontIndex   = 1;
            lblNormal.Text        = DifficultyNamesUIDefault[1];

            lblHard             = new XNALabel(WindowManager);
            lblHard.Name        = "lblHard";
            lblHard.TextAnchor  = LabelTextAnchorInfo.LEFT;
            lblHard.AnchorPoint = new Vector2(trbDifficultySelector.Right, lblEasy.AnchorPoint.Y);
            lblHard.FontIndex   = 1;
            lblHard.Text        = DifficultyNamesUIDefault[2];

            btnLaunch                 = new XNAClientButton(WindowManager);
            btnLaunch.Name            = "btnLaunch";
            btnLaunch.ClientRectangle = new Rectangle(12, Height - 35, 133, 23);
            btnLaunch.Text            = "Launch";
            btnLaunch.AllowClick      = false;
            btnLaunch.LeftClick      += BtnLaunch_LeftClick;

            var btnCancel = new XNAClientButton(WindowManager);

            btnCancel.Name            = "btnCancel";
            btnCancel.ClientRectangle = new Rectangle(Width - 145,
                                                      btnLaunch.Y, 133, 23);
            btnCancel.Text       = "Cancel";
            btnCancel.LeftClick += BtnCancel_LeftClick;

            AddChild(lblSelectCampaign);
            AddChild(lblMissionDescriptionHeader);
            AddChild(lbCampaignList);
            AddChild(tbMissionDescription);
            AddChild(lblDifficultyLevel);
            AddChild(btnLaunch);
            AddChild(btnCancel);
            AddChild(trbDifficultySelector);
            AddChild(lblEasy);
            AddChild(lblNormal);
            AddChild(lblHard);

            // Set control attributes from INI file
            base.Initialize();

            // Center on screen
            CenterOnParent();

            trbDifficultySelector.Value = UserINISettings.Instance.Difficulty;

            cheaterWindow = new CheaterWindow(WindowManager);
            DarkeningPanel dp = new DarkeningPanel(WindowManager);

            dp.AddChild(cheaterWindow);
            AddChild(dp);
            dp.CenterOnParent();
            cheaterWindow.CenterOnParent();
            cheaterWindow.YesClicked += CheaterWindow_YesClicked;
            cheaterWindow.Disable();

            EnabledChanged += CampaignSelector_EnabledChanged;

            missionCompletionNotification = new MissionCompletionNotification(WindowManager);
            WindowManager.AddAndInitializeControl(missionCompletionNotification);
            missionCompletionNotification.DrawOrder   = 9999;
            missionCompletionNotification.UpdateOrder = 9999;
            missionCompletionNotification.Disable();

            CampaignHandler.Instance.MissionRankUpdated += CampaignHandler_MissionRankUpdated;
            CampaignHandler.Instance.MissionCompleted   += CampaignHandler_MissionCompleted;
        }