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 setInfo(string name, int naijiu_, float attack) { labelWidget.Text = $"{attack.ToString():0.00}"; naijiu.Text = $"{name} 耐久:" + naijiu_.ToString(); naijiu.Size = new Vector2(XjJeiLibrary.caculateWidth(naijiu, 0.5f, naijiu.Text, this.Size.X), 16); Size = new Vector2(naijiu.Size.X + shuxing.ActualSize.X, shuxing.ActualSize.Y + naijiu.Size.Y); Margin = SubsystemXjJeiBehavior.margin; }
public void setPosi(Vector3 position_) { float w; position.Text = $"({(int)position_.X},{(int)position_.Y},{(int)position_.Z})"; position.Size = new Vector2(XjJeiLibrary.caculateWidth(position, 0.5f, position.Text, this.Size.X), 16); if (XjJeiLibrary.caculateWidth(naijiu, 0.5f, naijiu.Text, this.Size.X) >= XjJeiLibrary.caculateWidth(position, 0.5f, position.Text, this.Size.X)) { w = XjJeiLibrary.caculateWidth(naijiu, 0.5f, naijiu.Text, this.Size.X); } else { w = XjJeiLibrary.caculateWidth(position, 0.5f, position.Text, this.Size.X); } this.Size = new Vector2(w, shuxing.ActualSize.Y + naijiu.Size.Y); this.Margin = SubsystemXjJeiBehavior.margin; }
public void setCreatureinfo(ComponentCreature componentCreature) { if (componentCreature == null) { return; } clearWidgets(); StackPanelWidget stackLine_healthinfo = new StackPanelWidget() { Direction = LayoutDirection.Vertical, Margin = new Vector2(2, 0) }; creatureInfo.Text = $"{componentCreature.DisplayName}"; if (componentCreature.ComponentHealth.Health < 0.2f) { creatureHealth.Color = Color.Red; } else if (componentCreature.ComponentHealth.Health < 0.5f) { creatureHealth.Color = Color.Yellow; } else { creatureHealth.Color = Color.Green; } creatureInfo.Size = new Vector2(XjJeiLibrary.caculateWidth(creatureInfo, creatureInfo.FontScale, creatureInfo.Text, this.Size.X), creatureInfo.Size.Y); creatureHealth.Text = $"{componentCreature.ComponentHealth.AttackResilience*componentCreature.ComponentHealth.Health:0.00}"; stackLine_healthinfo.Children.Add(creatureInfo); stackLine_healthinfo.Children.Add(creatureHealth); if (!upMode) { Margin = Vector2.Zero; stackmain.Children.Add(stackLine_healthinfo); stackmain.Children.Add(HealthBarWidget); } else //右下角模式 { stackmain.Children.Add(stackLine_healthinfo); stackmain.Children.Add(HealthBarWidget); Margin = new Vector2(0, widget.DesiredSize.Y + SubsystemXjJeiBehavior.margin.Y); } HealthBarWidget.Value = componentCreature.ComponentHealth.Health; this.Size = new Vector2(HealthBarWidget.ActualSize.X + creatureInfo.ActualSize.X + 4, creatureHealth.Size.Y + creatureInfo.Size.Y + 4); }
public MessageInfo() { inputa.Size = new Vector2(XjJeiLibrary.caculateWidth(inputa, inputa.FontScale, inputa.Text, this.Size.X), inputa.Size.Y); sendtext.NormalSubtexture = new Subtexture(ContentManager.Get <Texture2D>("JEITextures/JEI_SMSG"), Vector2.Zero, Vector2.One); sendtext.ClickedSubtexture = new Subtexture(ContentManager.Get <Texture2D>("JEITextures/JEI_SMSG_P"), Vector2.Zero, Vector2.One); this.HorizontalAlignment = WidgetAlignment.Near; this.VerticalAlignment = WidgetAlignment.Near; this.Size = new Vector2(400, 200); this.Children.Add(stackmain); stackmain.Children.Add(canvasmain); canvasmain.Children.Add(rectangleWidget2); canvasmain.Children.Add(scroll); scroll.Children.Add(stack); scroll.ScrollPosition = 0f; stackmain.Children.Add(canvasline); canvasline.Children.Add(rectangleWidget); canvasline.Children.Add(stackline); stackline.Children.Add(inputa); stackline.Children.Add(canvasline_input); stackline.Children.Add(sendtext); canvasline_input.Children.Add(inputbg); canvasline_input.Children.Add(inputline); inputline.Children.Add(inputtext); }
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 override void Update() { if (sendtext.IsClicked) { if (!string.IsNullOrEmpty(inputtext.Text)) { List <string> parsedata = XjJeiLibrary.parseCommand(inputtext.Text); if (parsedata.Count > 0) { string cmd = parsedata[0]; switch (cmd) { case "hiddenjump": SubsystemXjJeiBehavior.showjump = false; CellInfoShow.jumpcanvas.IsVisible = false; addMessage("关闭成功"); break; case "help": addMessage("[color=green]/hiddenjump[/color] 隐藏跳跃按钮"); addMessage("[color=green]/showjump[/color] 显示跳跃按钮"); addMessage("[color=green]/changeweather[/color] 改变天气"); addMessage("[color=green]/jumpsize[/color] [color=red]10[/color] 改变跳跃按钮大小"); addMessage("[color=green]/help[/color] 查看帮助"); break; case "jumpsize": if (parsedata.Count == 2) { int spa = int.Parse(parsedata[1]); SubsystemXjJeiBehavior.jumpsize = new Vector2(spa, spa); CellInfoShow.jump.DesiredSize = SubsystemXjJeiBehavior.jumpsize; CellInfoShow.jumpcanvas.Size = SubsystemXjJeiBehavior.jumpsize; addMessage("设置成功"); } else { addMessage("参数错误"); } break; case "showjump": SubsystemXjJeiBehavior.showjump = true; CellInfoShow.jumpcanvas.IsVisible = true; addMessage("开启成功"); break; case "changeweather": addMessage("此功能尚未开发"); break; if (parsedata.Count > 1) { addMessage("更改天气成功"); } else { addMessage("可使用参数'sun' 'rain' 'snow'"); } break; default: addMessage($"不能识别的指令'[color=red]{inputtext.Text}[/color]'"); break; } } else { addMessage("暂不支持发送聊天消息"); } inputcache.Add(inputtext.Text); inputpos = inputcache.Count; scroll.ScrollPosition = scroll.CalculateScrollAreaLength(); inputtext.Text = ""; } } if (!alwaysShow) { if (needShow) {//需要显示 if (Time.RealTime - lastShowTime < 6) { this.m_isVisible = true; } else { this.m_isVisible = false; needShow = false; } } else { this.m_isVisible = false; } } if (stack.Children.Count > 400) { stack.Children.Clear(); } }
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; } }