mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 04:53:29 +01:00
Include the SpriteBatchContext in OnDrawn, OnElementDrawn and OnSelectedElementDrawn
This commit is contained in:
parent
ee2b0266aa
commit
d879894e30
3 changed files with 10 additions and 9 deletions
|
@ -29,6 +29,7 @@ Additions
|
|||
- Added the ability to display tooltips using the auto-nav style even when using the mouse
|
||||
|
||||
Improvements
|
||||
- **Include the SpriteBatchContext in OnDrawn, OnElementDrawn and OnSelectedElementDrawn**
|
||||
- Allow scrolling panels to set height based on children by setting TreatSizeAsMaximum
|
||||
|
||||
Fixes
|
||||
|
|
|
@ -1148,9 +1148,9 @@ namespace MLEM.Ui.Elements {
|
|||
/// <param name="alpha">The alpha to draw this element and its children with</param>
|
||||
/// <param name="context">The sprite batch context to use for drawing</param>
|
||||
public virtual void Draw(GameTime time, SpriteBatch batch, float alpha, SpriteBatchContext context) {
|
||||
this.System.InvokeOnElementDrawn(this, time, batch, alpha);
|
||||
this.System.InvokeOnElementDrawn(this, time, batch, alpha, context);
|
||||
if (this.IsSelected)
|
||||
this.System.InvokeOnSelectedElementDrawn(this, time, batch, alpha);
|
||||
this.System.InvokeOnSelectedElementDrawn(this, time, batch, alpha, context);
|
||||
|
||||
foreach (var child in this.GetRelevantChildren()) {
|
||||
if (!child.IsHidden) {
|
||||
|
@ -1387,7 +1387,7 @@ namespace MLEM.Ui.Elements {
|
|||
/// <param name="time">The game's time</param>
|
||||
/// <param name="batch">The sprite batch used for drawing</param>
|
||||
/// <param name="alpha">The alpha this element is drawn with</param>
|
||||
public delegate void DrawCallback(Element element, GameTime time, SpriteBatch batch, float alpha);
|
||||
public delegate void DrawCallback(Element element, GameTime time, SpriteBatch batch, float alpha, SpriteBatchContext context);
|
||||
|
||||
/// <summary>
|
||||
/// A generic delegate used inside of <see cref="Element.Update"/>
|
||||
|
|
|
@ -215,7 +215,7 @@ namespace MLEM.Ui {
|
|||
this.Controls = new UiControls(this, inputHandler);
|
||||
this.style = style;
|
||||
|
||||
this.OnElementDrawn += (e, time, batch, alpha) => e.OnDrawn?.Invoke(e, time, batch, alpha);
|
||||
this.OnElementDrawn += (e, time, batch, alpha, context) => e.OnDrawn?.Invoke(e, time, batch, alpha, context);
|
||||
this.OnElementUpdated += (e, time) => e.OnUpdated?.Invoke(e, time);
|
||||
this.OnElementPressed += e => e.OnPressed?.Invoke(e);
|
||||
this.OnElementSecondaryPressed += e => e.OnSecondaryPressed?.Invoke(e);
|
||||
|
@ -230,7 +230,7 @@ namespace MLEM.Ui {
|
|||
this.OnMousedElementChanged += e => this.ApplyToAll(t => t.OnMousedElementChanged?.Invoke(t, e));
|
||||
this.OnTouchedElementChanged += e => this.ApplyToAll(t => t.OnTouchedElementChanged?.Invoke(t, e));
|
||||
this.OnSelectedElementChanged += e => this.ApplyToAll(t => t.OnSelectedElementChanged?.Invoke(t, e));
|
||||
this.OnSelectedElementDrawn += (element, time, batch, alpha) => {
|
||||
this.OnSelectedElementDrawn += (element, time, batch, alpha, context) => {
|
||||
if (this.Controls.IsAutoNavMode && element.SelectionIndicator.HasValue())
|
||||
batch.Draw(element.SelectionIndicator, element.DisplayArea, Color.White * alpha, element.Scale / 2);
|
||||
};
|
||||
|
@ -427,12 +427,12 @@ namespace MLEM.Ui {
|
|||
}
|
||||
}
|
||||
|
||||
internal void InvokeOnElementDrawn(Element element, GameTime time, SpriteBatch batch, float alpha) {
|
||||
this.OnElementDrawn?.Invoke(element, time, batch, alpha);
|
||||
internal void InvokeOnElementDrawn(Element element, GameTime time, SpriteBatch batch, float alpha, SpriteBatchContext context) {
|
||||
this.OnElementDrawn?.Invoke(element, time, batch, alpha, context);
|
||||
}
|
||||
|
||||
internal void InvokeOnSelectedElementDrawn(Element element, GameTime time, SpriteBatch batch, float alpha) {
|
||||
this.OnSelectedElementDrawn?.Invoke(element, time, batch, alpha);
|
||||
internal void InvokeOnSelectedElementDrawn(Element element, GameTime time, SpriteBatch batch, float alpha, SpriteBatchContext context) {
|
||||
this.OnSelectedElementDrawn?.Invoke(element, time, batch, alpha, context);
|
||||
}
|
||||
|
||||
internal void InvokeOnElementUpdated(Element element, GameTime time) {
|
||||
|
|
Loading…
Reference in a new issue