From 5e8e848d521ea1fa57371e4821f745bfd530ce28 Mon Sep 17 00:00:00 2001 From: Julian Giebel Date: Thu, 16 Feb 2023 00:10:05 +0100 Subject: [PATCH] Content PR for RichText refactor (#13772) * Fix examine system after formatted text refactor Implement key bind markup tag * Add font prototype definitions * Update submodule. --------- Co-authored-by: moonheart08 --- Content.Client/Examine/ExamineSystem.cs | 10 ++++-- .../Guidebook/Richtext/KeyBindTag.cs | 25 +++++++++++++ Content.Shared/Examine/ExamineSystemShared.cs | 2 +- Resources/Prototypes/fonts.yml | 35 +++++++++++++++++++ .../Guidebook/Controls/Controls.xml | 16 ++++----- RobustToolbox | 2 +- 6 files changed, 78 insertions(+), 12 deletions(-) create mode 100644 Content.Client/Guidebook/Richtext/KeyBindTag.cs create mode 100644 Resources/Prototypes/fonts.yml diff --git a/Content.Client/Examine/ExamineSystem.cs b/Content.Client/Examine/ExamineSystem.cs index d6b8fde35f..acd62a9d39 100644 --- a/Content.Client/Examine/ExamineSystem.cs +++ b/Content.Client/Examine/ExamineSystem.cs @@ -244,9 +244,15 @@ namespace Content.Client.Examine return; } - foreach (var msg in message.Tags.OfType()) + foreach (var msg in message.Nodes) { - if (string.IsNullOrWhiteSpace(msg.Text)) continue; + if (msg.Name != null) + continue; + + var text = msg.Value.StringValue ?? ""; + + if (string.IsNullOrWhiteSpace(text)) + continue; var richLabel = new RichTextLabel() { Margin = new Thickness(4, 4, 0, 4)}; richLabel.SetMessage(message); diff --git a/Content.Client/Guidebook/Richtext/KeyBindTag.cs b/Content.Client/Guidebook/Richtext/KeyBindTag.cs new file mode 100644 index 0000000000..478f1b9bf6 --- /dev/null +++ b/Content.Client/Guidebook/Richtext/KeyBindTag.cs @@ -0,0 +1,25 @@ +using JetBrains.Annotations; +using Robust.Client.Input; +using Robust.Client.UserInterface.RichText; +using Robust.Shared.Utility; + +namespace Content.Client.Guidebook.Richtext; + +[UsedImplicitly] +public sealed class KeyBindTag : IMarkupTag +{ + [Dependency] private readonly IInputManager _inputManager = default!; + + public string Name => "keybind"; + + public string TextBefore(MarkupNode node) + { + if (!node.Value.TryGetString(out var keyBindName)) + return ""; + + if (!_inputManager.TryGetKeyBinding(keyBindName, out var binding)) + return keyBindName; + + return binding.GetKeyString(); + } +} diff --git a/Content.Shared/Examine/ExamineSystemShared.cs b/Content.Shared/Examine/ExamineSystemShared.cs index e5771b06bf..1eed657d0f 100644 --- a/Content.Shared/Examine/ExamineSystemShared.cs +++ b/Content.Shared/Examine/ExamineSystemShared.cs @@ -319,7 +319,7 @@ namespace Content.Shared.Examine /// public void PushMessage(FormattedMessage message) { - if (message.Tags.Count == 0) + if (message.Nodes.Count == 0) return; if (_doNewLine) diff --git a/Resources/Prototypes/fonts.yml b/Resources/Prototypes/fonts.yml new file mode 100644 index 0000000000..cc943aab85 --- /dev/null +++ b/Resources/Prototypes/fonts.yml @@ -0,0 +1,35 @@ +- type: font + id: Default + path: /Fonts/NotoSans/NotoSans-Regular.ttf + +- type: font + id: DefaultItalic + path: /Fonts/NotoSans/NotoSans-Italic.ttf + +- type: font + id: DefaultBold + path: /Fonts/NotoSans/NotoSans-Bold.ttf + +- type: font + id: NotoSansDisplay + path: /Fonts/NotoSansDisplay/NotoSansDisplay-Regular.ttf + +- type: font + id: NotoSansDisplayItalic + path: /Fonts/NotoSansDisplay/NotoSansDisplay-Italic.ttf + +- type: font + id: NotoSansDisplayBold + path: /Fonts/NotoSansDisplay/NotoSansDisplay-Bold.ttf + +- type: font + id: NotoSansDisplayBoldItalic + path: /Fonts/NotoSansDisplay/NotoSansDisplay-BoldItalic.ttf + +- type: font + id: BoxRound + path: /Fonts/Boxfont-round/Boxfont Round.ttf + +- type: font + id: AnimalSilence + path: /Fonts/Animal Silence.otf diff --git a/Resources/Server Info/Guidebook/Controls/Controls.xml b/Resources/Server Info/Guidebook/Controls/Controls.xml index 039f22f6d6..1c63692e88 100644 --- a/Resources/Server Info/Guidebook/Controls/Controls.xml +++ b/Resources/Server Info/Guidebook/Controls/Controls.xml @@ -8,12 +8,12 @@ We shall politely assume you already know how WASD to walk works. Beyond that, there's a handful primary interactions in SS14, ordered by importance: -- [color=#a4885c]Left click[/color] to pick up items and activate objects like buttons or computers, and [color=#a4885c]E[/color] to activate items. You can also press [color=#a4885c]alt[/color] while doing this to trigger alternate interactions for some objects. -- You can also quickly activate items you're holding by pressing [color=#a4885c]Z[/color] and [color=#a4885c]alt-Z[/color] respectively. -- [color=#a4885c]Right click[/color] to open the context menu. You can then either left click an entry just like you would in the world, or right click it again to open the verb menu, which gives you more complex ways to interact with an object. -- You can [color=#a4885c]shift-left click[/color] objects to examine them, and get their name and a detailed (though often humorous) description. +- [color=#a4885c][keybind="Use"/][/color] to pick up items and activate objects like buttons or computers, and [color=#a4885c][keybind="ActivateItemInWorld"/][/color] to activate items. You can also press [color=#a4885c]alt[/color] while doing this to trigger alternate interactions for some objects. +- You can also quickly activate items you're holding by pressing [color=#a4885c][keybind="ActivateItemInHand"/][/color] and [color=#a4885c][keybind="AltActivateItemInHand"/][/color] respectively. +- [color=#a4885c][keybind="UIRightClick"/][/color] to open the context menu. You can then either left click an entry just like you would in the world, or right click it again to open the verb menu, which gives you more complex ways to interact with an object. +- You can [color=#a4885c][keybind="ExamineEntity"/][/color] objects to examine them, and get their name and a detailed (though often humorous) description. -You can quickly try out these controls with the monkey below (note: clicking it only works in-game and not in the lobby), and at any point in this guidebook if you're shown an entity, [color=#a4885c]shift-left click to examine will always work[/color]: +You can quickly try out these controls with the monkey below (note: clicking it only works in-game and not in the lobby), and at any point in this guidebook if you're shown an entity, [color=#a4885c][keybind="ExamineEntity"/] to examine will always work[/color]: @@ -21,14 +21,14 @@ You can quickly try out these controls with the monkey below (note: clicking it ## Inventory In order to move items around in your inventory and between containers, you can click the item (or item name) to move it to your active hand, and then click the spot you want it to go (either a slot in your HUD, or the container). -The items in your hands are only active one at a time, in order to swap between what you're currently using, you can press [color=#a4885c]X[/color] on your keyboard to change active hands. +The items in your hands are only active one at a time, in order to swap between what you're currently using, you can press [color=#a4885c][keybind="SwapHands"/][/color] on your keyboard to change active hands. -Opening containers in your inventory is easy as well, either hover over the item and activate it with [color=#a4885c]E[/color] or [color=#a4885c]Z[/color], or click on the bag icon in the bottom right corner of the slot it is in. +Opening containers in your inventory is easy as well, either hover over the item and activate it with [color=#a4885c][keybind="ActivateItemInWorld"/][/color] or click on the bag icon in the bottom right corner of the slot it is in. When you open a container a window will pop up showing the contents of the container and how much space it has available to hold things. All items have an assigned size, some too large to fit into most or all containers. -To drop items, you can press [color=#a4885c]Q[/color], and to drop them more violently (also known as throwing), you can press [color=#a4885c]ctrl-Q[/color]. +To drop items, you can press [color=#a4885c][keybind="Drop"/][/color], and to drop them more violently (also known as throwing), you can press [color=#a4885c][keybind="ThrowItemInHand"/][/color]. ## Actions To the left in your HUD there's a bar showing various actions you can take. diff --git a/RobustToolbox b/RobustToolbox index f569f8e334..efe7bd9dfd 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit f569f8e334fba999f3b0bf70a7b1ba1e9d1ae079 +Subproject commit efe7bd9dfd5107e8a3d36ae1cba5c6f7c6673a62