Exemple #1
0
        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);
        }
Exemple #2
0
 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;
 }
Exemple #3
0
        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;
        }
Exemple #4
0
        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);
        }
Exemple #5
0
 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);
 }
Exemple #6
0
 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;
     }
 }
Exemple #7
0
        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;
            }
        }