]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Content PR for RichText refactor (#13772)
authorJulian Giebel <juliangiebel@live.de>
Wed, 15 Feb 2023 23:10:05 +0000 (00:10 +0100)
committerGitHub <noreply@github.com>
Wed, 15 Feb 2023 23:10:05 +0000 (17:10 -0600)
* Fix examine system after formatted text refactor
Implement key bind markup tag

* Add font prototype definitions

* Update submodule.

---------

Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com>
Content.Client/Examine/ExamineSystem.cs
Content.Client/Guidebook/Richtext/KeyBindTag.cs [new file with mode: 0644]
Content.Shared/Examine/ExamineSystemShared.cs
Resources/Prototypes/fonts.yml [new file with mode: 0644]
Resources/Server Info/Guidebook/Controls/Controls.xml
RobustToolbox

index d6b8fde35f9be23814ac63d4b44b5940ca7f0218..acd62a9d394ea774360b3335cc9a57834b6bae3b 100644 (file)
@@ -244,9 +244,15 @@ namespace Content.Client.Examine
                 return;
             }
 
-            foreach (var msg in message.Tags.OfType<FormattedMessage.TagText>())
+            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 (file)
index 0000000..478f1b9
--- /dev/null
@@ -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();
+    }
+}
index e5771b06bf80cbef81388db89f4c7a99dc315d51..1eed657d0f0092064115867013c794cbd1b0d212 100644 (file)
@@ -319,7 +319,7 @@ namespace Content.Shared.Examine
         /// <seealso cref="PushText"/>
         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 (file)
index 0000000..cc943aa
--- /dev/null
@@ -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
index 039f22f6d6c18b5ad697674dbc634ede8f5049cb..1c63692e88145582d2fbf900045c38e5aace5af3 100644 (file)
@@ -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]:
 
 
 <GuideEntityEmbed Entity="MobGuidebookMonkey" Interactive="True" Caption=""/>
@@ -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.
index f569f8e334fba999f3b0bf70a7b1ba1e9d1ae079..efe7bd9dfd5107e8a3d36ae1cba5c6f7c6673a62 160000 (submodule)
@@ -1 +1 @@
-Subproject commit f569f8e334fba999f3b0bf70a7b1ba1e9d1ae079
+Subproject commit efe7bd9dfd5107e8a3d36ae1cba5c6f7c6673a62