Иконка ресурса

FREE MenuSystem : 1.0.0 1.0.0

Нет прав для скачивания
C#:
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using UnityEngine;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Oxide.Plugins {
    [Info("MenuSystem", "Chibubrik", "1.0.0")]
    class MenuSystem : RustPlugin {
#region Вар
        private string Layer = "Menu_UI";
        [PluginReference]
        Plugin ImageLibrary, GameStoresRUST, CaseSystem, WipeCalendar, WipeBlock, SoReport, SkillSystem, TopChat, PassSystem;
        Dictionary<ulong, string> ActiveButton = new Dictionary<ulong, string>();
        Dictionary<ulong, string> ActiveButton2 = new Dictionary<ulong, string>();
        Dictionary<ulong, string> ActiveButton3 = new Dictionary<ulong, string>();
        Dictionary<string, string> Command = new Dictionary<string, string>() {
            ["ГЛАВНАЯ"]
            = "info", ["КОРЗИНА"] = "store", ["КЕЙСЫ"] = "case", ["КАЛЕНДАРЬ"] = "cal", ["ВАЙПБЛОК"] = "block", ["РЕПОРТ"] = "report", ["СКИЛЫ"] = "skill", ["НАСТРОЙКИ"] = "settings", ["БАТЛПАСС"] = "pass"
        }
        ;
        Dictionary<string, string> Set = new Dictionary<string, string>() {
            ["ЧАТ"]
            = "chat"
        }
        ;
#endregion
#region Класс
        public class Settings {
            [JsonProperty("Название кнопки")]
            public string DisplayName;
            [JsonProperty("Описание")]
            public string Info;
            [JsonProperty("Команда")]
            public string Command;
        }
#endregion
#region Кофниг
        Configuration config;
        class Configuration {
            [JsonProperty("Настройки")]
            public List<Settings> settings;
            public static Configuration GetNewConfig() {
                return new Configuration {
                    settings = new List<Settings>() {
                        new Settings {
                            DisplayName = "О СЕРВЕРЕ", Info = "<b><size=20>О СЕРВЕРЕ</size></b>\n\nХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуитаnХуита", Command = "i"
                        }
                        , new Settings {
                            DisplayName = "ПРАВИЛА", Info = "<b><size=20>ПРАВИЛА</size></b>\n\nХуита", Command = "p"
                        }
                        , new Settings {
                            DisplayName = "КОМАНДЫ И БИНДЫ", Info = "<b><size=20>КОМАНДЫ И БИНДЫ</size></b>\n\nХуита", Command = "b"
                        }
                        ,
                    }
                }
                ;
            }
        }
        protected override void LoadConfig() {
            base.LoadConfig();
            try {
                config = Config.ReadObject<Configuration>();
                if (config?.settings == null) LoadDefaultConfig();
            }
            catch {
                PrintWarning($"Ошибка чтения конфигурации 'oxide/config/{Name}', создаём новую конфигурацию!!");
                LoadDefaultConfig();
            }
            NextTick(SaveConfig);
        }
        protected override void LoadDefaultConfig() => config = Configuration.GetNewConfig();
        protected override void SaveConfig() => Config.WriteObject(config);
#endregion
#region Хуки
        void OnServerInitialized() {
            ImageLibrary.Call("AddImage", "https://imgur.com/C2g6QoA.png", "Background");
        }
#endregion
#region Команды
        [ChatCommand("menu")]
        void ChatMenu(BasePlayer player) => MenuUI(player, "info");
        [ChatCommand("store")]
        void ChatStore(BasePlayer player) => MenuUI(player, "store");
        [ChatCommand("case")]
        void ChatCase(BasePlayer player) => MenuUI(player, "case");
        [ChatCommand("wipe")]
        void ChatCal(BasePlayer player) => MenuUI(player, "cal");
        [ChatCommand("block")]
        void ChatBlock(BasePlayer player) => MenuUI(player, "block");
        [ChatCommand("report")]
        void ChatReport(BasePlayer player) => MenuUI(player, "report");
        [ChatCommand("skill")]
        void ChatSkill(BasePlayer player) => MenuUI(player, "skill");
        [ChatCommand("settings")]
        void ChatSet(BasePlayer player) => MenuUI(player, "settings");
        [ChatCommand("pass")]
        void ChaPass(BasePlayer player) => MenuUI(player, "pass");
        [ConsoleCommand("menu")]
        void ConsoleMenu(ConsoleSystem.Arg args) {
            var player = args.Player();
            ActiveButton[player.userID] = args.Args[0];
            UI(player, args.Args[0]);
            ButtonUI(player);
        }
        [ConsoleCommand("info")]
        void ConsoleInfo(ConsoleSystem.Arg args) {
            var player = args.Player();
            ActiveButton2[player.userID] = args.Args[0];
            InfoButton(player);
        }
        [ConsoleCommand("settings")]
        void ConsoleSettings(ConsoleSystem.Arg args) {
            var player = args.Player();
            SettingsUI(player);
        }
        [ConsoleCommand("set")]
        void ConsoleSet(ConsoleSystem.Arg args) {
            var player = args.Player();
            ActiveButton3[player.userID] = args.Args[0];
            SettingsUI(player, args.Args[0]);
        }
#endregion
#region Интерфейс
        void MenuUI(BasePlayer player, string name = "info") {
            ActiveButton[player.userID] = name;
            ActiveButton3[player.userID] = "chat";
            CuiHelper.DestroyUi(player, Layer);
            var container = new CuiElementContainer();
            container.Add(new CuiPanel {
                CursorEnabled = true, RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0 0 0 0.9"
                }
                ,
            }
            , "Overlay", Layer);
            container.Add(new CuiElement {
                Parent = Layer, Components = {
                    new CuiRawImageComponent {
                        Png = (string) ImageLibrary.Call("GetImage", "Background")
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
                    }
                }
            }
            );
            container.Add(new CuiPanel {
                RectTransform = {
                    AnchorMin = "0.05 0.8", AnchorMax = "0.24 0.88", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0 0 0 0"
                }
            }
            , Layer, "Logo");
            container.Add(new CuiElement {
                Parent = "Logo", Components = {
                    new CuiImageComponent {
                        Sprite = "assets/content/ui/menuui/rustlogo-normal-transparent.png"
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
                    }
                }
            }
            );
            container.Add(new CuiPanel {
                RectTransform = {
                    AnchorMin = "0.068 0.17", AnchorMax = "0.2 0.73", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0 0 0 0"
                }
            }
            , Layer, "Button");
            container.Add(new CuiButton {
                RectTransform = {
                    AnchorMin = "0.945 0.91", AnchorMax = $"1 1", OffsetMax = "0 0"
                }
                , Button = {
                    Color = "0 0 0 0", Close = Layer
                }
                , Text = {
                    Text = $"✖", Color = "1 1 1 0.5", Align = TextAnchor.MiddleCenter, FontSize = 50, Font = "robotocondensed-bold.ttf"
                }
            }
            , Layer);
            CuiHelper.AddUi(player, container);
            ButtonUI(player);
            UI(player, name);
        }
        void UI(BasePlayer player, string name) {
            DestroyUI(player);
            if (name == "info") InfoUI(player);
            if (name == "store") GameStoresRUST?.Call("InitializeStore", player);
            if (name == "case") CaseSystem?.Call("CaseUI", player);
            if (name == "cal") WipeCalendar.Call("CreateGui", player);
            if (name == "block") WipeBlock.Call("DrawBlockGUI", player);
            if (name == "report") SoReport.Call("StartUi", player);
            if (name == "skill") SkillSystem.Call("SkillUI", player);
            if (name == "settings") SettingsUI(player);
            if (name == "pass") PassSystem.Call("PassUI", player);
        }
        void ButtonUI(BasePlayer player) {
            CuiHelper.DestroyUi(player, "Command");
            var container = new CuiElementContainer();
            container.Add(new CuiPanel {
                RectTransform = {
                    AnchorMin = "0 0.13", AnchorMax = "1 1", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0 0 0 0"
                }
            }
            , "Button", "Command");
            float width = 1f, height = 0.138f, startxBox = 0f, startyBox = 0.995f - height, xmin = startxBox, ymin = startyBox;
            foreach (var check in Command) {
                var color = ActiveButton[player.userID] == check.Value ? "1 1 1 1" : "1 1 1 0.3";
                container.Add(new CuiButton {
                    RectTransform = {
                        AnchorMin = $"{xmin} {ymin}", AnchorMax = $"{xmin + width} {ymin + height * 1}", OffsetMin = "0 1", OffsetMax = "0 -1"
                    }
                    , Button = {
                        Color = "0 0 0 0", Command = $"menu {check.Value}"
                    }
                    , Text = {
                        Text = check.Key, Color = color, Align = TextAnchor.MiddleLeft, FontSize = 25, Font = "robotocondensed-bold.ttf"
                    }
                }
                , "Command");
                xmin += width;
                if (xmin + width >= 1) {
                    xmin = startxBox;
                    ymin -= height;
                }
            }
            CuiHelper.AddUi(player, container);
        }
        void InfoUI(BasePlayer player) {
            ActiveButton2[player.userID] = "i";
            var container = new CuiElementContainer();
            container.Add(new CuiPanel {
                RectTransform = {
                    AnchorMin = "0.276 0", AnchorMax = "0.945 1", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0.117 0.121 0.109 0"
                }
            }
            , Layer, "Info");
            container.Add(new CuiPanel {
                RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "0.289 1", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0.549 0.270 0.215 0.7", Material = ""
                }
            }
            , "Info", "Left");
            container.Add(new CuiLabel {
                RectTransform = {
                    AnchorMin = "0.09 0.91", AnchorMax = $"1 1", OffsetMax = "0 0"
                }
                , Text = {
                    Text = $"ГЛАВНАЯ", Color = "0.929 0.882 0.847 0.8", Align = TextAnchor.MiddleLeft, FontSize = 33, Font = "robotocondensed-bold.ttf"
                }
            }
            , "Left");
            CuiHelper.AddUi(player, container);
            InfoButton(player);
        }
        void InfoButton(BasePlayer player) {
            CuiHelper.DestroyUi(player, "InfoButton");
            CuiHelper.DestroyUi(player, "Text");
            var container = new CuiElementContainer();
            container.Add(new CuiPanel {
                RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0 0 0 0"
                }
            }
            , "Left", "InfoButton");
            float width = 1f, height = 0.06f, startxBox = 0f, startyBox = 0.6f - height, xmin = startxBox, ymin = startyBox;
            foreach (var check in config.settings) {
                var color = ActiveButton2[player.userID] == check.Command ? "0.149 0.145 0.137 0.8" : "0 0 0 0";
                container.Add(new CuiButton {
                    RectTransform = {
                        AnchorMin = $"{xmin} {ymin}", AnchorMax = $"{xmin + width} {ymin + height * 1}", OffsetMin = "0 1", OffsetMax = "0 -1"
                    }
                    , Button = {
                        Color = color, Command = $"info {check.Command}"
                    }
                    , Text = {
                        Text = $"{check.DisplayName}      ", Color = "1 1 1 0.8", Align = TextAnchor.MiddleRight, FontSize = 18, Font = "robotocondensed-bold.ttf"
                    }
                }
                , "InfoButton");
                if (ActiveButton2[player.userID] == check.Command) {
                    container.Add(new CuiPanel {
                        RectTransform = {
                            AnchorMin = "0.289 0", AnchorMax = "1 1", OffsetMax = "0 0"
                        }
                        , Image = {
                            Color = "0.117 0.121 0.109 0.95"
                        }
                    }
                    , "Info", "Text");
                    container.Add(new CuiLabel {
                        RectTransform = {
                            AnchorMin = "0.025 0", AnchorMax = $"0.965 1", OffsetMax = "0 0"
                        }
                        , Text = {
                            Text = check.Info, Color = "1 1 1 0.5", Align = TextAnchor.MiddleCenter, FontSize = 14, Font = "robotocondensed-regular.ttf"
                        }
                    }
                    , "Text");
                }
                xmin += width;
                if (xmin + width >= 1) {
                    xmin = startxBox;
                    ymin -= height;
                }
            }
            CuiHelper.AddUi(player, container);
        }
        void SettingsUI(BasePlayer player, string name = "chat") {
            CuiHelper.DestroyUi(player, "Settingsmain");
            CuiHelper.DestroyUi(player, "UI_SettingsLayer.WINDOW_FRAME");
            var container = new CuiElementContainer();
            container.Add(new CuiPanel {
                RectTransform = {
                    AnchorMin = "0.276 0", AnchorMax = "0.945 1", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0.117 0.121 0.109 0"
                }
            }
            , Layer, "Settingsmain");
            container.Add(new CuiPanel {
                RectTransform = {
                    AnchorMin = "0 0", AnchorMax = "0.289 1", OffsetMax = "0 0"
                }
                , Image = {
                    Color = "0.549 0.270 0.215 0.7", Material = ""
                }
            }
            , "Settingsmain", "Left");
            container.Add(new CuiLabel {
                RectTransform = {
                    AnchorMin = "0.09 0.91", AnchorMax = $"1 1", OffsetMax = "0 0"
                }
                , Text = {
                    Text = $"НАСТРОЙКИ", Color = "0.929 0.882 0.847 0.8", Align = TextAnchor.MiddleLeft, FontSize = 33, Font = "robotocondensed-bold.ttf"
                }
            }
            , "Left");
            float width = 1f, height = 0.06f, startxBox = 0f, startyBox = 0.6f - height, xmin = startxBox, ymin = startyBox;
            foreach (var check in Set) {
                var color = ActiveButton3[player.userID] == check.Value ? "0.149 0.145 0.137 0.8" : "0 0 0 0";
                container.Add(new CuiButton {
                    RectTransform = {
                        AnchorMin = $"{xmin} {ymin}", AnchorMax = $"{xmin + width} {ymin + height * 1}", OffsetMin = "0 1", OffsetMax = "0 -1"
                    }
                    , Button = {
                        Color = color, Command = $"set {check.Value}"
                    }
                    , Text = {
                        Text = $"{check.Key}      ", Color = "1 1 1 0.8", Align = TextAnchor.MiddleRight, FontSize = 18, Font = "robotocondensed-bold.ttf"
                    }
                }
                , "Left");
                xmin += width;
                if (xmin + width >= 1) {
                    xmin = startxBox;
                    ymin -= height;
                }
            }
            CuiHelper.AddUi(player, container);
            if (name == "chat") TopChat.Call("InitializeInterface", player);
        }
        void MapUI(BasePlayer player) {
            player.Command("map.open");
            player.Command("map_settings");
        }
#endregion
#region Хелпер
        void DestroyUI(BasePlayer player) {
            CuiHelper.DestroyUi(player, "Info");
            CuiHelper.DestroyUi(player, "Calendar");
            CuiHelper.DestroyUi(player, "Block");
            CuiHelper.DestroyUi(player, "Skill_UI");
            CuiHelper.DestroyUi(player, "ReportMain");
            CuiHelper.DestroyUi(player, "settings");
            CuiHelper.DestroyUi(player, "Settingsmain");
            CuiHelper.DestroyUi(player, "UI_SettingsLayer.WINDOW_FRAME");
            CuiHelper.DestroyUi(player, "Pass");
            CuiHelper.DestroyUi(player, "UI_GameStoresRUST_Store");
            CuiHelper.DestroyUi(player, "Case_UI");
            CuiHelper.DestroyUi(player, "ReportBMod");
        }
#endregion
    }
}

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху