Пример #1
0
 public static void LoadImage(ref CuiElementContainer container, string panel, string png, string aMin, string aMax)
 {
     container.Add(new CuiElement
     {
         Name       = CuiHelper.GetGuid(),
         Parent     = panel,
         Components =
         {
             new CuiRawImageComponent      {
                 Png = png
             },
             new CuiRectTransformComponent {
                 AnchorMin = aMin, AnchorMax = aMax
             }
         }
     });
 }
 private void CreateBoxUI(BasePlayer player, BaseEntity entity, int header = 0)
 {
     if (header == 0)
     {
         AddHeaderUI(player);
     }
     cuiContainer = ContainerOffset("BoxUIContent", "0.65 0.65 0.65 0.06", "0.5 0", "0.5 0", "192.5 16",
                                    "423 75.9");
     if (_skinbox.ContainsKey(entity.skinID) || entity.prefabID == 1844023509)
     {
         AddSelectedUI(player, entity);
     }
     else
     {
         AddCategoryUI(player, cuiContainer);
     }
 }
Пример #3
0
        // initialize GUI elements
        void InitGUI()
        {
            GUIContainer = new CuiElementContainer();

            GUIElement = new CuiElement()
            {
                Name       = GUIName,
                FadeOut    = data.ui.fadeOut,
                Components =
                {
                    (GUIText      = new CuiTextComponent()
                    {
                        Text      = "",
                        FontSize  = data.ui.fontSize,
                        Color     = data.ui.boostTextColor,
                        FadeIn    = data.ui.fadeIn,
                        Align     = TextAnchor.MiddleCenter
                    }),
                    (GUIPosition  = new CuiRectTransformComponent()
                    {
                        AnchorMin = data.ui.anchorMin,
                        AnchorMax = data.ui.anchorMax
                    })
                }
            };

            LockBackground = new CuiElement()
            {
                Name       = GUIName,
                FadeOut    = data.ui.fadeOut,
                Components =
                {
                    new CuiImageComponent()
                    {
                        Sprite = "assets/icons/lock.png",
                        Color  = data.ui.lockIconColor,
                        FadeIn = data.ui.fadeIn
                    },
                    new CuiRectTransformComponent()
                    {
                        AnchorMin = data.ui.lockAnchorMin,
                        AnchorMax = data.ui.lockAnchorMax
                    }
                }
            };
        }
Пример #4
0
        private static void SendUI(BasePlayer player, CuiElementContainer container)
        {
            var json = JsonConvert.SerializeObject(container, Formatting.None, new JsonSerializerSettings
            {
                StringEscapeHandling = StringEscapeHandling.Default,
                DefaultValueHandling = DefaultValueHandling.Ignore,
                Formatting           = Formatting.Indented
            });

            json = json.Replace(@"\t", "\t");
            json = json.Replace(@"\n", "\n");

            //CuiHelper.AddUi(player, container);
            CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo {
                connection = player.net.connection
            }, null, "AddUI", new Facepunch.ObjectList(json, null, null, null, null));
        }
Пример #5
0
        private void CreateHealthElement(ref CuiElementContainer element, string panelName, string name, float maxHealth, float currentHealth, float minY)
        {
            var    percent = System.Convert.ToDouble((float)currentHealth / (float)maxHealth);
            var    yMax    = 0.98 * percent;
            string color   = "0.2 0.6 0.2 0.9";

            if (percent <= 0.5)
            {
                color = "1 0.5 0 0.9";
            }
            if (percent <= 0.15)
            {
                color = "0.698 0.13 0.13 0.9";
            }
            EventManager.UI.CreatePanel(ref element, panelName, color, $"0.01 {minY + 0.005}", $"{yMax} {minY + 0.24}");
            EventManager.UI.CreateLabel(ref element, panelName, "", name, 8, $"0 {minY}", $"1 {minY + 0.25}");
        }
 static public CuiElementContainer CreateElementContainer(string panel, string color, string aMin, string aMax, bool cursor = false)
 {
     var NewElement = new CuiElementContainer()
 {
     {
         new CuiPanel
         {
             Image = {Color = color},
             RectTransform = {AnchorMin = aMin, AnchorMax = aMax},
             CursorEnabled = cursor,
         },
         new CuiElement().Parent,
         panel
     }
 };
     return NewElement;
 }
