From b2da9368485530a62a918af6f3b347bc993b69ab Mon Sep 17 00:00:00 2001 From: E F R <602406+Efruit@users.noreply.github.com> Date: Mon, 13 Dec 2021 02:25:42 +0000 Subject: [PATCH] Everything: Rich text redux (#5625) * lord save me * UI/ChatBox: Use the new `defStyle` param for `RenderMarkup` The previous iteration didn't work because `AddMessage` can't inherit its color from the PushColor (since we're not doing actual tag stacks anymore). * rebase touchup --- .../Actions/UI/ActionAlertTooltip.cs | 5 +- Content.Client/Actions/UI/ActionSlot.cs | 5 +- .../Administration/UI/BwoinkWindow.xaml.cs | 5 +- .../Changelog/ChangelogWindow.xaml.cs | 5 +- Content.Client/Chat/Managers/ChatManager.cs | 3 +- Content.Client/Chat/UI/ChatBox.xaml.cs | 9 +- .../ContextMenu/UI/ContextMenuElement.xaml.cs | 10 +- Content.Client/Credits/CreditsWindow.xaml.cs | 3 +- Content.Client/Examine/ExamineSystem.cs | 4 +- .../Roles/UI/GhostRoleRulesWindow.xaml.cs | 5 +- Content.Client/HUD/GameHud.cs | 3 +- Content.Client/Info/RulesAndInfoWindow.cs | 5 +- Content.Client/Info/ServerInfo.cs | 3 +- Content.Client/Message/RichTextLabelExt.cs | 3 +- Content.Client/Paper/UI/PaperWindow.xaml.cs | 5 +- Content.Client/Stylesheets/StyleBase.cs | 73 +++++++--- Content.Client/Stylesheets/StyleNano.cs | 126 ++++++++++++------ Content.Client/Stylesheets/StyleSpace.cs | 26 +--- Content.Server/Administration/BwoinkSystem.cs | 3 +- .../Atmos/Components/GasTankComponent.cs | 3 +- .../Botany/Components/PlantHolderComponent.cs | 3 +- .../Botany/Components/SeedComponent.cs | 3 +- Content.Server/Chat/Managers/ChatManager.cs | 17 +-- .../Components/MachineBoardComponent.cs | 3 +- .../Components/MachinePartComponent.cs | 3 +- .../Conditions/MachineFrameComplete.cs | 1 + Content.Server/Examine/ExamineSystem.cs | 7 +- Content.Server/Headset/HeadsetComponent.cs | 2 +- Content.Server/Labels/Label/LabelSystem.cs | 5 +- .../Components/EmergencyLightComponent.cs | 5 +- .../Components/HandheldLightComponent.cs | 3 +- .../Mind/Components/MindComponent.cs | 3 +- .../CrematoriumEntityStorageComponent.cs | 3 +- .../MorgueEntityStorageComponent.cs | 3 +- .../NodeContainer/NodeContainerComponent.cs | 23 ++-- .../Nutrition/EntitySystems/DrinkSystem.cs | 1 + Content.Server/Paper/PaperComponent.cs | 3 +- .../Components/ApcPowerReceiverComponent.cs | 3 +- .../Components/ExaminableBatteryComponent.cs | 3 +- .../Components/PowerCellComponent.cs | 3 +- .../Components/PowerCellSlotComponent.cs | 3 +- .../Components/HandheldRadioComponent.cs | 3 +- .../Suspicion/SuspicionRoleComponent.cs | 3 +- Content.Server/Toilet/ToiletComponent.cs | 3 +- Content.Server/Warps/WarpPointComponent.cs | 3 +- .../Ammunition/Components/AmmoBoxComponent.cs | 3 +- .../Ammunition/Components/AmmoComponent.cs | 3 +- .../Components/RangedMagazineComponent.cs | 3 +- .../Components/BoltActionBarrelComponent.cs | 3 +- .../Barrels/Components/PumpBarrelComponent.cs | 3 +- .../ServerMagazineBarrelComponent.cs | 3 +- .../Components/ServerRangedBarrelComponent.cs | 3 +- Content.Server/Window/WindowComponent.cs | 3 +- Content.Server/WireHacking/WiresComponent.cs | 3 +- .../Actions/Prototypes/BaseActionPrototype.cs | 10 +- Content.Shared/Alert/AlertPrototype.cs | 4 +- .../ArbitraryInsertConstructionGraphStep.cs | 3 +- .../Steps/ComponentConstructionGraphStep.cs | 17 ++- .../Steps/MaterialConstructionGraphStep.cs | 3 +- .../Steps/PrototypeConstructionGraphStep.cs | 6 +- Content.Shared/Examine/ExamineSystemShared.cs | 33 ++--- 61 files changed, 305 insertions(+), 214 deletions(-) diff --git a/Content.Client/Actions/UI/ActionAlertTooltip.cs b/Content.Client/Actions/UI/ActionAlertTooltip.cs index b64faa56b1..6a6dd268fe 100644 --- a/Content.Client/Actions/UI/ActionAlertTooltip.cs +++ b/Content.Client/Actions/UI/ActionAlertTooltip.cs @@ -4,6 +4,7 @@ using Robust.Client.UserInterface.Controls; using Robust.Shared.IoC; using Robust.Shared.Timing; using Robust.Shared.Utility; +using Robust.Shared.Utility.Markup; using static Robust.Client.UserInterface.Controls.BoxContainer; namespace Content.Client.Actions.UI @@ -68,7 +69,7 @@ namespace Content.Client.Actions.UI MaxWidth = TooltipTextMaxWidth, StyleClasses = {StyleNano.StyleClassTooltipActionRequirements} }; - requiresLabel.SetMessage(FormattedMessage.FromMarkup("[color=#635c5c]" + + requiresLabel.SetMessage(Basic.RenderMarkup("[color=#635c5c]" + requires + "[/color]")); vbox.AddChild(requiresLabel); @@ -88,7 +89,7 @@ namespace Content.Client.Actions.UI if (timeLeft > TimeSpan.Zero) { var duration = Cooldown.Value.End - Cooldown.Value.Start; - _cooldownLabel.SetMessage(FormattedMessage.FromMarkup( + _cooldownLabel.SetMessage(Basic.RenderMarkup( $"[color=#a10505]{duration.Seconds} sec cooldown ({timeLeft.Seconds + 1} sec remaining)[/color]")); _cooldownLabel.Visible = true; } diff --git a/Content.Client/Actions/UI/ActionSlot.cs b/Content.Client/Actions/UI/ActionSlot.cs index b6fc2bb2c4..c8fba1f50f 100644 --- a/Content.Client/Actions/UI/ActionSlot.cs +++ b/Content.Client/Actions/UI/ActionSlot.cs @@ -16,6 +16,7 @@ using Robust.Shared.Localization; using Robust.Shared.Maths; using Robust.Shared.Timing; using Robust.Shared.Utility; +using Robust.Shared.Utility.Markup; using static Robust.Client.UserInterface.Controls.BoxContainer; namespace Content.Client.Actions.UI @@ -478,10 +479,10 @@ namespace Content.Client.Actions.UI private FormattedMessage SlotNumberLabel() { - if (SlotNumber > 10) return FormattedMessage.FromMarkup(""); + if (SlotNumber > 10) return FormattedMessage.Empty; var number = Loc.GetString(SlotNumber == 10 ? "0" : SlotNumber.ToString()); var color = (ActionEnabled || !HasAssignment) ? EnabledColor : DisabledColor; - return FormattedMessage.FromMarkup("[color=" + color + "]" + number + "[/color]"); + return Basic.RenderMarkup("[color=" + color + "]" + number + "[/color]"); } private void UpdateIcons() diff --git a/Content.Client/Administration/UI/BwoinkWindow.xaml.cs b/Content.Client/Administration/UI/BwoinkWindow.xaml.cs index c3f000f6ca..7586a10649 100644 --- a/Content.Client/Administration/UI/BwoinkWindow.xaml.cs +++ b/Content.Client/Administration/UI/BwoinkWindow.xaml.cs @@ -18,6 +18,7 @@ using Robust.Shared.Maths; using Robust.Shared.Utility; using Robust.Shared.Network; using Robust.Shared.GameObjects; +using Robust.Shared.Utility.Markup; using YamlDotNet.RepresentationModel; namespace Content.Client.Administration.UI @@ -58,9 +59,7 @@ namespace Content.Client.Administration.UI public void ReceiveLine(string text) { - var formatted = new FormattedMessage(1); - formatted.AddMarkup(text); - TextOutput.AddMessage(formatted); + TextOutput.AddMessage(Basic.RenderMarkup(text)); } } } diff --git a/Content.Client/Changelog/ChangelogWindow.xaml.cs b/Content.Client/Changelog/ChangelogWindow.xaml.cs index a1b2d65eac..c66546a082 100644 --- a/Content.Client/Changelog/ChangelogWindow.xaml.cs +++ b/Content.Client/Changelog/ChangelogWindow.xaml.cs @@ -14,6 +14,7 @@ using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Maths; using Robust.Shared.Utility; +using Robust.Shared.Utility.Markup; using static Content.Client.Changelog.ChangelogManager; using static Robust.Client.UserInterface.Controls.BoxContainer; @@ -146,13 +147,13 @@ namespace Content.Client.Changelog Margin = new Thickness(6, 0, 0, 0), }; authorLabel.SetMessage( - FormattedMessage.FromMarkup(Loc.GetString("changelog-author-changed", ("author", author)))); + Basic.RenderMarkup(Loc.GetString("changelog-author-changed", ("author", author)))); ChangelogBody.AddChild(authorLabel); foreach (var change in groupedEntry.SelectMany(c => c.Changes)) { var text = new RichTextLabel(); - text.SetMessage(FormattedMessage.FromMarkup(change.Message)); + text.SetMessage(Basic.RenderMarkup(change.Message)); ChangelogBody.AddChild(new BoxContainer { Orientation = LayoutOrientation.Horizontal, diff --git a/Content.Client/Chat/Managers/ChatManager.cs b/Content.Client/Chat/Managers/ChatManager.cs index 60ea578aa1..34625be899 100644 --- a/Content.Client/Chat/Managers/ChatManager.cs +++ b/Content.Client/Chat/Managers/ChatManager.cs @@ -21,6 +21,7 @@ using Robust.Shared.Log; using Robust.Shared.Network; using Robust.Shared.Timing; using Robust.Shared.Utility; +using Robust.Shared.Utility.Markup; namespace Content.Client.Chat.Managers { @@ -420,7 +421,7 @@ namespace Content.Client.Chat.Managers return; } - var messages = SplitMessage(FormattedMessage.RemoveMarkup(msg.Message)); + var messages = SplitMessage(Basic.RenderMarkup(msg.Message).ToString()); foreach (var message in messages) { diff --git a/Content.Client/Chat/UI/ChatBox.xaml.cs b/Content.Client/Chat/UI/ChatBox.xaml.cs index 0199d0666a..d961cb3987 100644 --- a/Content.Client/Chat/UI/ChatBox.xaml.cs +++ b/Content.Client/Chat/UI/ChatBox.xaml.cs @@ -18,6 +18,7 @@ using Robust.Shared.Localization; using Robust.Shared.Log; using Robust.Shared.Maths; using Robust.Shared.Utility; +using Robust.Shared.Utility.Markup; namespace Content.Client.Chat.UI { @@ -395,7 +396,7 @@ namespace Content.Client.Chat.UI private void WriteChatMessage(StoredChatMessage message) { - var messageText = FormattedMessage.EscapeText(message.Message); + var messageText = Basic.EscapeText(message.Message); if (!string.IsNullOrEmpty(message.MessageWrap)) { messageText = string.Format(message.MessageWrap, messageText); @@ -502,11 +503,7 @@ namespace Content.Client.Chat.UI { DebugTools.Assert(!Disposed); - var formatted = new FormattedMessage(3); - formatted.PushColor(color); - formatted.AddMarkup(message); - formatted.Pop(); - Contents.AddMessage(formatted); + Contents.AddMessage(Basic.RenderMarkup(message, new Section{Color=color.ToArgb()})); } private void Input_OnTextEntered(LineEdit.LineEditEventArgs args) diff --git a/Content.Client/ContextMenu/UI/ContextMenuElement.xaml.cs b/Content.Client/ContextMenu/UI/ContextMenuElement.xaml.cs index c186e27fd5..2caba4ec71 100644 --- a/Content.Client/ContextMenu/UI/ContextMenuElement.xaml.cs +++ b/Content.Client/ContextMenu/UI/ContextMenuElement.xaml.cs @@ -7,6 +7,7 @@ using Robust.Client.UserInterface.XAML; using Robust.Shared.IoC; using Robust.Shared.Maths; using Robust.Shared.Utility; +using Robust.Shared.Utility.Markup; namespace Content.Client.ContextMenu.UI { @@ -45,7 +46,14 @@ namespace Content.Client.ContextMenu.UI /// /// Convenience property to set label text. /// - public string Text { set => Label.SetMessage(FormattedMessage.FromMarkupPermissive(value.Trim())); } + public string Text { + set + { + var b = new Basic(); + b.AddMarkupPermissive(value.Trim()); + Label.SetMessage(b.Render()); + } + } public ContextMenuElement(string? text = null) { diff --git a/Content.Client/Credits/CreditsWindow.xaml.cs b/Content.Client/Credits/CreditsWindow.xaml.cs index 2cd65733e9..cbf9ebe93c 100644 --- a/Content.Client/Credits/CreditsWindow.xaml.cs +++ b/Content.Client/Credits/CreditsWindow.xaml.cs @@ -15,6 +15,7 @@ using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Maths; using Robust.Shared.Utility; +using Robust.Shared.Utility.Markup; using YamlDotNet.RepresentationModel; using static Robust.Client.UserInterface.Controls.BoxContainer; @@ -143,7 +144,7 @@ namespace Content.Client.Credits var text = _resourceManager.ContentFileReadAllText($"/Credits/{path}"); if (markup) { - label.SetMessage(FormattedMessage.FromMarkup(text.Trim())); + label.SetMessage(Basic.RenderMarkup(text.Trim())); } else { diff --git a/Content.Client/Examine/ExamineSystem.cs b/Content.Client/Examine/ExamineSystem.cs index d3c3c90eaa..58fc9fc05f 100644 --- a/Content.Client/Examine/ExamineSystem.cs +++ b/Content.Client/Examine/ExamineSystem.cs @@ -181,9 +181,9 @@ namespace Content.Client.Examine message = response.Message; } - foreach (var msg in message.Tags.OfType()) + foreach (var msg in message.Sections) { - if (string.IsNullOrWhiteSpace(msg.Text)) continue; + if (string.IsNullOrWhiteSpace(msg.Content)) continue; var richLabel = new RichTextLabel(); richLabel.SetMessage(message); diff --git a/Content.Client/Ghost/Roles/UI/GhostRoleRulesWindow.xaml.cs b/Content.Client/Ghost/Roles/UI/GhostRoleRulesWindow.xaml.cs index 307c47dded..8aec632f6b 100644 --- a/Content.Client/Ghost/Roles/UI/GhostRoleRulesWindow.xaml.cs +++ b/Content.Client/Ghost/Roles/UI/GhostRoleRulesWindow.xaml.cs @@ -7,6 +7,7 @@ using Robust.Client.UserInterface.XAML; using Robust.Shared.Localization; using Robust.Shared.Timing; using Robust.Shared.Utility; +using Robust.Shared.Utility.Markup; namespace Content.Client.Ghost.Roles.UI { @@ -17,7 +18,9 @@ namespace Content.Client.Ghost.Roles.UI public GhostRoleRulesWindow(string rules, Action requestAction) { RobustXamlLoader.Load(this); - Title.SetMessage(FormattedMessage.FromMarkupPermissive(rules + "\n" + Loc.GetString("ghost-roles-window-rules-footer"))); + var b = new Basic(); + b.AddMarkupPermissive(rules + "\n" + Loc.GetString("ghost-roles-window-rules-footer")); + Title.SetMessage(b.Render()); RequestButton.OnPressed += requestAction; } diff --git a/Content.Client/HUD/GameHud.cs b/Content.Client/HUD/GameHud.cs index 6da65b2f20..4fd89226c2 100644 --- a/Content.Client/HUD/GameHud.cs +++ b/Content.Client/HUD/GameHud.cs @@ -24,6 +24,7 @@ using Robust.Shared.Log; using Robust.Shared.Maths; using Robust.Shared.Prototypes; using Robust.Shared.Utility; +using Robust.Shared.Utility.Markup; using static Robust.Client.Input.Keyboard.Key; using static Robust.Client.UserInterface.Controls.BoxContainer; using Control = Robust.Client.UserInterface.Control; @@ -727,7 +728,7 @@ namespace Content.Client.HUD private string? DefaultShortKeyName(BoundKeyFunction keyFunction) { - var name = FormattedMessage.EscapeText(_inputManager.GetKeyFunctionButtonString(keyFunction)); + var name = Basic.EscapeText(_inputManager.GetKeyFunctionButtonString(keyFunction)); return name.Length > 3 ? null : name; } diff --git a/Content.Client/Info/RulesAndInfoWindow.cs b/Content.Client/Info/RulesAndInfoWindow.cs index 25f5a8f5d7..5132d674a0 100644 --- a/Content.Client/Info/RulesAndInfoWindow.cs +++ b/Content.Client/Info/RulesAndInfoWindow.cs @@ -11,6 +11,7 @@ using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Maths; using Robust.Shared.Utility; +using Robust.Shared.Utility.Markup; using static Robust.Client.UserInterface.Controls.BoxContainer; namespace Content.Client.Info @@ -80,7 +81,7 @@ namespace Content.Client.Info var text = _resourceManager.ContentFileReadAllText($"/Server Info/{path}"); if (markup) { - label.SetMessage(FormattedMessage.FromMarkup(text.Trim())); + label.SetMessage(Basic.RenderMarkup(text.Trim())); } else { @@ -122,7 +123,7 @@ namespace Content.Client.Info var text = _resourceManager.ContentFileReadAllText($"/Server Info/{path}"); if (markup) { - label.SetMessage(FormattedMessage.FromMarkup(text.Trim())); + label.SetMessage(Basic.RenderMarkup(text.Trim())); } else { diff --git a/Content.Client/Info/ServerInfo.cs b/Content.Client/Info/ServerInfo.cs index d670a43458..16de98b95e 100644 --- a/Content.Client/Info/ServerInfo.cs +++ b/Content.Client/Info/ServerInfo.cs @@ -6,6 +6,7 @@ using Robust.Client.UserInterface.Controls; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Utility; +using Robust.Shared.Utility.Markup; namespace Content.Client.Info { @@ -62,7 +63,7 @@ namespace Content.Client.Info public void SetInfoBlob(string markup) { - _richTextLabel.SetMessage(FormattedMessage.FromMarkup(markup)); + _richTextLabel.SetMessage(Basic.RenderMarkup(markup)); } } } diff --git a/Content.Client/Message/RichTextLabelExt.cs b/Content.Client/Message/RichTextLabelExt.cs index df2c61e306..3f3b8008a8 100644 --- a/Content.Client/Message/RichTextLabelExt.cs +++ b/Content.Client/Message/RichTextLabelExt.cs @@ -1,5 +1,6 @@ using Robust.Client.UserInterface.Controls; using Robust.Shared.Utility; +using Robust.Shared.Utility.Markup; namespace Content.Client.Message { @@ -7,7 +8,7 @@ namespace Content.Client.Message { public static void SetMarkup(this RichTextLabel label, string markup) { - label.SetMessage(FormattedMessage.FromMarkup(markup)); + label.SetMessage(Basic.RenderMarkup(markup)); } } } diff --git a/Content.Client/Paper/UI/PaperWindow.xaml.cs b/Content.Client/Paper/UI/PaperWindow.xaml.cs index a35af8fd10..6dfc11d85b 100644 --- a/Content.Client/Paper/UI/PaperWindow.xaml.cs +++ b/Content.Client/Paper/UI/PaperWindow.xaml.cs @@ -4,6 +4,7 @@ using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.XAML; using Robust.Shared.Utility; +using Robust.Shared.Utility.Markup; namespace Content.Client.Paper.UI { @@ -21,9 +22,9 @@ namespace Content.Client.Paper.UI { Input.Visible = true; } - var msg = new FormattedMessage(); + var msg = new Basic(); msg.AddMarkupPermissive(state.Text); - Label.SetMessage(msg); + Label.SetMessage(msg.Render()); } } } diff --git a/Content.Client/Stylesheets/StyleBase.cs b/Content.Client/Stylesheets/StyleBase.cs index 5804d39134..d5735addbe 100644 --- a/Content.Client/Stylesheets/StyleBase.cs +++ b/Content.Client/Stylesheets/StyleBase.cs @@ -4,6 +4,7 @@ using Robust.Client.ResourceManagement; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; +using Robust.Shared.Utility; using Robust.Shared.Maths; namespace Content.Client.Stylesheets @@ -39,28 +40,57 @@ namespace Content.Client.Stylesheets protected StyleBoxTexture BaseAngleRect { get; } + protected IFontLibrary FontLib { get; } + protected StyleBase(IResourceCache resCache) { - var notoSans12 = resCache.GetFont - ( - new [] - { - "/Fonts/NotoSans/NotoSans-Regular.ttf", - "/Fonts/NotoSans/NotoSansSymbols-Regular.ttf", - "/Fonts/NotoSans/NotoSansSymbols2-Regular.ttf" - }, - 12 - ); - var notoSans12Italic = resCache.GetFont - ( - new [] - { - "/Fonts/NotoSans/NotoSans-Italic.ttf", - "/Fonts/NotoSans/NotoSansSymbols-Regular.ttf", - "/Fonts/NotoSans/NotoSansSymbols2-Regular.ttf" - }, - 12 + FontLib = new FontLibrary( + new FontClass(Id: "notosans", Style: (FontStyle) default, Size: (FontSize) 12) + ) as IFontLibrary; + + FontLib.AddFont("notosans", + new FontVariant + ( + FontStyle.Normal, + new [] + { + resCache.GetResource("/Fonts/NotoSans/NotoSans-Regular.ttf"), + resCache.GetResource("/Fonts/NotoSans/NotoSansSymbols-Regular.ttf"), + resCache.GetResource("/Fonts/NotoSans/NotoSansSymbols2-Regular.ttf") + } + ), + new FontVariant + ( + FontStyle.Italic, + new [] + { + resCache.GetResource("/Fonts/NotoSans/NotoSans-Italic.ttf"), + resCache.GetResource("/Fonts/NotoSans/NotoSansSymbols-Regular.ttf"), + resCache.GetResource("/Fonts/NotoSans/NotoSansSymbols2-Regular.ttf") + } + ), + new FontVariant + ( + FontStyle.Bold, + new [] + { + resCache.GetResource("/Fonts/NotoSans/NotoSans-Bold.ttf"), + resCache.GetResource("/Fonts/NotoSans/NotoSansSymbols-Bold.ttf"), + resCache.GetResource("/Fonts/NotoSans/NotoSansSymbols2-Regular.ttf") + } + ), + new FontVariant + ( + FontStyle.Bold | FontStyle.Italic, + new [] + { + resCache.GetResource("/Fonts/NotoSans/NotoSans-BoldItalic.ttf"), + resCache.GetResource("/Fonts/NotoSans/NotoSansSymbols-Bold.ttf"), + resCache.GetResource("/Fonts/NotoSans/NotoSansSymbols2-Regular.ttf") + } + ) ); + var textureCloseButton = resCache.GetTexture("/Textures/Interface/Nano/cross.svg.png"); // Button styles. @@ -151,7 +181,8 @@ namespace Content.Client.Stylesheets new SelectorElement(null, null, null, null), new[] { - new StyleProperty("font", notoSans12), + new StyleProperty("font-library", FontLib), + new StyleProperty("font", new FontClass("notosans", (FontStyle) default, (FontSize) 12)), }), // Default font. @@ -159,7 +190,7 @@ namespace Content.Client.Stylesheets new SelectorElement(null, new[] {StyleClassItalic}, null, null), new[] { - new StyleProperty("font", notoSans12Italic), + new StyleProperty("font", new FontClass("notosans", FontStyle.Italic, (FontSize) 12)), }), // Window close button base texture. diff --git a/Content.Client/Stylesheets/StyleNano.cs b/Content.Client/Stylesheets/StyleNano.cs index 5f92cc88c5..56138d2c1d 100644 --- a/Content.Client/Stylesheets/StyleNano.cs +++ b/Content.Client/Stylesheets/StyleNano.cs @@ -14,6 +14,7 @@ using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; using Robust.Shared.Maths; +using Robust.Shared.Utility; using static Robust.Client.UserInterface.StylesheetHelpers; namespace Content.Client.Stylesheets @@ -109,19 +110,49 @@ namespace Content.Client.Stylesheets public StyleNano(IResourceCache resCache) : base(resCache) { - var notoSans10 = resCache.notoStack(size: 10); - var notoSansItalic10 = resCache.notoStack(variation: "Italic", size: 10); - var notoSans12 = resCache.notoStack(size: 12); - var notoSansItalic12 = resCache.notoStack(variation: "Italic", size: 12); - var notoSansBold12 = resCache.notoStack(variation: "Bold", size: 12); - var notoSansBoldItalic12 = resCache.notoStack(variation: "BoldItalic", size: 12); - var notoSansDisplayBold14 = resCache.notoStack(variation: "Bold", display: true, size: 14); - var notoSansDisplayBold16 = resCache.notoStack(variation: "Bold", display: true, size: 16); - var notoSans15 = resCache.notoStack(variation: "Regular", size: 15); - var notoSans16 = resCache.notoStack(variation: "Regular", size: 16); - var notoSansBold16 = resCache.notoStack(variation: "Bold", size: 16); - var notoSansBold18 = resCache.notoStack(variation: "Bold", size: 18); - var notoSansBold20 = resCache.notoStack(variation: "Bold", size: 20); + FontLib.AddFont("notosansdisplay", + new FontVariant + ( + FontStyle.Normal, + new [] + { + resCache.GetResource("/Fonts/NotoSansDisplay/NotoSansDisplay-Regular.ttf"), + resCache.GetResource("/Fonts/NotoSans/NotoSansSymbols-Regular.ttf"), + resCache.GetResource("/Fonts/NotoSans/NotoSansSymbols2-Regular.ttf") + } + ), + new FontVariant + ( + FontStyle.Bold, + new [] + { + resCache.GetResource("/Fonts/NotoSansDisplay/NotoSansDisplay-Bold.ttf"), + resCache.GetResource("/Fonts/NotoSans/NotoSansSymbols-Regular.ttf"), + resCache.GetResource("/Fonts/NotoSans/NotoSansSymbols2-Regular.ttf") + } + ), + new FontVariant + ( + FontStyle.Italic, + new [] + { + resCache.GetResource("/Fonts/NotoSansDisplay/NotoSansDisplay-Italic.ttf"), + resCache.GetResource("/Fonts/NotoSans/NotoSansSymbols-Regular.ttf"), + resCache.GetResource("/Fonts/NotoSans/NotoSansSymbols2-Regular.ttf") + } + ), + new FontVariant + ( + FontStyle.Bold | FontStyle.Italic, + new [] + { + resCache.GetResource("/Fonts/NotoSansDisplay/NotoSansDisplay-BoldItalic.ttf"), + resCache.GetResource("/Fonts/NotoSans/NotoSansSymbols-Bold.ttf"), + resCache.GetResource("/Fonts/NotoSans/NotoSansSymbols2-Regular.ttf") + } + ) + ); + var windowHeaderTex = resCache.GetTexture("/Textures/Interface/Nano/window_header.png"); var windowHeader = new StyleBoxTexture { @@ -428,7 +459,16 @@ namespace Content.Client.Stylesheets var sliderFillRed = new StyleBoxTexture(sliderFillBox) {Modulate = Color.Red}; var sliderFillBlue = new StyleBoxTexture(sliderFillBox) {Modulate = Color.Blue}; - var boxFont13 = resCache.GetFont("/Fonts/Boxfont-round/Boxfont Round.ttf", 13); + FontLib.AddFont("box", + new FontVariant + ( + (FontStyle) default, + new [] + { + resCache.GetResource("/Fonts/Boxfont-round/Boxfont Round.ttf") + } + ) + ); var insetBack = new StyleBoxTexture { @@ -445,7 +485,7 @@ namespace Content.Client.Stylesheets new[] { new StyleProperty(Label.StylePropertyFontColor, NanoGold), - new StyleProperty(Label.StylePropertyFont, notoSansDisplayBold14), + new StyleProperty(Label.StylePropertyFont, new FontClass("notosansdisplay", FontStyle.Bold, (FontSize) 14)), }), // Alert (white) window title. new StyleRule( @@ -453,7 +493,7 @@ namespace Content.Client.Stylesheets new[] { new StyleProperty(Label.StylePropertyFontColor, Color.White), - new StyleProperty(Label.StylePropertyFont, notoSansDisplayBold14), + new StyleProperty(Label.StylePropertyFont, new FontClass("notosansdisplay", FontStyle.Bold, (FontSize) 14)), }), // Window background. new StyleRule( @@ -603,16 +643,16 @@ namespace Content.Client.Stylesheets // Context Menu Labels Element().Class(VerbMenuElement.StyleClassVerbInteractionText) - .Prop(Label.StylePropertyFont, notoSansBoldItalic12), + .Prop(Label.StylePropertyFont, new FontClass("notosans", FontStyle.Bold | FontStyle.Italic, (FontSize) 12)), Element().Class(VerbMenuElement.StyleClassVerbActivationText) - .Prop(Label.StylePropertyFont, notoSansBold12), + .Prop(Label.StylePropertyFont, new FontClass("notosans", FontStyle.Bold, (FontSize) 12)), Element().Class(VerbMenuElement.StyleClassVerbAlternativeText) - .Prop(Label.StylePropertyFont, notoSansItalic12), + .Prop(Label.StylePropertyFont, new FontClass("notosans", FontStyle.Italic, (FontSize) 12)), Element().Class(VerbMenuElement.StyleClassVerbOtherText) - .Prop(Label.StylePropertyFont, notoSans12), + .Prop(Label.StylePropertyFont, new FontClass("notosans", (FontStyle) default, (FontSize) 12)), // Thin buttons (No padding nor vertical margin) Element().Class(StyleClassStorageButton) @@ -677,7 +717,7 @@ namespace Content.Client.Stylesheets new SelectorElement(typeof(Label), null, null, null)), new[] { - new StyleProperty("font", notoSansBold16), + new StyleProperty("font", new FontClass("notosans", FontStyle.Bold, (FontSize) 16)), }), // Main menu: also make those buttons slightly more separated. @@ -783,52 +823,52 @@ namespace Content.Client.Stylesheets new SelectorElement(typeof(RichTextLabel), null, null, null)), new[] { - new StyleProperty("font", notoSansItalic12), + new StyleProperty("font", new FontClass("notosans", FontStyle.Italic, (FontSize) 12)), }), // alert tooltip new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] {StyleClassTooltipAlertTitle}, null, null), new[] { - new StyleProperty("font", notoSansBold18) + new StyleProperty("font", new FontClass("notosans", FontStyle.Bold, (FontSize) 18)) }), new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] {StyleClassTooltipAlertDescription}, null, null), new[] { - new StyleProperty("font", notoSans16) + new StyleProperty("font", new FontClass("notosans", (FontStyle) default, (FontSize) 16)) }), new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] {StyleClassTooltipAlertCooldown}, null, null), new[] { - new StyleProperty("font", notoSans16) + new StyleProperty("font", new FontClass("notosans", (FontStyle) default, (FontSize) 16)) }), // action tooltip new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] {StyleClassTooltipActionTitle}, null, null), new[] { - new StyleProperty("font", notoSansBold16) + new StyleProperty("font", new FontClass("notosans", FontStyle.Bold, (FontSize) 16)) }), new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] {StyleClassTooltipActionDescription}, null, null), new[] { - new StyleProperty("font", notoSans15) + new StyleProperty("font", new FontClass("notosans", (FontStyle) default, (FontSize) 15)) }), new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] {StyleClassTooltipActionCooldown}, null, null), new[] { - new StyleProperty("font", notoSans15) + new StyleProperty("font", new FontClass("notosans", (FontStyle) default, (FontSize) 15)) }), new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] {StyleClassTooltipActionRequirements}, null, null), new[] { - new StyleProperty("font", notoSans15) + new StyleProperty("font", new FontClass("notosans", (FontStyle) default, (FontSize) 15)) }), // small number for the entity counter in the entity menu new StyleRule(new SelectorElement(typeof(Label), new[] {EntityMenuElement.StyleClassEntityMenuCountText}, null, null), new[] { - new StyleProperty("font", notoSans10), + new StyleProperty("font", new FontClass("notosans", (FontStyle) default, (FontSize) 10)), new StyleProperty(Label.StylePropertyAlignMode, Label.AlignMode.Right), }), // hotbar slot new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] {StyleClassHotbarSlotNumber}, null, null), new[] { - new StyleProperty("font", notoSansDisplayBold16) + new StyleProperty("font", new FontClass("notosansdisplay", FontStyle.Bold, (FontSize) 16)) }), // Entity tooltip @@ -885,14 +925,14 @@ namespace Content.Client.Stylesheets new StyleRule( new SelectorElement(typeof(Label), new[] {Placeholder.StyleClassPlaceholderText}, null, null), new[] { - new StyleProperty(Label.StylePropertyFont, notoSans16), + new StyleProperty(Label.StylePropertyFont, new FontClass("notosans", (FontStyle) default, (FontSize) 16)), new StyleProperty(Label.StylePropertyFontColor, new Color(103, 103, 103, 128)), }), // Big Label new StyleRule(new SelectorElement(typeof(Label), new[] {StyleClassLabelHeading}, null, null), new[] { - new StyleProperty(Label.StylePropertyFont, notoSansBold16), + new StyleProperty(Label.StylePropertyFont, new FontClass("notosans", FontStyle.Bold, (FontSize) 16)), new StyleProperty(Label.StylePropertyFontColor, NanoGold), }), @@ -900,28 +940,28 @@ namespace Content.Client.Stylesheets new StyleRule(new SelectorElement(typeof(Label), new[] {StyleClassLabelHeadingBigger}, null, null), new[] { - new StyleProperty(Label.StylePropertyFont, notoSansBold20), + new StyleProperty(Label.StylePropertyFont, new FontClass("notosans", FontStyle.Bold, (FontSize) 20)), new StyleProperty(Label.StylePropertyFontColor, NanoGold), }), // Small Label new StyleRule(new SelectorElement(typeof(Label), new[] {StyleClassLabelSubText}, null, null), new[] { - new StyleProperty(Label.StylePropertyFont, notoSans10), + new StyleProperty(Label.StylePropertyFont, new FontClass("notosans", (FontStyle) default, (FontSize) 10)), new StyleProperty(Label.StylePropertyFontColor, Color.DarkGray), }), // Label Key new StyleRule(new SelectorElement(typeof(Label), new[] {StyleClassLabelKeyText}, null, null), new[] { - new StyleProperty(Label.StylePropertyFont, notoSansBold12), + new StyleProperty(Label.StylePropertyFont, new FontClass("notosans", FontStyle.Bold, (FontSize) 12)), new StyleProperty(Label.StylePropertyFontColor, NanoGold) }), new StyleRule(new SelectorElement(typeof(Label), new[] {StyleClassLabelSecondaryColor}, null, null), new[] { - new StyleProperty(Label.StylePropertyFont, notoSans12), + new StyleProperty(Label.StylePropertyFont, new FontClass("notosans", (FontStyle) default, (FontSize) 12)), new StyleProperty(Label.StylePropertyFontColor, Color.DarkGray), }), @@ -931,14 +971,14 @@ namespace Content.Client.Stylesheets new SelectorElement(typeof(Label), null, null, null)), new[] { - new StyleProperty("font", notoSans16) + new StyleProperty("font", new FontClass("notosans", (FontStyle) default, (FontSize) 16)) }), // Popup messages new StyleRule(new SelectorElement(typeof(Label), new[] {StyleClassPopupMessage}, null, null), new[] { - new StyleProperty("font", notoSansItalic10), + new StyleProperty("font", new FontClass("notosans", FontStyle.Italic, (FontSize) 10)), new StyleProperty("font-color", Color.LightGray), }), @@ -1029,7 +1069,7 @@ namespace Content.Client.Stylesheets new SelectorElement(typeof(Label), new[] {GameHud.TopButton.StyleClassLabelTopButton}, null, null), new[] { - new StyleProperty(Label.StylePropertyFont, notoSansDisplayBold14), + new StyleProperty(Label.StylePropertyFont, new FontClass("notosansdisplay", FontStyle.Bold, (FontSize) 14)), }), // Targeting doll @@ -1079,13 +1119,13 @@ namespace Content.Client.Stylesheets SelectorElement.Class(StyleClassLabelBig), new[] { - new StyleProperty("font", notoSans16), + new StyleProperty("font", new FontClass("notosans", (FontStyle) default, (FontSize) 16)), }), // StyleClassItemStatus new StyleRule(SelectorElement.Class(StyleClassItemStatus), new[] { - new StyleProperty("font", notoSans10), + new StyleProperty("font", new FontClass("notosans", (FontStyle) default, (FontSize) 10)), }), // Slider @@ -1190,7 +1230,7 @@ namespace Content.Client.Stylesheets }), Element