public static void CollectSettings(out IEnumerable <SettingEntryBase> results, out List <string> modsWithoutSettings, bool showDebug) { modsWithoutSettings = new List <string>(); try { results = GetBepInExCoreConfig(); } catch (Exception ex) { results = Enumerable.Empty <SettingEntryBase>(); BepInExPlugin.Logger.LogError(ex); } foreach (var plugin in Utils.FindPlugins()) { if (plugin.Info.Metadata.GUID == "com.bepis.bepinex.configurationmanager" || plugin.enabled == false) { BepInExPlugin.Dbgl($"plugin: {plugin.Info.Metadata.Name} enabled {plugin.enabled}"); } var type = plugin.GetType(); var pluginInfo = plugin.Info.Metadata; if (type.GetCustomAttributes(typeof(BrowsableAttribute), false).Cast <BrowsableAttribute>() .Any(x => !x.Browsable)) { modsWithoutSettings.Add(pluginInfo.Name); continue; } var detected = new List <SettingEntryBase>(); detected.AddRange(GetPluginConfig(plugin).Cast <SettingEntryBase>()); detected.RemoveAll(x => x.Browsable == false); if (!detected.Any()) { modsWithoutSettings.Add(pluginInfo.Name); } // Allow to enable/disable plugin if it uses any update methods ------ if (showDebug && type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Any(x => _updateMethodNames.Contains(x.Name))) { // todo make a different class for it and fix access modifiers? var enabledSetting = LegacySettingEntry.FromNormalProperty(plugin, type.GetProperty("enabled"), pluginInfo, plugin); enabledSetting.DispName = "!Allow plugin to run on every frame"; enabledSetting.Description = "Disabling this will disable some or all of the plugin's functionality.\nHooks and event-based functionality will not be disabled.\nThis setting will be lost after game restart."; enabledSetting.IsAdvanced = true; detected.Add(enabledSetting); } if (detected.Any()) { results = results.Concat(detected); } } }
/// <inheritdoc /> public BepInExPlugin() { context = this; Logger = base.Logger; CalculateDefaultWindowRect(); _fieldDrawer = new SettingFieldDrawer(this); _keybind = Config.Bind("General", "Show config manager", new KeyboardShortcut(KeyCode.F1), new ConfigDescription("The shortcut used to toggle the config manager window on and off.\n" + "The key can be overridden by a game-specific plugin if necessary, in that case this setting is ignored.")); nexusID = Config.Bind <int>("General", "NexusID", 740, "Nexus mod ID for updates"); _showAdvanced = Config.Bind <bool>("Filtering", "Show advanced", true); _showKeybinds = Config.Bind("Filtering", "Show keybinds", true); _showSettings = Config.Bind("Filtering", "Show settings", true); _hideSingleSection = Config.Bind("General", "Hide single sections", false, new ConfigDescription("Show section title for plugins with only one section")); _showMenuButton = Config.Bind("General", "Show Menu Button", true, new ConfigDescription("Show the menu button on the start menu")); _windowTitle = Config.Bind("Text", "WindowTitle", "Configuration Manager", new ConfigDescription("Window title text")); _normalText = Config.Bind("Text", "NormalText", "Normal", new ConfigDescription("Normal settings toggle text")); _shortcutsText = Config.Bind("Text", "ShortcutsText", "Keybinds", new ConfigDescription("Shortcut key settings toggle text")); _advancedText = Config.Bind("Text", "AdvancedText", "Advanced", new ConfigDescription("Advanced settings toggle text")); _searchText = Config.Bind("Text", "SearchText", "Search Settings: ", new ConfigDescription("Search label text")); _reloadText = Config.Bind("Text", "ReloadText", "Reload From File", new ConfigDescription("Reload mod config from file text")); _resetText = Config.Bind("Text", "ResetText", "Reset To Default", new ConfigDescription("Reset mod config to default text")); _resetSettingText = Config.Bind("Text", "ResetSettingText", "Reset", new ConfigDescription("Reset setting text")); _expandText = Config.Bind("Text", "ExpandText", "Expand", new ConfigDescription("Expand button text")); _collapseText = Config.Bind("Text", "CollapseText", "Collapse", new ConfigDescription("Collapse button text")); _tipText = Config.Bind("Text", "TipText", "Tip: Click plugin names to expand. Hover over setting names to see their descriptions.", new ConfigDescription("Tip text")); _clearText = Config.Bind("Text", "ClearText", "Clear", new ConfigDescription("Clear search text")); _openMenuText = Config.Bind("Text", "OpenMenuText", "Open Config Menu", new ConfigDescription("Open Menu Button text")); _pluginConfigCollapsedDefault = Config.Bind("General", "Plugin collapsed default", true, new ConfigDescription("If set to true plugins will be collapsed when opening the configuration manager window")); _windowPosition = Config.Bind("General", "WindowPosition", new Vector2(55, 35), "Window position"); _windowSize = Config.Bind("General", "WindowSize", DefaultWindowRect.size, "Window size"); _textSize = Config.Bind("General", "FontSize", 14, "Font Size"); _windowBackgroundColor = Config.Bind("Colors", "WindowBackgroundColor", new Color(0, 0, 0, 1), "Window background color"); _entryBackgroundColor = Config.Bind("Colors", "EntryBackgroundColor", new Color(0.557f, 0.502f, 0.502f, 0.871f), "Entry background color"); _fontColor = Config.Bind("Colors", "FontColor", new Color(1, 0.714f, 0.361f, 1), "Font color"); _widgetBackgroundColor = Config.Bind("Colors", "WidgetColor", new Color(0.882f, 0.463f, 0, 0.749f), "Widget color"); currentWindowRect = new Rect(_windowPosition.Value, _windowSize.Value); Patches.ApplyPatches(); }
public SettingFieldDrawer(BepInExPlugin instance) { _instance = instance; }