mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-26 14:38:34 +01:00
hiding elements
This commit is contained in:
parent
b1d41d572c
commit
4943a7b6f0
2 changed files with 17 additions and 8 deletions
|
@ -50,6 +50,7 @@ namespace MLEM.Ui.Elements {
|
||||||
|
|
||||||
public UiSystem System { get; private set; }
|
public UiSystem System { get; private set; }
|
||||||
public Element Parent { get; private set; }
|
public Element Parent { get; private set; }
|
||||||
|
public bool IsHidden;
|
||||||
private readonly List<Element> children = new List<Element>();
|
private readonly List<Element> children = new List<Element>();
|
||||||
|
|
||||||
private Rectangle area;
|
private Rectangle area;
|
||||||
|
@ -221,14 +222,18 @@ namespace MLEM.Ui.Elements {
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Draw(GameTime time, SpriteBatch batch, Color color) {
|
public virtual void Draw(GameTime time, SpriteBatch batch, Color color) {
|
||||||
foreach (var child in this.children)
|
foreach (var child in this.children) {
|
||||||
|
if (!child.IsHidden)
|
||||||
child.Draw(time, batch, color);
|
child.Draw(time, batch, color);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void DrawUnbound(GameTime time, SpriteBatch batch, Color color, BlendState blendState = null, SamplerState samplerState = null) {
|
public virtual void DrawUnbound(GameTime time, SpriteBatch batch, Color color, BlendState blendState = null, SamplerState samplerState = null) {
|
||||||
foreach (var child in this.children)
|
foreach (var child in this.children) {
|
||||||
|
if (!child.IsHidden)
|
||||||
child.DrawUnbound(time, batch, color, blendState, samplerState);
|
child.DrawUnbound(time, batch, color, blendState, samplerState);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetUiSystem(UiSystem system) {
|
public void SetUiSystem(UiSystem system) {
|
||||||
this.System = system;
|
this.System = system;
|
||||||
|
|
|
@ -41,13 +41,17 @@ namespace MLEM.Ui {
|
||||||
var col = color ?? Color.White;
|
var col = color ?? Color.White;
|
||||||
|
|
||||||
batch.Begin(SpriteSortMode.Deferred, blendState, samplerState, transformMatrix: Matrix.CreateScale(this.GlobalScale));
|
batch.Begin(SpriteSortMode.Deferred, blendState, samplerState, transformMatrix: Matrix.CreateScale(this.GlobalScale));
|
||||||
foreach (var root in this.rootElements)
|
foreach (var root in this.rootElements) {
|
||||||
|
if (!root.Element.IsHidden)
|
||||||
root.Element.Draw(time, batch, col);
|
root.Element.Draw(time, batch, col);
|
||||||
|
}
|
||||||
batch.End();
|
batch.End();
|
||||||
|
|
||||||
foreach (var root in this.rootElements)
|
foreach (var root in this.rootElements) {
|
||||||
|
if (!root.Element.IsHidden)
|
||||||
root.Element.DrawUnbound(time, batch, col, blendState, samplerState);
|
root.Element.DrawUnbound(time, batch, col, blendState, samplerState);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Add(string name, Element root) {
|
public void Add(string name, Element root) {
|
||||||
if (this.IndexOf(name) >= 0)
|
if (this.IndexOf(name) >= 0)
|
||||||
|
|
Loading…
Reference in a new issue