public override void Initialize() { // Get debug manager from game service. debugManager = Game.Services.GetService(typeof(DebugManager)) as DebugManager; if (debugManager == null) { throw new InvalidOperationException("DebugManaer is not registered."); } // Register 'fps' command if debug command is registered as a service. IDebugCommandHost host = Game.Services.GetService(typeof(IDebugCommandHost)) as IDebugCommandHost; if (host != null) { host.RegisterCommand("fps", "FPS Counter", this.CommandExecute); Visible = true; } // Initialize parameters. Fps = 0; sampleFrames = 0; stopwatch = Stopwatch.StartNew(); stringBuilder.Length = 0; base.Initialize(); }
public override void Initialize() { // Get debug manager from game service. debugManager = Game.Services.GetService(typeof(DebugManager)) as DebugManager; if (debugManager == null) { throw new InvalidOperationException("DebugManaer is not registered."); } // Register 'fps' command if debug command is registered as a service. IDebugCommandHost host = Game.Services.GetService(typeof(IDebugCommandHost)) as IDebugCommandHost; if (host != null) { host.RegisterCommand("th", "Time History", this.CommandExecute); Visible = false; } // Initialize parameters. stringBuilder.Length = 0; InitializeHistory(); base.Initialize(); }
public void EchoAllProperties(IDebugCommandHost host) { foreach (Command command in commands) { EchoProperty(host, command); } }
public override void Initialize() { #if TRACE debugManager = Game.Services.GetService(typeof(vxDebugManager)) as vxDebugManager; if (debugManager == null) { throw new InvalidOperationException("DebugManager is not registered."); } // Add "tr" command if DebugCommandHost is registered. IDebugCommandHost host = Game.Services.GetService(typeof(IDebugCommandHost)) as IDebugCommandHost; if (host != null) { host.RegisterCommand("tr", "Toggles the time ruler to measure system performace for different code regions.", this.CommandExecute); this.Visible = false; } // Initialize Parameters. logs = new FrameLog[2]; for (int i = 0; i < logs.Length; ++i) { logs[i] = new FrameLog(); } sampleFrames = TargetSampleFrames = 1; // Time-Ruler's update method doesn't need to get called. this.Enabled = false; #endif base.Initialize(); }
/// <summary> /// FPS command implementation. /// </summary> private void CommandExecute(IDebugCommandHost host, string command, IList<string> arguments) { foreach (string arg in arguments) { arg.ToLower(); } if (arguments.Contains("list")) { ShowList(); } if (arguments.Contains("open")) { int index = arguments.IndexOf("open"); string sceneToOpen = arguments[index + 1]; if (sceneManager.ContainsScene(sceneToOpen)) { // activate the selected scene sceneManager.ActivateScene(sceneToOpen); } } if (arguments.Contains("close")) { int index = arguments.IndexOf("close"); string sceneToClose = arguments[index + 1]; if (sceneManager.ContainsScene(sceneToClose)) { sceneManager.ExitScene(sceneToClose); } } // TODO: allow loading and disposing of scenes }
private void ExecuteRemoteCommand(IDebugCommandHost host, string command, IList <string> arguments) { if (NetworkSession == null) { try { GamerServicesDispatcher.WindowHandle = Game.Window.Handle; GamerServicesDispatcher.Initialize(Game.Services); } catch { } if (SignedInGamer.SignedInGamers.Count > 0) { commandHost.Echo("Finding available sessions..."); asyncResult = NetworkSession.BeginFind( NetworkSessionType.SystemLink, 1, null, null, null); phase = ConnectionPahse.FindSessions; } else { host.Echo("Please signed in."); phase = ConnectionPahse.EnsureSignedIn; } } else { ConnectedToRemote(); } }
public override void Initialize() { #if TRACE debugManager = Game.Services.GetService(typeof(DebugManager)) as DebugManager; if (debugManager == null) { throw new InvalidOperationException("DebugManager is not registered."); } // Add "tr" command if DebugCommandHost is registered. IDebugCommandHost host = Game.Services.GetService(typeof(IDebugCommandHost)) as IDebugCommandHost; if (host != null) { host.RegisterCommand("tr", "TimeRuler", this.CommandExecute); this.Visible = false; this.Enabled = false; } // Initialize Parameters. logs = new FrameLog[2]; for (int i = 0; i < logs.Length; ++i) { logs[i] = new FrameLog(); } sampleFrames = TargetSampleFrames = 1; #endif base.Initialize(); }
public override void Initialize() { // Get debug manager from game service. debugManager = Game.Services.GetService(typeof(DebugManager)) as DebugManager; if (debugManager == null) { throw new InvalidOperationException("DebugManaer is not registered."); } // Register 'fps' command if debug command is registered as a service. IDebugCommandHost host = Game.Services.GetService(typeof(IDebugCommandHost)) as IDebugCommandHost; if (host != null) { host.RegisterCommand("memory", "Memory Tracker", this.CommandExecute); Visible = false; } // Initialize parameters. Collections = 0; ManagedHeapSize = GC.GetTotalMemory(false); ManagedHeapDelta = 0; stopwatch = Stopwatch.StartNew(); stringBuilder.Length = 0; base.Initialize(); }
public static void Initialize(Game g) { IDebugCommandHost host = g.Services.GetService(typeof(IDebugCommandHost)) as IDebugCommandHost; if (host != null) { host.RegisterCommand("rendercol", "Render Collision Geometry", RenderCollisionCommand); } }
private void ToggleCollisionDisplay(IDebugCommandHost host, string command, IList <string> arguments) { foreach (var component in ScreenManager.Game.Components) { if (component is TexturedDrawableGameComponent) { TexturedDrawableGameComponent texturedComponent = component as TexturedDrawableGameComponent; texturedComponent.DrawCollisionArea = !texturedComponent.DrawCollisionArea; } } }
public RemoteDebugCommand(Game game) : base(game) { commandHost = game.Services.GetService(typeof(IDebugCommandHost)) as IDebugCommandHost; if (!IsHost) { commandHost.RegisterCommand("remote", "Start remote command", ExecuteRemoteCommand); } }
public RemoteDebugCommand(Game game) : base(game) { commandHost = game.Services.GetService(typeof(IDebugCommandHost)) as IDebugCommandHost; if (!IsHost) { commandHost.RegisterCommand("remote", "Start remote command", ExecuteRemoteCommand); } }
public void ToggleEditModeCommand(IDebugCommandHost host, string command, string[] arguments) { if (Config.EditMode == false) { game.IsMouseVisible = true; Config.EditMode = true; } else { game.IsMouseVisible = false; Config.EditMode = false; } }
/// <summary> /// This method is called from DebugCommandHost when the user types the 'pos' /// command into the command prompt. This is registered with the command prompt /// through the DebugCommandUI.RegisterCommand method we called in Initialize. /// </summary> void PosCommand(IDebugCommandHost host, string command, IList <string> arguments) { // if we got two arguments from the command if (arguments.Count == 2) { // process text "pos xPos yPos" by parsing our two arguments debugPos.X = Single.Parse(arguments[0], CultureInfo.InvariantCulture); debugPos.Y = Single.Parse(arguments[1], CultureInfo.InvariantCulture); } else { // if we didn't get two arguments, we echo the current position of the cat host.Echo(String.Format("Pos={0},{1}", debugPos.X, debugPos.Y)); } }
public void ToggleEditModeCommand(IDebugCommandHost host, string command, string[] arguments) { if(Config.EditMode == false) { game.IsMouseVisible = true; Config.EditMode = true; } else { game.IsMouseVisible = false; Config.EditMode = false; } }
public bool HandlePropertyCommand( IDebugCommandHost host, string commandName, string value) { bool handled = false; foreach (Command command in commands) { if (string.Compare(command.CommandName, commandName, true) == 0 || string.Compare(command.PropertyName, commandName, true) == 0) { HandleProperty(host, command, value); handled = true; break; } } return handled; }
private void CommandExecute(IDebugCommandHost host, string command, IList<string> arguments) { if (arguments.Count == 0) Visible = !Visible; foreach (string arg in arguments) { switch (arg.ToLower()) { case "on": Visible = true; break; case "off": Visible = false; break; } } }
/// <summary> /// memory command implementation. /// </summary> private void CommandExecute(IDebugCommandHost host, string command, IList <string> arguments) { if (arguments.Count == 0) { Visible = !Visible; } foreach (string arg in arguments) { switch (arg.ToLower()) { case "on": Visible = true; break; case "off": Visible = false; break; } } }
private static void RenderCollisionCommand(IDebugCommandHost host, string command, IList <string> arguments) { if (arguments.Count == 0) { RenderCollisionGeometry = !RenderCollisionGeometry; } foreach (string arg in arguments) { switch (arg.ToLower()) { case "on": RenderCollisionGeometry = true; break; case "off": RenderCollisionGeometry = false; break; } } }
/// <summary> /// FPS command implementation. /// </summary> private string CommandExecute(IDebugCommandHost host, string command, IList <string> arguments) { if (arguments.Count == 0) { Visible = !Visible; } foreach (string arg in arguments) { switch (arg.ToLower()) { case "on": Visible = true; break; case "off": Visible = false; break; } } return(String.Format("FPS is {0}", Visible)); }
void HandleProperty(IDebugCommandHost host, Command command, string value) { if (value == null) { EchoProperty(host, command); } else { SetProperty(host, command, value); } }
/// <summary> /// 'tr' command execution. /// </summary> void CommandExecute(IDebugCommandHost host, string command, IList<string> arguments) { bool previousVisible = Visible; if (arguments.Count == 0) Visible = !Visible; char[] subArgSeparator = new[] { ':' }; foreach (string orgArg in arguments) { string arg = orgArg.ToLower(); string[] subargs = arg.Split(subArgSeparator); switch (subargs[0]) { case "on": Visible = true; break; case "off": Visible = false; break; case "reset": ResetLog(); break; case "log": if (subargs.Length > 1) { if (String.Compare(subargs[1], "on") == 0) ShowLog = true; if (String.Compare(subargs[1], "off") == 0) ShowLog = false; } else { ShowLog = !ShowLog; } break; case "frame": int a = Int32.Parse(subargs[1]); a = Math.Max(a, 1); a = Math.Min(a, MaxSampleFrames); TargetSampleFrames = a; break; case "/?": case "--help": host.Echo("tr [log|on|off|reset|frame]"); host.Echo("Options:"); host.Echo(" on Display TimeRuler."); host.Echo(" off Hide TimeRuler."); host.Echo(" log Show/Hide marker log."); host.Echo(" reset Reset marker log."); host.Echo(" frame:sampleFrames"); host.Echo(" Change target sample frame count"); break; default: break; } } // Reset update count when Visible state changed. if (Visible != previousVisible) { Interlocked.Exchange(ref updateCount, 0); } }
private void ExecuteQuitCommand(IDebugCommandHost host, string command, IList <string> arguments) { SendPacket(QuitPacketHeader, "End Remote Debug Command."); DisconnectedFromRemote(); }
private void ExecuteQuitCommand(IDebugCommandHost host, string command, IList<string> arguments) { SendPacket(QuitPacketHeader, "End Remote Debug Command."); DisconnectedFromRemote(); }
private void ExecuteRemoteCommand(IDebugCommandHost host, string command, IList<string> arguments) { if (NetworkSession == null) { try { GamerServicesDispatcher.WindowHandle = Game.Window.Handle; GamerServicesDispatcher.Initialize(Game.Services); } catch { } if (SignedInGamer.SignedInGamers.Count > 0) { commandHost.Echo("Finding available sessions..."); asyncResult = NetworkSession.BeginFind( NetworkSessionType.SystemLink, 1, null, null, null); phase = ConnectionPahse.FindSessions; } else { host.Echo("Please signed in."); phase = ConnectionPahse.EnsureSignedIn; } } else { ConnectedToRemote(); } }
public static void ToggleDebugCommand(IDebugCommandHost host, string command, params string[] arguments) { Config.DebugModeEnabled = !Config.DebugModeEnabled; }
/// <summary> /// This method is called from DebugCommandHost when the user types the 'pos' /// command into the command prompt. This is registered with the command prompt /// through the DebugCommandUI.RegisterCommand method we called in Initialize. /// </summary> public void PosCommand(IDebugCommandHost host, string command, IList<string> arguments) { // if we got two arguments from the command if (arguments.Count == 2) { // process text "pos xPos yPos" by parsing our two arguments debugPos.X = Single.Parse(arguments[0], CultureInfo.InvariantCulture); debugPos.Y = Single.Parse(arguments[1], CultureInfo.InvariantCulture); } else { // if we didn't get two arguments, we echo the current position of the cat host.Echo(String.Format("Pos={0},{1}", debugPos.X, debugPos.Y)); } }
public static void ToggleSoundCommand(IDebugCommandHost host, string command, params string[] arguments) { Config.SoundEnabled = !Config.SoundEnabled; }
bool EchoProperty( IDebugCommandHost host, Command command, object parent) { //var propertyInfo = parent.GetType().GetProperty(command.PropertyName); //if (propertyInfo != null) //{ // var value = propertyInfo.GetValue(parent, null); // host.Echo(string.Format( // "[{0}] {1}: {2}", // command.CommandName, // command.PropertyName, // value)); // return true; //} var fieldInfo = parent.GetType().GetField(command.PropertyName); if (fieldInfo != null) { var value = fieldInfo.GetValue(parent); host.Echo(string.Format( "[{0}] {1}: {2}", command.CommandName, command.PropertyName, value)); return true; } return false; }
void EchoProperty( IDebugCommandHost host, Command command) { var propertyInfo = target.GetType().GetProperty(command.PropertyName); if (propertyInfo != null) { var value = propertyInfo.GetValue(target, null); host.Echo(string.Format( "[{0}] {1}: {2}", command.CommandName, command.PropertyName, value)); return; } var fieldInfo = target.GetType().GetField(command.PropertyName); if (fieldInfo != null) { var value = fieldInfo.GetValue(target); host.Echo(string.Format( "[{0}] {1}: {2}", command.CommandName, command.PropertyName, value)); return; } host.Echo(string.Format( "'{0}' have no property/filed '{1}'", target.GetType().Name, command.PropertyName)); }
object SetProperty( IDebugCommandHost host, Command command, string value, object parent) { try { //var propertyInfo = parent.GetType().GetProperty(command.PropertyName); //if (propertyInfo != null) //{ // object convertedValue = ConvertValue(propertyInfo.PropertyType, value); // propertyInfo.SetValue(parent, convertedValue, null); // return parent; //} var fieldInfo = parent.GetType().GetField(command.PropertyName); if (fieldInfo != null) { object convertedValue = ConvertValue(fieldInfo.FieldType, value); fieldInfo.SetValue(parent, convertedValue); return parent; } } catch (Exception e) { host.EchoError(e.Message); } return null; }
void EchoProperty( IDebugCommandHost host, Command command) { bool parentExist = false; var parentPropertyInfo = target.GetType().GetProperty(structPropertyName); if (parentPropertyInfo != null) { parentExist = true; var parent = parentPropertyInfo.GetValue(target, null); if (EchoProperty(host, command, parent)) { return; } } var parentFieldInfo = target.GetType().GetField(structPropertyName); if (parentFieldInfo != null) { parentExist = true; var parent = parentFieldInfo.GetValue(target); if (EchoProperty(host, command, parent)) { return; } } if (!parentExist) { host.Echo(string.Format( "'{0}' have no property/filed '{1}'", target.GetType().Name, structPropertyName)); } else { host.Echo(string.Format( "'{0}.{1}' have no property/filed '{2}'", target.GetType().Name, structPropertyName, command.PropertyName)); } }
/// <summary> /// 'tr' command execution. /// </summary> void CommandExecute(IDebugCommandHost host, string command, IList <string> arguments) { bool previousVisible = Visible; if (arguments.Count == 0) { Visible = !Visible; } char[] subArgSeparator = new[] { ':' }; foreach (string orgArg in arguments) { string arg = orgArg.ToLower(); string[] subargs = arg.Split(subArgSeparator); switch (subargs[0]) { case "on": Visible = true; break; case "off": Visible = false; break; case "reset": ResetLog(); break; case "log": if (subargs.Length > 1) { if (String.Compare(subargs[1], "on") == 0) { ShowLog = true; } if (String.Compare(subargs[1], "off") == 0) { ShowLog = false; } } else { ShowLog = !ShowLog; } break; case "frame": int a = Int32.Parse(subargs[1]); a = Math.Max(a, 1); a = Math.Min(a, MaxSampleFrames); TargetSampleFrames = a; break; case "/?": case "--help": host.Echo("tr [log|on|off|reset|frame]"); host.Echo("Options:"); host.Echo(" on Display TimeRuler."); host.Echo(" off Hide TimeRuler."); host.Echo(" log Show/Hide marker log."); host.Echo(" reset Reset marker log."); host.Echo(" frame:sampleFrames"); host.Echo(" Change target sample frame count"); break; default: break; } } // Reset update count when Visible state changed. if (Visible != previousVisible) { Interlocked.Exchange(ref updateCount, 0); } }
void SetProperty( IDebugCommandHost host, Command command, string value) { try { var propertyInfo = target.GetType().GetProperty(command.PropertyName); if (propertyInfo != null) { object convertedValue = ConvertValue(propertyInfo.PropertyType, value); propertyInfo.SetValue(target, convertedValue, null); return; } var fieldInfo = target.GetType().GetField(command.PropertyName); if (fieldInfo != null) { object convertedValue = ConvertValue(fieldInfo.FieldType, value); fieldInfo.SetValue(target, convertedValue); return; } host.Echo(string.Format( "'{0}' have no property/filed '{1}'", target.GetType().Name, command.PropertyName)); } catch (Exception e) { host.EchoError(e.Message); } }