Ejemplo n.º 1
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]));
                }
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }