Example #1
0
        //Init
        public LoginWindow(Canvas parent, MainMenu mainMenu, ImagePanel parentPanel)
        {
            //Assign References
            mMainMenu = mainMenu;

            //Main Menu Window
            mLoginWindow = new ImagePanel(parent, "LoginWindow");

            //Menu Header
            mLoginHeader = new Label(mLoginWindow, "LoginHeader");
            mLoginHeader.SetText(Strings.Login.title);

            mUsernameBackground = new ImagePanel(mLoginWindow, "UsernamePanel");

            //Login Username Label
            mUsernameLabel = new Label(mUsernameBackground, "UsernameLabel");
            mUsernameLabel.SetText(Strings.Login.username);

            //Login Username Textbox
            mUsernameTextbox = new TextBox(mUsernameBackground, "UsernameField");
            mUsernameTextbox.SubmitPressed += UsernameTextbox_SubmitPressed;
            mUsernameTextbox.Clicked       += _usernameTextbox_Clicked;

            mPasswordBackground = new ImagePanel(mLoginWindow, "PasswordPanel");

            //Login Password Label
            mPasswordLabel = new Label(mPasswordBackground, "PasswordLabel");
            mPasswordLabel.SetText(Strings.Login.password);

            //Login Password Textbox
            mPasswordTextbox = new TextBoxPassword(mPasswordBackground, "PasswordField");
            mPasswordTextbox.SubmitPressed += PasswordTextbox_SubmitPressed;
            mPasswordTextbox.TextChanged   += _passwordTextbox_TextChanged;

            //Login Save Pass Checkbox
            mSavePassChk = new LabeledCheckBox(mLoginWindow, "SavePassCheckbox")
            {
                Text = Strings.Login.savepass
            };

            //Forgot Password Button
            mForgotPassswordButton          = new Button(mLoginWindow, "ForgotPasswordButton");
            mForgotPassswordButton.IsHidden = true;
            mForgotPassswordButton.SetText(Strings.Login.forgot);
            mForgotPassswordButton.Clicked += mForgotPassswordButton_Clicked;

            //Login - Send Login Button
            mLoginBtn = new Button(mLoginWindow, "LoginButton");
            mLoginBtn.SetText(Strings.Login.login);
            mLoginBtn.Clicked += LoginBtn_Clicked;

            //Login - Back Button
            mBackBtn = new Button(mLoginWindow, "BackButton");
            mBackBtn.SetText(Strings.Login.back);
            mBackBtn.Clicked += BackBtn_Clicked;

            LoadCredentials();

            mLoginWindow.LoadJsonUi(GameContentManager.UI.Menu, Graphics.Renderer.GetResolutionString());
        }
Example #2
0
        //Init
        public Menu(Canvas gameCanvas)
        {
            mGameCanvas = gameCanvas;

            mMenuContainer = new ImagePanel(gameCanvas, "MenuContainer");
            mMenuContainer.ShouldCacheToTexture = true;

            mInventoryBackground = new ImagePanel(mMenuContainer, "InventoryContainer");
            mInventoryButton     = new Button(mInventoryBackground, "InventoryButton");
            mInventoryButton.SetToolTipText(Strings.GameMenu.items);
            mInventoryButton.Clicked += InventoryButton_Clicked;

            mSpellsBackground = new ImagePanel(mMenuContainer, "SpellsContainer");
            mSpellsButton     = new Button(mSpellsBackground, "SpellsButton");
            mSpellsButton.SetToolTipText(Strings.GameMenu.spells);
            mSpellsButton.Clicked += SpellsButton_Clicked;

            mCharacterBackground = new ImagePanel(mMenuContainer, "CharacterContainer");
            mCharacterButton     = new Button(mCharacterBackground, "CharacterButton");
            mCharacterButton.SetToolTipText(Strings.GameMenu.character);
            mCharacterButton.Clicked += CharacterButton_Clicked;

            mQuestsBackground = new ImagePanel(mMenuContainer, "QuestsContainer");
            mQuestsButton     = new Button(mQuestsBackground, "QuestsButton");
            mQuestsButton.SetToolTipText(Strings.GameMenu.quest);
            mQuestsButton.Clicked += QuestBtn_Clicked;

            mFriendsBackground = new ImagePanel(mMenuContainer, "FriendsContainer");
            mFriendsButton     = new Button(mFriendsBackground, "FriendsButton");
            mFriendsButton.SetToolTipText(Strings.GameMenu.friends);
            mFriendsButton.Clicked += FriendsBtn_Clicked;

            mPartyBackground = new ImagePanel(mMenuContainer, "PartyContainer");
            mPartyButton     = new Button(mPartyBackground, "PartyButton");
            mPartyButton.SetToolTipText(Strings.GameMenu.party);
            mPartyButton.Clicked += PartyBtn_Clicked;

            mGuildBackground = new ImagePanel(mMenuContainer, "GuildContainer");
            mGuildButton     = new Button(mGuildBackground, "GuildButton");
            mGuildButton.SetToolTipText(Strings.Guilds.Guild);
            mGuildButton.Clicked += GuildBtn_Clicked;

            mMenuBackground = new ImagePanel(mMenuContainer, "MenuContainer");
            mMenuButton     = new Button(mMenuBackground, "MenuButton");
            mMenuButton.SetToolTipText(Strings.GameMenu.Menu);
            mMenuButton.Clicked += MenuButtonClicked;

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

            //Assign Window References
            mPartyWindow     = new PartyWindow(gameCanvas);
            mFriendsWindow   = new FriendsWindow(gameCanvas);
            mInventoryWindow = new InventoryWindow(gameCanvas);
            mSpellsWindow    = new SpellsWindow(gameCanvas);
            mCharacterWindow = new CharacterWindow(gameCanvas);
            mQuestsWindow    = new QuestsWindow(gameCanvas);
            mMapItemWindow   = new MapItemWindow(gameCanvas);
            mGuildWindow     = new GuildWindow(gameCanvas);
        }
        /// <summary>
        /// Create a new instance of the <see cref="AnnouncementWindow"/> class.
        /// </summary>
        /// <param name="gameCanvas">The <see cref="Canvas"/> to render this control on.</param>
        public AnnouncementWindow(Canvas gameCanvas)
        {
            mGameCanvas = gameCanvas;
            mPicture    = new ImagePanel(gameCanvas, "AnnouncementWindow");
            mLabel      = new Label(mPicture, "AnnouncementLabel");

            mPicture.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());
        }
