Skip to content

Commit

Permalink
Add richText bool to InputFieldConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Rune580 committed May 19, 2024
1 parent 85533ce commit 2031e8a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions RiskOfOptions/Components/Options/InputFieldController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class InputFieldController : ModSettingsControl<string>
public RooInputField inputField;
public InputFieldConfig.SubmitEnum submitOn;
public TMP_InputField.LineType lineType;
public bool richText;
public TMP_InputValidator validator;
public TMP_InputField.CharacterValidation characterValidation;

Expand Down Expand Up @@ -41,6 +42,8 @@ protected override void Awake()

if (!inputField)
return;

inputField.richText = richText;

var button = transform.Find("Text Preview").GetComponentInChildren<HGButton>();
button.onClick.RemoveAllListeners();
Expand Down
7 changes: 7 additions & 0 deletions RiskOfOptions/OptionConfigs/InputFieldConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ namespace RiskOfOptions.OptionConfigs
public class InputFieldConfig : BaseOptionConfig
{
public SubmitEnum submitOn = SubmitEnum.OnChar;

public TMP_InputField.LineType lineType = TMP_InputField.LineType.MultiLineSubmit;

/// <summary>
/// Sets the <see cref="TMP_InputField.richText"/> bool on the <see cref="TMP_InputField"/> of this option.
/// <remarks>Defaults to true for backwards compatibility sake</remarks>
/// </summary>
public bool richText = true;

/// <summary>
/// Defines how an input field should determine when to submit the changes.
Expand Down
1 change: 1 addition & 0 deletions RiskOfOptions/Options/StringInputFieldOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public override GameObject CreateOptionGameObject(GameObject prefab, Transform p

controller.submitOn = config.submitOn;
controller.lineType = config.lineType;
controller.richText = config.richText;
controller.characterValidation = TMP_InputField.CharacterValidation.None;

button.name = $"Mod Option Input Field, {Name}";
Expand Down

0 comments on commit 2031e8a

Please sign in to comment.