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

FREE GestureMenu : 1.0.0 1.0.0

Нет прав для скачивания
C#:
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("GestureMenu", "Ryamkk", "1.0.0")]
    class GestureMenu : RustPlugin
    {	
        [PluginReference] Plugin ImageLibrary;
        

        public Dictionary<string, string> ImageGestures = new Dictionary<string, string>()
        {
            ["Icon0"] = "https://cdn.discordapp.com/attachments/956985279976185906/957027680891576349/victory.png",
            ["Icon1"] = "https://cdn.discordapp.com/attachments/956985279976185906/957027681768185926/shrug.png",
            ["Icon2"] = "https://cdn.discordapp.com/attachments/956985279976185906/957027681344557067/chicken.png",
            ["Icon3"] = "https://cdn.discordapp.com/attachments/956985279976185906/957027681529102346/hurry.png",
            ["Icon4"] = "https://cdn.discordapp.com/attachments/956985279976185906/957027681147453450/whoa.png",
        };
        
        public List<string> CommandGestures = new List<string>
        {
            "victory",
            "shrug",
            "chicken",
            "hurry",
            "whoa"
        };


        private void OnServerInitialized()
        {
            foreach (var check in ImageGestures)
                ImageLibrary.Call("AddImage", check.Value, check.Key);
        }
        
        void Unload()
        {
            foreach (BasePlayer player in BasePlayer.activePlayerList)
                CuiHelper.DestroyUi(player, "GestureMenuUI");
        }
        
        [ChatCommand("emotion")]
        private void cmdGameMenuOpen(BasePlayer player)
        {
            GestureMenuUI(player);
        }

        [ConsoleCommand("emotion.open")]
        private void CmdChatInfoMenu(ConsoleSystem.Arg args)
        {
            BasePlayer player = args.Player();
            GestureMenuUI(player);
        }

        private void GestureMenuUI(BasePlayer player)
        {
            CuiElementContainer container = new CuiElementContainer();

            container.Add(new CuiPanel
            {
                CursorEnabled = true,
                Image = { Color = "0 0 0 0" },
                RectTransform = { AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5" },
            }, "Hud", "GestureMenuUI");

            container.Add(new CuiElement
            {
                Parent = "GestureMenuUI",
                Components =
                {
                    new CuiButtonComponent { Close = "GestureMenuUI", Color = "0 0 0 0" },
                    new CuiRectTransformComponent { AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-1000 -1000", OffsetMax = "1000 1000" }
                }
            });
            
            int ImageSize = 20;
            int SpriteSize = 40;
            int ItemsCount = 11;

            for (var i = 0; i < ImageGestures.Values.Count(); i++)
            {
                var checkCommand = CommandGestures.ElementAt(i);
                var r = ImageGestures.Values.Count() * 10 + 55;
                var c = (double) ImageGestures.Values.Count() / 2;
                var pos = i / c * Math.PI;
                var xxx = r * Math.Sin(pos);
                var y = r * Math.Cos(pos);

                container.Add(new CuiElement
                {
                    Parent = "GestureMenuUI",
                    Components =
                    {
                        new CuiImageComponent { Sprite = "assets/icons/reddit.png", Color = HexToRustFormat("#ED851CB6") },
                        new CuiRectTransformComponent { AnchorMin = $"{xxx - SpriteSize} {y - SpriteSize}", AnchorMax = $"{xxx + SpriteSize} {y + SpriteSize}" },
                    },
                });

                container.Add(new CuiElement()
                {
                    Parent = "GestureMenuUI",
                    Components =
                    {
                        new CuiRawImageComponent { Color = HexToRustFormat("#ffffff"), Png = (string) ImageLibrary.Call("GetImage", $"Icon{i}") },
                        new CuiRectTransformComponent { AnchorMin = $"{xxx - ImageSize} {y - ImageSize}", AnchorMax = $"{xxx + ImageSize} {y + ImageSize}" }
                    }
                });

                container.Add(new CuiButton
                {
                    Button = { Color = "0 0 0 0", Command = $"gesture {checkCommand}", Close = "GestureMenuUI" },
                    RectTransform = { AnchorMin = $"{xxx - ImageSize} {y - ImageSize}", AnchorMax = $"{xxx + ImageSize} {y + ImageSize}" },
                    Text = { Text = "" }
                }, "GestureMenuUI");
            }

            CuiHelper.DestroyUi(player, "GestureMenuUI");
            CuiHelper.AddUi(player, container);
        }
        
        
        private static string HexToRustFormat(string hex)
        {
            if (string.IsNullOrEmpty(hex)) hex = "#FFFFFFFF";
            var str = hex.Trim('#');
            
            if (str.Length == 6) str += "FF";
            if (str.Length != 8) throw new Exception(hex);

            var r = byte.Parse(str.Substring(0, 2), NumberStyles.HexNumber);
            var g = byte.Parse(str.Substring(2, 2), NumberStyles.HexNumber);
            var b = byte.Parse(str.Substring(4, 2), NumberStyles.HexNumber);
            var a = byte.Parse(str.Substring(6, 2), NumberStyles.HexNumber);

            Color color = new Color32(r, g, b, a);

            return string.Format("{0:F2} {1:F2} {2:F2} {3:F2}", color.r, color.g, color.b, color.a);
        }
    }
}

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