From 960387d485ccdae307c8837b86fb130e4d8dea1b Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 1 Sep 2014 21:15:23 +0100 Subject: [PATCH] Add a command line parameter --remoteaccess to connect to instance * This is useful in e.g. a renderdoc-aware application that has voluntarily injected renderdoc, and then wants to boot the UI to automatically open up the management connection --- renderdocui/Code/AppMain.cs | 29 ++++++++++++++++++++++++++++- renderdocui/Code/Core.cs | 4 ++-- renderdocui/Windows/MainWindow.cs | 12 +++++++++++- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/renderdocui/Code/AppMain.cs b/renderdocui/Code/AppMain.cs index 9fa2b91ca..c6728aeb9 100644 --- a/renderdocui/Code/AppMain.cs +++ b/renderdocui/Code/AppMain.cs @@ -29,6 +29,7 @@ using System.Linq; using System.Text; using System.IO; using System.Windows.Forms; +using System.Text.RegularExpressions; using renderdoc; namespace renderdocui.Code @@ -74,6 +75,32 @@ namespace renderdocui.Code temp = true; } + string remoteHost = ""; + uint remoteIdent = 0; + + for (int i = 0; i < args.Length; i++) + { + if (args[i].ToLowerInvariant() == "--remoteaccess" && i + 1 < args.Length) + { + var regexp = @"^([a-zA-Z0-9_-]+:)?([0-9]+)$"; + + var match = Regex.Match(args[i+1], regexp); + + if (match.Success) + { + var host = match.Groups[1].Value; + if (host != "" && host[host.Length - 1] == ':') + host = host.Substring(0, host.Length - 1); + uint ident = 0; + if (uint.TryParse(match.Groups[2].Value, out ident)) + { + remoteHost = host; + remoteIdent = ident; + } + } + } + } + if (args.Length > 0 && File.Exists(args[args.Length - 1])) { filename = args[args.Length - 1]; @@ -107,7 +134,7 @@ namespace renderdocui.Code Application.CurrentCulture = new System.Globalization.CultureInfo("en-GB"); - var core = new Core(filename, temp, cfg); + var core = new Core(filename, remoteHost, remoteIdent, temp, cfg); try { diff --git a/renderdocui/Code/Core.cs b/renderdocui/Code/Core.cs index 2fbbbfbc0..f35ab6b82 100644 --- a/renderdocui/Code/Core.cs +++ b/renderdocui/Code/Core.cs @@ -146,13 +146,13 @@ namespace renderdocui.Code #region Init and Shutdown - public Core(string paramFilename, bool temp, PersistantConfig config) + public Core(string paramFilename, string remoteHost, uint remoteIdent, bool temp, PersistantConfig config) { if (!Directory.Exists(ConfigDirectory)) Directory.CreateDirectory(ConfigDirectory); m_Config = config; - m_MainWindow = new MainWindow(this, paramFilename, temp); + m_MainWindow = new MainWindow(this, paramFilename, remoteHost, remoteIdent, temp); } public void Shutdown() diff --git a/renderdocui/Windows/MainWindow.cs b/renderdocui/Windows/MainWindow.cs index 0e7d5a3b9..015162681 100644 --- a/renderdocui/Windows/MainWindow.cs +++ b/renderdocui/Windows/MainWindow.cs @@ -66,6 +66,8 @@ namespace renderdocui.Windows private Core m_Core; private string m_InitFilename; + private string m_InitRemoteHost; + private uint m_InitRemoteIdent; private List m_LiveCaptures = new List(); @@ -123,7 +125,7 @@ namespace renderdocui.Windows } } - public MainWindow(Core core, string initFilename, bool temp) + public MainWindow(Core core, string initFilename, string remoteHost, uint remoteIdent, bool temp) { InitializeComponent(); @@ -141,6 +143,8 @@ namespace renderdocui.Windows m_Core = core; m_InitFilename = initFilename; + m_InitRemoteHost = remoteHost; + m_InitRemoteIdent = remoteIdent; OwnTemporaryLog = temp; logStatisticsToolStripMenuItem.Enabled = false; @@ -190,6 +194,12 @@ namespace renderdocui.Windows PopulateRecentFiles(); PopulateRecentCaptures(); + if (m_InitRemoteIdent != 0) + { + var live = new LiveCapture(m_Core, m_InitRemoteHost, m_InitRemoteIdent, this); + ShowLiveCapture(live); + } + if (m_InitFilename != "") { if(Path.GetExtension(m_InitFilename) == ".rdc")