mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-26 06:28:35 +01:00
Added Element.OnStyleInit event
This commit is contained in:
parent
dbf370c968
commit
faa400c4e6
3 changed files with 20 additions and 0 deletions
|
@ -22,6 +22,9 @@ Fixes
|
||||||
- Fixed StaticSpriteBatch handling rotated sprites incorrectly
|
- Fixed StaticSpriteBatch handling rotated sprites incorrectly
|
||||||
|
|
||||||
### MLEM.Ui
|
### MLEM.Ui
|
||||||
|
Additions
|
||||||
|
- Added Element.OnStyleInit event
|
||||||
|
|
||||||
Improvements
|
Improvements
|
||||||
- Allow for checkboxes and radio buttons to be disabled
|
- Allow for checkboxes and radio buttons to be disabled
|
||||||
- Only set a paragraph's area dirty when a text change would cause it to change size
|
- Only set a paragraph's area dirty when a text change would cause it to change size
|
||||||
|
|
|
@ -342,6 +342,10 @@ namespace MLEM.Ui.Elements {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GenericCallback OnAreaUpdated;
|
public GenericCallback OnAreaUpdated;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Event that is called when this element's <see cref="InitStyle"/> method is called while setting the <see cref="Style"/>.
|
||||||
|
/// </summary>
|
||||||
|
public GenericCallback OnStyleInit;
|
||||||
|
/// <summary>
|
||||||
/// Event that is called when the element that is currently being moused changes within the ui system.
|
/// Event that is called when the element that is currently being moused changes within the ui system.
|
||||||
/// Note that the event fired doesn't necessarily correlate to this specific element.
|
/// Note that the event fired doesn't necessarily correlate to this specific element.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1058,6 +1062,8 @@ namespace MLEM.Ui.Elements {
|
||||||
this.SelectionIndicator = this.SelectionIndicator.OrStyle(style.SelectionIndicator);
|
this.SelectionIndicator = this.SelectionIndicator.OrStyle(style.SelectionIndicator);
|
||||||
this.ActionSound = this.ActionSound.OrStyle(style.ActionSound);
|
this.ActionSound = this.ActionSound.OrStyle(style.ActionSound);
|
||||||
this.SecondActionSound = this.SecondActionSound.OrStyle(style.ActionSound);
|
this.SecondActionSound = this.SecondActionSound.OrStyle(style.ActionSound);
|
||||||
|
|
||||||
|
this.System.InvokeOnElementStyleInit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -153,6 +153,10 @@ namespace MLEM.Ui {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Element.GenericCallback OnElementAreaUpdated;
|
public event Element.GenericCallback OnElementAreaUpdated;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Event that is called when an <see cref="Element"/>'s <see cref="Element.InitStyle"/> method is called while setting its <see cref="Element.Style"/>.
|
||||||
|
/// </summary>
|
||||||
|
public event Element.GenericCallback OnElementStyleInit;
|
||||||
|
/// <summary>
|
||||||
/// Event that is invoked when the <see cref="Element"/> that the mouse is currently over changes
|
/// Event that is invoked when the <see cref="Element"/> that the mouse is currently over changes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Element.GenericCallback OnMousedElementChanged;
|
public event Element.GenericCallback OnMousedElementChanged;
|
||||||
|
@ -190,6 +194,7 @@ namespace MLEM.Ui {
|
||||||
public UiSystem(Game game, UiStyle style, InputHandler inputHandler = null, bool automaticViewport = true) : base(game) {
|
public UiSystem(Game game, UiStyle style, InputHandler inputHandler = null, bool automaticViewport = true) : base(game) {
|
||||||
this.Controls = new UiControls(this, inputHandler);
|
this.Controls = new UiControls(this, inputHandler);
|
||||||
this.style = style;
|
this.style = style;
|
||||||
|
|
||||||
this.OnElementDrawn += (e, time, batch, alpha) => e.OnDrawn?.Invoke(e, time, batch, alpha);
|
this.OnElementDrawn += (e, time, batch, alpha) => e.OnDrawn?.Invoke(e, time, batch, alpha);
|
||||||
this.OnElementUpdated += (e, time) => e.OnUpdated?.Invoke(e, time);
|
this.OnElementUpdated += (e, time) => e.OnUpdated?.Invoke(e, time);
|
||||||
this.OnElementPressed += e => e.OnPressed?.Invoke(e);
|
this.OnElementPressed += e => e.OnPressed?.Invoke(e);
|
||||||
|
@ -201,6 +206,7 @@ namespace MLEM.Ui {
|
||||||
this.OnElementTouchEnter += e => e.OnTouchEnter?.Invoke(e);
|
this.OnElementTouchEnter += e => e.OnTouchEnter?.Invoke(e);
|
||||||
this.OnElementTouchExit += e => e.OnTouchExit?.Invoke(e);
|
this.OnElementTouchExit += e => e.OnTouchExit?.Invoke(e);
|
||||||
this.OnElementAreaUpdated += e => e.OnAreaUpdated?.Invoke(e);
|
this.OnElementAreaUpdated += e => e.OnAreaUpdated?.Invoke(e);
|
||||||
|
this.OnElementStyleInit += e => e.OnStyleInit?.Invoke(e);
|
||||||
this.OnMousedElementChanged += e => this.ApplyToAll(t => t.OnMousedElementChanged?.Invoke(t, e));
|
this.OnMousedElementChanged += e => this.ApplyToAll(t => t.OnMousedElementChanged?.Invoke(t, e));
|
||||||
this.OnTouchedElementChanged += e => this.ApplyToAll(t => t.OnTouchedElementChanged?.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.OnSelectedElementChanged += e => this.ApplyToAll(t => t.OnSelectedElementChanged?.Invoke(t, e));
|
||||||
|
@ -216,6 +222,7 @@ namespace MLEM.Ui {
|
||||||
if (e.OnSecondaryPressed != null)
|
if (e.OnSecondaryPressed != null)
|
||||||
e.SecondActionSound.Value?.Play();
|
e.SecondActionSound.Value?.Play();
|
||||||
};
|
};
|
||||||
|
|
||||||
MlemPlatform.Current?.AddTextInputListener(game.Window, (sender, key, character) => this.ApplyToAll(e => e.OnTextInput?.Invoke(e, key, character)));
|
MlemPlatform.Current?.AddTextInputListener(game.Window, (sender, key, character) => this.ApplyToAll(e => e.OnTextInput?.Invoke(e, key, character)));
|
||||||
|
|
||||||
if (automaticViewport) {
|
if (automaticViewport) {
|
||||||
|
@ -396,6 +403,10 @@ namespace MLEM.Ui {
|
||||||
this.OnElementAreaUpdated?.Invoke(element);
|
this.OnElementAreaUpdated?.Invoke(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void InvokeOnElementStyleInit(Element element) {
|
||||||
|
this.OnElementStyleInit?.Invoke(element);
|
||||||
|
}
|
||||||
|
|
||||||
internal void InvokeOnElementPressed(Element element) {
|
internal void InvokeOnElementPressed(Element element) {
|
||||||
this.OnElementPressed?.Invoke(element);
|
this.OnElementPressed?.Invoke(element);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue