private void SetInterpolatorSettings()
        {
            foreach (var interpolator in Driver.Interpolators)
            {
                interpolator.Dispose();
            }

            Driver.Interpolators.Clear();
            if (Settings.Interpolators != null)
            {
                foreach (var interpolatorName in Settings.Interpolators)
                {
                    var plugin = new PluginReference(interpolatorName);
                    var type   = plugin.GetTypeReference <Interpolator>();

                    var interpolator = plugin.Construct <Interpolator>(Platform.Timer);
                    foreach (var property in type.GetProperties())
                    {
                        if (property.GetCustomAttribute <PropertyAttribute>(false) != null &&
                            Settings.PluginSettings.TryGetValue(type.FullName + "." + property.Name, out var strValue))
                        {
                            var value = Convert.ChangeType(strValue, property.PropertyType);
                            property.SetValue(interpolator, value);
                        }
                    }

                    Driver.Interpolators.Add(interpolator);

                    Log.Write("Settings", $"Interpolator: {interpolator}");
                }
            }
        }
        public PluginManager()
        {
            Orientation       = Orientation.Horizontal;
            Panel1MinimumSize = 200;
            Panel1            = new Scrollable {
                Content = _pluginList
            };
            Panel2 = new Scrollable {
                Content = _settingControls
            };

            Plugins = new List <PluginReference>();
            _pluginList.SelectedIndexChanged += (sender, e) =>
            {
                if (_pluginList.SelectedIndex >= 0 && _pluginList.SelectedIndex <= Plugins.Count)
                {
                    SelectedPlugin = Plugins[_pluginList.SelectedIndex];
                }
            };

            foreach (var type in PluginManager.GetChildTypes <T>())
            {
                var pluginRef = new PluginReference(type);
                if (type != typeof(T) && !Plugins.Contains(pluginRef))
                {
                    Plugins.Add(pluginRef);
                }
            }

            _pluginList.Items.Clear();
            foreach (var plugin in Plugins)
            {
                _pluginList.Items.Add(string.IsNullOrWhiteSpace(plugin.Name) ? plugin.Path : plugin.Name);
            }
        }
        private void SetToolSettings()
        {
            foreach (var runningTool in Tools)
            {
                runningTool.Dispose();
            }

            foreach (var toolName in Settings.Tools)
            {
                var plugin = new PluginReference(toolName);
                var type   = plugin.GetTypeReference <ITool>();

                var tool = plugin.Construct <ITool>();
                foreach (var property in type.GetProperties())
                {
                    if (property.GetCustomAttribute <PropertyAttribute>(false) != null &&
                        Settings.PluginSettings.TryGetValue(type.FullName + "." + property.Name, out var strValue))
                    {
                        var value = Convert.ChangeType(strValue, property.PropertyType);
                        property.SetValue(tool, value);
                    }
                }

                if (tool.Initialize())
                {
                    Tools.Add(tool);
                }
                else
                {
                    Log.Write("Tool", $"Failed to initialize {plugin.Name} tool.", LogLevel.Error);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Determine if a plugin is enabled for a given project
        /// </summary>
        /// <param name="Project">The project to check</param>
        /// <param name="Plugin">Information about the plugin</param>
        /// <param name="Platform">The target platform</param>
        /// <param name="TargetType"></param>
        /// <param name="bBuildDeveloperTools"></param>
        /// <param name="bBuildEditor"></param>
        /// <param name="bBuildRequiresCookedData"></param>
        /// <returns>True if the plugin should be enabled for this project</returns>
        public static bool IsPluginDescriptorRequiredForProject(PluginInfo Plugin, ProjectDescriptor Project, UnrealTargetPlatform Platform, TargetType TargetType, bool bBuildDeveloperTools, bool bBuildEditor, bool bBuildRequiresCookedData)
        {
            // Check if it's referenced by name from the project descriptor. If it is, we'll need the plugin to be included with the project regardless of whether it has
            // any platform-specific modules or content, just so the runtime can make the call.
            if (Project != null && Project.Plugins != null)
            {
                foreach (PluginReferenceDescriptor PluginReference in Project.Plugins)
                {
                    if (String.Compare(PluginReference.Name, Plugin.Name, true) == 0)
                    {
                        return(PluginReference.IsEnabledForPlatform(Platform) && PluginReference.IsEnabledForTarget(TargetType));
                    }
                }
            }

            // If the plugin contains content, it should be included for all platforms
            if (Plugin.Descriptor.bCanContainContent)
            {
                return(true);
            }

            // Check if the plugin has any modules for the given target
            foreach (ModuleDescriptor Module in Plugin.Descriptor.Modules)
            {
                if (Module.IsCompiledInConfiguration(Platform, TargetType, bBuildDeveloperTools, bBuildEditor, bBuildRequiresCookedData))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 5
0
            protected virtual void OnSelectedSourceChanged(EventArgs e)
            {
                if (this.SelectedIndex < 0 || this.SelectedIndex > Plugins.Count - 1)
                {
                    return;
                }

                SelectedSource = Plugins[this.SelectedIndex];
                SelectedSourceChanged?.Invoke(this, SelectedSource);
            }
Esempio n. 6
0
            public void UseAssemblyReference(PathString rpath, String version)
            {
                var child = GetLogicalChildren <PluginReference>().FirstOrDefault(item => item.AssemblyPath == rpath);

                if (child == null)
                {
                    child = new PluginReference {
                        AssemblyPath = rpath
                    };

                    AddLogicalChild(child);
                }

                child.Version = version;
            }
Esempio n. 7
0
 private void UpdateSelectedStore(PluginReference reference)
 {
     if (CollectionReference.TryGetTarget(out PluginSettingStoreCollection storeCollection))
     {
         if (storeCollection.FirstOrDefault(store => store.Path == reference.Path) is PluginSettingStore store)
         {
             settingStoreEditor.Refresh(store);
         }
         else
         {
             var newStore = new PluginSettingStore(reference.GetTypeReference <TSource>(), false);
             storeCollection.Add(newStore);
             settingStoreEditor.Refresh(newStore);
         }
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Determine if a plugin is enabled for a given project
        /// </summary>
        /// <param name="Project">The project to check</param>
        /// <param name="Plugin">Information about the plugin</param>
        /// <param name="Platform">The target platform</param>
        /// <returns>True if the plugin should be enabled for this project</returns>
        public static bool IsPluginEnabledForProject(PluginInfo Plugin, ProjectDescriptor Project, UnrealTargetPlatform Platform, TargetRules.TargetType Target)
        {
            bool bEnabled = Plugin.Descriptor.bEnabledByDefault || Plugin.LoadedFrom == PluginLoadedFrom.GameProject;

            if (Project != null && Project.Plugins != null)
            {
                foreach (PluginReferenceDescriptor PluginReference in Project.Plugins)
                {
                    if (String.Compare(PluginReference.Name, Plugin.Name, true) == 0)
                    {
                        bEnabled = PluginReference.IsEnabledForPlatform(Platform) && PluginReference.IsEnabledForTarget(Target);
                    }
                }
            }
            return(bEnabled);
        }
Esempio n. 9
0
        /// <summary>
        /// Determine if a plugin is enabled for a given project
        /// </summary>
        /// <param name="Project">The project to check</param>
        /// <param name="Plugin">Information about the plugin</param>
        /// <param name="Platform">The target platform</param>
        /// <param name="Target"></param>
        /// <returns>True if the plugin should be enabled for this project</returns>
        public static bool IsPluginEnabledForProject(PluginInfo Plugin, ProjectDescriptor Project, UnrealTargetPlatform Platform, TargetType Target)
        {
            bool bEnabled = Plugin.EnabledByDefault;

            if (Project != null && Project.Plugins != null)
            {
                foreach (PluginReferenceDescriptor PluginReference in Project.Plugins)
                {
                    if (String.Compare(PluginReference.Name, Plugin.Name, true) == 0 && !PluginReference.bOptional)
                    {
                        bEnabled = PluginReference.IsEnabledForPlatform(Platform) && PluginReference.IsEnabledForTarget(Target);
                    }
                }
            }
            return(bEnabled);
        }
Esempio n. 10
0
        /// <summary>
        /// Determine if a plugin is enabled for a given project
        /// </summary>
        /// <param name="Project">The project to check</param>
        /// <param name="PluginName">Name of the plugin to check</param>
        /// <param name="Platform">The target platform</param>
        /// <param name="TargetConfiguration">The target configuration</param>
        /// <param name="Target"></param>
        /// <returns>True if the plugin should be enabled for this project</returns>
        public static bool IsPluginEnabledForProject(string PluginName, ProjectDescriptor Project, UnrealTargetPlatform Platform, UnrealTargetConfiguration TargetConfiguration, TargetType Target)
        {
            bool bEnabled = false;

            if (Project != null && Project.Plugins != null)
            {
                foreach (PluginReferenceDescriptor PluginReference in Project.Plugins)
                {
                    if (String.Compare(PluginReference.Name, PluginName, true) == 0)
                    {
                        bEnabled = PluginReference.bEnabled && PluginReference.IsEnabledForPlatform(Platform) && PluginReference.IsEnabledForTargetConfiguration(TargetConfiguration) && PluginReference.IsEnabledForTarget(Target);
                        break;
                    }
                }
            }
            return(bEnabled);
        }
Esempio n. 11
0
 public static IBinding GetBinding(string full)
 {
     if (!string.IsNullOrWhiteSpace(full))
     {
         var tokens    = full.Contains(", ") ? full.Split(", ", 2) : full.Split(": ", 2);
         var pluginRef = new PluginReference(tokens[0]);
         var binding   = pluginRef.Construct <IBinding>();
         if (binding != null)
         {
             binding.Property = tokens[1];
         }
         return(binding);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 12
0
        /// <summary>
        /// Determine if a plugin is enabled for a given project
        /// </summary>
        /// <param name="Project">The project to check</param>
        /// <param name="PluginName">Name of the plugin to check</param>
        /// <param name="Platform">The target platform</param>
        /// <param name="Target"></param>
        /// <returns>True if the plugin should be enabled for this project</returns>
        public static bool IsPluginEnabledForProject(string PluginName, ProjectDescriptor Project, UnrealTargetPlatform Platform, TargetType Target)
        {
            bool bEnabled = false;

            if (Project != null && Project.Plugins != null)
            {
                foreach (PluginReferenceDescriptor PluginReference in Project.Plugins)
                {
                    if (String.Compare(PluginReference.Name, PluginName, true) == 0)
                    {
                        // start with whether it's enabled by default
                        bEnabled = PluginReference.bEnabled;
                        bEnabled = PluginReference.IsEnabledForPlatform(Platform) && PluginReference.IsEnabledForTarget(Target);
                        break;
                    }
                }
            }
            return(bEnabled);
        }
Esempio n. 13
0
    private PluginReference AddPlugin()
    {
        var plugin = new PluginReference(this);

        plugin.onChange.AddListener(() =>
        {
            if (_plugins.Where(p => p.hasValue).GroupBy(p => p.commandName).Any(g => g.Count() > 1))
            {
                plugin.Clear();
            }
            OnPluginsListChanged();
        });
        plugin.onRemove.AddListener(() =>
        {
            plugin.Unregister();
            _plugins.Remove(plugin);
        });
        _plugins.Add(plugin);
        return(plugin);
    }
Esempio n. 14
0
        /// <summary>
        /// Determine if a plugin is enabled for a given project
        /// </summary>
        /// <param name="Project">The project to check. May be null.</param>
        /// <param name="Plugin">Information about the plugin</param>
        /// <param name="Platform">The target platform</param>
        /// <param name="Configuration">The target configuration</param>
        /// <param name="TargetType">The type of target being built</param>
        /// <returns>True if the plugin should be enabled for this project</returns>
        public static bool IsPluginEnabledForTarget(PluginInfo Plugin, ProjectDescriptor Project, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, TargetType TargetType)
        {
            if (!Plugin.Descriptor.SupportsTargetPlatform(Platform))
            {
                return(false);
            }

            bool bAllowEnginePluginsEnabledByDefault = (Project == null ? true : !Project.DisableEnginePluginsByDefault);
            bool bEnabled = Plugin.IsEnabledByDefault(bAllowEnginePluginsEnabledByDefault);

            if (Project != null && Project.Plugins != null)
            {
                foreach (PluginReferenceDescriptor PluginReference in Project.Plugins)
                {
                    if (String.Compare(PluginReference.Name, Plugin.Name, true) == 0 && !PluginReference.bOptional)
                    {
                        bEnabled = PluginReference.IsEnabledForPlatform(Platform) && PluginReference.IsEnabledForTargetConfiguration(Configuration) && PluginReference.IsEnabledForTarget(TargetType);
                    }
                }
            }
            return(bEnabled);
        }
Esempio n. 15
0
 // functions
 /// <summary>Checks whether two plugin references are equal.</summary>
 /// <param name="a">The first plugin reference.</param>
 /// <param name="b">The second plugin reference.</param>
 /// <returns>A boolean indicating whether the two plugin references are equal.</returns>
 public static bool Equals(PluginReference a, PluginReference b)
 {
     if (a == null & b == null) {
         return true;
     } else if (a == null | b == null) {
         return false;
     } else if (a.File != b.File) {
         return false;
     } else if (a.Data != b.Data) {
         return false;
     } else {
         return true;
     }
 }
        public PluginSettingsEditor(string friendlyName = null)
        {
            this.FriendlyName = friendlyName;

            var content = new Splitter();

            content.Orientation       = Orientation.Horizontal;
            content.Panel1MinimumSize = 200;
            content.Panel1            = new Scrollable {
                Content = _pluginList
            };
            content.Panel2 = new Scrollable {
                Content = _settingControls
            };

            Plugins = new List <PluginReference>();
            _pluginList.SelectedIndexChanged += (sender, e) =>
            {
                if (_pluginList.SelectedIndex >= 0 && _pluginList.SelectedIndex <= Plugins.Count)
                {
                    SelectedPlugin = Plugins[_pluginList.SelectedIndex];
                }
            };

            foreach (var type in PluginManager.GetChildTypes <T>())
            {
                var pluginRef = new PluginReference(type);
                if (type != typeof(T) && !Plugins.Contains(pluginRef))
                {
                    Plugins.Add(pluginRef);
                }
            }

            _pluginList.Items.Clear();
            foreach (var plugin in Plugins)
            {
                _pluginList.Items.Add(string.IsNullOrWhiteSpace(plugin.Name) ? plugin.Path : plugin.Name);
            }

            if (Plugins.Count == 0)
            {
                this.Content = new StackLayout
                {
                    Items =
                    {
                        new StackLayoutItem(null, true),
                        new StackLayoutItem($"No plugins containing {(string.IsNullOrWhiteSpace(this.FriendlyName) ? typeof(T).Name : $"{this.FriendlyName.ToLower()}s")} are installed.")
                        {
                            HorizontalAlignment = HorizontalAlignment.Center
                        },
                        new StackLayoutItem
                        {
                            Control = new LinkButton
                            {
                                Text    = "Plugin Repository",
                                Command = new Command(
                                    (s,           e) => SystemInfo.Open(App.PluginRepositoryUrl)
                                    )
                            },
                            HorizontalAlignment = HorizontalAlignment.Center
                        },
                        new StackLayoutItem(null, true)
                    }
                };
            }
            else
            {
                this.Content = content;
            }
        }
 public BindingReference(string bindingPath, string bindingProperty = null) : this()
 {
     Binding         = new PluginReference(bindingPath);
     BindingProperty = bindingProperty;
 }