public void UpdateNote(SharedAdminNote note) { Note = note; _label?.SetMessage(note.Message); if (_edit != null && _edit.Text != note.Message) { _edit.Text = note.Message; } }
public PDAMenuPopup(string text) { var label = new RichTextLabel(); label.SetMessage(text); AddChild(new PanelContainer { StyleClasses = { ExamineSystem.StyleClassEntityTooltip }, Children = { label } }); }
public void Populate(SharedPaperComponent.PaperBoundUserInterfaceState state) { if (state.Mode == SharedPaperComponent.PaperAction.Write) { Input.Visible = true; } var msg = new FormattedMessage(); msg.AddMarkupPermissive(state.Text); _label.SetMessage(msg); }
private void AddFormattedText(string text) { if (VBox == null) { return; } var introLabel = new RichTextLabel(); var introMessage = new FormattedMessage(); introMessage.AddMarkup(text); introLabel.SetMessage(introMessage); VBox.AddChild(introLabel); }
private BoxContainer MakeRoundEndSummaryTab(string gamemode, string roundEnd, TimeSpan roundDuration, int roundId) { var roundEndSummaryTab = new BoxContainer { Orientation = LayoutOrientation.Vertical, Name = Loc.GetString("round-end-summary-window-round-end-summary-tab-title") }; var roundEndSummaryContainerScrollbox = new ScrollContainer { VerticalExpand = true }; var roundEndSummaryContainer = new BoxContainer { Orientation = LayoutOrientation.Vertical }; //Gamemode Name var gamemodeLabel = new RichTextLabel(); var gamemodeMessage = new FormattedMessage(); gamemodeMessage.AddMarkup(Loc.GetString("round-end-summary-window-round-id-label", ("roundId", roundId))); gamemodeMessage.AddText(" "); gamemodeMessage.AddMarkup(Loc.GetString("round-end-summary-window-gamemode-name-label", ("gamemode", gamemode))); gamemodeLabel.SetMessage(gamemodeMessage); roundEndSummaryContainer.AddChild(gamemodeLabel); //Duration var roundTimeLabel = new RichTextLabel(); roundTimeLabel.SetMarkup(Loc.GetString("round-end-summary-window-duration-label", ("hours", roundDuration.Hours), ("minutes", roundDuration.Minutes), ("seconds", roundDuration.Seconds))); roundEndSummaryContainer.AddChild(roundTimeLabel); //Round end text if (!string.IsNullOrEmpty(roundEnd)) { var roundEndLabel = new RichTextLabel(); roundEndLabel.SetMarkup(roundEnd); roundEndSummaryContainer.AddChild(roundEndLabel); } roundEndSummaryContainerScrollbox.AddChild(roundEndSummaryContainer); roundEndSummaryTab.AddChild(roundEndSummaryContainerScrollbox); return(roundEndSummaryTab); }
public TutorialWindow() { Title = "The Tutorial!"; var scrollContainer = new ScrollContainer(); Contents.AddChild(scrollContainer); var label = new RichTextLabel(); scrollContainer.AddChild(label); var message = new FormattedMessage(); message.AddText(TutorialContents); label.SetMessage(message); }
protected override Control BuildBubble(string text) { var label = new RichTextLabel { MaxWidth = 256, }; label.SetMessage(text); var panel = new PanelContainer { StyleClasses = { "speechBox", "sayBox" }, Children = { label }, ModulateSelfOverride = Color.White.WithAlpha(0.75f) }; return(panel); }
private void _openTutorialWindow() { var window = new SS14Window { Title = "Tutorial" }; var scrollContainer = new ScrollContainer(); window.Contents.AddChild(scrollContainer); var label = new RichTextLabel(); scrollContainer.AddChild(label); var message = new FormattedMessage(); message.AddText(TutorialContents); label.SetMessage(message); window.AddToScreen(); }
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; }
public async void DoExamine(IEntity entity) { CloseTooltip(); var popupPos = _inputManager.MouseScreenPosition; // Actually open the tooltip. _examineTooltipOpen = new Popup(); _userInterfaceManager.StateRoot.AddChild(_examineTooltipOpen); var panel = new PanelContainer(); panel.AddStyleClass(StyleClassEntityTooltip); panel.ModulateSelfOverride = Color.LightGray.WithAlpha(0.90f); _examineTooltipOpen.AddChild(panel); //panel.SetAnchorAndMarginPreset(Control.LayoutPreset.Wide); var vBox = new VBoxContainer(); panel.AddChild(vBox); var hBox = new HBoxContainer { SeparationOverride = 5 }; vBox.AddChild(hBox); if (entity.TryGetComponent(out ISpriteComponent sprite)) { hBox.AddChild(new SpriteView { Sprite = sprite }); } hBox.AddChild(new Label { Text = entity.Name, SizeFlagsHorizontal = Control.SizeFlags.FillExpand, }); const float minWidth = 300; var size = Vector2.ComponentMax((minWidth, 0), panel.CombinedMinimumSize); popupPos += Vector2.ComponentMin(Vector2.Zero, _userInterfaceManager.StateRoot.Size - (size + popupPos)); _examineTooltipOpen.Open(UIBox2.FromDimensions(popupPos, size)); if (entity.Uid.IsClientSide()) { return; } // Ask server for extra examine info. RaiseNetworkEvent(new ExamineSystemMessages.RequestExamineInfoMessage(entity.Uid)); ExamineSystemMessages.ExamineInfoResponseMessage response; try { _requestCancelTokenSource = new CancellationTokenSource(); response = await AwaitNetMessage <ExamineSystemMessages.ExamineInfoResponseMessage>(_requestCancelTokenSource .Token); } catch (TaskCanceledException) { return; } finally { _requestCancelTokenSource = null; } foreach (var msg in response.Message.Tags.OfType <FormattedMessage.TagText>()) { if (!string.IsNullOrWhiteSpace(msg.Text)) { var richLabel = new RichTextLabel(); richLabel.SetMessage(response.Message); vBox.AddChild(richLabel); break; } } //_examineTooltipOpen.Position += Vector2.ComponentMin(Vector2.Zero,_userInterfaceManager.StateRoot.Size - (panel.Size + _examineTooltipOpen.Position)); }
public void Execute(IConsoleShell shell, string argStr, string[] args) { var window = new DefaultWindow { MinSize = (500, 400) }; var tabContainer = new TabContainer(); window.Contents.AddChild(tabContainer); var scroll = new ScrollContainer(); tabContainer.AddChild(scroll); //scroll.SetAnchorAndMarginPreset(Control.LayoutPreset.Wide); var vBox = new BoxContainer { Orientation = LayoutOrientation.Vertical }; scroll.AddChild(vBox); var progressBar = new ProgressBar { MaxValue = 10, Value = 5 }; vBox.AddChild(progressBar); var optionButton = new OptionButton(); optionButton.AddItem("Honk"); optionButton.AddItem("Foo"); optionButton.AddItem("Bar"); optionButton.AddItem("Baz"); optionButton.OnItemSelected += eventArgs => optionButton.SelectId(eventArgs.Id); vBox.AddChild(optionButton); var tree = new Tree { VerticalExpand = true }; var root = tree.CreateItem(); root.Text = "Honk!"; var child = tree.CreateItem(); child.Text = "Foo"; for (var i = 0; i < 20; i++) { child = tree.CreateItem(); child.Text = $"Bar {i}"; } vBox.AddChild(tree); var rich = new RichTextLabel(); var message = new FormattedMessage(); message.AddText("Foo\n"); message.PushColor(Color.Red); message.AddText("Bar"); message.Pop(); rich.SetMessage(message); vBox.AddChild(rich); var itemList = new ItemList(); tabContainer.AddChild(itemList); for (var i = 0; i < 10; i++) { itemList.AddItem(i.ToString()); } var grid = new GridContainer { Columns = 3 }; tabContainer.AddChild(grid); for (var y = 0; y < 3; y++) { for (var x = 0; x < 3; x++) { grid.AddChild(new Button { MinSize = (50, 50), Text = $"{x}, {y}" });
public void SetInfoBlob(string markup) { _richTextLabel.SetMessage(FormattedMessage.FromMarkup(markup)); }
public void SetInfoBlob(string markup) { _richTextLabel.SetMessage(Basic.RenderMarkup(markup)); }
/// <summary> /// Creates an action slot for the specified number /// </summary> /// <param name="slotIndex">slot index this corresponds to, 0-9 (0 labeled as 1, 8, labeled "9", 9 labeled as "0".</param> public ActionSlot(ActionsUI actionsUI, ActionMenu actionMenu, byte slotIndex) { _actionsUI = actionsUI; _actionMenu = actionMenu; _gameTiming = IoCManager.Resolve <IGameTiming>(); SlotIndex = slotIndex; MouseFilter = MouseFilterMode.Stop; MinSize = (64, 64); VerticalAlignment = VAlignment.Top; TooltipDelay = CustomTooltipDelay; TooltipSupplier = SupplyTooltip; _number = new RichTextLabel { StyleClasses = { StyleNano.StyleClassHotbarSlotNumber } }; _number.SetMessage(SlotNumberLabel()); _bigActionIcon = new TextureRect { HorizontalExpand = true, VerticalExpand = true, Stretch = TextureRect.StretchMode.Scale, Visible = false }; _bigItemSpriteView = new SpriteView { HorizontalExpand = true, VerticalExpand = true, Scale = (2, 2), Visible = false, OverrideDirection = Direction.South, }; _smallActionIcon = new TextureRect { HorizontalAlignment = HAlignment.Right, VerticalAlignment = VAlignment.Bottom, Stretch = TextureRect.StretchMode.Scale, Visible = false }; _smallItemSpriteView = new SpriteView { HorizontalAlignment = HAlignment.Right, VerticalAlignment = VAlignment.Bottom, Visible = false, OverrideDirection = Direction.South, }; _cooldownGraphic = new CooldownGraphic { Progress = 0, Visible = false }; // padding to the left of the number to shift it right var paddingBox = new BoxContainer { Orientation = LayoutOrientation.Horizontal, HorizontalExpand = true, VerticalExpand = true, MinSize = (64, 64) }; paddingBox.AddChild(new Control() { MinSize = (4, 4), });
public async void DoExamine(IEntity entity) { const float minWidth = 300; CloseTooltip(); var popupPos = _userInterfaceManager.MousePositionScaled; // Actually open the tooltip. _examineTooltipOpen = new Popup(); _userInterfaceManager.ModalRoot.AddChild(_examineTooltipOpen); var panel = new PanelContainer(); panel.AddStyleClass(StyleClassEntityTooltip); panel.ModulateSelfOverride = Color.LightGray.WithAlpha(0.90f); _examineTooltipOpen.AddChild(panel); //panel.SetAnchorAndMarginPreset(Control.LayoutPreset.Wide); var vBox = new VBoxContainer(); panel.AddChild(vBox); var hBox = new HBoxContainer { SeparationOverride = 5 }; vBox.AddChild(hBox); if (entity.TryGetComponent(out ISpriteComponent sprite)) { hBox.AddChild(new SpriteView { Sprite = sprite }); } hBox.AddChild(new Label { Text = entity.Name, HorizontalExpand = true, }); panel.Measure(Vector2.Infinity); var size = Vector2.ComponentMax((minWidth, 0), panel.DesiredSize); _examineTooltipOpen.Open(UIBox2.FromDimensions(popupPos, size)); FormattedMessage message; if (entity.Uid.IsClientSide()) { message = GetExamineText(entity, _playerManager.LocalPlayer.ControlledEntity); } else { // Ask server for extra examine info. RaiseNetworkEvent(new ExamineSystemMessages.RequestExamineInfoMessage(entity.Uid)); ExamineSystemMessages.ExamineInfoResponseMessage response; try { _requestCancelTokenSource = new CancellationTokenSource(); response = await AwaitNetworkEvent <ExamineSystemMessages.ExamineInfoResponseMessage>(_requestCancelTokenSource .Token); } catch (TaskCanceledException) { return; } finally { _requestCancelTokenSource = null; } message = response.Message; } foreach (var msg in message.Tags.OfType <FormattedMessage.TagText>()) { if (!string.IsNullOrWhiteSpace(msg.Text)) { var richLabel = new RichTextLabel(); richLabel.SetMessage(message); vBox.AddChild(richLabel); break; } } }
public bool Execute(IDebugConsole console, params string[] args) { var window = new SS14Window("UITest"); window.AddToScreen(); var tabContainer = new TabContainer(); window.Contents.AddChild(tabContainer); var scroll = new ScrollContainer(); tabContainer.AddChild(scroll); scroll.SetAnchorAndMarginPreset(Control.LayoutPreset.Wide); var vBox = new VBoxContainer(); scroll.AddChild(vBox); var progressBar = new ProgressBar { MaxValue = 10, Value = 5 }; vBox.AddChild(progressBar); var optionButton = new OptionButton(); optionButton.AddItem("Honk"); optionButton.AddItem("Foo"); optionButton.AddItem("Bar"); optionButton.AddItem("Baz"); optionButton.OnItemSelected += eventArgs => optionButton.SelectId(eventArgs.Id); vBox.AddChild(optionButton); var tree = new Tree { SizeFlagsVertical = Control.SizeFlags.FillExpand }; var root = tree.CreateItem(); root.Text = "Honk!"; var child = tree.CreateItem(); child.Text = "Foo"; for (var i = 0; i < 20; i++) { child = tree.CreateItem(); child.Text = $"Bar {i}"; } vBox.AddChild(tree); var rich = new RichTextLabel(); var message = new FormattedMessage(); message.AddText("Foo\n"); message.PushColor(Color.Red); message.AddText("Bar"); message.Pop(); rich.SetMessage(message); vBox.AddChild(rich); var itemList = new ItemList(); tabContainer.AddChild(itemList); for (var i = 0; i < 10; i++) { itemList.AddItem(i.ToString()); } var grid = new GridContainer { Columns = 3 }; tabContainer.AddChild(grid); for (var y = 0; y < 3; y++) { for (var x = 0; x < 3; x++) { grid.AddChild(new Button { CustomMinimumSize = (50, 50), Text = $"{x}, {y}" });
public static void SetMarkup(this RichTextLabel label, string markup) { label.SetMessage(Basic.RenderMarkup(markup)); }
private void PopulateInfo(ConstructionPrototype prototype) { ClearInfo(); var isItem = prototype.Type == ConstructionType.Item; _buildButton.Disabled = false; _buildButton.Text = Loc.GetString(!isItem ? "Place construction ghost" : "Craft"); _targetName.SetMessage(prototype.Name); _targetDescription.SetMessage(prototype.Description); _targetTexture.Texture = prototype.Icon.Frame0(); if (!_prototypeManager.TryIndex(prototype.Graph, out ConstructionGraphPrototype graph)) { return; } var startNode = graph.Nodes[prototype.StartNode]; var targetNode = graph.Nodes[prototype.TargetNode]; var path = graph.Path(startNode.Name, targetNode.Name); var current = startNode; var stepNumber = 1; Texture?GetTextureForStep(ConstructionGraphStep step) { switch (step) { case MaterialConstructionGraphStep materialStep: switch (materialStep.Material) { case StackType.Metal: return(_resourceCache.GetTexture("/Textures/Objects/Materials/sheets.rsi/metal.png")); case StackType.Glass: return(_resourceCache.GetTexture("/Textures/Objects/Materials/sheets.rsi/glass.png")); case StackType.Plasteel: return(_resourceCache.GetTexture("/Textures/Objects/Materials/sheets.rsi/plasteel.png")); case StackType.Phoron: return(_resourceCache.GetTexture("/Textures/Objects/Materials/sheets.rsi/phoron.png")); case StackType.Cable: return(_resourceCache.GetTexture("/Textures/Objects/Tools/cables.rsi/coil-30.png")); case StackType.MetalRod: return(_resourceCache.GetTexture("/Textures/Objects/Materials/materials.rsi/rods.png")); } break; case ToolConstructionGraphStep toolStep: switch (toolStep.Tool) { case ToolQuality.Anchoring: return(_resourceCache.GetTexture("/Textures/Objects/Tools/wrench.rsi/icon.png")); case ToolQuality.Prying: return(_resourceCache.GetTexture("/Textures/Objects/Tools/crowbar.rsi/icon.png")); case ToolQuality.Screwing: return(_resourceCache.GetTexture("/Textures/Objects/Tools/screwdriver.rsi/screwdriver-map.png")); case ToolQuality.Cutting: return(_resourceCache.GetTexture("/Textures/Objects/Tools/wirecutters.rsi/cutters-map.png")); case ToolQuality.Welding: return(_resourceCache.GetTexture("/Textures/Objects/Tools/welder.rsi/welder.png")); case ToolQuality.Multitool: return(_resourceCache.GetTexture("/Textures/Objects/Tools/multitool.rsi/multitool.png")); } break; case ComponentConstructionGraphStep componentStep: return(componentStep.Icon?.Frame0()); case PrototypeConstructionGraphStep prototypeStep: return(prototypeStep.Icon?.Frame0()); case NestedConstructionGraphStep _: return(null); } return(null); } foreach (var node in path) { var edge = current.GetEdge(node.Name); var firstNode = current == startNode; if (firstNode) { _stepList.AddItem(isItem ? Loc.GetString($"{stepNumber++}. To craft this item, you need:") : Loc.GetString($"{stepNumber++}. To build this, first you need:")); } foreach (var step in edge.Steps) { var icon = GetTextureForStep(step); switch (step) { case MaterialConstructionGraphStep materialStep: _stepList.AddItem( !firstNode ? Loc.GetString( "{0}. Add {1}x {2}.", stepNumber++, materialStep.Amount, materialStep.Material) : Loc.GetString(" {0}x {1}", materialStep.Amount, materialStep.Material), icon); break; case ToolConstructionGraphStep toolStep: _stepList.AddItem(Loc.GetString("{0}. Use a {1}.", stepNumber++, toolStep.Tool.GetToolName()), icon); break; case PrototypeConstructionGraphStep prototypeStep: _stepList.AddItem(Loc.GetString("{0}. Add {1}.", stepNumber++, prototypeStep.Name), icon); break; case ComponentConstructionGraphStep componentStep: _stepList.AddItem(Loc.GetString("{0}. Add {1}.", stepNumber++, componentStep.Name), icon); break; case NestedConstructionGraphStep nestedStep: var parallelNumber = 1; _stepList.AddItem(Loc.GetString("{0}. In parallel...", stepNumber++)); foreach (var steps in nestedStep.Steps) { var subStepNumber = 1; foreach (var subStep in steps) { icon = GetTextureForStep(subStep); switch (subStep) { case MaterialConstructionGraphStep materialStep: if (!isItem) { _stepList.AddItem(Loc.GetString(" {0}.{1}.{2}. Add {3}x {4}.", stepNumber, parallelNumber, subStepNumber++, materialStep.Amount, materialStep.Material), icon); } break; case ToolConstructionGraphStep toolStep: _stepList.AddItem(Loc.GetString(" {0}.{1}.{2}. Use a {3}.", stepNumber, parallelNumber, subStepNumber++, toolStep.Tool.GetToolName()), icon); break; case PrototypeConstructionGraphStep prototypeStep: _stepList.AddItem(Loc.GetString(" {0}.{1}.{2}. Add {3}.", stepNumber, parallelNumber, subStepNumber++, prototypeStep.Name), icon); break; case ComponentConstructionGraphStep componentStep: _stepList.AddItem(Loc.GetString(" {0}.{1}.{2}. Add {3}.", stepNumber, parallelNumber, subStepNumber++, componentStep.Name), icon); break; } } parallelNumber++; } break; } } current = node; } }
public static void SetMarkup(this RichTextLabel label, string markup) { label.SetMessage(FormattedMessage.FromMarkup(markup)); }