Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Character Consent Menu #162

Closed
wants to merge 13 commits into from
12 changes: 12 additions & 0 deletions Content.Client/Floof/CharConsent/UI/Windows/ConsentText.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<controls:FancyWindow
xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
MinSize="620 670"
Title="CConsentText"
Resizable="False">
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
<TextEdit Name="CConsentTextInput" Access="Public" MinSize="220 100" Margin="10" HorizontalExpand="True" VerticalExpand="True" />
</BoxContainer>
</controls:FancyWindow>
28 changes: 28 additions & 0 deletions Content.Client/Floof/CharConsent/UI/Windows/ConsentText.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Content.Client.UserInterface.Controls;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Utility;

namespace Content.Client.Floof.CharConsent.UI.Windows
{
[GenerateTypedNameReferences]
public sealed partial class ConsentText : FancyWindow
{
public Action<string>? OnConsentTextChanged;

public ConsentText()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

var loc = IoCManager.Resolve<ILocalizationManager>();
CConsentTextInput.Placeholder = new Rope.Leaf(loc.GetString("consent-text-placeholder"));
CConsentTextInput.OnKeyBindDown += _ => ConsentTextChanged();
}

public void ConsentTextChanged()
{
OnConsentTextChanged?.Invoke(Rope.Collapse(CConsentTextInput.TextRope).Trim());
}
}
}
30 changes: 29 additions & 1 deletion Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Content.Client.Message;
using Content.Client.Players.PlayTimeTracking;
using Content.Client.Roles;
using Content.Client.Floof.CharConsent.UI.Windows; // Floof - Per-Character Consent
using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Systems.Guidebook;
using Content.Shared.CCVar;
Expand Down Expand Up @@ -56,6 +57,7 @@ public sealed partial class HumanoidProfileEditor : BoxContainer
private LineEdit _ageEdit => CAgeEdit;
private LineEdit _nameEdit => CNameEdit;
private TextEdit? _flavorTextEdit;
private TextEdit? _consentTextEdit; // Floof - Per-Character Consent
private Button _nameRandomButton => CNameRandomize;
private Button _randomizeEverythingButton => CRandomizeEverything;
private RichTextLabel _warningLabel => CWarningLabel;
Expand Down Expand Up @@ -564,7 +566,7 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt

#endregion Markings

#region FlavorText
#region FlavorText

if (configurationManager.GetCVar(CCVars.FlavorText))
{
Expand All @@ -577,6 +579,18 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt

#endregion FlavorText

// Floof - Per-Character Consent
#region ConsentText

var consentText = new ConsentText();
_tabContainer.AddChild(consentText);
_tabContainer.SetTabTitle(_tabContainer.ChildCount - 1, Loc.GetString("humanoid-profile-editor-consenttext-tab"));
_consentTextEdit = consentText.CConsentTextInput;

consentText.OnConsentTextChanged += OnConsentTextChange;

#endregion ConsentText

#region Dummy

_previewRotateLeftButton.OnPressed += _ =>
Expand Down Expand Up @@ -821,7 +835,14 @@ private void OnFlavorTextChange(string content)
Profile = Profile.WithFlavorText(content);
IsDirty = true;
}
private void OnConsentTextChange(string content) // Floof - Per-Character Consent
{
if (Profile is null)
return;

Profile = Profile.WithConsentText(content);
IsDirty = true;
}
private void OnMarkingChange(MarkingSet markings)
{
if (Profile is null)
Expand Down Expand Up @@ -1045,6 +1066,12 @@ private void UpdateFlavorTextEdit()
_flavorTextEdit.TextRope = new Rope.Leaf(Profile?.FlavorText ?? "");
}

private void UpdateConsentTextEdit() // Floof - Per-Character Consent
{
if (_consentTextEdit != null)
_consentTextEdit.TextRope = new Rope.Leaf(Profile?.ConsentText ?? "");
}

private void UpdateAgeEdit()
{
_ageEdit.Text = Profile?.Age.ToString() ?? "";
Expand Down Expand Up @@ -1340,6 +1367,7 @@ public void UpdateControls()

UpdateNameEdit();
UpdateFlavorTextEdit();
UpdateConsentTextEdit();
UpdateSexControls();
UpdateGenderControls();
UpdateSkinColor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private static HumanoidCharacterProfile CharlieCharlieson()
"Charlie Charlieson",
"The biggest boy around.",
"Human",
"Everything",
1,
1,
21,
Expand Down
Loading
Loading