mirror of
https://github.com/EpicMorg/UniversalValveToolbox.git
synced 2024-12-26 06:35:29 +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 UniversalValveToolbox.Model.Provider;
|
||||
using UniversalValveToolbox.Utils;
|
||||
@ -10,6 +11,8 @@ namespace UniversalValveToolbox {
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main() {
|
||||
SteamClient.Init(480);
|
||||
|
||||
var dataProvide = new DataProvider();
|
||||
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 assemblyGameloopVdf = System.Reflection.Assembly.LoadFrom("Gameloop.Vdf.dll");
|
||||
System.Reflection.Assembly assemblyNewtonsoftJson = System.Reflection.Assembly.LoadFrom("Newtonsoft.Json.dll");
|
||||
|
||||
Version verEpicMorgSteamPathsLib = assemblyEpicMorgSteamPathsLib.GetName().Version;
|
||||
Version verFacepunchSteamworksWin32 = assemblyFacepunchSteamworksWin32.GetName().Version;
|
||||
Version verkasthackbindingwf = assemblykasthackbindingwf.GetName().Version;
|
||||
|
@ -9,7 +9,7 @@ using System.Collections.Generic;
|
||||
using UniversalValveToolbox.Utils;
|
||||
using System.Globalization;
|
||||
using System.Collections;
|
||||
using EpicMorg.SteamPathsLib;
|
||||
using Steamworks;
|
||||
|
||||
namespace UniversalValveToolbox {
|
||||
public partial class FormAddons : Form {
|
||||
@ -30,7 +30,7 @@ namespace UniversalValveToolbox {
|
||||
.Cast<DictionaryEntry>()
|
||||
.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();
|
||||
UpdateAddonCategoryComboBox();
|
||||
@ -106,6 +106,11 @@ namespace UniversalValveToolbox {
|
||||
}
|
||||
}
|
||||
|
||||
private bool isSteamAppInstall(int appId) {
|
||||
var isInstall = SteamApps.IsAppInstalled(appId);
|
||||
return isInstall;
|
||||
}
|
||||
|
||||
private void UpdateAddonCategoryComboBox() {
|
||||
comboBoxCategory.Items.Clear();
|
||||
comboBoxCategory.Items.AddRange(model.Categories.Select(c => c.Value).ToArray());
|
||||
|
@ -1,4 +1,4 @@
|
||||
using EpicMorg.SteamPathsLib;
|
||||
using Steamworks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@ -167,10 +167,9 @@ namespace UniversalValveToolbox {
|
||||
private void UpdateEngineList() {
|
||||
var dataProvider = new DataProvider();
|
||||
Engines = dataProvider.Engines.Where(engine => {
|
||||
var engineAppData = SteamPathsUtil.GetSteamAppDataById(engine.Appid);
|
||||
|
||||
return engineAppData != null && engineAppData.Installed;
|
||||
}).ToArray();
|
||||
var isInstall = SteamApps.IsAppInstalled(engine.Appid);
|
||||
return isInstall;
|
||||
}).ToArray();
|
||||
|
||||
if (Engines != null && Engines.Length != 0) {
|
||||
comboBoxEngine.Enabled = true;
|
||||
@ -222,7 +221,7 @@ namespace UniversalValveToolbox {
|
||||
if (SelectedEngine == null)
|
||||
return;
|
||||
|
||||
var pathSelectedEngine = SteamPathsUtil.GetSteamAppManifestDataById(SelectedEngine.Appid)?.Path;
|
||||
var pathSelectedEngine = SteamApps.AppInstallDir(SelectedEngine.Appid);
|
||||
|
||||
if (pathSelectedEngine != null) {
|
||||
var pairPathIconTools = SelectedEngine.Tools
|
||||
@ -260,20 +259,16 @@ namespace UniversalValveToolbox {
|
||||
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);
|
||||
|
||||
if (engineData != null && isAvailableProjectBySelectEngine) {
|
||||
var enginePath = engineData.Path;
|
||||
if (enginePath != null && isAvailableProjectBySelectEngine) {
|
||||
var iconPathEngine = Path.Combine(enginePath, SelectedEngine.Bin);
|
||||
|
||||
if (enginePath != null) {
|
||||
var iconPathEngine = Path.Combine(enginePath, SelectedEngine.Bin);
|
||||
var runProjectListViewItem = new ListViewItem(Properties.translations.MenuItems.itmRunProject, iconPathEngine, listViewGroupTools);
|
||||
runProjectListViewItem.Tag = RUN_PROJECT_ID;
|
||||
|
||||
var runProjectListViewItem = new ListViewItem(Properties.translations.MenuItems.itmRunProject, iconPathEngine, listViewGroupTools);
|
||||
runProjectListViewItem.Tag = RUN_PROJECT_ID;
|
||||
|
||||
listView.Items.Add(runProjectListViewItem);
|
||||
}
|
||||
listView.Items.Add(runProjectListViewItem);
|
||||
}
|
||||
}
|
||||
|
||||
@ -289,7 +284,7 @@ namespace UniversalValveToolbox {
|
||||
if (SelectedEngine == null)
|
||||
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));
|
||||
|
||||
|
||||
@ -374,15 +369,15 @@ namespace UniversalValveToolbox {
|
||||
|
||||
if (selectItem.Group == listViewGroupTools) {
|
||||
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}");
|
||||
}
|
||||
|
||||
var selectedTool = SelectedEngine.Tools.FirstOrDefault(tool => tool.Name == selectItemText);
|
||||
if (selectedTool != null) {
|
||||
var selectedEnginePath = SteamPathsUtil.GetSteamAppManifestDataById(SelectedEngine.Appid)?.Path;
|
||||
var selectedEnginePath = SteamApps.AppInstallDir(SelectedEngine.Appid);
|
||||
|
||||
if (selectedEnginePath != null) {
|
||||
var toolPath = Path.Combine(selectedEnginePath, selectedTool.Bin);
|
||||
@ -394,7 +389,15 @@ namespace UniversalValveToolbox {
|
||||
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
|
||||
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 Steamworks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -21,7 +22,7 @@ namespace UniversalValveToolbox {
|
||||
public FormProjects() {
|
||||
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();
|
||||
UpdateComboBoxEngine();
|
||||
@ -34,6 +35,11 @@ namespace UniversalValveToolbox {
|
||||
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) {
|
||||
UpdateComboBoxEngine();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
using EpicMorg.SteamPathsLib;
|
||||
using Steamworks;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
@ -28,7 +28,7 @@ namespace UniversalValveToolbox.Utils {
|
||||
if (pathProject == null || pathProject.Length == 0)
|
||||
return;
|
||||
|
||||
var SFMpath = SteamPathsUtil.GetSteamAppManifestDataById(1840)?.Path;
|
||||
var SFMpath = SteamApps.AppInstallDir(1840);
|
||||
|
||||
if (SFMpath == null)
|
||||
return;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using EpicMorg.SteamPathsLib;
|
||||
using Steamworks;
|
||||
using System.Diagnostics;
|
||||
using UniversalValveToolbox.Model.ViewModel;
|
||||
|
||||
namespace UniversalValveToolbox.Utils {
|
||||
@ -6,8 +7,9 @@ namespace UniversalValveToolbox.Utils {
|
||||
public static SteamDataViewModel SteamData {
|
||||
get {
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user