Allow specifying environment variable modifications

* This works for local and remote invocations of programs, but is mostly
  useful on unix systems (Windows programs use env vars less often)
This commit is contained in:
baldurk
2016-08-19 17:26:33 +02:00
parent 71cca06683
commit b5e6f8bef2
20 changed files with 1132 additions and 78 deletions
+39 -2
View File
@@ -53,8 +53,11 @@ namespace renderdocui.Windows.Dialogs
public string Executable = "";
public string WorkingDir = "";
public string CmdLine = "";
public EnvironmentModification[] Environment = new EnvironmentModification[0];
}
private EnvironmentModification[] m_EnvModifications = new EnvironmentModification[0];
private bool workDirHint = true;
private Core m_Core;
@@ -69,6 +72,8 @@ namespace renderdocui.Windows.Dialogs
workDirPath.Text = settings.WorkingDir;
cmdline.Text = settings.CmdLine;
SetEnvironmentModifications(settings.Environment);
workDirPath_Leave(null, null);
AllowFullscreen.Checked = settings.Options.AllowFullscreen;
@@ -109,6 +114,8 @@ namespace renderdocui.Windows.Dialogs
ret.WorkingDir = RealWorkDir;
ret.CmdLine = cmdline.Text;
ret.Environment = m_EnvModifications;
ret.Options.AllowFullscreen = AllowFullscreen.Checked;
ret.Options.AllowVSync = AllowVSync.Checked;
ret.Options.HookIntoChildren = HookIntoChildren.Checked;
@@ -195,7 +202,7 @@ namespace renderdocui.Windows.Dialogs
#region Callbacks
public delegate LiveCapture OnCaptureMethod(string exe, string workingDir, string cmdLine, CaptureOptions opts);
public delegate LiveCapture OnCaptureMethod(string exe, string workingDir, string cmdLine, EnvironmentModification[] env, CaptureOptions opts);
public delegate LiveCapture OnInjectMethod(UInt32 PID, string name, CaptureOptions opts);
private OnCaptureMethod m_CaptureCallback = null;
@@ -285,7 +292,7 @@ namespace renderdocui.Windows.Dialogs
string cmdLine = cmdline.Text;
var live = m_CaptureCallback(exe, workingDir, cmdLine, GetSettings().Options);
var live = m_CaptureCallback(exe, workingDir, cmdLine, GetSettings().Environment, GetSettings().Options);
if (queueFrameCap.Checked && live != null)
live.QueueCapture((int)queuedCapFrame.Value);
@@ -452,6 +459,36 @@ namespace renderdocui.Windows.Dialogs
workDirPath.ForeColor = SystemColors.WindowText;
}
private void setEnv_Click(object sender, EventArgs e)
{
EnvironmentEditor envEditor = new EnvironmentEditor();
foreach (var mod in m_EnvModifications)
envEditor.AddModification(mod, true);
DialogResult res = envEditor.ShowDialog(this);
if (res == DialogResult.OK)
SetEnvironmentModifications(envEditor.Modifications);
}
private void SetEnvironmentModifications(EnvironmentModification[] modifications)
{
m_EnvModifications = modifications;
string envModText = "";
foreach (var mod in modifications)
{
if (envModText != "")
envModText += ", ";
envModText += mod.GetDescription();
}
environmentDisplay.Text = envModText;
}
private void workDirPath_TextChanged(object sender, EventArgs e)
{
if(Directory.Exists(workDirPath.Text))