public void LoadFrom(YamlMappingNode mapping) { var serializer = YamlObjectSerializer.NewReader(mapping); serializer.DataField(this, x => x.IconPath, "icon", string.Empty); serializer.DataField(this, x => x.MaxSeverity, "maxSeverity", (short)-1); serializer.DataField(ref _minSeverity, "minSeverity", (short)1); serializer.DataReadFunction("name", string.Empty, s => Name = FormattedMessage.FromMarkup(s)); serializer.DataReadFunction("description", string.Empty, s => Description = FormattedMessage.FromMarkup(s)); serializer.DataField(this, x => x.AlertType, "alertType", AlertType.Error); if (AlertType == AlertType.Error) { Logger.ErrorS("alert", "missing or invalid alertType for alert with name {0}", Name); } if (serializer.TryReadDataField("category", out AlertCategory alertCategory)) { Category = alertCategory; } AlertKey = new AlertKey(AlertType, Category); }
public void SerializationTest(string text) { var message = FormattedMessage.FromMarkup(text); var node = Serialization.WriteValueAs <ValueDataNode>(message); Assert.That(node.Value, Is.EqualTo(text)); }
private void OnGetExamineVerbs(EntityUid uid, CableComponent component, GetVerbsEvent <ExamineVerb> args) { // Must be in details range to try this. // Theoretically there should be a separate range at which a multitool works, but this does just fine. if (_examineSystem.IsInDetailsRange(args.User, args.Target)) { var held = args.Using; // Pulsing is hardcoded here because I don't think it needs to be more complex than that right now. // Update if I'm wrong. var enabled = held != null && _toolSystem.HasQuality(held.Value, "Pulsing"); var verb = new ExamineVerb { Disabled = !enabled, Message = Loc.GetString("cable-multitool-system-verb-tooltip"), Text = Loc.GetString("cable-multitool-system-verb-name"), Category = VerbCategory.Examine, IconTexture = "/Textures/Interface/VerbIcons/zap.svg.192dpi.png", Act = () => { var markup = FormattedMessage.FromMarkup(GenerateCableMarkup(uid)); _examineSystem.SendExamineTooltip(args.User, uid, markup, false, false); } }; args.Verbs.Add(verb); } }
public void LoadFrom(YamlMappingNode mapping) { var serializer = YamlObjectSerializer.NewReader(mapping); serializer.DataField(this, x => x.Icon, "icon", SpriteSpecifier.Invalid); serializer.DataField(this, x => x.MaxSeverity, "maxSeverity", (short)-1); serializer.DataField(ref _minSeverity, "minSeverity", (short)1); serializer.DataReadFunction("name", string.Empty, s => Name = FormattedMessage.FromMarkup(s)); serializer.DataReadFunction("description", string.Empty, s => Description = FormattedMessage.FromMarkup(s)); serializer.DataField(this, x => x.AlertType, "alertType", AlertType.Error); if (AlertType == AlertType.Error) { Logger.ErrorS("alert", "missing or invalid alertType for alert with name {0}", Name); } if (serializer.TryReadDataField("category", out AlertCategory alertCategory)) { Category = alertCategory; } AlertKey = new AlertKey(AlertType, Category); HasOnClick = serializer.TryReadDataField("onClick", out string _); if (IoCManager.Resolve <IModuleManager>().IsClientModule) { return; } serializer.DataField(this, x => x.OnClick, "onClick", null); }
public virtual void LoadFrom(YamlMappingNode mapping) { var serializer = YamlObjectSerializer.NewReader(mapping); serializer.DataReadFunction("name", string.Empty, s => { ID = s; Name = FormattedMessage.FromMarkup(s); }); serializer.DataReadFunction("description", string.Empty, s => Description = FormattedMessage.FromMarkup(s)); serializer.DataField(this, x => x.Requires, "requires", null); serializer.DataField(this, x => x.Icon, "icon", SpriteSpecifier.Invalid); serializer.DataField(this, x => x.IconOn, "iconOn", SpriteSpecifier.Invalid); // client needs to know what type of behavior it is even if the actual implementation is only // on server side. If we wanted to avoid this we'd need to always add a shared or clientside interface // for each action even if there was only server-side logic, which would be cumbersome serializer.DataField(this, x => x.BehaviorType, "behaviorType", BehaviorType.None); if (BehaviorType == BehaviorType.None) { Logger.ErrorS("action", "Missing behaviorType for action with name {0}", Name); } if (BehaviorType != BehaviorType.Toggle && IconOn != SpriteSpecifier.Invalid) { Logger.ErrorS("action", "for action {0}, iconOn was specified but behavior" + " type was {1}. iconOn is only supported for Toggle behavior type.", Name); } serializer.DataField(this, x => x.Repeat, "repeat", false); if (Repeat && BehaviorType != BehaviorType.TargetEntity && BehaviorType != BehaviorType.TargetPoint) { Logger.ErrorS("action", " action named {0} used repeat: true, but this is only supported for" + " TargetEntity and TargetPoint behaviorType and its behaviorType is {1}", Name, BehaviorType); } serializer.DataField(this, x => x.DeselectOnCooldown, "deselectOnCooldown", false); serializer.DataField(this, x => x.DeselectWhenEntityNotClicked, "deselectWhenEntityNotClicked", false); serializer.DataReadFunction("filters", new List <string>(), rawTags => { Filters = rawTags.Select(rawTag => rawTag.Trim()).ToList(); }); serializer.DataReadFunction("keywords", new List <string>(), rawTags => { Keywords = rawTags.Select(rawTag => rawTag.Trim()).ToList(); }); }
public static void TestParseMarkupColorName() { var msg = FormattedMessage.FromMarkup("foo[color=orange]bar[/color]baz"); Assert.That(msg.Tags.Count, Is.EqualTo(5)); Assert.That(((FormattedMessage.TagText)msg.Tags[0]).Text, Is.EqualTo("foo")); Assert.That(((FormattedMessage.TagColor)msg.Tags[1]).Color, Is.EqualTo(Color.Orange)); Assert.That(((FormattedMessage.TagText)msg.Tags[2]).Text, Is.EqualTo("bar")); Assert.That(msg.Tags[3], Is.InstanceOf <FormattedMessage.TagPop>()); Assert.That(((FormattedMessage.TagText)msg.Tags[4]).Text, Is.EqualTo("baz")); }
public static void TestParseMarkupColorName() { var msg = FormattedMessage.FromMarkup("foo[color=orange]bar[/color]baz"); Assert.That(msg.Tags, NUnit.Framework.Is.EquivalentTo(new FormattedMessage.Tag[] { new FormattedMessage.TagText("foo"), new FormattedMessage.TagColor(Color.Orange), new FormattedMessage.TagText("bar"), FormattedMessage.TagPop.Instance, new FormattedMessage.TagText("baz") })); }
public InfoSection(string title, string text, bool markup = false) { RobustXamlLoader.Load(this); TitleLabel.Text = title; if (markup) { Content.SetMessage(FormattedMessage.FromMarkup(text.Trim())); } else { Content.SetMessage(text); } }
private void OnGetExamineVerbs(EntityUid uid, IdExaminableComponent component, GetVerbsEvent <ExamineVerb> args) { var detailsRange = _examineSystem.IsInDetailsRange(args.User, uid); var info = GetInfo(component.Owner) ?? Loc.GetString("id-examinable-component-verb-no-id"); var verb = new ExamineVerb() { Act = () => { var markup = FormattedMessage.FromMarkup(info); _examineSystem.SendExamineTooltip(args.User, uid, markup, false, false); }, Text = Loc.GetString("id-examinable-component-verb-text"), Category = VerbCategory.Examine, Disabled = !detailsRange, Message = Loc.GetString("id-examinable-component-verb-disabled"), IconTexture = "/Textures/Interface/VerbIcons/information.svg.192dpi.png" }; args.Verbs.Add(verb); }
private void AlertOnOnShowTooltip(object sender, EventArgs e) { var alertControl = (AlertControl)sender; _stateName.SetMessage(alertControl.Alert.Name); _stateDescription.SetMessage(alertControl.Alert.Description); // check for a cooldown if (alertControl.TotalDuration != null && alertControl.TotalDuration > 0) { _stateCooldown.SetMessage(FormattedMessage.FromMarkup("[color=#776a6a]" + alertControl.TotalDuration + " sec cooldown[/color]")); _stateCooldown.Visible = true; } else { _stateCooldown.Visible = false; } // TODO: Text display of cooldown Tooltips.PositionTooltip(_tooltip); // if we set it visible here the size of the previous tooltip will flicker for a frame, // so instead we wait until FrameUpdate to make it visible _tooltipReady = true; }
private void OnGetExamineVerbs(EntityUid uid, GasAnalyzableComponent component, GetVerbsEvent <ExamineVerb> args) { // Must be in details range to try this. if (_examineSystem.IsInDetailsRange(args.User, args.Target)) { var held = args.Using; var enabled = held != null && EntityManager.HasComponent <SharedGasAnalyzerComponent>(held); var verb = new ExamineVerb { Disabled = !enabled, Message = Loc.GetString("gas-analyzable-system-verb-tooltip"), Text = Loc.GetString("gas-analyzable-system-verb-name"), Category = VerbCategory.Examine, IconTexture = "/Textures/Interface/VerbIcons/examine.svg.192dpi.png", Act = () => { var markup = FormattedMessage.FromMarkup(GeneratePipeMarkup(uid)); _examineSystem.SendExamineTooltip(args.User, uid, markup, false, false); } }; args.Verbs.Add(verb); } }
public static void TestToMarkup(string text) { var message = FormattedMessage.FromMarkup(text); Assert.That(message.ToMarkup(), NUnit.Framework.Is.EqualTo(text)); }
public void SetInfoBlob(string markup) { _richTextLabel.SetMessage(FormattedMessage.FromMarkup(markup)); }
/// <summary> /// Push another message parsed from markup into this examine result, on its own line. /// </summary> /// <seealso cref="PushText"/> /// <seealso cref="PushMessage"/> public void PushMarkup(string markup) { PushMessage(FormattedMessage.FromMarkup(markup)); }
public static void SetMarkup(this RichTextLabel label, string markup) { label.SetMessage(FormattedMessage.FromMarkup(markup)); }