Пример #7
0
        private void ShowInfo(BasePlayer player, string command, string[] args)
        {
            if (player == null || _settings == null)
            {
                return;
            }

            if (!PlayerActiveTabs.ContainsKey(player.userID))
            {
                PlayerActiveTabs.Add(player.userID, new PlayerInfoState(_settings));
            }

            var container     = new CuiElementContainer();
            var mainPanelName = AddMainPanel(container);

            PlayerActiveTabs[player.userID].MainPanelName = mainPanelName;

            var tabToSelectIndex = _settings.TabToOpenByDefault;
            var allowedTabs      = _settings.Tabs
                                   .Where((tab, tabIndex) => string.IsNullOrEmpty(tab.OxideGroup) ||
                                          tab.OxideGroup.Split(',')
                                          .Any(group => Permission.UserHasGroup(player.userID.ToString(CultureInfo.InvariantCulture), group)))
                                   .ToList();

            if (allowedTabs.Count <= 0)
            {
                SendReply(player, "[GUI Help] You don't have permissions to see info.");
                return;
            }

            var activeAllowedTab    = allowedTabs[tabToSelectIndex];
            var tabContentPanelName = CreateTabContent(activeAllowedTab, container, mainPanelName);
            var activeTabButtonName = AddActiveButton(tabToSelectIndex, activeAllowedTab, container, mainPanelName);

            for (int tabIndex = 0; tabIndex < allowedTabs.Count; tabIndex++)
            {
                if (tabIndex == tabToSelectIndex)
                {
                    continue;
                }

                AddNonActiveButton(tabIndex, container, allowedTabs[tabIndex], mainPanelName, activeTabButtonName);
            }
            PlayerActiveTabs[player.userID].ActiveTabContentPanelName = tabContentPanelName;
            SendUI(player, container);
        }
Пример #8
0
 public static void CreateLabel(
     ref CuiElementContainer container,
     string panel,
     string color,
     string text,
     int size,
     string aMin,
     string aMax,
     TextAnchor align = TextAnchor.MiddleCenter)
 {
     container.Add(new CuiLabel
     {
         Text          = { Color = color, FontSize = size, Align = align, Text = text },
         RectTransform = { AnchorMin = aMin, AnchorMax = aMax }
     },
                   panel);
 }
Пример #9
0
        public static void CreateRightFadeout(BasePlayer player, string message)
        {
            string ARENA = $"{message}";

            IemUtils.DLog(message);
            string gui = "CreateRightFadeout";

            guiList.Add(gui);

            CuiHelper.DestroyUi(player, gui);

            var        elements    = new CuiElementContainer();
            CuiElement textElement = new CuiElement
            {
                Name       = gui,
                Parent     = "Hud.Under",
                FadeOut    = 5,
                Components =
                {
                    new CuiTextComponent
                    {
                        Text     = $"<color=#cc0000>{message}</color>",
                        FontSize = 22,
                        Align    = TextAnchor.UpperLeft,
                        //FadeIn = 5
                    },
                    new CuiOutlineComponent
                    {
                        Distance = "1.0 1.0",
                        Color    = "1.0 1.0 1.0 1.0"
                    },
                    new CuiRectTransformComponent
                    {
                        AnchorMin = "0.80 0.35",
                        AnchorMax = "1 0.9"
                    }
                }
            };

            elements.Add(textElement);
            CuiHelper.AddUi(player, elements);
            me.timer.Once(5f, () =>
            {
                CuiHelper.DestroyUi(player, gui);
            });
        }
Пример #10
0
        /// <summary>
        /// Show overlay menu for parent player
        /// </summary>
        public void ShowOverlay()
        {
            HideOverlay();             // just in case
            CancelPlacing();           // cancel placing
            HideMenu();

            var elements = new CuiElementContainer();

            overlay = Cui.Menu.CreateOverlay(elements, this);

            CuiHelper.AddUi(player, elements);

            //overlaytext = text;
            //overlaysubtext = subtext;
            isOverlayOpen = true;
            beltposition  = player.GetActiveItem().position;
        }
Пример #11
0
        private static void BuildNotificationBlock(ref CuiElementContainer container, int index, TimedNotification notification)
        {
            Vector2 dimension = new Vector2(1f, 0.07f);
            Vector2 origin    = new Vector2(0f, 1f);
            Vector2 offset    = new Vector2(0f, (0.015f + dimension.y) * (index + 1));
            Vector2 min       = origin - offset;
            Vector2 max       = min + dimension;

            Helper.UI.Panel(ref container, "ui_notifications_times", notification.color, $"{min.x} {min.y}", $"{max.x} {max.y}");

            // Message
            Helper.UI.Label(ref container, "ui_notifications_times", "1 1 1 1", notification.message, 12, $"{min.x} {min.y}", $"{max.x - 0.28} {max.y}");

            // Timer
            Helper.UI.Panel(ref container, "ui_notifications_times", "0 0 0 .64", $"{min.x + 0.72} {min.y}", $"{max.x} {max.y}");
            Helper.UI.Label(ref container, "ui_notifications_times", "1 1 1 1", Helper.TimeFormat.Short(TimeSpan.FromSeconds(notification.expires - Helper.Timestamp())), 12, $"{min.x + 0.72} {min.y}", $"{max.x} {max.y}");
        }
Пример #12
0
 public static void CreateInput(ref CuiElementContainer container, string panel, string color, string text, int size, string aMin, string aMax, string command, bool password, int charLimit, TextAnchor align = TextAnchor.MiddleCenter)
 {
     container.Add(new CuiElement
     {
         Name       = CuiHelper.GetGuid(),
         Parent     = panel,
         Components =
         {
             new CuiInputFieldComponent    {
                 Text = text, FontSize = size, Align = align, Color = color, Command = command, IsPassword = password, CharsLimit = charLimit
             },
             new CuiRectTransformComponent {
                 AnchorMin = aMin, AnchorMax = aMax
             }
         }
     });
 }
Пример #13
0
        void NPCSelectGUI(BasePlayer player)
        {
            IsOpen(player.userID, true);
            CuiHelper.DestroyUi(player, NPCGUS);

            string description            = Lang("npcguisel");
            CuiElementContainer container = UI.Container(NPCGUS, UI.Color("242424", 1f), "0.1 0.1", "0.9 0.9", true, "Overlay");

            UI.Label(ref container, NPCGUS, UI.Color("#ffffff", 1f), description, 18, "0.23 0.92", "0.7 1");
            UI.Label(ref container, NPCGUS, UI.Color("#22cc44", 1f), Lang("musician"), 12, "0.72 0.92", "0.77 1");
            UI.Label(ref container, NPCGUS, UI.Color("#2244cc", 1f), Lang("standard"), 12, "0.79 0.92", "0.86 1");
            UI.Button(ref container, NPCGUS, UI.Color("#d85540", 1f), Lang("close"), 12, "0.92 0.93", "0.985 0.98", $"npcgui selclose");
            int col = 0;
            int row = 0;

            List <ulong> npcs = (List <ulong>)HumanNPC?.Call("HumanNPCs");

            foreach (ulong npc in npcs)
            {
                if (row > 10)
                {
                    row = 0;
                    col++;
                }
                var hBand = (string)HumanNPC?.Call("GetHumanNPCInfo", npc, "band");
                if (hBand == "99")
                {
                    continue;
                }
                string color = "#2244cc";
                if (hBand != "0")
                {
                    color = "#22cc44";
                }

                var     hName = (string)HumanNPC?.Call("HumanNPCname", npc);
                float[] posb  = GetButtonPositionP(row, col);
                UI.Button(ref container, NPCGUS, UI.Color(color, 1f), hName, 12, $"{posb[0]} {posb[1]}", $"{posb[0] + ((posb[2] - posb[0]) / 2)} {posb[3]}", $"npcgui npc {npc.ToString()}");
                row++;
            }
            float[] posn = GetButtonPositionP(row, col);
            UI.Button(ref container, NPCGUS, UI.Color("#cc3333", 1f), Lang("new"), 12, $"{posn[0]} {posn[1]}", $"{posn[0] + ((posn[2] - posn[0]) / 2)} {posn[3]}", $"npcgui new");

            CuiHelper.AddUi(player, container);
        }
Пример #14
0
        private void CreateUI(BasePlayer player)
        {
            if (!config.ScreamOnDemand)
            {
                return;
            }

            DestroyUI(player);

            bool canScream = screams[player].NextPlay <= Time.time;

            var ui            = new CuiElementContainer();
            var rootPanelName = ui.Add(new CuiPanel
            {
                Image =
                {
                    Color = "0 0 0 0"
                },
                RectTransform =
                {
                    AnchorMin = "0 0.924",
                    AnchorMax = "1 1"
                }
            });

            // Text label
            ui.Add(new CuiLabel
            {
                RectTransform =
                {
                    AnchorMin = "0 0",
                    AnchorMax = "1 1"
                },
                Text =
                {
                    Text     = lang.GetMessage("helptext",                                  this, player.UserIDString),
                    Align    = TextAnchor.LowerCenter,
                    Color    = canScream ? "0.968 0.921 0.882 1" : "0.968 0.921 0.882 0.5",
                    FontSize = canScream ? 14 : 13
                }
            }, rootPanelName);

            openUis.Add(player.userID, rootPanelName);
            CuiHelper.AddUi(player, ui);
        }
Пример #15
0
            public CuiElementContainer ToDynamicContainer(PanelTypes type, params StringPlus.ReplacementData[] replacements)
            {
                CuiElementContainer container = new CuiElementContainer();

                string textData = StringPlus.Replace(text.text, replacements);

                container.Add(new CuiElement {
                    Name       = UniqueElementName(ContainerTypes.Dynamic, ContainerParent, type.ToString()),
                    Parent     = ContainerParent,
                    Components =
                    {
                        text.ToTextComponent(textData),
                        text.ToRectComponent()
                    }
                });

                return(container);
            }
Пример #16
0
        void UnstuckButton(string id, string text = null)
        {
            var basePlayer = BasePlayer.Find(id);
            var elements   = new CuiElementContainer();

            unstuck = elements.Add(new CuiButton
            {
                Button        = { Command = $"unstuck {id}", Color = guiColor },
                RectTransform =
                {
                    AnchorMin = string.Concat(anchorMinX, ' ', anchorMinY),
                    AnchorMax = string.Concat(anchorMaxX, ' ', anchorMaxY)
                },
                Text = { Text = (text ?? Lang("Stuck", id)), FontSize = 20, Align = TextAnchor.MiddleCenter }
            }, "Hud", "Unstuck");
            CuiHelper.DestroyUi(basePlayer, unstuck);
            CuiHelper.AddUi(basePlayer, elements);
        }
 private static void Label(ref CuiElementContainer container, string panel, string text, string color,
                           int size, string aMin, string aMax, float fadein = 0f, TextAnchor align = TextAnchor.MiddleCenter)
 {
     container.Add(new CuiLabel
     {
         Text =
         {
             FontSize = size,
             Align    = align,
             Text     = text,
             Color    = color,
             Font     = "robotocondensed-regular.ttf",
             FadeIn   = fadein
         },
         RectTransform = { AnchorMin = aMin, AnchorMax = aMax }
     },
                   panel);
 }
Пример #18
0
            public static CuiElementContainer NewCuiElement(string name, string color, string aMin, string aMax)
            {
                var element = new CuiElementContainer()
                {
                    {
                        new CuiPanel
                        {
                            Image         = { Color = color },
                            RectTransform = { AnchorMin = aMin, AnchorMax = aMax },
                            CursorEnabled = false
                        },
                        new CuiElement().Parent = "Overlay",
                        name
                    }
                };

                return(element);
            }
Пример #19
0
 public static void LoadImage(ref CuiElementContainer container, string panel, string url, string aMin, string aMax)
 {
     container.Add(new CuiElement
     {
         Name       = CuiHelper.GetGuid(),
         Parent     = panel,
         FadeOut    = 0.15f,
         Components =
         {
             new CuiRawImageComponent      {
                 Url = url, FadeIn = 0.3f
             },
             new CuiRectTransformComponent {
                 AnchorMin = aMin, AnchorMax = aMax
             }
         }
     });
 }
Пример #20
0
            public void HealthIndicator(BasePlayer player, float health)
            {
                CuiHelper.DestroyUi(player, "HealthGui");
                var healthstr  = health.ToString();
                var rocketstr  = isReloading ? "R" : rocketMax.ToString();
                var napalmstr  = isReloading ? "R" : napalmMax.ToString();
                var dispalystr = isReloading ? "Reloading     " + healthstr + "     Reloading" : "N: " + napalmstr + "         " + healthstr + "         R: " + rocketstr;

                var healthindicator = new CuiElementContainer();

                healthindicator.Add(new CuiButton
                {
                    Button        = { Command = "", Color = "0.0 0.0 0.0 1.0" },
                    RectTransform = { AnchorMin = "0.40 0.15", AnchorMax = "0.60 0.18" },
                    Text          = { Text = dispalystr, FontSize = 18, Color = "1.0 0.0 0.0 0.2", Align = TextAnchor.MiddleCenter }
                }, "Overall", "HealthGui");
                CuiHelper.AddUi(player, healthindicator);
            }
Пример #21
0
            static public CuiElementContainer CreateElementContainer(string panelName, string color, string aMin, string aMax, bool useCursor = false)
            {
                var NewElement = new CuiElementContainer()
                {
                    {
                        new CuiPanel
                        {
                            Image         = { Color = color },
                            RectTransform = { AnchorMin = aMin, AnchorMax = aMax },
                            CursorEnabled = useCursor
                        },
                        new CuiElement().Parent = "Overlay",
                        panelName
                    }
                };

                return(NewElement);
            }
Пример #22
0
            void AddDialogHeader(CuiElementContainer container)
            {
                container.Add(new CuiPanel {
                    Image         = { Color = "0 0 0 1" },
                    RectTransform = { AnchorMin = "0 0.966", AnchorMax = "0.999 0.999" }
                }, Ui.Element.MapDialog, Ui.Element.MapHeader);

                container.Add(new CuiLabel {
                    Text          = { Text = ConVar.Server.hostname, FontSize = 13, Align = TextAnchor.MiddleLeft, FadeIn = 0 },
                    RectTransform = { AnchorMin = "0.012 0.025", AnchorMax = "0.099 0.917" }
                }, Ui.Element.MapHeader, Ui.Element.MapHeaderTitle);

                container.Add(new CuiButton {
                    Text          = { Text = "X", FontSize = 13, Align = TextAnchor.MiddleCenter },
                    Button        = { Color = "0 0 0 0", Command = "imperium.map.toggle", FadeIn = 0 },
                    RectTransform = { AnchorMin = "0.972 0.083", AnchorMax = "0.995 0.917" }
                }, Ui.Element.MapHeader, Ui.Element.MapHeaderCloseButton);
            }
Пример #23
0
            static public CuiElementContainer Container(string panel, string aMin, string aMax)
            {
                CuiElementContainer container = new CuiElementContainer()
                {
                    {
                        new CuiPanel
                        {
                            Image         = { Color = ins.panelColor },
                            RectTransform = { AnchorMin = aMin, AnchorMax = aMax },
                            CursorEnabled = false
                        },
                        new CuiElement().Parent = "Overlay",
                        panel
                    }
                };

                return(container);
            }
Пример #24
0
            static public CuiElementContainer ElementContainer(string panelName, string color, UI4 dimensions, bool useCursor = false, string parent = "Overlay")
            {
                var NewElement = new CuiElementContainer()
                {
                    {
                        new CuiPanel
                        {
                            Image         = { Color = color },
                            RectTransform = { AnchorMin = dimensions.GetMin(), AnchorMax = dimensions.GetMax() },
                            CursorEnabled = useCursor
                        },
                        new CuiElement().Parent = parent,
                        panelName
                    }
                };

                return(NewElement);
            }
