environment patch fix

This commit is contained in:
Alex Z 2020-03-16 01:52:16 +03:00
parent e1cf1fa387
commit 9b45461af3
3 changed files with 51 additions and 0 deletions

View File

@ -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}");
}

View File

@ -154,6 +154,7 @@
<SubType>Component</SubType>
</Compile>
<Compile Include="UI\View\IconComboBoxItem.cs" />
<Compile Include="Utils\EnvUtils.cs" />
<Compile Include="Utils\JsonFileUtil.cs" />
<Compile Include="Utils\LanguageManager.cs" />
<Compile Include="Model\Dto\ToolDtoModel.cs" />

View File

@ -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"));
}
}
}