Пример #1
0
        //Update
        public void Update()
        {
            if (mEventDialogWindow.IsHidden)
            {
                Interface.InputBlockingElements.Remove(this);
            }
            else
            {
                if (!Interface.InputBlockingElements.Contains(this))
                {
                    Interface.InputBlockingElements.Add(this);
                }
            }

            if (Globals.EventDialogs.Count > 0)
            {
                if (mEventDialogWindow.IsHidden)
                {
                    base.Show();
                    mEventDialogWindow.Show();
                    mEventDialogWindow.MakeModal();
                    mEventDialogArea.ScrollToTop();
                    mEventDialogWindow.BringToFront();
                    var faceTex = Globals.ContentManager.GetTexture(
                        GameContentManager.TextureType.Face, Globals.EventDialogs[0].Face
                        );

                    var responseCount = 0;
                    var maxResponse   = 1;
                    if (Globals.EventDialogs[0].Opt1.Length > 0)
                    {
                        responseCount++;
                    }

                    if (Globals.EventDialogs[0].Opt2.Length > 0)
                    {
                        responseCount++;
                        maxResponse = 2;
                    }

                    if (Globals.EventDialogs[0].Opt3.Length > 0)
                    {
                        responseCount++;
                        maxResponse = 3;
                    }

                    if (Globals.EventDialogs[0].Opt4.Length > 0)
                    {
                        responseCount++;
                        maxResponse = 4;
                    }

                    mEventResponse1.Name = "";
                    mEventResponse2.Name = "";
                    mEventResponse3.Name = "";
                    mEventResponse4.Name = "";
                    switch (maxResponse)
                    {
                    case 1:
                        mEventDialogWindow.Name = "EventDialogWindow_1Response";
                        mEventResponse1.Name    = "Response1Button";

                        break;

                    case 2:
                        mEventDialogWindow.Name = "EventDialogWindow_2Responses";
                        mEventResponse1.Name    = "Response1Button";
                        mEventResponse2.Name    = "Response2Button";

                        break;

                    case 3:
                        mEventDialogWindow.Name = "EventDialogWindow_3Responses";
                        mEventResponse1.Name    = "Response1Button";
                        mEventResponse2.Name    = "Response2Button";
                        mEventResponse3.Name    = "Response3Button";

                        break;

                    case 4:
                        mEventDialogWindow.Name = "EventDialogWindow_4Responses";
                        mEventResponse1.Name    = "Response1Button";
                        mEventResponse2.Name    = "Response2Button";
                        mEventResponse3.Name    = "Response3Button";
                        mEventResponse4.Name    = "Response4Button";

                        break;
                    }

                    mEventDialogWindow.LoadJsonUi(
                        GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString()
                        );

                    if (faceTex != null)
                    {
                        mEventFace.Show();
                        mEventFace.Texture = faceTex;
                        mEventDialogArea.Show();
                        mEventDialogAreaNoFace.Hide();
                    }
                    else
                    {
                        mEventFace.Hide();
                        mEventDialogArea.Hide();
                        mEventDialogAreaNoFace.Show();
                    }

                    if (responseCount == 0)
                    {
                        mEventResponse1.Show();
                        mEventResponse1.SetText(Strings.EventWindow.Continue);
                        mEventResponse2.Hide();
                        mEventResponse3.Hide();
                        mEventResponse4.Hide();
                    }
                    else
                    {
                        if (Globals.EventDialogs[0].Opt1 != "")
                        {
                            mEventResponse1.Show();
                            mEventResponse1.SetText(Globals.EventDialogs[0].Opt1);
                        }
                        else
                        {
                            mEventResponse1.Hide();
                        }

                        if (Globals.EventDialogs[0].Opt2 != "")
                        {
                            mEventResponse2.Show();
                            mEventResponse2.SetText(Globals.EventDialogs[0].Opt2);
                        }
                        else
                        {
                            mEventResponse2.Hide();
                        }

                        if (Globals.EventDialogs[0].Opt3 != "")
                        {
                            mEventResponse3.Show();
                            mEventResponse3.SetText(Globals.EventDialogs[0].Opt3);
                        }
                        else
                        {
                            mEventResponse3.Hide();
                        }

                        if (Globals.EventDialogs[0].Opt4 != "")
                        {
                            mEventResponse4.Show();
                            mEventResponse4.SetText(Globals.EventDialogs[0].Opt4);
                        }
                        else
                        {
                            mEventResponse4.Hide();
                        }
                    }

                    mEventDialogWindow.SetSize(
                        mEventDialogWindow.Texture.GetWidth(), mEventDialogWindow.Texture.GetHeight()
                        );

                    if (faceTex != null)
                    {
                        mEventDialogLabel.ClearText();
                        mEventDialogLabel.Width = mEventDialogArea.Width -
                                                  mEventDialogArea.GetVerticalScrollBar().Width;

                        mEventDialogLabel.AddText(
                            Globals.EventDialogs[0].Prompt, mEventDialogLabelTemplate.TextColor,
                            mEventDialogLabelTemplate.CurAlignments.Count > 0
                                ? mEventDialogLabelTemplate.CurAlignments[0]
                                : Alignments.Left, mEventDialogLabelTemplate.Font
                            );

                        mEventDialogLabel.SizeToChildren(false, true);
                        mEventDialogArea.ScrollToTop();
                    }
                    else
                    {
                        mEventDialogLabelNoFace.ClearText();
                        mEventDialogLabelNoFace.Width = mEventDialogAreaNoFace.Width -
                                                        mEventDialogAreaNoFace.GetVerticalScrollBar().Width;

                        mEventDialogLabelNoFace.AddText(
                            Globals.EventDialogs[0].Prompt, mEventDialogLabelNoFaceTemplate.TextColor,
                            mEventDialogLabelNoFaceTemplate.CurAlignments.Count > 0
                                ? mEventDialogLabelNoFaceTemplate.CurAlignments[0]
                                : Alignments.Left, mEventDialogLabelNoFaceTemplate.Font
                            );

                        mEventDialogLabelNoFace.SizeToChildren(false, true);
                        mEventDialogAreaNoFace.ScrollToTop();
                    }
                }
            }
        }
