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(); }
public GuiText(string text, int fontSize = 14, GuiColor color = null, TextAnchor align = TextAnchor.MiddleCenter, float FadeIn = 0) { this.Text = text; this.FontSize = fontSize; this.Align = align; this.Color = color?.getColorString() ?? new GuiColor(0, 0, 0, 1).getColorString(); this.FadeIn = FadeIn; }
public static List <GuiElement> GetNewGuiPanel( Plugin plugin, string name, Rectangle rectangle, GuiElement parent, Layer layer, GuiColor panelColor = null, float FadeIn = 0, float FadeOut = 0, GuiText text = null, string imgName = null, Blur blur = Blur.none) { List <GuiElement> elements = new List <GuiElement>(); Layer higherLayer = layer; if (parent != null) { higherLayer = (Layer)Math.Min((int)layer, (int)parent.Layer); } if (string.IsNullOrEmpty(imgName)) { GuiPlainPanel plainPanel = GuiPlainPanel.GetNewGuiPlainPanel(name, rectangle, parent, layer, panelColor, FadeIn, FadeOut, blur); elements.Add(plainPanel); } else { GuiImage image = GuiImage.GetNewGuiImage(plugin, name, rectangle, imgName, false, parent, layer, panelColor, FadeIn, FadeOut); elements.Add(image); } if (text != null) { text.FadeIn = FadeIn; GuiLabel label = new GuiLabel { Name = name + "_txt", Rectangle = new Rectangle(), Layer = higherLayer, Parent = name, Text = text, FadeOut = FadeOut, Components = { text, new Rectangle() } }; elements.Add(label); } return(elements); }
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 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 static GUIStyle GetGuiItemStyle(GuiItemType type, GuiColor textColor = GuiColor.White, TextAnchor textAnchor = TextAnchor.MiddleCenter, FontStyle fontStyle = FontStyle.Normal, bool wordWrap = false) { if (!isInitStyles) { isInitStyles = SetGUIStyles(); } switch (type) { case GuiItemType.NORMALBUTTON: NormalButton.normal.textColor = GetGuiColor(textColor); NormalButton.fontStyle = fontStyle; NormalButton.alignment = textAnchor; NormalButton.wordWrap = wordWrap; NormalButton.normal.textColor = GetGuiColor(textColor); NormalButton.hover.textColor = Color.white; NormalButton.active.textColor = Color.green; return(NormalButton); case GuiItemType.TOGGLEBUTTON: return(ToggleButton); case GuiItemType.TAB: return(Tab); case GuiItemType.LABEL: Label.normal.textColor = GetGuiColor(textColor); Label.fontStyle = fontStyle; Label.alignment = textAnchor; Label.wordWrap = wordWrap; Label.clipping = TextClipping.Overflow; return(Label); case GuiItemType.TEXTFIELD: return(Textfield); case GuiItemType.TEXTAREA: Textarea.fontStyle = fontStyle; Textarea.alignment = textAnchor; Textarea.wordWrap = wordWrap; Textarea.normal.textColor = GetGuiColor(textColor); return(Textarea); case GuiItemType.BOX: return(Box); case GuiItemType.DROPDOWN: //Dropdown.normal.background = MakeTex(10, 10, new Color(0f, 1f, 0f, 1f)); return(Dropdown); } throw new Exception("Unknown error!"); }
protected override void DrawMyData() { CurrentTextureName = Dragging ? DraggingTextureName : NormalTextureName; if (DebugMode) { Manager.ImageCompositor.Draw(CurrentTextureName, State, GuiColor.MidnightBlue()); } else { base.DrawMyData(); } }
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); }
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); }
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 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); }
public static Color GetGuiColor(GuiColor color) { switch (color) { case GuiColor.Black: return(Color.black); case GuiColor.Blue: return(Color.blue); case GuiColor.Clear: return(Color.clear); case GuiColor.Cyan: return(Color.cyan); case GuiColor.Green: return(Color.green); case GuiColor.Gray: return(Color.gray); case GuiColor.Grey: return(Color.grey); case GuiColor.Magenta: return(Color.magenta); case GuiColor.Red: return(Color.red); case GuiColor.White: return(Color.white); case GuiColor.Yellow: return(Color.yellow); default: break; } return(Color.white); }
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); }
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); }
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(); }
public void addButton(string name, CuiRectTransformComponent rectangle, GuiColor panelColor = null, float FadeIn = 0, float FadeOut = 0, GuiText text = null, Action <BasePlayer, string[]> callback = null, string close = null, bool CursorEnabled = true, string imgName = null, string parent = "Hud", bool blur = false) { if (string.IsNullOrEmpty(name)) { name = "button"; } else { name = PluginInstance.encodeName(this, name); } purgeDuplicates(name); if (imgName != null) { this.addImage(PluginInstance.decodeName(this, name), rectangle, imgName, parent, null, FadeIn, FadeOut); this.addPlainButton(PluginInstance.decodeName(this, name) + "_btn", new Rectangle(), panelColor, FadeIn, FadeOut, text, callback, close, CursorEnabled, PluginInstance.decodeName(this, name)); } else { this.addPlainButton(PluginInstance.decodeName(this, name), rectangle, panelColor, FadeIn, FadeOut, text, callback, close, CursorEnabled, parent, blur); } }
public GuiItemColor(GuiColor normal = GuiColor.Gray, GuiColor active = GuiColor.Green, GuiColor hover = GuiColor.White) { Normal = normal; Hover = hover; Active = active; }
public static GuiPlainPanel GetNewGuiPlainPanel(string name, Rectangle rectangle, GuiElement parent = null, Layer layer = Layer.hud, GuiColor panelColor = null, float fadeIn = 0, float fadeOut = 0, Blur blur = Blur.none) { //PluginInstance.Puts($"name: {name ?? "null"}, rect: {rectangle?.ToString() ?? "null"}, parent: {parent?.ToString() ?? "null"}, layer: {layer}, panelColor: {panelColor?.ToString() ?? "null"}, fadein: {fadeIn}, fadeOut: {fadeOut}, blur: {blur}"); Layer higherLayer = layer; if (parent != null) { higherLayer = (Layer)Math.Min((int)layer, (int)parent.Layer); } string materialString = "Assets/Icons/IconMaterial.mat"; if (blur != Blur.none) { materialString = blurs[(int)blur]; } return(new GuiPlainPanel { Name = name, Rectangle = rectangle.WithParent(parent?.Rectangle), Layer = higherLayer, Parent = layers[(int)higherLayer], Color = panelColor, FadeOut = fadeOut, Components = { new CuiImageComponent { Color = panelColor?.getColorString() ?? "0 0 0 0", FadeIn = fadeIn, Material = materialString }, rectangle.WithParent(parent?.Rectangle) } }); }
public List <GuiElement> addButton(string name, Rectangle rectangle, Layer layer, GuiColor panelColor = null, float FadeIn = 0, float FadeOut = 0, GuiText text = null, Action <BasePlayer, string[]> callback = null, string close = null, bool CursorEnabled = true, string imgName = null, Blur blur = Blur.none) { return(addButton(name, rectangle, null, layer, panelColor, FadeIn, FadeOut, text, callback, close, CursorEnabled, imgName, blur)); }
public List <GuiElement> addButton(string name, Rectangle rectangle, GuiElement parent, Layer layer, GuiColor panelColor = null, float FadeIn = 0, float FadeOut = 0, GuiText text = null, Action <BasePlayer, string[]> callback = null, string close = null, bool CursorEnabled = true, string imgName = null, Blur blur = Blur.none) { if (string.IsNullOrEmpty(name)) { name = "button"; } purgeDuplicates(name); List <GuiElement> elements = new List <GuiElement>(); if (imgName != null) { elements.Add(addImage(name + "_img", rectangle, imgName, parent, layer, panelColor, FadeIn, FadeOut)); elements.AddRange(addPlainButton(name + "_btn", rectangle, parent, layer, new GuiColor(0, 0, 0, 0), FadeIn, FadeOut, text, callback, close, CursorEnabled)); } else { elements.AddRange(addPlainButton(name, rectangle, parent, layer, panelColor, FadeIn, FadeOut, text, callback, close, CursorEnabled, blur)); } return(elements); }
public List <GuiElement> addPlainButton(string name, Rectangle rectangle, GuiColor panelColor = null, float FadeIn = 0, float FadeOut = 0, GuiText text = null, Action <BasePlayer, string[]> callback = null, string close = null, bool CursorEnabled = true, string parent = "Hud", Blur blur = Blur.none) { return(addPlainButton(name, rectangle, GetParent(parent), Layer.hud, panelColor, FadeIn, FadeOut, text, callback, close, CursorEnabled, blur)); }
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); }
public List <GuiElement> addInput(string name, Rectangle rectangle, Action <BasePlayer, string[]> callback, string parent = "Hud", string close = null, GuiColor panelColor = null, int charLimit = 100, GuiText text = null, float FadeIn = 0, float FadeOut = 0, bool isPassword = false, bool CursorEnabled = true, string imgName = null, Blur blur = Blur.none) { return(addInput(name, rectangle, callback, GetParent(parent), Layer.hud, close, panelColor, charLimit, text, FadeIn, FadeOut, isPassword, CursorEnabled, imgName, blur)); }
public static List <GuiElement> GetNewGuiPlainButton( Plugin plugin, GuiContainer container, string name, Rectangle rectangle, GuiElement parent = null, Layer layer = Layer.hud, GuiColor panelColor = null, float fadeIn = 0, float fadeOut = 0, GuiText text = null, Action <BasePlayer, string[]> callback = null, string close = null, bool CursorEnabled = true, Blur blur = Blur.none) { List <GuiElement> elements = new List <GuiElement>(); Layer higherLayer = layer; if (parent != null) { higherLayer = (Layer)Math.Min((int)layer, (int)parent.Layer); } StringBuilder closeString = new StringBuilder(""); if (close != null) { closeString.Append(" --close "); closeString.Append(close); } string materialString = "Assets/Icons/IconMaterial.mat"; if (blur != Blur.none) { materialString = blurs[(int)blur]; } if (text != null) { text.FadeIn = fadeIn; } GuiPlainButton button = new GuiPlainButton { Name = name, Rectangle = rectangle.WithParent(parent?.Rectangle), Layer = higherLayer, Parent = layers[(int)higherLayer], ParentElement = parent, FadeOut = fadeOut, Components = { new CuiButtonComponent { Command = $"gui.input {plugin.Name} {container.name} {removeWhiteSpaces(name)}{closeString}", FadeIn = fadeIn, Color = panelColor?.getColorString() ?? "0 0 0 0", Material = materialString }, rectangle.WithParent(parent?.Rectangle) }, Label = new GuiLabel { Name = name + "_txt", Rectangle = new Rectangle(), Layer = higherLayer, Parent = name, Text = text, FadeOut = fadeOut, Components = { text, new Rectangle() } } }; elements.Add(button); if (text != null) { elements.Add(button.Label); } if (CursorEnabled) { elements.Add(new GuiElement() { Name = name + "_cursor", Parent = name, Components = { new CuiNeedsCursorComponent() } }); } return(elements); }
public static List <GuiElement> GetNewGuiInputField( Plugin plugin, GuiContainer container, string name, Rectangle rectangle, Action <BasePlayer, string[]> callback, GuiElement parent, Layer layer, string close = null, GuiColor panelColor = null, int charLimit = 100, GuiText text = null, float FadeIn = 0, float FadeOut = 0, bool isPassword = false, bool CursorEnabled = true, string imgName = null, Blur blur = Blur.none) { List <GuiElement> elements = new List <GuiElement>(); Layer higherLayer = layer; if (parent != null) { higherLayer = (Layer)Math.Min((int)layer, (int)parent.Layer); } StringBuilder closeString = new StringBuilder(""); if (close != null) { closeString.Append(" --close "); closeString.Append(close); } if (text != null) { text.FadeIn = FadeIn; } if (imgName != null || panelColor != null) { elements.AddRange( GuiPanel.GetNewGuiPanel( plugin, name + "_label", rectangle, parent, layer, panelColor, FadeIn, FadeOut, null, imgName, blur )); } elements.Add(new GuiElement { Name = name, Rectangle = rectangle.WithParent(parent?.Rectangle), Layer = higherLayer, Parent = layers[(int)higherLayer], FadeOut = FadeOut, ParentElement = parent, Components = { new CuiInputFieldComponent { Align = text.Align, FontSize = text.FontSize, Color = text.Color, Command = $"gui.input {plugin.Name} {container.name} {removeWhiteSpaces(name)}{closeString} --input", CharsLimit = charLimit, IsPassword = isPassword }, rectangle.WithParent(parent?.Rectangle) } }); if (CursorEnabled) { elements.Add(new GuiElement() { Name = name + "_cursor", Parent = name, Components = { new CuiNeedsCursorComponent() } }); } return(elements); }
public List <GuiElement> addInput(string name, Rectangle rectangle, Action <BasePlayer, string[]> callback, GuiElement parent, Layer layer, string close = null, GuiColor panelColor = null, int charLimit = 100, GuiText text = null, float FadeIn = 0, float FadeOut = 0, bool isPassword = false, bool CursorEnabled = true, string imgName = null, Blur blur = Blur.none) { if (string.IsNullOrEmpty(name)) { name = "input"; } purgeDuplicates(name); List <GuiElement> input = GuiInputField.GetNewGuiInputField( plugin, this, name, rectangle, callback, parent, layer, close, panelColor, charLimit, text, FadeIn, FadeOut, isPassword, CursorEnabled, imgName, blur); if (callback != null) { this.registerCallback(name, callback); } AddRange(input); return(input); }
public GuiImage addRawImage(string name, Rectangle rectangle, string imgData, GuiElement Parent, Layer layer, GuiColor panelColor = null, float FadeIn = 0, float FadeOut = 0) { if (string.IsNullOrEmpty(name)) { name = "image"; } purgeDuplicates(name); GuiImage img = GuiImage.GetNewGuiImage(plugin, name, rectangle, imgData, true, Parent, layer, panelColor, FadeIn, FadeOut); Add(img); return(img); }
public List <GuiElement> addPlainButton(string name, Rectangle rectangle, GuiElement parent, Layer layer, GuiColor panelColor = null, float FadeIn = 0, float FadeOut = 0, GuiText text = null, Action <BasePlayer, string[]> callback = null, string close = null, bool CursorEnabled = true, Blur blur = Blur.none) { if (string.IsNullOrEmpty(name)) { name = "plainButton"; } purgeDuplicates(name); List <GuiElement> elements = GuiPlainButton.GetNewGuiPlainButton(plugin, this, name, rectangle, parent, layer, panelColor, FadeIn, FadeOut, text, callback, close, CursorEnabled, blur); if (callback != null) { this.registerCallback(name, callback); } AddRange(elements); return(elements); }
public static GuiImage GetNewGuiImage(Plugin plugin, string name, Rectangle rectangle, string imgNameOrData, bool raw = false, GuiElement parent = null, Layer layer = Layer.hud, GuiColor panelColor = null, float fadeIn = 0, float fadeOut = 0) { Layer higherLayer = layer; if (parent != null) { higherLayer = (Layer)Math.Min((int)layer, (int)parent.Layer); } return(new GuiImage { Name = name, Rectangle = rectangle.WithParent(parent?.Rectangle), Layer = higherLayer, Parent = layers[(int)higherLayer], Color = panelColor, FadeOut = fadeOut, Components = { new CuiRawImageComponent { Color = panelColor?.getColorString() ?? "1 1 1 1", FadeIn = fadeIn, Png = raw?imgNameOrData:PluginInstance.getImageData(plugin, imgNameOrData) }, rectangle.WithParent(parent?.Rectangle) } }); }
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++; } }