4using System.Collections.Generic;
6using System.Reflection;
7using System.Diagnostics;
8using System.Runtime.CompilerServices;
12using Microsoft.Xna.Framework;
13using Microsoft.Xna.Framework.Input;
14using Microsoft.Xna.Framework.Graphics;
19 public class CUIDebugEvent
21 public CUIComponent Host;
22 public CUIComponent Target;
27 public CUIDebugEvent(CUIComponent host, CUIComponent target,
string method,
string sprop,
string tprop,
string value)
31 Method = method ??
"";
39 public class CUIDebugEventComponent : CUIComponent
41 public static Dictionary<int, Color> CapturedIDs =
new Dictionary<int, Color>();
45 private CUIDebugEvent _value;
public CUIDebugEvent Value
55 LastUpdate = Timing.TotalTime;
62 public void Flush() => Value =
null;
64 private void MakeText()
73 Line1 = $
" {Value.Target} in {Value.Host}.{Value.Method}";
74 Line2 = $
" {Value.SProp} -> {Value.TProp} {Value.Value}";
78 public static Random random =
new Random();
80 private static float NextColor;
81 private static float ColorShift = 0.05f;
82 private void AssignColor()
84 if (Value.Target ==
null)
return;
86 if (CapturedIDs.ContainsKey(Value.Target.
ID))
96 CapturedIDs[Value.Target.
ID] = GetColor(NextColor);
98 NextColor += ColorShift;
99 if (NextColor > 1) NextColor = 0;
106 public string Line1 =
"";
107 public string Line2 =
"";
109 public float UpdateTimer;
110 public double LastUpdate;
112 public Color GetColor(
float d)
114 return ToolBox.GradientLerp(d,
119 Color.Magenta * 0.5f,
124 public Color GetColor2(
float d)
126 return ToolBox.GradientLerp(Math.Min(0.8f, d),
127 CapturedIDs[Value.Target.
ID],
133 public override void Draw(SpriteBatch spriteBatch)
137 base.Draw(spriteBatch);
139 GUIStyle.Font.Value.DrawString(spriteBatch, Line1,
Real.Position, Color.White, rotation: 0, origin: Vector2.Zero, 0.9f, se: SpriteEffects.None, layerDepth: 0.1f);
141 GUIStyle.Font.Value.DrawString(spriteBatch, Line2,
Real.Position +
new Vector2(0, 20), Color.White, rotation: 0, origin: Vector2.Zero, 0.9f, se: SpriteEffects.None, layerDepth: 0.1f);
145 public CUIDebugEventComponent(CUIDebugEvent value =
null) : base()
150 Absolute =
new CUINullRect(
null,
null,
null, 40);
bool Revealed
Visible + !IgnoreEvents.
Color BackgroundColor
Color of BackgroundSprite, default is black If you're using custom sprite and don't see it make sur...
CUIRect Real
Calculated prop, position on real screen in pixels Should be fully calculated after CUIMainComponent....
int ID
Global ID, unique for component.
CUINullRect Absolute
Absolute size and position in pixels.