using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace MLEM.Ui.Elements { /// /// A that can have custom drawing parameters. /// Custom drawing parameters include a matrix, as well as a custom call. /// All of the custom draw group will be drawn with the custom parameters. /// [Obsolete("CustomDrawGroup mechanics have been moved down to Element, which means custom draw groups are no longer necessary.")] public class CustomDrawGroup : Group { public readonly TransformCallback TransformGetter; /// /// Creates a new custom draw group with the given settings /// /// The group's anchor /// The group's size /// The group's /// The group's /// Whether this group should automatically calculate its height based on its children public CustomDrawGroup(Anchor anchor, Vector2 size, TransformCallback transformGetter = null, BeginDelegate beginImpl = null, bool setHeightBasedOnChildren = true) : base(anchor, size, setHeightBasedOnChildren) { this.TransformGetter = transformGetter ?? ((element, time, matrix) => Matrix.Identity); this.BeginImpl = beginImpl; } /// [Obsolete("Use ScaleTransform instead")] public void ScaleOrigin(float scale, Vector2? origin = null) { this.ScaleTransform(scale, origin); } /// public override void Draw(GameTime time, SpriteBatch batch, float alpha, BlendState blendState, SamplerState samplerState, Matrix matrix) { if (this.Transform == Matrix.Identity) this.Transform = this.TransformGetter(this, time, matrix); base.Draw(time, batch, alpha, blendState, samplerState, matrix); } /// /// A delegate method used for /// /// The element whose transform to get /// The game's time /// The regular transform matrix public delegate Matrix TransformCallback(Element element, GameTime time, Matrix matrix); } }