public override void RunGame(string gameDir, string args) { Log.Info("Starting XCOM Chimera Squad"); if (!SteamAPIWrapper.Init()) { MessageBox.Show("Could not connect to steam.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } var p = new Process { StartInfo = { Arguments = args, FileName = gameDir + @"\Binaries\Win64\xcom.exe", WorkingDirectory = gameDir } }; try { p.Start(); } catch (Win32Exception ex) { Log.Warn("Failed to start game process", ex); MessageBox.Show("An error occured while trying to run the game. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } SteamAPIWrapper.Shutdown(); }
public static void Unsubscribe(ulong id) { SteamAPIWrapper.Init(); SteamUGC.UnsubscribeItem(id.ToPublishedFileID()); SteamAPIWrapper.RunCallbacks(); }
/// <summary> /// Runs War of the Chosen with the selected arguments /// </summary> /// <param name="gameDir"></param> /// <param name="args"></param> public static void RunWotC(string gameDir, string args) { Log.Info("Starting WotC"); if (!SteamAPIWrapper.Init()) { MessageBox.Show("Could not connect to steam.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } var p = new Process { StartInfo = { Arguments = args, FileName = gameDir + @"\XCom2-WarOfTheChosen\Binaries\Win64\XCom2.exe", WorkingDirectory = gameDir + @"\XCom2-WarOfTheChosen" } }; try { p.Start(); } catch (Win32Exception ex) { Log.Warn("Failed to start game process", ex); MessageBox.Show("An error occured while trying to run the game. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } SteamAPIWrapper.Shutdown(); }
public MainForm(Settings settings) { InitializeComponent(); appRestartPendingLabel.Visible = false; // Settings SteamAPIWrapper.Init(); Settings = settings; // Restore states showHiddenModsToolStripMenuItem.Checked = settings.ShowHiddenElements; // Hide WotC and Challenge Mode buttons if necessary if (settings.GamePath != "") { var wotcAvailable = Directory.Exists(settings.GamePath + @"\XCom2-WarOfTheChosen"); runWarOfTheChosenToolStripMenuItem.Visible = wotcAvailable; runChallengeModeToolStripMenuItem.Visible = wotcAvailable; importFromWotCToolStripMenuItem.Visible = wotcAvailable; } // Init interface InitObjectListView(); UpdateInterface(); RegisterEvents(); //Other intialization InitializeTabImages(); // Init the argument checkboxes UpdateQuickArgumentsMenu(); #if !DEBUG // Check for Updates CheckSteamForUpdates(); #endif // Run callbacks var t1 = new Timer(); t1.Tick += (sender, e) => { SteamAPIWrapper.RunCallbacks(); }; t1.Interval = 10; t1.Start(); // Check for running downloads #if DEBUG if (Settings.GetWorkshopPath() != null) { CheckSteamForNewMods(); var t2 = new Timer(); t2.Tick += (sender, e) => { CheckSteamForNewMods(); }; t2.Interval = 30000; t2.Start(); } #endif }
public const int MAX_UGC_RESULTS = 50; // according to public static ulong[] GetSubscribedItems() { SteamAPIWrapper.Init(); var num = SteamUGC.GetNumSubscribedItems(); var ids = new PublishedFileId_t[num]; SteamUGC.GetSubscribedItems(ids, num); return ids.Select(t => t.m_PublishedFileId).ToArray(); }
public ItemDetailsRequest Send() { SteamAPIWrapper.Init(); _onQueryCompleted = CallResult <SteamUGCQueryCompleted_t> .Create(QueryCompleted); _queryHandle = SteamUGC.CreateQueryUGCDetailsRequest(new[] { ID.ToPublishedFileID() }, 1); var apiCall = SteamUGC.SendQueryUGCRequest(_queryHandle); _onQueryCompleted.Set(apiCall); return(this); }
public static UpdateInfo GetDownloadInfo(ulong id) { SteamAPIWrapper.Init(); ulong punBytesProcessed; ulong punBytesTotal; SteamUGC.GetItemDownloadInfo(new PublishedFileId_t(id), out punBytesProcessed, out punBytesTotal); return(new UpdateInfo { ItemID = id, BytesProcessed = punBytesProcessed, BytesTotal = punBytesTotal }); }
public static InstallInfo GetInstallInfo(ulong id) { SteamAPIWrapper.Init(); ulong punSizeOnDisk; string pchFolder; uint punTimeStamp; SteamUGC.GetItemInstallInfo(new PublishedFileId_t(id), out punSizeOnDisk, out pchFolder, 256, out punTimeStamp); return(new InstallInfo { ItemID = id, SizeOnDisk = punSizeOnDisk, Folder = pchFolder, TimeStamp = new DateTime(punTimeStamp * 10) }); }
public ItemDetailsRequest Send() { SteamAPIWrapper.Init(); PublishedFileId_t[] idList = Identifiers.ConvertAll(id => new PublishedFileId_t(id)).ToArray(); _onQueryCompleted = CallResult <SteamUGCQueryCompleted_t> .Create(QueryCompleted); _queryHandle = SteamUGC.CreateQueryUGCDetailsRequest(idList, (uint)idList.Length); SteamUGC.SetReturnLongDescription(_queryHandle, GetFullDescription); SteamUGC.SetReturnChildren(_queryHandle, true); // required, otherwise m_unNumChildren will always be 0 var apiCall = SteamUGC.SendQueryUGCRequest(_queryHandle); _onQueryCompleted.Set(apiCall); return(this); }
/// <summary> /// Runs War of the Chosen with the selected arguments /// </summary> /// <param name="gameDir"></param> /// <param name="args"></param> public static void RunWotC(string gameDir, string args) { if (!SteamAPIWrapper.Init()) { MessageBox.Show("Could not connect to steam."); } var p = new Process { StartInfo = { Arguments = args, FileName = gameDir + @"\XCom2-WarOfTheChosen\Binaries\Win64\XCom2.exe", WorkingDirectory = gameDir + @"\XCom2-WarOfTheChosen" } }; p.Start(); SteamAPIWrapper.Shutdown(); }
public QueryUGCChildren Send() { if (DependencyCount == 0) { return(this); } SteamAPIWrapper.Init(); _onQueryCompleted = CallResult <SteamUGCQueryCompleted_t> .Create(QueryCompleted); _queryHandle = SteamUGC.CreateQueryUGCDetailsRequest(new[] { Id.ToPublishedFileID() }, 1); //SteamUGC.SetReturnLongDescription(_queryHandle, GetFullDescription); SteamUGC.SetReturnChildren(_queryHandle, true); var apiCall = SteamUGC.SendQueryUGCRequest(_queryHandle); _onQueryCompleted.Set(apiCall); return(this); }
/// <summary> /// Runs the game with the selected arguments /// </summary> /// <param name="gameDir"></param> /// <param name="args"></param> public static void RunGame(string gameDir, string args) { Log.Info("Starting XCOM 2 (vanilla)"); if (!SteamAPIWrapper.Init()) { MessageBox.Show("Could not connect to steam."); } var p = new Process { StartInfo = { Arguments = args, FileName = gameDir + @"\Binaries\Win64\XCom2.exe", WorkingDirectory = gameDir } }; p.Start(); SteamAPIWrapper.Shutdown(); }
public static void Subscribe(ulong id) { SteamAPIWrapper.Init(); SteamUGC.SubscribeItem(id.ToPublishedFileID()); }
public static EItemState GetDownloadStatus(ulong id) { SteamAPIWrapper.Init(); return((EItemState)SteamUGC.GetItemState(new PublishedFileId_t(id))); }
public MainForm(Settings settings) { InitializeComponent(); appRestartPendingLabel.Visible = false; aboutToolStripMenuItem.DropDownDirection = ToolStripDropDownDirection.BelowLeft; // Settings SteamAPIWrapper.Init(); Settings = settings; // Restore states showHiddenModsToolStripMenuItem.Checked = settings.ShowHiddenElements; cShowStateFilter.Checked = settings.ShowStateFilter; cEnableGrouping.Checked = settings.ShowModListGroups; cShowPrimaryDuplicates.Checked = Settings.ShowPrimaryDuplicateAsDependency; cShowPrimaryDuplicates.Visible = Settings.EnableDuplicateModIdWorkaround; modlist_ListObjectListView.UseTranslucentSelection = Settings.UseTranslucentModListSelection; olvRequiredMods.UseTranslucentSelection = Settings.UseTranslucentModListSelection; olvDependentMods.UseTranslucentSelection = Settings.UseTranslucentModListSelection; // Set visibility of some controls depending on game type var wotcAvailable = Directory.Exists(settings.GamePath + @"\XCom2-WarOfTheChosen"); runXCOM2ToolStripMenuItem.Visible = Program.XEnv.Game == GameId.X2; runWarOfTheChosenToolStripMenuItem.Visible = wotcAvailable && Program.XEnv.Game == GameId.X2; runChallengeModeToolStripMenuItem.Visible = wotcAvailable && Program.XEnv.Game == GameId.X2; importFromWotCToolStripMenuItem.Visible = wotcAvailable && Program.XEnv.Game == GameId.X2; importFromXCOM2ToolStripMenuItem.Visible = Program.XEnv.Game == GameId.X2; runChimeraSquadToolStripMenuItem.Visible = Program.XEnv.Game == GameId.ChimeraSquad; importFromChimeraSquadToolStripMenuItem.Visible = Program.XEnv.Game == GameId.ChimeraSquad; if (Program.XEnv.Game != GameId.X2) { modlist_ListObjectListView.AllColumns.Remove(olvForWOTC); modlist_ListObjectListView.RebuildColumns(); olvDependentMods.AllColumns.Remove(olvColDepModsWotc); olvDependentMods.RebuildColumns(); olvRequiredMods.AllColumns.Remove(olvColReqModsWotc); olvRequiredMods.RebuildColumns(); } // If game path is not configured, hide several function/options. if (string.IsNullOrEmpty(settings.GamePath)) { runWarOfTheChosenToolStripMenuItem.Enabled = false; runChallengeModeToolStripMenuItem.Enabled = false; importFromWotCToolStripMenuItem.Enabled = false; importFromXCOM2ToolStripMenuItem.Enabled = false; importFromChimeraSquadToolStripMenuItem.Enabled = false; } // Init interface InitModListView(); InitDependencyListViews(); UpdateInterface(); RegisterEvents(); // Other intialization InitializeTabImages(); // Init the argument checkboxes InitQuickArgumentsMenu(settings); #if !DEBUG // Update mod information var mods = Settings.Mods.All.ToList(); UpdateMods(mods, () => { modlist_ListObjectListView.RefreshObjects(mods); }); #endif // Run callbacks var t1 = new Timer(); t1.Tick += (sender, e) => { SteamAPIWrapper.RunCallbacks(); }; t1.Interval = 10; t1.Start(); /* * // Check for running downloads #if DEBUG * if (Settings.GetWorkshopPath() != null) * { * CheckSteamForNewMods(); * * var t2 = new Timer(); * t2.Tick += (sender, e) => { CheckSteamForNewMods(); }; * t2.Interval = 30000; * t2.Start(); * } #endif */ }
private void Awake() { // Only one instance of SteamManager at a time! if (s_instance != null) { //Destroy(gameObject); return; } s_instance = this; if (s_EverInialized) { // This is almost always an error. // The most common case where this happens is the SteamManager getting desstroyed via Application.Quit() and having some code in some OnDestroy which gets called afterwards, creating a new SteamManager. throw new System.Exception("Tried to Initialize the SteamAPI twice in one session!"); } // We want our SteamManager Instance to persist across scenes. //DontDestroyOnLoad(gameObject); if (!Packsize.Test()) { Debug.Fail("[Steamworks.NET] Packsize Test returned false, the wrong version of Steamworks.NET is being run in this platform."); } if (!DllCheck.Test()) { Debug.Fail("[Steamworks.NET] DllCheck Test returned false, One or more of the Steamworks binaries seems to be the wrong version."); } try { // If Steam is not running or the game wasn't started through Steam, SteamAPI_RestartAppIfNecessary starts the // Steam client and also launches this game again if the User owns it. This can act as a rudimentary form of DRM. // Once you get a Steam AppID assigned by Valve, you need to replace AppId_t.Invalid with it and // remove steam_appid.txt from the game depot. eg: "(AppId_t)480" or "new AppId_t(480)". // See the Valve documentation for more information: https://partner.steamgames.com/documentation/drm#FAQ if (SteamAPIWrapper.RestartAppIfNecessary(AppId_t.Invalid)) { System.Windows.Forms.Application.Exit(); return; } } catch (System.DllNotFoundException e) { // We catch this exception here, as it will be the first occurence of it. Debug.Fail("[Steamworks.NET] Could not load [lib]steam_api.dll/so/dylib. It's likely not in the correct location. Refer to the README for more details.\n" + e); System.Windows.Forms.Application.Exit(); return; } // Initialize the SteamAPI, if Init() returns false this can happen for many reasons. // Some examples include: // Steam Client is not running. // Launching from outside of steam without a steam_appid.txt file in place. // Running under a different OS User or Access level (for example running "as administrator") // Valve's documentation for this is located here: // https://partner.steamgames.com/documentation/getting_started // https://partner.steamgames.com/documentation/example // Under: Common Build Problems // https://partner.steamgames.com/documentation/bootstrap_stats // At the very bottom // If you're running into Init issues try running DbgView prior to launching to get the internal output from Steam. // http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx m_bInitialized = SteamAPIWrapper.Init(); if (!m_bInitialized) { Debug.Fail("[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information."); return; } s_EverInialized = true; }
public void Send() { SteamAPIWrapper.Init(); SteamUGC.DownloadItem(new PublishedFileId_t(_id), true); }
public MainForm(Settings settings) { InitializeComponent(); appRestartPendingLabel.Visible = false; progress_toolstrip_progressbar.Visible = false; aboutToolStripMenuItem.DropDownDirection = ToolStripDropDownDirection.BelowLeft; // Settings SteamAPIWrapper.Init(); Settings = settings; // Restore states InitMainGui(settings); // Init interface InitModListView(); InitDependencyListViews(); UpdateInterface(); RegisterEvents(); // Other intialization InitializeTabImages(); // Init the argument checkboxes InitQuickArgumentsMenu(settings); #if !DEBUG // Update mod information var mods = Settings.Mods.All.ToList(); if (settings.OnlyUpdateEnabledOrNewModsOnStartup) { mods = mods.Where(mod => mod.isActive || mod.State.HasFlag(ModState.New)).ToList(); } UpdateMods(mods, () => { modlist_ListObjectListView.RefreshObjects(mods); }); #endif // Run callbacks var t1 = new Timer(); t1.Tick += (sender, e) => { SteamAPIWrapper.RunCallbacks(); }; t1.Interval = 10; t1.Start(); /* * // Check for running downloads #if DEBUG * if (Settings.GetWorkshopPath() != null) * { * CheckSteamForNewMods(); * * var t2 = new Timer(); * t2.Tick += (sender, e) => { CheckSteamForNewMods(); }; * t2.Interval = 30000; * t2.Start(); * } #endif */ }
private static void Main() { if (!IsDebugBuild) { // Capture all unhandled Exceptions AppDomain.CurrentDomain.UnhandledException += (sender, args) => HandleUnhandledException(args.ExceptionObject as Exception, "UnhandledException"); Application.ThreadException += (sender, args) => HandleUnhandledException(args.Exception, "ThreadException"); } // Mutex is used to check if another instance of AML is already running Mutex mutex = new Mutex(true, "E3241D27-3DD8-4615-888A-502252B9E2A1", out var isFirstInstance); IDisposable sentrySdkInstance = null; try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); InitAppSettings(); sentrySdkInstance = InitSentry(); if (!CheckDotNet4_7_2()) { Log.Warn(".NET Framework v4.7.2 required"); var result = MessageBox.Show("This program requires Microsoft .NET Framework v4.7.2 or newer. Do you want to open the download page now?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (result == DialogResult.Yes) { Tools.StartProcess("https://dotnet.microsoft.com/download/dotnet-framework"); } return; } if (!SteamAPIWrapper.Init()) { Log.Warn("Failed to detect Steam"); StringBuilder message = new StringBuilder(); message.AppendLine("Please make sure that:"); message.AppendLine("- Steam is running"); message.AppendLine("- the file steam_appid.txt exists in the AML folder"); message.AppendLine("- neither (or both) of Steam and AML are running\n with admin privileges"); MessageBox.Show(message.ToString(), "Error - unable to detect Steam!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // Load settings var settings = InitializeSettings(); if (settings == null) { Log.Error("Failed to initialize settings"); return; } // Exit if another instance of AML is already running and multiple instances are disabled. if (!settings.AllowMultipleInstances && !isFirstInstance) { MessageBox.Show("Another instance of AML is already running.", "AML already started", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // Check for update if (!IsDebugBuild && settings.CheckForUpdates) { CheckForUpdate(); } // clean up old files if (File.Exists(Program.XEnv.DefaultConfigDir + @"\DefaultModOptions.ini.bak")) { // Restore backup File.Copy(Program.XEnv.DefaultConfigDir + @"\DefaultModOptions.ini.bak", Program.XEnv.DefaultConfigDir + @"\DefaultModOptions.ini", true); File.Delete(Program.XEnv.DefaultConfigDir + @"\DefaultModOptions.ini.bak"); } Application.Run(new MainForm(settings)); SteamAPIWrapper.Shutdown(); } finally { Log.Info("Shutting down..."); sentrySdkInstance?.Dispose(); GlobalSettings.Instance.Save(); GC.KeepAlive(mutex); // prevent the mutex from being garbage collected early mutex.Dispose(); } }
private static void Main() { #if !DEBUG try { #endif Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!CheckDotNet4_6() && MessageBox.Show("This program requires .NET v4.6 or newer.\r\nDo you want to install it now?", "Error", MessageBoxButtons.YesNo) == DialogResult.Yes) { Process.Start(@"https://www.microsoft.com/de-de/download/details.aspx?id=49981"); } if (!SteamAPIWrapper.Init()) { MessageBox.Show("Please start steam first!"); return; } // SteamWorkshop.StartCallbackService(); // Load settings var settings = InitializeSettings(); if (settings == null) { return; } #if !DEBUG // Check for update if (settings.CheckForUpdates) { try { using (var client = new System.Net.WebClient()) { client.Headers.Add("User-Agent: Other"); var json = client.DownloadString("https://api.github.com/repos/aEnigmatic/xcom2-launcher/releases/latest"); var release = Newtonsoft.Json.JsonConvert.DeserializeObject <GitHub.Release>(json); var currentVersion = GetCurrentVersion(); if (currentVersion != release.tag_name) { // New version available new UpdateAvailableDialog(release, currentVersion).ShowDialog(); } } } catch (System.Net.WebException) { // No internet? } } #endif // clean up old files if (File.Exists(XCOM2.DefaultConfigDir + @"\DefaultModOptions.ini.bak")) { // Restore backup File.Copy(XCOM2.DefaultConfigDir + @"\DefaultModOptions.ini.bak", XCOM2.DefaultConfigDir + @"\DefaultModOptions.ini", true); File.Delete(XCOM2.DefaultConfigDir + @"\DefaultModOptions.ini.bak"); } Application.Run(new MainForm(settings)); SteamAPIWrapper.Shutdown(); #if !DEBUG } catch (Exception e) { MessageBox.Show("An exception occured. See error.log for additional details."); File.WriteAllText("error.log", e.Message + "\r\nStack:\r\n" + e.StackTrace); } #endif }
private static void Main() { #if !DEBUG try { #endif Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!CheckDotNet4_6()) { var result = MessageBox.Show("This program requires Microsoft .NET Framework v4.6 or newer. Do you want to open the download page now?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (result == DialogResult.Yes) { Process.Start("https://www.microsoft.com/en-us/download/details.aspx?id=56115"); } return; } if (!SteamAPIWrapper.Init()) { MessageBox.Show("Please start steam first!"); return; } // SteamWorkshop.StartCallbackService(); // Load settings var settings = InitializeSettings(); if (settings == null) { return; } #if !DEBUG // Check for update if (settings.CheckForUpdates) { CheckForUpdate(); } #endif // clean up old files if (File.Exists(XCOM2.DefaultConfigDir + @"\DefaultModOptions.ini.bak")) { // Restore backup File.Copy(XCOM2.DefaultConfigDir + @"\DefaultModOptions.ini.bak", XCOM2.DefaultConfigDir + @"\DefaultModOptions.ini", true); File.Delete(XCOM2.DefaultConfigDir + @"\DefaultModOptions.ini.bak"); } Application.Run(new MainForm(settings)); SteamAPIWrapper.Shutdown(); #if !DEBUG } catch (Exception e) { MessageBox.Show("An exception occured. See error.log for additional details."); File.WriteAllText("error.log", e.Message + "\r\nStack:\r\n" + e.StackTrace); } #endif }