Multiline edit everywhere (#15216)
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
<Control HorizontalExpand="True" SizeFlagsStretchRatio="1" />
|
<Control HorizontalExpand="True" SizeFlagsStretchRatio="1" />
|
||||||
<OptionButton Name="AnnounceMethod" Access="Public" HorizontalExpand="True" SizeFlagsStretchRatio="2"/>
|
<OptionButton Name="AnnounceMethod" Access="Public" HorizontalExpand="True" SizeFlagsStretchRatio="2"/>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
<LineEdit Name="Announcement" Access="Public" PlaceHolder="{Loc admin-announce-announcement-placeholder}"/>
|
<TextEdit Name="Announcement" Access="Public" VerticalExpand="True" MinHeight="100" />
|
||||||
|
|
||||||
<GridContainer Rows="1">
|
<GridContainer Rows="1">
|
||||||
<CheckBox Name="KeepWindowOpen" Access="Public" Text="{Loc 'admin-announce-keep-open'}" />
|
<CheckBox Name="KeepWindowOpen" Access="Public" Text="{Loc 'admin-announce-keep-open'}" />
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using Robust.Client.AutoGenerated;
|
using Robust.Client.AutoGenerated;
|
||||||
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
using Robust.Client.UserInterface.XAML;
|
using Robust.Client.UserInterface.XAML;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Client.Administration.UI
|
namespace Content.Client.Administration.UI
|
||||||
{
|
{
|
||||||
@@ -16,18 +18,18 @@ namespace Content.Client.Administration.UI
|
|||||||
RobustXamlLoader.Load(this);
|
RobustXamlLoader.Load(this);
|
||||||
IoCManager.InjectDependencies(this);
|
IoCManager.InjectDependencies(this);
|
||||||
|
|
||||||
|
Announcement.Placeholder = new Rope.Leaf(_localization.GetString("admin-announce-announcement-placeholder"));
|
||||||
AnnounceMethod.AddItem(_localization.GetString("admin-announce-type-station"));
|
AnnounceMethod.AddItem(_localization.GetString("admin-announce-type-station"));
|
||||||
AnnounceMethod.SetItemMetadata(0, AdminAnnounceType.Station);
|
AnnounceMethod.SetItemMetadata(0, AdminAnnounceType.Station);
|
||||||
AnnounceMethod.AddItem(_localization.GetString("admin-announce-type-server"));
|
AnnounceMethod.AddItem(_localization.GetString("admin-announce-type-server"));
|
||||||
AnnounceMethod.SetItemMetadata(1, AdminAnnounceType.Server);
|
AnnounceMethod.SetItemMetadata(1, AdminAnnounceType.Server);
|
||||||
AnnounceMethod.OnItemSelected += AnnounceMethodOnOnItemSelected;
|
AnnounceMethod.OnItemSelected += AnnounceMethodOnOnItemSelected;
|
||||||
Announcement.OnTextChanged += AnnouncementOnOnTextChanged;
|
Announcement.OnKeyBindUp += AnnouncementOnOnTextChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AnnouncementOnOnTextChanged(GUIBoundKeyEventArgs args)
|
||||||
private void AnnouncementOnOnTextChanged(LineEdit.LineEditEventArgs args)
|
|
||||||
{
|
{
|
||||||
AnnounceButton.Disabled = args.Text.TrimStart() == "";
|
AnnounceButton.Disabled = Rope.Collapse(Announcement.TextRope).TrimStart() == "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AnnounceMethodOnOnItemSelected(OptionButton.ItemSelectedEventArgs args)
|
private void AnnounceMethodOnOnItemSelected(OptionButton.ItemSelectedEventArgs args)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Content.Client.Eui;
|
using Content.Client.Eui;
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Client.Administration.UI
|
namespace Content.Client.Administration.UI
|
||||||
{
|
{
|
||||||
@@ -19,7 +20,7 @@ namespace Content.Client.Administration.UI
|
|||||||
{
|
{
|
||||||
SendMessage(new AdminAnnounceEuiMsg.DoAnnounce
|
SendMessage(new AdminAnnounceEuiMsg.DoAnnounce
|
||||||
{
|
{
|
||||||
Announcement = _window.Announcement.Text,
|
Announcement = Rope.Collapse(_window.Announcement.TextRope),
|
||||||
Announcer = _window.Announcer.Text,
|
Announcer = _window.Announcer.Text,
|
||||||
AnnounceType = (AdminAnnounceType) (_window.AnnounceMethod.SelectedMetadata ?? AdminAnnounceType.Station),
|
AnnounceType = (AdminAnnounceType) (_window.AnnounceMethod.SelectedMetadata ?? AdminAnnounceType.Station),
|
||||||
CloseAfter = !_window.KeepWindowOpen.Pressed,
|
CloseAfter = !_window.KeepWindowOpen.Pressed,
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
using System;
|
using Content.Shared.Communications;
|
||||||
using Content.Shared.Communications;
|
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.ViewVariables;
|
|
||||||
|
|
||||||
namespace Content.Client.Communications.UI
|
namespace Content.Client.Communications.UI
|
||||||
{
|
{
|
||||||
@@ -59,8 +55,22 @@ namespace Content.Client.Communications.UI
|
|||||||
|
|
||||||
public void AnnounceButtonPressed(string message)
|
public void AnnounceButtonPressed(string message)
|
||||||
{
|
{
|
||||||
var msg = message.Length <= 256 ? message.Trim() : $"{message.Trim().Substring(0, 256)}...";
|
var msg = (message.Length <= 256 ? message.Trim() : $"{message.Trim().Substring(0, 256)}...").ToCharArray();
|
||||||
SendMessage(new CommunicationsConsoleAnnounceMessage(msg));
|
|
||||||
|
// No more than 2 newlines, other replaced to spaces
|
||||||
|
var newlines = 0;
|
||||||
|
for (var i = 0; i < msg.Length; i++)
|
||||||
|
{
|
||||||
|
if (msg[i] != '\n')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (newlines >= 2)
|
||||||
|
msg[i] = ' ';
|
||||||
|
|
||||||
|
newlines++;
|
||||||
|
}
|
||||||
|
|
||||||
|
SendMessage(new CommunicationsConsoleAnnounceMessage(new string(msg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CallShuttle()
|
public void CallShuttle()
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<controls:FancyWindow xmlns="https://spacestation14.io"
|
<controls:FancyWindow xmlns="https://spacestation14.io"
|
||||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
||||||
Title="{Loc 'comms-console-menu-title'}"
|
Title="{Loc 'comms-console-menu-title'}"
|
||||||
MinSize="350 225">
|
MinSize="400 225">
|
||||||
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True" Margin="5">
|
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True" Margin="5">
|
||||||
<LineEdit Name="MessageInput" PlaceHolder="{Loc 'comms-console-menu-announcement-placeholder'}" HorizontalExpand="True" Margin="0 0 0 5" />
|
<TextEdit Name="MessageInput" HorizontalExpand="True" VerticalExpand="True" Margin="0 0 0 5" MinHeight="100" />
|
||||||
<Button Name="AnnounceButton" Text="{Loc 'comms-console-menu-announcement-button'}" StyleClasses="OpenLeft" Access="Public" />
|
<Button Name="AnnounceButton" Text="{Loc 'comms-console-menu-announcement-button'}" StyleClasses="OpenLeft" Access="Public" />
|
||||||
|
|
||||||
<OptionButton Name="AlertLevelButton" StyleClasses="OpenRight" Access="Public" />
|
<OptionButton Name="AlertLevelButton" StyleClasses="OpenRight" Access="Public" />
|
||||||
|
|||||||
@@ -1,14 +1,8 @@
|
|||||||
using Content.Client.UserInterface.Controls;
|
using Content.Client.UserInterface.Controls;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Robust.Client.AutoGenerated;
|
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.Client.UserInterface.XAML;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.Utility;
|
||||||
using Robust.Shared.Localization;
|
|
||||||
using Robust.Shared.Maths;
|
|
||||||
using static Robust.Client.UserInterface.Controls.BoxContainer;
|
|
||||||
using Timer = Robust.Shared.Timing.Timer;
|
using Timer = Robust.Shared.Timing.Timer;
|
||||||
|
|
||||||
namespace Content.Client.Communications.UI
|
namespace Content.Client.Communications.UI
|
||||||
@@ -26,7 +20,10 @@ namespace Content.Client.Communications.UI
|
|||||||
|
|
||||||
Owner = owner;
|
Owner = owner;
|
||||||
|
|
||||||
AnnounceButton.OnPressed += (_) => Owner.AnnounceButtonPressed(MessageInput.Text.Trim());
|
var loc = IoCManager.Resolve<ILocalizationManager>();
|
||||||
|
MessageInput.Placeholder = new Rope.Leaf(loc.GetString("comms-console-menu-announcement-placeholder"));
|
||||||
|
|
||||||
|
AnnounceButton.OnPressed += (_) => Owner.AnnounceButtonPressed(Rope.Collapse(MessageInput.TextRope).Trim());
|
||||||
AnnounceButton.Disabled = !owner.CanAnnounce;
|
AnnounceButton.Disabled = !owner.CanAnnounce;
|
||||||
|
|
||||||
AlertLevelButton.OnItemSelected += args =>
|
AlertLevelButton.OnItemSelected += args =>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.Input;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.Utility;
|
||||||
using static Content.Shared.Paper.SharedPaperComponent;
|
using static Content.Shared.Paper.SharedPaperComponent;
|
||||||
|
|
||||||
namespace Content.Client.Paper.UI
|
namespace Content.Client.Paper.UI
|
||||||
@@ -23,7 +23,15 @@ namespace Content.Client.Paper.UI
|
|||||||
|
|
||||||
_window = new PaperWindow();
|
_window = new PaperWindow();
|
||||||
_window.OnClose += Close;
|
_window.OnClose += Close;
|
||||||
_window.Input.OnTextEntered += Input_OnTextEntered;
|
_window.Input.OnKeyBindDown += args => // Solution while TextEdit don't have events
|
||||||
|
{
|
||||||
|
if (args.Function == EngineKeyFunctions.TextSubmit)
|
||||||
|
{
|
||||||
|
var text = Rope.Collapse(_window.Input.TextRope);
|
||||||
|
Input_OnTextEntered(text);
|
||||||
|
args.Handle();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (entityMgr.TryGetComponent<PaperVisualsComponent>(Owner.Owner, out var visuals))
|
if (entityMgr.TryGetComponent<PaperVisualsComponent>(Owner.Owner, out var visuals))
|
||||||
{
|
{
|
||||||
@@ -39,15 +47,16 @@ namespace Content.Client.Paper.UI
|
|||||||
_window?.Populate((PaperBoundUserInterfaceState) state);
|
_window?.Populate((PaperBoundUserInterfaceState) state);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Input_OnTextEntered(LineEdit.LineEditEventArgs obj)
|
private void Input_OnTextEntered(string text)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(obj.Text))
|
if (!string.IsNullOrEmpty(text))
|
||||||
{
|
{
|
||||||
SendMessage(new PaperInputTextMessage(obj.Text));
|
SendMessage(new PaperInputTextMessage(text));
|
||||||
|
|
||||||
if (_window != null)
|
if (_window != null)
|
||||||
{
|
{
|
||||||
_window.Input.Text = string.Empty;
|
_window.Input.TextRope = Rope.Leaf.Empty;
|
||||||
|
_window.Input.CursorPosition = new TextEdit.CursorPos(0, TextEdit.LineBreakBias.Top);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,15 +10,15 @@
|
|||||||
<PanelContainer Name="PaperBackground" StyleClasses="PaperDefaultBorder" VerticalExpand="True" HorizontalExpand="True">
|
<PanelContainer Name="PaperBackground" StyleClasses="PaperDefaultBorder" VerticalExpand="True" HorizontalExpand="True">
|
||||||
<ScrollContainer Name="ScrollingContents" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalExpand="True" VerticalExpand="True" HScrollEnabled="False">
|
<ScrollContainer Name="ScrollingContents" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalExpand="True" VerticalExpand="True" HScrollEnabled="False">
|
||||||
<PanelContainer Name="PaperContent" VerticalExpand="True" HorizontalExpand="True" MaxWidth="600">
|
<PanelContainer Name="PaperContent" VerticalExpand="True" HorizontalExpand="True" MaxWidth="600">
|
||||||
<BoxContainer Orientation="Vertical" VerticalAlignment="Top">
|
<BoxContainer Orientation="Vertical" VerticalAlignment="Stretch">
|
||||||
<TextureButton Name="HeaderImage" HorizontalAlignment="Center" VerticalAlignment="Top" MouseFilter="Ignore"/>
|
<TextureButton Name="HeaderImage" HorizontalAlignment="Center" VerticalAlignment="Top" MouseFilter="Ignore"/>
|
||||||
<Control Name="TextAlignmentPadding" VerticalAlignment="Top" />
|
<Control Name="TextAlignmentPadding" VerticalAlignment="Top" />
|
||||||
<RichTextLabel Name="BlankPaperIndicator" StyleClasses="LabelSecondaryColor"
|
<RichTextLabel Name="BlankPaperIndicator" StyleClasses="LabelSecondaryColor"
|
||||||
VerticalAlignment="Top" HorizontalAlignment="Center"/>
|
VerticalAlignment="Top" HorizontalAlignment="Center"/>
|
||||||
<RichTextLabel StyleClasses="PaperWrittenText" Name="WrittenTextLabel" VerticalAlignment="Top"/>
|
<RichTextLabel StyleClasses="PaperWrittenText" Name="WrittenTextLabel" VerticalAlignment="Top"/>
|
||||||
<PanelContainer Name="InputContainer" StyleClasses="TransparentBorderedWindowPanel"
|
<PanelContainer Name="InputContainer" StyleClasses="TransparentBorderedWindowPanel" MinHeight="100"
|
||||||
VerticalAlignment="Top" HorizontalExpand="True">
|
VerticalAlignment="Stretch" VerticalExpand="True" HorizontalExpand="True">
|
||||||
<LineEdit Name="Input" StyleClasses="PaperLineEdit" Access="Public" />
|
<TextEdit Name="Input" StyleClasses="PaperLineEdit" Access="Public" />
|
||||||
</PanelContainer>
|
</PanelContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
<BoxContainer Name="StampDisplay" Orientation="Vertical" VerticalAlignment="Bottom" Margin="6"/>
|
<BoxContainer Name="StampDisplay" Orientation="Vertical" VerticalAlignment="Bottom" Margin="6"/>
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ namespace Content.Server.Communications
|
|||||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||||
|
|
||||||
private const int MaxMessageLength = 256;
|
private const int MaxMessageLength = 256;
|
||||||
|
private const int MaxMessageNewlines = 2;
|
||||||
private const float UIUpdateInterval = 5.0f;
|
private const float UIUpdateInterval = 5.0f;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
@@ -223,7 +224,21 @@ namespace Content.Server.Communications
|
|||||||
private void OnAnnounceMessage(EntityUid uid, CommunicationsConsoleComponent comp,
|
private void OnAnnounceMessage(EntityUid uid, CommunicationsConsoleComponent comp,
|
||||||
CommunicationsConsoleAnnounceMessage message)
|
CommunicationsConsoleAnnounceMessage message)
|
||||||
{
|
{
|
||||||
var msg = message.Message.Length <= MaxMessageLength ? message.Message.Trim() : $"{message.Message.Trim().Substring(0, MaxMessageLength)}...";
|
var msgChars = (message.Message.Length <= MaxMessageLength ? message.Message.Trim() : $"{message.Message.Trim().Substring(0, MaxMessageLength)}...").ToCharArray();
|
||||||
|
|
||||||
|
var newlines = 0;
|
||||||
|
for (var i = 0; i < msgChars.Length; i++)
|
||||||
|
{
|
||||||
|
if (msgChars[i] != '\n')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (newlines >= MaxMessageNewlines)
|
||||||
|
msgChars[i] = ' ';
|
||||||
|
|
||||||
|
newlines++;
|
||||||
|
}
|
||||||
|
|
||||||
|
var msg = new string(msgChars);
|
||||||
var author = Loc.GetString("comms-console-announcement-unknown-sender");
|
var author = Loc.GetString("comms-console-announcement-unknown-sender");
|
||||||
if (message.Session.AttachedEntity is {Valid: true} mob)
|
if (message.Session.AttachedEntity is {Valid: true} mob)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
admin-announce-title = Make Announcement
|
admin-announce-title = Make Announcement
|
||||||
admin-announce-announcement-placeholder = Announcement text
|
admin-announce-announcement-placeholder = Announcement text...
|
||||||
admin-announce-announcer-placeholder = Announcer
|
admin-announce-announcer-placeholder = Announcer
|
||||||
admin-announce-announcer-default = Central Command
|
admin-announce-announcer-default = Central Command
|
||||||
admin-announce-button = Announce
|
admin-announce-button = Announce
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# User interface
|
# User interface
|
||||||
comms-console-menu-title = Communications Console
|
comms-console-menu-title = Communications Console
|
||||||
comms-console-menu-announcement-placeholder = Announcement
|
comms-console-menu-announcement-placeholder = Announcement text...
|
||||||
comms-console-menu-announcement-button = Announce
|
comms-console-menu-announcement-button = Announce
|
||||||
comms-console-menu-call-shuttle = Call emergency shuttle
|
comms-console-menu-call-shuttle = Call emergency shuttle
|
||||||
comms-console-menu-recall-shuttle = Recall emergency shuttle
|
comms-console-menu-recall-shuttle = Recall emergency shuttle
|
||||||
|
|||||||
@@ -331,10 +331,12 @@ binds:
|
|||||||
type: State
|
type: State
|
||||||
key: Return
|
key: Return
|
||||||
canRepeat: true
|
canRepeat: true
|
||||||
|
mod1: Shift
|
||||||
- function: TextNewline
|
- function: TextNewline
|
||||||
type: State
|
type: State
|
||||||
key: NumpadEnter
|
key: NumpadEnter
|
||||||
canRepeat: true
|
canRepeat: true
|
||||||
|
mod1: Shift
|
||||||
- function: TextSubmit
|
- function: TextSubmit
|
||||||
type: State
|
type: State
|
||||||
key: Return
|
key: Return
|
||||||
|
|||||||
Reference in New Issue
Block a user