mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
more stuff
This commit is contained in:
1 parent
57bab258e5
commit
8b2d24ccc1
8 files changed
+46
-57
No files matched your search
@@ -10,68 +10,37 @@ namespace MiraAPI.Example;
|
||||
public class ExampleLocalSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
{
|
||||
public override string TabName => "Mira Example";
|
||||
protected override bool ShouldCreateLabels => false;
|
||||
|
||||
public override LocalSettingTabAppearance TabAppearance => new()
|
||||
{
|
||||
TabColor = Color.cyan,
|
||||
ToggleActiveColor = Color.blue,
|
||||
ToggleInactiveColor = Color.red,
|
||||
SliderHoverColor = Color.magenta,
|
||||
};
|
||||
|
||||
[LocalSliderSetting(min: 0, max: 15, suffixType: MiraNumberSuffixes.Multiplier)]
|
||||
public ConfigEntry<float> ExampleFloatEntry { get; private set; } = config.Bind("General", "Example Float Setting", 50f);
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ExampleToggle { get; private set; } = config.Bind("General", "Example Bool", true);
|
||||
|
||||
[LocalSettingToggle]
|
||||
public ConfigEntry<bool> PlayStartupSound { get; private set; } = config.Bind("Audio", "Play Startup Sound", true);
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ExampleToggle2 { get; private set; } = config.Bind("General", "Example Bool 2", false);
|
||||
|
||||
[LocalSettingToggle]
|
||||
public ConfigEntry<bool> MuteInBackground { get; private set; } = config.Bind("Audio", "Mute In Background", false);
|
||||
[LocalSliderSetting(suffixType: MiraNumberSuffixes.Percent, formatString: "0", roundValue: true)]
|
||||
public ConfigEntry<float> ExampleSlider { get; private set; } = config.Bind("General", "Slider", 50f);
|
||||
|
||||
[LocalSettingToggle]
|
||||
public ConfigEntry<bool> AutoSaveEnabled { get; private set; } = config.Bind("General", "Auto Save Enabled", true);
|
||||
|
||||
[LocalSettingToggle]
|
||||
public ConfigEntry<bool> EnableCloudSync { get; private set; } = config.Bind("General", "Enable Cloud Sync", false);
|
||||
|
||||
[LocalSettingToggle]
|
||||
public ConfigEntry<bool> ShowAdvancedTooltips { get; private set; } = config.Bind("UI", "Show Advanced Tooltips", true);
|
||||
|
||||
[LocalSettingToggle]
|
||||
public ConfigEntry<bool> CompactUI { get; private set; } = config.Bind("UI", "Compact UI Layout", false);
|
||||
|
||||
[LocalSettingToggle]
|
||||
public ConfigEntry<bool> EnableControllerSupport { get; private set; } = config.Bind("Input", "Enable Controller Support", true);
|
||||
|
||||
[LocalSettingToggle]
|
||||
public ConfigEntry<bool> EnableVibration { get; private set; } = config.Bind("Input", "Enable Controller Vibration", true);
|
||||
|
||||
[LocalSettingToggle]
|
||||
public ConfigEntry<bool> ShowPlayerNames { get; private set; } = config.Bind("Gameplay", "Show Player Names", true);
|
||||
|
||||
[LocalSettingToggle]
|
||||
public ConfigEntry<bool> EnableHardMode { get; private set; } = config.Bind("Gameplay", "Enable Hard Mode", false);
|
||||
[LocalSettingToggle]
|
||||
public ConfigEntry<bool> EnableHardMode2 { get; private set; } = config.Bind("Gameplay", "Enable Hard Mode", false);
|
||||
[LocalSettingToggle]
|
||||
public ConfigEntry<bool> EnableHardMode3 { get; private set; } = config.Bind("Gameplay", "Enable Hard Mode", false);
|
||||
[LocalSettingToggle]
|
||||
public ConfigEntry<bool> EnableHardMode4 { get; private set; } = config.Bind("Gameplay", "Enable Hard Mode", false);
|
||||
[LocalSettingToggle]
|
||||
public ConfigEntry<bool> EnableHardMode5 { get; private set; } = config.Bind("Gameplay", "Enable Hard Mode", false);
|
||||
|
||||
[LocalNumberSetting]
|
||||
public ConfigEntry<int> NumberExample { get; private set; } = config.Bind("Gameplay", "Number of cheeseburgers", 3);
|
||||
[LocalNumberSetting(suffixType: MiraNumberSuffixes.Seconds)]
|
||||
public ConfigEntry<int> ExampleNumber { get; private set; } = config.Bind("General", "Example Number", 4);
|
||||
|
||||
[LocalEnumSetting]
|
||||
public ConfigEntry<ExampleSettingEnum> EnumExample { get; private set; } = config.Bind("Gameplay", "Anything else", ExampleSettingEnum.Fries);
|
||||
public ConfigEntry<ExampleEnumSetting> ExampleEnum { get; private set; } = config.Bind("General", "Example Enum", ExampleEnumSetting.Fries);
|
||||
}
|
||||
|
||||
public enum ExampleSettingEnum
|
||||
public enum ExampleEnumSetting
|
||||
{
|
||||
Cheeseburger,
|
||||
Sandwich,
|
||||
Fries,
|
||||
OnionRings,
|
||||
ChickenNuggets,
|
||||
Gun,
|
||||
}
|
||||
|
||||
public class Tab1(ConfigFile config) : LocalSettingsTab(config) { public override string TabName => "Tab"; public override LocalSettingTabAppearance TabAppearance => new(); }
|
||||
|
||||
@@ -19,6 +19,7 @@ public class LocalSliderSettingAttribute(
|
||||
float min = 0,
|
||||
float max = 100,
|
||||
string? description = null,
|
||||
bool displayValue = false,
|
||||
string? formatString = null,
|
||||
bool roundValue = false,
|
||||
MiraNumberSuffixes suffixType = MiraNumberSuffixes.None
|
||||
@@ -27,6 +28,6 @@ public class LocalSliderSettingAttribute(
|
||||
/// <inheritdoc/>
|
||||
internal override LocalSliderSetting CreateSetting(Type tab, ConfigEntryBase configEntryBase)
|
||||
{
|
||||
return new LocalSliderSetting(tab, configEntryBase, name, description, new FloatRange(min, max), suffixType, formatString, roundValue);
|
||||
return new LocalSliderSetting(tab, configEntryBase, name, description, new FloatRange(min, max), displayValue, suffixType, formatString, roundValue);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -9,7 +9,7 @@ namespace MiraAPI.LocalSettings.Attributes;
|
||||
/// </summary>
|
||||
/// <inheritdoc/>
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class LocalSettingToggleAttribute(
|
||||
public class LocalToggleSettingAttribute(
|
||||
string? name = null,
|
||||
string? description = null
|
||||
) : LocalSettingAttribute(name, description)
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
@@ -40,7 +41,11 @@ public class LocalEnumSetting : LocalSettingBase<int>
|
||||
: base(tab, configEntry, name, description)
|
||||
{
|
||||
EnumType = enumType;
|
||||
Values = values ?? Enum.GetNames(EnumType);
|
||||
Values = values ?? Enum
|
||||
.GetValues(configEntry.SettingType)
|
||||
.Cast<Enum>()
|
||||
.Select(x => x.ToDisplayString())
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -58,6 +63,7 @@ public class LocalEnumSetting : LocalSettingBase<int>
|
||||
if (highlight != null)
|
||||
{
|
||||
highlight.color = Tab!.TabAppearance.EnumHoverColor;
|
||||
highlight.gameObject.SetActive(false);
|
||||
}
|
||||
toggleComp.Destroy();
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ public class LocalNumberSetting : LocalSettingBase<int>
|
||||
if (highlight != null)
|
||||
{
|
||||
highlight.color = Tab!.TabAppearance.NumberHoverColor;
|
||||
highlight.gameObject.SetActive(false);
|
||||
}
|
||||
toggleComp.Destroy();
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public abstract class LocalSettingBase<T> : ILocalSetting
|
||||
/// <returns>The value text.</returns>
|
||||
protected virtual string GetValueText()
|
||||
{
|
||||
return GetValue()?.ToString() ?? string.Empty;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -19,6 +19,11 @@ public class LocalSliderSetting : LocalSettingBase<float>
|
||||
/// </summary>
|
||||
public FloatRange SliderRange { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the value should be displayed next to name.
|
||||
/// </summary>
|
||||
public bool DisplayValue { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a format for the text to use to format the number.
|
||||
/// </summary>
|
||||
@@ -48,15 +53,17 @@ public class LocalSliderSetting : LocalSettingBase<float>
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
FloatRange? sliderRange = null,
|
||||
bool displayValue = false,
|
||||
MiraNumberSuffixes? suffixType = null,
|
||||
string? formatString = null,
|
||||
bool roundValue = false)
|
||||
: base(tab, configEntry, name, description)
|
||||
{
|
||||
SuffixType = suffixType ?? MiraNumberSuffixes.None;
|
||||
SliderRange = sliderRange ?? new FloatRange(0, 100);
|
||||
RoundValue = roundValue;
|
||||
DisplayValue = displayValue;
|
||||
SuffixType = suffixType ?? MiraNumberSuffixes.None;
|
||||
FormatString = formatString ?? "0.0";
|
||||
RoundValue = roundValue;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -80,7 +87,7 @@ public class LocalSliderSetting : LocalSettingBase<float>
|
||||
rollover.OutColor = Tab!.TabAppearance.SliderColor;
|
||||
rollover.OverColor = Tab!.TabAppearance.SliderHoverColor;
|
||||
newSlider.Title.transform.localPosition = new Vector3(0.5f, 0, -1f);
|
||||
newSlider.Title.horizontalAlignment = HorizontalAlignmentOptions.Right;
|
||||
newSlider.Title.horizontalAlignment = DisplayValue ? HorizontalAlignmentOptions.Left : HorizontalAlignmentOptions.Center;
|
||||
newSlider.Title.text = GetValueText();
|
||||
|
||||
newSlider.OnValueChange.AddListener((UnityAction)(() =>
|
||||
@@ -100,9 +107,14 @@ public class LocalSliderSetting : LocalSettingBase<float>
|
||||
/// <inheritdoc/>
|
||||
protected override string GetValueText()
|
||||
{
|
||||
var value = GetValue();
|
||||
var formated = Helpers.FormatValue(value, SuffixType, FormatString);
|
||||
var maxFormated = Helpers.FormatValue(SliderRange.max, SuffixType, FormatString);
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name}: <b>{formated} / {maxFormated}</font></b>";
|
||||
if (DisplayValue)
|
||||
{
|
||||
var value = GetValue();
|
||||
var formated = Helpers.FormatValue(value, SuffixType, FormatString);
|
||||
var maxFormated = Helpers.FormatValue(SliderRange.max, SuffixType, FormatString);
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name}: <b>{formated} / {maxFormated}</font></b>";
|
||||
}
|
||||
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name}</font></b>";
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,6 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
/// <summary>
|
||||
/// Gets whether the modifiers hud should be on the left side of the screen (under roles/task tab). Recommended for streamers.
|
||||
/// </summary>
|
||||
[LocalSettingToggle]
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ModifiersHudLeftSide { get; private set; } = config.Bind("Displays", "Show Modifiers HUD on Left Side", false);
|
||||
}
|
||||
Reference in new issue
Block a user