Esempio n. 1
0
 private void CloseKeybindings()
 {
     mControlsContainer.Hide();
     mOptionsContainer.Show();
     mOptionsHeader.SetText(Strings.Options.title);
     mApplyKeybindingsButton.Hide();
     mCancelKeybindingsButton.Hide();
     mRestoreKeybindingsButton.Hide();
 }
Esempio n. 2
0
        private void EditKeybindingsButton_Clicked(Base sender, ClickedEventArgs arguments)
        {
            //Determine if controls are currently being shown or not
            if (!mControlsContainer.IsVisible)
            {
                mControlsContainer.Show();
                mOptionsContainer.Hide();
                mOptionsHeader.SetText(Strings.Controls.title);
                mApplyKeybindingsButton.Show();
                mCancelKeybindingsButton.Show();
                mRestoreKeybindingsButton.Show();
                foreach (Control control in Enum.GetValues(typeof(Control)))
                {
                    mKeyButtons[control][0].Text =
                        Strings.Keys.keydict[
                            Enum.GetName(typeof(Keys), mEdittingControls.ControlMapping[control].Key1).ToLower()];

                    mKeyButtons[control][1].Text =
                        Strings.Keys.keydict[
                            Enum.GetName(typeof(Keys), mEdittingControls.ControlMapping[control].Key2).ToLower()];
                }
            }
        }
Esempio n. 3
0
        private void UpdateSelectedQuest()
        {
            if (mSelectedQuest == null)
            {
                mQuestList.Show();
                mQuestTitle.Hide();
                mQuestDescArea.Hide();
                mQuestStatus.Hide();
                mBackButton.Hide();
                mQuitButton.Hide();
            }
            else
            {
                mQuestDescLabel.ClearText();
                mQuitButton.IsDisabled = true;
                ListBoxRow rw;
                string[]   myText     = null;
                var        taskString = new List <string>();
                if (Globals.Me.QuestProgress.ContainsKey(mSelectedQuest.Id))
                {
                    if (Globals.Me.QuestProgress[mSelectedQuest.Id].TaskId != Guid.Empty)
                    {
                        //In Progress
                        mQuestStatus.SetText(Strings.QuestLog.inprogress);
                        mQuestStatus.SetTextColor(Color.Yellow, Label.ControlState.Normal);
                        if (mSelectedQuest.InProgressDescription.Length > 0)
                        {
                            mQuestDescLabel.AddText(
                                mSelectedQuest.InProgressDescription, Color.White, Alignments.Left,
                                mQuestDescTemplateLabel.Font
                                );

                            mQuestDescLabel.AddLineBreak();
                            mQuestDescLabel.AddLineBreak();
                        }

                        mQuestDescLabel.AddText(
                            Strings.QuestLog.currenttask, Color.White, Alignments.Left, mQuestDescTemplateLabel.Font
                            );

                        mQuestDescLabel.AddLineBreak();
                        for (var i = 0; i < mSelectedQuest.Tasks.Count; i++)
                        {
                            if (mSelectedQuest.Tasks[i].Id == Globals.Me.QuestProgress[mSelectedQuest.Id].TaskId)
                            {
                                if (mSelectedQuest.Tasks[i].Description.Length > 0)
                                {
                                    mQuestDescLabel.AddText(
                                        mSelectedQuest.Tasks[i].Description, Color.White, Alignments.Left,
                                        mQuestDescTemplateLabel.Font
                                        );

                                    mQuestDescLabel.AddLineBreak();
                                    mQuestDescLabel.AddLineBreak();
                                }

                                if (mSelectedQuest.Tasks[i].Objective == QuestObjective.GatherItems) //Gather Items
                                {
                                    mQuestDescLabel.AddText(
                                        Strings.QuestLog.taskitem.ToString(
                                            Globals.Me.QuestProgress[mSelectedQuest.Id].TaskProgress,
                                            mSelectedQuest.Tasks[i].Quantity,
                                            ItemBase.GetName(mSelectedQuest.Tasks[i].TargetId)
                                            ), Color.White, Alignments.Left, mQuestDescTemplateLabel.Font
                                        );
                                }
                                else if (mSelectedQuest.Tasks[i].Objective == QuestObjective.KillNpcs) //Kill Npcs
                                {
                                    mQuestDescLabel.AddText(
                                        Strings.QuestLog.tasknpc.ToString(
                                            Globals.Me.QuestProgress[mSelectedQuest.Id].TaskProgress,
                                            mSelectedQuest.Tasks[i].Quantity,
                                            NpcBase.GetName(mSelectedQuest.Tasks[i].TargetId)
                                            ), Color.White, Alignments.Left, mQuestDescTemplateLabel.Font
                                        );
                                }
                            }
                        }

                        mQuitButton.IsDisabled = !mSelectedQuest.Quitable;
                    }
                    else
                    {
                        if (Globals.Me.QuestProgress[mSelectedQuest.Id].Completed)
                        {
                            //Completed
                            if (mSelectedQuest.LogAfterComplete)
                            {
                                mQuestStatus.SetText(Strings.QuestLog.completed);
                                mQuestStatus.SetTextColor(Color.Green, Label.ControlState.Normal);
                                mQuestDescLabel.AddText(
                                    mSelectedQuest.EndDescription, Color.White, Alignments.Left,
                                    mQuestDescTemplateLabel.Font
                                    );
                            }
                        }
                        else
                        {
                            //Not Started
                            if (mSelectedQuest.LogBeforeOffer)
                            {
                                mQuestStatus.SetText(Strings.QuestLog.notstarted);
                                mQuestStatus.SetTextColor(Color.Red, Label.ControlState.Normal);
                                mQuestDescLabel.AddText(
                                    mSelectedQuest.BeforeDescription, Color.White, Alignments.Left,
                                    mQuestDescTemplateLabel.Font
                                    );

                                mQuitButton?.Hide();
                            }
                        }
                    }
                }
                else
                {
                    //Not Started
                    if (mSelectedQuest.LogBeforeOffer)
                    {
                        mQuestStatus.SetText(Strings.QuestLog.notstarted);
                        mQuestStatus.SetTextColor(Color.Red, Label.ControlState.Normal);
                        mQuestDescLabel.AddText(
                            mSelectedQuest.BeforeDescription, Color.White, Alignments.Left, mQuestDescTemplateLabel.Font
                            );
                    }
                }

                mQuestList.Hide();
                mQuestTitle.IsHidden    = false;
                mQuestTitle.Text        = mSelectedQuest.Name;
                mQuestDescArea.IsHidden = false;
                mQuestDescLabel.Width   = mQuestDescArea.Width - mQuestDescArea.GetVerticalScrollBar().Width;
                mQuestDescLabel.SizeToChildren(false, true);
                mQuestStatus.Show();
                mBackButton.Show();
                mQuitButton.Show();
            }
        }