Пример #25
0
            static public CuiElementContainer Container(string panelName, string aMin, string aMax, bool cursor = false)
            {
                var NewElement = new CuiElementContainer()
                {
                    {
                        new CuiPanel
                        {
                            Image         = { Color = uiColors["background"] },
                            RectTransform = { AnchorMin = aMin, AnchorMax = aMax },
                            CursorEnabled = cursor
                        },
                        new CuiElement().Parent = "Overlay",
                        panelName
                    }
                };

                return(NewElement);
            }
Пример #26
0
            public static CuiElementContainer Container(string panel, string color, string min, string max, bool useCursor = false, string parent = "Overlay")
            {
                CuiElementContainer container = new CuiElementContainer()
                {
                    {
                        new CuiPanel
                        {
                            Image         = { Color = color },
                            RectTransform = { AnchorMin = min, AnchorMax = max },
                            CursorEnabled = useCursor
                        },
                        new CuiElement().Parent = parent,
                        panel
                    }
                };

                return(container);
            }
Пример #27
0
        private void VanishGui(BasePlayer basePlayer)
        {
            if (!basePlayer || !basePlayer.IsConnected || !IsInvisible(basePlayer))
            {
                return;
            }

            if (basePlayer.HasPlayerFlag(BasePlayer.PlayerFlags.ReceivingSnapshot))
            {
                timer.Once(0.1f, () => VanishGui(basePlayer));
                return;
            }

            string gui;

            if (guiInfo.TryGetValue(basePlayer.userID, out gui))
            {
                CuiHelper.DestroyUi(basePlayer, gui);
            }

            CuiElementContainer elements = new CuiElementContainer();

            guiInfo[basePlayer.userID] = CuiHelper.GetGuid();

            elements.Add(new CuiElement
            {
                Name       = guiInfo[basePlayer.userID],
                Components =
                {
                    new CuiRawImageComponent
                    {
                        Color = config.ImageColor,
                        Url   = config.ImageUrlIcon
                    },
                    new CuiRectTransformComponent
                    {
                        AnchorMin = config.ImageAnchorMin,
                        AnchorMax = config.ImageAnchorMax
                    }
                }
            });

            CuiHelper.AddUi(basePlayer, elements);
        }
Пример #28
0
        private void UpdateTprUI(BasePlayer player, List <BasePlayer> players, int index = 0)
        {
            Helper.UI.Destroy(player, "ui_teleport_tpr_toolbar");
            Helper.UI.Destroy(player, "ui_teleport_tpr_entries");

            Puts($"Players: {players.Count}");

            // Create the home items themself
            CuiElementContainer entriesContainer = Helper.UI.Container("ui_teleport_tpr_entries", "0 0 0 0", "0 0.04", "0.997 1", false, "ui_teleport_tpr");
            int i = 0;

            foreach (var p in players.Skip(index * 15).Take(15))
            {
                Vector2 dimension = new Vector2(0.997f, 0.05f);
                Vector2 origin    = new Vector2(0.0f, 1f);
                Vector2 offset    = new Vector2(0f, (0.013f + dimension.y) * (i + 1));
                Vector2 min       = origin - offset;
                Vector2 max       = min + dimension;

                Helper.UI.Panel(ref entriesContainer, "ui_teleport_tpr_entries", "1 1 1 0.02", $"{min.x} {min.y}", $"{max.x} {max.y}");
                Helper.UI.Label(ref entriesContainer, "ui_teleport_tpr_entries", "1 1 1 1", $"{p.displayName}", 12, $"{min.x + 0.02} {min.y}", $"{max.x} {max.y}", TextAnchor.MiddleLeft);
                Helper.UI.Button(ref entriesContainer, "ui_teleport_tpr_entries", "0.12 0.38 0.57 1", "Request Teleport", 12, $"{min.x + 0.8} {min.y + 0.01}", $"{max.x - 0.02} {max.y - 0.01}", $"teleport tpr request {p.UserIDString}");

                i++;
            }

            // Create toolbar container
            CuiElementContainer toolbarContainer = Helper.UI.Container("ui_teleport_tpr_toolbar", "0 0 0 0", "0 0", "0.997 0.04", false, "ui_teleport_tpr");

            if (index > 0)
            {
                Helper.UI.Button(ref toolbarContainer, "ui_teleport_tpr_toolbar", "0.12 0.38 0.57 1", "< Previous", 12, "0 0", "0.2 0.96", $"teleport tpr index {index - 1}");
            }

            if (players.Count - (index * 15) > 15)
            {
                Helper.UI.Button(ref toolbarContainer, "ui_teleport_tpr_toolbar", "0.12 0.38 0.57 1", "Next >", 12, "0.8 0", "0.997 0.96", $"teleport tpr index {index + 1}");
            }

            Helper.UI.Button(ref toolbarContainer, "ui_teleport_tpr_toolbar", "0.8 0.2 0.2 1", "Close Teleport Request", 12, $"{(index > 0 ? "0.21" : "0")} 0", $"{(players.Count - (index * 15) > 15 ? "0.79" : "0.997")} 0.96", $"teleport tpr close");

            Helper.UI.Add(player, entriesContainer);
            Helper.UI.Add(player, toolbarContainer);
        }
