Quick Menu

A easily accessible menu that contains configurable buttons.

Total Downloads: 1,751 - First Release: Apr 12, 2017 - Last Update: Apr 28, 2017

5/5, 10 likes
  1. GGRRRAAAHHHHHHH RIIIIIIGHT when I download and see how kick ass your plugin is, along with a hundred bucks in plugins ALL with GUIs from the Chaos Code website (a breakaway group from devs in Oxide) SOOOO frustrating!

    Anyway, GREAT plugin, can't wait until we can get all these working proper again. Sorry you devs have to go through this crap of updating, reupdating, updating, reupdating... but really - the players LOVE you. Really, we do.
     
  2. I'll be working on setting it up for 6 buttons maybe more. I just gotta get some time and figure out some other things. I'll also be making it so you can configure the Cancel button and just click the background to close the menu.

    Appreciate the love and understanding :D
     
  3. After I open the panel, I can not close it. I click the close button - nothing happens. Also, if you call the panel more than once, it does not close.
     

    Attached Files:

    Last edited by a moderator: Apr 25, 2017
  4. Dont know if this plugins is running 100% but could you please update the plugin details page with more info, like the hotkey to display menu and so on please. Id like to use this but you have hardly no information posted about it.
     
  5. Code:
    using System.Collections.Generic;
    using UnityEngine;
    using Oxide.Game.Rust.Cui;
    using System;
    using System.Linq;
    using Oxide.Core.Configuration;
    using Oxide.Core;namespace Oxide.Plugins
    {
        [Info("QuickMenu2", "Xianith", "0.0.2", ResourceId = 2419)]    class QuickMenu2 : RustPlugin
        {
            bool QuickMenu2Open = false;        private Dictionary<string, string> UIColors = new Dictionary<string, string>
            {
               {"dark", "0.1 0.1 0.1 0.98" },
               {"blue", "0.16 0.34 0.49 1.0" },
               {"red", "0.56 0.20 0.15 1.0" },
               {"green", "0.31 0.37 0.20 1.0" },
               {"grey", "0.34 0.34 0.34 1.0" },
               {"lightblue", "0.56 0.74 0.89 1.0" },
               {"lightgreen", "0.60 0.70 0.51 1.0" },
               {"lightred", "0.96 0.60 0.55 1.0" }
            };        #region Config
            private bool Changed = false;        private string QuickMenu2Key;        private string TopButtonColor;
            private string TopButtonFontColor;
            private string TopButtonText;
            private string TopButtonCommand;        private string MiddleButtonColor;
            private string MiddleButtonFontColor;
            private string MiddleButtonText;
            private string MiddleButtonCommand;
           
            private string newButtonColor;
            private string newButtonFontColor;
            private string newButtonText;
            private string newButtonCommand;
           
            private string fButtonColor;
            private string fButtonFontColor;
            private string fButtonText;
            private string fButtonCommand;        private string BottomButtonColor;
            private string BottomButtonFontColor;
            private string BottomButtonText;
            private string BottomButtonCommand;
           
            private string textButtonColor;
            private string textButtonFontColor;
            private string textButtonText;
            private string textButtonCommand;        private object GetConfig(string menu, string datavalue, object defaultValue)
            {
                var data = Config[menu] as Dictionary<string, object>;
                if (data == null)
                {
                    data = new Dictionary<string, object>();
                    Config[menu] = data;
                    Changed = true;
                }
                object value;
                if (!data.TryGetValue(datavalue, out value))
                {
                    value = defaultValue;
                    data[datavalue] = value;
                    Changed = true;
                }
                return value;
            }
           
            void LoadVariables()
            {
                QuickMenu2Key = Convert.ToString(GetConfig("Settings", "Hot key", "f6"));
                TopButtonColor = Convert.ToString(GetConfig("Top Button", "Color", "green"));
                TopButtonText = Convert.ToString(GetConfig("Top Button", "Text", "Trade Accept"));
                TopButtonCommand = Convert.ToString(GetConfig("Top Button", "Command", "/trade accept"));
                MiddleButtonColor = Convert.ToString(GetConfig("Middle Button", "Color", "blue"));
                MiddleButtonText = Convert.ToString(GetConfig("Middle Button", "Text", "Teleport Cancel"));
                MiddleButtonCommand = Convert.ToString(GetConfig("Middle Button", "Command", "/tpc"));
                BottomButtonColor = Convert.ToString(GetConfig("Bottom Button", "Color", "red"));
                BottomButtonText = Convert.ToString(GetConfig("Bottom Button", "Text", "Remover"));
                BottomButtonCommand = Convert.ToString(GetConfig("Bottom Button", "Command", "/remove")); newButtonColor = Convert.ToString(GetConfig("new Button", "Color", "blue"));
                newButtonText = Convert.ToString(GetConfig("new Button", "Text", "Teleport Cancel"));
                newButtonCommand = Convert.ToString(GetConfig("new Button", "Command", "/tpc"));
                fButtonColor = Convert.ToString(GetConfig("f Button", "Color", "blue"));
                fButtonText = Convert.ToString(GetConfig("f Button", "Text", "Teleport Cancel"));
                fButtonCommand = Convert.ToString(GetConfig("f Button", "Command", "/tpc"));
                textButtonColor = Convert.ToString(GetConfig("text Button", "Color", "blue"));
                textButtonText = Convert.ToString(GetConfig("text Button", "Text", "Teleport Cancel"));
                textButtonCommand = Convert.ToString(GetConfig("text Button", "Command", "/tpc"));
               
                if (!Changed) return;
                SaveConfig();
                Changed = false;
            }        protected override void LoadDefaultConfig()
            {
                Config.Clear();
                LoadVariables();
            }        private void Loaded()
            {
                LoadVariables();
            }
            #endregion Config        private void OnPlayerInit(BasePlayer player)
            {
                if (player != null)
                {
                    player.Command($"bind {QuickMenu2Key} \"UI_QuickMenu2\"");
                }
            }        public void QuickMenu2GuiCreate(BasePlayer player)
            {
                if (player == null)
                    return;            var QuickMenu2Elements = new CuiElementContainer();
                var quickMain = QuickMenu2Elements.Add(new CuiPanel
                {
                    Image = { Color = UIColors["dark"] },
                    RectTransform = { AnchorMin = "0.40 0.25", AnchorMax = "0.59 0.80" },
                    CursorEnabled = true,
                }, "Overlay", "QuickMenu2");            // Cancel Button
                QuickMenu2Elements.Add(new CuiButton
                {
                    Button = { Command = $"UI_QuickMenu2", Color = UIColors["grey"] },
                    RectTransform = { AnchorMin = "0.02 0.025", AnchorMax = "0.97 0.15" },
                    Text = { Text = "ЗАКРЫТЬ", FontSize = 15, Align = TextAnchor.MiddleCenter }
                }, quickMain);            // Bottom Button
                QuickMenu2Elements.Add(new CuiButton
                {
                    Button = { Command = $"UI_QuickMenu2_Cmd {BottomButtonCommand}", Color = UIColors[$"{BottomButtonColor}"] },
                    RectTransform = { AnchorMin = "0.02 0.16", AnchorMax = "0.97 0.25" },
                    Text = { Color = UIColors[$"light{BottomButtonColor}"], Text = $"{BottomButtonText}", FontSize = 15, Align = TextAnchor.MiddleCenter }
                }, quickMain);
               
                // f Button
                QuickMenu2Elements.Add(new CuiButton
                {
                    Button = { Command = $"UI_QuickMenu2_Cmd {fButtonCommand}", Color = UIColors[$"{fButtonColor}"] },
                    RectTransform = { AnchorMin = "0.02 0.56", AnchorMax = "0.97 0.65" },
                    Text = { Color = UIColors[$"light{fButtonColor}"], Text = $"{fButtonText}", FontSize = 15, Align = TextAnchor.MiddleCenter }
                }, quickMain);
               
                // text Button
                QuickMenu2Elements.Add(new CuiButton
                {
                    Button = { Command = $"UI_QuickMenu2_Cmd {textButtonCommand}", Color = UIColors[$"{textButtonColor}"] },
                    RectTransform = { AnchorMin = "0.02 0.67", AnchorMax = "0.97 0.97" },
                    Text = { Color = UIColors[$"light{textButtonColor}"], Text = $"{textButtonText}", FontSize = 15, Align = TextAnchor.MiddleCenter }
                }, quickMain);            // Middle Button
                QuickMenu2Elements.Add(new CuiButton
                {
                    Button = { Command = $"UI_QuickMenu2_Cmd {MiddleButtonCommand}", Color = UIColors[$"{MiddleButtonColor}"] },
                    RectTransform = { AnchorMin = "0.02 0.26", AnchorMax = "0.97 0.35" },
                    Text = { Color = UIColors[$"light{MiddleButtonColor}"], Text = $"{MiddleButtonText}", FontSize = 15, Align = TextAnchor.MiddleCenter }
                }, quickMain);
               
                // new Button
                QuickMenu2Elements.Add(new CuiButton
                {
                    Button = { Command = $"UI_QuickMenu2_Cmd {newButtonCommand}", Color = UIColors[$"{newButtonColor}"] },
                    RectTransform = { AnchorMin = "0.02 0.46", AnchorMax = "0.97 0.55" },
                    Text = { Color = UIColors[$"light{newButtonColor}"], Text = $"{newButtonText}", FontSize = 15, Align = TextAnchor.MiddleCenter }
                }, quickMain);            // Top Button
                QuickMenu2Elements.Add(new CuiButton
                {
                    Button = { Command = $"UI_QuickMenu2_Cmd {TopButtonCommand}", Color = UIColors[$"{TopButtonColor}"] },
                    RectTransform = { AnchorMin = "0.02 0.36", AnchorMax = "0.97 0.45" },
                    Text = { Color = UIColors[$"light{TopButtonColor}"], Text = $"{TopButtonText}", FontSize = 15, Align = TextAnchor.MiddleCenter }
                }, quickMain);
                CuiHelper.AddUi(player, QuickMenu2Elements);        }        #region Commands
             [ChatCommand("qm2")]
                void cmdQuickMenu2(BasePlayer player, string command, string[] args)
                {
                      QuickMenu2Open = true;
                      QuickMenu2GuiCreate(player);
                }
               
            [ConsoleCommand("UI_QuickMenu2")]
                private void cmdUI_QuickMenu2(ConsoleSystem.Arg arg)
                {
                    var player = arg.Connection.player as BasePlayer;
                    if (player == null)
                        return;                if (!QuickMenu2Open)
                    {
                        QuickMenu2Open = true;
                        QuickMenu2GuiCreate(player);
                    }
                    else
                    {
                        CuiHelper.DestroyUi(player, "QuickMenu2");
                        QuickMenu2Open = false;
                    }
                }        [ConsoleCommand("UI_QuickMenu2_Cmd")]
                private void cmdUI_QuickMenu2_Cmd(ConsoleSystem.Arg arg)
                {
                    var cmd = "";
                    var player = arg.Connection.player as BasePlayer;
                    if (player == null)
                        return;                CuiHelper.DestroyUi(player, "QuickMenu2");
                    QuickMenu2Open = false;               cmd = string.Join(" ", arg.Args.Skip(0).ToArray());
                   rust.RunClientCommand(player, $"chat.say", cmd);
                }
            #endregion
        }
    }
    
    Я Расщепление
    связать J UI_QuickMenu2
    привязывать ч UI_QuickMenu

    Если нажать ч / J быстро, панель не закрывается
     
  6. I got a question(may be request - call it whatever you want) - as far as I know binding keys thro polugins doesn't work right now - so... can you add chat command or something to open this menu?
     
  7. bind h UI_QuickMenu
    /qm
     
  8. Surly - you can do it manually. But do you really expect all players to do it? They just wont give a....let's say nothing about it =)
     
  9. Code:
    [ChatCommand("qm2")]
                void cmdQuickMenu2(BasePlayer player, string command, string[] args)
                {
                      QuickMenu2Open = true;
                      QuickMenu2GuiCreate(player);
                }

    Sorry if I do not understand something. I do not understand English well
     
  10. Oh, lol. There is nothing about it in the plugin description. Gonna check all the code, and may be do something usefull about it)
     
  11. Ok, so @Xianith - I got something for you =D
    Here is my patch for your plugin - PATCH (sorry, for some reason I still can't make attachments @Wulf? Can you tell me why and then I'll be able to?)
    What have I done:
    1. Added new Help button - always on player screen, pressing it will open menu. Fully configuratable thro the config file. Even it's position on screen.
    2. Changed your strange way of handling colors to a brand new one - now your users able to pick any color from UIColors.
    3. Added 2 new colors - Gold and Deepping. Check out THIS resource - it's really usefull =3
    4. Fixed bug related to the plugins restart - menu use to bugged, so after plugin restart every player, who has menu open have to disconnect from server.
    5. Everything related to the binds are now commented untill the devs would do something about it.
    Also - add /qm command to the owerview, cos there is no way to find this command but look thro source code.
     
  12. Keybindings can not be set by the server anymore... good luck

    I'm still working on adding in multiple configurable buttons. A full menu was never the intention of QuickMenu... so I won't be exceeding like 12 buttons but will look into making more if possible / desired.
     
    Last edited by a moderator: Apr 27, 2017
  13. Good luck with what? I'm not talking about binding, I'm talking about plugin itself. Check out what I've done. At least the color part.
    P.S. I got to ask - why did you make quickMenuOpen just a bool value? So what If one player opens the menu. It would be set to true. But then another player tries to open it - it's already true, so he won't see a menu. Correct me if I'm wrong, but it should be Dictionary<BasePlayer, bool> and should be stored for each player
     
    Last edited by a moderator: Apr 27, 2017
  14. I haven't run into any issues while it was a bool. I thought CUI elements were per client base regardless. Anywho, thanks for the patch. I've been hella busy lately hence why no patch.

    As of right now I updated the descript to include the /qm command.
     
  15. Xianith updated Quick Menu with a new update entry:

    0.0.5

     
  16. Don't working plugin!!!
     
  17. What Do you mean? What exacly doesn't work?
    Ok, so @Xianith, once again - insted of checking color as a string for every color you can use something like this:
    Code:
    if(!UIColors.ContainsKey(TopButtonColor))
                    TopButtonColor = "grey";
    So the users would be able to set any colors from UIColors. Why do you checking every color as a string? You already got all available colors in the dictionary.
    Also - in your case you can use Dictionary<ulong, bool> insted of Dictionary<ulong, screen> with custom class screen. I just don't see the reason. You also could just create a list with players, who have qui opened. If they are in the list - qui is opend. If they aren't - qui closed.
     
    Last edited by a moderator: Apr 28, 2017
  18. Because I like being difficult ;P

    And I code at like 11 when I'm realllly tired and aren't thinking straight.

    Let me fix this up. I think I'll go with the list approach because a bool isn't needed.
     
  19. Xianith updated Quick Menu with a new update entry:

    0.0.6


    [DOUBLEPOST=1493385192][/DOUBLEPOST]
    Don't hate me but I kept the QuickMenuInfo dictionary in :X I think I'll be using it in a further update when I introduce a clever version of your help button that I was working on a couple of months ago.
     
  20. Oook... that's even worse. What is "custom" color? Why are you always assigning the new value to the UIColors? You have to check if color are typed correctly. You don't have to assign the user color to the custom every time, why do so?
    Step 2 - You are only adding QuickMenuInfo on the plugin load, but what if the player joins after the plugin was loaded? You are already adding players there on the command run. You have to chose - adding all existing players on load and on join, or on command run. Right now you have it kinda both, wich is usless.