mirror of
https://github.com/EpicMorg/UniversalValveToolbox.git
synced 2025-01-27 22:18:12 +03:00
replace steampathslib to facepunch.steamworks
This commit is contained in:
parent
93b7e2789a
commit
5396b80b57
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using Steamworks;
|
||||||
|
using System;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using UniversalValveToolbox.Model.Provider;
|
using UniversalValveToolbox.Model.Provider;
|
||||||
using UniversalValveToolbox.Utils;
|
using UniversalValveToolbox.Utils;
|
||||||
@ -10,6 +11,8 @@ namespace UniversalValveToolbox {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main() {
|
static void Main() {
|
||||||
|
SteamClient.Init(480);
|
||||||
|
|
||||||
var dataProvide = new DataProvider();
|
var dataProvide = new DataProvider();
|
||||||
var currSettings = dataProvide.Settings;
|
var currSettings = dataProvide.Settings;
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ namespace UniversalValveToolbox {
|
|||||||
System.Reflection.Assembly assemblykasthackbindingwf = System.Reflection.Assembly.LoadFrom("kasthack.binding.wf.dll");
|
System.Reflection.Assembly assemblykasthackbindingwf = System.Reflection.Assembly.LoadFrom("kasthack.binding.wf.dll");
|
||||||
System.Reflection.Assembly assemblyGameloopVdf = System.Reflection.Assembly.LoadFrom("Gameloop.Vdf.dll");
|
System.Reflection.Assembly assemblyGameloopVdf = System.Reflection.Assembly.LoadFrom("Gameloop.Vdf.dll");
|
||||||
System.Reflection.Assembly assemblyNewtonsoftJson = System.Reflection.Assembly.LoadFrom("Newtonsoft.Json.dll");
|
System.Reflection.Assembly assemblyNewtonsoftJson = System.Reflection.Assembly.LoadFrom("Newtonsoft.Json.dll");
|
||||||
|
|
||||||
Version verEpicMorgSteamPathsLib = assemblyEpicMorgSteamPathsLib.GetName().Version;
|
Version verEpicMorgSteamPathsLib = assemblyEpicMorgSteamPathsLib.GetName().Version;
|
||||||
Version verFacepunchSteamworksWin32 = assemblyFacepunchSteamworksWin32.GetName().Version;
|
Version verFacepunchSteamworksWin32 = assemblyFacepunchSteamworksWin32.GetName().Version;
|
||||||
Version verkasthackbindingwf = assemblykasthackbindingwf.GetName().Version;
|
Version verkasthackbindingwf = assemblykasthackbindingwf.GetName().Version;
|
||||||
|
@ -9,7 +9,7 @@ using System.Collections.Generic;
|
|||||||
using UniversalValveToolbox.Utils;
|
using UniversalValveToolbox.Utils;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using EpicMorg.SteamPathsLib;
|
using Steamworks;
|
||||||
|
|
||||||
namespace UniversalValveToolbox {
|
namespace UniversalValveToolbox {
|
||||||
public partial class FormAddons : Form {
|
public partial class FormAddons : Form {
|
||||||
@ -30,7 +30,7 @@ namespace UniversalValveToolbox {
|
|||||||
.Cast<DictionaryEntry>()
|
.Cast<DictionaryEntry>()
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
model = new FormAddonViewModel(dataProvider.Addons, dataProvider.Engines.Where(engine => SteamPathsUtil.GetSteamAppDataById(engine.Appid) != null).ToArray(), categories);
|
model = new FormAddonViewModel(dataProvider.Addons, dataProvider.Engines.Where(engine => isSteamAppInstall(engine.Appid)).ToArray(), categories);
|
||||||
|
|
||||||
UpdateAddonsComboBox();
|
UpdateAddonsComboBox();
|
||||||
UpdateAddonCategoryComboBox();
|
UpdateAddonCategoryComboBox();
|
||||||
@ -106,6 +106,11 @@ namespace UniversalValveToolbox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool isSteamAppInstall(int appId) {
|
||||||
|
var isInstall = SteamApps.IsAppInstalled(appId);
|
||||||
|
return isInstall;
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateAddonCategoryComboBox() {
|
private void UpdateAddonCategoryComboBox() {
|
||||||
comboBoxCategory.Items.Clear();
|
comboBoxCategory.Items.Clear();
|
||||||
comboBoxCategory.Items.AddRange(model.Categories.Select(c => c.Value).ToArray());
|
comboBoxCategory.Items.AddRange(model.Categories.Select(c => c.Value).ToArray());
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using EpicMorg.SteamPathsLib;
|
using Steamworks;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@ -167,9 +167,8 @@ namespace UniversalValveToolbox {
|
|||||||
private void UpdateEngineList() {
|
private void UpdateEngineList() {
|
||||||
var dataProvider = new DataProvider();
|
var dataProvider = new DataProvider();
|
||||||
Engines = dataProvider.Engines.Where(engine => {
|
Engines = dataProvider.Engines.Where(engine => {
|
||||||
var engineAppData = SteamPathsUtil.GetSteamAppDataById(engine.Appid);
|
var isInstall = SteamApps.IsAppInstalled(engine.Appid);
|
||||||
|
return isInstall;
|
||||||
return engineAppData != null && engineAppData.Installed;
|
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
|
|
||||||
if (Engines != null && Engines.Length != 0) {
|
if (Engines != null && Engines.Length != 0) {
|
||||||
@ -222,7 +221,7 @@ namespace UniversalValveToolbox {
|
|||||||
if (SelectedEngine == null)
|
if (SelectedEngine == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var pathSelectedEngine = SteamPathsUtil.GetSteamAppManifestDataById(SelectedEngine.Appid)?.Path;
|
var pathSelectedEngine = SteamApps.AppInstallDir(SelectedEngine.Appid);
|
||||||
|
|
||||||
if (pathSelectedEngine != null) {
|
if (pathSelectedEngine != null) {
|
||||||
var pairPathIconTools = SelectedEngine.Tools
|
var pairPathIconTools = SelectedEngine.Tools
|
||||||
@ -260,13 +259,10 @@ namespace UniversalValveToolbox {
|
|||||||
listView.Items.AddRange(itemsTools);
|
listView.Items.AddRange(itemsTools);
|
||||||
|
|
||||||
|
|
||||||
var engineData = SteamPathsUtil.GetSteamAppManifestDataById(SelectedEngine.Appid);
|
var enginePath = SteamApps.AppInstallDir(SelectedEngine.Appid);
|
||||||
var isAvailableProjectBySelectEngine = Projects.Any(project => project.Engine == SelectedEngine.Appid);
|
var isAvailableProjectBySelectEngine = Projects.Any(project => project.Engine == SelectedEngine.Appid);
|
||||||
|
|
||||||
if (engineData != null && isAvailableProjectBySelectEngine) {
|
if (enginePath != null && isAvailableProjectBySelectEngine) {
|
||||||
var enginePath = engineData.Path;
|
|
||||||
|
|
||||||
if (enginePath != null) {
|
|
||||||
var iconPathEngine = Path.Combine(enginePath, SelectedEngine.Bin);
|
var iconPathEngine = Path.Combine(enginePath, SelectedEngine.Bin);
|
||||||
|
|
||||||
var runProjectListViewItem = new ListViewItem(Properties.translations.MenuItems.itmRunProject, iconPathEngine, listViewGroupTools);
|
var runProjectListViewItem = new ListViewItem(Properties.translations.MenuItems.itmRunProject, iconPathEngine, listViewGroupTools);
|
||||||
@ -275,7 +271,6 @@ namespace UniversalValveToolbox {
|
|||||||
listView.Items.Add(runProjectListViewItem);
|
listView.Items.Add(runProjectListViewItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateAddonsList() {
|
private void UpdateAddonsList() {
|
||||||
var removeItem = new List<ListViewItem>();
|
var removeItem = new List<ListViewItem>();
|
||||||
@ -289,7 +284,7 @@ namespace UniversalValveToolbox {
|
|||||||
if (SelectedEngine == null)
|
if (SelectedEngine == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var pathSelectedEngine = SteamPathsUtil.GetSteamAppManifestDataById(SelectedEngine.Appid)?.Path;
|
var pathSelectedEngine = SteamApps.AppInstallDir(SelectedEngine.Appid);
|
||||||
var addonsSelectedEngine = dataProvider.Addons.Where(a => a.Engines.Contains(SelectedEngine.Appid));
|
var addonsSelectedEngine = dataProvider.Addons.Where(a => a.Engines.Contains(SelectedEngine.Appid));
|
||||||
|
|
||||||
|
|
||||||
@ -374,7 +369,7 @@ namespace UniversalValveToolbox {
|
|||||||
|
|
||||||
if (selectItem.Group == listViewGroupTools) {
|
if (selectItem.Group == listViewGroupTools) {
|
||||||
if (RUN_PROJECT_ID.Equals(selectItem.Tag) && SelectedProject != null) {
|
if (RUN_PROJECT_ID.Equals(selectItem.Tag) && SelectedProject != null) {
|
||||||
var pathEngineBin = Path.Combine(SteamPathsUtil.GetSteamAppManifestDataById(SelectedEngine.Appid).Path, SelectedEngine.Bin);
|
var pathEngineBin = Path.Combine(SteamApps.AppInstallDir(SelectedEngine.Appid), SelectedEngine.Bin);
|
||||||
|
|
||||||
|
|
||||||
Process.Start(pathEngineBin, $"-steam -game \"{SelectedProject?.Path ?? string.Empty}\" {SelectedProject.Args}");
|
Process.Start(pathEngineBin, $"-steam -game \"{SelectedProject?.Path ?? string.Empty}\" {SelectedProject.Args}");
|
||||||
@ -382,7 +377,7 @@ namespace UniversalValveToolbox {
|
|||||||
|
|
||||||
var selectedTool = SelectedEngine.Tools.FirstOrDefault(tool => tool.Name == selectItemText);
|
var selectedTool = SelectedEngine.Tools.FirstOrDefault(tool => tool.Name == selectItemText);
|
||||||
if (selectedTool != null) {
|
if (selectedTool != null) {
|
||||||
var selectedEnginePath = SteamPathsUtil.GetSteamAppManifestDataById(SelectedEngine.Appid)?.Path;
|
var selectedEnginePath = SteamApps.AppInstallDir(SelectedEngine.Appid);
|
||||||
|
|
||||||
if (selectedEnginePath != null) {
|
if (selectedEnginePath != null) {
|
||||||
var toolPath = Path.Combine(selectedEnginePath, selectedTool.Bin);
|
var toolPath = Path.Combine(selectedEnginePath, selectedTool.Bin);
|
||||||
@ -394,7 +389,15 @@ namespace UniversalValveToolbox {
|
|||||||
finalArg += $" -game \"{SelectedProject?.Path ?? string.Empty}\" ";
|
finalArg += $" -game \"{SelectedProject?.Path ?? string.Empty}\" ";
|
||||||
}
|
}
|
||||||
|
|
||||||
Process.Start(toolPath, finalArg);
|
SteamClient.Shutdown();
|
||||||
|
SteamClient.Init(Convert.ToUInt32(SelectedEngine.Appid));
|
||||||
|
var process = Process.Start(toolPath, finalArg);
|
||||||
|
process.EnableRaisingEvents = true;
|
||||||
|
process.Exited += (a, b) => {
|
||||||
|
SteamClient.Shutdown();
|
||||||
|
SteamClient.Init(480);
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
MessageBox.Show($"\"{selectedTool.Name}\" {Properties.translations.MessageBoxes.msgTextNotFound}\n{toolPath}", Properties.translations.MessageBoxes.msgWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
MessageBox.Show($"\"{selectedTool.Name}\" {Properties.translations.MessageBoxes.msgTextNotFound}\n{toolPath}", Properties.translations.MessageBoxes.msgWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using EpicMorg.SteamPathsLib;
|
|
||||||
using kasthack.binding.wf;
|
using kasthack.binding.wf;
|
||||||
|
using Steamworks;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -21,7 +22,7 @@ namespace UniversalValveToolbox {
|
|||||||
public FormProjects() {
|
public FormProjects() {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
model = new FormProjectViewModel(dataProvider.Projects, dataProvider.Engines.Where(engine => SteamPathsUtil.GetSteamAppDataById(engine.Appid) != null).ToArray());
|
model = new FormProjectViewModel(dataProvider.Projects, dataProvider.Engines.Where(engine => isAppInstalled(engine.Appid)).ToArray());
|
||||||
|
|
||||||
UpdateComboBoxProject();
|
UpdateComboBoxProject();
|
||||||
UpdateComboBoxEngine();
|
UpdateComboBoxEngine();
|
||||||
@ -34,6 +35,11 @@ namespace UniversalValveToolbox {
|
|||||||
comboBoxEngine.Bind(a => a.SelectedIndex, model, a => a.SelectEngineIndex);
|
comboBoxEngine.Bind(a => a.SelectedIndex, model, a => a.SelectEngineIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool isAppInstalled(int appId) {
|
||||||
|
var isInstall = SteamApps.IsAppInstalled(appId);
|
||||||
|
return isInstall;
|
||||||
|
}
|
||||||
|
|
||||||
private void Model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) {
|
private void Model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) {
|
||||||
UpdateComboBoxEngine();
|
UpdateComboBoxEngine();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using EpicMorg.SteamPathsLib;
|
using Steamworks;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ namespace UniversalValveToolbox.Utils {
|
|||||||
if (pathProject == null || pathProject.Length == 0)
|
if (pathProject == null || pathProject.Length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var SFMpath = SteamPathsUtil.GetSteamAppManifestDataById(1840)?.Path;
|
var SFMpath = SteamApps.AppInstallDir(1840);
|
||||||
|
|
||||||
if (SFMpath == null)
|
if (SFMpath == null)
|
||||||
return;
|
return;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using EpicMorg.SteamPathsLib;
|
using Steamworks;
|
||||||
|
using System.Diagnostics;
|
||||||
using UniversalValveToolbox.Model.ViewModel;
|
using UniversalValveToolbox.Model.ViewModel;
|
||||||
|
|
||||||
namespace UniversalValveToolbox.Utils {
|
namespace UniversalValveToolbox.Utils {
|
||||||
@ -6,8 +7,9 @@ namespace UniversalValveToolbox.Utils {
|
|||||||
public static SteamDataViewModel SteamData {
|
public static SteamDataViewModel SteamData {
|
||||||
get {
|
get {
|
||||||
var result = new SteamDataViewModel();
|
var result = new SteamDataViewModel();
|
||||||
result.SteamPid = SteamPathsUtil.GetActiveProcessSteamData()?.PID ?? 0;
|
|
||||||
result.UserNameSteam = SteamPathsUtil.GetSteamData()?.LastGameNameUsed ?? null;
|
result.SteamPid = Process.GetProcessesByName("steam")[0]?.Id ?? 0;
|
||||||
|
result.UserNameSteam = SteamClient.Name ?? null;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user