public UIButton(UIContainer container, string buttonText = "", string buttonColor = "0 0 0 0.85", string textColor = "1 1 1 1", int fontSize = 15) : base(container)
            {
                _fontSize = fontSize;

                var button = new CuiButton();

                buttonComponent = button.Button;
                textComponent   = button.Text;

                buttonComponent.Command = CuiHelper.GetGuid();
                buttonComponent.Color   = buttonColor;

                textComponent.Text     = buttonText;
                textComponent.FontSize = _fontSize;
                textComponent.Align    = TextAnchor.MiddleCenter;

                Element.Components.Insert(0, buttonComponent);

                _plugin.cmd.AddConsoleCommand(buttonComponent.Command, _plugin, "OnButtonClick");

                _plugin.UIButtonCallBacks[buttonComponent.Command] = this;

                label = new UILabel(container, buttonText, parent: Element.Name, fontSize: _fontSize);

                label.SetPosition(0, 0);
                label.SetSize(1f, 1f);
                label.text.Align = TextAnchor.MiddleCenter;
                label.text.Color = textColor;

                textComponent = label.text;
            }
示例#2
0
        private void ShowGui(BasePlayer player)
        {
            Puts(player.displayName + " has connected");

            var elements = new CuiElementContainer();
            var panel    = new CuiPanel
            {
                Image         = { Color = "1.0 0.0 0.0 0.5" },
                CursorEnabled = true,
                RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1" }
            };

            var panelName = elements.Add(panel);

            var button = new CuiButton
            {
                Button        = { Close = panelName, Color = "0 0.5 0 1" },
                RectTransform = { AnchorMin = "0.4 0.4", AnchorMax = "0.6 0.6" },
                Text          = { Text = "Close", FontSize = 22, Align = TextAnchor.MiddleCenter }
            };

            elements.Add(button, panelName);

            CuiHelper.AddUi(player, elements);
        }
示例#3
0
        private void OpenMainHappyPanel(BasePlayer player, string command, string[] args, int editing)
        {
            bool isadmin = permission.UserHasPermission(player.UserIDString, admin);

            if (isadmin == false)
            {
                return;
            }
            CuiHelper.DestroyUi(player, MainHappyPanel);
            if (debug == true)
            {
                Puts($"DEBUT VOID PANEL");
            }

            #region MAIN PANEL COLONNES & COULEURS

            string PanelColor       = "0.0 0.0 0.0 1.0";
            string buttonCloseColor = "0.6 0.26 0.2 1";

            #endregion

            #region MAIN PANEL CUI de base

            var CuiElement = new CuiElementContainer();

            MainHappyPanel = CuiElement.Add(new CuiPanel

            {
                Image         = { Color = $"{PanelColor}" },
                RectTransform = { AnchorMin = "0.0 0.0", AnchorMax = "1.0 1.0" },
                CursorEnabled = true
            }, new CuiElement().Parent = "Overlay", MainHappyPanel);

            var closeButton = new CuiButton
            {
                Button        = { Close = MainHappyPanel, Color = $"{buttonCloseColor}" },
                RectTransform = { AnchorMin = "0.95 0.95", AnchorMax = "0.99 0.99" },
                Text          = { Text = "[X]", FontSize = 16, Align = TextAnchor.MiddleCenter }
            };

            CuiElement.Add(closeButton, MainHappyPanel);

            var Title = CuiElement.Add(new CuiLabel
            {
                Text          = { Text = $"HAPPY HOUR(s) !", Color = "1.0 1.0 1.0 1.0", FontSize = 24, Align = TextAnchor.MiddleRight },
                RectTransform = { AnchorMin = $"0.70 0.95", AnchorMax = $"0.94 0.99" }
            }, MainHappyPanel);

            var Editing = CuiElement.Add(new CuiLabel
            {
                Text          = { Text = $"edit with <ITEMS> and toggle <ON/OFF> button(s) ", Color = "1.0 1.0 1.0 1.0", FontSize = 20, Align = TextAnchor.MiddleCenter },
                RectTransform = { AnchorMin = $"0.20 0.95", AnchorMax = $"0.65 0.99" }
            }, MainHappyPanel);

            CuiHelper.AddUi(player, CuiElement);

            DisplayHoursButtons(player, editing);
        }
示例#4
0
        void DisplayBannerToAll(string reason)
        {
            foreach (var player in BasePlayer.activePlayerList)
            {
                if (bannerdisplay == true)
                {
                    string message = string.Empty;
                    if (reason == "spawn")
                    {
                        message = $"{lang.GetMessage("SpawnMsg", this, player.UserIDString)}";
                    }
                    if (reason == "killed")
                    {
                        message = $"{lang.GetMessage("KilledMsg", this, player.UserIDString)}";
                    }
                    var CuiElement   = new CuiElementContainer();
                    var PatrolBanner = CuiElement.Add(new CuiPanel {
                        Image = { Color = bannercolor }, RectTransform = { AnchorMin = "0.20 0.85", AnchorMax = "0.80 0.90" }, CursorEnabled = false
                    });
                    var closeButton = new CuiButton {
                        Button = { Close = PatrolBanner, Color = "0.0 0.0 0.0 0.6" }, RectTransform = { AnchorMin = "0.90 0.01", AnchorMax = "0.99 0.99" }, Text = { Text = "X", FontSize = 20, Align = TextAnchor.MiddleCenter }
                    };
                    CuiElement.Add(closeButton, PatrolBanner);
                    CuiElement.Add(new CuiLabel {
                        Text = { Text = $"{message}", FontSize = 20, Align = TextAnchor.MiddleCenter, Color = "1.0 1.0 1.0 1" }, RectTransform = { AnchorMin = "0.10 0.10", AnchorMax = "0.90 0.90" }
                    }, PatrolBanner);

                    CuiHelper.AddUi(player, CuiElement);

                    timer.Once(12, () =>
                    {
                        CuiHelper.DestroyUi(player, PatrolBanner);
                    });
                    if (debug == true)
                    {
                        Puts($"BANNER DISPLAYING FOR PLAYER {player.displayName}");
                    }
                }

                if (sound == true)
                {
                    var sound = new Effect("assets/bundled/prefabs/fx/player/howl.prefab", player, 0, Vector3.zero, Vector3.forward);
                    EffectNetwork.Send(sound, player.net.connection);
                    if (debug == true)
                    {
                        Puts($"PLAYING SOUND FOR PLAYER {player.displayName}");
                    }
                }
            }
        }
