public void Initialize() { SubscribeToEvents(); if (!Client.Initialize()) { Log?.Invoke($"Could not initialize a Discord IPC connection with application ID {Client.ApplicationID}.", "RPC", LogLevel.Critical); } Log?.Invoke("Initialized.", "RPC", LogLevel.Info); try { File.WriteAllText("steam_appid.txt", _appId.ToString("D")); } catch (Exception ex) { Log?.Invoke($"Could not write out game app ID to file: {ex.Message}", "Steamworks", LogLevel.Critical); } if (!SteamAPI.Init()) { Log?.Invoke($"Could not initialize a Steamworks connection for app ID {_appId:D}.", "Steamworks", LogLevel.Critical); } Log?.Invoke("Initialized.", "Steamworks", LogLevel.Info); }
/// <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); }