Example #4
0
        public EscapeMenu([NotNull] Canvas gameCanvas) : base(gameCanvas, "EscapeMenu")
        {
            Interface.InputBlockingElements?.Add(this);

            Width  = gameCanvas.Width;
            Height = gameCanvas.Height;

            mContainer = new ImagePanel(this, "EscapeMenu");

            mTitle = new Label(mContainer, "TitleLabel")
            {
                Text = Strings.EscapeMenu.Title,
            };

            mOptionsWindow = new OptionsWindow(gameCanvas, null, null);

            mOptions = new Button(mContainer, "OptionsButton")
            {
                Text = Strings.EscapeMenu.Options
            };

            mOptions.Clicked += Options_Clicked;

            mGoToCharacterSelect = new Button(mContainer, "CharacterSelectButton")
            {
                Text = Strings.EscapeMenu.CharacterSelect
            };

            mGoToCharacterSelect.Clicked += GoToCharacterSelect_Clicked;

            mLogout = new Button(mContainer, "LogoutButton")
            {
                Text = Strings.EscapeMenu.Logout
            };

            mLogout.Clicked += Logout_Clicked;

            mExitToDesktop = new Button(mContainer, "ExitToDesktopButton")
            {
                Text = Strings.EscapeMenu.ExitToDesktop
            };

            mExitToDesktop.Clicked += ExitToDesktop_Clicked;

            mClose = new Button(mContainer, "CloseButton")
            {
                Text = Strings.EscapeMenu.Close
            };

            mClose.Clicked += Close_Clicked;

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

            if (Options.Player.MaxCharacters <= 1)
            {
                mGoToCharacterSelect.IsDisabled = true;
            }
        }
        //Init
        public SelectCharacterWindow(Canvas parent, MainMenu mainMenu, ImagePanel parentPanel)
        {
            //Assign References
            mMainMenu = mainMenu;

            //Main Menu Window
            mCharacterSelectionPanel = new ImagePanel(parent, "CharacterSelectionWindow");

            //Menu Header
            mCharacterSelectionHeader = new Label(mCharacterSelectionPanel, "CharacterSelectionHeader");
            mCharacterSelectionHeader.SetText(Strings.CharacterSelection.title);

            //Character Name
            mCharnameLabel = new Label(mCharacterSelectionPanel, "CharacterNameLabel");
            mCharnameLabel.SetText(Strings.CharacterSelection.empty);

            //Character Info
            mInfoLabel = new Label(mCharacterSelectionPanel, "CharacterInfoLabel");
            mInfoLabel.SetText(Strings.CharacterSelection.New);

            //Character Container
            mCharacterContainer = new ImagePanel(mCharacterSelectionPanel, "CharacterContainer");

            //Next char Button
            mNextCharButton          = new Button(mCharacterContainer, "NextCharacterButton");
            mNextCharButton.Clicked += _nextCharButton_Clicked;

            //Prev Char Button
            mPrevCharButton          = new Button(mCharacterContainer, "PreviousCharacterButton");
            mPrevCharButton.Clicked += _prevCharButton_Clicked;

            //Play Button
            mPlayButton = new Button(mCharacterSelectionPanel, "PlayButton");
            mPlayButton.SetText(Strings.CharacterSelection.play);
            mPlayButton.Clicked += _playButton_Clicked;
            mPlayButton.Hide();

            //Delete Button
            mDeleteButton = new Button(mCharacterSelectionPanel, "DeleteButton");
            mDeleteButton.SetText(Strings.CharacterSelection.delete);
            mDeleteButton.Clicked += _deleteButton_Clicked;
            mDeleteButton.Hide();

            //Create new char Button
            mNewButton = new Button(mCharacterSelectionPanel, "NewButton");
            mNewButton.SetText(Strings.CharacterSelection.New);
            mNewButton.Clicked += _newButton_Clicked;

            //Logout Button
            mLogoutButton = new Button(mCharacterSelectionPanel, "LogoutButton");
            mLogoutButton.SetText(Strings.CharacterSelection.logout);
            mLogoutButton.IsHidden = true;
            mLogoutButton.Clicked += mLogoutButton_Clicked;

            mCharacterSelectionPanel.LoadJsonUi(GameContentManager.UI.Menu, Graphics.Renderer.GetResolutionString());
        }
Example #6
0
        //Init
        public Chatbox(Canvas gameCanvas, GameInterface gameUi)
        {
            mGameUi = gameUi;

            //Chatbox Window
            mChatboxWindow   = new ImagePanel(gameCanvas, "ChatboxWindow");
            mChatboxMessages = new ListBox(mChatboxWindow, "MessageList");
            mChatboxMessages.EnableScroll(false, true);
            mChatboxWindow.ShouldCacheToTexture = true;

            mChatboxTitle          = new Label(mChatboxWindow, "ChatboxTitle");
            mChatboxTitle.Text     = Strings.Chatbox.title;
            mChatboxTitle.IsHidden = true;

            mChatbar          = new ImagePanel(mChatboxWindow, "Chatbar");
            mChatbar.IsHidden = true;

            mChatboxInput = new TextBox(mChatboxWindow, "ChatboxInputField");
            mChatboxInput.SubmitPressed += ChatBoxInput_SubmitPressed;
            mChatboxInput.Text           = GetDefaultInputText();
            mChatboxInput.Clicked       += ChatBoxInput_Clicked;
            mChatboxInput.IsTabable      = false;
            mChatboxInput.SetMaxLength(Options.MaxChatLength);
            Interface.FocusElements.Add(mChatboxInput);

            mChannelLabel          = new Label(mChatboxWindow, "ChannelLabel");
            mChannelLabel.Text     = Strings.Chatbox.channel;
            mChannelLabel.IsHidden = true;

            mChannelCombobox = new ComboBox(mChatboxWindow, "ChatChannelCombobox");
            for (var i = 0; i < 3; i++)
            {
                var menuItem = mChannelCombobox.AddItem(Strings.Chatbox.channels[i]);
                menuItem.UserData = i;
            }

            //Add admin channel only if power > 0.
            if (Globals.Me.Type > 0)
            {
                var menuItem = mChannelCombobox.AddItem(Strings.Chatbox.channeladmin);
                menuItem.UserData = 3;
            }

            mChatboxText      = new Label(mChatboxWindow);
            mChatboxText.Name = "ChatboxText";
            mChatboxText.Font = mChatboxWindow.Parent.Skin.DefaultFont;

            mChatboxSendButton          = new Button(mChatboxWindow, "ChatboxSendButton");
            mChatboxSendButton.Text     = Strings.Chatbox.send;
            mChatboxSendButton.Clicked += ChatBoxSendBtn_Clicked;

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

            mChatboxText.IsHidden = true;
        }
Example #7
0
        //Init
        public ResetPasswordWindow(Canvas parent, MainMenu mainMenu, ImagePanel parentPanel)
        {
            //Assign References
            mMainMenu = mainMenu;

            //Main Menu Window
            mResetWindow          = new ImagePanel(parent, "ResetPasswordWindow");
            mResetWindow.IsHidden = true;

            //Menu Header
            mWindowHeader = new Label(mResetWindow, "Header");
            mWindowHeader.SetText(Strings.ResetPass.title);

            //Code Fields/Labels
            mCodeInputBackground = new ImagePanel(mResetWindow, "CodePanel");

            mCodeInputLabel = new Label(mCodeInputBackground, "CodeLabel");
            mCodeInputLabel.SetText(Strings.ResetPass.code);

            mCodeInputTextbox = new TextBox(mCodeInputBackground, "CodeField");
            mCodeInputTextbox.SubmitPressed += Textbox_SubmitPressed;
            mCodeInputTextbox.Clicked       += Textbox_Clicked;

            //Password Fields/Labels
            //Register Password Background
            mPasswordBackground = new ImagePanel(mResetWindow, "Password1Panel");

            mPasswordLabel = new Label(mPasswordBackground, "Password1Label");
            mPasswordLabel.SetText(Strings.ResetPass.password);

            mPasswordTextbox = new TextBoxPassword(mPasswordBackground, "Password1Field");
            mPasswordTextbox.SubmitPressed += PasswordTextbox_SubmitPressed;

            //Confirm Password Fields/Labels
            mPasswordBackground2 = new ImagePanel(mResetWindow, "Password2Panel");

            mPasswordLabel2 = new Label(mPasswordBackground2, "Password2Label");
            mPasswordLabel2.SetText(Strings.ResetPass.password2);

            mPasswordTextbox2 = new TextBoxPassword(mPasswordBackground2, "Password2Field");
            mPasswordTextbox2.SubmitPressed += PasswordTextbox2_SubmitPressed;

            //Login - Send Login Button
            mSubmitBtn = new Button(mResetWindow, "SubmitButton");
            mSubmitBtn.SetText(Strings.ResetPass.submit);
            mSubmitBtn.Clicked += SubmitBtn_Clicked;

            //Login - Back Button
            mBackBtn = new Button(mResetWindow, "BackButton");
            mBackBtn.SetText(Strings.ResetPass.back);
            mBackBtn.Clicked += BackBtn_Clicked;

            mResetWindow.LoadJsonUi(GameContentManager.UI.Menu, Graphics.Renderer.GetResolutionString());
        }
