public override void draw(SpriteBatch b)
        {
            base.draw(b);

            if (!ShouldDraw)
            {
                return;
            }

            Rectangle avatarSource = Desktop.Taskbar.AvatarButton.sourceRect;
            Vector2   position     = Utility.PointToVector2(ContentSafeArea.Location);
            string    text;
            int       textWidth;

            textWidth   = ContentSafeArea.Width;
            text        = Game1.parseText(text: _headerText, whichFont: HeadingTextFont, width: textWidth);
            position.Y += this.DrawHeading(b, position: position, text: text, drawBackground: true);
            Rectangle avatarDest = new Rectangle(
                (int)(position.X + HeadingTextFont.MeasureString(text).X - (avatarSource.Width * MenuScale) - Padding.X),
                (int)(position.Y),
                avatarSource.Width * MenuScale,
                avatarSource.Height * MenuScale);

            Desktop.Taskbar.DrawAvatarButton(b, avatarDest);

            text        = Game1.parseText(text: _subheaderText, whichFont: BodyTextFont, width: textWidth - (avatarSource.X * MenuScale) - Padding.X);
            position.Y += this.DrawText(b, position: position, text: text);

            text        = Game1.parseText(text: _bodyText, whichFont: BodyTextFont, width: textWidth);
            position.Y += this.DrawText(b, position: position, text: text);

            this.DrawFloatingActionButtons(b);
            this.DrawHoverText(b);
        }
        public override void RealignElements()
        {
            base.RealignElements();

            if (_parentMenu != null)
            {
                Vector2 bodyCharSize    = BodyTextFont.MeasureString("(");
                Vector2 headingCharSize = HeadingTextFont.MeasureString(")");
                width  = (int)(Math.Max(_parentMenu.width, (bodyCharSize.X * 28) + Padding.X));
                height = (int)((bodyCharSize.Y * 6) + (headingCharSize.Y * 1) + (Padding.Y * 3));
            }
        }
Пример #3
0
        public override void draw(SpriteBatch b)
        {
            base.draw(b);

            if (!ShouldDraw)
            {
                return;
            }

            if (IsOnHomePage)
            {
                // Character heads
                foreach (ClickableTextureComponent head in Heads)
                {
                    head.draw(b);
                }
            }
            else
            {
                Vector2 position       = Utility.PointToVector2(ContentSafeArea.Location);
                Vector2 positionChange = Vector2.Zero;

                string  text;
                Vector2 textSize;
                int     textWidth;

                Rectangle sourceRect = SelectedChara.getMugShotSourceRect();

                // Character name
                positionChange.X = (sourceRect.Width * MenuScale) + Padding.X;
                positionChange.Y = Padding.Y * 2;
                position.X      += positionChange.X;
                textWidth        = (int)(GoToButton.bounds.X - position.X);
                text             = Game1.parseText(text: SelectedChara.displayName, whichFont: HeadingTextFont, width: textWidth);
                textSize         = HeadingTextFont.MeasureString(text);
                this.DrawHeading(b, position: position, text: text, drawBackground: true);

                // Character sprite
                position.X -= positionChange.X;
                position.Y -= positionChange.Y;
                b.Draw(texture: SelectedChara.Sprite.Texture,
                       position: position,
                       sourceRectangle: sourceRect,
                       color: Color.White,
                       rotation: 0f, origin: Vector2.Zero, scale: MenuScale, effects: SpriteEffects.None, layerDepth: 1f);
                position.Y += positionChange.Y;

                // Character location
                positionChange.Y = textSize.Y + (Padding.Y * 2);
                position.Y      += positionChange.Y;
                text             = ModEntry.Instance.i18n.Get("ui.character.locationformat",
                                                              new {
                    LocationName = SelectedChara.currentLocation.Name,
                    TileLocation = SelectedChara.getTileLocationPoint().ToString()
                });
                position.Y += this.DrawText(b, position: position, text: text);
            }

            this.DrawFloatingActionButtons(b);
            this.DrawHoverText(b);
        }