Skip to content

Commit

Permalink
update text entry buttons to have new value
Browse files Browse the repository at this point in the history
  • Loading branch information
misternebula committed Oct 10, 2024
1 parent 7d2f751 commit 5d8c06f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/OWML.Common/Interfaces/Menus/IOWMLTextEntryElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,15 @@ public interface IOWMLTextEntryElement : IOWMLMenuValueOption
public event TextEntryConfirmEvent OnConfirmEntry;

public string GetInputText();

/// <summary>
/// Sets the text that is displayed without updating the underlying option value.
/// </summary>
public void SetText(string text);

/// <summary>
/// Sets the underlying option value to the text, and updates the displayed text.
/// </summary>
public void SetCurrentValue(string text);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ public string GetInputText()
return _popup.GetInputText();
}

public void SetCurrentValue(string text)
public void SetText(string text)
{
gameObject.GetComponentsInChildren<MenuOption>().First(x => x != this)._label.text = text;
}

public void SetCurrentValue(string text)
{
SetText(text);
_popup.GetInputField().text = text;
OnConfirmEntry();
}
Expand Down
2 changes: 2 additions & 0 deletions src/OWML.ModHelper.Menus/NewMenuSystem/MenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ void SaveConfig()
mod.ModHelper.Config.SetSettingsValue(name, newValue);
mod.ModHelper.Storage.Save(mod.ModHelper.Config, Constants.ModConfigFileName);
mod.Configure(mod.ModHelper.Config);
textInput.SetText(newValue);
};
break;
case SettingType.NUMBER:
Expand All @@ -338,6 +339,7 @@ void SaveConfig()
mod.ModHelper.Config.SetSettingsValue(name, newValue);
mod.ModHelper.Storage.Save(mod.ModHelper.Config, Constants.ModConfigFileName);
mod.Configure(mod.ModHelper.Config);
numberInput.SetText(newValue.ToString());
};
break;
default:
Expand Down

0 comments on commit 5d8c06f

Please sign in to comment.