예제 #1
0
 public PlayerPreferences(string position, bool toggle, int fontSize, string color)
 {
     elements      = new CuiElementContainer();
     playerCounter = new CuiLabel
     {
         Text =
         {
             Text     = "",
             FontSize = fontSize,
             Color    = color,
             Align    = TextAnchor.UpperRight
         },
         RectTransform =
         {
             AnchorMin = "0 0",
             AnchorMax = "1 1"
         }
     };
     container = elements.Add(new CuiPanel
     {
         Image =
         {
             Color = "0 0 0 0"
         },
         RectTransform =
         {
             AnchorMin = "0 0",
             AnchorMax = "1 1"
         }
     });
     elements.Add(playerCounter, container);
     this.position = position;
     this.toggle   = toggle;
 }
예제 #2
0
        public override void CreateUI()
        {
            string rootKey = Elements.Add(new CuiPanel
            {
                RectTransform =
                {
                    AnchorMin = "0.4 0.15",
                    AnchorMax = "0.6 0.3"
                },
                Image =
                {
                    Color = "0 0 0 0.7"
                }
            });

            contentLabel = new CuiLabel
            {
                RectTransform =
                {
                    AnchorMin = "0.02 0.01",
                    AnchorMax = "0.98 0.99"
                },
                Text =
                {
                    Text     = "",
                    Color    = "0.9 0.9 0.9 1",
                    FontSize =              14,
                    Align    = TextAnchor.MiddleCenter
                }
            };

            Elements.Add(contentLabel, rootKey);
        }
예제 #3
0
            public static void CreateLabel(ref CuiElementContainer container, string panel, string color, string text, int size, string aMin, string aMax, TextAnchor align = TextAnchor.MiddleCenter, float fadein = 1f)
            {
                var label = new CuiLabel
                {
                    Text          = { Color = color, FontSize = size, Align = align, FadeIn = fadein, Text = text },
                    RectTransform = { AnchorMin = aMin, AnchorMax = aMax }
                };

                container.Add(label, panel);
            }
예제 #4
0
        public override void CreateUI()
        {
            var root = new CuiPanel
            {
                RectTransform =
                {
                    AnchorMin = "0.425 0",
                    AnchorMax = "0.575 0.021"
                },
                Image =
                {
                    Color  = "0 0 0 0",
                    FadeIn = 0.2f
                },
                FadeOut = 0.2f
            };

            var background = new CuiPanel
            {
                RectTransform =
                {
                    AnchorMin = "0 0",
                    AnchorMax = "1 1"
                },
                Image =
                {
                    Color = "0 0 0 0.8"
                }
            };

            var label = new CuiLabel
            {
                RectTransform =
                {
                    AnchorMin = "0 0",
                    AnchorMax = "1 1"
                },
                Text =
                {
                    Text     = Lang.Translate(null, "crafter-inrange"),
                    Color    = "0.9 0.9 0.9 1",
                    FontSize =                  12,
                    Align    = TextAnchor.MiddleCenter
                }
            };

            string rootKey = Elements.Add(root, "Overlay");

            Elements.Add(background, rootKey);
            Elements.Add(label, rootKey);
        }
예제 #5
0
        private CuiLabel CreateLabel(string text, int fontSize, TextAnchor anchor, float xPos, float yPos, float xSize, float ySize)
        {
            var label = new CuiLabel
            {
                RectTransform =
                {
                    AnchorMin = xPos + " " + yPos,
                    AnchorMax = (xPos + xSize) + " " + (yPos + ySize)
                },
                Text =
                {
                    Align    = anchor,
                    FontSize = fontSize,
                    Text     = text
                }
            };

            return(label);
        }
예제 #6
0
        private static CuiLabel CreateTextLineLabel(HelpTab helpTab, float firstLineMargin, float textLineHeight, int textRow,
                                                    string textLine)
        {
            var textLineLabel = new CuiLabel
            {
                RectTransform =
                {
                    AnchorMin = "0.01 " + (firstLineMargin - textLineHeight * (textRow + 1)),
                    AnchorMax = "0.85 " + (firstLineMargin - textLineHeight * textRow)
                },
                Text =
                {
                    Align    = helpTab.TextAnchor,
                    FontSize = helpTab.TextFontSize,
                    Text     = textLine
                }
            };

            return(textLineLabel);
        }
예제 #7
0
        public static CuiElement AddOutline(CuiLabel label, string parent = "Hud", string color = "0.15 0.15 0.15 0.43", string dist = "1.1 -1.1", bool usealpha = false, string name = null)
        {
            if (string.IsNullOrEmpty(name))
            {
                name = CuiHelper.GetGuid();
            }
            CuiElement cuiElement = new CuiElement();

            cuiElement.Name    = name;
            cuiElement.Parent  = parent;
            cuiElement.FadeOut = label.FadeOut;
            cuiElement.Components.Add((ICuiComponent)label.Text);
            cuiElement.Components.Add((ICuiComponent)label.RectTransform);
            cuiElement.Components.Add((ICuiComponent) new CuiOutlineComponent {
                Color           = color,
                Distance        = dist,
                UseGraphicAlpha = usealpha
            });
            return(cuiElement);
        }