Пример #2
0
        public void Show()
        {
            if (mMainMenu == null)
            {
                mOptionsPanel.MakeModal(true);
            }

            mPreviousMusicVolume = Globals.Database.MusicVolume;
            mPreviousSoundVolume = Globals.Database.SoundVolume;
            mEdittingControls    = new Controls(Controls.ActiveControls);
            if (Graphics.Renderer.GetValidVideoModes().Count > 0)
            {
                string resolutionLabel;
                if (Graphics.Renderer.HasOverrideResolution)
                {
                    resolutionLabel = Strings.Options.ResolutionCustom;

                    if (mCustomResolutionMenuItem == null)
                    {
                        mCustomResolutionMenuItem = mResolutionList.AddItem(Strings.Options.ResolutionCustom);
                    }

                    mCustomResolutionMenuItem.Show();
                }
                else
                {
                    resolutionLabel = Graphics.Renderer.GetValidVideoModes()[Globals.Database.TargetResolution];
                }

                mResolutionList.SelectByText(resolutionLabel);
            }

            switch (Globals.Database.TargetFps)
            {
            case -1:     //Unlimited
                mFpsList.SelectByText(Strings.Options.unlimitedfps);

                break;

            case 0:     //VSYNC
                mFpsList.SelectByText(Strings.Options.vsync);

                break;

            case 1:
                mFpsList.SelectByText(Strings.Options.fps30);

                break;

            case 2:
                mFpsList.SelectByText(Strings.Options.fps60);

                break;

            case 3:
                mFpsList.SelectByText(Strings.Options.fps90);

                break;

            case 4:
                mFpsList.SelectByText(Strings.Options.fps120);

                break;

            default:
                mFpsList.SelectByText(Strings.Options.vsync);

                break;
            }

            mAutocloseWindowsCheckbox.IsChecked = Globals.Database.HideOthersOnWindowOpen;
            mFullscreen.IsChecked  = Globals.Database.FullScreen;
            mMusicSlider.Value     = Globals.Database.MusicVolume;
            mSoundSlider.Value     = Globals.Database.SoundVolume;
            mMusicLabel.Text       = Strings.Options.musicvolume.ToString((int)mMusicSlider.Value);
            mSoundLabel.Text       = Strings.Options.soundvolume.ToString((int)mSoundSlider.Value);
            mOptionsPanel.IsHidden = false;
        }