Exemple #1
0
        public Btn_Texture(M_Rectangle _rect, Action <Btn_Texture> _onClick, Texture2D _tex)
            : base(_rect, f => _onClick((Btn_Texture)f))
        {
            tex = _tex;

            texPos = _rect.GetCenter() - tex.GetSize() / 2f;
        }
Exemple #2
0
        public void DrawCustom(Vector2 pos)
        {
            box.SetToAnchor(Anchor.Bottom(pos - new Vector2(0, 16f)));
            box.PushIntoRectangle(viewInScreenSpace);

            boxInner.pos = box.pos + new Vector2(cornerRadius);

            boxInnerToDraw.pos    = box.pos + new Vector2(0, cornerRadius);
            boxInnerToDraw.Width  = box.Width;
            boxInnerToDraw.Height = box.Height - cornerRadius * 2f;
            boxInnerToDraw.Draw(backColor);

            boxInnerToDraw.pos    = box.pos + new Vector2(cornerRadius, 0);
            boxInnerToDraw.Width  = box.Width - cornerRadius * 2f;
            boxInnerToDraw.Height = box.Height;
            boxInnerToDraw.Draw(backColor);

            Vector2 speechStart = pos + Vector2.Normalize(boxInner.GetCenter() - pos) * 8f;

            Vector2         dist = speechStart - boxInner.GetCenter();
            CollisionResult cr   = boxInner.DistToVector(speechStart, dist);

            if (cr.distance.HasValue)
            {
                Drawer.DrawLineRelative(speechStart, -dist * cr.distance.Value, backColor, 2f);
            }

            for (int y = 0; y < 2; y++)
            {
                for (int x = 0; x < 2; x++)
                {
                    Vector2 p = box.pos + new Vector2(x * (box.Width - cornerRadius), y * (box.Height - cornerRadius));
                    corner.Draw(p, backColor, new Rectangle(x * cornerRadius, y * cornerRadius, cornerRadius, cornerRadius));
                }
            }


            Vector2 drawPos = box.pos + boxBorder;

            for (int i = 0; i < currentLine; i++)
            {
                font.Draw(lines[i], drawPos, textColor);
                drawPos += newLineSpace;
            }

            if (currentLine < lines.Count)
            {
                string  t1;
                Vector2 s;
                if (currentChar > 0)
                {
                    t1 = lines[currentLine].Remove((int)currentChar);
                    font.Draw(t1, drawPos, textColor);
                    s = font.MeasureString(t1);
                }
                else
                {
                    s   = font.MeasureString("A");
                    s.X = 0;
                    t1  = "";
                }
                string  t2 = lines[currentLine][(int)currentChar].ToString();
                Vector2 s2 = font.MeasureString(t2);
                font.Draw(t2, Anchor.Left(drawPos + s + new Vector2(0, -s2.Y) / 2f), textColor, Vector2.One * 1.5f);
            }
        }