private bool RestartAppIfNecessaryImpl(uint appid) { // Write the Steam AppID to a local file if not dropped by the other method. SteamAppId.WriteToDirectory(_applicationFolder, (int)appid); _restartAppIfNecessaryHook.OriginalFunction(appid); return(false); }
public RichPresenceConverter(ulong rpcClientId, ulong steamUserId, SteamAppId appId = SteamAppId.TF2, bool autoStart = true, string imageKey = null, string imageText = null) { Client = new DiscordRpcClient(rpcClientId.ToString(), autoEvents: true); _steamId = new CSteamID(steamUserId); _appId = appId; _autoStart = autoStart; _timer = new Timer { AutoReset = true, Enabled = false, Interval = 1000 }; _imageKey = imageKey; _imageText = imageText; }
private void DropSteamAppId(Logger logger) { try { var manager = new SteamAppsManager(); foreach (var app in manager.SteamApps) { if (!_applicationFolder.Contains(app.InstallDir)) { continue; } logger.SteamWriteLineAsync($"Found Steam Library Entry with Id {app.AppID}. Dropping {SteamAppId.FileName}.", logger.ColorSuccess); SteamAppId.WriteToDirectory(_applicationFolder, app.AppID); return; } logger.SteamWriteLineAsync($"Application not found in any Steam library. Recommend dropping a {SteamAppId.FileName} yourself.", logger.ColorError); } catch (Exception e) { logger.SteamWriteLineAsync($"Failed to scan through Steam games and locate current game. Error: {e.Message}, {e.StackTrace}", logger.ColorError); } }
/// <summary> /// Reads the mod directories from the XComEngine.ini file. /// </summary> /// <returns>List of mod directories. NULL if the ini file is missing or couldn't be accessed.</returns> public IEnumerable <string> DetectModDirs() { // Prevent stack overflow (Issue #19) if (_gameDir == null) { return(new string[0]); } List <string> currentModDirs; var validModDirs = new List <string>(); try { currentModDirs = GetConfigFile("Engine").Get("Engine.DownloadableContentEnumerator", "ModRootDirs") ?? new List <string>(); } catch (IOException ex) { Log.Warn("Unable to access 'XComEngine.ini'", ex); return(null); } catch (UnauthorizedAccessException ex) { Log.Warn("Unable to access 'XComEngine.ini'", ex); return(null); } // Add default Steam Workshop mod path if it is missing. var appId = SteamAppId.ToString(); if (!currentModDirs.Any(dir => dir.EndsWith(appId) || dir.EndsWith(appId + "\\"))) { var workShopModPath = Path.GetFullPath(Path.Combine(_gameDir, "../..", "workshop", "content", appId)); currentModDirs.Add(workShopModPath); Log.Info("Added default Steam Workshop mod directory: " + workShopModPath); } foreach (var modDir in currentModDirs) { try { string dir; if (Path.IsPathRooted(modDir)) { // make sure all directories end with '\' (can only happen if someone adds a dir manually?) dir = modDir.EndsWith(@"\") ? modDir : modDir + @"\"; } else { dir = Path.GetFullPath(Path.Combine(GameDir, "bin", "Win64", modDir)); Log.Debug($"Changed non rooted mod directory from '{modDir}' to '{dir}'"); } if (Directory.Exists(dir)) { validModDirs.Add(dir); } } catch (ArgumentException ex) { Log.Error($"Invalid mod directory '{modDir}'", ex); } } return(validModDirs); }
public override int GetHashCode() => SteamAppId.GetHashCode();