-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into ExperimantalLanguage
- Loading branch information
Showing
250 changed files
with
8,027 additions
and
1,684 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Content.Shared.Consent; | ||
using Robust.Shared.Network; | ||
|
||
namespace Content.Client.Consent; | ||
|
||
public sealed class ClientConsentManager : IClientConsentManager | ||
{ | ||
[Dependency] private readonly IClientNetManager _netManager = default!; | ||
|
||
// TODO: sync all players consent settings with ServerConsentManager, for client prediction | ||
private PlayerConsentSettings? _consent; | ||
|
||
public bool HasLoaded => _consent is not null; | ||
|
||
public event Action? OnServerDataLoaded; | ||
|
||
public void Initialize() | ||
{ | ||
_netManager.RegisterNetMessage<MsgUpdateConsent>(HandleUpdateConsent); | ||
} | ||
|
||
public void UpdateConsent(PlayerConsentSettings consentSettings) | ||
{ | ||
var msg = new MsgUpdateConsent | ||
{ | ||
Consent = consentSettings | ||
}; | ||
_netManager.ClientSendMessage(msg); | ||
} | ||
|
||
public PlayerConsentSettings GetConsent() | ||
{ | ||
if (_consent is null) | ||
throw new InvalidOperationException("Consent settings not loaded yet?"); | ||
|
||
return _consent; | ||
} | ||
|
||
private void HandleUpdateConsent(MsgUpdateConsent message) | ||
{ | ||
_consent = message.Consent; | ||
|
||
OnServerDataLoaded?.Invoke(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using Content.Shared.Consent; | ||
|
||
namespace Content.Client.Consent; | ||
|
||
public sealed class ConsentSystem : SharedConsentSystem | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Content.Shared.Consent; | ||
|
||
namespace Content.Client.Consent; | ||
|
||
public interface IClientConsentManager | ||
{ | ||
event Action OnServerDataLoaded; | ||
bool HasLoaded { get; } | ||
|
||
void Initialize(); | ||
void UpdateConsent(PlayerConsentSettings consentSettings); | ||
PlayerConsentSettings GetConsent(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using Content.Client.Consent.UI.Windows; | ||
using Content.Client.Gameplay; | ||
using Content.Client.UserInterface.Controls; | ||
using Content.Client.UserInterface.Systems.MenuBar.Widgets; | ||
using Content.Shared.Input; | ||
using Robust.Client.Input; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controllers; | ||
using Robust.Client.UserInterface.Controllers.Implementations; | ||
using Robust.Shared.Input.Binding; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Player; | ||
using Robust.Shared.Utility; | ||
using JetBrains.Annotations; | ||
using static Robust.Client.UserInterface.Controls.BaseButton; | ||
|
||
namespace Content.Client.Consent.UI; | ||
|
||
[UsedImplicitly] | ||
public sealed class ConsentUiController : UIController, IOnStateChanged<GameplayState> | ||
{ | ||
[Dependency] private readonly IInputManager _input = default!; | ||
|
||
private ConsentWindow? _window; | ||
|
||
private MenuButton? ConsentButton => UIManager.GetActiveUIWidgetOrNull<GameTopMenuBar>()?.ConsentButton; | ||
|
||
public void OnStateEntered(GameplayState state) | ||
{ | ||
EnsureWindow(); | ||
|
||
_input.SetInputCommand(ContentKeyFunctions.OpenConsentWindow, | ||
InputCmdHandler.FromDelegate(_ => ToggleWindow())); | ||
} | ||
|
||
public void OnStateExited(GameplayState state) | ||
{ | ||
if (_window != null) | ||
{ | ||
_window.Dispose(); | ||
_window = null; | ||
} | ||
} | ||
|
||
public void UnloadButton() | ||
{ | ||
if (ConsentButton == null) | ||
{ | ||
return; | ||
} | ||
|
||
ConsentButton.OnPressed -= ConsentButtonPressed; | ||
} | ||
|
||
public void LoadButton() | ||
{ | ||
if (ConsentButton == null) | ||
{ | ||
return; | ||
} | ||
|
||
ConsentButton.OnPressed += ConsentButtonPressed; | ||
} | ||
|
||
private void ConsentButtonPressed(ButtonEventArgs args) | ||
{ | ||
ToggleWindow(); | ||
} | ||
|
||
private void EnsureWindow() | ||
{ | ||
if (_window is { Disposed: false }) | ||
return; | ||
|
||
_window = UIManager.CreateWindow<ConsentWindow>(); | ||
_window.OnOpen += () => { | ||
if (ConsentButton is not null) | ||
ConsentButton.Pressed = true; | ||
}; | ||
_window.OnClose += () => { | ||
if (ConsentButton is not null) | ||
ConsentButton.Pressed = false; | ||
_window.UpdateUi(); // Discard unsaved changes | ||
}; | ||
} | ||
|
||
private void ToggleWindow() | ||
{ | ||
if (_window is null) | ||
return; | ||
|
||
UIManager.ClickSound(); | ||
if (_window.IsOpen != true) | ||
{ | ||
_window.OpenCentered(); | ||
} | ||
else | ||
{ | ||
_window.Close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<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="{Loc consent-window-title}" | ||
Resizable="False"> | ||
<BoxContainer Orientation="Vertical" HorizontalExpand="True" Margin="5"> | ||
<Label Text="{Loc consent-window-text}" /> | ||
<BoxContainer Orientation="Horizontal" Margin="5"> | ||
<Label Name="SaveLabel" FontColorOverride="Red" Access="Public" /> | ||
<Control HorizontalExpand="True" /> | ||
<Button | ||
Name="SaveConsentSettings" | ||
Access="Public" | ||
Text="Save" | ||
Disabled="True" /> | ||
</BoxContainer> | ||
<Label Text="{Loc consent-window-freetext-label}" /> | ||
<PanelContainer HorizontalExpand="True" VerticalExpand="True" MinWidth="200"> | ||
<PanelContainer.PanelOverride> | ||
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" /> | ||
</PanelContainer.PanelOverride> | ||
<TextEdit | ||
Name="ConsentFreetext" | ||
Access="Public" | ||
MinHeight="100" | ||
VerticalExpand="True" /> | ||
</PanelContainer> | ||
<Control MinSize="0 10" /> | ||
<Label Text="{Loc consent-window-toggles-label}" /> | ||
|
||
<!-- TODO: Generate these in code by iterating prototypes? --> | ||
<!-- Example Consent Toggle --> | ||
<PanelContainer HorizontalExpand="True" MinWidth="200"> | ||
<PanelContainer.PanelOverride> | ||
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" /> | ||
</PanelContainer.PanelOverride> | ||
<BoxContainer Orientation="Vertical" HorizontalExpand="True" Margin="5"> | ||
<BoxContainer Orientation="Horizontal" Margin="5"> | ||
<Label Text="{Loc consent-example1}" /> | ||
<Control HorizontalExpand="True" /> | ||
<Button | ||
Name="ConsentToggleExample1Off" | ||
ToggleMode="True" | ||
Access="Public" | ||
Text="Off" | ||
StyleClasses="OpenRight" /> | ||
<Button | ||
Name="ConsentToggleExample1On" | ||
ToggleMode="True" | ||
Access="Public" | ||
Text="On" | ||
StyleClasses="OpenLeft" /> | ||
</BoxContainer> | ||
<Label Text="{Loc consent-example1-desc}" /> | ||
</BoxContainer> | ||
</PanelContainer> | ||
|
||
|
||
</BoxContainer> | ||
</controls:FancyWindow> |
101 changes: 101 additions & 0 deletions
101
Content.Client/Consent/UI/Windows/ConsentWindow.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using Content.Client.UserInterface.Controls; | ||
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; | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Client.Consent.UI.Windows; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class ConsentWindow : FancyWindow | ||
{ | ||
[Dependency] private readonly IClientConsentManager _consentManager = default!; | ||
[Dependency] private readonly IConfigurationManager _configManager = default!; | ||
|
||
private ButtonGroup Example1Buttons; | ||
|
||
public ConsentWindow() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
|
||
SaveConsentSettings.OnPressed += _ => { | ||
SaveConsentSettings.Disabled = true; | ||
_consentManager.UpdateConsent(GetSettings()); | ||
}; | ||
|
||
_consentManager.OnServerDataLoaded += UpdateUi; | ||
if (_consentManager.HasLoaded) | ||
UpdateUi(); | ||
|
||
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() | ||
{ | ||
var text = Rope.Collapse(ConsentFreetext.TextRope); | ||
var toggles = new Dictionary<ProtoId<ConsentTogglePrototype>, string>(); | ||
|
||
if (Example1Buttons.Pressed == ConsentToggleExample1On) | ||
{ | ||
toggles["Example1"] = "on"; | ||
} | ||
|
||
return new(text, toggles); | ||
} | ||
|
||
private void UnsavedChanges() | ||
{ | ||
// Validate freetext length | ||
var maxLength = _configManager.GetCVar(CCVars.ConsentFreetextMaxLength); | ||
var length = Rope.Collapse(ConsentFreetext.TextRope).Length; | ||
|
||
if (length > maxLength) | ||
{ | ||
SaveLabel.Text = Loc.GetString("consent-window-char-limit-warning", ("length", length), ("maxLength", maxLength)); | ||
SaveConsentSettings.Disabled = true; | ||
|
||
return; | ||
} | ||
|
||
// If everything is valid, enable save button and inform user they need to save. | ||
SaveLabel.Text = Loc.GetString("consent-window-unsaved-changes"); | ||
SaveConsentSettings.Disabled = false; | ||
} | ||
|
||
public void UpdateUi() | ||
{ | ||
var consent = _consentManager.GetConsent(); | ||
|
||
ConsentToggleExample1Off.Pressed = true; | ||
|
||
ConsentFreetext.TextRope = new Rope.Leaf(consent.Freetext); | ||
foreach (var toggle in consent.Toggles) | ||
{ | ||
if (toggle.Key == "Example1" && toggle.Value == "on") | ||
{ | ||
ConsentToggleExample1On.Pressed = true; | ||
} | ||
else | ||
{ | ||
throw new InvalidOperationException("Invalid consent toggle"); | ||
} | ||
} | ||
|
||
SaveConsentSettings.Disabled = true; | ||
SaveLabel.Text = ""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
Content.Client/DeltaV/CartridgeLoader/Cartridges/SecWatchEntryControl.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<BoxContainer xmlns="https://spacestation14.io" | ||
xmlns:cartridges="clr-namespace:Content.Client.DeltaV.CartridgeLoader.Cartridges" | ||
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls" | ||
HorizontalExpand="True" | ||
VerticalExpand="True" | ||
Margin="5"> | ||
<!-- All labels populated in constructor --> | ||
<BoxContainer Orientation="Horizontal" HorizontalAlignment="Left"> | ||
<BoxContainer Orientation="Vertical"> | ||
<Label Name="Status"/> | ||
<Label Text="{Loc 'criminal-records-console-reason'}"/> | ||
</BoxContainer> | ||
<customControls:VSeparator StyleClasses="LowDivider" Margin="8 0"/> | ||
<BoxContainer Orientation="Vertical"> | ||
<Label Name="Title"/> | ||
<Label Name="Reason"/> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</BoxContainer> |
Oops, something went wrong.