Пример #29
0
        private void UpdateHomeUI(BasePlayer player, int index = 0)
        {
            Helper.UI.Destroy(player, "ui_teleport_home_toolbar");
            Helper.UI.Destroy(player, "ui_teleport_home_entries");

            // Create the home items themself
            CuiElementContainer entriesContainer = Helper.UI.Container("ui_teleport_home_entries", "0 0 0 0", "0 0.04", "0.997 1", false, "ui_teleport_home");
            int i = 0;

            foreach (var home in playerHomes[player.userID].Skip(index * 15).Take(15))
            {
                Vector2 dimension = new Vector2(0.997f, 0.05f);
                Vector2 origin    = new Vector2(0.0f, 1f);
                Vector2 offset    = new Vector2(0f, (0.013f + dimension.y) * (i + 1));
                Vector2 min       = origin - offset;
                Vector2 max       = min + dimension;

                Helper.UI.Panel(ref entriesContainer, "ui_teleport_home_entries", "1 1 1 0.02", $"{min.x} {min.y}", $"{max.x} {max.y}");
                Helper.UI.Label(ref entriesContainer, "ui_teleport_home_entries", "1 1 1 1", $"Home {home.Key}", 12, $"{min.x + 0.02} {min.y}", $"{max.x} {max.y}", TextAnchor.MiddleLeft);
                Helper.UI.Button(ref entriesContainer, "ui_teleport_home_entries", "0.8 0.2 0.2 1", "Delete", 12, $"{min.x + 0.8} {min.y + 0.01}", $"{max.x - 0.02} {max.y - 0.01}", $"teleport home remove {home.Key}");
                Helper.UI.Button(ref entriesContainer, "ui_teleport_home_entries", "0.12 0.38 0.57 1", "Teleport", 12, $"{min.x + 0.598} {min.y + 0.01}", $"{max.x - 0.22} {max.y - 0.01}", $"teleport home teleport {home.Key}");

                i++;
            }

            // Create toolbar container
            CuiElementContainer toolbarContainer = Helper.UI.Container("ui_teleport_home_toolbar", "0 0 0 0", "0 0", "0.997 0.04", false, "ui_teleport_home");

            if (index > 0)
            {
                Helper.UI.Button(ref toolbarContainer, "ui_teleport_home_toolbar", "0.12 0.38 0.57 1", "< Previous", 12, "0 0", "0.2 0.96", $"teleport home index {index - 1}");
            }

            if (playerHomes[player.userID].Count - (index * 15) > 15)
            {
                Helper.UI.Button(ref toolbarContainer, "ui_teleport_home_toolbar", "0.12 0.38 0.57 1", "Next >", 12, "0.8 0", "0.997 0.96", $"teleport home index {index + 1}");
            }

            Helper.UI.Button(ref toolbarContainer, "ui_teleport_home_toolbar", "0.12 0.38 0.57 1", "Add Home", 12, $"{(index > 0 ? "0.21" : "0")} 0", "0.495 0.96", $"teleport home add {index}");
            Helper.UI.Button(ref toolbarContainer, "ui_teleport_home_toolbar", "0.8 0.2 0.2 1", "Close Homes", 12, "0.505 0", $"{(playerHomes[player.userID].Count - (index * 15) > 15 ? "0.79" : "0.997")} 0.96", $"teleport home close");

            Helper.UI.Add(player, entriesContainer);
            Helper.UI.Add(player, toolbarContainer);
        }
Пример #30
0
        void CreateBox(CuiElementContainer container, string AnchorMin, string AnchorMax, string Resolution, bool Active = false)
        {
            string BoxName = CuiHelper.GetGuid();

            container.Add(new CuiElement
            {
                Name       = BoxName,
                Parent     = "ResolutionMain",
                Components =
                {
                    new CuiButtonComponent
                    {
                        Command = "resolution.select " + Resolution, // NOTE! Text will put as CMD
                        Close   = "ResolutionMain",
                        Color   = "1 1 1 0.4"
                    },
                    new CuiRectTransformComponent
                    {
                        AnchorMin = AnchorMin,
                        AnchorMax = AnchorMax
                    }
                }
            });

            container.Add(new CuiElement
            {
                Name       = CuiHelper.GetGuid(),
                Parent     = BoxName,
                Components =
                {
                    new CuiTextComponent
                    {
                        Text     = Resolution + (Active ? "\n\n" + GetLangMessage("RES_CHOOSED") : ""),
                        FontSize = 30,
                        Align    = TextAnchor.MiddleCenter
                    },
                    new CuiRectTransformComponent(),
                    new CuiOutlineComponent()
                    {
                        Color = "0 0 0 1"
                    }
                }
            });
        }
        void RenderMode(BasePlayer player, bool repair = false)
        {
            CuiHelper.DestroyUi(player, "EnhancedHammerUI");
            if (PlayerHasFlag(player.userID, PlayerFlags.PLUGIN_DISABLED) || 
                PlayerHasFlag(player.userID, PlayerFlags.ICONS_DISABLED) || 
                (!repair && playersInfo[player.userID].upgradeInfo == BuildingGrade.Enum.Count))
                return;

            CuiElementContainer panel = new CuiElementContainer();
            string icon = "http://i.imgur.com/Nq6DNSX.png";
            if (!repair)
            {
                switch (playersInfo[player.userID].upgradeInfo)
                {
                    case BuildingGrade.Enum.Wood:
                        icon = "http://i.imgur.com/F4XBBhY.png";
                        break;
                    case BuildingGrade.Enum.Stone:
                        icon = "http://i.imgur.com/S7Sl9oh.png";
                        break;
                    case BuildingGrade.Enum.Metal:
                        icon = "http://i.imgur.com/fVjzbag.png";
                        break;
                    case BuildingGrade.Enum.TopTier:
                        icon = "http://i.imgur.com/f0WklR3.png";
                        break;
                }

            }
            CuiElement ehUI = new CuiElement { Name = "EnhancedHammerUI", Parent = "HUD/Overlay", FadeOut = 0.5f };
            CuiRawImageComponent ehUI_IMG = new CuiRawImageComponent { FadeIn = 0.5f, Url = icon };
            CuiRectTransformComponent ehUI_RECT = new CuiRectTransformComponent
            {
                AnchorMin = "0.32 0.09",
                AnchorMax = "0.34 0.13"
            };
            ehUI.Components.Add(ehUI_IMG);
            ehUI.Components.Add(ehUI_RECT);
            panel.Add(ehUI);
            CuiHelper.AddUi(player, panel);
        }
Пример #32
0
        private void nextCountdown()
        {
            if(currentCount >= 0){
                if(elements != null){
                    elements = null;
                }
                elements = new CuiElementContainer();

                string numToShow = currentCount.ToString();
                string color = "0 0 0 1.0";

                if(currentCount == 0){
                    numToShow = "FIGHT!";
                    color = "0.50 0.0 0.0 1.0";
                    foreach(EventPlayer player in EventPlayers){
                        GivePlayerKit(player.player, EventKit);

                    }
                    EventStarted = true;
                }
                BroadcastToChat(numToShow);

                var oldCount = mainCount;
                mainCount = elements.Add(new CuiPanel
                {
                    Image =
                    {
                        Color = "0.1 0.1 0.1 0"
                    },
                    RectTransform =
                    {
                        AnchorMin = "0.45 0.45",
                        AnchorMax = "0.55 0.55"
                    },
                    CursorEnabled = false
                }, "HUD/Overlay", "event_countdown");

                elements.Add(new CuiLabel
                    {
                        Text =
                        {
                            Text = numToShow,
                            FontSize = 34,
                            Align = TextAnchor.MiddleCenter,
                            Color = color
                        }
            ,                        RectTransform =
                        {
                            AnchorMin = "0.0 0.0",
                            AnchorMax = "1.0 1.0"
                        }
                    }, "event_countdown");

                if(currentCount == 0){
                    ConsoleSystem.Run.Server.Normal("launchEvent");
                }

                foreach (EventPlayer player in EventPlayers)
                {
                    CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player.player.net.connection }, null, "DestroyUI", new Facepunch.ObjectList("event_countdown", null, null, null, null));

                    CuiHelper.AddUi(player.player, elements);

                    if(currentCount > 0){
                        Effect.server.Run("assets/bundled/prefabs/fx/door/lock.code.lock.prefab", player.player.transform.position, Vector3.zero, null, false);
                    }
                    if(currentCount == 0){
                        CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player.player.net.connection }, null, "DestroyUI", new Facepunch.ObjectList("event_blackout", null, null, null, null));
                        Effect.server.Run("assets/bundled/prefabs/fx/entities/helicopter/heli_explosion.prefab", player.player.transform.position, Vector3.zero, null, false);
                        //BroadcastToChat("SDFDDSF");
                    }
                }
            }
            else{
                foreach (EventPlayer player in EventPlayers)
                {
                    if(mainCount != null){
                        CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player.player.net.connection }, null, "DestroyUI", new Facepunch.ObjectList("event_countdown", null, null, null, null));
                    }
                }
            }
            currentCount--;
        }
Пример #33
0
        private void guitest(BasePlayer player, string command, string[] args)
        {
            elements = new CuiElementContainer();

            mainName = elements.Add(new CuiPanel
            {
                Image =
                {
                    Color = "0.1 0.1 0.1 1"
                },
                RectTransform =
                {
                    AnchorMin = "0.0 0.95",
                    AnchorMax = "1.0 1.0"
                },
                CursorEnabled = false
            }, "HUD/Overlay", "event_top"

            );

             elements.Add(new CuiLabel
                {
                    Text =
                    {
                        Text = "2 Players Left.",
                        FontSize = 24,
                        Align = TextAnchor.MiddleCenter
                    },
                    RectTransform =
                    {
                        AnchorMin = "0.0 0.0",
                        AnchorMax = "1.0 1.0"
                    }
                }, "event_top");

              elements.Add(new CuiLabel
                {
                    Text =
                    {
                        Text = "DeadLaugh Event",
                        FontSize = 16,
                        Align = TextAnchor.MiddleLeft
                    },
                    RectTransform =
                    {
                        AnchorMin = "0.025 0.0",
                        AnchorMax = "1.0 1.0"
                    }
                }, "event_top");

              CuiHelper.AddUi(player, elements);
        }
