/// <summary> /// Entry point called from Doorstop /// </summary> /// <param name="args">First argument is the path of the currently executing process.</param> public static void Main(string[] args) { _paths = Paths.Create(); _logger = new Logger(PathExtensions.Combine(_paths.LogsPath, "PatchLoader.log")); _paths.WorkshopModsPath = GetWorkshopModsPath(_paths.WorkingPath, _logger); _logger.Info("Detected paths:\n" + _paths); if (_paths.DisableMods) { _logger.Info("******** Mods loading disabled via --disableMods commandline argument. Further execution aborted ********"); return; } if (_paths.SkipWorkshop) { _logger.Info("******** Workshop mods loading disabled via --noWorkshop commandline argument. Processing workshop mods directories will be skipped ********"); } try { AppDomain.CurrentDomain.TypeResolve += AssemblyResolver; AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolver; new InternalLoader(_logger, _paths) .Run(); } catch (Exception e) { _logger.Exception(e); } finally { AppDomain.CurrentDomain.AssemblyResolve -= AssemblyResolver; AppDomain.CurrentDomain.TypeResolve -= AssemblyResolver; } }
//TODO: maybe move into DoorstopManager, but cleanly private void SaveOrUpdateWorkshopPath() { if (_pluginInfo.publishedFileID == PublishedFileId.invalid) { _logger.Info("Mod not in workshop folder. Cannot detect workshop directory path. Config not saved."); return; //not a mod from the workshop folder, so we can give up here. } var workshopPath = Directory.GetParent(PlatformService.workshop.GetSubscribedItemPath(_pluginInfo.publishedFileID)).FullName; if (File.Exists(_patchLoaderConfigFilePath)) { var config = _configManager.Load(); if (config.WorkshopPath != workshopPath) { config.WorkshopPath = workshopPath; _configManager.Save(config); } } else { var config = new Config() { WorkshopPath = workshopPath }; _configManager.Save(config); } }
public void Install() { if (!File.Exists(LoaderFileName)) { InstallLoader(); } if (!File.Exists(_configFileName)) { InstallConfigFile(); } RuntimePlatform platform = Application.platform; if (File.Exists(_configFileName) && platform != RuntimePlatform.WindowsPlayer && platform != RuntimePlatform.WindowsEditor) { if (platform == RuntimePlatform.LinuxPlayer) { (this as LinuxDoorstopManager)?.GrantExecuteAccessForConfig(); RequiresRestart = true; } else if (platform == RuntimePlatform.OSXPlayer) { (this as MacOSDoorstopManager)?.GrantExecuteAccessForConfig(); } } else { RequiresRestart = true; } _logger.Info("Doorstop installed successfully."); }
private static string GetWorkshopModsPath(string workingPath, Logger logger) { var configFilePath = Path.Combine(workingPath, "PatchLoader.Config.xml"); if (File.Exists(configFilePath)) { return(new ConfigManager <Config>(configFilePath, logger).Load().WorkshopPath); } else { logger.Info($"File '{configFilePath}' does not exist."); return(null); } }
private static string GetWorkshopModsPath(string workingPath, Logger logger) { var configFilePath = Path.Combine(workingPath, "PatchLoader.Config.xml"); if (File.Exists(configFilePath)) { return(new ConfigManager <Config>(configFilePath, logger).Load().WorkshopPath); } else { logger.Info($"File '{configFilePath}' does not exist."); PatchLoaderStatusInfo.Statuses.Add("PatchLoader.Config.xml", new PatchStatus("PatchLoader.Config.xml", workingPath, "Not found! Workshop mods may cause problems")); return(null); } }
internal static void ShowRestartGameModal(string message, string title = "PatchLoaderMod", Logger logger = null) { logger?.Info($"[ShowRestartGameModal - {title}] {message}"); CoroutineHelper.WaitFor( () => UIView.library != null, success: () => { UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel", (comp, result) => { Debug.Log("[PatchLoaderMod] Trying to quit the game"); // LoadingManager.instance.QuitApplication(); doesn't work sometimes Application.Quit(); }).SetMessage(title, message, false); }, failure: () => { Debug.Log("[PatchLoaderMod] Fail"); throw new Exception("PatchLoader could not open an important dialog. Something seems to be seriously broken. Please contact the author."); }, stopPollingAfterInSec: 30f ); }