示例#5
0
        void CommandLb(BasePlayer player, string command, string[] args)
        {
            var elements = new CuiElementContainer();

            var panel = new CuiPanel
            {
                Image         = { Color = "0.0 0.0 0.0 0.75" },
                CursorEnabled = true,
                RectTransform = { AnchorMin = "0.3 0.3", AnchorMax = "0.75 0.75" }
            };
            var panelName = elements.Add(panel);

            var button = new CuiButton
            {
                Button        = { Close = panelName, Color = "0 0.5 0 1" },
                RectTransform = { AnchorMin = "0.9 0.9", AnchorMax = "0.99 0.97" },
                Text          = { Text = "Close", FontSize = 14, Align = TextAnchor.MiddleCenter }
            };

            elements.Add(button, panelName);

            elements.Add(CreateLabel("Name", 18, TextAnchor.UpperCenter, 0.01f, 0.9f, 0.3f, 0.1f), panelName);

            var yPos = 0.87f;

            for (var i = 0; i < 10; i++)
            {
                var info = _storedData.Players[i];

                if (info == null)
                {
                    break;
                }

                elements.Add(CreateLabel(info.Name, 12, TextAnchor.MiddleCenter, 0.01f, yPos, 0.3f, 0.04f), panelName);
                yPos -= 0.1f;
            }

            CuiHelper.AddUi(player, elements);
        }
        private static void AddNonActiveButton(
            int tabIndex,
            CuiElementContainer container,
            HelpTab helpTab,
            string mainPanelName,
            string activeTabButtonName)
        {
            Color nonActiveButtonColor;

            ColorExtensions.TryParseHexString(_settings.InactiveButtonColor, out nonActiveButtonColor);

            CuiButton helpTabButton     = CreateTabButton(tabIndex, helpTab, nonActiveButtonColor);
            string    helpTabButtonName = container.Add(helpTabButton, mainPanelName);

            CuiElement helpTabButtonCuiElement =
                container.First(i => i.Name.Equals(helpTabButtonName, StringComparison.OrdinalIgnoreCase));
            CuiButtonComponent generatedHelpTabButton = helpTabButtonCuiElement.Components.OfType <CuiButtonComponent>().First();

            string command = string.Format("changeTab {0} {1} {2} {3}", tabIndex, activeTabButtonName, helpTabButtonName, mainPanelName);

            generatedHelpTabButton.Command = command;
        }