Example #8
0
        public Draggable(int x, int y, GameTexture tex)
        {
            mPnl = new ImagePanel(Interface.GameUi.GameCanvas, "Draggable");
            mPnl.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());
            mPnl.SetPosition(
                InputHandler.MousePosition.X - mPnl.Width / 2, InputHandler.MousePosition.Y - mPnl.Height / 2
                );

            mPnl.Texture = tex;
            Active       = this;
        }
Example #9
0
        public MenuGuiBase(Canvas myCanvas)
        {
            mMenuCanvas        = myCanvas;
            MainMenu           = new MainMenu(mMenuCanvas);
            mServerStatusArea  = new ImagePanel(mMenuCanvas, "ServerStatusArea");
            mServerStatusLabel = new Label(mServerStatusArea, "ServerStatusLabel")
            {
                Text = Strings.Server.StatusLabel.ToString(MainMenu.ActiveNetworkStatus.ToLocalizedString()),
            };

            mServerStatusArea.LoadJsonUi(GameContentManager.UI.Menu, Graphics.Renderer.GetResolutionString());
            MainMenu.NetworkStatusChanged += HandleNetworkStatusChanged;
        }
Example #10
0
        //Init
        public HotBarWindow(Canvas gameCanvas)
        {
            HotbarWindow = new ImagePanel(gameCanvas, "HotbarWindow");
            HotbarWindow.ShouldCacheToTexture = true;
            InitHotbarItems();
            HotbarWindow.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());

            for (var i = 0; i < Items.Count; i++)
            {
                if (Items[i].EquipPanel.Texture == null)
                {
                    Items[i].EquipPanel.Texture = Graphics.Renderer.GetWhiteTexture();
                }
            }
        }
Example #11
0
        //Init
        public ForgotPasswordWindow(Canvas parent, MainMenu mainMenu, ImagePanel parentPanel)
        {
            //Assign References
            mMainMenu = mainMenu;

            //Main Menu Window
            mResetWindow          = new ImagePanel(parent, "ForgotPasswordWindow");
            mResetWindow.IsHidden = true;

            //Menu Header
            mWindowHeader = new Label(mResetWindow, "Header");
            mWindowHeader.SetText(Strings.ForgotPass.title);

            mInputBackground = new ImagePanel(mResetWindow, "InputPanel");

            //Login Username Label
            mInputLabel = new Label(mInputBackground, "InputLabel");
            mInputLabel.SetText(Strings.ForgotPass.label);

            //Login Username Textbox
            mInputTextbox = new TextBox(mInputBackground, "InputField");
            mInputTextbox.SubmitPressed += Textbox_SubmitPressed;
            mInputTextbox.Clicked       += Textbox_Clicked;

            mHintLabelTemplate          = new Label(mResetWindow, "HintLabel");
            mHintLabelTemplate.IsHidden = true;

            //Login - Send Login Button
            mSubmitBtn = new Button(mResetWindow, "SubmitButton");
            mSubmitBtn.SetText(Strings.ForgotPass.submit);
            mSubmitBtn.Clicked += SubmitBtn_Clicked;

            //Login - Back Button
            mBackBtn = new Button(mResetWindow, "BackButton");
            mBackBtn.SetText(Strings.ForgotPass.back);
            mBackBtn.Clicked += BackBtn_Clicked;

            mResetWindow.LoadJsonUi(GameContentManager.UI.Menu, Graphics.Renderer.GetResolutionString());

            mHintLabel = new RichLabel(mResetWindow);
            mHintLabel.SetBounds(mHintLabelTemplate.Bounds);
            mHintLabelTemplate.IsHidden = false;
            mHintLabel.AddText(
                Strings.ForgotPass.hint, mHintLabelTemplate.TextColor,
                mHintLabelTemplate.CurAlignments.Count > 0 ? mHintLabelTemplate.CurAlignments[0] : Alignments.Left,
                mHintLabelTemplate.Font
                );
        }
        //Init
        public MapItemWindow(Canvas gameCanvas)
        {
            mMapItemWindow = new ImagePanel(gameCanvas, "MapItemWindow");
            mMenuHeader    = new Label(mMapItemWindow, "Title");
            mMenuHeader.SetText(Strings.MapItemWindow.Title);

            mItemContainer = new ScrollControl(mMapItemWindow, "ItemsContainer");
            mItemContainer.EnableScroll(false, true);

            mBtnLootAll          = new Button(mMapItemWindow, "LootAllButton");
            mBtnLootAll.Text     = Strings.MapItemWindow.LootButton;
            mBtnLootAll.Clicked += MBtnLootAll_Clicked;

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

            CreateItemContainer();
        }
        //Init
        public CreditsWindow(Canvas parent, MainMenu mainMenu)
        {
            //Assign References
            mMainMenu = mainMenu;

            //Main Menu Window
            mCreditsWindow = new ImagePanel(parent, "CreditsWindow");

            //Menu Header
            mCreditsHeader = new Label(mCreditsWindow, "CreditsHeader");
            mCreditsHeader.SetText(Strings.Credits.title);

            mCreditsContent = new ScrollControl(mCreditsWindow, "CreditsScrollview");
            mCreditsContent.EnableScroll(false, true);

            mRichLabel = new RichLabel(mCreditsContent, "CreditsLabel");

            //Back Button
            mBackBtn = new Button(mCreditsWindow, "BackButton");
            mBackBtn.SetText(Strings.Credits.back);
            mBackBtn.Clicked += BackBtn_Clicked;

            mCreditsWindow.LoadJsonUi(GameContentManager.UI.Menu, Graphics.Renderer.GetResolutionString());
        }
