/// <summary> /// Creates a UI component with the specified background color and transparency value. /// </summary> /// <param name="bgColor">Background color of this component</param> /// <param name="alpha">Transparency value of this component [0.0f - 1.0f]. 1.0f meaning /// totally opaque, and 0.0f meaning totally transparent</param> public Component(Color bgColor, float alpha) { this.alpha = (byte)(alpha * 255); this.backgroundColor = new Color(bgColor.R, bgColor.G, bgColor.B, this.alpha); name = "Component"; visible = true; enabled = true; parent = null; drawBorder = true; drawBackground = true; focused = false; borderColor = Color.Black; disabledColor = Color.Gray; textureColor = Color.White; label = ""; horizontalAlignment = GoblinEnums.HorizontalAlignment.Left; verticalAlignment = GoblinEnums.VerticalAlignment.Top; textColor = Color.Black; textAlpha = (byte)255; keyDown = false; mouseDown = false; within = false; entered = false; }
/// <summary> /// Creates a UI component with the specified background color and transparency value. /// </summary> /// <param name="bgColor">Background color of this component</param> /// <param name="alpha">Transparency value of this component [0.0f - 1.0f]. 1.0f meaning /// totally opaque, and 0.0f meaning totally transparent</param> public Component(Color bgColor, float alpha) { this.alpha = (byte)(alpha * 255); this.backgroundColor= new Color(bgColor.R, bgColor.G, bgColor.B, this.alpha); name = "Component"; visible = true; enabled = true; parent = null; drawBorder = true; drawBackground = true; focused = false; borderColor = Color.Black; disabledColor = Color.Gray; textureColor = Color.White; label = ""; horizontalAlignment = GoblinEnums.HorizontalAlignment.Left; verticalAlignment = GoblinEnums.VerticalAlignment.Top; textColor = Color.Black; textAlpha = (byte)255; keyDown = false; mouseDown = false; within = false; entered = false; }
/// <summary> /// Draws a 3D text with the given font, style, color, transformation, horizontal align, and vertical /// align. /// </summary> /// <remarks> /// This 3D text won't be actually drawn until Flush() method is called. If this method is called before /// base.Draw(...) in your main Game class's Draw(...) function, then it's automatically flushed when /// base.Draw(...) is called. If this method is called after base.Draw(...) function, then you need to /// call Flush() function after calling one or more of this function. Otherwise, the 3D texts drawing will /// be deferred until the next base.Draw(...) or Flush() call. /// </remarks> /// <param name="text">Text string to be displayed in 3D.</param> /// <param name="font">Font to use for the 3D text.</param> /// <param name="style">3D text style (Outline, Fill, or Extrude).</param> /// <param name="color">Color of the 3D text.</param> /// <param name="transform">Transformation of the 3D text.</param> /// <param name="hAlign">The horizontal (x-axis) shifting</param> /// <param name="vAlign"></param> public static void Write3DText(String text, VectorFont font, Text3DStyle style, Color color, Matrix transform, GoblinEnums.HorizontalAlignment hAlign, GoblinEnums.VerticalAlignment vAlign) { if (queued3DTexts == null) { queued3DTexts = new List <Text3DInfo>(); } Text3DInfo textInfo = new Text3DInfo(); Text text3d = null; if (font == null) { throw new ArgumentException("'font' must be non-null value"); } switch (style) { case Text3DStyle.Outline: text3d = font.Outline(text); break; case Text3DStyle.Fill: text3d = font.Fill(text); break; case Text3DStyle.Extrude: text3d = font.Extrude(text); break; } textInfo.text3d = text3d; textInfo.color = color; Matrix shiftTransform = Matrix.Identity; switch (hAlign) { case GoblinEnums.HorizontalAlignment.None: case GoblinEnums.HorizontalAlignment.Left: // The default is aligned to left, so nothing to do break; case GoblinEnums.HorizontalAlignment.Center: shiftTransform.Translation -= Vector3.UnitX * text3d.Width / 2; break; case GoblinEnums.HorizontalAlignment.Right: shiftTransform.Translation -= Vector3.UnitX * text3d.Width; break; } switch (vAlign) { case GoblinEnums.VerticalAlignment.None: case GoblinEnums.VerticalAlignment.Bottom: // The default is aligned to bottom, so nothing to do break; case GoblinEnums.VerticalAlignment.Center: shiftTransform.Translation -= Vector3.UnitY * text3d.Height / 2; break; case GoblinEnums.VerticalAlignment.Top: shiftTransform.Translation -= Vector3.UnitY * text3d.Height; break; } shiftTransform *= MatrixHelper.GetRotationMatrix(transform); transform.Translation += shiftTransform.Translation; textInfo.transform = transform; queued3DTexts.Add(textInfo); }