Пример #1
0
        public static void doRightAlignedBackingLabelScaled(Rectangle dest, string msg, SpriteFont font, Color back, Color front)
        {
            GuiData.spriteBatch.Draw(Utils.white, dest, back);
            Vector2 vector2_1 = font.MeasureString(msg);

            Vector2[] stringScaleForSize = TextItem.GetStringScaleForSize(font, msg, dest);
            Vector2   scale     = stringScaleForSize[0];
            Vector2   vector2_2 = stringScaleForSize[1];
            Vector2   vector2_3 = vector2_1 * scale;
            Vector2   position  = new Vector2((float)(dest.X + dest.Width) - vector2_3.X, (float)(dest.Y + dest.Height / 2) - vector2_3.Y / 2f);

            GuiData.spriteBatch.DrawString(font, msg, position, front, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.6f);
        }
Пример #2
0
        public static void doCenteredFontLabel(Rectangle dest, string text, SpriteFont font, Color color, bool LockToLeft = false)
        {
            Vector2 vector2_1 = font.MeasureString(text);
            Vector2 vector2_2 = new Vector2((float)dest.Width / vector2_1.X, (float)dest.Height / vector2_1.Y);

            if ((double)Math.Min(vector2_2.X, vector2_2.Y) < 1.0)
            {
                TextItem.doFontLabelToSize(dest, text, font, color, true, false);
            }
            else
            {
                Vector2 position = Utils.ClipVec2ForTextRendering(new Vector2((float)((double)dest.X + (double)dest.Width / 2.0 - (double)vector2_1.X / 2.0), (float)((double)dest.Y + (double)dest.Height / 2.0 - (double)vector2_1.Y / 2.0)));
                if (LockToLeft)
                {
                    position.X = (float)dest.X;
                }
                GuiData.spriteBatch.DrawString(font, text, position, color);
            }
        }
Пример #3
0
        public static void doRightAlignedBackingLabelFill(Rectangle dest, string msg, SpriteFont font, Color back, Color front)
        {
            GuiData.spriteBatch.Draw(Utils.white, dest, back);
            Vector2   vector2_1 = font.MeasureString(msg);
            Rectangle dest1     = dest;

            dest1.Width -= 7;
            dest1.X     += 4;
            Vector2[] stringScaleForSize = TextItem.GetStringScaleForSize(font, msg, dest1);
            Vector2   scale     = stringScaleForSize[0];
            Vector2   vector2_2 = stringScaleForSize[1];

            vector2_2.Y *= 2f;
            vector2_2.Y -= 3f;
            Vector2 vector2_3 = new Vector2((float)dest1.X, (float)dest.Y);

            GuiData.spriteBatch.DrawString(font, msg, vector2_3 + vector2_2, front, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.6f);
            Rectangle destinationRectangle = new Rectangle(dest.X, (int)((double)dest.Y + (double)vector2_2.Y - 4.0 + (double)vector2_1.Y * (double)scale.Y), dest.Width, 1);

            GuiData.spriteBatch.Draw(Utils.white, destinationRectangle, front);
        }