示例#7
0
        void ShowLotery(BasePlayer player, string[] args)
        {
            if (!Economy.IsLoaded)
            {
                SendReply(player, lang.GetMessage("NoEconomy", this, player.UserIDString));
                return;
            }
            int        multiplier     = 1;
            int        bet            = 0;
            int        from           = 0;
            double     currentBalance = (double)Economy?.Call("GetPlayerMoney", player.userID.ToString());
            playerinfo playerbet      = new playerinfo();

            if (Currentbet.ContainsKey(player.userID))
            {
                Currentbet.TryGetValue(player.userID, out playerbet);
            }
            else
            {
                Currentbet.Add(player.userID, new playerinfo());
                Currentbet.TryGetValue(player.userID, out playerbet);
            }
            if (args != null && args.Length > 0)
            {
                if (args[0].Contains("less") || args[0].Contains("plus"))
                {
                    if (args[0].Contains("plus"))
                    {
                        if (currentBalance >= playerbet.currentbet * (playerbet.multiplicator + 1))
                        {
                            int.TryParse(args[1], out multiplier);
                            playerbet.multiplicator += multiplier;
                        }
                    }
                    if (args[0].Contains("less"))
                    {
                        if (playerbet.multiplicator > 1)
                        {
                            playerbet.multiplicator -= 1;
                        }
                    }
                }
                if (args[0].Contains("bet"))
                {
                    int.TryParse(args[1], out bet);
                    if (currentBalance < (playerbet.currentbet + bet) * playerbet.multiplicator)
                    {
                        SendReply(player, lang.GetMessage("NotEnoughMoney", this, player.UserIDString));
                    }
                    else
                    {
                        playerbet.currentbet += bet;
                    }
                }
                if (args[0].Contains("page"))
                {
                    int.TryParse(args[1], out from);
                }
            }
            int    i        = 0;
            double jackpots = Math.Round(Currentbet.Sum(v => v.Value.totalbet));

            jackpots += jackpot;
            var win          = new CuiElementContainer();
            var containerwin = win.Add(new CuiPanel
            {
                Image =
                {
                    Color = "0.1 0.1 0.1 1"
                },
                RectTransform =
                {
                    AnchorMin = "0.8 0.2",
                    AnchorMax = "1 0.8"
                },
                CursorEnabled = true
            }, "Hud", "containerwin");

            win.Add(new CuiLabel
            {
                Text =
                {
                    Text     = "Win Rate",
                    FontSize =         18,
                    Align    = TextAnchor.MiddleCenter
                },
                RectTransform =
                {
                    AnchorMin = "0.1 0.85",
                    AnchorMax = "0.9 1"
                }
            }, containerwin);
            if (UseSR && ServerRewards.IsLoaded)
            {
                foreach (var elem in SRRates)
                {
                    var pos  = 0.86 - (i - from) / 10.0;
                    var pos2 = 0.91 - (i - from) / 20.0;
                    win.Add(new CuiLabel
                    {
                        Text =
                        {
                            Text     = elem.Key + ": " + elem.Value + " point(s)",
                            FontSize =                                         18,
                            Align    = TextAnchor.MiddleCenter
                        },
                        RectTransform =
                        {
                            AnchorMin = $"{0.1} {pos}",
                            AnchorMax = $"{0.9} {pos2}"
                        }
                    }, containerwin);
                    i++;
                }
            }
            else
            {
                foreach (var elem in IndividualRates)
                {
                    if (i == 0)
                    {
                        var pos  = 0.81 - (i - from) / 10.0;
                        var pos2 = 0.86 - (i - from) / 20.0;
                        win.Add(new CuiLabel
                        {
                            Text =
                            {
                                Text     = elem.Key + ": " + elem.Value + " %",
                                FontSize =                                  18,
                                Align    = TextAnchor.MiddleCenter
                            },
                            RectTransform =
                            {
                                AnchorMin = $"{0.1} {pos}",
                                AnchorMax = $"{0.9} {pos2}"
                            }
                        }, containerwin);
                    }
                    else if (i >= from && i < from + 9)
                    {
                        var pos  = 0.81 - (i - from) / 10.0;
                        var pos2 = 0.86 - (i - from) / 20.0;
                        win.Add(new CuiLabel
                        {
                            Text =
                            {
                                Text     = elem.Key + ": " + elem.Value + " %",
                                FontSize =                                  18,
                                Align    = TextAnchor.MiddleCenter
                            },
                            RectTransform =
                            {
                                AnchorMin = $"{0.1} {pos}",
                                AnchorMax = $"{0.9} {pos2}"
                            }
                        }, containerwin);
                    }
                    i++;
                }
                var minfrom = from <= 10 ? 0 : from - 10;
                var maxfrom = from + 10 >= i ? from : from + 10;
                win.AddRange(ChangeBonusPage(minfrom, maxfrom));
            }

            var elements = new CuiElementContainer();

            #region background
            var container = elements.Add(new CuiPanel
            {
                Image =
                {
                    Color = "0.1 0.1 0.1 1"
                },
                RectTransform =
                {
                    AnchorMin = "0 0.2",
                    AnchorMax = "0.8 0.8"
                },
                CursorEnabled = true
            }, "Hud", "container");
            #endregion
            #region closebutton
            var closeButton = new CuiButton
            {
                Button =
                {
                    Command = "cmdDestroyUI",
                    Close   = container,
                    Color   = "0.8 0.8 0.8 0.2"
                },
                RectTransform =
                {
                    AnchorMin = "0.86 0.92",
                    AnchorMax = "0.97 0.98"
                },
                Text =
                {
                    Text     = "X",
                    FontSize =  22,
                    Align    = TextAnchor.MiddleCenter
                }
            };
            elements.Add(closeButton, container);
            #endregion
            #region currency
            elements.Add(new CuiLabel
            {
                Text =
                {
                    Text     = string.Format(lang.GetMessage("Balance", this, player.UserIDString), currentBalance.ToString(CultureInfo.CurrentCulture)),
                    FontSize =                                      18,
                    Align    = TextAnchor.MiddleCenter
                },
                RectTransform =
                {
                    AnchorMin = "0.1 0.91",
                    AnchorMax = "0.9 0.98"
                }
            }, container);
            #endregion
            #region multiplier
            elements.Add(new CuiLabel
            {
                Text =
                {
                    Text     = "Multiplier : x" + playerbet.multiplicator,
                    FontSize =                                         18,
                    Align    = TextAnchor.MiddleCenter
                },
                RectTransform =
                {
                    AnchorMin = "0.05 0.81",
                    AnchorMax = "0.15 0.88"
                }
            }, container);
            elements.Add(new CuiButton
            {
                Button =
                {
                    Command = "cmdLess",
                    Close   = container,
                    Color   = "0.8 0.8 0.8 0.2"
                },
                Text =
                {
                    Text     = "-",
                    FontSize =  18,
                    Align    = TextAnchor.MiddleCenter
                },
                RectTransform =
                {
                    AnchorMin = "0.2 0.81",
                    AnchorMax = "0.3 0.88"
                }
            }, container);
            elements.Add(new CuiButton
            {
                Button =
                {
                    Command = "cmdPlus",
                    Close   = container,
                    Color   = "0.8 0.8 0.8 0.2"
                },
                Text =
                {
                    Text     = "+",
                    FontSize =  18,
                    Align    = TextAnchor.MiddleCenter
                },
                RectTransform =
                {
                    AnchorMin = "0.31 0.81",
                    AnchorMax = "0.41 0.88"
                }
            }, container);
            #endregion
            #region bet
            elements.Add(new CuiLabel
            {
                Text =
                {
                    Text     = "Bet modifiers :",
                    FontSize =                18,
                    Align    = TextAnchor.MiddleCenter
                },
                RectTransform =
                {
                    AnchorMin = "0.05 0.61",
                    AnchorMax = "0.15 0.68"
                }
            }, container);
            elements.Add(new CuiButton
            {
                Button =
                {
                    Command = "cmdBet 1",
                    Close   = container,
                    Color   = "0.8 0.8 0.8 0.2"
                },
                Text =
                {
                    Text     = "+1",
                    FontSize =   18,
                    Align    = TextAnchor.MiddleCenter
                },
                RectTransform =
                {
                    AnchorMin = "0.05 0.51",
                    AnchorMax = "0.15 0.58"
                }
            }, container);
            elements.Add(new CuiButton
            {
                Button =
                {
                    Command = "cmdBet 5",
                    Close   = container,
                    Color   = "0.8 0.8 0.8 0.2"
                },
                Text =
                {
                    Text     = "+5",
                    FontSize =   18,
                    Align    = TextAnchor.MiddleCenter
                },
                RectTransform =
                {
                    AnchorMin = "0.155 0.51",
                    AnchorMax = "0.255 0.58"
                }
            }, container);
            elements.Add(new CuiButton
            {
                Button =
                {
                    Command = "cmdBet 10",
                    Close   = container,
                    Color   = "0.8 0.8 0.8 0.2"
                },
                Text =
                {
                    Text     = "+10",
                    FontSize =    18,
                    Align    = TextAnchor.MiddleCenter
                },
                RectTransform =
                {
                    AnchorMin = "0.26 0.51",
                    AnchorMax = "0.36 0.58"
                }
            }, container);
            elements.Add(new CuiButton
            {
                Button =
                {
                    Command = "cmdBet 100",
                    Close   = container,
                    Color   = "0.8 0.8 0.8 0.2"
                },
                Text =
                {
                    Text     = "+100",
                    FontSize =     18,
                    Align    = TextAnchor.MiddleCenter
                },
                RectTransform =
                {
                    AnchorMin = "0.365 0.51",
                    AnchorMax = "0.485 0.58"
                }
            }, container);
            elements.Add(new CuiButton
            {
                Button =
                {
                    Command = "cmdBet 1000",
                    Close   = container,
                    Color   = "0.8 0.8 0.8 0.2"
                },
                Text =
                {
                    Text     = "+1000",
                    FontSize =      18,
                    Align    = TextAnchor.MiddleCenter
                },
                RectTransform =
                {
                    AnchorMin = "0.05 0.41",
                    AnchorMax = "0.15 0.48"
                }
            }, container);
            elements.Add(new CuiButton
            {
                Button =
                {
                    Command = "cmdBet 10000",
                    Close   = container,
                    Color   = "0.8 0.8 0.8 0.2"
                },
                Text =
                {
                    Text     = "+10000",
                    FontSize =       18,
                    Align    = TextAnchor.MiddleCenter
                },
                RectTransform =
                {
                    AnchorMin = "0.155 0.41",
                    AnchorMax = "0.255 0.48"
                }
            }, container);
            elements.Add(new CuiButton
            {
                Button =
                {
                    Command = "cmdPlaceBet",
                    Close   = container,
                    Color   = "0.8 0.8 0.8 0.2"
                },
                Text =
                {
                    Text     = "Place Bet",
                    FontSize =          18,
                    Align    = TextAnchor.MiddleCenter
                },
                RectTransform =
                {
                    AnchorMin = "0.05 0.31",
                    AnchorMax = "0.255 0.38"
                }
            }, container);
            #endregion
            #region winpart
            elements.Add(new CuiLabel
            {
                Text =
                {
                    Text     = string.Format(lang.GetMessage("CurrentBet", this, player.UserIDString), playerbet.currentbet * playerbet.multiplicator),
                    FontSize =                                         18,
                    Align    = TextAnchor.MiddleCenter
                },
                RectTransform =
                {
                    AnchorMin = "0.71 0.71",
                    AnchorMax = "0.99 0.81"
                }
            }, container);

            if (UseSR && ServerRewards.IsLoaded)
            {
                var mini = string.Format(lang.GetMessage("MinimumSRBet", this, player.UserIDString), MinBetjackpot, SRjackpot);
                elements.Add(new CuiLabel
                {
                    Text =
                    {
                        Text     = mini,
                        FontSize =   18,
                        Align    = TextAnchor.MiddleCenter
                    },
                    RectTransform =
                    {
                        AnchorMin = "0.71 0.39",
                        AnchorMax = "0.99 0.59"
                    }
                }, container);
            }
            else
            {
                elements.Add(new CuiLabel
                {
                    Text =
                    {
                        Text     = string.Format(lang.GetMessage("Roll", this, player.UserIDString), JackpotNumber, jackpots),
                        FontSize =                                   18,
                        Align    = TextAnchor.MiddleCenter
                    },
                    RectTransform =
                    {
                        AnchorMin = "0.71 0.39",
                        AnchorMax = "0.99 0.59"
                    }
                }, container);
            }
            #endregion
            CuiHelper.AddUi(player, elements);
            CuiHelper.AddUi(player, win);
            Currentbet.Remove(player.userID);
            Currentbet.Add(player.userID, playerbet);
            SaveData(Currentbet);
        }
