Esempio n. 1
0
        public UIObject(string name, UIAlignment boundsAlign, UIAlignment alignment, flags flag)
        {
            //default values (this will be overwritten in derived classes)
            bounds       = new Rectangle(0, 0, 0, 0);
            childObjects = new List <UIObject>();
            this.Name    = name;
            this.flag    = flag;

            origin = alignment.GetAlignment(this, this);
        }
Esempio n. 2
0
        public UIObject(string name, Rectangle bounds, UIAlignment boundsAlign, UIAlignment alignment, flags flag)
        {
            childObjects = new List <UIObject>();
            this.Name    = name;
            this.bounds  = bounds;
            this.flag    = flag;

            Vector2 boundsAlignment = boundsAlign.GetAlignment(this, parent);

            this.bounds.X = (int)boundsAlignment.X;
            this.bounds.Y = (int)boundsAlignment.Y;

            origin = alignment.GetAlignment(this, this);
        }
Esempio n. 3
0
        public UIText(string name, UIAlignment boundsAlign, UIAlignment alignment, flags flag, string fontName, string text, int fontSize, string targetName = null) : base(name, boundsAlign, alignment, flag)
        {
            textRenderer      = TextRenderer.MakeTextRenderer(name, fontName, targetName);
            textRenderer.Size = fontSize;
            textRenderer.Text = text;
            //textRenderer.Font = Resources.LoadAsset(new Font().GetType(), fontName, SceneManager.activeScene) as Font;

            //get the width and height of the string being drawn
            bounds.Width  = (int)((float)textRenderer.Font.GetFont(fontSize).MeasureString(text).X *(float)fontSize / (float)textRenderer.Font.GetSize(fontSize));
            bounds.Height = (int)((float)textRenderer.Font.GetFont(fontSize).MeasureString(text).Y *(float)fontSize / (float)textRenderer.Font.GetSize(fontSize));

            Vector2 boundsAlignment = boundsAlign.GetAlignment(this, parent);

            bounds.X = (int)boundsAlignment.X;
            bounds.Y = (int)boundsAlignment.Y;

            textRenderer.Position = new Vector2(bounds.X, bounds.Y);
        }