diff --git a/Content.Client/Administration/UI/Notes/NoteEdit.xaml.cs b/Content.Client/Administration/UI/Notes/NoteEdit.xaml.cs index 5cd3da438e..6a921cf6a1 100644 --- a/Content.Client/Administration/UI/Notes/NoteEdit.xaml.cs +++ b/Content.Client/Administration/UI/Notes/NoteEdit.xaml.cs @@ -3,6 +3,7 @@ using Content.Shared.Administration.Notes; using Content.Shared.Database; using Robust.Client.AutoGenerated; using Robust.Client.Console; +using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; using Robust.Shared.Timing; @@ -24,6 +25,9 @@ public sealed partial class NoteEdit : FancyWindow RobustXamlLoader.Load(this); PlayerName = playerName; Title = Loc.GetString("admin-note-editor-title-new", ("player", PlayerName)); + IsCreating = note is null; + CanCreate = canCreate; + CanEdit = canEdit; ResetSubmitButton(); @@ -33,6 +37,7 @@ public sealed partial class NoteEdit : FancyWindow TypeOption.OnItemSelected += OnTypeChanged; + SeverityOption.AddItem(Loc.GetString("admin-note-editor-severity-select"), -1); SeverityOption.AddItem(Loc.GetString("admin-note-editor-severity-none"), (int) Shared.Database.NoteSeverity.None); SeverityOption.AddItem(Loc.GetString("admin-note-editor-severity-low"), (int) Shared.Database.NoteSeverity.Minor); SeverityOption.AddItem(Loc.GetString("admin-note-editor-severity-medium"), (int) Shared.Database.NoteSeverity.Medium); @@ -42,10 +47,11 @@ public sealed partial class NoteEdit : FancyWindow PermanentCheckBox.OnPressed += OnPermanentPressed; SecretCheckBox.OnPressed += OnSecretPressed; SubmitButton.OnPressed += OnSubmitButtonPressed; + SubmitButton.OnMouseEntered += OnSubmitButtonMouseEntered; + SubmitButton.OnMouseExited += OnSubmitButtonMouseExited; if (note is null && !canCreate) { - SubmitButton.Disabled = true; TypeOption.Disabled = true; SeverityOption.Disabled = true; } @@ -77,21 +83,45 @@ public sealed partial class NoteEdit : FancyWindow UpdatePermanentCheckboxFields(); ExpiryLineEdit.Text = ExpiryTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); } - - if (!canEdit) - { - SubmitButton.Disabled = true; - } } + + UpdateSubmitButton(); } + private void OnSubmitButtonMouseEntered(GUIMouseHoverEventArgs args) + { + if (!SubmitButton.Disabled) + return; + + SeverityOption.ModulateSelfOverride = Color.Red; + } + + private void OnSubmitButtonMouseExited(GUIMouseHoverEventArgs args) + { + SeverityOption.ModulateSelfOverride = null; + } + + private NoteSeverity? _noteSeverity = null; + private string PlayerName { get; } private int NoteId { get; } private bool IsSecret { get; set; } private NoteType NoteType { get; set; } - private NoteSeverity? NoteSeverity { get; set; } = Shared.Database.NoteSeverity.None; + + private NoteSeverity? NoteSeverity + { + get => _noteSeverity; + set + { + _noteSeverity = value; + UpdateSubmitButton(); + } + } private DateTime? ExpiryTime { get; set; } private TimeSpan? DeleteResetOn { get; set; } + private bool IsCreating { get; set; } + private bool CanCreate { get; set; } + private bool CanEdit { get; set; } private void OnTypeChanged(OptionButton.ItemSelectedEventArgs args) { @@ -153,7 +183,7 @@ public sealed partial class NoteEdit : FancyWindow private void OnSeverityChanged(OptionButton.ItemSelectedEventArgs args) { - NoteSeverity = (NoteSeverity) args.Id; + NoteSeverity = args.Id == -1 ? NoteSeverity = null : (NoteSeverity) args.Id; SeverityOption.SelectId(args.Id); } @@ -192,6 +222,26 @@ public sealed partial class NoteEdit : FancyWindow } } + /// + /// Updates whether or not the submit button is disabled. + /// + private void UpdateSubmitButton() + { + if (!CanEdit) + { + SubmitButton.Disabled = true; + return; + } + + if (IsCreating && !CanCreate) + { + SubmitButton.Disabled = true; + return; + } + + SubmitButton.Disabled = NoteSeverity == null; + } + private void ResetSubmitButton() { SubmitButton.Text = Loc.GetString("admin-note-editor-submit"); @@ -236,6 +286,8 @@ public sealed partial class NoteEdit : FancyWindow PermanentCheckBox.OnPressed -= OnPermanentPressed; SecretCheckBox.OnPressed -= OnSecretPressed; SubmitButton.OnPressed -= OnSubmitButtonPressed; + SubmitButton.OnMouseEntered -= OnSubmitButtonMouseEntered; + SubmitButton.OnMouseExited -= OnSubmitButtonMouseExited; SubmitPressed = null; } diff --git a/Resources/Locale/en-US/administration/ui/admin-notes.ftl b/Resources/Locale/en-US/administration/ui/admin-notes.ftl index 0a4da34e55..16cdc7c500 100644 --- a/Resources/Locale/en-US/administration/ui/admin-notes.ftl +++ b/Resources/Locale/en-US/administration/ui/admin-notes.ftl @@ -48,6 +48,7 @@ admin-note-editor-type-message = Message admin-note-editor-type-watchlist = Watchlist admin-note-editor-type-server-ban = Server Ban admin-note-editor-type-role-ban = Role Ban +admin-note-editor-severity-select = Select admin-note-editor-severity-none = None admin-note-editor-severity-low = Low admin-note-editor-severity-medium = Medium