diff --git a/Content.Client/Consent/UI/Windows/ConsentWindow.xaml b/Content.Client/Consent/UI/Windows/ConsentWindow.xaml
index 09d31a88cdf..11803c5e4c8 100644
--- a/Content.Client/Consent/UI/Windows/ConsentWindow.xaml
+++ b/Content.Client/Consent/UI/Windows/ConsentWindow.xaml
@@ -31,33 +31,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
+
diff --git a/Content.Client/Consent/UI/Windows/ConsentWindow.xaml.cs b/Content.Client/Consent/UI/Windows/ConsentWindow.xaml.cs
index 3e19c97354e..3a8bceccd67 100644
--- a/Content.Client/Consent/UI/Windows/ConsentWindow.xaml.cs
+++ b/Content.Client/Consent/UI/Windows/ConsentWindow.xaml.cs
@@ -2,9 +2,7 @@
using Content.Shared.CCVar;
using Content.Shared.Consent;
using Robust.Client.AutoGenerated;
-using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
-using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
@@ -17,15 +15,16 @@ public sealed partial class ConsentWindow : FancyWindow
{
[Dependency] private readonly IClientConsentManager _consentManager = default!;
[Dependency] private readonly IConfigurationManager _configManager = default!;
-
- private ButtonGroup Example1Buttons;
+ [Dependency] private readonly IPrototypeManager _protoManager = default!;
+ private readonly List _entries = new();
public ConsentWindow()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
- SaveConsentSettings.OnPressed += _ => {
+ SaveConsentSettings.OnPressed += _ =>
+ {
SaveConsentSettings.Disabled = true;
_consentManager.UpdateConsent(GetSettings());
};
@@ -36,12 +35,6 @@ public ConsentWindow()
ConsentFreetext.Placeholder = new Rope.Leaf(Loc.GetString("consent-window-freetext-placeholder"));
ConsentFreetext.OnTextChanged += _ => UnsavedChanges();
-
- Example1Buttons = new ButtonGroup();
- ConsentToggleExample1On.Group = Example1Buttons;
- ConsentToggleExample1On.OnToggled += _ => UnsavedChanges();
- ConsentToggleExample1Off.Group = Example1Buttons;
- ConsentToggleExample1Off.OnToggled += _ => UnsavedChanges();
}
private PlayerConsentSettings GetSettings()
@@ -49,9 +42,10 @@ private PlayerConsentSettings GetSettings()
var text = Rope.Collapse(ConsentFreetext.TextRope);
var toggles = new Dictionary, string>();
- if (Example1Buttons.Pressed == ConsentToggleExample1On)
+ foreach (var entry in _entries)
{
- toggles["Example1"] = "on";
+ if (entry.Button != null && entry.Button.Pressed)
+ toggles[entry.Consent.ID] = "on";
}
return new(text, toggles);
@@ -76,26 +70,96 @@ private void UnsavedChanges()
SaveConsentSettings.Disabled = false;
}
- public void UpdateUi()
+ private void AddConsentEntry(ConsentTogglePrototype prototype)
{
- var consent = _consentManager.GetConsent();
+ var state = new EntryState { Consent = prototype };
- ConsentToggleExample1Off.Pressed = true;
+ var container = new BoxContainer { Orientation = BoxContainer.LayoutOrientation.Vertical };
- ConsentFreetext.TextRope = new Rope.Leaf(consent.Freetext);
+ var header = new BoxContainer
+ {
+ Orientation = BoxContainer.LayoutOrientation.Horizontal,
+ Margin = new Thickness(5f, 5f)
+ };
+
+ var name = new Label
+ {
+ Text = Loc.GetString($"consent-{prototype.ID}-name"),
+ HorizontalExpand = true
+ };
+
+ var buttonOff = new Button { Text = "Off" };
+ buttonOff.StyleClasses.Add("OpenRight");
+ buttonOff.Pressed = true;
+
+ var buttonOn = new Button { Text = "On" };
+ buttonOn.StyleClasses.Add("OpenLeft");
+ state.Button = buttonOn;
+
+ buttonOff.OnPressed += _ => ButtonOnPress(buttonOff, buttonOn);
+ buttonOn.OnPressed += _ => ButtonOnPress(buttonOn, buttonOff);
+
+ var consent = _consentManager.GetConsent();
foreach (var toggle in consent.Toggles)
{
- if (toggle.Key == "Example1" && toggle.Value == "on")
+ if (toggle.Key == prototype.ID && toggle.Value == "on")
{
- ConsentToggleExample1On.Pressed = true;
- }
- else
- {
- throw new InvalidOperationException("Invalid consent toggle");
+ buttonOn.Pressed = true;
+ buttonOff.Pressed = false;
+ continue;
}
}
+ header.AddChild(name);
+ header.AddChild(buttonOff);
+ header.AddChild(buttonOn);
+
+ container.AddChild(header);
+
+ var desc = new Label
+ {
+ Text = Loc.GetString($"consent-{prototype.ID}-desc"),
+ };
+
+ container.AddChild(desc);
+
+ var wrapper = new PanelContainer();
+ wrapper.StyleClasses.Add("PdaBorderRect");
+
+ wrapper.AddChild(container);
+ ConsentList.AddChild(wrapper);
+
+ _entries.Add(state);
+ }
+
+ private void ButtonOnPress(Button currentButton, Button otherbutton)
+ {
+ currentButton.Pressed = true;
+ otherbutton.Pressed = false;
+ UnsavedChanges();
+ }
+
+ public void UpdateUi()
+ {
+ var consent = _consentManager.GetConsent();
+
+ ConsentFreetext.TextRope = new Rope.Leaf(consent.Freetext);
+
+ if (ConsentList.ChildCount > 0)
+ ConsentList.RemoveAllChildren();
+ _entries.Clear();
+
+ var consentprototypelist = _protoManager.EnumeratePrototypes();
+ foreach (var prototype in consentprototypelist)
+ AddConsentEntry(prototype);
+
SaveConsentSettings.Disabled = true;
SaveLabel.Text = "";
}
+
+ private struct EntryState
+ {
+ public ConsentTogglePrototype Consent;
+ public Button? Button;
+ }
}
diff --git a/Content.Shared/Consent/ConsentTogglePrototype.cs b/Content.Shared/Consent/ConsentTogglePrototype.cs
index f5eb697ecc4..dae7d98f933 100644
--- a/Content.Shared/Consent/ConsentTogglePrototype.cs
+++ b/Content.Shared/Consent/ConsentTogglePrototype.cs
@@ -10,10 +10,4 @@ public sealed partial class ConsentTogglePrototype : IPrototype
{
[IdDataField]
public string ID { get; private set; } = default!;
-
- ///
- /// The name that will show in UI. Must be loc string.
- ///
- [DataField]
- public string Name = default!;
}
diff --git a/Resources/Locale/en-US/Blep/consent.ftl b/Resources/Locale/en-US/Blep/consent.ftl
index d630ae65945..be26d55de7b 100644
--- a/Resources/Locale/en-US/Blep/consent.ftl
+++ b/Resources/Locale/en-US/Blep/consent.ftl
@@ -18,5 +18,5 @@ consent-examine-verb = Consent Info
consent-examine-not-set = This player has no consent preferences set. Ask for consent first before engaging in any erotic roleplay.
# Consent toggles
-consent-example1 = Example Consent Toggle
-consent-example1-desc = This is just here as an example for how to add consent toggles.
+consent-Example-name = Example Consent Toggle
+consent-Example-desc = This is just here as an example for how to add consent toggles.
diff --git a/Resources/Prototypes/Consent/examples.yml b/Resources/Prototypes/Consent/examples.yml
deleted file mode 100644
index d0b749c3da6..00000000000
--- a/Resources/Prototypes/Consent/examples.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-- type: consentToggle
- id: Example1
- name: consent-example1
diff --git a/Resources/Prototypes/consent.yml b/Resources/Prototypes/consent.yml
new file mode 100644
index 00000000000..9c1d59f2c1a
--- /dev/null
+++ b/Resources/Prototypes/consent.yml
@@ -0,0 +1,2 @@
+# - type: consentToggle
+# id: Example