Example #14
0
        public SpellDescWindow(Guid spellId, int x, int y, bool centerHorizontally = false)
        {
            var spell = SpellBase.Get(spellId);

            if (spell == null)
            {
                return;
            }

            mDescWindow = new ImagePanel(Interface.GameUi.GameCanvas, "SpellDescWindowExpanded");

            var icon = new ImagePanel(mDescWindow, "SpellIcon");

            var spellName = new Label(mDescWindow, "SpellName");

            spellName.Text = spell.Name;

            var spellType = new Label(mDescWindow, "SpellType");

            spellType.Text = Strings.SpellDesc.spelltypes[(int)spell.SpellType];

            var spellDesc     = new RichLabel(mDescWindow, "SpellDesc");
            var spellStats    = new RichLabel(mDescWindow, "SpellStats");
            var spellDescText = new Label(mDescWindow, "SpellDescText");

            spellDescText.Font = spellDescText.Parent.Skin.DefaultFont;
            var spellStatsText = new Label(mDescWindow, "SpellStatsText");

            spellStatsText.Font     = spellStatsText.Parent.Skin.DefaultFont;
            spellDescText.IsHidden  = true;
            spellStatsText.IsHidden = true;

            //Load this up now so we know what color to make the text when filling out the desc
            mDescWindow.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());
            if (spell.Description.Length > 0)
            {
                spellDesc.AddText(
                    Strings.SpellDesc.desc.ToString(spell.Description), spellDesc.RenderColor,
                    spellDescText.CurAlignments.Count > 0 ? spellDescText.CurAlignments[0] : Alignments.Left,
                    spellDescText.Font
                    );

                spellDesc.AddLineBreak();
                spellDesc.AddLineBreak();
            }

            if (spell.SpellType == (int)SpellTypes.CombatSpell)
            {
                if (spell.Combat.TargetType == SpellTargetTypes.Projectile)
                {
                    var proj = ProjectileBase.Get(spell.Combat.ProjectileId);
                    spellType.Text = Strings.SpellDesc.targettypes[(int)spell.Combat.TargetType]
                                     .ToString(proj?.Range ?? 0, spell.Combat.HitRadius);
                }
                else
                {
                    spellType.Text = Strings.SpellDesc.targettypes[(int)spell.Combat.TargetType]
                                     .ToString(spell.Combat.CastRange, spell.Combat.HitRadius);
                }
            }

            if (spell.SpellType == (int)SpellTypes.CombatSpell &&
                (spell.Combat.TargetType == SpellTargetTypes.AoE ||
                 spell.Combat.TargetType == SpellTargetTypes.Single) &&
                spell.Combat.HitRadius > 0)
            {
                spellStats.AddText(
                    Strings.SpellDesc.radius.ToString(spell.Combat.HitRadius), spellStats.RenderColor,
                    spellStatsText.CurAlignments.Count > 0 ? spellStatsText.CurAlignments[0] : Alignments.Left,
                    spellStatsText.Font
                    );

                spellStats.AddLineBreak();
                spellStats.AddLineBreak();
            }

            if (spell.CastDuration > 0)
            {
                var castDuration = (float)spell.CastDuration / 1000f;
                spellStats.AddText(
                    Strings.SpellDesc.casttime.ToString(castDuration), spellStats.RenderColor,
                    spellStatsText.CurAlignments.Count > 0 ? spellStatsText.CurAlignments[0] : Alignments.Left,
                    spellStatsText.Font
                    );

                spellStats.AddLineBreak();
                if (spell.CooldownDuration <= 0)
                {
                    spellStats.AddLineBreak();
                }
            }

            if (spell.CooldownDuration > 0)
            {
                var cdr = 1 - Globals.Me.GetCooldownReduction() / 100;
                var cd  = (float)(spell.CooldownDuration * cdr) / 1000f;
                spellStats.AddText(
                    Strings.SpellDesc.cooldowntime.ToString(cd), spellStats.RenderColor,
                    spellStatsText.CurAlignments.Count > 0 ? spellStatsText.CurAlignments[0] : Alignments.Left,
                    spellStatsText.Font
                    );

                spellStats.AddLineBreak();
                spellStats.AddLineBreak();
            }

            var requirements = spell.VitalCost[(int)Vitals.Health] > 0 || spell.VitalCost[(int)Vitals.Mana] > 0;

            if (requirements == true)
            {
                spellStats.AddText(
                    Strings.SpellDesc.prereqs, spellStats.RenderColor,
                    spellStatsText.CurAlignments.Count > 0 ? spellStatsText.CurAlignments[0] : Alignments.Left,
                    spellStatsText.Font
                    );

                spellStats.AddLineBreak();
                if (spell.VitalCost[(int)Vitals.Health] > 0)
                {
                    spellStats.AddText(
                        Strings.SpellDesc.vitalcosts[(int)Vitals.Health]
                        .ToString(spell.VitalCost[(int)Vitals.Health]), spellStats.RenderColor,
                        spellStatsText.CurAlignments.Count > 0 ? spellStatsText.CurAlignments[0] : Alignments.Left,
                        spellStatsText.Font
                        );

                    spellStats.AddLineBreak();
                }

                if (spell.VitalCost[(int)Vitals.Mana] > 0)
                {
                    spellStats.AddText(
                        Strings.SpellDesc.vitalcosts[(int)Vitals.Mana].ToString(spell.VitalCost[(int)Vitals.Mana]),
                        spellStats.RenderColor,
                        spellStatsText.CurAlignments.Count > 0 ? spellStatsText.CurAlignments[0] : Alignments.Left,
                        spellStatsText.Font
                        );

                    spellStats.AddLineBreak();
                }

                spellStats.AddLineBreak();
            }

            var stats = "";

            if (spell.SpellType == (int)SpellTypes.CombatSpell)
            {
                stats = Strings.SpellDesc.effects;
                spellStats.AddText(
                    stats, spellStats.RenderColor,
                    spellStatsText.CurAlignments.Count > 0 ? spellStatsText.CurAlignments[0] : Alignments.Left,
                    spellStatsText.Font
                    );

                spellStats.AddLineBreak();

                if (spell.Combat.Effect > 0)
                {
                    spellStats.AddText(
                        Strings.SpellDesc.effectlist[(int)spell.Combat.Effect], spellStats.RenderColor,
                        spellStatsText.CurAlignments.Count > 0 ? spellStatsText.CurAlignments[0] : Alignments.Left,
                        spellStatsText.Font
                        );

                    spellStats.AddLineBreak();
                }

                for (var i = 0; i < (int)Vitals.VitalCount; i++)
                {
                    var vitalDiff = spell.Combat.VitalDiff?[i] ?? 0;
                    if (vitalDiff == 0)
                    {
                        continue;
                    }

                    var vitalSymbol = vitalDiff < 0 ? Strings.SpellDesc.addsymbol : Strings.SpellDesc.removesymbol;
                    if (spell.Combat.Effect == StatusTypes.Shield)
                    {
                        stats = Strings.SpellDesc.shield.ToString(Math.Abs(vitalDiff));
                    }
                    else
                    {
                        stats = Strings.SpellDesc.vitals[i].ToString(vitalSymbol, Math.Abs(vitalDiff));
                    }

                    spellStats.AddText(
                        stats, spellStats.RenderColor,
                        spellStatsText.CurAlignments.Count > 0 ? spellStatsText.CurAlignments[0] : Alignments.Left,
                        spellStatsText.Font
                        );

                    spellStats.AddLineBreak();
                }

                if (spell.Combat.Duration > 0)
                {
                    for (var i = 0; i < (int)Stats.StatCount; i++)
                    {
                        if (spell.Combat.StatDiff[i] != 0)
                        {
                            spellStats.AddText(
                                Strings.SpellDesc.stats[i]
                                .ToString(
                                    (spell.Combat.StatDiff[i] > 0
                                            ? Strings.SpellDesc.addsymbol.ToString()
                                            : Strings.SpellDesc.removesymbol.ToString()) +
                                    Math.Abs(spell.Combat.StatDiff[i])
                                    ), spellStats.RenderColor,
                                spellStatsText.CurAlignments.Count > 0
                                    ? spellStatsText.CurAlignments[0]
                                    : Alignments.Left, spellStatsText.Font
                                );

                            spellStats.AddLineBreak();
                        }
                    }

                    var duration = (float)spell.Combat.Duration / 1000f;
                    spellStats.AddText(
                        Strings.SpellDesc.duration.ToString(duration), spellStats.RenderColor,
                        spellStatsText.CurAlignments.Count > 0 ? spellStatsText.CurAlignments[0] : Alignments.Left,
                        spellStatsText.Font
                        );

                    spellStats.AddLineBreak();
                }
            }

            spellStats.SizeToChildren(false, true);
            if (spellStats.Children.Count == 0)
            {
                mDescWindow.Name    = "SpellDescWindow";
                spellStats.Name     = "";
                spellStatsText.Name = "";
            }

            //Load Again for positioning purposes.
            mDescWindow.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());
            spellDescText.IsHidden  = true;
            spellStatsText.IsHidden = true;
            icon.Texture            = Globals.ContentManager.GetTexture(GameContentManager.TextureType.Spell, spell.Icon);
            spellStats.SizeToChildren(false, true);
            if (centerHorizontally)
            {
                mDescWindow.MoveTo(x - mDescWindow.Width / 2, y + mDescWindow.Padding.Top);
            }
            else
            {
                mDescWindow.MoveTo(x - mDescWindow.Width - mDescWindow.Padding.Right, y + mDescWindow.Padding.Top);
            }
        }
        //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();
                    }
                }
            }
        }
