public void setPlantInfo(string txt, int value, int grow) { clearWidgets(); if (!upMode) { title.Text = txt + $"({getGrowInfo(grow)})" + "\nID:" + Terrain.ExtractContents(value) + " Data:" + Terrain.ExtractData(value); iconWidget.Value = value; iconWidget.Scale = 0.7f; title.Size = new Vector2(XjJeiLibrary.caculateWidth(title, title.FontScale, title.Text, this.Size.X), XjJeiLibrary.caculateHeight(title, title.m_lines.Count, title.FontScale)); stackmain.Direction = LayoutDirection.Horizontal; stackmain.HorizontalAlignment = WidgetAlignment.Center; stackmain.Children.Add(iconWidget); stackmain.Children.Add(title); Margin = Vector2.Zero; float yya; if (iconWidget.Size.Y >= title.Size.Y) { yya = iconWidget.Size.Y; } else { yya = title.Size.Y; } Size = new Vector2(title.Size.X + 40 + iconWidget.Size.X, yya); } else { title.Text = txt + $"({getGrowInfo(grow)})"; title.Size = new Vector2(XjJeiLibrary.caculateWidth(title, title.FontScale, title.Text, this.Size.X), XjJeiLibrary.caculateHeight(title, title.m_lines.Count, title.FontScale)); title.HorizontalAlignment = WidgetAlignment.Near; stackmain.HorizontalAlignment = WidgetAlignment.Near; stackmain.Children.Add(title); Margin = new Vector2(widget.Size.X + SubsystemXjJeiBehavior.margin.X, SubsystemXjJeiBehavior.margin.Y + widget.DesiredSize.Y); Size = title.Size; } }
public StackPanelWidget matchColor(string str) { StackPanelWidget stackPanel = new StackPanelWidget() { Direction = LayoutDirection.Horizontal }; string[] ll = str.Split(new string[] { "[color=", "]", "[/color]" }, System.StringSplitOptions.None); if (ll[0] == str) { LabelWidget labelWidget = new LabelWidget() { Text = str, FontScale = 0.6f, WordWrap = true }; labelWidget.Margin = new Vector2(2, 0); labelWidget.Size = new Vector2(XjJeiLibrary.caculateWidth(labelWidget, labelWidget.FontScale, str, canvasmain.Size.X), XjJeiLibrary.caculateHeight(labelWidget, 1, labelWidget.FontScale)); stackPanel.Children.Add(labelWidget); } else { bool isColor = false; Color cc = Color.White; foreach (string ain in ll) { if (!isColor) { cc = colorTable(ain); if (cc != Color.Transparent) { isColor = true; } else { LabelWidget labelWidget = new LabelWidget() { Text = ain, FontScale = 0.6f, WordWrap = true }; float wid = XjJeiLibrary.caculateWidth(labelWidget, labelWidget.FontScale, ain, canvasmain.Size.X); labelWidget.Size = new Vector2(XjJeiLibrary.caculateWidth(labelWidget, labelWidget.FontScale, ain, canvasmain.Size.X), XjJeiLibrary.caculateHeight(labelWidget, 1, labelWidget.FontScale)); labelWidget.Margin = new Vector2(2, 0); stackPanel.Children.Add(labelWidget); } } else { LabelWidget labelWidget = new LabelWidget() { Text = ain, FontScale = 0.6f, Color = cc, WordWrap = true }; labelWidget.Size = new Vector2(XjJeiLibrary.caculateWidth(labelWidget, labelWidget.FontScale, ain, canvasmain.Size.X), XjJeiLibrary.caculateHeight(labelWidget, 1, labelWidget.FontScale)); labelWidget.Margin = new Vector2(2, 0); stackPanel.Children.Add(labelWidget); isColor = false; } } } return(stackPanel); }
public void setBlockInfo(string txt, int value, int dig, BlockDigMethod digmethod, int nowdig) { clearWidgets(); if (!upMode) { title.Text = txt; iconWidget.Value = value; if (nowdig < dig) { digValue.Color = Color.Red; } else { digValue.Color = Color.White; } digValue.Text = $"{dig}"; switch (digmethod) { case BlockDigMethod.None: toolValue.Text = "无"; break; case BlockDigMethod.Hack: toolValue.Text = $"斧"; break; case BlockDigMethod.Shovel: toolValue.Text = $"铲"; break; case BlockDigMethod.Quarry: toolValue.Text = $"镐"; break; } if (toolValue.Text != "无") { title.Text = txt + $"({toolValue.Text})" + "\nID:" + Terrain.ExtractContents(value) + " Data:" + Terrain.ExtractData(value); } else { title.Text = txt + "\nID:" + Terrain.ExtractContents(value); } toolValue.FontScale = 0.5f; iconWidget.Scale = 1f; iconWidget.Value = value; stackmain.HorizontalAlignment = WidgetAlignment.Center; title.HorizontalAlignment = WidgetAlignment.Far; toolValue.Size = new Vector2(XjJeiLibrary.caculateWidth(toolValue, toolValue.FontScale, toolValue.Text, this.Size.X), XjJeiLibrary.caculateHeight(toolValue, toolValue.m_lines.Count, toolValue.FontScale)); title.Size = new Vector2(XjJeiLibrary.caculateWidth(title, title.FontScale, title.Text, this.Size.X), XjJeiLibrary.caculateHeight(title, title.m_lines.Count, title.FontScale)); stackmain.Children.Add(iconWidget); stackmain.Children.Add(title); Margin = Vector2.Zero; float yya; if (iconWidget.Size.Y >= title.Size.Y) { yya = iconWidget.Size.Y; } else { yya = title.Size.Y; } Size = new Vector2(title.Size.X + 40 + iconWidget.Size.X, yya); } else { title.Text = txt; title.Size = new Vector2(XjJeiLibrary.caculateWidth(title, title.FontScale, title.Text, this.Size.X), XjJeiLibrary.caculateHeight(title, title.m_lines.Count, title.FontScale)); stackmain.Children.Add(title); Margin = new Vector2(widget.Size.X + SubsystemXjJeiBehavior.margin.X, SubsystemXjJeiBehavior.margin.Y + widget.Size.Y); Size = title.Size; } }