public UnrealPluginInstaller(Lifetime lifetime, ILogger logger, UnrealPluginDetector pluginDetector, PluginPathsProvider pathsProvider, ISolution solution, ISettingsStore settingsStore, IShellLocks shellLocks, UnrealHost unrealHost) { myLifetime = lifetime; myLogger = logger; myPathsProvider = pathsProvider; myShellLocks = shellLocks; myUnrealHost = unrealHost; myBoundSettingsStore = settingsStore.BindToContextLive(myLifetime, ContextRange.Smart(solution.ToDataContext())); myPluginDetector = pluginDetector; myPluginDetector.InstallInfoProperty.Change.Advise_NewNotNull(myLifetime, installInfo => { myShellLocks.ExecuteOrQueueReadLockEx(myLifetime, "UnrealPluginInstaller.CheckAllProjectsIfAutoInstallEnabled", () => { var unrealPluginInstallInfo = installInfo.New; if (unrealPluginInstallInfo.EnginePlugin.IsPluginAvailable) { // TODO: add install plugin to Engine } ; if (!myBoundSettingsStore.GetValue((UnrealLinkSettings s) => s.InstallRiderLinkPlugin)) { foreach (var installDescription in unrealPluginInstallInfo.ProjectPlugins) { if (installDescription.IsPluginAvailable == false || installDescription.PluginVersion != myPathsProvider.CurrentPluginVersion) { myUnrealHost.PerformModelAction(model => model.OnEditorModelOutOfSync()); } } return; } InstallPluginIfRequired(unrealPluginInstallInfo); }); }); BindToInstallationSettingChange(); BindToNotificationFixAction(); }
public RiderBackendToUnrealEditor(Lifetime lifetime, IShellLocks locks, IScheduler dispatcher, ILogger logger, UnrealHost unrealHost, UnrealLinkResolver linkResolver, EditorNavigator editorNavigator, UnrealPluginDetector pluginDetector) { myComponentLifetime = lifetime; myLocks = locks; myConnectionLifetimeProducer = new SequentialLifetimes(lifetime); myDispatcher = dispatcher; myLogger = logger; myUnrealHost = unrealHost; myLinkResolver = linkResolver; myEditorNavigator = editorNavigator; myLogger.Info("RiderBackendToUnrealEditor building started"); pluginDetector.InstallInfoProperty.View(myComponentLifetime, (lt, pluginInfo) => { if (pluginInfo == null) { return; } var portDirectoryFullPath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "..", "Local", "Jetbrains", "Rider", "Unreal", "Ports"); Directory.CreateDirectory(portDirectoryFullPath); var watcher = new FileSystemWatcher(portDirectoryFullPath) { NotifyFilter = NotifyFilters.LastWrite }; var projects = pluginInfo.ProjectPlugins.Select(it => it.UprojectFilePath.NameWithoutExtension) .ToList(); FileSystemEventHandler handler = (obj, fileSystemEvent) => { var path = FileSystemPath.Parse(fileSystemEvent.FullPath); if (projects.Contains(path.NameWithoutExtension) && myComponentLifetime.IsAlive) { myLocks.ExecuteOrQueue(myComponentLifetime, "CreateProtocol", () => CreateProtocols(path)); } }; watcher.Changed += handler; watcher.Created += handler; // Check if it's even possible to happen lt.Bracket(() => { }, () => { watcher.Dispose(); }); StartWatcher(watcher); foreach (var projectName in projects) { var portFileFullPath = Path.Combine(portDirectoryFullPath, projectName); CreateProtocols(FileSystemPath.Parse(portFileFullPath)); } }); myLogger.Info("RiderBackendToUnrealEditor building finished"); }
private void InstallPluginIfRequired(UnrealPluginInstallInfo unrealPluginInstallInfo) { bool needToRegenerateProjectFiles = false; foreach (var installDescription in unrealPluginInstallInfo.ProjectPlugins) { if (installDescription.PluginVersion == myPathsProvider.CurrentPluginVersion) { continue; } var pluginDir = installDescription.UnrealPluginRootFolder; var upluginFile = UnrealPluginDetector.GetPathToUpluginFile(pluginDir); var backupDir = pluginDir.AddSuffix(BACKUP_SUFFIX); try { if (pluginDir.ExistsDirectory) { pluginDir.Move(backupDir); } } catch (Exception exception) { myLogger.Verbose(exception, ExceptionOrigin.Algorithmic, "Couldn't backup original RiderLink plugin folder"); continue; } var editorPluginPathFile = myPathsProvider.PathToPackedPlugin; try { ZipFile.ExtractToDirectory(editorPluginPathFile.FullPath, pluginDir.FullPath); } catch (Exception _) { if (backupDir.ExistsDirectory) { backupDir.Move(pluginDir); } continue; } if (backupDir.ExistsDirectory) { backupDir.Delete(); } PatchTypeOfUpluginFile(upluginFile); needToRegenerateProjectFiles = true; } if (needToRegenerateProjectFiles) { RegenerateProjectFiles(unrealPluginInstallInfo.ProjectPlugins.FirstNotNull()?.UprojectFilePath); } }