Example #16
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();
        }
        public ItemDescWindow(
            ItemBase item,
            int amount,
            int x,
            int y,
            int[] statBuffs,
            string titleOverride    = "",
            string valueLabel       = "",
            bool centerHorizontally = false
            )
        {
            var title = titleOverride;

            if (string.IsNullOrWhiteSpace(title))
            {
                title = item.Name;
            }

            mDescWindow = new ImagePanel(Interface.GameUi.GameCanvas, "ItemDescWindow");
            if (item != null && item.ItemType == ItemTypes.Equipment)
            {
                mDescWindow.Name = "ItemDescWindowExpanded";
            }

            if (item != null)
            {
                var icon = new ImagePanel(mDescWindow, "ItemIcon");

                var itemName = new Label(mDescWindow, "ItemNameLabel");
                itemName.Text = title;

                var itemQuantity = new Label(mDescWindow, "ItemQuantityLabel");

                if (amount > 1)
                {
                    itemQuantity.Text += amount.ToString("N0").Replace(",", Strings.Numbers.comma);
                }

                itemName.AddAlignment(Alignments.CenterH);

                var itemType  = new Label(mDescWindow, "ItemTypeLabel");
                var itemValue = new Label(mDescWindow, "ItemValueLabel");

                itemType.Text = Strings.ItemDesc.itemtypes[(int)item.ItemType];
                itemValue.SetText(valueLabel);

                if (item.ItemType == ItemTypes.Equipment &&
                    item.EquipmentSlot >= 0 &&
                    item.EquipmentSlot < Options.EquipmentSlots.Count)
                {
                    itemType.Text = Options.EquipmentSlots[item.EquipmentSlot];
                    if (item.EquipmentSlot == Options.WeaponIndex && item.TwoHanded)
                    {
                        itemType.Text += " - " + Strings.ItemDesc.twohand;
                    }
                }

                if (item.Rarity > 0)
                {
                    itemType.Text += " - " + Strings.ItemDesc.rarity[item.Rarity];
                    var rarity = CustomColors.Items.Rarities.ContainsKey(item.Rarity)
                        ? CustomColors.Items.Rarities[item.Rarity]
                        : Color.White;

                    itemType.TextColorOverride.R = rarity.R;
                    itemType.TextColorOverride.G = rarity.G;
                    itemType.TextColorOverride.B = rarity.B;
                    itemType.TextColorOverride.A = rarity.A;
                }

                var itemDesc     = new RichLabel(mDescWindow, "ItemDescription");
                var itemDescText = new Label(mDescWindow, "ItemDescText");
                itemDescText.Font = itemDescText.Parent.Skin.DefaultFont;
                var itemStatsText = new Label(mDescWindow, item.ItemType == ItemTypes.Equipment ? "ItemStatsText" : "");
                itemStatsText.Font = itemStatsText.Parent.Skin.DefaultFont;
                var itemStats = new RichLabel(mDescWindow, item.ItemType == ItemTypes.Equipment ? "ItemStats" : "");
                itemDescText.IsHidden  = true;
                itemStatsText.IsHidden = true;

                //Load this up now so we know what color to make the text when filling out the desc
                mDescWindow.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());
                if (item.Description.Length > 0)
                {
                    itemDesc.AddText(
                        Strings.ItemDesc.desc.ToString(item.Description), itemDesc.RenderColor,
                        itemDescText.CurAlignments.Count > 0 ? itemDescText.CurAlignments[0] : Alignments.Left,
                        itemDescText.Font
                        );

                    itemDesc.AddLineBreak();
                    itemDesc.AddLineBreak();
                }

                var stats = "";
                if (item.ItemType == ItemTypes.Equipment)
                {
                    stats = Strings.ItemDesc.bonuses;
                    itemStats.AddText(
                        stats, itemStats.RenderColor,
                        itemStatsText.CurAlignments.Count > 0 ? itemStatsText.CurAlignments[0] : Alignments.Left,
                        itemDescText.Font
                        );

                    itemStats.AddLineBreak();
                    if (item.ItemType == ItemTypes.Equipment && item.EquipmentSlot == Options.WeaponIndex)
                    {
                        stats = Strings.ItemDesc.damage.ToString(item.Damage);
                        itemStats.AddText(
                            stats, itemStats.RenderColor,
                            itemStatsText.CurAlignments.Count > 0 ? itemStatsText.CurAlignments[0] : Alignments.Left,
                            itemDescText.Font
                            );

                        itemStats.AddLineBreak();
                    }

                    for (var i = 0; i < (int)Vitals.VitalCount; i++)
                    {
                        var bonus = item.VitalsGiven[i].ToString();
                        if (item.PercentageVitalsGiven[i] > 0)
                        {
                            if (item.VitalsGiven[i] > 0)
                            {
                                bonus += " + ";
                            }
                            else
                            {
                                bonus = "";
                            }

                            bonus += item.PercentageVitalsGiven[i] + "%";
                        }

                        var vitals = Strings.ItemDesc.vitals[i].ToString(bonus);
                        itemStats.AddText(
                            vitals, itemStats.RenderColor,
                            itemStatsText.CurAlignments.Count > 0 ? itemStatsText.CurAlignments[0] : Alignments.Left,
                            itemDescText.Font
                            );

                        itemStats.AddLineBreak();
                    }

                    if (statBuffs != null)
                    {
                        for (var i = 0; i < (int)Stats.StatCount; i++)
                        {
                            var flatStat = item.StatsGiven[i] + statBuffs[i];
                            var bonus    = flatStat.ToString();

                            if (item.PercentageStatsGiven[i] > 0)
                            {
                                if (flatStat > 0)
                                {
                                    bonus += " + ";
                                }
                                else
                                {
                                    bonus = "";
                                }

                                bonus += item.PercentageStatsGiven[i] + "%";
                            }

                            stats = Strings.ItemDesc.stats[i].ToString(bonus);
                            itemStats.AddText(
                                stats, itemStats.RenderColor,
                                itemStatsText.CurAlignments.Count > 0
                                    ? itemStatsText.CurAlignments[0]
                                    : Alignments.Left, itemDescText.Font
                                );

                            itemStats.AddLineBreak();
                        }
                    }
                }

                if (item.ItemType == ItemTypes.Equipment &&
                    item.Effect.Type != EffectType.None &&
                    item.Effect.Percentage > 0)
                {
                    itemStats.AddText(
                        Strings.ItemDesc.effect.ToString(
                            item.Effect.Percentage, Strings.ItemDesc.effects[(int)item.Effect.Type - 1]
                            ), itemStats.RenderColor,
                        itemStatsText.CurAlignments.Count > 0 ? itemStatsText.CurAlignments[0] : Alignments.Left,
                        itemDescText.Font
                        );
                }

                //Load Again for positioning purposes.
                mDescWindow.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());
                var itemTex = Globals.ContentManager.GetTexture(GameContentManager.TextureType.Item, item.Icon);
                if (itemTex != null)
                {
                    icon.Texture     = itemTex;
                    icon.RenderColor = item.Color;
                }

                itemDesc.SizeToChildren(false, true);
                itemStats.SizeToChildren(false, true);
                itemDescText.IsHidden  = true;
                itemStatsText.IsHidden = true;
                if (centerHorizontally)
                {
                    mDescWindow.MoveTo(x - mDescWindow.Width / 2, y + mDescWindow.Padding.Top);
                }
                else
                {
                    mDescWindow.MoveTo(x - mDescWindow.Width - mDescWindow.Padding.Right, y + mDescWindow.Padding.Top);
                }
            }
        }