示例#8
0
        // ReSharper disable once UnusedMember.Local
        private void Init()
        {
            LoadConfig();

            cmd.AddConsoleCommand("gamemenu.exec", this, arg =>
            {
                if (!arg.HasArgs(2))
                {
                    return(false);
                }

                var isChat = arg.Args[0] == "chat";
                SendCommand(arg.Connection, arg.Args.Skip(1).ToArray(), isChat);

                return(false);
            });

            var menusCount = _config.Menus.Count;
            var btwButtons = _config.BetweenButtons;
            var fadeTime   = _config.FadeTime;

            _backgroundButton = new CuiButton
            {
                Button =
                {
                    Close  = "GameMenuCUI",
                    Color  = "0.0 0.0 0.0 0.0",
                    FadeIn = fadeTime
                },
                Text =
                {
                    Text = string.Empty
                },
                RectTransform =
                {
                    AnchorMin = "0.0 0.0",
                    AnchorMax = "1.0 1.0"
                }
            };

            for (var i = 0; i < menusCount; i++)
            {
                var menu = _config.Menus[i];

                // Registering permissions
                var perm = menu.Permission;
                if (!string.IsNullOrEmpty(perm) && !permission.PermissionExists(perm, this))
                {
                    permission.RegisterPermission(perm, this);
                }

                // Loading CUIs

                var buttonsCount = menu.Buttons.Count;
                var totalHeight  = 0.0f;
                var sum          = 0f;
                for (var i2 = 0; i2 < buttonsCount; i2++)
                {
                    sum += menu.Buttons[i2].ButtonHeight;
                }

                var maxWidth = 0f;
                for (var i2 = 0; i2 < buttonsCount; i2++)
                {
                    var buttonWidth = menu.Buttons[i2].ButtonWidth;
                    if (buttonWidth > maxWidth)
                    {
                        maxWidth = buttonWidth;
                    }
                }

                var maxHeight = sum + btwButtons * (buttonsCount - 1);

                // Loading menu
                var mWidth    = maxWidth + 2 * btwButtons;
                var mWidthMin = (1.0f - mWidth) / 2;
                var mWidthMax = mWidthMin + mWidth;

                var nHeight    = menu.NameHeight;
                var mHeight    = 3 * btwButtons + maxHeight + nHeight;
                var mHeightMin = (1.0f - mHeight) / 2;
                var mHeightMax = mHeightMin + mHeight;

                menu.Menu = new CuiPanel
                {
                    Image =
                    {
                        Color  = menu.BackgroundColor,
                        FadeIn = fadeTime
                    },
                    CursorEnabled = true,
                    RectTransform =
                    {
                        AnchorMin = $"{mWidthMin} {mHeightMin}",
                        AnchorMax = $"{mWidthMax} {mHeightMax}"
                    }
                };

                var nHeightMax = mHeightMax - btwButtons;
                var nHeightMin = nHeightMax - nHeight;

                menu.MenuText = new CuiLabel
                {
                    Text =
                    {
                        Text     = menu.Name,
                        Align    = TextAnchor.MiddleCenter,
                        Color    = menu.NameColor,
                        FadeIn   = fadeTime,
                        FontSize = menu.NameSize
                    },
                    RectTransform =
                    {
                        AnchorMin = $"{mWidthMin} {nHeightMin}",
                        AnchorMax = $"{mWidthMax} {nHeightMax}"
                    }
                };

                // Loading buttons
                for (var i2 = 0; i2 < buttonsCount; i2++)
                {
                    var button = menu.Buttons[i2];
                    var width  = button.ButtonWidth;
                    var height = button.ButtonHeight;

                    var widthMin = (1.0f - width) / 2;
                    var widthMax = widthMin + width;

                    var heightMin = mHeightMin + totalHeight + (i2 + 1) * btwButtons;
                    var heightMax = heightMin + height;

                    totalHeight += height;
                    var type = button.IsChatCommand ? "chat" : "console";

                    button.Button = new CuiButton
                    {
                        Text =
                        {
                            Text     = $"<color={button.TextColor}>{button.Text}</color>",
                            FontSize = button.TextSize,
                            Align    = TextAnchor.MiddleCenter,
                            FadeIn   = fadeTime
                        },
                        Button =
                        {
                            Color   = button.ButtonColor,
                            Command = $"gamemenu.exec {type} {button.Command}",
                            FadeIn  = fadeTime
                        },
                        RectTransform =
                        {
                            AnchorMin = $"{widthMin} {heightMin}",
                            AnchorMax = $"{widthMax} {heightMax}"
                        }
                    };
                }

                // Registering chat commands for menus
                if (!string.IsNullOrEmpty(menu.CommmandChat))
                {
                    cmd.AddChatCommand(menu.CommmandChat, this, (player, command, args) =>
                    {
                        if (!CanUse(player, perm))
                        {
                            player.ChatMessage(GetMsg("No Permission", player.UserIDString));
                            return;
                        }

                        ShowUI(player, menu);
                    });
                }

                // Registering console commands for menus
                if (!string.IsNullOrEmpty(menu.CommmandConsole))
                {
                    cmd.AddConsoleCommand(menu.CommmandConsole, this, arg =>
                    {
                        if (arg.Connection == null || arg.IsRcon)
                        {
                            arg.ReplyWith(GetMsg("Only Player"));
                            return(true);
                        }

                        var player = BasePlayer.FindByID(arg.Connection.userid);
                        if (!CanUse(player, perm))
                        {
                            arg.ReplyWith(GetMsg("No Permission", player.UserIDString));
                            return(true);
                        }

                        ShowUI(player, menu);
                        return(false);
                    });
                }
            }
        }
示例#9
0
        void UseUI(BasePlayer player, string msg)
        {
            var elements = new CuiElementContainer();

            var mainName = elements.Add(new CuiPanel
            {
                Image =
                {
                    Color = "0.1 0.1 0.1 1"
                },
                RectTransform =
                {
                    AnchorMin = "0 0",
                    AnchorMax = "1 1"
                },
                CursorEnabled = true
            }, "Overlay", "RulesGUI");

            if (backroundimage == true)
            {
                elements.Add(new CuiElement
                {
                    Parent     = "RulesGUI",
                    Components =
                    {
                        new CuiRawImageComponent
                        {
                            Url    = backroundimageurl,
                            Sprite = "assets/content/textures/generic/fulltransparent.tga"
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0 0",
                            AnchorMax = "1 1"
                        }
                    }
                });
            }
            var Agree = new CuiButton
            {
                Button =
                {
                    Close = mainName,
                    Color = "0 255 0 1"
                },
                RectTransform =
                {
                    AnchorMin = "0.2 0.16",
                    AnchorMax = "0.45 0.2"
                },
                Text =
                {
                    Text     = "I Agree",
                    FontSize =        22,
                    Align    = TextAnchor.MiddleCenter
                }
            };
            var Disagree = new CuiButton
            {
                Button =
                {
                    Command = "global.hardestcommandtoeverguess",
                    Close   = mainName,
                    Color   = "255 0 0 1"
                },
                RectTransform =
                {
                    AnchorMin = "0.5 0.16",
                    AnchorMax = "0.75 0.2"
                },
                Text =
                {
                    Text     = "I Disagree",
                    FontSize =           22,
                    Align    = TextAnchor.MiddleCenter
                }
            };

            elements.Add(new CuiLabel
            {
                Text =
                {
                    Text     = msg,
                    FontSize =  22,
                    Align    = TextAnchor.MiddleCenter
                },
                RectTransform =
                {
                    AnchorMin = "0 0.20",
                    AnchorMax = "1 0.9"
                }
            }, mainName);
            elements.Add(Agree, mainName);
            elements.Add(Disagree, mainName);
            CuiHelper.AddUi(player, elements);
        }
示例#10
0
        void DisplayBannerToAll(string reason)
        {
            // Clear all the previous banner
            DestroyAllBanner();
            bannerlist.Clear();

            // Run it for all player
            foreach (var player in BasePlayer.activePlayerList.ToList())
            {
                // Check if user has the permission
                bool hasPermission = permission.UserHasPermission(player.UserIDString, MapMyAirdropBanner);

                if (!hasPermission && !displayGuiForAll)
                {
                    continue;
                }

                // Here, user have permission so just create the banner
                List <string> bannerforplayers = new List <string>();

                // Generate the message
                string message = string.Empty;
                switch (reason)
                {
                case "spawn":
                {
                    message = lang.GetMessage("SpawnMsg", this, player.UserIDString);
                    break;
                }

                case "dropped":
                {
                    message = lang.GetMessage("DroppedMsg", this, player.UserIDString);
                    break;
                }

                case "looted":
                {
                    message = lang.GetMessage("LootedMsg", this, player.UserIDString);
                    break;
                }

                case "killed":
                {
                    message = lang.GetMessage("KilledMsg", this, player.UserIDString);
                    break;
                }
                }

                // Create the banner element
                CuiElementContainer CuiElement  = new CuiElementContainer();
                CuiPanel            bannerPanel = new CuiPanel
                {
                    Image =
                    {
                        Color = "0.5 0.5 0.5 0.30",
                    },
                    RectTransform =
                    {
                        AnchorMin = bannerAnchorMin,
                        AnchorMax = bannerAnchorMax,
                        OffsetMin = bannerOffsetMin,
                        OffsetMax = bannerOffsetMax,
                    },
                    CursorEnabled = false,
                };

                string CargoBanner = CuiElement.Add(bannerPanel);
                var    closeButton = new CuiButton {
                    Button =
                    {
                        Close = CargoBanner,
                        Color = "0.0 0.0 0.0 0.6",
                    },
                    RectTransform =
                    {
                        AnchorMin = "0.90 0.01",
                        AnchorMax = "0.99 0.99",
                    },
                    Text =
                    {
                        Text     = "X",
                        FontSize =  12,
                        Align    = TextAnchor.MiddleCenter
                    },
                };

                // CuiElement.Add(closeButton, CargoBanner);

                CuiElement.Add(new CuiLabel {
                    Text =
                    {
                        Text     = message,
                        FontSize =                      14,
                        FadeIn   =                    1.0f,
                        Align    = TextAnchor.MiddleCenter,
                        Color    = "1.0 1.0 1.0 1"
                    },
                    RectTransform =
                    {
                        AnchorMin = "0.10 0.10",
                        AnchorMax = "0.90 0.90",
                    },
                },
                               CargoBanner);

                CuiHelper.AddUi(player, CuiElement);
                timer.Once(6, () =>
                {
                    CuiHelper.DestroyUi(player, CargoBanner);
                });

                bannerforplayers.Add(CargoBanner);
                bannerlist.Remove(player);
                bannerlist.Add(player, bannerforplayers);
            }
        }
示例#11
0
        private void DisplayDropHUD(string reason)
        {
            // Clear all the hud
            DestroyAllHUD();
            HUDlist.Clear();

            List <Vector3>    positionlist  = new List <Vector3>();
            List <BaseEntity> droplist      = new List <BaseEntity>();
            List <string>     HUDforplayers = new List <string>();

            /*if (reason == "spawn")
             * {
             *
             * }*/
            if (reason == "dropped" || reason == "update" || reason == "killed" || reason == "looted")
            {
                // Remove the previous data if there is then add the new data
                foreach (var Suppliez in entsupply)
                {
                    Vector3 supplyupdated = Suppliez.Key.transform.position;
                    dropposition.Remove(Suppliez.Key);
                    dropposition.Add(Suppliez.Key, supplyupdated);
                }

                // Add the data into the local list
                foreach (var pair in dropposition)
                {
                    droplist.Add(pair.Key);
                    positionlist.Add(pair.Value);
                }

                int round = 0;
                foreach (var player in BasePlayer.activePlayerList.ToList())
                {
                    bool HUDview = permission.UserHasPermission(player.UserIDString, MapMyAirdropHUD);

                    // Check if user has the permission
                    if (!HUDview && !displayHudForAll)
                    {
                        continue;
                    }

                    // Storer for all the drops
                    Dictionary <Vector3, int> allDropsAvailable = new Dictionary <Vector3, int>();

                    // Loop for each drops
                    foreach (Vector3 drop_posi in positionlist)
                    {
                        // Sort the data base on distance
                        int dist = (int)Vector3.Distance(drop_posi, player.transform.position);
                        allDropsAvailable.Add(drop_posi, dist);
                    }

                    // Only run if the list is has data
                    if (allDropsAvailable.Count > 0)
                    {
                        // Sort the list based on distance
                        var dictList = allDropsAvailable.ToList();
                        dictList.Sort((pair1, pair2) => pair1.Value.CompareTo(pair2.Value));

                        int counter = 0;
                        foreach (KeyValuePair <Vector3, int> theData in dictList)
                        {
                            // Break it at 5, limit it to 5 on the screen
                            if (counter == bannerHUDLimit)
                            {
                                break;
                            }

                            // Increment the counter
                            counter++;

                            // Offset between each gui element
                            double columnOffset = 0.08 * round++;

                            // Generate the gui
                            var    CuiElement     = new CuiElementContainer();
                            string CargoHUDBanner = CuiElement.Add(new CuiPanel
                            {
                                Image =
                                {
                                    Color = "0.5 0.5 0.5 0.2",
                                },
                                RectTransform =
                                {
                                    AnchorMin = Convert.ToDouble(hudAnchorMin.Split()[0]) + columnOffset + " " + Convert.ToDouble(hudAnchorMin.Split()[1]),
                                    AnchorMax = Convert.ToDouble(hudAnchorMax.Split()[0]) + columnOffset + " " + Convert.ToDouble(hudAnchorMax.Split()[1]),
                                    OffsetMin = hudOffsetMin,
                                    OffsetMax = hudOffsetMax,
                                },
                                CursorEnabled = false,
                            });

                            var closeButton = new CuiButton
                            {
                                Button =
                                {
                                    Close = CargoHUDBanner,
                                    Color = "0.0 0.0 0.0 0.6",
                                },
                                RectTransform =
                                {
                                    AnchorMin = "0.90 0.00",
                                    AnchorMax = "1.00 1.00",
                                },
                                Text =
                                {
                                    Text     = "X",
                                    FontSize =                       8,
                                    Align    = TextAnchor.MiddleCenter,
                                },
                            };

                            // CuiElement.Add(closeButton, CargoHUDBanner);

                            // Get the distance between the player
                            int    dist    = theData.Value;
                            string message = string.Format(lang.GetMessage("HUDDistanceMsg", this, player.UserIDString), dist.ToString());

                            // Player distance GUI
                            var playerdistance = CuiElement.Add(new CuiLabel
                            {
                                Text =
                                {
                                    Text     = string.Format(lang.GetMessage("HUDAirdropMsg", this, player.UserIDString), round, message),
                                    Color    = "1.0 1.0 1.0 1.0",
                                    FontSize =                                            10,
                                    Align    = TextAnchor.MiddleCenter
                                },
                                RectTransform =
                                {
                                    AnchorMin = "0.0 0.0",
                                    AnchorMax = "0.85 1.0",
                                },
                            }, CargoHUDBanner);

                            // Add The GUI
                            CuiHelper.AddUi(player, CuiElement);
                            HUDforplayers.Add(CargoHUDBanner);
                        }
                    }

                    HUDlist.Remove(player);
                    HUDlist.Add(player, HUDforplayers);
                }

                if (!alreadyUpdating && HUDlist.Count > 0)
                {
                    alreadyUpdating = true;
                    timer.Once(10, () =>
                    {
                        DisplayDropHUD("update");
                    });
                }
                else if (alreadyUpdating && HUDlist.Count == 0)
                {
                    alreadyUpdating = false;
                }
                else if (alreadyUpdating && HUDlist.Count > 0)
                {
                    alreadyUpdating = true;
                    timer.Once(10, () =>
                    {
                        DisplayDropHUD("update");
                    });
                }
            }
        }
        void DisplayBannerToAll(string reason)
        {
            DestroyAllBanner();
            bannerlist.Clear();
            foreach (var player in BasePlayer.activePlayerList.ToList())
            {
                List <string> bannerforplayers = new List <string>();

                double lignehaut = 0.90;
                double lignebas  = 0.85;
                string message   = string.Empty;
                switch (reason)
                {
                case "spawn":
                {
                    message = lang.GetMessage("SpawnMsg", this, player.UserIDString);
                    break;
                }

                case "dropped":
                {
                    message = lang.GetMessage("DroppedMsg", this, player.UserIDString);
                    break;
                }

                case "looted":
                {
                    message = lang.GetMessage("LootedMsg", this, player.UserIDString);
                    break;
                }

                case "killed":
                {
                    message   = lang.GetMessage("KilledMsg", this, player.UserIDString);
                    lignehaut = lignehaut - 0.06;
                    lignebas  = lignebas - 0.06;
                    break;
                }
                }
                var    CuiElement  = new CuiElementContainer();
                string CargoBanner = CuiElement.Add(new CuiPanel {
                    Image = { Color = "0.5 0.5 0.5 0.30" }, RectTransform = { AnchorMin = $"0.20 {lignebas}", AnchorMax = $"0.80 {lignehaut}" }, CursorEnabled = false
                });
                var closeButton = new CuiButton {
                    Button = { Close = CargoBanner, Color = "0.0 0.0 0.0 0.6" }, RectTransform = { AnchorMin = "0.90 0.01", AnchorMax = "0.99 0.99" }, Text = { Text = "X", FontSize = 20, Align = TextAnchor.MiddleCenter }
                };
                CuiElement.Add(closeButton, CargoBanner);
                CuiElement.Add(new CuiLabel {
                    Text = { Text = $"{message}", FontSize = 20, FadeIn = 1.0f, Align = TextAnchor.MiddleCenter, Color = "1.0 1.0 1.0 1" }, RectTransform = { AnchorMin = "0.10 0.10", AnchorMax = "0.90 0.90" }
                }, CargoBanner);

                bool bannerview = permission.UserHasPermission(player.UserIDString, MapMyAirdropBanner);

                if (bannerview)
                {
                    CuiHelper.AddUi(player, CuiElement);
                    timer.Once(6, () =>
                    {
                        //DestroyAllBanner();
                        CuiHelper.DestroyUi(player, CargoBanner);
                    });
                }
                bannerforplayers.Add(CargoBanner);
                bannerlist.Remove(player);
                bannerlist.Add(player, bannerforplayers);


                //var sound = new Effect("assets/bundled/prefabs/fx/player/howl.prefab", player, 0, Vector3.zero, Vector3.forward);
                //EffectNetwork.Send(sound, player.net.connection);
                //if (debug == true) {Puts($"BANNER AND SOUNDFX PLAYING FOR PLAYER {player.displayName}");}
            }

            //bannerlist.Add(CargoBanner);
        }
        private void CargoHUD(string reason)
        {
            if (debug)
            {
                Puts($"HUD STARTS");
            }
            DestroyAllHUD();
            HUDlist.Clear();
            double            colonnegauche = 0.10;
            double            colonnedroite = colonnegauche + 0.07;
            double            lignehaut     = 1.00;
            double            lignebas      = lignehaut - 0.05;
            int               Round         = 1;
            int               round         = -1;
            List <Vector3>    positionlist  = new List <Vector3>();
            List <BaseEntity> droplist      = new List <BaseEntity>();

            Vector3[]    positionarray;
            BaseEntity[] droparray;

            /*if (reason == "spawn")
             * {
             *
             * }*/
            if (reason == "dropped")
            {
                if (debug)
                {
                    Puts($"HUD FOR DROP");
                }
                foreach (var Suppliez in entsupply)
                {
                    Vector3 supplyupdated = Suppliez.Key.transform.position;
                    if (debug)
                    {
                        Puts($"REFRESHED SUPPLY POSITION {supplyupdated}");
                    }
                    dropposition.Remove(Suppliez.Key);
                    dropposition.Add(Suppliez.Key, supplyupdated);
                }
                foreach (var pair in dropposition)
                {
                    //droplist.Remove(pair.Key);
                    droplist.Add(pair.Key);
                    positionlist.Add(pair.Value);
                }
                droparray     = droplist.ToArray();
                positionarray = positionlist.ToArray();
                int           dropnum       = droplist.Count;
                string        message       = "";
                List <string> HUDforplayers = new List <string>();
                foreach (var player in BasePlayer.activePlayerList.ToList())
                {
                    HUDforplayers = new List <string>();
                    for (Round = 1; Round <= dropnum; Round++)
                    {
                        if (debug)
                        {
                            Puts($"round {round} on {dropnum}");
                        }
                        round = round + 1;
                        double colonnedecalage = 0.08 * round;
                        bool   HUDview         = permission.UserHasPermission(player.UserIDString, MapMyAirdropHUD);
                        var    CuiElement      = new CuiElementContainer();
                        string CargoHUDBanner  = CuiElement.Add(new CuiPanel {
                            Image = { Color = "0.5 0.5 0.5 0.2" }, RectTransform = { AnchorMin = $"{colonnegauche + colonnedecalage} {lignebas}", AnchorMax = $"{colonnedroite + colonnedecalage} {lignehaut}" }, CursorEnabled = false
                        });
                        //}, new CuiElement().Parent = "Overlay", CargoHUDBanner);
                        var closeButton = new CuiButton {
                            Button = { Close = CargoHUDBanner, Color = "0.0 0.0 0.0 0.6" }, RectTransform = { AnchorMin = "0.90 0.00", AnchorMax = "1.00 1.00" }, Text = { Text = "X", FontSize = 8, Align = TextAnchor.MiddleCenter }
                        };
                        CuiElement.Add(closeButton, CargoHUDBanner);                            // close button in case plugin reload while HUD are on.
                        if (debug)
                        {
                            Puts($"PLAYER BEFORE DISTANCE");
                        }
                        Vector3 dropis = positionarray[round];
                        int     dist   = (int)Vector3.Distance(dropis, player.transform.position);
                        message = String.Format(lang.GetMessage("HUDDistanceMsg", this, player.UserIDString), dist.ToString());
                        if (debug)
                        {
                            Puts($"PLAYER DISTANCE MESSAGE DONE : {message}");
                        }
                        var playerdistance = CuiElement.Add(new CuiLabel
                        {
                            Text          = { Text = String.Format(lang.GetMessage("HUDAirdropMsg", this, player.UserIDString), round + 1, message), Color = "1.0 1.0 1.0 1.0", FontSize = 10, Align = TextAnchor.MiddleCenter },
                            RectTransform = { AnchorMin = $"0.0 0.0", AnchorMax = $"0.85 1.0" }
                        }, CargoHUDBanner);
                        if (HUDview)
                        {
                            CuiHelper.AddUi(player, CuiElement);
                        }
                        HUDforplayers.Add(CargoHUDBanner);
                    }
                    HUDlist.Remove(player);
                    HUDlist.Add(player, HUDforplayers);
                }
            }
        }
