steam api init fix
This commit is contained in:
STAM 2022-04-15 21:03:43 +03:00
parent 4cde1acd9a
commit 70d8205e2b
Signed by: stam
GPG Key ID: E149C3760CFA3C7E
2 changed files with 44 additions and 7 deletions

View File

@ -1,5 +1,7 @@
using Steamworks; using Microsoft.Win32;
using Steamworks;
using System; using System;
using System.Diagnostics;
using System.Windows.Forms; using System.Windows.Forms;
using UniversalValveToolbox.Model.Provider; using UniversalValveToolbox.Model.Provider;
using UniversalValveToolbox.Utils; using UniversalValveToolbox.Utils;
@ -14,12 +16,47 @@ namespace UniversalValveToolbox {
var dataProvide = new DataProvider(); var dataProvide = new DataProvider();
var currSettings = dataProvide.Settings; var currSettings = dataProvide.Settings;
LanguageManager.UpdateLanguage(currSettings.Language);
SteamClient.Init(currSettings.ToolsAppId);
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
LanguageManager.UpdateLanguage(currSettings.Language);
try { SteamClient.Init(currSettings.ToolsAppId); }
catch (Exception ex) {
DialogResult result = MessageBox.Show(@"Some error was occurred when trying to init Steam API:" + Environment.NewLine +
"---------------------------------------------------------------------------" + Environment.NewLine +
ex.Message + Environment.NewLine +
"---------------------------------------------------------------------------" + Environment.NewLine +
"Try to launch Steam?",
"Error!", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
if (result == DialogResult.Yes)
{
try {
string steamPATH = "";
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Valve\Steam");
steamPATH = key.GetValue("SteamExe").ToString();
Process.Start(steamPATH);
key.Close();
}
catch (Exception exs) {
MessageBox.Show(@"Sorry. Steam launch failed because:" + Environment.NewLine +
"---------------------------------------------------------------------------" + Environment.NewLine +
exs.Message + Environment.NewLine +
"---------------------------------------------------------------------------" + Environment.NewLine +
"Application will be terminated.",
"Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
}
else
{
MessageBox.Show("Application will be terminated.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Application.Exit();
}
}
Application.Run(new FormMain()); Application.Run(new FormMain());
} }
} }

View File

@ -33,5 +33,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.3")] [assembly: AssemblyVersion("1.0.0.4")]
[assembly: AssemblyFileVersion("1.0.0.3")] [assembly: AssemblyFileVersion("1.0.0.4")]