Skip to content

Commit f521d6f

Browse files
committed
performance fixes on DebugWindow
With the DebugWindow open for a while the FPS would slowly creep down to nearly 0, and from the profiler it appeared to be clustered in MoveNext in the different threaded async value generators. I'm hoping the more active value providers will be more performant.
1 parent 2cf6117 commit f521d6f

38 files changed

+861
-368
lines changed

Intersect.Client.Core/Core/Graphics.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ public static void DrawInGame(TimeSpan deltaTime)
529529
}
530530

531531
//Game Rendering
532-
public static void Render(TimeSpan deltaTime, TimeSpan _)
532+
public static void Render(TimeSpan deltaTime, TimeSpan totalTime)
533533
{
534534
var takingScreenshot = false;
535535
if (Renderer?.ScreenshotRequests.Count > 0)
@@ -592,7 +592,7 @@ public static void Render(TimeSpan deltaTime, TimeSpan _)
592592

593593
Renderer.Scale = Globals.Database.UIScale;
594594

595-
Interface.Interface.DrawGui();
595+
Interface.Interface.DrawGui(deltaTime, totalTime);
596596

597597
DrawGameTexture(
598598
Renderer.GetWhiteTexture(), new FloatRect(0, 0, 1, 1), CurrentView,

Intersect.Client.Core/Core/Main.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ public static void Update(TimeSpan deltaTime)
9898
Globals.InputManager.Update(deltaTime);
9999
Audio.Update();
100100

101+
Time.Update();
102+
101103
Globals.OnGameUpdate(deltaTime);
102104
}
103105
}
@@ -267,7 +269,6 @@ private static void ProcessGame()
267269
}
268270

269271
Graphics.UpdatePlayerLight();
270-
Time.Update();
271272
}
272273

273274
public static void JoinGame()

Intersect.Client.Core/General/Time.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ public static void LoadTime(DateTime timeUpdate, Color clr, float rate)
2929

3030
public static void Update()
3131
{
32+
if (!Networking.Network.IsConnected)
33+
{
34+
sServerTime = DateTime.Now;
35+
return;
36+
}
37+
3238
if (sUpdateTime < Timing.Global.Milliseconds)
3339
{
3440
var ts = new TimeSpan(0, 0, 0, 0, (int) (1000 * sRate));

Intersect.Client.Core/Interface/Debugging/DebugWindow.cs

Lines changed: 71 additions & 268 deletions
Large diffs are not rendered by default.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Intersect.Client.Entities;
2+
using Intersect.Client.General;
3+
using Intersect.Client.Interface.Data;
4+
5+
namespace Intersect.Client.Interface.Debugging.Providers;
6+
7+
public sealed class ActivePlayerProvider(TimeSpan delay) : DelayedDataProvider<Player?>(delay)
8+
{
9+
public ActivePlayerProvider() : this(MinimumDelay) { }
10+
11+
protected override bool TryDelayedUpdate(TimeSpan elapsed, TimeSpan total)
12+
{
13+
var newValue = Globals.Me;
14+
return TrySetValue(newValue);
15+
}
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Intersect.Client.Framework.Gwen.Control;
2+
using Intersect.Client.Interface.Data;
3+
4+
namespace Intersect.Client.Interface.Debugging.Providers;
5+
6+
public sealed class NodeUnderCursorProvider(TimeSpan delay) : DelayedDataProvider<Base?>(delay)
7+
{
8+
public NodeUnderCursorProvider() : this(MinimumDelay) { }
9+
10+
public NodeFilter Filter { get; set; } = NodeFilter.IncludeMouseInputDisabled;
11+
12+
protected override bool TryDelayedUpdate(TimeSpan elapsed, TimeSpan total)
13+
{
14+
var newValue = Interface.FindComponentUnderCursor(Filter);
15+
return TrySetValue(newValue);
16+
}
17+
}

Intersect.Client.Core/Interface/Game/GameInterface.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public void AdminWindowSelectName(string playerName)
322322
adminWindow.PlayerName = playerName;
323323
}
324324

325-
public void Update()
325+
public void Update(TimeSpan elapsed, TimeSpan total)
326326
{
327327
if (Globals.Me != null && PlayerBox?.MyEntity != Globals.Me)
328328
{
@@ -509,9 +509,9 @@ public void Update()
509509
}
510510
}
511511

512-
public void Draw()
512+
public void Draw(TimeSpan elapsed, TimeSpan total)
513513
{
514-
GameCanvas.RenderCanvas();
514+
GameCanvas.RenderCanvas(elapsed, total);
515515
}
516516

517517
private void CloseShop()

Intersect.Client.Core/Interface/Interface.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public static bool HasInputFocus() =>
169169
#region "GUI Functions"
170170

171171
//Actual Drawing Function
172-
public static void DrawGui()
172+
public static void DrawGui(TimeSpan elapsed, TimeSpan total)
173173
{
174174
if (!GwenInitialized)
175175
{
@@ -178,11 +178,11 @@ public static void DrawGui()
178178

179179
if (Globals.GameState == GameStates.Menu)
180180
{
181-
MenuUi.Update();
181+
MenuUi.Update(elapsed, total);
182182
}
183183
else if (Globals.GameState == GameStates.InGame)
184184
{
185-
GameUi.Update();
185+
GameUi.Update(elapsed, total);
186186
}
187187

188188
//Do not allow hiding of UI under several conditions
@@ -193,7 +193,7 @@ public static void DrawGui()
193193
sGameCanvas.RestrictToParent = false;
194194
if (Globals.GameState == GameStates.Menu)
195195
{
196-
MenuUi.Draw();
196+
MenuUi.Draw(elapsed, total);
197197
}
198198
else if (Globals.GameState == GameStates.InGame)
199199
{
@@ -210,7 +210,7 @@ public static void DrawGui()
210210
{
211211
sGameCanvas.Show();
212212
}
213-
GameUi.Draw();
213+
GameUi.Draw(elapsed, total);
214214
}
215215
}
216216
}
@@ -266,7 +266,7 @@ public static void EnqueueInGame(Action action)
266266
_onCreatedGameUi.Enqueue(action);
267267
}
268268

269-
public static Framework.Gwen.Control.Base? FindComponentUnderCursor(ComponentStateFilters filters = default)
269+
public static Framework.Gwen.Control.Base? FindComponentUnderCursor(NodeFilter filters = default)
270270
{
271271
var cursor = new Point(InputHandler.MousePosition.X, InputHandler.MousePosition.Y);
272272
var componentUnderCursor = CurrentInterface?.Root.GetComponentAt(cursor, filters);

Intersect.Client.Core/Interface/Menu/LoginWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ private void UsernameInputClicked(Base sender, MouseButtonState arguments)
206206
text => _usernameInput.Text = text ?? string.Empty,
207207
Strings.LoginWindow.Username,
208208
_usernameInput.Text,
209-
inputBounds: _usernameInput.BoundsGlobal
209+
inputBounds: _usernameInput.GlobalBounds
210210
);
211211
}
212212

Intersect.Client.Core/Interface/Menu/MainMenu.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public static void HandleReceivedConfiguration()
118118
}
119119

120120
//Methods
121-
public void Update()
121+
public void Update(TimeSpan elapsed, TimeSpan total)
122122
{
123123
if (_mainMenuWindow.IsVisible)
124124
{

0 commit comments

Comments
 (0)