Beispiel #1
0
            private void SendHuePicker()
            {
                GuiContainer c = new GuiContainer(PluginInstance, "HuePicker", nameof(ColorPicker));

                int    baseX        = 610;
                int    y            = 732;
                double width        = 700d / hueRes;
                int    height       = 30;
                double hueIncrement = 360d / hueRes;

                for (int i = 0; i < hueRes; i++)
                {
                    Rectangle pos   = new Rectangle(baseX + i * width, y, width, height, resX, resY, true);
                    GuiColor  color = new GuiColor(i * hueIncrement, 1, 1, 1);
                    int       hue   = (int)(i * hueIncrement);

                    int index = i;

                    Action <BasePlayer, string[]> callback = (p, a) =>
                    {
                        Hue = hue;
                        SendHueSelector(index);
                        SendVSPicker();
                    };

                    c.addPlainButton($"hue_{i}", pos, layer, color, fadeIn, fadeOut, callback: callback);
                }

                c.display(Player);

                SendHueSelector(0);
                SendVSPicker();
            }
Beispiel #2
0
        public void dropdown(Plugin plugin, BasePlayer player, List <string> options, Rectangle rectangle, GuiContainer.Layer layer, string parent, GuiColor panelColor, GuiColor textColor, Action <string> callback, bool allowNew = false, int page = 0, Predicate <string> predicate = null)
        {
            if (allowNew)
            {
                options.Add("(add new)");
            }
            int maxItems = 5;

            rectangle.H *= ((float)options.Count / (float)maxItems);
            List <List <string> > ListOfLists = SplitIntoChunks <string>(options, maxItems);
            GuiContainer          container   = new GuiContainer(plugin, "dropdown_API", parent);

            double cfX = rectangle.W / 300;
            double cfY = rectangle.H / 570;

            Action <BasePlayer, string[]> up = (bPlayer, input) =>
            {
                dropdown(plugin, player, options, rectangle, layer, parent, panelColor, textColor, callback, allowNew, page - 1, predicate);
            };
            Action <BasePlayer, string[]> down = (bPlayer, input) =>
            {
                dropdown(plugin, player, options, rectangle, layer, parent, panelColor, textColor, callback, allowNew, page + 1, predicate);
            };

            if (page > 0)
            {
                container.addPlainButton("dropdown_up", new Rectangle(0, 1, 298, 36, 300, 570, true), new GuiColor(1, 1, 1, 0.4f), 0, 0, new GuiText("<b>∧</b>", (int)Math.Floor(22 * cfY), new GuiColor("black")), up, parent: "dropdown_background");
            }
            if (page < ListOfLists.Count - 1)
            {
                container.addPlainButton("dropdown_up", new Rectangle(0, 533, 298, 37, 300, 570, true), new GuiColor(1, 1, 1, 0.4f), 0, 0, new GuiText("<b>∨</b>", (int)Math.Floor(22 * cfY), new GuiColor("black")), down, parent: "dropdown_background");
            }

            int count = 0;

            foreach (string option in ListOfLists[page])
            {
                int       hEach = (int)(rectangle.H / ListOfLists[page].Count);
                Rectangle pos   = new Rectangle(0, 0 + (count * hEach), rectangle.W, hEach, rectangle.W, rectangle.H, true).WithParent(rectangle);

                Action <BasePlayer, string[]> btnCallback = null;
                if (option == "(add new)")
                {
                    btnCallback = (bPlayer, input) => dropdownAddNew(plugin, player, pos, callback, predicate);
                }
                else
                {
                    string selected = option;
                    btnCallback = (bPlayer, input) =>
                    {
                        callback(selected);
                    };
                }
                container.addPlainButton($"dropdown_option_{option}", pos, layer, panelColor, 0, 0, new GuiText(option, color: textColor), btnCallback, blur: GuiContainer.Blur.strong);
                count++;
            }

            container.display(player);
        }
Beispiel #3
0
        public void sendBounty(BasePlayer player, Bounty bounty)
        {
#if DEBUG
            player.ChatMessage($"sendBounty: {bounty.placerName} -> {bounty.targetName}");
#endif
            closeBounty(player);
            GuiContainer c = new GuiContainer(this, "bountyPreview");

            //template
            Rectangle templatePos = new Rectangle(623, 26, 673, 854, resX, resY, true);
            c.addImage("template", templatePos, "bounty_template", GuiContainer.Layer.hud, FadeIn: FadeIn, FadeOut: FadeOut);

            //targetName
            Rectangle targetNamePos  = new Rectangle(680, 250, 560, 65, resX, resY, true);
            int       fontsize       = guiCreator.getFontsizeByFramesize(bounty.targetName.Length, targetNamePos);
            GuiText   targetNameText = new GuiText(bounty.targetName, fontsize);
            c.addText("targetName", targetNamePos, GuiContainer.Layer.hud, targetNameText, FadeIn, FadeOut);

            //image
            if (config.showSteamImage)
            {
                Rectangle imagePos = new Rectangle(828, 315, 264, 264, resX, resY, true);
                c.addImage("image", imagePos, bounty.targetID.ToString(), GuiContainer.Layer.hud, FadeIn: FadeIn, FadeOut: FadeOut);
            }

            //reward
            Rectangle rewardPos  = new Rectangle(680, 579, 560, 53, resX, resY, true);
            string    reward     = $"{bounty.rewardAmount} {bounty.reward.info.displayName.english}";
            GuiText   rewardText = new GuiText(reward, guiCreator.getFontsizeByFramesize(reward.Length, rewardPos));
            c.addText("reward", rewardPos, GuiContainer.Layer.hud, rewardText, FadeIn, FadeOut);

            //reason
            Rectangle reasonPos  = new Rectangle(680, 681, 560, 53, resX, resY, true);
            GuiText   reasonText = new GuiText(bounty.reason, 14);
            c.addText("reason", reasonPos, GuiContainer.Layer.hud, reasonText, FadeIn, FadeOut);

            //placerName
            Rectangle placerNamePos  = new Rectangle(680, 771, 560, 36, resX, resY, true);
            GuiText   placerNameText = new GuiText(bounty.placerName, guiCreator.getFontsizeByFramesize(bounty.placerName.Length, placerNamePos));
            c.addText("placerName", placerNamePos, GuiContainer.Layer.hud, placerNameText, FadeIn, FadeOut);

            //exitButton
            Rectangle closeButtonPos = new Rectangle(1296, 52, 60, 60, resX, resY, true);
            c.addButton("close", closeButtonPos, GuiContainer.Layer.hud, darkRed, FadeIn, FadeOut, new GuiText("X", 24, lightRed), blur: GuiContainer.Blur.medium);

            c.display(player);

            //button
            if (bounty.hunt != null)
            {
                huntButton(player, bounty, huntErrorType.huntActive);
            }
            else
            {
                huntButton(player, bounty);
            }
        }
Beispiel #4
0
        public void prompt(BasePlayer player, string header, string msg, Action <BasePlayer, string[]> Callback = null)
        {
            GuiContainer containerGUI = new GuiContainer(this, "prompt");

            containerGUI.addPlainButton("close", new Rectangle(), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0.3f), 0.1f, 0.1f, blur: GuiContainer.Blur.medium);
            containerGUI.addPlainPanel("background", new Rectangle(710, 390, 500, 300, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0.6f), 0.1f, 0.1f, GuiContainer.Blur.medium);
            containerGUI.addPanel("header", new Rectangle(710, 390, 500, 60, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0), 0.1f, 0.1f, new GuiText(header, 25, new GuiColor(1, 1, 1, 0.7f)));
            containerGUI.addPanel("msg", new Rectangle(735, 400, 450, 150, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0), 0.1f, 0.1f, new GuiText(msg, 14, new GuiColor(1, 1, 1, 0.7f)));
            containerGUI.addPlainButton("ok", new Rectangle(860, 520, 200, 50, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(0, 0, 1, 0.6f), 0.1f, 0.1f, new GuiText("OK", 20, new GuiColor(1, 1, 1, 0.7f)), Callback, "prompt");
            containerGUI.display(player);
        }
Beispiel #5
0
            private void SendPreview()
            {
                GuiContainer c = new GuiContainer(PluginInstance, "Preview", nameof(ColorPicker));

                Rectangle pos   = new Rectangle(1160, 368, 150, 150, resX, resY, true);
                GuiColor  color = new GuiColor(Hue, Saturation, Value, 1);

                c.addPlainPanel("panel", pos, layer, color, fadeIn, fadeOut);

                c.display(Player);
            }
Beispiel #6
0
        public void SmallConfirmPrompt(BasePlayer player, string header, Action <BasePlayer, string[]> yesCallback, Action <BasePlayer, string[]> noCallback)
        {
            GuiContainer containerGUI = new GuiContainer(this, "prompt");

            containerGUI.addPlainButton("close", new Rectangle(), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0.3f), 0.1f, 0.1f, callback: noCallback, blur: GuiContainer.Blur.medium);
            containerGUI.addPlainPanel("background", new Rectangle(710, 465, 500, 150, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0.6f), 0.1f, 0.1f, GuiContainer.Blur.medium);
            containerGUI.addPanel("header", new Rectangle(710, 465, 500, 60, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0), 0.1f, 0.1f, new GuiText(header, 25, new GuiColor(1, 1, 1, 0.7f)));
            containerGUI.addPlainButton("yes", new Rectangle(740, 545, 200, 50, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(0, 1, 0, 0.6f), 0.1f, 0.1f, new GuiText("YES", 20, new GuiColor(1, 1, 1, 0.7f)), yesCallback, "prompt");
            containerGUI.addPlainButton("no", new Rectangle(980, 545, 200, 50, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(1, 0, 0, 0.6f), 0.1f, 0.1f, new GuiText("NO", 20, new GuiColor(1, 1, 1, 0.7f)), noCallback, "prompt");
            containerGUI.display(player);
        }
Beispiel #7
0
        private void demoCommand(BasePlayer player, string command, string[] args)
        {
            if (!permission.UserHasPermission(player.UserIDString, "gui.demo"))
            {
                PrintToChat(player, lang.GetMessage("noPermission", this, player.UserIDString));
                return;
            }
            if (args.Length == 0)
            {
                GuiContainer container = new GuiContainer(this, "demo");
                container.addPanel("demo_panel", new Rectangle(0.25f, 0.5f, 0.25f, 0.25f), GuiContainer.Layer.hud, new GuiColor(0, 1, 0, 1), 1, 1, new GuiText("This is a regular panel", 30));
                container.addPanel("demo_img", new Rectangle(0.25f, 0.25f, 0.25f, 0.25f), FadeIn: 1, FadeOut: 1, text: new GuiText("this is an image with writing on it", 30, color: new GuiColor(1, 1, 1, 1)), imgName: "flower");
                Action <BasePlayer, string[]> heal = (bPlayer, input) => { bPlayer.Heal(10); };
                container.addButton("demo_healButton", new Rectangle(0.5f, 0.5f, 0.25f, 0.25f), GuiContainer.Layer.hud, null, 1, 1, new GuiText("heal me", 40), heal, null, false, "flower");
                Action <BasePlayer, string[]> hurt = (bPlayer, input) => { bPlayer.Hurt(10); };
                container.addButton("demo_hurtButton", new Rectangle(0.5f, 0.25f, 0.25f, 0.25f), new GuiColor(1, 0, 0, 0.5f), 1, 1, new GuiText("hurt me", 40), hurt);
                container.addText("demo_inputLabel", new Rectangle(0.375f, 0.85f, 0.25f, 0.1f), new GuiText("Print to chat:", 30, null, TextAnchor.LowerCenter), 1, 1);
                Action <BasePlayer, string[]> inputCallback = (bPlayer, input) => { PrintToChat(bPlayer, string.Concat(input)); };
                container.addInput("demo_input", new Rectangle(0.375f, 0.75f, 0.25f, 0.1f), inputCallback, GuiContainer.Layer.hud, null, new GuiColor("white"), 100, new GuiText("", 50), 1, 1);
                container.addButton("close", new Rectangle(0.1f, 0.1f, 0.1f, 0.1f), new GuiColor("red"), 1, 0, new GuiText("close", 50));
                container.display(player);

                GuiContainer container2 = new GuiContainer(this, "demo_child", "demo");
                container2.addPanel("layer1", new Rectangle(1400, 800, 300, 100, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor("red"), 1, 1, new GuiText("overall", align: TextAnchor.LowerLeft));
                container2.addPanel("layers_label", new Rectangle(1400, 800, 300, 100, 1920, 1080, true), GuiContainer.Layer.overall, null, 1, 1, new GuiText("Available layers:", 20, align: TextAnchor.UpperLeft));
                container2.addPanel("layer2", new Rectangle(1425, 825, 300, 100, 1920, 1080, true), GuiContainer.Layer.overlay, new GuiColor("yellow"), 1, 1, new GuiText("overlay", align: TextAnchor.LowerLeft));
                container2.addPanel("layer3", new Rectangle(1450, 850, 300, 100, 1920, 1080, true), GuiContainer.Layer.menu, new GuiColor("green"), 1, 1, new GuiText("menu", align: TextAnchor.LowerLeft));
                container2.addPanel("layer4", new Rectangle(1475, 875, 300, 100, 1920, 1080, true), GuiContainer.Layer.hud, new GuiColor("blue"), 1, 1, new GuiText("hud", align: TextAnchor.LowerLeft));
                container2.addPanel("layer5", new Rectangle(1500, 900, 300, 100, 1920, 1080, true), GuiContainer.Layer.under, new GuiColor("purple"), 1, 1, new GuiText("under", align: TextAnchor.LowerLeft));
                container2.display(player);

                GuiContainer container3 = new GuiContainer(this, "demo_anchors", "demo");
                container3.addPlainPanel("bl", new Rectangle(20, 960, 100, 100, 1920, 1080, true, Rectangle.Anchors.BottomLeft), GuiContainer.Layer.menu, new GuiColor("white"), 1, 1);
                container3.addPlainPanel("cl", new Rectangle(20, 490, 100, 100, 1920, 1080, true, Rectangle.Anchors.CenterLeft), GuiContainer.Layer.menu, new GuiColor("white"), 1, 1);
                container3.addPlainPanel("ul", new Rectangle(20, 20, 100, 100, 1920, 1080, true, Rectangle.Anchors.UpperLeft), GuiContainer.Layer.menu, new GuiColor("white"), 1, 1);
                container3.addPlainPanel("uc", new Rectangle(910, 20, 100, 100, 1920, 1080, true, Rectangle.Anchors.UpperCenter), GuiContainer.Layer.menu, new GuiColor("white"), 1, 1);
                container3.addPlainPanel("ur", new Rectangle(1800, 20, 100, 100, 1920, 1080, true, Rectangle.Anchors.UpperRight), GuiContainer.Layer.menu, new GuiColor("white"), 1, 1);
                container3.addPlainPanel("cr", new Rectangle(1800, 490, 100, 100, 1920, 1080, true, Rectangle.Anchors.CenterRight), GuiContainer.Layer.menu, new GuiColor("white"), 1, 1);
                container3.addPlainPanel("br", new Rectangle(1800, 960, 100, 100, 1920, 1080, true, Rectangle.Anchors.BottomRight), GuiContainer.Layer.menu, new GuiColor("white"), 1, 1);
                container3.addPlainPanel("bc", new Rectangle(910, 960, 100, 100, 1920, 1080, true, Rectangle.Anchors.BottomCenter), GuiContainer.Layer.menu, new GuiColor("white"), 1, 1);
                container3.display(player);

                customGameTip(player, "This is a custom gametip!", 5);
                return;
            }
            else if (args.Length >= 3)
            {
                if (args[0] == "gametip")
                {
                    customGameTip(player, args[2], 3f, (gametipType)Enum.Parse(typeof(gametipType), args[1]));
                }
            }
        }
Beispiel #8
0
        public void sendTargetIndicator(BasePlayer player, Hunt hunt)
        {
            if (!config.showTargetIndicator)
            {
                return;
            }
#if DEBUG
            player.ChatMessage($"sendTargetIndicator: {hunt.hunterName} -> {hunt.bounty.targetName}");
#endif
            if (player == null)
            {
                return;
            }
            if (player.IsSleeping())
            {
                return;
            }
            GuiContainer c = new GuiContainer(this, "targetIndicator");

            //Background
            Rectangle bgPos    = new Rectangle(50, 250, 350, 100, resX, resY, true);
            float     distance = config.safeDistance;
            if (hunt.hunter?.transform != null && hunt.target?.transform != null)
            {
                distance = Vector3.Distance(hunt.hunter.transform.position, hunt.target.transform.position);
            }
            GuiColor bgColor = config.showDistance?gradientRedYellowGreen(Mathf.Clamp((distance / config.safeDistance), 0, 1)):lightGrey;
            bgColor.setAlpha(0.5f);
            c.addPlainPanel("Background", bgPos, GuiContainer.Layer.hud, bgColor, 0, 0, GuiContainer.Blur.medium);

            //TopLine
            Rectangle topLinePos      = new Rectangle(50, 250, 350, 50, resX, resY, true);
            string    TopLineString   = $"You are being hunted{(config.showHunter?$" by {hunt.hunterName}":"")}!";
            int       topLineFontsize = guiCreator.getFontsizeByFramesize(TopLineString.Length, topLinePos);
            GuiText   topLineText     = new GuiText(TopLineString, topLineFontsize, opaqueWhite);
            c.addText("topline", topLinePos, GuiContainer.Layer.hud, topLineText);

            //BottomLine
            Rectangle bottomLinePos      = new Rectangle(50, 300, 350, 20, resX, resY, true);
            string    bottomLineString   = "You can run, but you can't hide!";
            int       bottomLineFontsize = guiCreator.getFontsizeByFramesize(bottomLineString.Length, bottomLinePos);
            GuiText   bottomLineText     = new GuiText(bottomLineString, bottomLineFontsize, opaqueWhite);
            c.addText("bottomLine", bottomLinePos, GuiContainer.Layer.hud, bottomLineText);

            //Countdown
            Rectangle CountdownPos      = new Rectangle(50, 320, 350, 30, resX, resY, true);
            string    CountdownString   = hunt.remaining.ToString(@"hh\:mm\:ss");
            int       CountdownFontsize = guiCreator.getFontsizeByFramesize(CountdownString.Length, CountdownPos);
            GuiText   CountdownText     = new GuiText(CountdownString, CountdownFontsize, opaqueWhite);
            c.addText("Countdown", CountdownPos, GuiContainer.Layer.hud, CountdownText);

            c.display(player);
        }
Beispiel #9
0
        public void creatorButton(BasePlayer player, createErrorType error = createErrorType.none, BountyBP bp = null)
        {
            GuiContainer c         = new GuiContainer(this, "createButton", "bountyCreator");
            Rectangle    ButtonPos = new Rectangle(710, 856, 500, 100, resX, resY, true);

            List <GuiText> textOptions = new List <GuiText>
            {
                new GuiText("Create Bounty", guiCreator.getFontsizeByFramesize(13, ButtonPos), lightGreen),
                new GuiText("Target not found!", guiCreator.getFontsizeByFramesize(17, ButtonPos), lightRed),
                new GuiText("Invalid reward!", guiCreator.getFontsizeByFramesize(15, ButtonPos), lightRed),
                new GuiText("Can't afford reward!", guiCreator.getFontsizeByFramesize(20, ButtonPos), lightRed),
                new GuiText("Reason missing!", guiCreator.getFontsizeByFramesize(15, ButtonPos), lightRed)
            };

            Action <BasePlayer, string[]> cb = (p, a) =>
            {
                if (bp.target == null)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    creatorButton(player, createErrorType.missingTarget, bp);
                }
                else if (bp.reward == 0)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    creatorButton(player, createErrorType.badReward, bp);
                }
                else if (config.requireReason && string.IsNullOrEmpty(bp.reason))
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    creatorButton(player, createErrorType.missingReason, bp);
                }
                else
                {
                    Effect.server.Run(successSound, player.transform.position);
                    bp.init(player);
                    GuiTracker.getGuiTracker(player).destroyGui(this, "bountyCreator");
                }
            };

            c.addPlainButton("button", ButtonPos, GuiContainer.Layer.hud, (error == createErrorType.none) ? darkGreen : darkRed, FadeIn, FadeOut, textOptions[(int)error], cb, blur: GuiContainer.Blur.medium);
            c.display(player);

            if (error != createErrorType.none)
            {
                PluginInstance.timer.Once(2f, () =>
                {
                    if (GuiTracker.getGuiTracker(player).getContainer(this, "bountyCreator") != null)
                    {
                        creatorButton(player, bp: bp);
                    }
                });
            }
        }
Beispiel #10
0
        private void imgrawPreviewCommand(BasePlayer player, string command, string[] args)
        {
            if (!permission.UserHasPermission(player.UserIDString, "gui.demo"))
            {
                PrintToChat(player, lang.GetMessage("noPermission", this, player.UserIDString));
                return;
            }
            GuiContainer container = new GuiContainer(this, "imgPreview");

            container.addRawImage("img", new Rectangle(710, 290, 500, 500, 1920, 1080, true), args[0], GUICreator.GuiContainer.Layer.hud);
            container.addPlainButton("close", new Rectangle(0.15f, 0.15f, 0.1f, 0.1f), new GuiColor(1, 0, 0, 0.8f), 0, 0, new GuiText("close"));
            container.display(player);
        }
Beispiel #11
0
            private void SendSVSelector(int s, int v)
            {
                GuiContainer c = new GuiContainer(PluginInstance, "SVSelector", "SVPicker");

                int    baseX  = 595;
                int    baseY  = 315;
                double width  = 525d / (satRes + 1);
                double height = 375d / (valueRes + 1);

                Rectangle pos   = new Rectangle(baseX + s * width, baseY + v * height, 75, 75, resX, resY, true);
                GuiColor  color = new GuiColor(Hue, Saturation, Value, 1);

                c.addImage("selected", pos, "circle", layer, color, fadeIn, fadeOut);

                c.display(Player);
            }
Beispiel #12
0
            private void SendHueSelector(int i)
            {
                GuiContainer c = new GuiContainer(PluginInstance, "HueSelector", "HuePicker");

                int    baseX        = 603;
                int    y            = 722;
                double width        = 700d / hueRes;
                double hueIncrement = 360d / hueRes;

                Rectangle pos   = new Rectangle(baseX + i * width, y, 50, 50, resX, resY, true);
                GuiColor  color = new GuiColor(i * hueIncrement, 1, 1, 1);

                c.addImage("selected", pos, "circle", layer, color, fadeIn, fadeOut);

                c.display(Player);
            }
Beispiel #13
0
        private void SendEntry(BasePlayer player, KeyValuePair <BasePlayer, PlayerSummary> kvp, int count, int sizeEach, int gap, Action <BasePlayer> callback)
        {
            if (GuiTracker.getGuiTracker(player).getContainer(PluginInstance, "PlayerSearch") == null)
            {
                return;
            }

            GuiColor black60 = new GuiColor(0, 0, 0, 0.6f);
            GuiColor black40 = new GuiColor(0, 0, 0, 0.4f);
            GuiColor white70 = new GuiColor(1, 1, 1, 0.7f);

            GuiContainer c = new GuiContainer(PluginInstance, $"{count}ImageContainer", "PlayerSearch");

            //background
            Rectangle entryBgPos = new Rectangle(715, 360 + count * (sizeEach + gap), 490, 80, 1920, 1080, true);

            c.addPlainPanel($"{count}EntryBG", entryBgPos, GuiContainer.Layer.overall, black60, 0.2f, 0);

            //ID
            Rectangle idPos  = new Rectangle(795, 365 + count * (sizeEach + gap), 405, 35, 1920, 1080, true);
            GuiText   idText = new GuiText($"[{kvp.Key.userID}]", 14, white70);

            c.addText($"{count}id", idPos, GuiContainer.Layer.overall, idText, 0.2f, 0);

            //Name
            Rectangle namePos  = new Rectangle(795, 400 + count * (sizeEach + gap), 405, 35, 1920, 1080, true);
            GuiText   nameText = new GuiText($"{kvp.Key.displayName}", getFontsizeByFramesize(kvp.Key.displayName.Length, namePos), white70);

            c.addText($"{count}name", namePos, GuiContainer.Layer.overall, nameText, 0.2f, 0);

            //button
            Action <BasePlayer, string[]> buttonCb = (p2, a) =>
            {
                GuiTracker.getGuiTracker(player).destroyGui(PluginInstance, "PlayerSearch");
                callback(kvp.Key);
            };

            c.addPlainButton($"{count}btnOverlay", entryBgPos, GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0), 0.2f, 0, callback: buttonCb, CursorEnabled: true);

            Rectangle imgPos = new Rectangle(720, 365 + count * (sizeEach + gap), 70, 70, 1920, 1080, true);

            c.addButton($"{count}Image", imgPos, GuiContainer.Layer.overall, null, 0.2f, 0, callback: buttonCb, close: "PlayerSearch", imgName: kvp.Key.UserIDString);

            c.display(player);
        }
Beispiel #14
0
            private void SendButton()
            {
                GuiContainer c = new GuiContainer(PluginInstance, "Ok", nameof(ColorPicker));

                Rectangle pos   = new Rectangle(1160, 540, 150, 60, resX, resY, true);
                GuiColor  color = new GuiColor(0, 1, 0, 0.5f);
                GuiText   text  = new GuiText("OK", 30, GuiColor.White.withAlpha(0.7f));

                Action <BasePlayer, string[]> callback = (p, a) =>
                {
                    Callback?.Invoke(new GuiColor(Hue, Value, Saturation, 1));
                    GuiTracker.getGuiTracker(Player).destroyGui(PluginInstance, nameof(ColorPicker));
                };

                c.addPlainButton("button", pos, layer, color, fadeIn, fadeOut, text, callback);

                c.display(Player);
            }
Beispiel #15
0
        public void Tickbox(BasePlayer player, Plugin plugin, Rectangle parentRectangle, GuiContainer.Layer layer, string name, string parentContainer, Action <BasePlayer, string[]> onTick, Action <BasePlayer, string[]> onUntick, bool initialState = false, bool disabled = false, float fadeIn = 0, float fadeOut = 0)
        {
            GuiContainer c         = new GuiContainer(plugin, name + "_APITickbox", parentContainer);
            GuiColor     lightGrey = new GuiColor(0.5f, 0.5f, 0.5f, 1);
            GuiColor     darkGrey  = new GuiColor(0.8f, 0.8f, 0.8f, 1);

            if (initialState)
            {
                Rectangle fgPos = new Rectangle(0.15f, 0.15f, 0.72f, 0.72f, 1f, 1f, true).WithParent(parentRectangle);
                c.addPlainButton("bg", parentRectangle, layer, disabled ? lightGrey : GuiColor.White, fadeIn, fadeOut, callback: disabled ? null : onUntick);
                c.addPlainButton("fg", fgPos, layer, disabled ? darkGrey : GuiColor.Black, fadeIn, fadeOut, callback: disabled ? null : onUntick);
            }
            else
            {
                c.addPlainButton("bg", parentRectangle, layer, disabled ? lightGrey : GuiColor.White, fadeIn, fadeOut, callback: disabled ? null : onTick);
            }

            c.display(player);
        }
Beispiel #16
0
        public void sendHunterIndicator(BasePlayer player, Hunt hunt)
        {
#if DEBUG
            player.ChatMessage($"sendHunterIndicator: {hunt.hunterName} -> {hunt.bounty.targetName}");
#endif
            if (player == null)
            {
                return;
            }
            if (player.IsSleeping())
            {
                return;
            }
            GuiContainer c = new GuiContainer(this, "hunterIndicator");

            //Background
            Rectangle bgPos = new Rectangle(50, 100, 350, 150, resX, resY, true);
            c.addPlainPanel("bg", bgPos, GuiContainer.Layer.hud, lightGrey, 0, 0, GuiContainer.Blur.medium);

            //Name
            Rectangle namePos        = new Rectangle(50, 100, 350, 35, resX, resY, true);
            string    nameTextString = $"You are hunting {hunt.bounty.targetName}";
            int       fontsize       = guiCreator.getFontsizeByFramesize(nameTextString.Length, namePos);
            GuiText   nameText       = new GuiText(nameTextString, fontsize, opaqueWhite);
            c.addText("name", namePos, GuiContainer.Layer.hud, nameText);

            //Last Seen
            if (config.showLastSeen)
            {
                Rectangle lastSeenPos    = new Rectangle(50, 135, 350, 80, resX, resY, true);
                string    lastSeenString = hunt.lastSeen();
                GuiText   lastSeenText   = new GuiText(lastSeenString, 10, opaqueWhite);
                c.addText("lastSeen", lastSeenPos, GuiContainer.Layer.hud, lastSeenText);
            }

            //Countdown
            Rectangle countdownPos  = new Rectangle(50, 215, 350, 35, resX, resY, true);
            GuiText   countdownText = new GuiText(hunt.remaining.ToString(@"hh\:mm\:ss"), 20, opaqueWhite);
            c.addText("countdown", countdownPos, GuiContainer.Layer.hud, countdownText);

            c.display(player);
        }
Beispiel #17
0
        public void imgPreview(BasePlayer player, string url)
        {
            Action callback = () =>
            {
                Rectangle    rectangle = new Rectangle(710, 290, 500, 500, 1920, 1080, true);
                GuiContainer container = new GuiContainer(PluginInstance, $"imgPreview");
                container.addRawImage($"img", rectangle, ImageLibrary.Call <string>("GetImage", $"GUICreator_preview_{url}"), "Hud");
                container.addPlainButton("close", new Rectangle(0.15f, 0.15f, 0.1f, 0.1f), new GuiColor(1, 0, 0, 0.8f), 0, 0, new GuiText("close"));
                container.display(player);
            };

            if (ImageLibrary.Call <bool>("HasImage", $"GUICreator_preview_{url}", (ulong)0))
            {
                callback();
            }
            else
            {
                ImageLibrary.Call <bool>("AddImage", url, $"GUICreator_preview_{url}", (ulong)0, callback);
            }
        }
Beispiel #18
0
            private void SendBackgound()
            {
                GuiContainer c = new GuiContainer(PluginInstance, nameof(ColorPicker));

                //clickout
                c.addPlainButton("close", new Rectangle(), layer, GuiColor.Transparent);

                //Panel
                Rectangle panelPos   = new Rectangle(560, 265, 800, 550, resX, resY, true);
                GuiColor  panelColor = new GuiColor(0, 0, 0, 0.5f);

                c.addPlainPanel("bgPanel", panelPos, layer, panelColor, fadeIn, fadeOut, GuiContainer.Blur.medium);

                //Label
                Rectangle labelPos  = new Rectangle(560, 265, 800, 60, resX, resY, true);
                GuiText   labelText = new GuiText(header, 30, GuiColor.White.withAlpha(0.7f));

                c.addText("bgLabel", labelPos, layer, labelText, fadeIn, fadeOut);

                c.display(Player);
            }
Beispiel #19
0
        public void SubmitPrompt(BasePlayer player, string header, Action <BasePlayer, string> inputCallback)
        {
            GuiContainer containerGUI = new GuiContainer(this, "prompt");

            containerGUI.addPlainButton("close", new Rectangle(), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0.3f), 0.1f, 0.1f, blur: GuiContainer.Blur.medium);
            containerGUI.addPlainPanel("background", new Rectangle(710, 425, 500, 230, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0.6f), 0.1f, 0.1f, GuiContainer.Blur.medium);
            containerGUI.addPanel("header", new Rectangle(710, 435, 500, 60, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0), 0.1f, 0.1f, new GuiText(header, 25, new GuiColor(1, 1, 1, 0.7f)));
            Submission submission = new Submission();
            Action <BasePlayer, string[]> inputFieldCallback = (p, a) =>
            {
                submission.Input = string.Join(" ", a);
            };

            containerGUI.addInput("input", new Rectangle(735, 505, 450, 60, 1920, 1080, true), inputFieldCallback, GuiContainer.Layer.overall, null, new GuiColor(1, 1, 1, 1), 100, new GuiText("", 14, new GuiColor(0, 0, 0, 1)), 0.1f, 0.1f);
            Action <BasePlayer, string[]> cb = (p, a) =>
            {
                inputCallback(p, submission.Input);
            };

            containerGUI.addPlainButton("submit", new Rectangle(860, 583, 200, 50, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(1, 0, 0, 0.6f), 0.1f, 0.1f, new GuiText("SUBMIT", 20, new GuiColor(1, 1, 1, 0.7f)), cb, "prompt");
            containerGUI.display(player);
        }
Beispiel #20
0
            private void SendVSPicker()
            {
                GuiContainer c = new GuiContainer(PluginInstance, "SVPicker", nameof(ColorPicker));

                int    baseX        = 610;
                int    baseY        = 330;
                double width        = 525d / (satRes + 1);
                double height       = 375d / (valueRes + 1);
                double satIncrement = 1d / satRes;
                double valIncrement = 1d / valueRes;

                for (int v = 0; v <= valueRes; v++)
                {
                    for (int s = 0; s <= satRes; s++)
                    {
                        double    saturation = s * satIncrement;
                        double    value      = (valueRes - v) * valIncrement;
                        Rectangle pos        = new Rectangle(baseX + s * width, baseY + v * height, width, height, resX, resY, true);
                        GuiColor  color      = new GuiColor(Hue, saturation, value, 1);

                        int si = s;
                        int vi = v;

                        Action <BasePlayer, string[]> callback = (p, a) =>
                        {
                            Saturation = saturation;
                            Value      = value;
                            SendSVSelector(si, vi);
                            SendPreview();
                        };

                        c.addPlainButton($"sv_{s}_{v}", pos, layer, color, fadeIn, fadeOut, callback: callback);
                    }
                }

                c.display(Player);

                SendPreview();
            }
Beispiel #21
0
        public void customGameTip(BasePlayer player, string text, float duration = 0, gametipType type = gametipType.gametip)
        {
            GuiTracker.getGuiTracker(player).destroyGui(this, "gameTip");

            GuiContainer container = new GuiContainer(this, "gameTip");

            switch (type)
            {
            case gametipType.gametip:
                //container.addImage("gametip", new Rectangle(375, 844, 1170, 58, 1920, 1080, true), "bgTex", GuiContainer.Layer.overall, new GuiColor("#25639BF0"), 0.5f, 1);
                container.addPlainPanel("gametip", new Rectangle(375, 844, 1170, 58, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor("#25639BF4"), 0.5f, 1, GuiContainer.Blur.greyout);
                container.addText("gametip_txt", new Rectangle(433, 844, 1112, 58, 1920, 1080, true), GuiContainer.Layer.overall, new GuiText(text, 20, new GuiColor("#FFFFFFD9")), 0.5f, 1);
                container.addImage("gametip_icon", new Rectangle(375, 844, 58, 58, 1920, 1080, true), "gameTipIcon", GuiContainer.Layer.overall, new GuiColor("#FFFFFFD9"), 0.5f, 1);
                break;

            case gametipType.warning:
                container.addPlainPanel("gametip", new Rectangle(375, 844, 1170, 58, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor("#DED502F0"), 0.5f, 1);
                container.addText("gametip_txt", new Rectangle(433, 844, 1112, 58, 1920, 1080, true), GuiContainer.Layer.overall, new GuiText(text, 20, new GuiColor("#000000D9")), 0.5f, 1);
                container.addImage("gametip_icon", new Rectangle(375, 844, 58, 58, 1920, 1080, true), "warning_alpha", GuiContainer.Layer.overall, new GuiColor("#FFFFFFD9"), 0.5f, 1);
                break;

            case gametipType.error:
                //container.addImage("gametip", new Rectangle(375, 844, 1170, 58, 1920, 1080, true), "bgTex", GuiContainer.Layer.overall, new GuiColor("#BB0000F0"), 0.5f, 1);
                container.addPlainPanel("gametip", new Rectangle(375, 844, 1170, 58, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor("#BB0000F0"), 0.5f, 1, GuiContainer.Blur.greyout);
                container.addText("gametip_txt", new Rectangle(433, 844, 1112, 58, 1920, 1080, true), GuiContainer.Layer.overall, new GuiText(text, 20, new GuiColor("#FFFFFFD9")), 0.5f, 1);
                container.addImage("gametip_icon", new Rectangle(375, 844, 58, 58, 1920, 1080, true), "white_cross", GuiContainer.Layer.overall, new GuiColor("#FFFFFFD9"), 0.5f, 1);
                break;
            }

            if (duration != 0)
            {
                Timer closeTimer = timer.Once(duration, () =>
                {
                    GuiTracker.getGuiTracker(player).destroyGui(this, container);
                });
                container.timers.Add(closeTimer);
            }
            container.display(player);
        }
Beispiel #22
0
        private void dropdownAddNew(Plugin plugin, BasePlayer player, Rectangle rectangle, Action <string> callback, Predicate <string> predicate)
        {
            GuiContainer container = new GuiContainer(this, "dropdown_addNew", "dropdown_API");
            Action <BasePlayer, string[]> inputCallback = (bPlayer, input) =>
            {
                if (input.Length == 0)
                {
                    return;
                }
                GuiTracker.getGuiTracker(player).destroyGui(PluginInstance, "dropdown_addNew");
                StringBuilder newName = new StringBuilder();
                int           i       = 1;
                foreach (string s in input)
                {
                    newName.Append(s);
                    if (i != input.Length)
                    {
                        newName.Append(" ");
                    }
                    i++;
                }

                if (predicate != null)
                {
                    if (!predicate(newName.ToString()))
                    {
                        prompt(player, "Your input is invalid!", "INVALID INPUT");
                        dropdownAddNew(plugin, player, rectangle, callback, predicate);
                        return;
                    }
                }
                callback(newName.ToString());
                GuiTracker.getGuiTracker(player).destroyGui(PluginInstance, container);
            };

            container.addInput("dropdown_addNew_input", rectangle, inputCallback, GuiContainer.Layer.menu, null, new GuiColor("white"), 15, new GuiText("", color: new GuiColor("black")), 0, 0);
            container.display(player);
        }
Beispiel #23
0
        public void sendCreator(BasePlayer player)
        {
#if DEBUG
            player.ChatMessage($"sendCreator");
#endif
            BountyBP     bp = new BountyBP();
            GuiContainer c  = new GuiContainer(this, "bountyCreator");

            //template
            Rectangle templatePos = new Rectangle(623, 26, 673, 854, resX, resY, true);
            c.addImage("template", templatePos, "bounty_template", GuiContainer.Layer.hud, FadeIn: FadeIn, FadeOut: FadeOut);

            //targetName
            Rectangle targetNamePos      = new Rectangle(680, 250, 100, 53, resX, resY, true);
            Rectangle targetNamePosInput = new Rectangle(780, 250, 460, 53, resX, resY, true);
            c.addText("targetNameHeader", targetNamePos, GuiContainer.Layer.hud, new GuiText("Target:", 20), FadeIn, FadeOut);
            Action <BasePlayer, string[]> targetNameCB = (p, a) =>
            {
                if (a.Length < 1)
                {
                    return;
                }
                BasePlayer target = findPlayer(a[0], player);
                if (target == null)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    creatorButton(player, createErrorType.missingTarget, bp);
                    return;
                }
                bp.target = target;
                GuiTracker.getGuiTracker(player).destroyGui(this, c, "targetName");
                int          fontsize       = guiCreator.getFontsizeByFramesize(target.displayName.Length, targetNamePosInput);
                GuiText      targetNameText = new GuiText(target.displayName, fontsize);
                GuiContainer c2             = new GuiContainer(this, "tfound", "bountyCreator");
                c2.addText("targetName", targetNamePosInput, GuiContainer.Layer.hud, targetNameText, FadeIn, FadeOut);
                c2.display(player);
                Effect.server.Run(successSound, player.transform.position);

                //image
                if (config.showSteamImage)
                {
                    GetSteamUserData(target.userID, (ps) =>
                    {
                        guiCreator.registerImage(this, target.userID.ToString(), ps.avatarfull, () =>
                        {
                            Rectangle imagePos = new Rectangle(828, 315, 264, 264, resX, resY, true);
                            GuiContainer c3    = new GuiContainer(this, "image", "bountyCreator");
                            c3.addImage("image", imagePos, target.userID.ToString(), GuiContainer.Layer.hud, FadeIn: FadeIn, FadeOut: FadeOut);
                            c3.display(player);
                            player.ChatMessage("sent image");
                        });
                    });
                }
            };
            c.addInput("targetName", targetNamePosInput, targetNameCB, GuiContainer.Layer.hud, panelColor: new GuiColor("white"), text: new GuiText("", 20, new GuiColor("black")), FadeOut: FadeOut, FadeIn: FadeIn);

            //reward
            ItemDefinition itemDefinition          = ItemManager.FindItemDefinition(config.currency);
            Rectangle      rewardPosInput          = new Rectangle(828, 579, 132, 53, resX, resY, true);
            Rectangle      rewardPosCurrency       = new Rectangle(970, 579, 122, 53, resX, resY, true);
            Action <BasePlayer, string[]> rewardCB = (p, a) =>
            {
                if (a.Length < 1)
                {
                    return;
                }
                int reward = 0;
                if (!int.TryParse(a[0], out reward))
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    creatorButton(player, createErrorType.badReward, bp);
                    return;
                }
                if (reward < config.minReward)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    creatorButton(player, createErrorType.badReward, bp);
                    return;
                }
                if (player.inventory.GetAmount(itemDefinition.itemid) < reward)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    creatorButton(player, createErrorType.cantAfford, bp);
                    return;
                }
                bp.reward = reward;
                GuiTracker.getGuiTracker(player).destroyGui(this, c, "reward");
                GuiContainer c2 = new GuiContainer(this, "rewardok", "bountyCreator");
                c2.addText("reward", rewardPosInput, GuiContainer.Layer.hud, new GuiText(reward.ToString(), 24, align: TextAnchor.MiddleRight), FadeIn, FadeOut);
                c2.display(player);
                Effect.server.Run(successSound, player.transform.position);
            };
            c.addInput("reward", rewardPosInput, rewardCB, GuiContainer.Layer.hud, panelColor: new GuiColor("white"), text: new GuiText("", 22, new GuiColor("black")), FadeOut: FadeOut, FadeIn: FadeIn);
            c.addText("rewardCurrency", rewardPosCurrency, GuiContainer.Layer.hud, new GuiText(itemDefinition.displayName.english, 24, new GuiColor("black"), TextAnchor.MiddleLeft), FadeIn, FadeOut);

            //reason
            Rectangle reasonPos      = new Rectangle(680, 681, 100, 53, resX, resY, true);
            Rectangle reasonPosInput = new Rectangle(780, 681, 460, 53, resX, resY, true);
            c.addText("reasonHeader", reasonPos, GuiContainer.Layer.hud, new GuiText("Reason:", 20), FadeIn, FadeOut);
            Action <BasePlayer, string[]> reasonCB = (p, a) =>
            {
                if (a.Length < 1)
                {
                    return;
                }
                StringBuilder sb = new StringBuilder();
                foreach (string s in a)
                {
                    sb.Append($"{s} ");
                }
                bp.reason = sb.ToString().Trim();
            };
            c.addInput("reason", reasonPosInput, reasonCB, GuiContainer.Layer.hud, panelColor: new GuiColor("white"), text: new GuiText("", 14, new GuiColor("black")), FadeOut: FadeOut, FadeIn: FadeIn);

            //placerName
            Rectangle placerNamePos  = new Rectangle(680, 771, 560, 36, resX, resY, true);
            GuiText   placerNameText = new GuiText(player.displayName, guiCreator.getFontsizeByFramesize(player.displayName.Length, placerNamePos));
            c.addText("placerName", placerNamePos, GuiContainer.Layer.hud, placerNameText, FadeIn, FadeOut);

            //exitButton
            Rectangle closeButtonPos = new Rectangle(1296, 52, 60, 60, resX, resY, true);
            c.addButton("close", closeButtonPos, GuiContainer.Layer.hud, darkRed, FadeIn, FadeOut, new GuiText("X", 24, lightRed), blur: GuiContainer.Blur.medium);

            c.display(player);

            //button
            creatorButton(player, bp: bp);
        }
Beispiel #24
0
        public void huntButton(BasePlayer player, Bounty bounty, huntErrorType error = huntErrorType.none)
        {
            GuiContainer c         = new GuiContainer(this, "huntButton", "bountyPreview");
            Rectangle    ButtonPos = new Rectangle(710, 856, 500, 100, resX, resY, true);

            List <GuiText> textOptions = new List <GuiText>
            {
                new GuiText("Start Hunting", guiCreator.getFontsizeByFramesize(13, ButtonPos), lightGreen),
                new GuiText("You are already hunting", guiCreator.getFontsizeByFramesize(23, ButtonPos), lightRed),
                new GuiText("Target is already being hunted", guiCreator.getFontsizeByFramesize(30, ButtonPos), lightRed),
                new GuiText("Target can't be hunted yet", guiCreator.getFontsizeByFramesize(26, ButtonPos), lightRed),
                new GuiText("Hunt Active", guiCreator.getFontsizeByFramesize(11, ButtonPos), lightRed),
                new GuiText("You can't hunt yourself!", guiCreator.getFontsizeByFramesize(24, ButtonPos), lightRed),
                new GuiText("Target is offline", guiCreator.getFontsizeByFramesize(17, ButtonPos), lightRed),
                new GuiText("Too close to the target!", guiCreator.getFontsizeByFramesize(24, ButtonPos), lightRed),
            };

            Action <BasePlayer, string[]> cb = (p, a) =>
            {
                TimeSpan targetCooldown   = TimeSpan.Zero;
                TimeSpan creationCooldown = new TimeSpan(0, 0, config.creationCooldown - (int)bounty.timeSinceCreation.TotalSeconds);
                if (error == huntErrorType.huntActive)
                {
                    return;
                }
                else if (bounty.target == null)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.offline);
                }
                else if (bounty.target.IsSleeping())
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.offline);
                }
                else if (bounty.hunt != null || HuntData.getHuntByHunter(p) != null)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.hunterAlreadyHunting);
                }
                else if (HuntData.getHuntByTarget(bounty.target) != null)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.targetAlreadyHunted);
                }
                else if ((bounty.timeSinceCreation.TotalSeconds < config.creationCooldown || CooldownData.isOnCooldown(bounty.target, out targetCooldown)) && !hasPermission(player, permissions.admin))
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.targetCooldown);
                    TimeSpan select = creationCooldown;
                    if (targetCooldown > creationCooldown)
                    {
                        select = targetCooldown;
                    }
                    player.ChatMessage($"Cooldown: {select.ToString(@"hh\:mm\:ss")}");
                }
                else if (bounty.target == player && !hasPermission(player, permissions.admin))
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.selfHunt);
                }
                else if (Vector3.Distance(player.transform.position, bounty.target.transform.position) < config.safeDistance && !hasPermission(player, permissions.admin))
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.tooClose);
                }
                else
                {
                    Effect.server.Run(successSound, player.transform.position);
                    bounty.startHunt(p);
                    BountyData.removeBounty(bounty.noteUid);
                    player.GetActiveItem()?.Remove();
                    closeBounty(player);
                }
            };

            c.addPlainButton("button", ButtonPos, GuiContainer.Layer.hud, (error == huntErrorType.none)?darkGreen:darkRed, FadeIn, FadeOut, textOptions[(int)error], cb, blur: GuiContainer.Blur.medium);
            c.display(player);

            if (error != huntErrorType.none && error != huntErrorType.huntActive)
            {
                PluginInstance.timer.Once(2f, () =>
                {
                    if (GuiTracker.getGuiTracker(player).getContainer(this, "bountyPreview") != null)
                    {
                        huntButton(player, bounty);
                    }
                });
            }
        }
Beispiel #25
0
        private void SendPlayerSearchUI(BasePlayer player, KeyValuePair <BasePlayer, PlayerSummary>[] results, Action <BasePlayer> callback, int page = 0)
        {
            List <List <KeyValuePair <BasePlayer, PlayerSummary> > > listOfLists = SplitIntoChunks(results.ToList(), 5);

            GuiContainer c = new GuiContainer(PluginInstance, "PlayerSearch");

            //clickout
            c.addPlainButton("close", new Rectangle(), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0.3f), 0.1f, 0.1f, blur: GuiContainer.Blur.medium);

            GuiColor black60 = new GuiColor(0, 0, 0, 0.6f);
            GuiColor black40 = new GuiColor(0, 0, 0, 0.4f);
            GuiColor white70 = new GuiColor(1, 1, 1, 0.7f);

            //background
            Rectangle bgPos = new Rectangle(710, 260, 500, 560, 1920, 1080, true);

            c.addPlainPanel("background", bgPos, GuiContainer.Layer.overall, black60, 0.2f, 0, GuiContainer.Blur.medium);
            c.addPlainPanel("background2", bgPos, GuiContainer.Layer.overall, black60, 0.2f, 0, GuiContainer.Blur.greyout);

            //header
            Rectangle headerPos  = new Rectangle(710, 260, 500, 60, 1920, 1080, true);
            GuiText   headerText = new GuiText("Players found:", 20, white70);

            c.addText("header", headerPos, GuiContainer.Layer.overall, headerText, 0.2f, 0);

            //navigators
            if (page != 0)
            {
                //up
                Rectangle upPos = new Rectangle(945, 325, 30, 30, 1920, 1080, true);
                Action <BasePlayer, string[]> upCb = (p, a) =>
                {
                    SendPlayerSearchUI(player, results, callback, page - 1);
                };
                c.addButton("upbtn", upPos, GuiContainer.Layer.overall, white70, 0.2f, 0, callback: upCb, imgName: "triangle_up");
            }
            if (page != listOfLists.Count - 1)
            {
                //down
                Rectangle downPos = new Rectangle(945, 785, 30, 30, 1920, 1080, true);
                Action <BasePlayer, string[]> downCb = (p, a) =>
                {
                    SendPlayerSearchUI(player, results, callback, page + 1);
                };
                c.addButton("downbtn", downPos, GuiContainer.Layer.overall, white70, 0.2f, 0, callback: downCb, imgName: "triangle_down");
            }

            c.display(player);

            //entries
            int count    = 0;
            int sizeEach = 80;
            int gap      = 5;

            foreach (KeyValuePair <BasePlayer, PlayerSummary> kvp in listOfLists[page])
            {
                int    ccount    = count;
                int    csizeEach = sizeEach;
                int    cgap      = gap;
                Action imageCb   = () =>
                {
                    SendEntry(player, kvp, ccount, csizeEach, cgap, callback);
                };
                registerImage(PluginInstance, kvp.Key.UserIDString, kvp.Value.avatarfull, imageCb, true);
                count++;
            }
        }