Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8acfeb0
Settings
obvEve Mar 20, 2025
1258674
CustomButtonSetting
obvEve Mar 20, 2025
f667a29
Custom Button
obvEve Mar 21, 2025
bbdee5b
fix NW validation
obvEve Mar 21, 2025
399de90
fix server validation
obvEve Mar 21, 2025
ae13f07
allow unsafe
obvEve Mar 21, 2025
8baa6cc
Merge branch 'dev' into settings
obvEve Mar 24, 2025
075a201
Rework
obvEve Apr 4, 2025
a637334
Merge remote-tracking branch 'origin/settings' into settings
obvEve Apr 4, 2025
89f1fe2
prevent exploit
obvEve Apr 4, 2025
2455b18
Fix OriginalDefinition
obvEve Apr 4, 2025
5935fd4
Add DefinedSettings
obvEve Apr 4, 2025
ffc2bb2
Merge branch 'dev' into settings
obvEve Apr 4, 2025
4bb0f52
wrap
obvEve Apr 4, 2025
8461eea
repair
obvEve Apr 4, 2025
bca88a7
Use abstract method instead of Reflection
obvEve Apr 4, 2025
727b391
remove no longer required constructor
obvEve Apr 4, 2025
e2130a5
fix player leaving
obvEve Apr 4, 2025
5b03303
i cooked
obvEve Apr 4, 2025
3fbe904
Fix settings
obvEve Apr 4, 2025
dfb3417
CustomDropdownSetting
obvEve Apr 5, 2025
2b204de
CustomKeybindSetting
obvEve Apr 5, 2025
49def76
Keybind example
obvEve Apr 5, 2025
be14d52
Merge branch 'dev' into settings
obvEve Apr 5, 2025
539ddd7
PatchCategory
obvEve Apr 5, 2025
88efe92
feat: two button setting
LumiFae Apr 6, 2025
e23f81e
docs: improve docs on other settings
LumiFae Apr 6, 2025
cc5e09b
Merge pull request #21 from LumiFae/settings
obvEve Apr 6, 2025
457bbc6
wrap
obvEve Apr 9, 2025
9c296e7
Improve
obvEve Apr 9, 2025
07a130c
Internal example
obvEve Apr 9, 2025
a039c24
fix compile
obvEve Apr 9, 2025
8f11210
docs: normalise documentation
LumiFae Apr 9, 2025
75d5036
Merge pull request #23 from LumiFae/settings-docs
obvEve Apr 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions SecretAPI/Features/UserSettings/CustomButtonSetting.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
namespace SecretAPI.Features.UserSettings
{
using System;
using global::UserSettings.ServerSpecific;
using SecretAPI.Interfaces;

/// <summary>
/// Wraps <see cref="SSButton"/>.
/// </summary>
public abstract class CustomButtonSetting : CustomSetting, ISetting<SSButton>
{
/// <summary>
/// Initializes a new instance of the <see cref="CustomButtonSetting"/> class.
/// </summary>
/// <param name="button">The button base.</param>
protected CustomButtonSetting(SSButton button)
: base(button)
{
Base = button;
}

/// <summary>
/// Initializes a new instance of the <see cref="CustomButtonSetting"/> class.
/// </summary>
/// <param name="id">The ID of the button.</param>
/// <param name="label">The setting's label.</param>
/// <param name="buttonText">The button text.</param>
/// <param name="holdTimeSeconds">The time to hold.</param>
/// <param name="hint">The hint to show.</param>
protected CustomButtonSetting(int? id, string label, string buttonText, float? holdTimeSeconds = null, string? hint = null)
: this(new SSButton(id, label, buttonText, holdTimeSeconds, hint))
{
}

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

/// <summary>
/// Gets the <see cref="TimeSpan"/> of the last press.
/// </summary>
public TimeSpan LastPress => Base.SyncLastPress.Elapsed;

/// <summary>
/// Gets or sets the text of the button.
/// </summary>
public string Text
{
get => Base.ButtonText;
set => Base.ButtonText = value;
}

/// <summary>
/// Gets or sets the amount of time to hold the button in seconds.
/// </summary>
public float HoldTime
{
get => Base.HoldTimeSeconds;
set => Base.HoldTimeSeconds = value;
}
}
}
58 changes: 58 additions & 0 deletions SecretAPI/Features/UserSettings/CustomDropdownSetting.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
namespace SecretAPI.Features.UserSettings
{
using global::UserSettings.ServerSpecific;
using SecretAPI.Interfaces;

/// <summary>
/// Custom <see cref="SSDropdownSetting"/> wrapper.
/// </summary>
public abstract class CustomDropdownSetting : CustomSetting, ISetting<SSDropdownSetting>
{
/// <summary>
/// Initializes a new instance of the <see cref="CustomDropdownSetting"/> class.
/// </summary>
/// <param name="setting">The base setting to create the wrapper with.</param>
protected CustomDropdownSetting(SSDropdownSetting setting)
: base(setting)
{
Base = setting;
}

/// <summary>
/// Initializes a new instance of the <see cref="CustomDropdownSetting"/> class.
/// </summary>
/// <param name="id">The ID of the setting.</param>
/// <param name="label">The setting's label.</param>
/// <param name="options">The array of string options to give.</param>
/// <param name="defaultOptionIndex">The default option (int index).</param>
/// <param name="entryType">The entry type.</param>
/// <param name="hint">The hint to show.</param>
protected CustomDropdownSetting(
int? id,
string label,
string[] options,
int defaultOptionIndex = 0,
SSDropdownSetting.DropdownEntryType entryType = SSDropdownSetting.DropdownEntryType.Regular,
string? hint = null)
: this(new SSDropdownSetting(id, label, options, defaultOptionIndex, entryType, hint))
{
}

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

/// <summary>
/// Gets or sets the options.
/// </summary>
public string[] Options
{
get => Base.Options;
set => Base.Options = value;
}

/// <summary>
/// Gets the selected option as string.
/// </summary>
public string SelectedOption => Base.SyncSelectionText;
}
}
35 changes: 35 additions & 0 deletions SecretAPI/Features/UserSettings/CustomHeader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace SecretAPI.Features.UserSettings
{
using global::UserSettings.ServerSpecific;
using SecretAPI.Interfaces;

/// <summary>
/// Wraps <see cref="SSGroupHeader"/>.
/// </summary>
public class CustomHeader : ISetting<SSGroupHeader>
{
/// <summary>
/// Initializes a new instance of the <see cref="CustomHeader"/> class.
/// </summary>
/// <param name="label">The label to show.</param>
/// <param name="reducedPadding">Reduced padding.</param>
/// <param name="hint">Hint displayed.</param>
public CustomHeader(string label, bool reducedPadding = false, string? hint = null)
{
Base = new SSGroupHeader(label, reducedPadding, hint);
}

/// <summary>
/// Gets a <see cref="CustomHeader"/> for Gameplay purposes.
/// </summary>
public static CustomHeader Gameplay { get; } = new("Gameplay");

/// <summary>
/// Gets a <see cref="CustomHeader"/> for Example purposes.
/// </summary>
public static CustomHeader Examples { get; } = new("Examples");

/// <inheritdoc />
public SSGroupHeader Base { get; }
}
}
43 changes: 43 additions & 0 deletions SecretAPI/Features/UserSettings/CustomKeybindSetting.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace SecretAPI.Features.UserSettings
{
using global::UserSettings.ServerSpecific;
using SecretAPI.Interfaces;
using UnityEngine;

/// <summary>
/// Wrapper for <see cref="SSKeybindSetting"/>.
/// </summary>
public abstract class CustomKeybindSetting : CustomSetting, ISetting<SSKeybindSetting>
{
/// <summary>
/// Initializes a new instance of the <see cref="CustomKeybindSetting"/> class.
/// </summary>
/// <param name="setting">The setting to wrap.</param>
protected CustomKeybindSetting(SSKeybindSetting setting)
: base(setting)
{
Base = setting;
}

/// <summary>
/// Initializes a new instance of the <see cref="CustomKeybindSetting"/> class.
/// </summary>
/// <param name="id">The ID of the setting.</param>
/// <param name="label">The setting's label.</param>
/// <param name="suggestedKey">The suggested key.</param>
/// <param name="preventInteractionOnGui">Whether to prevent interaction in a GUI.</param>
/// <param name="hint">The hint to show.</param>
protected CustomKeybindSetting(
int? id,
string label,
KeyCode suggestedKey = KeyCode.None,
bool preventInteractionOnGui = true,
string? hint = null)
: this(new SSKeybindSetting(id, label, suggestedKey, preventInteractionOnGui, hint))
{
}

/// <inheritdoc/>
public new SSKeybindSetting Base { get; }
}
}
81 changes: 81 additions & 0 deletions SecretAPI/Features/UserSettings/CustomPlainTextSetting.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
namespace SecretAPI.Features.UserSettings
{
using global::UserSettings.ServerSpecific;
using SecretAPI.Interfaces;
using TMPro;

/// <summary>
/// Wrapper for <see cref="SSPlaintextSetting" />.
/// </summary>
public abstract class CustomPlainTextSetting : CustomSetting, ISetting<SSPlaintextSetting>
{
/// <summary>
/// Initializes a new instance of the <see cref="CustomPlainTextSetting"/> class.
/// </summary>
/// <param name="setting">The setting to create wrapper from.</param>
protected CustomPlainTextSetting(SSPlaintextSetting setting)
: base(setting)
{
Base = setting;
}

/// <summary>
/// Initializes a new instance of the <see cref="CustomPlainTextSetting"/> class.
/// </summary>
/// <param name="id">The ID of the setting.</param>
/// <param name="label">The setting's label.</param>
/// <param name="placeholder">The placeholder to use for the setting.</param>
/// <param name="characterLimit">The max allowed characters.</param>
/// <param name="contentType">The content type.</param>
/// <param name="hint">The hint to display for the setting.</param>
protected CustomPlainTextSetting(
int? id,
string label,
string placeholder = "...",
int characterLimit = 64,
TMP_InputField.ContentType contentType = TMP_InputField.ContentType.Standard,
string? hint = null)
: this(new SSPlaintextSetting(id, label, placeholder, characterLimit, contentType, hint))
{
}

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

/// <summary>
/// Gets or sets the synced input text.
/// </summary>
public string InputText
{
get => Base.SyncInputText;
set => Base.SyncInputText = value;
}

/// <summary>
/// Gets or sets the content type.
/// </summary>
public TMP_InputField.ContentType ContentType
{
get => Base.ContentType;
set => Base.ContentType = value;
}

/// <summary>
/// Gets or sets the placeholder.
/// </summary>
public string Placeholder
{
get => Base.Placeholder;
set => Base.Placeholder = value;
}

/// <summary>
/// Gets or sets the character limit.
/// </summary>
public int CharacterLimit
{
get => Base.CharacterLimit;
set => Base.CharacterLimit = value;
}
}
}
Loading