mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-26 06:28:35 +01:00
organized UiSystem constructor
This commit is contained in:
parent
a02334a34c
commit
cca02b5396
1 changed files with 16 additions and 19 deletions
|
@ -183,6 +183,22 @@ 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.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) => {
|
||||||
|
if (this.Controls.IsAutoNavMode && element.SelectionIndicator.HasValue())
|
||||||
|
batch.Draw(element.SelectionIndicator, element.DisplayArea, Color.White * alpha, element.Scale / 2);
|
||||||
|
};
|
||||||
|
this.OnElementPressed += e => {
|
||||||
|
if (e.OnPressed != null)
|
||||||
|
e.ActionSound.Value?.Play();
|
||||||
|
};
|
||||||
|
this.OnElementSecondaryPressed += e => {
|
||||||
|
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) {
|
if (automaticViewport) {
|
||||||
this.Viewport = new Rectangle(Point.Zero, game.Window.ClientBounds.Size);
|
this.Viewport = new Rectangle(Point.Zero, game.Window.ClientBounds.Size);
|
||||||
|
@ -194,25 +210,6 @@ namespace MLEM.Ui {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MlemPlatform.Current != null)
|
|
||||||
MlemPlatform.Current.AddTextInputListener(game.Window, (sender, key, character) => this.ApplyToAll(e => e.OnTextInput?.Invoke(e, key, character)));
|
|
||||||
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) => {
|
|
||||||
if (this.Controls.IsAutoNavMode && element.SelectionIndicator.HasValue()) {
|
|
||||||
batch.Draw(element.SelectionIndicator, element.DisplayArea, Color.White * alpha, element.Scale / 2);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
this.OnElementPressed += e => {
|
|
||||||
if (e.OnPressed != null)
|
|
||||||
e.ActionSound.Value?.Play();
|
|
||||||
};
|
|
||||||
this.OnElementSecondaryPressed += e => {
|
|
||||||
if (e.OnSecondaryPressed != null)
|
|
||||||
e.SecondActionSound.Value?.Play();
|
|
||||||
};
|
|
||||||
|
|
||||||
this.TextFormatter = new TextFormatter();
|
this.TextFormatter = new TextFormatter();
|
||||||
this.TextFormatter.Codes.Add(new Regex("<l(?: ([^>]+))?>"), (f, m, r) => new LinkCode(m, r, 1 / 16F, 0.85F,
|
this.TextFormatter.Codes.Add(new Regex("<l(?: ([^>]+))?>"), (f, m, r) => new LinkCode(m, r, 1 / 16F, 0.85F,
|
||||||
t => this.Controls.MousedElement is Paragraph.Link l1 && l1.Token == t || this.Controls.TouchedElement is Paragraph.Link l2 && l2.Token == t));
|
t => this.Controls.MousedElement is Paragraph.Link l1 && l1.Token == t || this.Controls.TouchedElement is Paragraph.Link l2 && l2.Token == t));
|
||||||
|
|
Loading…
Reference in a new issue