Example #18
0
        //Init
        public Chatbox(Canvas gameCanvas, GameInterface gameUi)
        {
            mGameUi = gameUi;

            //Chatbox Window
            mChatboxWindow   = new ImagePanel(gameCanvas, "ChatboxWindow");
            mChatboxMessages = new ListBox(mChatboxWindow, "MessageList");
            mChatboxMessages.EnableScroll(false, true);
            mChatboxWindow.ShouldCacheToTexture = true;

            mChatboxTitle          = new Label(mChatboxWindow, "ChatboxTitle");
            mChatboxTitle.Text     = Strings.Chatbox.title;
            mChatboxTitle.IsHidden = true;

            // Generate tab butons.
            for (var btn = 0; btn < (int)ChatboxTab.Count; btn++)
            {
                mTabButtons.Add((ChatboxTab)btn, new Button(mChatboxWindow, $"{(ChatboxTab)btn}TabButton"));
                // Do we have a localized string for this chat tab? If not assign none as the text.
                LocalizedString name;
                mTabButtons[(ChatboxTab)btn].Text     = Strings.Chatbox.ChatTabButtons.TryGetValue((ChatboxTab)btn, out name) ? name : Strings.General.none;
                mTabButtons[(ChatboxTab)btn].Clicked += TabButtonClicked;
                // We'll be using the user data to determine which tab we've clicked later.
                mTabButtons[(ChatboxTab)btn].UserData = (ChatboxTab)btn;
            }

            mChatbar          = new ImagePanel(mChatboxWindow, "Chatbar");
            mChatbar.IsHidden = true;

            mChatboxInput = new TextBox(mChatboxWindow, "ChatboxInputField");
            mChatboxInput.SubmitPressed += ChatBoxInput_SubmitPressed;
            mChatboxInput.Text           = GetDefaultInputText();
            mChatboxInput.Clicked       += ChatBoxInput_Clicked;
            mChatboxInput.IsTabable      = false;
            mChatboxInput.SetMaxLength(Options.MaxChatLength);
            Interface.FocusElements.Add(mChatboxInput);

            mChannelLabel          = new Label(mChatboxWindow, "ChannelLabel");
            mChannelLabel.Text     = Strings.Chatbox.channel;
            mChannelLabel.IsHidden = true;

            mChannelCombobox = new ComboBox(mChatboxWindow, "ChatChannelCombobox");
            for (var i = 0; i < 3; i++)
            {
                var menuItem = mChannelCombobox.AddItem(Strings.Chatbox.channels[i]);
                menuItem.UserData  = i;
                menuItem.Selected += MenuItem_Selected;
            }

            //Add admin channel only if power > 0.
            if (Globals.Me.Type > 0)
            {
                var menuItem = mChannelCombobox.AddItem(Strings.Chatbox.channeladmin);
                menuItem.UserData  = 3;
                menuItem.Selected += MenuItem_Selected;
            }

            mChatboxText      = new Label(mChatboxWindow);
            mChatboxText.Name = "ChatboxText";
            mChatboxText.Font = mChatboxWindow.Parent.Skin.DefaultFont;

            mChatboxSendButton          = new Button(mChatboxWindow, "ChatboxSendButton");
            mChatboxSendButton.Text     = Strings.Chatbox.send;
            mChatboxSendButton.Clicked += ChatBoxSendBtn_Clicked;

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

            mChatboxText.IsHidden = true;

            // Disable this to start, since this is the default tab we open the client on.
            mTabButtons[ChatboxTab.All].Disable();

            // Platform check, are we capable of copy/pasting on this machine?
            if (GameClipboard.Instance == null || !GameClipboard.Instance.CanCopyPaste())
            {
                ChatboxMsg.AddMessage(new ChatboxMsg(Strings.Chatbox.UnableToCopy, CustomColors.Alerts.Error, ChatMessageType.Error));
            }
        }
        //Init
        public CreateCharacterWindow(
            Canvas parent,
            MainMenu mainMenu,
            ImagePanel parentPanel,
            SelectCharacterWindow selectCharacterWindow
            )
        {
            //Assign References
            mMainMenu = mainMenu;
            mSelectCharacterWindow = selectCharacterWindow;

            //Main Menu Window
            mCharCreationPanel          = new ImagePanel(parent, "CharacterCreationWindow");
            mCharCreationPanel.IsHidden = true;

            //Menu Header
            mCharCreationHeader = new Label(mCharCreationPanel, "CharacterCreationHeader");
            mCharCreationHeader.SetText(Strings.CharacterCreation.title);

            //Character Name Background
            mCharacterNameBackground = new ImagePanel(mCharCreationPanel, "CharacterNamePanel");

            //Character name Label
            mCharnameLabel = new Label(mCharacterNameBackground, "CharacterNameLabel");
            mCharnameLabel.SetText(Strings.CharacterCreation.name);

            //Character name Textbox
            mCharnameTextbox = new TextBox(mCharacterNameBackground, "CharacterNameField");
            mCharnameTextbox.SubmitPressed += CharnameTextbox_SubmitPressed;

            //Class Background
            mClassBackground = new ImagePanel(mCharCreationPanel, "ClassPanel");

            //Class Label
            mClassLabel = new Label(mClassBackground, "ClassLabel");
            mClassLabel.SetText(Strings.CharacterCreation.Class);

            //Class Combobox
            mClassCombobox = new ComboBox(mClassBackground, "ClassCombobox");
            mClassCombobox.ItemSelected += classCombobox_ItemSelected;

            //Hint Label
            mHintLabel = new Label(mCharCreationPanel, "HintLabel");
            mHintLabel.SetText(Strings.CharacterCreation.hint);
            mHintLabel.IsHidden = true;

            //Hint2 Label
            mHint2Label = new Label(mCharCreationPanel, "Hint2Label");
            mHint2Label.SetText(Strings.CharacterCreation.hint2);
            mHint2Label.IsHidden = true;

            //Character Container
            mCharacterContainer = new ImagePanel(mCharCreationPanel, "CharacterContainer");

            //Character sprite
            mCharacterPortrait = new ImagePanel(mCharacterContainer, "CharacterPortait");
            mCharacterPortrait.SetSize(48, 48);

            //Next Sprite Button
            mNextSpriteButton          = new Button(mCharacterContainer, "NextSpriteButton");
            mNextSpriteButton.Clicked += _nextSpriteButton_Clicked;

            //Prev Sprite Button
            mPrevSpriteButton          = new Button(mCharacterContainer, "PreviousSpriteButton");
            mPrevSpriteButton.Clicked += _prevSpriteButton_Clicked;

            //Class Background
            mGenderBackground = new ImagePanel(mCharCreationPanel, "GenderPanel");

            //Gender Label
            mGenderLabel = new Label(mGenderBackground, "GenderLabel");
            mGenderLabel.SetText(Strings.CharacterCreation.gender);

            //Male Checkbox
            mMaleChk = new LabeledCheckBox(mGenderBackground, "MaleCheckbox")
            {
                Text = Strings.CharacterCreation.male
            };

            mMaleChk.IsChecked  = true;
            mMaleChk.Checked   += maleChk_Checked;
            mMaleChk.UnChecked += femaleChk_Checked; // If you notice this, feel free to hate us ;)

            //Female Checkbox
            mFemaleChk = new LabeledCheckBox(mGenderBackground, "FemaleCheckbox")
            {
                Text = Strings.CharacterCreation.female
            };

            mFemaleChk.Checked   += femaleChk_Checked;
            mFemaleChk.UnChecked += maleChk_Checked;

            //Register - Send Registration Button
            mCreateButton = new Button(mCharCreationPanel, "CreateButton");
            mCreateButton.SetText(Strings.CharacterCreation.create);
            mCreateButton.Clicked += CreateButton_Clicked;

            mBackButton          = new Button(mCharCreationPanel, "BackButton");
            mBackButton.IsHidden = true;
            mBackButton.SetText(Strings.CharacterCreation.back);
            mBackButton.Clicked += BackButton_Clicked;

            mCharCreationPanel.LoadJsonUi(GameContentManager.UI.Menu, Graphics.Renderer.GetResolutionString());
        }
