Skip to content

Commit

Permalink
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Browse files Browse the repository at this point in the history
I did NOT wanna make a PR today
  • Loading branch information
Trevlouw committed Jan 25, 2025
1 parent 2a5d340 commit 1e3863e
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 34 deletions.
3 changes: 2 additions & 1 deletion EXILED/Exiled.API/Features/Core/UserSettings/SettingBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,11 @@ public static bool TryGetSetting<T>(Player player, int id, out T setting)
{
SSButton button => new ButtonSetting(button),
SSDropdownSetting dropdownSetting => new DropdownSetting(dropdownSetting),
SSTextArea textArea => new TextInputSetting(textArea),
SSTextArea textArea => new TextAreaSetting(textArea),
SSGroupHeader header => new HeaderSetting(header),
SSKeybindSetting keybindSetting => new KeybindSetting(keybindSetting),
SSTwoButtonsSetting twoButtonsSetting => new TwoButtonsSetting(twoButtonsSetting),
SSPlaintextSetting plainTextSetting => new TextInputSetting(plainTextSetting),
_ => new SettingBase(settingBase)
};

Expand Down
93 changes: 93 additions & 0 deletions EXILED/Exiled.API/Features/Core/UserSettings/TextAreaSetting.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// -----------------------------------------------------------------------
// <copyright file="TextAreaSetting.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.API.Features.Core.UserSettings
{
using System;

using Exiled.API.Interfaces;
using global::UserSettings.ServerSpecific;
using TMPro;

/// <summary>
/// Represents a text area setting.
/// </summary>
public class TextAreaSetting : SettingBase, IWrapper<SSTextArea>
{
/// <summary>
/// Initializes a new instance of the <see cref="TextAreaSetting"/> class.
/// </summary>
/// <param name="id"><inheritdoc cref="SettingBase.Id"/></param>
/// <param name="label"><inheritdoc cref="SettingBase.Label"/></param>
/// <param name="foldoutMode"><inheritdoc cref="FoldoutMode"/></param>
/// <param name="alignment"><inheritdoc cref="Alignment"/></param>
/// <param name="hintDescription"><inheritdoc cref="SettingBase.HintDescription"/></param>
/// <param name="header"><inheritdoc cref="SettingBase.Header"/></param>
/// <param name="onChanged"><inheritdoc cref="SettingBase.OnChanged"/></param>
public TextAreaSetting(
int id,
string label,
SSTextArea.FoldoutMode foldoutMode = SSTextArea.FoldoutMode.NotCollapsable,
TextAlignmentOptions alignment = TextAlignmentOptions.TopLeft,
string hintDescription = null,
HeaderSetting header = null,
Action<Player, SettingBase> onChanged = null)
: base(new SSTextArea(id, label, foldoutMode, hintDescription, alignment), header, onChanged)
{
Base = (SSTextArea)base.Base;
}

/// <summary>
/// Initializes a new instance of the <see cref="TextAreaSetting"/> class.
/// </summary>
/// <param name="settingBase">A <see cref="SSTextArea"/> instance.</param>
internal TextAreaSetting(SSTextArea settingBase)
: base(settingBase)
{
Base = settingBase;
}

/// <inheritdoc/>
public new SSTextArea Base { get; }

/// <summary>
/// Gets or sets the text for the setting.
/// </summary>
public new string Label
{
get => Base.Label;
set => Base.SendTextUpdate(value);
}

/// <summary>
/// Gets or sets the foldout mode.
/// </summary>
public SSTextArea.FoldoutMode FoldoutMode
{
get => Base.Foldout;
set => Base.Foldout = value;
}

/// <summary>
/// Gets or sets the text alignment options.
/// </summary>
public TextAlignmentOptions Alignment
{
get => Base.AlignmentOptions;
set => Base.AlignmentOptions = value;
}

/// <summary>
/// Returns a representation of this <see cref="TextAreaSetting"/>.
/// </summary>
/// <returns>A string in human-readable format.</returns>
public override string ToString()
{
return base.ToString() + $" /{FoldoutMode}/ *{Alignment}*";
}
}
}
63 changes: 30 additions & 33 deletions EXILED/Exiled.API/Features/Core/UserSettings/TextInputSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,78 +16,75 @@ namespace Exiled.API.Features.Core.UserSettings
/// <summary>
/// Represents a text input setting.
/// </summary>
public class TextInputSetting : SettingBase, IWrapper<SSTextArea>
public class TextInputSetting : SettingBase, IWrapper<SSPlaintextSetting>
{
/// <summary>
/// Initializes a new instance of the <see cref="TextInputSetting"/> class.
/// </summary>
/// <param name="id"><inheritdoc cref="SettingBase.Id"/></param>
/// <param name="label"><inheritdoc cref="SettingBase.Label"/></param>
/// <param name="foldoutMode"><inheritdoc cref="FoldoutMode"/></param>
/// <param name="alignment"><inheritdoc cref="Alignment"/></param>
/// <param name="hintDescription"><inheritdoc cref="SettingBase.HintDescription"/></param>
/// <param name="header"><inheritdoc cref="SettingBase.Header"/></param>
/// <param name="onChanged"><inheritdoc cref="SettingBase.OnChanged"/></param>
public TextInputSetting(
int id,
string label,
SSTextArea.FoldoutMode foldoutMode = SSTextArea.FoldoutMode.NotCollapsable,
TextAlignmentOptions alignment = TextAlignmentOptions.TopLeft,
string hintDescription = null,
HeaderSetting header = null,
Action<Player, SettingBase> onChanged = null)
: base(new SSTextArea(id, label, foldoutMode, hintDescription, alignment), header, onChanged)
/// <param name="placeHolder"><inheritdoc cref="PlaceHolder"/></param>
/// <param name="characterLimit"><inheritdoc cref="CharacterLimit"/></param>
/// <param name="contentType"><inheritdoc cref="ContentType"/></param>
/// /// <param name="hintDescription"><inheritdoc cref="SettingBase.HintDescription"/></param>
public TextInputSetting(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 = (SSTextArea)base.Base;
Base = (SSPlaintextSetting)base.Base;
}

/// <summary>
/// Initializes a new instance of the <see cref="TextInputSetting"/> class.
/// </summary>
/// <param name="settingBase">A <see cref="SSTextArea"/> instance.</param>
internal TextInputSetting(SSTextArea settingBase)
/// <param name="settingBase">A <see cref="SSGroupHeader"/> instance.</param>
internal TextInputSetting(SSPlaintextSetting settingBase)
: base(settingBase)
{
Base = settingBase;
}

/// <inheritdoc/>
public new SSTextArea Base { get; }
public new SSPlaintextSetting Base { get; }

/// <summary>
/// Gets or sets the text for the setting.
/// Gets a value indicating whether the key is pressed.
/// </summary>
public new string Label
public string Text => Base.SyncInputText;

/// <summary>
/// Gets or sets a value indicating the placeholder shown within the PlainTextSetting.
/// </summary>
public string PlaceHolder
{
get => Base.Label;
set => Base.SendTextUpdate(value);
get => Base.Placeholder;
set => Base.Placeholder = value;
}

/// <summary>
/// Gets or sets the foldout mode.
/// Gets or sets a value indicating the type of content within the PlainTextSetting.
/// </summary>
public SSTextArea.FoldoutMode FoldoutMode
public TMP_InputField.ContentType ContentType
{
get => Base.Foldout;
set => Base.Foldout = value;
get => Base.ContentType;
set => Base.ContentType = value;
}

/// <summary>
/// Gets or sets the text alignment options.
/// Gets or sets a value indicating the max number of characters in the PlainTextSetting.
/// </summary>
public TextAlignmentOptions Alignment
public int CharacterLimit
{
get => Base.AlignmentOptions;
set => Base.AlignmentOptions = value;
get => Base.CharacterLimit;
set => Base.CharacterLimit = value;
}

/// <summary>
/// Returns a representation of this <see cref="TextInputSetting"/>.
/// Returns a representation of this <see cref="HeaderSetting"/>.
/// </summary>
/// <returns>A string in human-readable format.</returns>
public override string ToString()
{
return base.ToString() + $" /{FoldoutMode}/ *{Alignment}*";
return base.ToString() + $" /{Text}/ *{ContentType}* +{CharacterLimit}+";
}
}
}

0 comments on commit 1e3863e

Please sign in to comment.