Пример #34
0
        /*
        private void updateGUI()
        {
           // startCountdown();

            if(elements != null){
                elements = null;
            }
            elements = new CuiElementContainer();
            string mainNameTemp = mainName;

            if(!EventStarted){
                json1 = @"[
                       {
                            ""name"": ""event_blackout"",
                            ""parent"": ""HUD/Overlay"",
                            ""components"":
                            [
                                {
                                    ""type"":""UnityEngine.UI.RawImage"",
                                    ""imagetype"": ""Filled"",
                                    ""color"": ""1.0 1.0 1.0 1.0"",
                                    ""url"": ""http://rust.deadlaugh.com/overlay/dl2.png"",
                                    ""fadeIn"": ""1""
                                },
                                {
                                    ""type"":""RectTransform"",
                                    ""anchormin"": ""0.0 0.0"",
                                    ""anchormax"": ""1.0 1.0""
                                }
                            ]
                        }
                    ]
                    ";

            }

            mainName = elements.Add(new CuiPanel
            {
                Image =
                {
                    Color = "0.1 0.1 0.1 1"
                },
                RectTransform =
                {
                    AnchorMin = "0.0 0.95",
                    AnchorMax = "1.0 1.0"
                },
                CursorEnabled = false
            },"HUD/Overlay", "event_top");

             elements.Add(new CuiLabel
                {
                    Text =
                    {
                        Text = activeCount().ToString() + " Players Left.",
                        FontSize = 24,
                        Align = TextAnchor.MiddleCenter
                    },
                    RectTransform =
                    {
                        AnchorMin = "0.0 0.0",
                        AnchorMax = "1.0 1.0"
                    }
                }, "event_top");

              elements.Add(new CuiLabel
                {
                    Text =
                    {
                        Text = "DeadLaugh Event",
                        FontSize = 16,
                        Align = TextAnchor.MiddleLeft
                    },
                    RectTransform =
                    {
                        AnchorMin = "0.025 0.0",
                        AnchorMax = "1.0 1.0"
                    }
                }, "event_top");

            foreach (EventPlayer player1 in EventPlayers)
            {

                    CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player1.player.net.connection }, null, "DestroyUI", new Facepunch.ObjectList("event_top", null, null, null, null));

                    if(player1.inEvent){
                        if(!EventStarted){
                            CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player1.player.net.connection }, null, "AddUI", new Facepunch.ObjectList(json1));
                        }
                        CuiHelper.AddUi(player1.player, elements);
                    }
            }

            if(activeCount() == 1 && EventStarted ){
                startCelebration(getWinner());
            }
        }
        */
        private void updateGUI(BasePlayer player)
        {
            // startCountdown();

            if(elements != null){
                elements = null;
            }
            elements = new CuiElementContainer();
            string mainNameTemp = mainName;

            if(!EventStarted){
                json1 = @"[
                       {
                            ""name"": ""event_blackout"",
                            ""parent"": ""HUD/Overlay"",
                            ""components"":
                            [
                                {
                                    ""type"":""UnityEngine.UI.RawImage"",
                                    ""imagetype"": ""Filled"",
                                    ""color"": ""1.0 1.0 1.0 1.0"",
                                    ""url"": ""http://rust.deadlaugh.com/overlay/dl2.png"",
                                    ""fadeIn"": ""1""
                                },
                                {
                                    ""type"":""RectTransform"",
                                    ""anchormin"": ""0.0 0.0"",
                                    ""anchormax"": ""1.0 1.0""
                                }
                            ]
                        }
                    ]
                    ";

            }

            mainName = elements.Add(new CuiPanel
            {
                Image =
                {
                    Color = "0.1 0.1 0.1 1"
                },
                RectTransform =
                {
                    AnchorMin = "0.0 0.95",
                    AnchorMax = "1.0 1.0"
                },
                CursorEnabled = false
            },"HUD/Overlay", "event_top");

             elements.Add(new CuiLabel
                {
                    Text =
                    {
                        Text = activeCount().ToString() + " Players Left.",
                        FontSize = 24,
                        Align = TextAnchor.MiddleCenter
                    },
                    RectTransform =
                    {
                        AnchorMin = "0.0 0.0",
                        AnchorMax = "1.0 1.0"
                    }
                }, "event_top");

              elements.Add(new CuiLabel
                {
                    Text =
                    {
                        Text = "DeadLaugh Event",
                        FontSize = 16,
                        Align = TextAnchor.MiddleLeft
                    },
                    RectTransform =
                    {
                        AnchorMin = "0.025 0.0",
                        AnchorMax = "1.0 1.0"
                    }
                }, "event_top");

            CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player.net.connection }, null, "DestroyUI", new Facepunch.ObjectList("event_top", null, null, null, null));

            EventPlayer p = player.GetComponent<EventPlayer>();

            if((p != null) && (p.inEvent)){ // add event_blackout once to each player
                if(!EventStarted){
                    CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player.net.connection }, null, "AddUI", new Facepunch.ObjectList(json1));
                }
            }

            foreach (EventPlayer player1 in EventPlayers)
            {
                    CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player1.player.net.connection }, null, "DestroyUI", new Facepunch.ObjectList("event_top", null, null, null, null));

                    if(player1.inEvent){
                        CuiHelper.AddUi(player1.player, elements);
                    }
            }
        }