/// <summary>
        ///     Initializes a new instance of the <see cref="MessageBox" /> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        /// <param name="text">Message to display.</param>
        /// <param name="caption">Window caption.</param>
        public MessageBox(Base parent, string text, string caption = "") : base(parent, caption, true)
        {
            DeleteOnClose = true;

            mLabel           = new Label(mInnerPanel);
            mLabel.Text      = text;
            mLabel.Margin    = Margin.Five;
            mLabel.Dock      = Pos.Top;
            mLabel.Alignment = Pos.Center;

            mButton          = new Button(mInnerPanel);
            mButton.Text     = "OK"; // todo: parametrize buttons
            mButton.Clicked += CloseButtonPressed;
            mButton.Clicked += DismissedHandler;
            mButton.Margin   = Margin.Five;
            mButton.SetSize(50, 20);

            Align.Center(this);
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageBox"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        /// <param name="text">Message to display.</param>
        /// <param name="caption">Window caption.</param>
        public MessageBox(ControlBase parent, string text, string caption = "")
            : base(parent, caption, true)
        {
            DeleteOnClose = true;

            label           = new Label(innerPanel);
            label.Text      = text;
            label.Margin    = Margin.Five;
            label.Dock      = Pos.Top;
            label.Alignment = Pos.Center;

            button          = new Button(innerPanel);
            button.Text     = "OK"; // todo: parametrize buttons
            button.Clicked += closeButtonPressed;
            button.Clicked += dismissedHandler;
            button.Margin   = Margin.Five;
            button.SetSize(50, 20);

            base.DisableResizing();

            Align.Center(this);
        }
예제 #3
0
        public MessageBox(Gwen.Controls.ControlBase ctrl, string text, string title, ButtonType buttons) : base(ctrl, title)
        {
            Text                         = text;
            _buttons                     = buttons;
            DeleteOnClose                = true;
            Container                    = new ControlBase(m_Panel);
            Container.Margin             = new Margin(0, Skin.DefaultFont.LineHeight, 0, 0);
            Container.Dock               = Dock.Bottom;
            Container.AutoSizeToContents = true;
            switch (buttons)
            {
            case ButtonType.Ok:
                AddButton("Okay", DialogResult.OK);
                break;

            case ButtonType.OkCancel:
                AddButton("Cancel", DialogResult.Cancel);
                AddButton("Okay", DialogResult.OK);
                break;

            case ButtonType.YesNo:
                AddButton("No", DialogResult.No);
                AddButton("Yes", DialogResult.Yes);
                break;

            case ButtonType.YesNoCancel:
                AddButton("Cancel", DialogResult.Cancel);
                AddButton("No", DialogResult.No);
                AddButton("Yes", DialogResult.Yes);
                break;
            }
            Setup();
            Align.Center(this);
            DisableResizing();
            Invalidate();
        }
예제 #4
0
        //Methods
        public void Update()
        {
            if (mCharacterWindow.IsHidden)
            {
                return;
            }

            mCharacterName.Text          = Globals.Me.Name;
            mCharacterLevelAndClass.Text = Strings.Character.levelandclass.ToString(
                Globals.Me.Level, ClassBase.GetName(Globals.Me.Class)
                );

            //Load Portrait
            //UNCOMMENT THIS LINE IF YOU'D RATHER HAVE A FACE HERE GameTexture faceTex = Globals.ContentManager.GetTexture(GameContentManager.TextureType.Face, Globals.Me.Face);
            var entityTex = Globals.ContentManager.GetTexture(
                GameContentManager.TextureType.Entity, Globals.Me.MySprite
                );

            /* UNCOMMENT THIS BLOCK IF YOU"D RATHER HAVE A FACE HERE if (Globals.Me.Face != "" && Globals.Me.Face != _currentSprite && faceTex != null)
             * {
             *   _characterPortrait.Texture = faceTex;
             *   _characterPortrait.SetTextureRect(0, 0, faceTex.GetWidth(), faceTex.GetHeight());
             *   _characterPortrait.SizeToContents();
             *   Align.Center(_characterPortrait);
             *   _characterPortrait.IsHidden = false;
             *   for (int i = 0; i < Options.EquipmentSlots.Count; i++)
             *   {
             *       _paperdollPanels[i].Hide();
             *   }
             * }
             * else */
            if (Globals.Me.MySprite != "" && Globals.Me.MySprite != mCurrentSprite && entityTex != null)
            {
                for (var z = 0; z < Options.PaperdollOrder[1].Count; z++)
                {
                    var paperdoll = "";
                    var type      = GameContentManager.TextureType.Paperdoll;
                    if (Options.EquipmentSlots.IndexOf(Options.PaperdollOrder[1][z]) > -1)
                    {
                        var equipment = Globals.Me.MyEquipment;
                        if (equipment[Options.EquipmentSlots.IndexOf(Options.PaperdollOrder[1][z])] > -1 &&
                            equipment[Options.EquipmentSlots.IndexOf(Options.PaperdollOrder[1][z])] <
                            Options.MaxInvItems)
                        {
                            var itemNum = Globals.Me
                                          .Inventory[equipment[Options.EquipmentSlots.IndexOf(Options.PaperdollOrder[1][z])]]
                                          .ItemId;

                            if (ItemBase.Get(itemNum) != null)
                            {
                                var itemdata = ItemBase.Get(itemNum);
                                if (Globals.Me.Gender == 0)
                                {
                                    paperdoll = itemdata.MalePaperdoll;
                                }
                                else
                                {
                                    paperdoll = itemdata.FemalePaperdoll;
                                }
                            }
                        }
                    }
                    else if (Options.PaperdollOrder[1][z] == "Player")
                    {
                        PaperdollPanels[z].Show();
                        PaperdollPanels[z].Texture = entityTex;
                        PaperdollPanels[z].SetTextureRect(0, 0, entityTex.GetWidth() / 4, entityTex.GetHeight() / 4);
                        PaperdollPanels[z].SizeToContents();
                        Align.Center(PaperdollPanels[z]);
                    }

                    if (paperdoll == "" && Options.PaperdollOrder[1][z] == Options.Equipment.HairSlot)
                    {
                        paperdoll = Globals.Me.CustomSpriteLayers[(int)Enums.CustomSpriteLayers.Hair];
                        type      = GameContentManager.TextureType.Hair;
                    }

                    if (string.IsNullOrWhiteSpace(paperdoll) && !string.IsNullOrWhiteSpace(PaperdollTextures[z]) && Options.PaperdollOrder[1][z] != "Player")
                    {
                        PaperdollPanels[z].Texture = null;
                        PaperdollPanels[z].Hide();
                        PaperdollTextures[z] = "";
                    }
                    else if (paperdoll != "" && paperdoll != PaperdollTextures[z])
                    {
                        var paperdollTex = Globals.ContentManager.GetTexture(
                            type, paperdoll
                            );

                        PaperdollPanels[z].Texture = paperdollTex;
                        if (paperdollTex != null)
                        {
                            PaperdollPanels[z]
                            .SetTextureRect(
                                0, 0, PaperdollPanels[z].Texture.GetWidth() / 4,
                                PaperdollPanels[z].Texture.GetHeight() / 4
                                );

                            PaperdollPanels[z]
                            .SetSize(
                                PaperdollPanels[z].Texture.GetWidth() / 4,
                                PaperdollPanels[z].Texture.GetHeight() / 4
                                );

                            PaperdollPanels[z]
                            .SetPosition(
                                mCharacterContainer.Width / 2 - PaperdollPanels[z].Width / 2,
                                mCharacterContainer.Height / 2 - PaperdollPanels[z].Height / 2
                                );
                        }

                        PaperdollPanels[z].Show();
                        PaperdollTextures[z] = paperdoll;
                    }
                }
            }
            else if (Globals.Me.MySprite != mCurrentSprite && Globals.Me.Face != mCurrentSprite)
            {
                mCharacterPortrait.IsHidden = true;
                for (var i = 0; i < Options.EquipmentSlots.Count; i++)
                {
                    PaperdollPanels[i].Hide();
                }
            }

            mAttackLabel.SetText(
                Strings.Character.stat0.ToString(Strings.Combat.stat0, Globals.Me.Stat[(int)Stats.Attack])
                );

            mDefenseLabel.SetText(
                Strings.Character.stat2.ToString(Strings.Combat.stat2, Globals.Me.Stat[(int)Stats.Defense])
                );

            mSpeedLabel.SetText(
                Strings.Character.stat4.ToString(Strings.Combat.stat4, Globals.Me.Stat[(int)Stats.Speed])
                );

            mAbilityPwrLabel.SetText(
                Strings.Character.stat1.ToString(Strings.Combat.stat1, Globals.Me.Stat[(int)Stats.AbilityPower])
                );

            mMagicRstLabel.SetText(
                Strings.Character.stat3.ToString(Strings.Combat.stat3, Globals.Me.Stat[(int)Stats.MagicResist])
                );

            mPointsLabel.SetText(Strings.Character.points.ToString(Globals.Me.StatPoints));
            mAddAbilityPwrBtn.IsHidden = Globals.Me.StatPoints == 0 ||
                                         Globals.Me.Stat[(int)Stats.AbilityPower] == Options.MaxStatValue;

            mAddAttackBtn.IsHidden =
                Globals.Me.StatPoints == 0 || Globals.Me.Stat[(int)Stats.Attack] == Options.MaxStatValue;

            mAddDefenseBtn.IsHidden = Globals.Me.StatPoints == 0 ||
                                      Globals.Me.Stat[(int)Stats.Defense] == Options.MaxStatValue;

            mAddMagicResistBtn.IsHidden = Globals.Me.StatPoints == 0 ||
                                          Globals.Me.Stat[(int)Stats.MagicResist] == Options.MaxStatValue;

            mAddSpeedBtn.IsHidden =
                Globals.Me.StatPoints == 0 || Globals.Me.Stat[(int)Stats.Speed] == Options.MaxStatValue;

            for (var i = 0; i < Options.EquipmentSlots.Count; i++)
            {
                if (Globals.Me.MyEquipment[i] > -1 && Globals.Me.MyEquipment[i] < Options.MaxInvItems)
                {
                    if (Globals.Me.Inventory[Globals.Me.MyEquipment[i]].ItemId != Guid.Empty)
                    {
                        Items[i]
                        .Update(
                            Globals.Me.Inventory[Globals.Me.MyEquipment[i]].ItemId,
                            Globals.Me.Inventory[Globals.Me.MyEquipment[i]].StatBuffs
                            );
                    }
                    else
                    {
                        Items[i].Update(Guid.Empty, mEmptyStatBoost);
                    }
                }
                else
                {
                    Items[i].Update(Guid.Empty, mEmptyStatBoost);
                }
            }
        }
예제 #5
0
        private void UpdateImage()
        {
            var faceTex   = Globals.ContentManager.GetTexture(GameContentManager.TextureType.Face, MyEntity.Face);
            var entityTex = Globals.ContentManager.GetTexture(GameContentManager.TextureType.Entity, MyEntity.MySprite);

            if (faceTex != null && faceTex != EntityFace.Texture)
            {
                EntityFace.Texture = faceTex;
                EntityFace.SetTextureRect(0, 0, faceTex.GetWidth(), faceTex.GetHeight());
                Align.Center(EntityFace);
                mCurrentSprite      = MyEntity.Face;
                EntityFace.IsHidden = false;
                var i = 0;
                for (var z = 0; z < Options.PaperdollOrder[1].Count; z++)
                {
                    if (Options.PaperdollOrder[1][z] != "Player")
                    {
                        if (PaperdollPanels == null)
                        {
                            Log.Warn($@"{nameof(PaperdollPanels)} is null.");
                        }
                        else if (PaperdollPanels[i] == null)
                        {
                            Log.Warn($@"{nameof(PaperdollPanels)}[{i}] is null.");
                        }

                        PaperdollPanels?[i]?.Hide();
                        i++;
                    }
                }
            }
            else if (entityTex != null && faceTex == null || faceTex != null && faceTex != EntityFace.Texture)
            {
                if (entityTex != EntityFace.Texture)
                {
                    EntityFace.Texture = entityTex;
                    EntityFace.SetTextureRect(0, 0, entityTex.GetWidth() / 4, entityTex.GetHeight() / 4);
                    EntityFace.SizeToContents();
                    Align.Center(EntityFace);
                    mCurrentSprite      = MyEntity.MySprite;
                    EntityFace.IsHidden = false;
                }

                var equipment = MyEntity.Equipment;
                if (MyEntity == Globals.Me)
                {
                    for (var i = 0; i < MyEntity.MyEquipment.Length; i++)
                    {
                        var eqp = MyEntity.MyEquipment[i];
                        if (eqp > -1 && eqp < Options.MaxInvItems)
                        {
                            equipment[i] = MyEntity.Inventory[eqp].ItemId;
                        }
                        else
                        {
                            equipment[i] = Guid.Empty;
                        }
                    }
                }

                var n = 0;
                for (var z = 0; z < Options.PaperdollOrder[1].Count; z++)
                {
                    var paperdoll = "";
                    var type      = GameContentManager.TextureType.Paperdoll;
                    if (Options.EquipmentSlots.IndexOf(Options.PaperdollOrder[1][z]) > -1 &&
                        equipment.Length == Options.EquipmentSlots.Count)
                    {
                        if (equipment[Options.EquipmentSlots.IndexOf(Options.PaperdollOrder[1][z])] != Guid.Empty)
                        {
                            var itemId = equipment[Options.EquipmentSlots.IndexOf(Options.PaperdollOrder[1][z])];
                            if (ItemBase.Get(itemId) != null)
                            {
                                var itemdata = ItemBase.Get(itemId);
                                if (MyEntity.Gender == 0)
                                {
                                    paperdoll = itemdata.MalePaperdoll;
                                }
                                else
                                {
                                    paperdoll = itemdata.FemalePaperdoll;
                                }
                            }
                        }
                    }

                    //Check for Player layer
                    if (Options.PaperdollOrder[1][z] == "Player")
                    {
                        continue;
                    }

                    if (MyEntity is Player && paperdoll == "" && Options.PaperdollOrder[1][z] == Options.Equipment.HairSlot)
                    {
                        paperdoll = ((Player)MyEntity).CustomSpriteLayers[(int)Enums.CustomSpriteLayers.Hair];
                        type      = GameContentManager.TextureType.Hair;
                    }

                    if (paperdoll == "" && PaperdollTextures[n] != "")
                    {
                        PaperdollPanels[n].Texture = null;
                        PaperdollPanels[n].Hide();
                        PaperdollTextures[n] = "";
                    }
                    else if (paperdoll != "" && paperdoll != PaperdollTextures[n])
                    {
                        var paperdollTex = Globals.ContentManager.GetTexture(
                            type, paperdoll
                            );

                        PaperdollPanels[n].Texture = paperdollTex;
                        if (paperdollTex != null)
                        {
                            PaperdollPanels[n]
                            .SetTextureRect(
                                0, 0, PaperdollPanels[n].Texture.GetWidth() / 4,
                                PaperdollPanels[n].Texture.GetHeight() / 4
                                );

                            PaperdollPanels[n]
                            .SetSize(
                                PaperdollPanels[n].Texture.GetWidth() / 4,
                                PaperdollPanels[n].Texture.GetHeight() / 4
                                );

                            PaperdollPanels[n]
                            .SetPosition(
                                EntityFaceContainer.Width / 2 - PaperdollPanels[n].Width / 2,
                                EntityFaceContainer.Height / 2 - PaperdollPanels[n].Height / 2
                                );
                        }

                        PaperdollPanels[n].Show();
                        PaperdollTextures[n] = paperdoll;
                    }

                    //Check for Player layer
                    if (Options.PaperdollOrder[1][z] != "Player")
                    {
                        n++;
                    }
                }
            }
            else if (MyEntity.MySprite != mCurrentSprite && MyEntity.Face != mCurrentSprite)
            {
                EntityFace.IsHidden = true;
                for (var i = 0; i < Options.EquipmentSlots.Count; i++)
                {
                    PaperdollPanels[i].Hide();
                }
            }
        }
        public void Setup(string picture, int size, bool clickable)
        {
            Picture   = picture;
            Size      = size;
            Clickable = clickable;

            mPicture.Texture = Globals.ContentManager.GetTexture(GameContentManager.TextureType.Image, picture);
            if (mPicture.Texture != null)
            {
                mPicture.SetSize(mPicture.Texture.GetWidth(), mPicture.Texture.GetHeight());
                Align.Center(mPicture);

                if (size != (int)PictureSize.Original)  // Don't scale if you want to keep the original size.
                {
                    if (size == (int)PictureSize.StretchToFit)
                    {
                        mPicture.SetSize(mGameCanvas.Width, mGameCanvas.Height);
                        Align.Center(mPicture);
                    }
                    else
                    {
                        var n = 1;

                        //If you want half fullscreen size set n to 2.
                        if (size == (int)PictureSize.HalfScreen)
                        {
                            n = 2;
                        }

                        var ar          = (float)mPicture.Width / (float)mPicture.Height;
                        var heightLimit = true;
                        if (mGameCanvas.Width < mGameCanvas.Height * ar)
                        {
                            heightLimit = false;
                        }

                        if (heightLimit)
                        {
                            var height = mGameCanvas.Height;
                            var width  = mGameCanvas.Height * ar;
                            mPicture.SetSize((int)(width / n), (int)(height / n));
                            Align.Center(mPicture);
                        }
                        else
                        {
                            var width  = mGameCanvas.Width;
                            var height = width / ar;
                            mPicture.SetSize((int)(width / n), (int)(height / n));
                            Align.Center(mPicture);
                        }
                    }
                }

                mPicture.BringToFront();
                mPicture.Show();
            }
            else
            {
                Close();
            }
        }
예제 #7
0
 public void Center()
 {
     Align.Center(this);
 }