mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-01 08:37:26 +00:00
74 lines
1.9 KiB
C#
74 lines
1.9 KiB
C#
using Content.Shared._CD.Records;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Client.Lobby.UI;
|
|
|
|
public sealed partial class HumanoidProfileEditor
|
|
{
|
|
private bool _allowFlavorText;
|
|
|
|
private FlavorText.FlavorText? _flavorText;
|
|
private TextEdit? _flavorTextEdit;
|
|
|
|
/// <summary>
|
|
/// Refreshes the flavor text editor status.
|
|
/// </summary>
|
|
public void RefreshFlavorText()
|
|
{
|
|
if (_allowFlavorText)
|
|
{
|
|
if (_flavorText != null)
|
|
return;
|
|
|
|
_flavorText = new FlavorText.FlavorText();
|
|
TabContainer.AddChild(_flavorText);
|
|
TabContainer.SetTabTitle(TabContainer.ChildCount - 1, Loc.GetString("humanoid-profile-editor-flavortext-tab"));
|
|
_flavorTextEdit = _flavorText.CFlavorTextInput;
|
|
|
|
_flavorText.OnFlavorTextChanged += OnFlavorTextChange;
|
|
}
|
|
else
|
|
{
|
|
if (_flavorText == null)
|
|
return;
|
|
|
|
TabContainer.RemoveChild(_flavorText);
|
|
_flavorText.OnFlavorTextChanged -= OnFlavorTextChange;
|
|
_flavorText.Dispose();
|
|
_flavorTextEdit?.Dispose();
|
|
_flavorTextEdit = null;
|
|
_flavorText = null;
|
|
}
|
|
}
|
|
|
|
private void OnFlavorTextChange(string content)
|
|
{
|
|
if (Profile is null)
|
|
return;
|
|
|
|
Profile = Profile.WithFlavorText(content);
|
|
SetDirty();
|
|
}
|
|
|
|
private void UpdateFlavorTextEdit()
|
|
{
|
|
if (_flavorTextEdit != null)
|
|
{
|
|
_flavorTextEdit.TextRope = new Rope.Leaf(Profile?.FlavorText ?? "");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Start CD - Character Records
|
|
private void UpdateProfileRecords(PlayerProvidedCharacterRecords records)
|
|
{
|
|
if (Profile is null)
|
|
return;
|
|
Profile = Profile.WithCDCharacterRecords(records);
|
|
IsDirty = true;
|
|
}
|
|
// End CD - Character Records
|
|
}
|