mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 04:53:29 +01:00
Fixed UiMetrics.ForceAreaUpdateTime being inaccurate for nested elements
This commit is contained in:
parent
3ad024b95a
commit
6a3c797eba
3 changed files with 16 additions and 14 deletions
|
@ -69,6 +69,7 @@ Fixes
|
|||
- Fixed children of Panel scroll bars also being scrolled
|
||||
- Fixed RootElement.CanSelectContent and Element.IsSelected returning incorrect results when CanBeSelected changes
|
||||
- Fixed dropdowns with some non-selectable children failing to navigate when using gamepad controls
|
||||
- Fixed UiMetrics.ForceAreaUpdateTime being inaccurate for nested elements
|
||||
|
||||
Removals
|
||||
- Marked StyleProp equality members as obsolete
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
@ -409,6 +410,7 @@ namespace MLEM.Ui.Elements {
|
|||
protected RectangleF ParentArea => this.Parent?.ChildPaddedArea ?? (RectangleF) this.system.Viewport;
|
||||
|
||||
private readonly List<Element> children = new List<Element>();
|
||||
private readonly Stopwatch stopwatch = new Stopwatch();
|
||||
private bool sortedChildrenDirty;
|
||||
private IList<Element> sortedChildren;
|
||||
private UiSystem system;
|
||||
|
@ -559,7 +561,7 @@ namespace MLEM.Ui.Elements {
|
|||
// which would cause our ForceUpdateArea code to be run twice, so we only update our parent instead
|
||||
if (this.Parent != null && this.Parent.UpdateAreaIfDirty())
|
||||
return;
|
||||
this.System.Stopwatch.Restart();
|
||||
this.stopwatch.Restart();
|
||||
|
||||
var parentArea = this.ParentArea;
|
||||
var parentCenterX = parentArea.X + parentArea.Width / 2;
|
||||
|
@ -569,8 +571,8 @@ namespace MLEM.Ui.Elements {
|
|||
var recursion = 0;
|
||||
UpdateDisplayArea(actualSize);
|
||||
|
||||
this.System.Stopwatch.Stop();
|
||||
this.System.Metrics.ForceAreaUpdateTime += this.System.Stopwatch.Elapsed;
|
||||
this.stopwatch.Stop();
|
||||
this.System.Metrics.ForceAreaUpdateTime += this.stopwatch.Elapsed;
|
||||
this.System.Metrics.ForceAreaUpdates++;
|
||||
|
||||
void UpdateDisplayArea(Vector2 newSize) {
|
||||
|
|
|
@ -182,9 +182,8 @@ namespace MLEM.Ui {
|
|||
/// </summary>
|
||||
public event RootCallback OnRootRemoved;
|
||||
|
||||
internal readonly Stopwatch Stopwatch = new Stopwatch();
|
||||
|
||||
private readonly List<RootElement> rootElements = new List<RootElement>();
|
||||
private readonly Stopwatch stopwatch = new Stopwatch();
|
||||
private float globalScale = 1;
|
||||
private bool drewEarly;
|
||||
private UiStyle style;
|
||||
|
@ -253,14 +252,14 @@ namespace MLEM.Ui {
|
|||
/// <param name="time">The game's time</param>
|
||||
public override void Update(GameTime time) {
|
||||
this.Metrics.ResetUpdates();
|
||||
this.Stopwatch.Restart();
|
||||
this.stopwatch.Restart();
|
||||
|
||||
this.Controls.Update();
|
||||
for (var i = this.rootElements.Count - 1; i >= 0; i--)
|
||||
this.rootElements[i].Element.Update(time);
|
||||
|
||||
this.Stopwatch.Stop();
|
||||
this.Metrics.UpdateTime += this.Stopwatch.Elapsed;
|
||||
this.stopwatch.Stop();
|
||||
this.Metrics.UpdateTime += this.stopwatch.Elapsed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -271,15 +270,15 @@ namespace MLEM.Ui {
|
|||
/// <param name="batch">The sprite batch to use for drawing</param>
|
||||
public void DrawEarly(GameTime time, SpriteBatch batch) {
|
||||
this.Metrics.ResetDraws();
|
||||
this.Stopwatch.Restart();
|
||||
this.stopwatch.Restart();
|
||||
|
||||
foreach (var root in this.rootElements) {
|
||||
if (!root.Element.IsHidden)
|
||||
root.Element.DrawEarly(time, batch, this.DrawAlpha * root.Element.DrawAlpha, this.BlendState, this.SamplerState, this.DepthStencilState, this.Effect, root.Transform);
|
||||
}
|
||||
|
||||
this.Stopwatch.Stop();
|
||||
this.Metrics.DrawTime += this.Stopwatch.Elapsed;
|
||||
this.stopwatch.Stop();
|
||||
this.Metrics.DrawTime += this.stopwatch.Elapsed;
|
||||
this.drewEarly = true;
|
||||
}
|
||||
|
||||
|
@ -292,7 +291,7 @@ namespace MLEM.Ui {
|
|||
public void Draw(GameTime time, SpriteBatch batch) {
|
||||
if (!this.drewEarly)
|
||||
this.Metrics.ResetDraws();
|
||||
this.Stopwatch.Restart();
|
||||
this.stopwatch.Restart();
|
||||
|
||||
foreach (var root in this.rootElements) {
|
||||
if (root.Element.IsHidden)
|
||||
|
@ -303,8 +302,8 @@ namespace MLEM.Ui {
|
|||
batch.End();
|
||||
}
|
||||
|
||||
this.Stopwatch.Stop();
|
||||
this.Metrics.DrawTime += this.Stopwatch.Elapsed;
|
||||
this.stopwatch.Stop();
|
||||
this.Metrics.DrawTime += this.stopwatch.Elapsed;
|
||||
this.drewEarly = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue