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])); } } }
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); } }
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); }
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++; } }
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); }