Example #1
0
        protected static SettingsProvider CreateEarlySettingsProvider(string id, SettingsScope scope)
        {
            // If the preference / setting panel is open before the plugin container gets initialized,
            // we can't afford to return null in [SettingsProvider], because the panel will then never
            // get created later. This is a workaround that creates a wrapper around the configuration now
            // which doesn't render anything until the plugin container is initialized.

            if (PluginContainer.initialized)
            {
                return(PluginContainer.GetPlugin(id).configuration.CreateSettingsProvider(scope));
            }
            else
            {
                return(new SettingsProvider(PluginConfiguration.ScopeRoot(scope) + "/Ludiq/" + id, scope)
                {
                    label = id,
                    guiHandler = query =>
                    {
                        if (PluginContainer.initialized)
                        {
                            PluginContainer.GetPlugin(id).configuration.OnGUI(scope, query);
                        }
                    },
                    footerBarGuiHandler = () =>
                    {
                        if (PluginContainer.initialized)
                        {
                            PluginContainer.GetPlugin(id).configuration.OnFooterGUI(scope);
                        }
                    },
                });
            }
        }