C#:
// #define TESTING
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using Oxide.Core;
using Oxide.Core.Libraries;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using Oxide.Plugins.ServerPanelPopUpsExtensionMethods;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UIElements;
using Image = UnityEngine.UI.Image;
using Random = UnityEngine.Random;
#if CARBON
using Carbon.Base;
using Carbon.Modules;
#endif
namespace Oxide.Plugins
{
[Info("ServerPanel Pop Ups", "Mevent", "1.1.1")]
public class ServerPanelPopUps : RustPlugin
{
#region Fields
[PluginReference] private Plugin
ServerPanel = null,
Notify = null,
UINotify = null,
ImageLibrary = null;
private static ServerPanelPopUps Instance;
#if CARBON
private ImageDatabaseModule imageDatabase;
#endif
private bool _enabledImageLibrary;
private const string
Perm_Edit = "serverpanelpopups.edit",
CmdMainConsole = "UI_ServerPanel_PopUps",
Layer = "UI.PopUp",
EditingLayerPopUpEditor = "UI.PopUp.EditingLayer.PopUpEditor",
EditingLayerElementEditor = "UI.PopUp.EditingLayer.ElementEditor",
EditingLayerModalAnchorSelector = "UI.PopUp.EditingLayer.Modal.AnchorSelector",
EditingLayerModalColorSelector = "UI.PopUp.EditingLayer.Modal.ColorSelector",
EditingLayerModalTextEditor = "UI.PopUp.EditingLayer.Modal.TextEditor",
EditingElementOutline = "UI.PopUp.EditingLayer.EditingElement.Outline";
private Dictionary<string, int> _popUpByCommand = new();
private Dictionary<int, int> _popUpByID = new();
#endregion
#region Config
private Configuration _config;
private class Configuration
{
#region Fields
[JsonProperty(PropertyName = "Work with Notify?")]
public bool UseNotify = true;
[JsonProperty(PropertyName = "Pop Ups", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<PopUpEntry> PopUps = new()
{
new()
{
Enabled = true,
ID = GetUniquePopUpID(),
Commands = new[] {"pop.server.rules"},
Background = new PopUpEntry.BackgroundUI
{
Background = UiElement.CreatePanel(InterfacePosition.CreatePosition(),
new IColor("#000000", 90), material: "assets/content/ui/uibackgroundblur.mat",
sprite: "assets/content/ui/ui.background.transparent.radial.psd"),
CloseAfterClick = true,
ParentLayer = "Overlay"
},
Content = new PopUpEntry.ContentUI
{
Background =
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0.5 0.5", "0.5 0.5", "-450 -175", "450 175"),
new IColor("#000000", 100),
randomName: "PopUp.ServerRules.Background"),
ContentElements = new List<UiElement>
{
UiElement.CreateImage(InterfacePosition.CreatePosition("0 1", "0 1", "4 -346", "394 -4"),
"https://gitlab.com/TheMevent/PluginsStorage/raw/main/Images/ServerPanel/serverpanel-popups-banner-rules.png",
randomName: "PopUp.ServerRules.Banner"), // Banner
UiElement.CreateImage(InterfacePosition.CreatePosition("0 1", "0 1", "410 -54", "438 -26"),
"https://gitlab.com/TheMevent/PluginsStorage/raw/main/Images/ServerPanel/serverpanel-icon-rules.png",
randomName: "PopUp.ServerRules.HeaderIcon"), // HeaderIcon
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "1 1", "448 -62.5", "-22 -17.5"),
new IColor("#CF432D", 90), "SERVER RULES", 32,
align: TextAnchor.UpperLeft,
randomName: "PopUp.ServerRules.HeaderTitle"), // HeaderTitle
UiElement.CreatePanel(InterfacePosition.CreatePosition("0 1", "1 1", "0 -4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerRules.Outline.1"), // Outline (1)
UiElement.CreatePanel(InterfacePosition.CreatePosition("0 0", "1 0", "0 0", "0 4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerRules.Outline.2"), // Outline (2)
UiElement.CreatePanel(InterfacePosition.CreatePosition("0 0", "0 1", "0 4", "4 -4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerRules.Outline.3"), // Outline (3)
UiElement.CreatePanel(InterfacePosition.CreatePosition("1 0", "1 1", "-4 4", "0 -4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerRules.Outline.4") // Outline (4)
},
UseScrolling = true,
ScrollView = new PopUpEntry.ScrollViewUI
{
Scroll = new ScrollUIElement
{
AnchorMinX = 0, AnchorMinY = 0,
AnchorMaxX = 1, AnchorMaxY = 1,
OffsetMinX = 410, OffsetMinY = 20,
OffsetMaxX = -22, OffsetMaxY = -80,
ScrollType = ScrollType.Vertical,
MovementType = ScrollRect.MovementType.Elastic,
Elasticity = 0.25f,
DecelerationRate = 0.3f,
ScrollSensitivity = 24f,
Scrollbar = new ScrollUIElement.ScrollBarSettings
{
AutoHide = false,
Size = 3f,
HandleColor = new IColor("#D74933", 100),
PressedColor = new IColor("#D74933", 100),
HighlightColor = new IColor("#D74933", 100),
TrackColor = new IColor("#373737", 100)
}
},
ScrollElements = new List<UiElement>
{
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "1 1", "0 -350", "0 0"),
new IColor("#E2DBD3", 100),
new List<string>
{
"Welcome to <color=#CF432D>{server_name}</color>! Before you start playing, we would like to remind you of our rules.",
"",
"1.<color=#CF432D>Respect for other players</color>: Please be polite and respectful when interacting with other members of the community.",
"2.<color=#CF432D>No cheats or exploits</color>: We strictly prohibit the use of any software or methods that give an unfair advantage to players.",
"3.<color=#CF432D>No insults or threats</color>: Any form of harassment, discrimination, or threats is not tolerated.",
"4.<color=#CF432D>No profanity</color>: Avoid using harsh language or obscene words in chat.",
"5.<color=#CF432D>Fair play</color>: Do not grief or kill other players without reason.Cooperation and fair play are encouraged.",
"6.<color=#CF432D>Non-interference</color>: Do not interfere with the progress of other players to complete their objectives.",
"7.<color=#CF432D>Privacy</color>: Do not disclose personal information or private details about other members of our community.",
"8.<color=#CF432D>Advertising of third-party resources is not allowed.</color> Please do not share links to other websites or resources without the permission of the administrators.",
"9.The administrators have the right to remove any content that does not comply with the rules of this server.",
"10.In case of any violation of the rules by a player, the administrators have the authority to block their account.",
"", "Thank you for your cooperation and enjoy the game!"
},
14, "robotocondensed-regular.ttf",
randomName: "PopUp.ServerRules.Description") // Description
},
ScrollHeight = 350
}
},
CloseButton = new PopUpEntry.CloseButtonUI
{
Background =
UiElement.CreatePanel(InterfacePosition.CreatePosition("1 1", "1 1", "-49 -49", "-9 -9"),
new IColor("#000000", 0)),
Title = UiElement.CreateImage(
InterfacePosition.CreatePosition("0.5 0.5", "0.5 0.5", "-10 -10", "10 10"),
"assets/icons/close.png")
}
},
new()
{
Enabled = true,
ID = GetUniquePopUpID(),
Commands = new[] {"pop.server.commands"},
Background = new PopUpEntry.BackgroundUI
{
Background = UiElement.CreatePanel(InterfacePosition.CreatePosition(),
new IColor("#000000", 90), material: "assets/content/ui/uibackgroundblur.mat",
sprite: "assets/content/ui/ui.background.transparent.radial.psd"),
CloseAfterClick = true,
ParentLayer = "Overlay"
},
Content = new PopUpEntry.ContentUI
{
Background =
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0.5 0.5", "0.5 0.5", "-450 -175", "450 175"),
new IColor("#000000", 100),
randomName: "PopUp.ServerCommands.Background"),
ContentElements = new List<UiElement>
{
UiElement.CreateImage(InterfacePosition.CreatePosition("0 1", "0 1", "4 -346", "394 -4"),
"https://gitlab.com/TheMevent/PluginsStorage/raw/main/Images/ServerPanel/serverpanel-popups-banner-commands.png",
randomName: "PopUp.ServerCommands.Banner"), // Banner
UiElement.CreateImage(InterfacePosition.CreatePosition("0 1", "0 1", "410 -54", "438 -26"),
"https://gitlab.com/TheMevent/PluginsStorage/raw/main/Images/ServerPanel/serverpanel-icon-commands.png",
randomName: "PopUp.ServerCommands.HeaderIcon"), // HeaderIcon
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "1 1", "448 -62.5", "-22 -17.5"),
new IColor("#CF432D", 90), "SERVER COMMANDS", 32,
align: TextAnchor.UpperLeft,
randomName: "PopUp.ServerCommands.HeaderTitle"), // HeaderTitle
UiElement.CreatePanel(InterfacePosition.CreatePosition("0 1", "1 1", "0 -4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerCommands.Outline.1"), // Outline (1)
UiElement.CreatePanel(InterfacePosition.CreatePosition("0 0", "1 0", "0 0", "0 4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerCommands.Outline.2"), // Outline (2)
UiElement.CreatePanel(InterfacePosition.CreatePosition("0 0", "0 1", "0 4", "4 -4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerCommands.Outline.3"), // Outline (3)
UiElement.CreatePanel(InterfacePosition.CreatePosition("1 0", "1 1", "-4 4", "0 -4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerCommands.Outline.4") // Outline (4)
},
UseScrolling = true,
ScrollView = new PopUpEntry.ScrollViewUI
{
Scroll = new ScrollUIElement
{
AnchorMinX = 0, AnchorMinY = 0,
AnchorMaxX = 1, AnchorMaxY = 1,
OffsetMinX = 410, OffsetMinY = 20,
OffsetMaxX = -22, OffsetMaxY = -80,
ScrollType = ScrollType.Vertical,
MovementType = ScrollRect.MovementType.Elastic,
Elasticity = 0.25f,
DecelerationRate = 0.3f,
ScrollSensitivity = 24f,
Scrollbar = new ScrollUIElement.ScrollBarSettings
{
AutoHide = false,
Size = 3f,
HandleColor = new IColor("#D74933", 100),
PressedColor = new IColor("#D74933", 100),
HighlightColor = new IColor("#D74933", 100),
TrackColor = new IColor("#373737", 100)
}
},
ScrollElements = new List<UiElement>
{
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "1 1", "0 -350", "0 0"),
new IColor("#E2DBD3", 100),
new List<string>
{
"<color=#CF432D>/info</color> – open this menu",
"<color=#CF432D>/trade player_name</color> – safe trade with other players",
"<color=#CF432D>/online</color> – see how many players online",
"<color=#CF432D>/shop</color> – open in-game shop",
"<color=#CF432D>/kits</color> – open kits menu",
"<color=#CF432D>/clan</color> – open clans menu",
"<color=#CF432D>/tpr player_name</color> – send teleport request to other player",
"<color=#CF432D>/tpa</color> – accept player teleport request",
"<color=#CF432D>/tpc</color> – cancel player teleport request",
"<color=#CF432D>/sethome home_name</color> – set your home location",
"<color=#CF432D>/home home_name</color> – teleport to your home"
},
14, "robotocondensed-regular.ttf",
randomName: "PopUp.ServerCommands.Description") // Description
},
ScrollHeight = 350
}
},
CloseButton = new PopUpEntry.CloseButtonUI
{
Background =
UiElement.CreatePanel(InterfacePosition.CreatePosition("1 1", "1 1", "-49 -49", "-9 -9"),
new IColor("#000000", 0)),
Title = UiElement.CreateImage(
InterfacePosition.CreatePosition("0.5 0.5", "0.5 0.5", "-10 -10", "10 10"),
"assets/icons/close.png")
}
},
new()
{
Enabled = true,
ID = GetUniquePopUpID(),
Commands = new[] {"pop.server.binds"},
Background = new PopUpEntry.BackgroundUI
{
Background = UiElement.CreatePanel(InterfacePosition.CreatePosition(),
new IColor("#000000", 90), material: "assets/content/ui/uibackgroundblur.mat",
sprite: "assets/content/ui/ui.background.transparent.radial.psd"),
CloseAfterClick = true,
ParentLayer = "Overlay"
},
Content = new PopUpEntry.ContentUI
{
Background =
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0.5 0.5", "0.5 0.5", "-450 -175", "450 175"),
new IColor("#000000", 100),
randomName: "PopUp.ServerBinds.Background"),
ContentElements = new List<UiElement>
{
UiElement.CreateImage(InterfacePosition.CreatePosition("0 1", "0 1", "4 -346", "394 -4"),
"https://gitlab.com/TheMevent/PluginsStorage/raw/main/Images/ServerPanel/serverpanel-popups-banner-binds.png",
randomName: "PopUp.ServerBinds.Banner"), // Banner
UiElement.CreateImage(InterfacePosition.CreatePosition("0 1", "0 1", "410 -54", "438 -26"),
"https://gitlab.com/TheMevent/PluginsStorage/raw/main/Images/ServerPanel/serverpanel-icon-binds.png",
randomName: "PopUp.ServerBinds.HeaderIcon"), // HeaderIcon
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "1 1", "448 -62.5", "-22 -17.5"),
new IColor("#CF432D", 90), "SERVER BINDS", 32,
align: TextAnchor.UpperLeft,
randomName: "PopUp.ServerBinds.HeaderTitle"), // HeaderTitle
UiElement.CreatePanel(InterfacePosition.CreatePosition("0 1", "1 1", "0 -4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerBinds.Outline.1"), // Outline (1)
UiElement.CreatePanel(InterfacePosition.CreatePosition("0 0", "1 0", "0 0", "0 4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerBinds.Outline.2"), // Outline (2)
UiElement.CreatePanel(InterfacePosition.CreatePosition("0 0", "0 1", "0 4", "4 -4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerBinds.Outline.3"), // Outline (3)
UiElement.CreatePanel(InterfacePosition.CreatePosition("1 0", "1 1", "-4 4", "0 -4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerBinds.Outline.4") // Outline (4)
},
UseScrolling = true,
ScrollView = new PopUpEntry.ScrollViewUI
{
Scroll = new ScrollUIElement
{
AnchorMinX = 0, AnchorMinY = 0,
AnchorMaxX = 1, AnchorMaxY = 1,
OffsetMinX = 410, OffsetMinY = 20,
OffsetMaxX = -22, OffsetMaxY = -80,
ScrollType = ScrollType.Vertical,
MovementType = ScrollRect.MovementType.Elastic,
Elasticity = 0.25f,
DecelerationRate = 0.3f,
ScrollSensitivity = 24f,
Scrollbar = new ScrollUIElement.ScrollBarSettings
{
AutoHide = false,
Size = 3f,
HandleColor = new IColor("#D74933", 100),
PressedColor = new IColor("#D74933", 100),
HighlightColor = new IColor("#D74933", 100),
TrackColor = new IColor("#373737", 100)
}
},
ScrollElements = new List<UiElement>
{
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "1 1", "0 -350", "0 0"),
new IColor("#E2DBD3", 100),
"To install binds, use the console (F1 key):",
13, "robotocondensed-regular.ttf",
randomName: "PopUp.ServerBinds.Description"), // Description
#region Binds
#region Bind 1
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "0 1", "0 -50", "188 -30"),
IColor.Create("#E2DBD3"), "OPEN GRAFFITI MENU", 12,
randomName: "PopUp.ServerBinds.Bind.1.Title"),
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0 1", "0 1", "213 -50", "363 -30"),
IColor.Create("#696969", 30),
randomName: "PopUp.ServerBinds.Bind.1.Value.Background"),
UiElement.CreateInputField(
InterfacePosition.CreatePosition("0 1", "0 1", "213 -50", "363 -30"),
IColor.Create("#E2DBD3"), "bind KEY +spray", 10,
align: TextAnchor.MiddleCenter,
randomName: "PopUp.ServerBinds.Bind.1.Value.Input"),
#endregion
#region Bind 2
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "0 1", "0 -75", "188 -55"),
IColor.Create("#E2DBD3"), "AUTO-RUN", 12,
randomName: "PopUp.ServerBinds.Bind.2.Title"),
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0 1", "0 1", "213 -75", "363 -55"),
IColor.Create("#696969", 30),
randomName: "PopUp.ServerBinds.Bind.2.Value.Background"),
UiElement.CreateInputField(
InterfacePosition.CreatePosition("0 1", "0 1", "213 -75", "363 -55"),
IColor.Create("#E2DBD3"), "bind KEY forward;sprint", 10,
align: TextAnchor.MiddleCenter,
randomName: "PopUp.ServerBinds.Bind.2.Value.Input"),
#endregion
#region Bind 3
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "0 1", "0 -100", "188 -80"),
IColor.Create("#E2DBD3"), "AUTO-ATTACK", 12,
randomName: "PopUp.ServerBinds.Bind.3.Title"),
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0 1", "0 1", "213 -100", "363 -80"),
IColor.Create("#696969", 30),
randomName: "PopUp.ServerBinds.Bind.3.Value.Background"),
UiElement.CreateInputField(
InterfacePosition.CreatePosition("0 1", "0 1", "213 -100", "363 -80"),
IColor.Create("#E2DBD3"), "bind KEY attack", 10,
align: TextAnchor.MiddleCenter,
randomName: "PopUp.ServerBinds.Bind.3.Value.Input"),
#endregion
#region Bind 4
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "0 1", "0 -125", "188 -105"),
IColor.Create("#E2DBD3"), "OPEN KITS MENU", 12,
randomName: "PopUp.ServerBinds.Bind.4.Title"),
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0 1", "0 1", "213 -125", "363 -105"),
IColor.Create("#696969", 30),
randomName: "PopUp.ServerBinds.Bind.4.Value.Background"),
UiElement.CreateInputField(
InterfacePosition.CreatePosition("0 1", "0 1", "213 -125", "363 -105"),
IColor.Create("#E2DBD3"), "bind KEY chat.say /kits", 10,
align: TextAnchor.MiddleCenter,
randomName: "PopUp.ServerBinds.Bind.4.Value.Input"),
#endregion
#region Bind 5
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "0 1", "0 -150", "188 -130"),
IColor.Create("#E2DBD3"), "TELEPORT TO HOME", 12,
randomName: "PopUp.ServerBinds.Bind.5.Title"),
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0 1", "0 1", "213 -150", "363 -130"),
IColor.Create("#696969", 30),
randomName: "PopUp.ServerBinds.Bind.5.Value.Background"),
UiElement.CreateInputField(
InterfacePosition.CreatePosition("0 1", "0 1", "213 -150", "363 -130"),
IColor.Create("#E2DBD3"), "bind KEY chat.say /home {name}", 10,
align: TextAnchor.MiddleCenter,
randomName: "PopUp.ServerBinds.Bind.5.Value.Input"),
#endregion
#region Bind 6
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "0 1", "0 -175", "188 -155"),
IColor.Create("#E2DBD3"), "ACCEPT TELEPORT REQUEST", 12,
randomName: "PopUp.ServerBinds.Bind.6.Title"),
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0 1", "0 1", "213 -175", "363 -155"),
IColor.Create("#696969", 30),
randomName: "PopUp.ServerBinds.Bind.6.Value.Background"),
UiElement.CreateInputField(
InterfacePosition.CreatePosition("0 1", "0 1", "213 -175", "363 -155"),
IColor.Create("#E2DBD3"), "bind KEY chat.say /tpa", 10,
align: TextAnchor.MiddleCenter,
randomName: "PopUp.ServerBinds.Bind.6.Value.Input"),
#endregion
#region Bind 7
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "0 1", "0 -200", "188 -180"),
IColor.Create("#E2DBD3"), "OPEN SKILLS", 12,
randomName: "PopUp.ServerBinds.Bind.7.Title"),
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0 1", "0 1", "213 -200", "363 -180"),
IColor.Create("#696969", 30),
randomName: "PopUp.ServerBinds.Bind.7.Value.Background"),
UiElement.CreateInputField(
InterfacePosition.CreatePosition("0 1", "0 1", "213 -200", "363 -180"),
IColor.Create("#E2DBD3"), "bind KEY chat.say /skills", 10,
align: TextAnchor.MiddleCenter,
randomName: "PopUp.ServerBinds.Bind.7.Value.Input"),
#endregion
#region Bind 8
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "0 1", "0 -225", "188 -205"),
IColor.Create("#E2DBD3"), "OPEN DAILY REWARDS", 12,
randomName: "PopUp.ServerBinds.Bind.8.Title"),
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0 1", "0 1", "213 -225", "363 -205"),
IColor.Create("#696969", 30),
randomName: "PopUp.ServerBinds.Bind.8.Value.Background"),
UiElement.CreateInputField(
InterfacePosition.CreatePosition("0 1", "0 1", "213 -225", "363 -205"),
IColor.Create("#E2DBD3"), "bind KEY chat.say /daily", 10,
align: TextAnchor.MiddleCenter,
randomName: "PopUp.ServerBinds.Bind.8.Value.Input"),
#endregion
#endregion Binds
},
ScrollHeight = 350
}
},
CloseButton = new PopUpEntry.CloseButtonUI
{
Background =
UiElement.CreatePanel(InterfacePosition.CreatePosition("1 1", "1 1", "-49 -49", "-9 -9"),
new IColor("#000000", 0)),
Title = UiElement.CreateImage(
InterfacePosition.CreatePosition("0.5 0.5", "0.5 0.5", "-10 -10", "10 10"),
"assets/icons/close.png")
}
},
new()
{
Enabled = true,
ID = GetUniquePopUpID(),
Commands = new[] {"pop.server.contacts"},
Background = new PopUpEntry.BackgroundUI
{
Background = UiElement.CreatePanel(InterfacePosition.CreatePosition(),
new IColor("#000000", 90), material: "assets/content/ui/uibackgroundblur.mat",
sprite: "assets/content/ui/ui.background.transparent.radial.psd"),
CloseAfterClick = true,
ParentLayer = "Overlay"
},
Content = new PopUpEntry.ContentUI
{
Background =
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0.5 0.5", "0.5 0.5", "-450 -175", "450 175"),
new IColor("#000000", 100),
randomName: "PopUp.ServerContacts.Background"),
ContentElements = new List<UiElement>
{
UiElement.CreateImage(InterfacePosition.CreatePosition("0 1", "0 1", "4 -346", "394 -4"),
"https://gitlab.com/TheMevent/PluginsStorage/raw/main/Images/ServerPanel/serverpanel-popups-banner-contacts.png",
randomName: "PopUp.ServerContacts.Banner"), // Banner
UiElement.CreateImage(InterfacePosition.CreatePosition("0 1", "0 1", "410 -54", "438 -26"),
"https://gitlab.com/TheMevent/PluginsStorage/raw/main/Images/ServerPanel/serverpanel-icon-contacts.png",
randomName: "PopUp.ServerContacts.HeaderIcon"), // HeaderIcon
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "1 1", "448 -62.5", "-22 -17.5"),
new IColor("#CF432D", 90), "SERVER CONTACTS", 32,
align: TextAnchor.UpperLeft,
randomName: "PopUp.ServerContacts.HeaderTitle"), // HeaderTitle
UiElement.CreatePanel(InterfacePosition.CreatePosition("0 1", "1 1", "0 -4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerContacts.Outline.1"), // Outline (1)
UiElement.CreatePanel(InterfacePosition.CreatePosition("0 0", "1 0", "0 0", "0 4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerContacts.Outline.2"), // Outline (2)
UiElement.CreatePanel(InterfacePosition.CreatePosition("0 0", "0 1", "0 4", "4 -4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerContacts.Outline.3"), // Outline (3)
UiElement.CreatePanel(InterfacePosition.CreatePosition("1 0", "1 1", "-4 4", "0 -4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerContacts.Outline.4") // Outline (4)
},
UseScrolling = true,
ScrollView = new PopUpEntry.ScrollViewUI
{
Scroll = new ScrollUIElement
{
AnchorMinX = 0, AnchorMinY = 0,
AnchorMaxX = 1, AnchorMaxY = 1,
OffsetMinX = 410, OffsetMinY = 20,
OffsetMaxX = -22, OffsetMaxY = -80,
ScrollType = ScrollType.Vertical,
MovementType = ScrollRect.MovementType.Elastic,
Elasticity = 0.25f,
DecelerationRate = 0.3f,
ScrollSensitivity = 24f,
Scrollbar = new ScrollUIElement.ScrollBarSettings
{
AutoHide = false,
Size = 3f,
HandleColor = new IColor("#D74933", 100),
PressedColor = new IColor("#D74933", 100),
HighlightColor = new IColor("#D74933", 100),
TrackColor = new IColor("#373737", 100)
}
},
ScrollElements = new List<UiElement>
{
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "0 1", "0 -250", "468 0"),
new IColor("#E2DBD3", 100),
new List<string>
{
"Are your questions urgent or do you have any questions depending on your VIP, please contact us through our website."
},
14, "robotocondensed-regular.ttf",
randomName: "PopUp.ServerContacts.Description"), // Description
#region QR (1)
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0 1", "0 1", "0 -235", "120 -55"),
new IColor("#696969", 20),
randomName: "PopUp.ServerContacts.QR.Website.Background"), //BG
UiElement.CreateImage(
InterfacePosition.CreatePosition("0 1", "0 1", "10 -170", "110 -70"),
"{qr_website}",
randomName: "PopUp.ServerContacts.QR.Website.Image"), //IMAGE
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0 1", "0 1", "0 -235", "120 -210"),
new IColor("#CF432D", 80),
randomName: "PopUp.ServerContacts.QR.Website.Contact"), // Contact Panel
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "0 1", "0 -235", "120 -210"),
new IColor("#E2DBD3", 100), "STORE", 12,
align: TextAnchor.MiddleCenter,
randomName: "PopUp.ServerContacts.QR.Website.Contact.Label"), // Contact Label
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0 1", "0 1", "0 -210", "120 -185"),
new IColor("#CF432D", 15),
randomName: "PopUp.ServerContacts.QR.Website.URL.Panel"), // Link Panel
UiElement.CreateInputField(
InterfacePosition.CreatePosition("0 1", "0 1", "0 -210", "120 -185"),
new IColor("#E2DBD3", 60),
"{url_website}",
10,
align: TextAnchor.MiddleCenter, font:
"robotocondensed-regular.ttf",
randomName: "PopUp.ServerContacts.QR.Website.URL.Input"), // Link Label
#endregion QR (1)
#region QR (2)
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0 1", "0 1", "140 -235", "260 -55"),
new IColor("#696969", 20),
randomName: "PopUp.ServerContacts.QR.Discord.Background"), //BG
UiElement.CreateImage(
InterfacePosition.CreatePosition("0 1", "0 1", "150 -170", "250 -70"),
"{qr_discord}",
randomName: "PopUp.ServerContacts.QR.Discord.Image"), //IMAGE
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0 1", "0 1", "140 -235", "260 -210"),
new IColor("#CF432D", 80),
randomName: "PopUp.ServerContacts.QR.Discord.Contact"), // Contact Panel
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "0 1", "140 -235", "260 -210"),
new IColor("#E2DBD3", 100), "DISCORD", 12,
align: TextAnchor.MiddleCenter,
randomName: "PopUp.ServerContacts.QR.Discord.Contact.Label"), // Contact Label
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0 1", "0 1", "140 -210", "260 -185"),
new IColor("#CF432D", 15),
randomName: "PopUp.ServerContacts.QR.Discord.URL.Panel"), // Link Panel
UiElement.CreateInputField(
InterfacePosition.CreatePosition("0 1", "0 1", "140 -210", "260 -185"),
new IColor("#E2DBD3", 60),
"{url_discord}",
10,
align: TextAnchor.MiddleCenter, font:
"robotocondensed-regular.ttf",
randomName: "PopUp.ServerContacts.QR.Discord.URL.Input"), // Link Label
#endregion QR (2)
},
ScrollHeight = 350
}
},
CloseButton = new PopUpEntry.CloseButtonUI
{
Background =
UiElement.CreatePanel(InterfacePosition.CreatePosition("1 1", "1 1", "-49 -49", "-9 -9"),
new IColor("#000000", 0)),
Title = UiElement.CreateImage(
InterfacePosition.CreatePosition("0.5 0.5", "0.5 0.5", "-10 -10", "10 10"),
"assets/icons/close.png")
}
},
new()
{
Enabled = true,
ID = GetUniquePopUpID(),
Commands = new[] {"pop.server.info"},
Background = new PopUpEntry.BackgroundUI
{
Background = UiElement.CreatePanel(InterfacePosition.CreatePosition(),
new IColor("#000000", 90), material: "assets/content/ui/uibackgroundblur.mat",
sprite: "assets/content/ui/ui.background.transparent.radial.psd"),
CloseAfterClick = true,
ParentLayer = "Overlay"
},
Content = new PopUpEntry.ContentUI
{
Background =
UiElement.CreatePanel(
InterfacePosition.CreatePosition("0.5 0.5", "0.5 0.5", "-450 -175", "450 175"),
new IColor("#000000", 100),
randomName: "PopUp.ServerInfo.Background"),
ContentElements = new List<UiElement>
{
UiElement.CreateImage(InterfacePosition.CreatePosition("0 1", "0 1", "4 -346", "394 -4"),
"https://gitlab.com/TheMevent/PluginsStorage/raw/main/Images/ServerPanel/serverpanel-popups-banner-info.png",
randomName: "PopUp.ServerInfo.Banner"), // Banner
UiElement.CreateImage(InterfacePosition.CreatePosition("0 1", "0 1", "410 -54", "438 -26"),
"https://gitlab.com/TheMevent/PluginsStorage/raw/main/Images/ServerPanel/serverpanel-icon-info.png",
randomName: "PopUp.ServerInfo.HeaderIcon"), // HeaderIcon
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "1 1", "448 -62.5", "-22 -17.5"),
new IColor("#CF432D", 90), "SERVER INFO", 32,
align: TextAnchor.UpperLeft,
randomName: "PopUp.ServerInfo.HeaderTitle"), // HeaderTitle
UiElement.CreatePanel(InterfacePosition.CreatePosition("0 1", "1 1", "0 -4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerInfo.Outline.1"), // Outline (1)
UiElement.CreatePanel(InterfacePosition.CreatePosition("0 0", "1 0", "0 0", "0 4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerInfo.Outline.2"), // Outline (2)
UiElement.CreatePanel(InterfacePosition.CreatePosition("0 0", "0 1", "0 4", "4 -4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerInfo.Outline.3"), // Outline (3)
UiElement.CreatePanel(InterfacePosition.CreatePosition("1 0", "1 1", "-4 4", "0 -4"),
new IColor("#CF432D", 100),
randomName: "PopUp.ServerInfo.Outline.4"), // Outline (4)
UiElement.CreateImage(InterfacePosition.CreatePosition("0 1", "0 1", "4 -346", "394 -175"),
"assets/content/ui/UI.Background.Transparent.Linear.psd",
new IColor("#1E2022", 100),
randomName: "PopUp.ServerInfo.Hover"), // Hover
UiElement.CreateImage(
InterfacePosition.CreatePosition("0 1", "0 1", "169 -205", "229 -145"),
"https://gitlab.com/TheMevent/PluginsStorage/raw/main/Images/ServerPanel/serverpanel-button-play.png",
randomName: "PopUp.ServerInfo.Image.Play"), // Image Play
UiElement.CreateButton(
InterfacePosition.CreatePosition("0 1", "0 1", "169 -205", "229 -145"),
IColor.CreateTransparent(), IColor.CreateTransparent(), string.Empty,
command:
"serverpanel_broadcastvideo https://gitlab.com/TheMevent/PluginsStorage/raw/main/Images/ServerPanel/rust-official-trailer.mp4",
randomName: "PopUp.ServerInfo.Button.Play") // Button Play
},
UseScrolling = true,
ScrollView = new PopUpEntry.ScrollViewUI
{
Scroll = new ScrollUIElement
{
AnchorMinX = 0, AnchorMinY = 0,
AnchorMaxX = 1, AnchorMaxY = 1,
OffsetMinX = 410, OffsetMinY = 20,
OffsetMaxX = -22, OffsetMaxY = -80,
ScrollType = ScrollType.Vertical,
MovementType = ScrollRect.MovementType.Elastic,
Elasticity = 0.25f,
DecelerationRate = 0.3f,
ScrollSensitivity = 24f,
Scrollbar = new ScrollUIElement.ScrollBarSettings
{
AutoHide = false,
Size = 3f,
HandleColor = new IColor("#D74933", 100),
PressedColor = new IColor("#D74933", 100),
HighlightColor = new IColor("#D74933", 100),
TrackColor = new IColor("#373737", 100)
}
},
ScrollElements = new List<UiElement>
{
UiElement.CreateLabel(
InterfacePosition.CreatePosition("0 1", "1 1", "0 -350", "0 0"),
new IColor("#E2DBD3", 100),
new List<string>
{
"WIPE SCHEDULE: <color=#CF432D>{server_wipe_days}</color> @ <color=#CF432D>{server_wipe_time}</color> ({server_wipe_time_zone})",
"",
"<size=18><color=#CF432D><b>SERVER INFO:</b></color></size>",
"– {server_rates} GATHER RATES ON RESOURCES, COMPONENTS AND FOOD",
"– {server_stack_size} STACK SIZE",
"– {server_craft_speed} CRAFTING SPEED",
"– FASTER SMELTING/RECYCLING SPEED",
"– LONG DAYS & SHORT NIGHTS",
"– ACTIVE ADMINS",
"– DDoS PROTECTED",
"– LAG FREE EXPERIENCE"
},
14, "robotocondensed-regular.ttf",
randomName: "PopUp.ServerInfo.Description") // Description
},
ScrollHeight = 350
}
},
CloseButton = new PopUpEntry.CloseButtonUI
{
Background =
UiElement.CreatePanel(InterfacePosition.CreatePosition("1 1", "1 1", "-49 -49", "-9 -9"),
new IColor("#000000", 0)),
Title = UiElement.CreateImage(
InterfacePosition.CreatePosition("0.5 0.5", "0.5 0.5", "-10 -10", "10 10"),
"assets/icons/close.png")
}
}
};
#endregion
}
#region Classes
public class PopUpEntry
{
#region Fields
[JsonProperty(PropertyName = "Enabled")]
public bool Enabled;
[JsonProperty(PropertyName = "ID")]
public int ID;
[JsonProperty(PropertyName = "Commands", ObjectCreationHandling = ObjectCreationHandling.Replace)]
public string[] Commands = Array.Empty<string>();
[JsonProperty(PropertyName = "Background")]
public BackgroundUI Background = new();
[JsonProperty(PropertyName = "Close Button")]
public CloseButtonUI CloseButton = new();
[JsonProperty(PropertyName = "Content")]
public ContentUI Content = new();
#endregion
#region Public Methods
public void Show(BasePlayer player)
{
var container = new CuiElementContainer();
ShowBackground(player, container);
ShowContent(player, container);
ShowCloseButton(player, container);
CuiHelper.AddUi(player, container);
}
private void ShowEditButton(BasePlayer player, CuiElementContainer container)
{
ShowEditButtonUI(player, container, Layer + ".Content", Layer + ".Button.Edit",
cmdEdit: $"{CmdMainConsole} edit_popup start {ID}");
}
private void ShowCloseButton(BasePlayer player, CuiElementContainer container)
{
CloseButton.Show(player, container, Layer + ".Content", Layer,
command: $"{CmdMainConsole} close");
}
private void ShowBackground(BasePlayer player, CuiElementContainer container)
{
Background.ShowBackground(player, container, Layer, cmdBG: $"{CmdMainConsole} close");
}
public void ShowContent(BasePlayer player, CuiElementContainer container)
{
Content.ShowContent(player, container, Layer, Layer + ".Content");
if (CanPlayerEdit(player)) ShowEditButton(player, container);
}
public List<UiElement> GetAllUiElements()
{
var nestedElements = new List<UiElement>();
GetNestedUiElementsRecursive(this, nestedElements);
return nestedElements;
}
private void GetNestedUiElementsRecursive(object obj, List<UiElement> nestedElements)
{
switch (obj)
{
case UiElement uiElement:
nestedElements.Add(uiElement);
break;
case PopUpEntry popUpEntry:
GetNestedUiElementsRecursive(popUpEntry.Background, nestedElements);
GetNestedUiElementsRecursive(popUpEntry.Content, nestedElements);
GetNestedUiElementsRecursive(popUpEntry.CloseButton, nestedElements);
break;
case BackgroundUI backgroundUI:
GetNestedUiElementsRecursive(backgroundUI.Background, nestedElements);
break;
case ContentUI contentUI:
foreach (var element in contentUI.ContentElements)
GetNestedUiElementsRecursive(element, nestedElements);
if (contentUI.UseScrolling)
foreach (var element in contentUI.ScrollView.ScrollElements)
GetNestedUiElementsRecursive(element, nestedElements);
break;
case CloseButtonUI closeButtonUI:
GetNestedUiElementsRecursive(closeButtonUI.Background, nestedElements);
GetNestedUiElementsRecursive(closeButtonUI.Title, nestedElements);
break;
}
}
#endregion
#region Classes
public class BackgroundUI
{
#region Fields
[JsonProperty(PropertyName = "Parent Layer (Overlay/Hud)")]
public string ParentLayer;
[JsonProperty(PropertyName = "Background")]
public UiElement Background = new();
[JsonProperty(PropertyName = "Close after click?")]
public bool CloseAfterClick;
#endregion
#region Public Methods
public string ShowBackground(BasePlayer player,
CuiElementContainer container,
string name = "",
string cmdBG = "")
{
if (string.IsNullOrEmpty(name))
name = CuiHelper.GetGuid();
if (string.IsNullOrEmpty(ParentLayer))
ParentLayer = "Overlay";
Background.Get(ref container, player, ParentLayer, name, name);
if (CloseAfterClick)
container.Add(new CuiElement
{
Parent = name,
Components =
{
new CuiButtonComponent
{
Color = "0 0 0 0",
Command = cmdBG,
Close = name
},
new CuiRectTransformComponent(),
new CuiNeedsCursorComponent()
}
});
return name;
}
#endregion
}
public class ContentUI
{
#region Fields
[JsonProperty(PropertyName = "Background")]
public UiElement Background = new();
[JsonProperty(PropertyName = "Content Elements",
ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<UiElement> ContentElements = new();
[JsonProperty(PropertyName = "Use scrolling?")]
public bool UseScrolling;
[JsonProperty(PropertyName = "Scroll Settings")]
public ScrollViewUI ScrollView = new();
#endregion
#region Public Methods
public void ShowContent(BasePlayer player, CuiElementContainer container,
string parent,
string name = "",
Action<string> callback = null)
{
if (string.IsNullOrEmpty(name))
name = CuiHelper.GetGuid();
Background.Get(ref container, player, parent, name, name);
ContentElements?.ForEach(element => element.Get(ref container, player, name,
element.Name, element.Name));
if (UseScrolling)
ScrollView?.Get(player, container, name, Layer + ".Scroll");
callback?.Invoke(name);
}
public List<UiElement> GetEditableUiElements()
{
var list = new List<UiElement>(ContentElements);
if (UseScrolling)
list.AddRange(ScrollView.ScrollElements);
return list;
}
#endregion
}
public class ScrollViewUI
{
#region Fields
[JsonProperty(PropertyName = "Scroll")]
public ScrollUIElement Scroll = new();
[JsonProperty(PropertyName = "Scroll Elements",
ObjectCreationHandling = ObjectCreationHandling.Replace)]
public List<UiElement> ScrollElements = new();
[JsonProperty(PropertyName = "Scroll Height")]
public float ScrollHeight;
#endregion
#region Public Methods
public void Get(BasePlayer player, CuiElementContainer container, string parent, string name = "")
{
if (string.IsNullOrEmpty(name))
name = parent + ".Scroll.Panel";
container.Add(new CuiElement
{
Name = name,
DestroyUi = name,
Parent = parent,
Components =
{
new CuiImageComponent
{
Color = "0 0 0 0"
},
Scroll.GetRectTransform()
}
});
container.Add(new CuiElement
{
Name = name + ".View",
Parent = name,
Components =
{
Scroll.GetScrollView(CalculateContentRectTransform(ScrollHeight))
}
});
ScrollElements?.ForEach(element =>
element.Get(ref container, player, name + ".View", element.Name, element.Name));
}
public CuiRectTransform CalculateContentRectTransform(float totalWidth)
{
CuiRectTransform contentRect;
if (Scroll.ScrollType == ScrollType.Horizontal)
contentRect = new CuiRectTransform
{
AnchorMin = "0 0", AnchorMax = "0 1",
OffsetMin = "0 0",
OffsetMax = $"{totalWidth} 0"
};
else
contentRect = new CuiRectTransform
{
AnchorMin = "0 1", AnchorMax = "1 1",
OffsetMin = $"0 -{totalWidth}",
OffsetMax = "0 0"
};
return contentRect;
}
private CuiRectTransformComponent CalculateCategoriesPosition(float offsetX, float categoryWidth,
float categoryHeight)
{
CuiRectTransformComponent cuiRect;
if (Scroll.ScrollType == ScrollType.Horizontal)
cuiRect = new CuiRectTransformComponent
{
AnchorMin = "0 1", AnchorMax = "0 1",
OffsetMin = $"{offsetX} -{categoryHeight}",
OffsetMax = $"{offsetX + categoryWidth} 0"
};
else
cuiRect = new CuiRectTransformComponent
{
AnchorMin = "0 1", AnchorMax = "0 1",
OffsetMin = $"0 {offsetX - categoryHeight}",
OffsetMax = $"{categoryWidth} {offsetX}"
};
return cuiRect;
}
#endregion
}
public class CloseButtonUI
{
#region Fields
[JsonProperty(PropertyName = "Background")]
public UiElement Background = new();
[JsonProperty(PropertyName = "Title")] public UiElement Title = new();
#endregion
#region Public Methods
public void Show(BasePlayer player, CuiElementContainer container, string parent,
string closeLayer = "", string command = "")
{
Background.Get(ref container, player, parent, parent + ".CloseButton", parent + ".CloseButton");
Title.Get(ref container, player, parent + ".CloseButton", parent + ".CloseButton.Command");
container.Add(new CuiElement
{
Parent = parent + ".CloseButton",
Components =
{
new CuiButtonComponent
{
Color = "0 0 0 0",
Command = command,
Close = closeLayer
}
}
});
}
#endregion
}
#endregion
}
#region UI
public class InterfacePosition
{
#region Fields
[JsonProperty(PropertyName = "AnchorMin (X)")]
public float AnchorMinX;
[JsonProperty(PropertyName = "AnchorMin (Y)")]
public float AnchorMinY;
[JsonProperty(PropertyName = "AnchorMax (X)")]
public float AnchorMaxX;
[JsonProperty(PropertyName = "AnchorMax (Y)")]
public float AnchorMaxY;
[JsonProperty(PropertyName = "OffsetMin (X)")]
public float OffsetMinX;
[JsonProperty(PropertyName = "OffsetMin (Y)")]
public float OffsetMinY;
[JsonProperty(PropertyName = "OffsetMax (X)")]
public float OffsetMaxX;
[JsonProperty(PropertyName = "OffsetMax (Y)")]
public float OffsetMaxY;
#endregion Fields
#region Public Methods
public float GetAxis(bool isX)
{
if (isX)
{
return OffsetMinX;
}
return -OffsetMaxY;
}
public void SetVerticalAxis(VerticalConstraint constraint)
{
switch (constraint)
{
case VerticalConstraint.Center:
AnchorMinX = AnchorMinX = 0.5f;
break;
case VerticalConstraint.Bottom:
AnchorMinY = AnchorMaxY = 0f;
break;
case VerticalConstraint.Top:
AnchorMinY = AnchorMaxY = 1f;
break;
case VerticalConstraint.Scale:
AnchorMinY = 0f;
AnchorMaxY = 1f;
break;
}
}
public VerticalConstraint GetVerticalAxis()
{
if (Mathf.Approximately(AnchorMinY, AnchorMaxY))
{
if (Mathf.Approximately(AnchorMinY, 0.5f))
return VerticalConstraint.Center;
if (Mathf.Approximately(AnchorMinY, 0f))
return VerticalConstraint.Bottom;
if (Mathf.Approximately(AnchorMinY, 1f))
return VerticalConstraint.Top;
}
if (Mathf.Approximately(AnchorMinY, 0) && Mathf.Approximately(AnchorMaxY, 1))
return VerticalConstraint.Scale;
return VerticalConstraint.Custom;
}
public void SetHorizontalAxis(HorizontalConstraint constraint)
{
switch (constraint)
{
case HorizontalConstraint.Center:
AnchorMinX = AnchorMaxX = 0.5f;
break;
case HorizontalConstraint.Left:
AnchorMinX = AnchorMaxX = 0f;
break;
case HorizontalConstraint.Right:
AnchorMinX = AnchorMaxX = 1f;
break;
case HorizontalConstraint.Scale:
AnchorMinX = 0f;
AnchorMaxX = 1f;
break;
}
}
public HorizontalConstraint GetHorizontalAxis()
{
if (Mathf.Approximately(AnchorMinX, AnchorMaxX))
{
if (Mathf.Approximately(AnchorMinX, 0.5f))
return HorizontalConstraint.Center;
if (Mathf.Approximately(AnchorMinX, 0f))
return HorizontalConstraint.Left;
if (Mathf.Approximately(AnchorMinX, 1f))
return HorizontalConstraint.Right;
}
if (Mathf.Approximately(AnchorMinX, 0) && Mathf.Approximately(AnchorMaxX, 1))
return HorizontalConstraint.Scale;
return HorizontalConstraint.Custom;
}
public enum HorizontalConstraint
{
Left,
Center,
Right,
Scale,
Custom
}
public enum VerticalConstraint
{
Bottom,
Center,
Top,
Scale,
Custom
}
public void SetAxis(bool isX, float value)
{
if (isX)
{
var oldX = OffsetMinX;
OffsetMinX = value;
OffsetMaxX = OffsetMaxX - oldX + value;
}
els
// ... [Code preview truncated due to length. Full source in attached file] ...