示例#14
0
        void UseUI(BasePlayer player, string itemurl, string itemurl2, string rightginfo, string leftginfo)
        {
            CuiElementContainer elements = new CuiElementContainer();
            var backround = elements.Add(new CuiPanel
            {
                Image =
                {
                    Color = "0.1 0.1 0.1 0.7"
                },
                RectTransform =
                {
                    AnchorMin = "0.8 0.32",
                    AnchorMax = "1 0.8"
                },
                CursorEnabled = true
            }, "HUD/Overlay", "BackroundGUI");

            elements.Add(new CuiElement
            {
                Parent     = "BackroundGUI",
                Components =
                {
                    new CuiRawImageComponent
                    {
                        Url    = itemurl,
                        Sprite = "assets/content/textures/generic/fulltransparent.tga"
                    },
                    new CuiRectTransformComponent
                    {
                        AnchorMin = "0 0.55",
                        AnchorMax = "0.3 0.9"
                    }
                }
            });
            elements.Add(new CuiElement
            {
                Parent     = "BackroundGUI",
                Components =
                {
                    new CuiRawImageComponent
                    {
                        Url    = itemurl2,
                        Sprite = "assets/content/textures/generic/fulltransparent.tga"
                    },
                    new CuiRectTransformComponent
                    {
                        AnchorMin = "0.7 0.55",
                        AnchorMax = "1 0.9"
                    }
                }
            });
            elements.Add(new CuiLabel
            {
                Text =
                {
                    Text     = leftginfo,
                    FontSize =        14,
                    Align    = TextAnchor.UpperLeft
                },
                RectTransform =
                {
                    AnchorMin = "0.05 0",
                    AnchorMax = "0.45 0.55"
                }
            }, "BackroundGUI");
            elements.Add(new CuiLabel
            {
                Text =
                {
                    Text     = rightginfo,
                    FontSize =         14,
                    Align    = TextAnchor.UpperRight
                },
                RectTransform =
                {
                    AnchorMin = "0.55 0",
                    AnchorMax = "0.95 0.55"
                }
            }, "BackroundGUI");
            var closeback = new CuiButton
            {
                Button =
                {
                    Close = "BackroundGUI",
                    Color = "255 0 0 1"
                },
                RectTransform =
                {
                    AnchorMin = "0.9 0.9",
                    AnchorMax = "1 1"
                },
                Text =
                {
                    Text     = "x",
                    FontSize =  22,
                    Align    = TextAnchor.MiddleCenter
                }
            };

            elements.Add(closeback, backround);
            CuiHelper.AddUi(player, elements);
        }