Example #20
0
        //Init
        public EntityBox(Canvas gameCanvas, EntityTypes entityType, Entity myEntity, bool playerBox = false)
        {
            MyEntity     = myEntity;
            EntityType   = entityType;
            PlayerBox    = playerBox;
            EntityWindow =
                playerBox ? new ImagePanel(gameCanvas, "PlayerBox") : new ImagePanel(gameCanvas, "TargetBox");

            EntityWindow.ShouldCacheToTexture = true;

            EntityInfoPanel = new ImagePanel(EntityWindow, "EntityInfoPanel");

            EntityName = new Framework.Gwen.Control.Label(EntityInfoPanel, "EntityNameLabel")
            {
                Text = myEntity?.Name
            };
            EntityLevel        = new Framework.Gwen.Control.Label(EntityInfoPanel, "EntityLevelLabel");
            EntityNameAndLevel = new Framework.Gwen.Control.Label(EntityInfoPanel, "NameAndLevelLabel")
            {
                IsHidden = true
            };

            EntityMap = new Framework.Gwen.Control.Label(EntityInfoPanel, "EntityMapLabel");

            PaperdollPanels   = new ImagePanel[Options.EquipmentSlots.Count];
            PaperdollTextures = new string[Options.EquipmentSlots.Count];
            var i = 0;

            for (var z = 0; z < Options.PaperdollOrder[1].Count; z++)
            {
                if (Options.PaperdollOrder[1][z] == "Player")
                {
                    EntityFaceContainer = new ImagePanel(EntityInfoPanel, "EntityGraphicContainer");

                    EntityFace = new ImagePanel(EntityFaceContainer);
                    EntityFace.SetSize(64, 64);
                    EntityFace.AddAlignment(Alignments.Center);
                }
                else
                {
                    PaperdollPanels[i]   = new ImagePanel(EntityFaceContainer);
                    PaperdollTextures[i] = "";
                    PaperdollPanels[i].Hide();
                    i++;
                }
            }

            EventDesc = new RichLabel(EntityInfoPanel, "EventDescLabel");

            HpBackground = new ImagePanel(EntityInfoPanel, "HPBarBackground");
            HpBar        = new ImagePanel(EntityInfoPanel, "HPBar");
            ShieldBar    = new ImagePanel(EntityInfoPanel, "ShieldBar");
            HpTitle      = new Framework.Gwen.Control.Label(EntityInfoPanel, "HPTitle");
            HpTitle.SetText(Strings.EntityBox.vital0);
            HpLbl = new Framework.Gwen.Control.Label(EntityInfoPanel, "HPLabel");

            MpBackground = new ImagePanel(EntityInfoPanel, "MPBackground");
            MpBar        = new ImagePanel(EntityInfoPanel, "MPBar");
            MpTitle      = new Framework.Gwen.Control.Label(EntityInfoPanel, "MPTitle");
            MpTitle.SetText(Strings.EntityBox.vital1);
            MpLbl = new Framework.Gwen.Control.Label(EntityInfoPanel, "MPLabel");

            ExpBackground = new ImagePanel(EntityInfoPanel, "EXPBackground");
            ExpBar        = new ImagePanel(EntityInfoPanel, "EXPBar");
            ExpTitle      = new Framework.Gwen.Control.Label(EntityInfoPanel, "EXPTitle");
            ExpTitle.SetText(Strings.EntityBox.exp);
            ExpLbl = new Framework.Gwen.Control.Label(EntityInfoPanel, "EXPLabel");

            TradeLabel = new Button(EntityInfoPanel, "TradeButton");
            TradeLabel.SetText(Strings.EntityBox.trade);
            TradeLabel.SetToolTipText(Strings.EntityBox.tradetip.ToString(MyEntity.Name));
            TradeLabel.Clicked += tradeRequest_Clicked;

            PartyLabel = new Button(EntityInfoPanel, "PartyButton");
            PartyLabel.SetText(Strings.EntityBox.party);
            PartyLabel.SetToolTipText(Strings.EntityBox.partytip.ToString(MyEntity.Name));
            PartyLabel.Clicked += invite_Clicked;

            FriendLabel = new Button(EntityInfoPanel, "FriendButton");
            FriendLabel.SetText(Strings.EntityBox.friend);
            FriendLabel.SetToolTipText(Strings.EntityBox.friendtip.ToString(MyEntity.Name));
            FriendLabel.Clicked += friendRequest_Clicked;
            FriendLabel.IsHidden = true;

            EntityStatusPanel = new ImagePanel(EntityWindow, "StatusArea");

            SetEntity(myEntity);

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

            UpdateSpellStatus();

            i = 0;
            for (var z = 0; z < Options.PaperdollOrder[1].Count; z++)
            {
                if (Options.PaperdollOrder[1][z] == "Player")
                {
                    EntityFace.RenderColor = EntityFaceContainer.RenderColor;
                }
                else
                {
                    PaperdollPanels[i].RenderColor = EntityFaceContainer.RenderColor;
                    i++;
                }
            }

            EntityWindow.Hide();

            mLastUpdateTime = Globals.System.GetTimeMs();
        }
