diff --git a/EXILED/Exiled.API/Features/Core/UserSettings/SettingBase.cs b/EXILED/Exiled.API/Features/Core/UserSettings/SettingBase.cs index 5af5f615e7..776b80cca3 100644 --- a/EXILED/Exiled.API/Features/Core/UserSettings/SettingBase.cs +++ b/EXILED/Exiled.API/Features/Core/UserSettings/SettingBase.cs @@ -176,6 +176,8 @@ public static bool TryGetSetting(Player player, int id, out T setting) SSGroupHeader header => new HeaderSetting(header), SSKeybindSetting keybindSetting => new KeybindSetting(keybindSetting), SSTwoButtonsSetting twoButtonsSetting => new TwoButtonsSetting(twoButtonsSetting), + SSPlaintextSetting plainTextSetting => new UserTextInputSetting(plainTextSetting), + SSSliderSetting sliderSetting => new SliderSetting(sliderSetting), _ => new SettingBase(settingBase) }; diff --git a/EXILED/Exiled.API/Features/Core/UserSettings/SliderSetting.cs b/EXILED/Exiled.API/Features/Core/UserSettings/SliderSetting.cs new file mode 100644 index 0000000000..66d88174d9 --- /dev/null +++ b/EXILED/Exiled.API/Features/Core/UserSettings/SliderSetting.cs @@ -0,0 +1,124 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.API.Features.Core.UserSettings +{ + using System; + + using Exiled.API.Interfaces; + using global::UserSettings.ServerSpecific; + + /// + /// Represents a slider setting. + /// + public class SliderSetting : SettingBase, IWrapper + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public SliderSetting(int id, string label, float minValue, float maxValue, float defaultValue, bool isInteger = false, string stringFormat = "0.##", string displayFormat = "{0}", string hintDescription = null) + : this(new SSSliderSetting(id, label, minValue, maxValue, defaultValue, isInteger, stringFormat, displayFormat, hintDescription)) + { + Base = (SSSliderSetting)base.Base; + } + + /// + /// Initializes a new instance of the class. + /// + /// A instance. + internal SliderSetting(SSSliderSetting settingBase) + : base(settingBase) + { + Base = settingBase; + } + + /// + /// Gets or sets the minimum value of the slider. + /// + public float MinimumValue + { + get => Base.MinValue; + set => Base.MinValue = value; + } + + /// + /// Gets or sets the maximum value of the slider. + /// + public float MaximumValue + { + get => Base.MaxValue; + set => Base.MaxValue = value; + } + + /// + /// Gets or sets the default value of the slider. + /// + public float DefaultValue + { + get => Base.DefaultValue; + set => Base.DefaultValue = value; + } + + /// + /// Gets or sets a value indicating whether the slider displays integers. + /// + public bool IsInteger + { + get => Base.Integer; + set => Base.Integer = value; + } + + /// + /// Gets a value indicating whether the slider is currently being dragged. + /// + public bool IsBeingDragged => Base.SyncDragging; + + /// + /// Gets a float that represents the current value of the slider. + /// + public float SliderValue => Base.Integer ? Base.SyncIntValue : Base.SyncFloatValue; + + /// + /// Gets or sets the formatting used for the number in the slider. + /// + public string StringFormat + { + get => Base.ValueToStringFormat; + set => Base.ValueToStringFormat = value; + } + + /// + /// Gets or sets the formatting used for the final display of the value of the slider. + /// + public string DisplayFormat + { + get => Base.FinalDisplayFormat; + set => Base.FinalDisplayFormat = value; + } + + /// + public new SSSliderSetting Base { get; } + + /// + /// Returns a representation of this . + /// + /// A string in human-readable format. + public override string ToString() + { + return base.ToString() + $" /{MinimumValue}/ *{MaximumValue}* +{DefaultValue}+ '{SliderValue}'"; + } + } +} \ No newline at end of file diff --git a/EXILED/Exiled.API/Features/Core/UserSettings/UserTextInputSetting.cs b/EXILED/Exiled.API/Features/Core/UserSettings/UserTextInputSetting.cs new file mode 100644 index 0000000000..8944558e03 --- /dev/null +++ b/EXILED/Exiled.API/Features/Core/UserSettings/UserTextInputSetting.cs @@ -0,0 +1,90 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.API.Features.Core.UserSettings +{ + using System; + + using Exiled.API.Interfaces; + using global::UserSettings.ServerSpecific; + using TMPro; + + /// + /// Represents a user text input setting. + /// + public class UserTextInputSetting : SettingBase, IWrapper + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + /// /// + public UserTextInputSetting(int id, string label, string placeHolder = "", int characterLimit = 64, TMP_InputField.ContentType contentType = TMP_InputField.ContentType.Standard, string hintDescription = null) + : this(new SSPlaintextSetting(id, label, placeHolder, characterLimit, contentType, hintDescription)) + { + Base = (SSPlaintextSetting)base.Base; + } + + /// + /// Initializes a new instance of the class. + /// + /// A instance. + internal UserTextInputSetting(SSPlaintextSetting settingBase) + : base(settingBase) + { + Base = settingBase; + } + + /// + public new SSPlaintextSetting Base { get; } + + /// + /// Gets the value of the text entered by a client. + /// + public string Text => Base.SyncInputText; + + /// + /// Gets or sets a value indicating the placeholder shown within the PlainTextSetting. + /// + public string PlaceHolder + { + get => Base.Placeholder; + set => Base.Placeholder = value; + } + + /// + /// Gets or sets a value indicating the type of content within the PlainTextSetting. + /// + public TMP_InputField.ContentType ContentType + { + get => Base.ContentType; + set => Base.ContentType = value; + } + + /// + /// Gets or sets a value indicating the max number of characters in the PlainTextSetting. + /// + public int CharacterLimit + { + get => Base.CharacterLimit; + set => Base.CharacterLimit = value; + } + + /// + /// Returns a representation of this . + /// + /// A string in human-readable format. + public override string ToString() + { + return base.ToString() + $" /{Text}/ *{ContentType}* +{CharacterLimit}+"; + } + } +} \ No newline at end of file