/// <inheritdoc /> public ConfigurationManager() { 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")); _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), "Etnry 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); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), null); }
/// <inheritdoc /> public ConfigurationManager() { Logger = base.Logger; _fieldDrawer = new SettingFieldDrawer(this); _showAdvanced = Config.AddSetting("Filtering", "Show advanced", false); _showKeybinds = Config.AddSetting("Filtering", "Show keybinds", true); _showSettings = Config.AddSetting("Filtering", "Show settings", true); _keybind = Config.AddSetting("General", "Show config manager", new BepInEx.Configuration.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.")); _hideSingleSection = Config.AddSetting("General", "Hide single sections", false, new ConfigDescription("Show section title for plugins with only one section")); }
/// <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(); }
private void DrawSinglePlugin(PluginSettingsData plugin) { var style = new GUIStyle(GUI.skin.box); style.normal.textColor = _fontColor.Value; style.normal.background = EntryBackground; style.fontSize = fontSize; GUI.backgroundColor = _entryBackgroundColor.Value; GUILayout.BeginVertical(style); var categoryHeader = _showDebug ? new GUIContent(plugin.Info.Name.TrimStart('!') + " " + plugin.Info.Version, "GUID: " + plugin.Info.GUID) : new GUIContent(plugin.Info.Name.TrimStart('!') + " " + plugin.Info.Version); var isSearching = !string.IsNullOrEmpty(SearchString); if (SettingFieldDrawer.DrawPluginHeader(categoryHeader, plugin.Collapsed && !isSearching) && !isSearching) { plugin.Collapsed = !plugin.Collapsed; } if (isSearching || !plugin.Collapsed) { foreach (var category in plugin.Categories) { if (!string.IsNullOrEmpty(category.Name)) { if (plugin.Categories.Count > 1 || !_hideSingleSection.Value) { SettingFieldDrawer.DrawCategoryHeader(category.Name); } } foreach (var setting in category.Settings) { DrawSingleSetting(setting); GUILayout.Space(2); } } } GUILayout.EndVertical(); }
private void DrawSinglePlugin(PluginSettingsData plugin) { var style = new GUIStyle(GUI.skin.box); style.normal.textColor = _fontColor.Value; style.normal.background = EntryBackground; style.fontSize = fontSize; GUI.backgroundColor = _entryBackgroundColor.Value; GUILayout.BeginVertical(style); var categoryHeader = _showDebug ? new GUIContent(plugin.Info.Name.TrimStart('!') + " " + plugin.Info.Version, "GUID: " + plugin.Info.GUID) : new GUIContent(plugin.Info.Name.TrimStart('!') + " " + plugin.Info.Version); var isSearching = !string.IsNullOrEmpty(SearchString); if (SettingFieldDrawer.DrawPluginHeader(categoryHeader, plugin.Collapsed && !isSearching) && !isSearching) { plugin.Collapsed = !plugin.Collapsed; } if (isSearching || !plugin.Collapsed) { foreach (var category in plugin.Categories) { if (!string.IsNullOrEmpty(category.Name)) { if (plugin.Categories.Count > 1 || !_hideSingleSection.Value) { SettingFieldDrawer.DrawCategoryHeader(category.Name); } } foreach (var setting in category.Settings) { DrawSingleSetting(setting); GUILayout.Space(2); } } GUILayout.BeginHorizontal(); var color = GUI.backgroundColor; GUI.backgroundColor = _widgetBackgroundColor.Value; if (GUILayout.Button(_reloadText.Value, buttonStyle, GUILayout.ExpandWidth(true))) { foreach (var category in plugin.Categories) { foreach (var setting in category.Settings) { setting.PluginInstance.Config.Reload(); break; } break; } BuildFilteredSettingList(); } if (GUILayout.Button(_resetText.Value, buttonStyle, GUILayout.ExpandWidth(true))) { foreach (var category in plugin.Categories) { foreach (var setting in category.Settings) { setting.Set(setting.DefaultValue); } } BuildFilteredSettingList(); } GUI.backgroundColor = color; GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }
private void SettingsWindow(int id) { GUI.DragWindow(new Rect(0, 0, currentWindowRect.width, 20)); DrawWindowHeader(); _settingWindowScrollPos = GUILayout.BeginScrollView(_settingWindowScrollPos, false, true); var scrollPosition = _settingWindowScrollPos.y; var scrollHeight = currentWindowRect.height; GUILayout.BeginVertical(); { if (string.IsNullOrEmpty(SearchString)) { DrawTips(); if (_tipsHeight == 0 && Event.current.type == EventType.Repaint) { _tipsHeight = (int)GUILayoutUtility.GetLastRect().height; } } var currentHeight = _tipsHeight; foreach (var plugin in _filteredSetings) { var visible = plugin.Height == 0 || currentHeight + plugin.Height >= scrollPosition && currentHeight <= scrollPosition + scrollHeight; if (visible) { try { DrawSinglePlugin(plugin); } catch (ArgumentException) { // Needed to avoid GUILayout: Mismatched LayoutGroup.Repaint crashes on large lists } if (plugin.Height == 0 && Event.current.type == EventType.Repaint) { plugin.Height = (int)GUILayoutUtility.GetLastRect().height; } } else { try { GUILayout.Space(plugin.Height); } catch (ArgumentException) { // Needed to avoid GUILayout: Mismatched LayoutGroup.Repaint crashes on large lists } } currentHeight += plugin.Height; } if (_showDebug) { GUILayout.Space(10); GUILayout.Label("Plugins with no options available: " + _modsWithoutSettings, labelStyle); } else { // Always leave some space in case there's a dropdown box at the very bottom of the list GUILayout.Space(70); } } GUILayout.EndVertical(); GUILayout.EndScrollView(); if (!SettingFieldDrawer.DrawCurrentDropdown()) { DrawTooltip(currentWindowRect); } }