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