diff --git a/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml.cs b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml.cs index 7bb425f618e..c8d7e915a1e 100644 --- a/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml.cs +++ b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml.cs @@ -1,4 +1,4 @@ -using Content.Shared.Administration.Notes; +using Content.Shared.Administration.Notes; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface; using Robust.Client.UserInterface.XAML; @@ -13,7 +13,7 @@ public AdminMessagePopupMessage(AdminMessageEuiState.Message message) { RobustXamlLoader.Load(this); - Admin.SetMessage(FormattedMessage.FromMarkup(Loc.GetString( + Admin.SetMessage(FormattedMessage.FromMarkupOrThrow(Loc.GetString( "admin-notes-message-admin", ("admin", message.AdminName), ("date", message.AddedOn.ToLocalTime())))); diff --git a/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml.cs b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml.cs index bf2ca9bec41..148cbf4e18e 100644 --- a/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml.cs +++ b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml.cs @@ -49,7 +49,7 @@ public void SetState(AdminMessageEuiState state) MessageContainer.AddChild(new AdminMessagePopupMessage(message)); } - Description.SetMessage(FormattedMessage.FromMarkup(Loc.GetString("admin-notes-message-desc", ("count", state.Messages.Length)))); + Description.SetMessage(FormattedMessage.FromMarkupOrThrow(Loc.GetString("admin-notes-message-desc", ("count", state.Messages.Length)))); } private void OnDismissButtonPressed(BaseButton.ButtonEventArgs obj) diff --git a/Content.Client/Administration/UI/Bwoink/BwoinkPanel.xaml.cs b/Content.Client/Administration/UI/Bwoink/BwoinkPanel.xaml.cs index 7a032d0bbd7..833514e4aa2 100644 --- a/Content.Client/Administration/UI/Bwoink/BwoinkPanel.xaml.cs +++ b/Content.Client/Administration/UI/Bwoink/BwoinkPanel.xaml.cs @@ -59,7 +59,7 @@ public void ReceiveLine(SharedBwoinkSystem.BwoinkTextMessage message) Unread++; var formatted = new FormattedMessage(1); - formatted.AddMarkup($"[color=gray]{message.SentAt.ToShortTimeString()}[/color] {message.Text}"); + formatted.AddMarkupOrThrow($"[color=gray]{message.SentAt.ToShortTimeString()}[/color] {message.Text}"); TextOutput.AddMessage(formatted); LastMessage = message.SentAt; } diff --git a/Content.Client/Anomaly/Ui/AnomalyGeneratorBoundUserInterface.cs b/Content.Client/Anomaly/Ui/AnomalyGeneratorBoundUserInterface.cs index 5d1985485c4..f088ac1976b 100644 --- a/Content.Client/Anomaly/Ui/AnomalyGeneratorBoundUserInterface.cs +++ b/Content.Client/Anomaly/Ui/AnomalyGeneratorBoundUserInterface.cs @@ -1,7 +1,5 @@ using Content.Shared.Anomaly; -using Content.Shared.Gravity; using JetBrains.Annotations; -using Robust.Client.GameObjects; using Robust.Client.UserInterface; namespace Content.Client.Anomaly.Ui; diff --git a/Content.Client/Changelog/ChangelogTab.xaml.cs b/Content.Client/Changelog/ChangelogTab.xaml.cs index 8fbeaab5f40..ca86f8a6b2e 100644 --- a/Content.Client/Changelog/ChangelogTab.xaml.cs +++ b/Content.Client/Changelog/ChangelogTab.xaml.cs @@ -131,13 +131,13 @@ public void PopulateChangelog(ChangelogManager.Changelog changelog) Margin = new Thickness(6, 0, 0, 0), }; authorLabel.SetMessage( - FormattedMessage.FromMarkup(Loc.GetString("changelog-author-changed", ("author", author)))); + FormattedMessage.FromMarkupOrThrow(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(FormattedMessage.FromMarkupOrThrow(change.Message)); ChangelogBody.AddChild(new BoxContainer { Orientation = LayoutOrientation.Horizontal, diff --git a/Content.Client/Chat/UI/SpeechBubble.cs b/Content.Client/Chat/UI/SpeechBubble.cs index adb61d10e62..32e9f4ae9be 100644 --- a/Content.Client/Chat/UI/SpeechBubble.cs +++ b/Content.Client/Chat/UI/SpeechBubble.cs @@ -180,7 +180,7 @@ protected FormattedMessage FormatSpeech(string message, Color? fontColor = null) var msg = new FormattedMessage(); if (fontColor != null) msg.PushColor(fontColor.Value); - msg.AddMarkup(message); + msg.AddMarkupOrThrow(message); return msg; } diff --git a/Content.Client/Commands/ActionsCommands.cs b/Content.Client/Commands/ActionsCommands.cs index 593b8e82569..c155c7a9dea 100644 --- a/Content.Client/Commands/ActionsCommands.cs +++ b/Content.Client/Commands/ActionsCommands.cs @@ -1,6 +1,4 @@ using Content.Client.Actions; -using Content.Client.Actions; -using Content.Client.Mapping; using Content.Shared.Administration; using Robust.Shared.Console; diff --git a/Content.Client/Credits/CreditsWindow.xaml.cs b/Content.Client/Credits/CreditsWindow.xaml.cs index 1cdc1ee4c9b..3a56647d592 100644 --- a/Content.Client/Credits/CreditsWindow.xaml.cs +++ b/Content.Client/Credits/CreditsWindow.xaml.cs @@ -145,7 +145,7 @@ void AddSection(string title, string path, bool markup = false) var text = _resourceManager.ContentFileReadAllText($"/Credits/{path}"); if (markup) { - label.SetMessage(FormattedMessage.FromMarkup(text.Trim())); + label.SetMessage(FormattedMessage.FromMarkupOrThrow(text.Trim())); } else { diff --git a/Content.Client/CriminalRecords/CriminalRecordsConsoleWindow.xaml.cs b/Content.Client/CriminalRecords/CriminalRecordsConsoleWindow.xaml.cs index 21aa54c9622..7cae290fe17 100644 --- a/Content.Client/CriminalRecords/CriminalRecordsConsoleWindow.xaml.cs +++ b/Content.Client/CriminalRecords/CriminalRecordsConsoleWindow.xaml.cs @@ -227,7 +227,7 @@ private void PopulateRecordContainer(GeneralStationRecord stationRecord, Crimina StatusOptionButton.SelectId((int) criminalRecord.Status); if (criminalRecord.Reason is {} reason) { - var message = FormattedMessage.FromMarkup(Loc.GetString("criminal-records-console-wanted-reason")); + var message = FormattedMessage.FromMarkupOrThrow(Loc.GetString("criminal-records-console-wanted-reason")); message.AddText($": {reason}"); WantedReason.SetMessage(message); WantedReason.Visible = true; diff --git a/Content.Client/Gravity/GravitySystem.cs b/Content.Client/Gravity/GravitySystem.cs index 3e87f76ba2b..dd51436a1f5 100644 --- a/Content.Client/Gravity/GravitySystem.cs +++ b/Content.Client/Gravity/GravitySystem.cs @@ -1,4 +1,5 @@ using Content.Shared.Gravity; +using Content.Shared.Power; using Robust.Client.GameObjects; namespace Content.Client.Gravity; @@ -21,7 +22,7 @@ private void OnAppearanceChange(EntityUid uid, SharedGravityGeneratorComponent c if (args.Sprite == null) return; - if (_appearanceSystem.TryGetData(uid, GravityGeneratorVisuals.State, out var state, args.Component)) + if (_appearanceSystem.TryGetData(uid, PowerChargeVisuals.State, out var state, args.Component)) { if (comp.SpriteMap.TryGetValue(state, out var spriteState)) { @@ -30,7 +31,7 @@ private void OnAppearanceChange(EntityUid uid, SharedGravityGeneratorComponent c } } - if (_appearanceSystem.TryGetData(uid, GravityGeneratorVisuals.Charge, out var charge, args.Component)) + if (_appearanceSystem.TryGetData(uid, PowerChargeVisuals.Charge, out var charge, args.Component)) { var layer = args.Sprite.LayerMapGet(GravityGeneratorVisualLayers.Core); switch (charge) diff --git a/Content.Client/Gravity/UI/GravityGeneratorBoundUserInterface.cs b/Content.Client/Gravity/UI/GravityGeneratorBoundUserInterface.cs deleted file mode 100644 index 32b40747d55..00000000000 --- a/Content.Client/Gravity/UI/GravityGeneratorBoundUserInterface.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Content.Shared.Gravity; -using JetBrains.Annotations; -using Robust.Client.UserInterface; - -namespace Content.Client.Gravity.UI -{ - [UsedImplicitly] - public sealed class GravityGeneratorBoundUserInterface : BoundUserInterface - { - [ViewVariables] - private GravityGeneratorWindow? _window; - - public GravityGeneratorBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) - { - } - - protected override void Open() - { - base.Open(); - - _window = this.CreateWindow(); - _window.SetEntity(Owner); - } - - protected override void UpdateState(BoundUserInterfaceState state) - { - base.UpdateState(state); - - var castState = (SharedGravityGeneratorComponent.GeneratorState) state; - _window?.UpdateState(castState); - } - - public void SetPowerSwitch(bool on) - { - SendMessage(new SharedGravityGeneratorComponent.SwitchGeneratorMessage(on)); - } - } -} diff --git a/Content.Client/Gravity/UI/GravityGeneratorWindow.xaml.cs b/Content.Client/Gravity/UI/GravityGeneratorWindow.xaml.cs deleted file mode 100644 index 6f04133b594..00000000000 --- a/Content.Client/Gravity/UI/GravityGeneratorWindow.xaml.cs +++ /dev/null @@ -1,75 +0,0 @@ -using Content.Shared.Gravity; -using Robust.Client.AutoGenerated; -using Robust.Client.GameObjects; -using Robust.Client.UserInterface.Controls; -using Robust.Client.UserInterface.XAML; -using FancyWindow = Content.Client.UserInterface.Controls.FancyWindow; - -namespace Content.Client.Gravity.UI -{ - [GenerateTypedNameReferences] - public sealed partial class GravityGeneratorWindow : FancyWindow - { - private readonly ButtonGroup _buttonGroup = new(); - - public event Action? OnPowerSwitch; - - public GravityGeneratorWindow() - { - RobustXamlLoader.Load(this); - IoCManager.InjectDependencies(this); - - OnButton.Group = _buttonGroup; - OffButton.Group = _buttonGroup; - - OnButton.OnPressed += _ => OnPowerSwitch?.Invoke(true); - OffButton.OnPressed += _ => OnPowerSwitch?.Invoke(false); - } - - public void SetEntity(EntityUid uid) - { - EntityView.SetEntity(uid); - } - - public void UpdateState(SharedGravityGeneratorComponent.GeneratorState state) - { - if (state.On) - OnButton.Pressed = true; - else - OffButton.Pressed = true; - - PowerLabel.Text = Loc.GetString( - "gravity-generator-window-power-label", - ("draw", state.PowerDraw), - ("max", state.PowerDrawMax)); - - PowerLabel.SetOnlyStyleClass(MathHelper.CloseTo(state.PowerDraw, state.PowerDrawMax) ? "Good" : "Caution"); - - ChargeBar.Value = state.Charge; - ChargeText.Text = (state.Charge / 255f).ToString("P0"); - StatusLabel.Text = Loc.GetString(state.PowerStatus switch - { - GravityGeneratorPowerStatus.Off => "gravity-generator-window-status-off", - GravityGeneratorPowerStatus.Discharging => "gravity-generator-window-status-discharging", - GravityGeneratorPowerStatus.Charging => "gravity-generator-window-status-charging", - GravityGeneratorPowerStatus.FullyCharged => "gravity-generator-window-status-fully-charged", - _ => throw new ArgumentOutOfRangeException() - }); - - StatusLabel.SetOnlyStyleClass(state.PowerStatus switch - { - GravityGeneratorPowerStatus.Off => "Danger", - GravityGeneratorPowerStatus.Discharging => "Caution", - GravityGeneratorPowerStatus.Charging => "Caution", - GravityGeneratorPowerStatus.FullyCharged => "Good", - _ => throw new ArgumentOutOfRangeException() - }); - - EtaLabel.Text = state.EtaSeconds >= 0 - ? Loc.GetString("gravity-generator-window-eta-value", ("left", TimeSpan.FromSeconds(state.EtaSeconds))) - : Loc.GetString("gravity-generator-window-eta-none"); - - EtaLabel.SetOnlyStyleClass(state.EtaSeconds >= 0 ? "Caution" : "Disabled"); - } - } -} diff --git a/Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs b/Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs index 87931bf8455..f8d1c7e9720 100644 --- a/Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs +++ b/Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs @@ -140,7 +140,7 @@ private void GenerateControl(ReagentPrototype reagent) var i = 0; foreach (var effectString in effect.EffectDescriptions) { - descMsg.AddMarkup(effectString); + descMsg.AddMarkupOrThrow(effectString); i++; if (i < descriptionsCount) descMsg.PushNewline(); @@ -174,7 +174,7 @@ private void GenerateControl(ReagentPrototype reagent) var i = 0; foreach (var effectString in guideEntryRegistryPlant.PlantMetabolisms) { - descMsg.AddMarkup(effectString); + descMsg.AddMarkupOrThrow(effectString); i++; if (i < descriptionsCount) descMsg.PushNewline(); @@ -195,7 +195,7 @@ private void GenerateControl(ReagentPrototype reagent) FormattedMessage description = new(); description.AddText(reagent.LocalizedDescription); description.PushNewline(); - description.AddMarkup(Loc.GetString("guidebook-reagent-physical-description", + description.AddMarkupOrThrow(Loc.GetString("guidebook-reagent-physical-description", ("description", reagent.LocalizedPhysicalDescription))); ReagentDescription.SetMessage(description); } diff --git a/Content.Client/Guidebook/Controls/GuideReagentReaction.xaml.cs b/Content.Client/Guidebook/Controls/GuideReagentReaction.xaml.cs index 168f352d1ab..135dc5522ac 100644 --- a/Content.Client/Guidebook/Controls/GuideReagentReaction.xaml.cs +++ b/Content.Client/Guidebook/Controls/GuideReagentReaction.xaml.cs @@ -155,7 +155,7 @@ private void SetReagents(Dictionary reagents, ref RichTextL var i = 0; foreach (var (product, amount) in reagents.OrderByDescending(p => p.Value)) { - msg.AddMarkup(Loc.GetString("guidebook-reagent-recipes-reagent-display", + msg.AddMarkupOrThrow(Loc.GetString("guidebook-reagent-recipes-reagent-display", ("reagent", protoMan.Index(product).LocalizedName), ("ratio", amount))); i++; if (i < reagentCount) diff --git a/Content.Client/Info/InfoSection.xaml.cs b/Content.Client/Info/InfoSection.xaml.cs index ab9d352d32f..9e10a4d7b4b 100644 --- a/Content.Client/Info/InfoSection.xaml.cs +++ b/Content.Client/Info/InfoSection.xaml.cs @@ -1,4 +1,4 @@ -using Robust.Client.AutoGenerated; +using Robust.Client.AutoGenerated; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; using Robust.Shared.Utility; @@ -18,7 +18,7 @@ public void SetText(string title, string text, bool markup = false) { TitleLabel.Text = title; if (markup) - Content.SetMessage(FormattedMessage.FromMarkup(text.Trim())); + Content.SetMessage(FormattedMessage.FromMarkupOrThrow(text.Trim())); else Content.SetMessage(text); } diff --git a/Content.Client/Info/ServerInfo.cs b/Content.Client/Info/ServerInfo.cs index 23be7506267..901fc913374 100644 --- a/Content.Client/Info/ServerInfo.cs +++ b/Content.Client/Info/ServerInfo.cs @@ -24,7 +24,7 @@ public ServerInfo() } public void SetInfoBlob(string markup) { - _richTextLabel.SetMessage(FormattedMessage.FromMarkup(markup)); + _richTextLabel.SetMessage(FormattedMessage.FromMarkupOrThrow(markup)); } } } diff --git a/Content.Client/Message/RichTextLabelExt.cs b/Content.Client/Message/RichTextLabelExt.cs index 7ff6390764b..ee3c00fa1b8 100644 --- a/Content.Client/Message/RichTextLabelExt.cs +++ b/Content.Client/Message/RichTextLabelExt.cs @@ -15,7 +15,7 @@ public static class RichTextLabelExt /// public static RichTextLabel SetMarkup(this RichTextLabel label, string markup) { - label.SetMessage(FormattedMessage.FromMarkup(markup)); + label.SetMessage(FormattedMessage.FromMarkupOrThrow(markup)); return label; } diff --git a/Content.Client/Players/PlayTimeTracking/JobRequirementsManager.cs b/Content.Client/Players/PlayTimeTracking/JobRequirementsManager.cs index 8ce22489c71..6d52c50290e 100644 --- a/Content.Client/Players/PlayTimeTracking/JobRequirementsManager.cs +++ b/Content.Client/Players/PlayTimeTracking/JobRequirementsManager.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using Content.Client.Lobby; using Content.Shared.CCVar; using Content.Shared.Players; @@ -133,7 +133,7 @@ public bool CheckRoleRequirements(HashSet? requirements, Humanoi reasons.Add(jobReason.ToMarkup()); } - reason = reasons.Count == 0 ? null : FormattedMessage.FromMarkup(string.Join('\n', reasons)); + reason = reasons.Count == 0 ? null : FormattedMessage.FromMarkupOrThrow(string.Join('\n', reasons)); return reason == null; } diff --git a/Content.Client/Power/PowerCharge/PowerChargeBoundUserInterface.cs b/Content.Client/Power/PowerCharge/PowerChargeBoundUserInterface.cs new file mode 100644 index 00000000000..7a36b8ddf59 --- /dev/null +++ b/Content.Client/Power/PowerCharge/PowerChargeBoundUserInterface.cs @@ -0,0 +1,38 @@ +using Content.Shared.Power; +using Robust.Client.UserInterface; + +namespace Content.Client.Power.PowerCharge; + +public sealed class PowerChargeBoundUserInterface : BoundUserInterface +{ + [ViewVariables] + private PowerChargeWindow? _window; + + public PowerChargeBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) + { + } + + public void SetPowerSwitch(bool on) + { + SendMessage(new SwitchChargingMachineMessage(on)); + } + + protected override void Open() + { + base.Open(); + if (!EntMan.TryGetComponent(Owner, out PowerChargeComponent? component)) + return; + + _window = this.CreateWindow(); + _window.UpdateWindow(this, Loc.GetString(component.WindowTitle)); + } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + if (state is not PowerChargeState chargeState) + return; + + _window?.UpdateState(chargeState); + } +} diff --git a/Content.Client/Power/PowerCharge/PowerChargeComponent.cs b/Content.Client/Power/PowerCharge/PowerChargeComponent.cs new file mode 100644 index 00000000000..ab5baa4e2f5 --- /dev/null +++ b/Content.Client/Power/PowerCharge/PowerChargeComponent.cs @@ -0,0 +1,10 @@ +using Content.Shared.Power; + +namespace Content.Client.Power.PowerCharge; + +/// +[RegisterComponent] +public sealed partial class PowerChargeComponent : SharedPowerChargeComponent +{ + +} diff --git a/Content.Client/Gravity/UI/GravityGeneratorWindow.xaml b/Content.Client/Power/PowerCharge/PowerChargeWindow.xaml similarity index 60% rename from Content.Client/Gravity/UI/GravityGeneratorWindow.xaml rename to Content.Client/Power/PowerCharge/PowerChargeWindow.xaml index 853f437a2bf..4e61255326e 100644 --- a/Content.Client/Gravity/UI/GravityGeneratorWindow.xaml +++ b/Content.Client/Power/PowerCharge/PowerChargeWindow.xaml @@ -1,27 +1,26 @@  -