public static void Postfix(uGUI_OptionsPanel __instance) { nitroxSettingsManager ??= Resolve <NitroxSettingsManager>(true); int tabIndex = __instance.AddTab("Nitrox"); foreach (KeyValuePair <string, List <NitroxSettingsManager.Setting> > settingEntries in nitroxSettingsManager.NitroxSettings) { __instance.AddHeading(tabIndex, settingEntries.Key); foreach (NitroxSettingsManager.Setting setting in settingEntries.Value) { switch (setting.SettingType) { case NitroxSettingsManager.SettingType.TOGGLE: __instance.AddToggleOption(tabIndex, setting.Label, setting.GetValue <bool>(), (UnityAction <bool>)setting.Callback); break; case NitroxSettingsManager.SettingType.SLIDER: __instance.AddSliderOption(tabIndex, setting.Label, setting.GetValue <float>(), setting.SliderMinValue, setting.SliderMaxValue, setting.SliderDefaultValue, (UnityAction <float>)setting.Callback); break; case NitroxSettingsManager.SettingType.LIST: __instance.AddChoiceOption(tabIndex, setting.Label, setting.ListItems, setting.GetValue <int>(), (UnityAction <int>)setting.Callback); break; } } } }
public static void AddGeneralTab_Postfix(uGUI_OptionsPanel __instance) { __instance.AddHeading(_tabIndex, "Snap Turning");//add new heading under the General Tab __instance.AddToggleOption(_tabIndex, "Enable Snap Turning", SnapTurningOptions.EnableSnapTurning, (bool v) => SnapTurningOptions.EnableSnapTurning = v); __instance.AddChoiceOption(_tabIndex, "Snap Angle", SnapTurningOptions.SnapAngleChoices, SnapTurningOptions.SnapAngleChoiceIndex, (int index) => SnapTurningOptions.SnapAngleChoiceIndex = index); __instance.AddBindingOption(_tabIndex, "Keyboard Turn Left", GameInput.Device.Keyboard, GameInput.Button.LookLeft); __instance.AddBindingOption(_tabIndex, "Keyboard Turn Right", GameInput.Device.Keyboard, GameInput.Button.LookRight); __instance.AddToggleOption(_tabIndex, "Disable Mouse Look", SnapTurningOptions.DisableMouseLook, (bool v) => SnapTurningOptions.DisableMouseLook = v); }
internal static void AddTabs_Postfix(uGUI_OptionsPanel __instance) { uGUI_OptionsPanel optionsPanel = __instance; // Start the modsTab index at a value of -1 int modsTab = -1; // Loop through all of the tabs for (int i = 0; i < optionsPanel.tabsContainer.childCount; i++) { // Check if they are named "Mods" var text = optionsPanel.tabsContainer.GetChild(i).GetComponentInChildren <Text>(true); if (text != null && text.text == "Mods") { // Set the tab index to the found one and break modsTab = i; break; } } // If no tab was found, create one if (modsTab == -1) { modsTab = optionsPanel.AddTab("Mods"); } // Maybe this could be split into its own file to handle smlhelper options, or maybe it could be removed alltogether optionsPanel.AddHeading(modsTab, "SMLHelper"); optionsPanel.AddToggleOption(modsTab, "Enable debug logs", V2.Logger.EnableDebugging, V2.Logger.SetDebugging); optionsPanel.AddChoiceOption(modsTab, "Extra item info", new string[] { "Mod name (default)", "Mod name and item ID", "Nothing" }, (int)TooltipPatcher.ExtraItemInfoOption, (i) => TooltipPatcher.SetExtraItemInfo((TooltipPatcher.ExtraItemInfo)i)); // adding all other options here modOptions.Values.ForEach(options => options.AddOptionsToPanel(optionsPanel, modsTab)); }
internal static void AddTabs_Postfix(uGUI_OptionsPanel __instance) { uGUI_OptionsPanel optionsPanel = __instance; // Start the modsTab index at a value of -1 var modsTab = -1; // Loop through all of the tabs for (int i = 0; i < optionsPanel.tabsContainer.childCount; i++) { // Check if they are named "Mods" var text = optionsPanel.tabsContainer.GetChild(i).GetComponentInChildren <Text>(true); if (text != null && text.text == "Mods") { // Set the tab index to the found one and break modsTab = i; break; } } // If no tab was found, create one if (modsTab == -1) { modsTab = optionsPanel.AddTab("Mods"); } // Maybe this could be split into its own file to handle smlhelper options, or maybe it could be removed alltogether optionsPanel.AddHeading(modsTab, "SMLHelper"); optionsPanel.AddToggleOption(modsTab, "Enable debug logs", V2.Logger.EnableDebugging, V2.Logger.SetDebugging); foreach (ModOptions modOption in modOptions.Values) { optionsPanel.AddHeading(modsTab, modOption.Name); foreach (ModOption option in modOption.Options) { switch (option.Type) { case ModOptionType.Slider: var slider = (ModSliderOption)option; optionsPanel.AddSliderOption(modsTab, slider.Label, slider.Value, slider.MinValue, slider.MaxValue, slider.Value, new UnityAction <float>((float sliderVal) => modOption.OnSliderChange(slider.Id, sliderVal))); break; case ModOptionType.Toggle: var toggle = (ModToggleOption)option; optionsPanel.AddToggleOption(modsTab, toggle.Label, toggle.Value, new UnityAction <bool>((bool toggleVal) => modOption.OnToggleChange(toggle.Id, toggleVal))); break; case ModOptionType.Choice: var choice = (ModChoiceOption)option; optionsPanel.AddChoiceOption(modsTab, choice.Label, choice.Options, choice.Index, new UnityAction <int>((int index) => modOption.OnChoiceChange(choice.Id, index, choice.Options[index]))); break; case ModOptionType.Keybind: var keybind = (ModKeybindOption)option; ModKeybindOption.AddBindingOptionWithCallback(optionsPanel, modsTab, keybind.Label, keybind.Key, keybind.Device, new UnityAction <KeyCode>((KeyCode key) => modOption.OnKeybindChange(keybind.Id, key))); break; default: V2.Logger.Log($"Invalid ModOptionType detected for option: {option.Id} ({option.Type.ToString()})", LogLevel.Error); break; } } } }
public static void AddGeneralTab_Postfix(uGUI_OptionsPanel __instance) { __instance.AddHeading(tabIndex, "Snap Turning");//add new heading under the General Tab __instance.AddToggleOption(tabIndex, "Enable Snap Turning", SnapTurningOptions.EnableSnapTurning, (bool v) => SnapTurningOptions.EnableSnapTurning = v); __instance.AddChoiceOption(tabIndex, "Snap Angle", SnapTurningOptions.SnapAngleChoices, SnapTurningOptions.SnapAngleChoiceIndex, (int index) => SnapTurningOptions.SnapAngleChoiceIndex = index); }