Esempio n. 4
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();
                    }
                }
            }
        }
Esempio n. 5
0
        //Init
        public OptionsWindow(Canvas parent, MainMenu mainMenu, ImagePanel parentPanel)
        {
            //Assign References
            mMainMenu = mainMenu;

            //Main Menu Window
            mOptionsPanel = new ImagePanel(parent, "OptionsWindow")
            {
                IsHidden = true
            };
            Interface.InputBlockingElements.Add(mOptionsPanel);

            //Menu Header
            mOptionsHeader = new Label(mOptionsPanel, "OptionsHeader");
            mOptionsHeader.SetText(Strings.Options.title);

            //Options Get Stored in the Options Scroll Control
            mOptionsContainer = new ScrollControl(mOptionsPanel, "OptionsContainer");
            mOptionsContainer.EnableScroll(false, false);
            mOptionsContainer.Show();

            //Resolution Background
            mResolutionBackground = new ImagePanel(mOptionsContainer, "ResolutionPanel");

            //Options - Resolution Label
            mResolutionLabel = new Label(mResolutionBackground, "ResolutionLabel");
            mResolutionLabel.SetText(Strings.Options.resolution);

            mResolutionList = new ComboBox(mResolutionBackground, "ResolutionCombobox");
            var myModes = Graphics.Renderer.GetValidVideoModes();

            myModes?.ForEach(
                t =>
            {
                var item       = mResolutionList.AddItem(t);
                item.Alignment = Pos.Left;
            }
                );

            //FPS Background
            mFpsBackground = new ImagePanel(mOptionsContainer, "FPSPanel");

            //Options - FPS Label
            mFpsLabel = new Label(mFpsBackground, "FPSLabel");
            mFpsLabel.SetText(Strings.Options.targetfps);

            //Options - FPS List
            mFpsList = new ComboBox(mFpsBackground, "FPSCombobox");
            mFpsList.AddItem(Strings.Options.vsync);
            mFpsList.AddItem(Strings.Options.fps30);
            mFpsList.AddItem(Strings.Options.fps60);
            mFpsList.AddItem(Strings.Options.fps90);
            mFpsList.AddItem(Strings.Options.fps120);
            mFpsList.AddItem(Strings.Options.unlimitedfps);

            //Options - Fullscreen Checkbox
            mFullscreen = new LabeledCheckBox(mOptionsContainer, "FullscreenCheckbox")
            {
                Text = Strings.Options.fullscreen
            };

            mAutocloseWindowsCheckbox = new LabeledCheckBox(mOptionsContainer, "AutocloseWindowsCheckbox")
            {
                Text = Strings.Options.AutocloseWindows
            };

            mEditKeybindingsBtn = new Button(mOptionsContainer, "KeybindingsButton")
            {
                Text = Strings.Controls.edit
            };
            mEditKeybindingsBtn.Clicked += EditKeybindingsButton_Clicked;

            //Options - Sound Label
            mSoundLabel = new Label(mOptionsContainer, "SoundLabel");
            mSoundLabel.SetText(Strings.Options.soundvolume.ToString(100));

            //Options - Sound Slider
            mSoundSlider               = new HorizontalSlider(mOptionsContainer, "SoundSlider");
            mSoundSlider.Min           = 0;
            mSoundSlider.Max           = 100;
            mSoundSlider.ValueChanged += _soundSlider_ValueChanged;

            //Options - Music Label
            mMusicLabel = new Label(mOptionsContainer, "MusicLabel");
            mMusicLabel.SetText(Strings.Options.musicvolume.ToString(100));

            //Options - Music Slider
            mMusicSlider               = new HorizontalSlider(mOptionsContainer, "MusicSlider");
            mMusicSlider.Min           = 0;
            mMusicSlider.Max           = 100;
            mMusicSlider.ValueChanged += _musicSlider_ValueChanged;

            //Controls Get Stored in the Controls Scroll Control
            mControlsContainer = new ScrollControl(mOptionsPanel, "ControlsContainer");
            mControlsContainer.EnableScroll(false, true);
            mControlsContainer.Hide();

            mApplyKeybindingsButton      = new Button(mOptionsPanel, "ExitControlsButton");
            mApplyKeybindingsButton.Text = Strings.Options.apply;
            mApplyKeybindingsButton.Hide();
            mApplyKeybindingsButton.Clicked += ApplyKeybindingsButton_Clicked;

            mCancelKeybindingsButton      = new Button(mOptionsPanel, "CancelControlsButton");
            mCancelKeybindingsButton.Text = Strings.Options.back;
            mCancelKeybindingsButton.Hide();
            mCancelKeybindingsButton.Clicked += CancelKeybindingsButton_Clicked;

            mRestoreKeybindingsButton      = new Button(mOptionsPanel, "RestoreControlsButton");
            mRestoreKeybindingsButton.Text = Strings.Options.restore;
            mRestoreKeybindingsButton.Hide();
            mRestoreKeybindingsButton.Clicked += RestoreKeybindingsButton_Clicked;

            var row         = 0;
            var defaultFont = GameContentManager.Current?.GetFont("sourcesansproblack", 16);

            foreach (Control control in Enum.GetValues(typeof(Control)))
            {
                var offset = row * 32;
                var name   = Enum.GetName(typeof(Control), control)?.ToLower();

                var label = new Label(mControlsContainer, $"Control{Enum.GetName( typeof( Control ), control )}Label")
                {
                    Text = Strings.Controls.controldict[name],
                    AutoSizeToContents = true,
                    Font = defaultFont
                };

                label.SetBounds(8, 8 + offset, 0, 24);
                label.SetTextColor(new Color(255, 255, 255, 255), Label.ControlState.Normal);

                var key1 = new Button(mControlsContainer, $"Control{Enum.GetName( typeof( Control ), control )}Button1")
                {
                    Text = "",
                    AutoSizeToContents = false,
                    UserData           = new KeyValuePair <Control, int>(control, 1),
                    Font = defaultFont
                };

                key1.Clicked += Key_Clicked;

                var key2 = new Button(mControlsContainer, $"Control{Enum.GetName( typeof( Control ), control )}Button2")
                {
                    Text = "",
                    AutoSizeToContents = false,
                    UserData           = new KeyValuePair <Control, int>(control, 2),
                    Font = defaultFont
                };

                key2.Clicked += Key_Clicked;

                mKeyButtons.Add(control, new[] { key1, key2 });

                row++;
            }

            //Options - Apply Button
            mApplyBtn = new Button(mOptionsContainer, "ApplyButton");
            mApplyBtn.SetText(Strings.Options.apply);
            mApplyBtn.Clicked += ApplyBtn_Clicked;

            //Options - Back Button
            mBackBtn = new Button(mOptionsContainer, "CancelButton");
            mBackBtn.SetText(Strings.Options.cancel);
            mBackBtn.Clicked += BackBtn_Clicked;

            Input.KeyDown   += OnKeyDown;
            Input.MouseDown += OnKeyDown;

            mOptionsPanel.LoadJsonUi(
                mainMenu == null ? GameContentManager.UI.InGame : GameContentManager.UI.Menu,
                Graphics.Renderer.GetResolutionString()
                );

            CloseKeybindings();
        }