示例#15
0
        public static void ConfirmCancel(BasePlayer player, string message,
                                         string confirmMsg, string cancelMsg,
                                         Action confirmCode, Action cancelCode)
        {
            confirms[player.UserIDString] = new ConfirmCancelBlock
            {
                confirmMethod = confirmCode,
                cancelMethod  = cancelCode
            };

            string ARENA = $"{message}";

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

            guiList.Add(gui);

            CuiHelper.DestroyUi(player, gui);

            var elements = new CuiElementContainer();
            var mainName = elements.Add(new CuiPanel
            {
                Image =
                {
                    Color = "0.1 0.1 0.1 1"
                },
                RectTransform =
                {
                    AnchorMin = "0.3 0.3",
                    AnchorMax = "0.7 0.7"
                },
                CursorEnabled = true
            }, "Overlay", gui);
            var confirmButton = new CuiButton
            {
                Button =
                {
                    //Close = mainName,
                    Command = "iem.ui confirm_ok",
                    Color   = "0.1 0.8 0.1 0.2"
                },
                RectTransform =
                {
                    AnchorMin = "0.6 0.2",
                    AnchorMax = "0.85 0.4"
                },
                Text =
                {
                    Text     = confirmMsg,
                    FontSize =         22,
                    Align    = TextAnchor.MiddleCenter
                }
            };

            elements.Add(confirmButton, mainName);
            var cancelButton = new CuiButton
            {
                Button =
                {
                    //Close = mainName,
                    Command = "iem.ui confirm_cancel",
                    Color   = "0.8 0.1 0.1 0.2"
                },
                RectTransform =
                {
                    AnchorMin = "0.15 0.2",
                    AnchorMax = "0.40 0.4"
                },
                Text =
                {
                    Text     = cancelMsg,
                    FontSize =        22,
                    Align    = TextAnchor.MiddleCenter
                }
            };

            elements.Add(cancelButton, mainName);



            elements.Add(new CuiLabel
            {
                Text =
                {
                    Text     = message,
                    FontSize =      22,
                    Align    = TextAnchor.MiddleCenter
                },
                RectTransform =
                {
                    AnchorMin = "0.15 0.45",
                    AnchorMax = "0.85 0.95"
                }
            }, mainName);


            CuiHelper.AddUi(player, elements);
        }