-
Notifications
You must be signed in to change notification settings - Fork 15
PORT: Adds Pinky Text #96
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| using Content.Shared._DVA.DVCustomObjectiveSummary; | ||
| using Robust.Client.UserInterface.Controllers; | ||
| using Robust.Shared.Network; | ||
|
|
||
| namespace Content.Client._DVA.DVCustomObjectiveSummary; | ||
|
|
||
| public sealed class DVCustomObjectiveSummaryUIController : UIController | ||
| { | ||
| [Dependency] private readonly IClientNetManager _net = default!; | ||
|
|
||
| private DVCustomObjectiveSummaryWindow? _window; | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
| SubscribeNetworkEvent<DVCustomObjectiveSummaryOpenMessage>(OnDVCustomObjectiveSummaryOpen); | ||
| } | ||
|
|
||
| private void OnDVCustomObjectiveSummaryOpen(DVCustomObjectiveSummaryOpenMessage msg, EntitySessionEventArgs args) | ||
| { | ||
| OpenWindow(); | ||
| } | ||
|
|
||
| public void OpenWindow() | ||
| { | ||
| // If a window is already open, close it | ||
| _window?.Close(); | ||
|
|
||
| _window = new DVCustomObjectiveSummaryWindow(); | ||
| _window.OpenCentered(); | ||
| _window.OnClose += () => _window = null; | ||
| _window.OnSubmitted += OnFeedbackSubmitted; | ||
| } | ||
|
|
||
| private void OnFeedbackSubmitted(string args) | ||
| { | ||
| var msg = new DVCustomObjectiveClientSetObjective | ||
| { | ||
| Summary = args, | ||
| }; | ||
| _net.ClientSendMessage(msg); | ||
| _window?.Close(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <controls:FancyWindow xmlns="https://spacestation14.io" | ||
| xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
| Title="{Loc 'custom-objective-window-title'}" | ||
| MinSize="300 250" | ||
| SetSize="550 370"> | ||
| <BoxContainer Orientation="Vertical" Margin="10 10 20 0"> | ||
| <Label HorizontalAlignment="Center" Text="{Loc 'custom-objective-window-explain'}" /> | ||
| <TextEdit Name="ObjectiveSummaryTextEdit" MaxHeight="500" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" MinHeight="200" /> | ||
| <Label Name="CharacterLimitLabel" HorizontalAlignment="Center" StyleClasses="LabelSmall"/> | ||
| <Label HorizontalAlignment="Center" Text="{Loc 'custom-objective-window-explain-edit'}" /> | ||
| <controls:ConfirmButton Name="SubmitButton" ConfirmationText="{Loc 'custom-objective-window-submit-button-text-confirm'}" Text="{Loc 'custom-objective-window-submit-button-text'}" Margin="0 10 0 10" /> | ||
| </BoxContainer> | ||
| </controls:FancyWindow> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| using Content.Client.UserInterface.Controls; | ||
| using Content.Shared._DVA.DCCVars; | ||
|
Check failure on line 2 in Content.Client/_DVA/DVCustomObjectiveSummary/DVCustomObjectiveSummaryWindow.xaml.cs
|
||
| using Content.Shared.Mind; | ||
| using Robust.Client.AutoGenerated; | ||
| using Robust.Client.Player; | ||
| using Robust.Client.UserInterface.XAML; | ||
| using Robust.Shared.Configuration; | ||
| using Robust.Shared.Utility; | ||
|
|
||
| namespace Content.Client._DVA.DVCustomObjectiveSummary; | ||
|
|
||
| [GenerateTypedNameReferences] | ||
| public sealed partial class DVCustomObjectiveSummaryWindow : FancyWindow | ||
| { | ||
| [Dependency] private readonly IPlayerManager _players = default!; | ||
| [Dependency] private readonly IEntityManager _entity = default!; | ||
| [Dependency] private readonly IConfigurationManager _cfg = default!; | ||
|
|
||
| private SharedMindSystem? _mind; | ||
|
|
||
| // Maximum length the summary can be in characters. | ||
| private int _maxLengthSummaryLength; | ||
|
|
||
| public event Action<string>? OnSubmitted; | ||
|
|
||
| public DVCustomObjectiveSummaryWindow() | ||
| { | ||
| RobustXamlLoader.Load(this); | ||
| IoCManager.InjectDependencies(this); | ||
|
|
||
| _cfg.OnValueChanged(DCCVars.MaxObjectiveSummaryLength, len => | ||
| { | ||
| _maxLengthSummaryLength = len; | ||
| UpdateWordCount(); | ||
| }, | ||
| invokeImmediately: true); | ||
|
|
||
|
|
||
| SubmitButton.OnPressed += | ||
| _ => OnSubmitted?.Invoke(Rope.Collapse(ObjectiveSummaryTextEdit.TextRope)); | ||
| ObjectiveSummaryTextEdit.OnTextChanged += _ => UpdateWordCount(); | ||
|
|
||
| _mind ??= _entity.System<SharedMindSystem>(); | ||
|
|
||
| _mind.TryGetMind(_players.LocalSession, out var mindUid, out _); | ||
|
|
||
| // This is only for if you quit the server then rejoin. | ||
| if (_entity.TryGetComponent<Shared._DVA.DVCustomObjectiveSummary.DVCustomObjectiveSummaryComponent>(mindUid, out var summary)) | ||
| ObjectiveSummaryTextEdit.TextRope = new Rope.Leaf(summary.ObjectiveSummary); | ||
|
|
||
| UpdateWordCount(); | ||
| } | ||
|
|
||
| private void UpdateWordCount() | ||
| { | ||
| var textLength = ObjectiveSummaryTextEdit.TextLength; | ||
| var overMax = textLength > _maxLengthSummaryLength; | ||
|
|
||
| // Disable the button if it's over the max length. | ||
| SubmitButton.Disabled = overMax; | ||
| CharacterLimitLabel.Text = textLength + "/" + _maxLengthSummaryLength; | ||
|
|
||
| CharacterLimitLabel.FontColorOverride = overMax ? Color.Red : null; | ||
| PlaceholderText.Visible = textLength == 0; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| using Content.Server.Administration.Logs; | ||
| using Content.Shared._DVA.DVCustomObjectiveSummary; | ||
| using Content.Shared.Database; | ||
| using Content.Shared.Mind; | ||
| using Robust.Shared.Network; | ||
|
|
||
| namespace Content.Server._DVA.DVCustomObjectiveSummary; | ||
|
|
||
| public sealed class DVCustomObjectiveSummarySystem : EntitySystem | ||
| { | ||
| [Dependency] private readonly IServerNetManager _net = default!; | ||
| [Dependency] private readonly ISharedPlayerManager _player = default!; | ||
|
Check failure on line 12 in Content.Server/_DVA/DVCustomObjectiveSummary/DVCustomObjectiveSummarySystem.cs
|
||
| [Dependency] private readonly SharedMindSystem _mind = default!; | ||
| [Dependency] private readonly IAdminLogManager _adminLog = default!; | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| SubscribeLocalEvent<EvacShuttleLeftEvent>(OnEvacShuttleLeft); | ||
|
|
||
| _net.RegisterNetMessage<DVCustomObjectiveClientSetObjective>(OnDVCustomObjectiveFeedback); | ||
| } | ||
|
|
||
| private void OnDVCustomObjectiveFeedback(DVCustomObjectiveClientSetObjective msg) | ||
| { | ||
| if (!_mind.TryGetMind(msg.MsgChannel.UserId, out var mind)) | ||
| return; | ||
|
|
||
| if (mind.Value.Comp.Objectives.Count == 0) | ||
| return; | ||
|
|
||
| var comp = EnsureComp<DVCustomObjectiveSummaryComponent>(mind.Value); | ||
|
|
||
| comp.ObjectiveSummary = msg.Summary; | ||
| Dirty(mind.Value.Owner, comp); | ||
|
|
||
| _adminLog.Add(LogType.ObjectiveSummary, $"{ToPrettyString(mind.Value.Comp.OwnedEntity)} wrote objective summery: {msg.Summary}"); | ||
| } | ||
|
|
||
| private void OnEvacShuttleLeft(EvacShuttleLeftEvent args) | ||
| { | ||
| var allMinds = _mind.GetAliveHumans(); | ||
|
|
||
| foreach (var mind in allMinds) | ||
| { | ||
| // Only send the popup to people with objectives. | ||
| if (mind.Comp.Objectives.Count == 0) | ||
| continue; | ||
|
|
||
| if (!_player.TryGetSessionById(mind.Comp.UserId, out var session)) | ||
| continue; | ||
|
|
||
| RaiseNetworkEvent(new DVCustomObjectiveSummaryOpenMessage(), session); | ||
| } | ||
| } | ||
| } | ||
|
Vapetastic-Gaming marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| using Robust.Shared.GameStates; | ||
|
|
||
| namespace Content.Shared._DVA.DVCustomObjectiveSummary; | ||
|
|
||
| /// <summary> | ||
| /// Put on a players mind if the wrote a custom summary for their objectives. | ||
| /// </summary> | ||
| [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
| public sealed partial class DVCustomObjectiveSummaryComponent : Component | ||
| { | ||
| /// <summary> | ||
| /// What the player wrote as their summary! | ||
| /// </summary> | ||
| [DataField, AutoNetworkedField] | ||
| public string ObjectiveSummary = ""; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.