mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-12-25 01:39:23 +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
|
||||
|
||||
### MLEM.Ui
|
||||
Additions
|
||||
- Added Element.OnStyleInit event
|
||||
|
||||
Improvements
|
||||
- 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
|
||||
|
|
|
@ -342,6 +342,10 @@ namespace MLEM.Ui.Elements {
|
|||
/// </summary>
|
||||
public GenericCallback OnAreaUpdated;
|
||||
/// <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.
|
||||
/// Note that the event fired doesn't necessarily correlate to this specific element.
|
||||
/// </summary>
|
||||
|
@ -1058,6 +1062,8 @@ namespace MLEM.Ui.Elements {
|
|||
this.SelectionIndicator = this.SelectionIndicator.OrStyle(style.SelectionIndicator);
|
||||
this.ActionSound = this.ActionSound.OrStyle(style.ActionSound);
|
||||
this.SecondActionSound = this.SecondActionSound.OrStyle(style.ActionSound);
|
||||
|
||||
this.System.InvokeOnElementStyleInit(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -153,6 +153,10 @@ namespace MLEM.Ui {
|
|||
/// </summary>
|
||||
public event Element.GenericCallback OnElementAreaUpdated;
|
||||
/// <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
|
||||
/// </summary>
|
||||
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) {
|
||||
this.Controls = new UiControls(this, inputHandler);
|
||||
this.style = style;
|
||||
|
||||
this.OnElementDrawn += (e, time, batch, alpha) => e.OnDrawn?.Invoke(e, time, batch, alpha);
|
||||
this.OnElementUpdated += (e, time) => e.OnUpdated?.Invoke(e, time);
|
||||
this.OnElementPressed += e => e.OnPressed?.Invoke(e);
|
||||
|
@ -201,6 +206,7 @@ namespace MLEM.Ui {
|
|||
this.OnElementTouchEnter += e => e.OnTouchEnter?.Invoke(e);
|
||||
this.OnElementTouchExit += e => e.OnTouchExit?.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.OnTouchedElementChanged += e => this.ApplyToAll(t => t.OnTouchedElementChanged?.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)
|
||||
e.SecondActionSound.Value?.Play();
|
||||
};
|
||||
|
||||
MlemPlatform.Current?.AddTextInputListener(game.Window, (sender, key, character) => this.ApplyToAll(e => e.OnTextInput?.Invoke(e, key, character)));
|
||||
|
||||
if (automaticViewport) {
|
||||
|
@ -396,6 +403,10 @@ namespace MLEM.Ui {
|
|||
this.OnElementAreaUpdated?.Invoke(element);
|
||||
}
|
||||
|
||||
internal void InvokeOnElementStyleInit(Element element) {
|
||||
this.OnElementStyleInit?.Invoke(element);
|
||||
}
|
||||
|
||||
internal void InvokeOnElementPressed(Element element) {
|
||||
this.OnElementPressed?.Invoke(element);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue