From b635d4efaf7b0c4f52b90921061d234bc7806728 Mon Sep 17 00:00:00 2001 From: CaypenNow <66198468+CaypenNow@users.noreply.github.com> Date: Tue, 2 Apr 2024 19:17:43 +0500 Subject: [PATCH] [Feat] Interactive Board (#258) * interactive board * change2 * fixes --- .../InteractiveBoardComponent.cs | 9 + .../InteractiveBoardSystem.cs | 24 ++ .../UI/InteractiveBoardBoundUserInterface.cs | 66 ++++++ .../UI/InteractiveBoardVisualsComponent.cs | 35 +++ .../UI/InteractiveBoardWindow.xaml | 28 +++ .../UI/InteractiveBoardWindow.xaml.cs | 207 ++++++++++++++++ .../InteractiveBoardComponent.cs | 14 ++ .../InteractiveBoardSystem.cs | 221 ++++++++++++++++++ .../OnInteractiveBoardWriteComponent.cs | 7 + .../SharedInteractiveBoardComponent.cs | 55 +++++ .../Locale/ru-RU/devices/interactiveboard.ftl | 6 + Resources/Prototypes/Atmospherics/gases.yml | 2 +- .../Catalog/Fills/Lockers/heads.yml | 2 + .../Objects/Misc/interactiveboard.yml | 49 ++++ Resources/Prototypes/_White/tags.yml | 6 + .../interactiveboardbackground.png | Bin 0 -> 411 bytes .../interactiveboardbackground.png.yml | 2 + .../interactiveboard.rsi/interactiveboard.png | Bin 0 -> 272 bytes .../interactiveboard_with_words.png | Bin 0 -> 375 bytes .../Devices/interactiveboard.rsi/meta.json | 20 ++ .../Devices/interactiveboard.rsi/pen.png | Bin 0 -> 386 bytes 21 files changed, 752 insertions(+), 1 deletion(-) create mode 100644 Content.Client/_White/InteractiveBoard/InteractiveBoardComponent.cs create mode 100644 Content.Client/_White/InteractiveBoard/InteractiveBoardSystem.cs create mode 100644 Content.Client/_White/InteractiveBoard/UI/InteractiveBoardBoundUserInterface.cs create mode 100644 Content.Client/_White/InteractiveBoard/UI/InteractiveBoardVisualsComponent.cs create mode 100644 Content.Client/_White/InteractiveBoard/UI/InteractiveBoardWindow.xaml create mode 100644 Content.Client/_White/InteractiveBoard/UI/InteractiveBoardWindow.xaml.cs create mode 100644 Content.Server/_White/InteractiveBoard/InteractiveBoardComponent.cs create mode 100644 Content.Server/_White/InteractiveBoard/InteractiveBoardSystem.cs create mode 100644 Content.Server/_White/InteractiveBoard/OnInteractiveBoardWriteComponent.cs create mode 100644 Content.Shared/_White/InteractiveBoard/SharedInteractiveBoardComponent.cs create mode 100644 Resources/Locale/ru-RU/devices/interactiveboard.ftl create mode 100644 Resources/Prototypes/_White/Entities/Objects/Misc/interactiveboard.yml create mode 100644 Resources/Textures/White/Interface/InteractiveBoard/interactiveboardbackground.png create mode 100644 Resources/Textures/White/Interface/InteractiveBoard/interactiveboardbackground.png.yml create mode 100644 Resources/Textures/White/Objects/Devices/interactiveboard.rsi/interactiveboard.png create mode 100644 Resources/Textures/White/Objects/Devices/interactiveboard.rsi/interactiveboard_with_words.png create mode 100644 Resources/Textures/White/Objects/Devices/interactiveboard.rsi/meta.json create mode 100644 Resources/Textures/White/Objects/Devices/interactiveboard.rsi/pen.png diff --git a/Content.Client/_White/InteractiveBoard/InteractiveBoardComponent.cs b/Content.Client/_White/InteractiveBoard/InteractiveBoardComponent.cs new file mode 100644 index 0000000000..b86ea49f84 --- /dev/null +++ b/Content.Client/_White/InteractiveBoard/InteractiveBoardComponent.cs @@ -0,0 +1,9 @@ +using Content.Shared._White.InteractiveBoard; +using Robust.Shared.GameStates; + +namespace Content.Client._White.InteractiveBoard; + +[NetworkedComponent, RegisterComponent] +public sealed partial class InteractiveBoardComponent : SharedInteractiveBoardComponent +{ +} diff --git a/Content.Client/_White/InteractiveBoard/InteractiveBoardSystem.cs b/Content.Client/_White/InteractiveBoard/InteractiveBoardSystem.cs new file mode 100644 index 0000000000..3a92dbb04f --- /dev/null +++ b/Content.Client/_White/InteractiveBoard/InteractiveBoardSystem.cs @@ -0,0 +1,24 @@ +using Content.Client._White.InteractiveBoard.UI; +using Robust.Client.GameObjects; + +using static Content.Shared._White.InteractiveBoard.SharedInteractiveBoardComponent; + +namespace Content.Client._White.InteractiveBoard; + +public sealed class InteractiveBoardSystem : VisualizerSystem +{ + protected override void OnAppearanceChange(EntityUid uid, InteractiveBoardVisualsComponent component, ref AppearanceChangeEvent args) + { + if (args.Sprite == null) + return; + + if (AppearanceSystem.TryGetData(uid, InteractiveBoardVisuals.Status , out var writingStatus, args.Component)) + args.Sprite.LayerSetVisible(InteractiveBoardVisualLayers.Writing, writingStatus == InteractiveBoardStatus.Written); + } +} + +public enum InteractiveBoardVisualLayers +{ + Writing +} + diff --git a/Content.Client/_White/InteractiveBoard/UI/InteractiveBoardBoundUserInterface.cs b/Content.Client/_White/InteractiveBoard/UI/InteractiveBoardBoundUserInterface.cs new file mode 100644 index 0000000000..d0726a0748 --- /dev/null +++ b/Content.Client/_White/InteractiveBoard/UI/InteractiveBoardBoundUserInterface.cs @@ -0,0 +1,66 @@ +using JetBrains.Annotations; +using Robust.Client.UserInterface.Controls; +using Robust.Shared.Input; +using Robust.Shared.Utility; +using static Content.Shared._White.InteractiveBoard.SharedInteractiveBoardComponent; + +namespace Content.Client._White.InteractiveBoard.UI; + +[UsedImplicitly] +public sealed class InteractiveBoardBoundUserInterface : BoundUserInterface +{ + [ViewVariables] + private InteractiveBoardWindow? _window; + + public InteractiveBoardBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) + { + } + + protected override void Open() + { + base.Open(); + + _window = new InteractiveBoardWindow(); + _window.OnClose += Close; + _window.Input.OnKeyBindDown += args => + { + if (args.Function == EngineKeyFunctions.TextSubmit) + { + var text = Rope.Collapse(_window.Input.TextRope); + Input_OnTextEntered(text); + args.Handle(); + } + }; + + if (EntMan.TryGetComponent(Owner, out var visuals)) + { + _window.InitVisuals(Owner, visuals); + } + + _window.OpenCentered(); + } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + _window?.Populate((InteractiveBoardBoundUserInterfaceState) state); + } + + private void Input_OnTextEntered(string text) + { + SendMessage(new InteractiveBoardInputTextMessage(text)); + + if (_window != null) + { + _window.Input.TextRope = Rope.Leaf.Empty; + _window.Input.CursorPosition = new TextEdit.CursorPos(0, TextEdit.LineBreakBias.Top); + } + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + if (!disposing) return; + _window?.Dispose(); + } +} diff --git a/Content.Client/_White/InteractiveBoard/UI/InteractiveBoardVisualsComponent.cs b/Content.Client/_White/InteractiveBoard/UI/InteractiveBoardVisualsComponent.cs new file mode 100644 index 0000000000..277647a14e --- /dev/null +++ b/Content.Client/_White/InteractiveBoard/UI/InteractiveBoardVisualsComponent.cs @@ -0,0 +1,35 @@ +using System.Numerics; + +namespace Content.Client._White.InteractiveBoard.UI; + +[RegisterComponent] +public sealed partial class InteractiveBoardVisualsComponent : Component +{ + public string ImagePath = "/Textures/White/Interface/InteractiveBoard/interactiveboardbackground.png"; + + public Box2 BackgroundPatchMargin = default; + + public Color BackgroundModulate = Color.White; + + public bool BackgroundImageTile = false; + + public Vector2 BackgroundScale = Vector2.One; + + public string? HeaderImagePath; + + public Color HeaderImageModulate = Color.White; + + public Box2 HeaderMargin = default; + + public string? ContentImagePath; + + public Color ContentImageModulate = Color.White; + + public Box2 ContentMargin = default; + + public int ContentImageNumLines = 1; + + public Color FontAccentColor = new(223, 223, 213); + + public Vector2? MaxWritableArea = null; +} diff --git a/Content.Client/_White/InteractiveBoard/UI/InteractiveBoardWindow.xaml b/Content.Client/_White/InteractiveBoard/UI/InteractiveBoardWindow.xaml new file mode 100644 index 0000000000..8287f93ea3 --- /dev/null +++ b/Content.Client/_White/InteractiveBoard/UI/InteractiveBoardWindow.xaml @@ -0,0 +1,28 @@ + + + + +