Skip to content

Commit

Permalink
Improve support on graph plotter.
Browse files Browse the repository at this point in the history
  • Loading branch information
saint11 committed Dec 15, 2023
1 parent a03eb68 commit 175184e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/Murder.Editor/Architect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public class Architect : Game


/* *** Architect state *** */

private bool _isPlayingGame = false;

protected override bool AlwaysUpdateBeforeFixed => _isPlayingGame;
Expand Down
22 changes: 22 additions & 0 deletions src/Murder.Editor/Systems/Debug/EditorGraphLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ public void Plot(float point)
_maxValue = MathF.Max(point, _maxValue);
_valuesCache = [.. _values];
}
public void Plot(float point, int max)
{
if (_values.Count>max)
{
_values.Clear();
}
_values.Add(point);
_maxValue = MathF.Max(point, _maxValue);
_valuesCache = [.. _values];
}

public float[] Values => _valuesCache;
public float Max => _maxValue;
Expand All @@ -35,6 +45,18 @@ public override void PlotGraph(float value, string callerFilePath)
graph.Plot(value);
}

public override void PlotGraph(float value, int max, string callerFilePath)
{
string callerClassName = Path.GetFileNameWithoutExtension(callerFilePath);
if (!Graphs.ContainsKey(callerClassName))
{
Graphs[callerClassName] = new Graph();
}

Graph graph = Graphs[callerClassName];
graph.Plot(value, max);
}

public override void ClearGraph(string callerFilePath)
{
string callerClassName = Path.GetFileNameWithoutExtension(callerFilePath);
Expand Down
1 change: 1 addition & 0 deletions src/Murder/Diagnostics/GameLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ protected virtual void Input(Func<string, string>? onInputAction) { }
public static void ClearAllGraphs() => Game.Instance.GraphLogger.ClearAllGraphs();
public static void ClearGraph([CallerFilePath] string callerFilePath = "") => Game.Instance.GraphLogger.ClearGraph(callerFilePath);
public static void PlotGraph(float point, [CallerFilePath] string callerFilePath = "") => Game.Instance.GraphLogger.PlotGraph(point, callerFilePath);
public static void PlotGraph(float point, int max, [CallerFilePath] string callerFilePath = "") => Game.Instance.GraphLogger.PlotGraph(point, max, callerFilePath);
public static void LogPerf(string v, Vector4? color = null) =>
GetOrCreateInstance().LogPerfImpl(v, color ?? new Vector4(1, 1, 1, 1) /* white */);

Expand Down
2 changes: 2 additions & 0 deletions src/Murder/Diagnostics/GraphLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ public virtual void ClearGraph(string callerFilePath)

public virtual void PlotGraph(float value, string callerFilePath)
{ }
public virtual void PlotGraph(float value, int max, string callerFilePath)
{ }
}
}

0 comments on commit 175184e

Please sign in to comment.