Example #21
0
        //Init
        public MainMenu(Canvas menuCanvas)
        {
            mMenuCanvas = menuCanvas;

            var logo = new ImagePanel(menuCanvas, "Logo");

            logo.LoadJsonUi(GameContentManager.UI.Menu, Graphics.Renderer.GetResolutionString());

            //Main Menu Window
            mMenuWindow = new ImagePanel(menuCanvas, "MenuWindow");

            mServerStatusLabel = new Label(mMenuWindow, "ServerStatusLabel")
            {
                AutoSizeToContents   = true,
                ShouldDrawBackground = true,
                Text = Strings.Server.StatusLabel.ToString(ActiveNetworkStatus.ToLocalizedString()),
            };

            mServerStatusLabel.SetTextColor(Color.White, Label.ControlState.Normal);
            mServerStatusLabel.AddAlignment(Alignments.Bottom);
            mServerStatusLabel.AddAlignment(Alignments.Left);
            mServerStatusLabel.ProcessAlignments();

            NetworkStatusChanged += HandleNetworkStatusChanged;

            //Menu Header
            mMenuHeader = new Label(mMenuWindow, "Title");
            mMenuHeader.SetText(Strings.MainMenu.title);

            //Login Button
            mLoginButton = new Button(mMenuWindow, "LoginButton");
            mLoginButton.SetText(Strings.MainMenu.login);
            mLoginButton.Clicked += LoginButton_Clicked;

            //Register Button
            mRegisterButton = new Button(mMenuWindow, "RegisterButton");
            mRegisterButton.SetText(Strings.MainMenu.register);
            mRegisterButton.Clicked += RegisterButton_Clicked;

            //Credits Button
            mCreditsButton = new Button(mMenuWindow, "CreditsButton");
            mCreditsButton.SetText(Strings.MainMenu.credits);
            mCreditsButton.Clicked += CreditsButton_Clicked;

            //Exit Button
            mExitButton = new Button(mMenuWindow, "ExitButton");
            mExitButton.SetText(Strings.MainMenu.exit);
            mExitButton.Clicked += ExitButton_Clicked;

            //Options Button
            mOptionsButton          = new Button(mMenuWindow, "OptionsButton");
            mOptionsButton.Clicked += OptionsButton_Clicked;
            mOptionsButton.SetText(Strings.MainMenu.options);
            if (!string.IsNullOrEmpty(Strings.MainMenu.optionstooltip))
            {
                mOptionsButton.SetToolTipText(Strings.MainMenu.optionstooltip);
            }

            mMenuWindow.LoadJsonUi(GameContentManager.UI.Menu, Graphics.Renderer.GetResolutionString());

            //Options Controls
            mOptionsWindow = new OptionsWindow(menuCanvas, this, mMenuWindow);

            //Login Controls
            mLoginWindow = new LoginWindow(menuCanvas, this, mMenuWindow);

            //Register Controls
            mRegisterWindow = new RegisterWindow(menuCanvas, this, mMenuWindow);

            //Forgot Password Controls
            mForgotPasswordWindow = new ForgotPasswordWindow(menuCanvas, this, mMenuWindow);

            //Reset Password Controls
            mResetPasswordWindow = new ResetPasswordWindow(menuCanvas, this, mMenuWindow);

            //Character Selection Controls
            mSelectCharacterWindow = new SelectCharacterWindow(mMenuCanvas, this, mMenuWindow);

            //Character Creation Controls
            mCreateCharacterWindow = new CreateCharacterWindow(mMenuCanvas, this, mMenuWindow, mSelectCharacterWindow);

            //Credits Controls
            mCreditsWindow = new CreditsWindow(mMenuCanvas, this);

            UpdateDisabled();
        }
        //Init
        public RegisterWindow(Canvas parent, MainMenu mainMenu, ImagePanel parentPanel)
        {
            //Assign References
            mMainMenu = mainMenu;

            //Main Menu Window
            mRegistrationPanel = new ImagePanel(parent, "RegistrationWindow");

            //Menu Header
            mRegistrationHeader = new Label(mRegistrationPanel, "RegistrationLabel");
            mRegistrationHeader.SetText(Strings.Registration.title);

            //Register Username Background
            mUsernameBackground = new ImagePanel(mRegistrationPanel, "UsernamePanel");

            //Register Username Label
            mUsernameLabel = new Label(mUsernameBackground, "UsernameLabel");
            mUsernameLabel.SetText(Strings.Registration.username);

            //Register Username Textbox
            mUsernameTextbox = new TextBox(mUsernameBackground, "UsernameField");
            mUsernameTextbox.SubmitPressed += UsernameTextbox_SubmitPressed;

            //Register Email Background
            mEmailBackground = new ImagePanel(mRegistrationPanel, "EmailPanel");

            //Register Email Label
            mEmailLabel = new Label(mEmailBackground, "EmailLabel");
            mEmailLabel.SetText(Strings.Registration.email);

            //Register Email Textbox
            mEmailTextbox = new TextBox(mEmailBackground, "EmailField");
            mEmailTextbox.SubmitPressed += EmailTextbox_SubmitPressed;

            //Register Password Background
            mPasswordBackground = new ImagePanel(mRegistrationPanel, "Password1Panel");

            //Register Password Label
            mPasswordLabel = new Label(mPasswordBackground, "Password1Label");
            mPasswordLabel.SetText(Strings.Registration.password);

            //Register Password Textbox
            mPasswordTextbox = new TextBoxPassword(mPasswordBackground, "Password1Field");
            mPasswordTextbox.SubmitPressed += PasswordTextbox_SubmitPressed;

            //Register Password Background
            mPasswordBackground2 = new ImagePanel(mRegistrationPanel, "Password2Panel");

            //Register Password Label2
            mPasswordLabel2 = new Label(mPasswordBackground2, "Password2Label");
            mPasswordLabel2.SetText(Strings.Registration.confirmpass);

            //Register Password Textbox2
            mPasswordTextbox2 = new TextBoxPassword(mPasswordBackground2, "Password2Field");
            mPasswordTextbox2.SubmitPressed += PasswordTextbox2_SubmitPressed;

            //Register - Send Registration Button
            mRegisterBtn = new Button(mRegistrationPanel, "RegisterButton");
            mRegisterBtn.SetText(Strings.Registration.register);
            mRegisterBtn.Clicked += RegisterBtn_Clicked;

            //Register - Back Button
            mBackBtn = new Button(mRegistrationPanel, "BackButton");
            mBackBtn.SetText(Strings.Registration.back);
            mBackBtn.Clicked += BackBtn_Clicked;

            mRegistrationPanel.LoadJsonUi(GameContentManager.UI.Menu, Graphics.Renderer.GetResolutionString());
        }