diff --git a/src/UniversalValveToolbox/UI/FormMain.cs b/src/UniversalValveToolbox/UI/FormMain.cs index b3387e7..b938cde 100644 --- a/src/UniversalValveToolbox/UI/FormMain.cs +++ b/src/UniversalValveToolbox/UI/FormMain.cs @@ -71,6 +71,9 @@ namespace UniversalValveToolbox { var indexProject = comboBoxProjects.Items.IndexOf(lastSelectedProject.Name); comboBoxProjects.SelectedIndex = indexProject; + + EnvUtils.PrepareVProject($"{SelectedProject?.Path ?? ""}"); + EnvUtils.PrepareSFMData($"{SelectedProject?.Path ?? ""}"); } } private void SaveLastSelectedProject() { @@ -363,11 +366,14 @@ namespace UniversalValveToolbox { var selectItem = listView.SelectedItems[0]; var selectItemText = selectItem.Text; + EnvUtils.PrepareVProject($"{SelectedProject?.Path ?? ""}"); + EnvUtils.PrepareSFMData($"{SelectedProject?.Path ?? ""}"); if (selectItem.Group == listViewGroupTools) { if (RUN_PROJECT_ID.Equals(selectItem.Tag) && SelectedProject != null) { var pathEngineBin = Path.Combine(SteamPathsUtil.GetSteamAppManifestDataById(SelectedEngine.Appid).Path, SelectedEngine.Bin); + Process.Start(pathEngineBin, $"-steam -game \"{SelectedProject?.Path ?? ""}\" {SelectedProject.Args}"); } diff --git a/src/UniversalValveToolbox/UniversalValveToolbox.csproj b/src/UniversalValveToolbox/UniversalValveToolbox.csproj index 80a97be..752a17c 100644 --- a/src/UniversalValveToolbox/UniversalValveToolbox.csproj +++ b/src/UniversalValveToolbox/UniversalValveToolbox.csproj @@ -154,6 +154,7 @@ Component + diff --git a/src/UniversalValveToolbox/Utils/EnvUtils.cs b/src/UniversalValveToolbox/Utils/EnvUtils.cs new file mode 100644 index 0000000..18f68e6 --- /dev/null +++ b/src/UniversalValveToolbox/Utils/EnvUtils.cs @@ -0,0 +1,44 @@ +using EpicMorg.SteamPathsLib; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace UniversalValveToolbox.Utils { + class EnvUtils { + public static void PrepareVProject(string data) { + Environment.SetEnvironmentVariable("VProject", data, EnvironmentVariableTarget.User); + } + + public static void PrepareVMod(string data) { + Environment.SetEnvironmentVariable("VMod", data, EnvironmentVariableTarget.User); + } + + public static void PrepareVGame(string data) { + Environment.SetEnvironmentVariable("VGame", data, EnvironmentVariableTarget.User); + } + + public static void PrepareVContent(string data) { + Environment.SetEnvironmentVariable("VContent", data, EnvironmentVariableTarget.User); + } + + public static void PrepareVTools(string data) { + Environment.SetEnvironmentVariable("VTools", data, EnvironmentVariableTarget.User); + } + + public static void PrepareSFMData(string pathProject) { + var SFMpath = SteamPathsUtil.GetSteamAppManifestDataById(1840)?.Path; + + if (SFMpath == null) + return; + + PrepareVMod(Path.GetDirectoryName(pathProject)); + PrepareVProject(pathProject); + PrepareVContent(Path.Combine(SFMpath, "content")); + PrepareVGame(Path.Combine(SFMpath, "game")); + PrepareVTools(Path.Combine(SFMpath, "game", "sdktools")); + } + } +}