Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- QuickMenu.cs Thu Apr 27 02:44:12 2017
- +++ QuickMenu_new.cs Thu Apr 27 02:42:35 2017
- @@ -8,7 +8,7 @@
- namespace Oxide.Plugins
- {
- - [Info("QuickMenu", "Xianith", "0.0.4", ResourceId = 2419)]
- + [Info("QuickMenu", "Xianith. Edited by Vlad-00003", "0.0.6")]
- class QuickMenu : RustPlugin
- {
- @@ -19,18 +19,21 @@
- 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" },
- - {"lightgrey", "1 1 1 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" }
- + {"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" },
- + {"lightgrey", "1 1 1 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" },
- + {"deeppink", "1 0.078 0.576 1.0" },
- + {"gold", "1 0.843 0 1.0"}
- };
- - private string quickMenuKey;
- + //private string quickMenuKey;
- + private Dictionary<BasePlayer, string> HelpButtons = new Dictionary<BasePlayer, string>();
- private string TopButtonColor;
- private string TopButtonFontColor;
- @@ -57,6 +60,11 @@
- private string BottomButtonText;
- private string BottomButtonCommand;
- + private string HelpButtonColor;
- + private string HelpButtonText;
- + private string HelpButtonAnchorMax;
- + private string HelpButtonAnchorMin;
- +
- private object GetConfig(string menu, string datavalue, object defaultValue)
- {
- var data = Config[menu] as Dictionary<string, object>;
- @@ -79,7 +87,7 @@
- void LoadVariables()
- {
- - quickMenuKey = Convert.ToString(GetConfig("Settings", "Hot key", "f6"));
- + //quickMenuKey = 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", "chat.say /trade accept"));
- @@ -93,18 +101,26 @@
- BottomButtonText = Convert.ToString(GetConfig("Bottom Button", "Text", "CANCEL"));
- // BottomButtonCommand = Convert.ToString(GetConfig("Bottom Button", "Command", "UI_QuickMenu"));
- - if (TopButtonColor != "green" && TopButtonColor != "red" && TopButtonColor != "blue")
- + HelpButtonColor = Convert.ToString(GetConfig("Help button", "Color", "red"));
- + HelpButtonText = Convert.ToString(GetConfig("Help button", "Text", "Open quick menu"));
- + HelpButtonAnchorMax = Convert.ToString(GetConfig("Help button", "Anchor Max", "0.75 0.108"));
- + HelpButtonAnchorMin = Convert.ToString(GetConfig("Help button", "Anchor Min", "0.644 0.025"));
- +
- + if(!UIColors.ContainsKey(TopButtonColor))
- TopButtonColor = "grey";
- -
- - if (MidTopButtonColor != "green" && MidTopButtonColor != "red" && MidTopButtonColor != "blue")
- +
- + if (!UIColors.ContainsKey(MidTopButtonColor))
- MidTopButtonColor = "grey";
- -
- - if (MidBottomButtonColor != "green" && MidBottomButtonColor != "red" && MidBottomButtonColor != "blue")
- +
- + if (!UIColors.ContainsKey(MidBottomButtonColor))
- MidBottomButtonColor = "grey";
- - if (BottomButtonColor != "green" && BottomButtonColor != "red" && BottomButtonColor != "blue")
- + if (!UIColors.ContainsKey(BottomButtonColor))
- BottomButtonColor = "grey";
- -
- +
- + if (!UIColors.ContainsKey(HelpButtonColor))
- + HelpButtonColor = "grey";
- +
- if (!Changed) return;
- SaveConfig();
- Changed = false;
- @@ -129,7 +145,8 @@
- {
- foreach (BasePlayer player in BasePlayer.activePlayerList)
- {
- - player.Command($"bind {quickMenuKey} \"UI_QuickMenu\"");
- + //player.Command($"bind {quickMenuKey} \"UI_QuickMenu\"");
- + AddHelpButton(player);
- }
- }
- @@ -137,24 +154,77 @@
- {
- foreach (BasePlayer player in BasePlayer.activePlayerList)
- {
- - player.Command($"bind {quickMenuKey} \"UI_QuickMenu\"");
- + //player.Command($"bind {quickMenuKey} \"UI_QuickMenu\"");
- + if (HelpButtons.ContainsKey(player))
- + {
- + CuiHelper.DestroyUi(player, HelpButtons[player]);
- + CuiHelper.DestroyUi(player, "quickMenu");
- + }
- }
- }
- + void Unload()
- + {
- + HotKeyUnbind();
- + }
- private void OnPlayerInit(BasePlayer player)
- {
- - if (player != null)
- + //if (player != null)
- + //{
- + // player.Command($"bind {quickMenuKey} \"UI_QuickMenu\"");
- + //}
- + if (player == null)
- + return;
- +
- + if (player.HasPlayerFlag(BasePlayer.PlayerFlags.ReceivingSnapshot))
- {
- - player.Command($"bind {quickMenuKey} \"UI_QuickMenu\"");
- + timer.Once(2, () => OnPlayerInit(player));
- + return;
- }
- + AddHelpButton(player);
- }
- private void OnPlayerDisconnected(BasePlayer player)
- {
- - player.Command($"bind {quickMenuKey} \"UI_QuickMenu\"");
- + //player.Command($"bind {quickMenuKey} \"UI_QuickMenu\"");
- + if (HelpButtons.ContainsKey(player))
- + {
- + CuiHelper.DestroyUi(player, HelpButtons[player]);
- + }
- + CuiHelper.DestroyUi(player, "quickMenu");
- }
- #endregion Binding
- -
- + private void AddHelpButton(BasePlayer player)
- + {
- + CuiElementContainer main = new CuiElementContainer();
- + var button = new CuiButton
- + {
- + Button =
- + {
- + Command = "UI_QuickMenu",
- + Color = UIColors[$"{HelpButtonColor}"]
- + },
- + RectTransform =
- + {
- + AnchorMin = HelpButtonAnchorMin,
- + AnchorMax = HelpButtonAnchorMax
- + },
- + Text =
- + {
- + Text = HelpButtonText,
- + FontSize = 14,
- + Align = TextAnchor.MiddleCenter
- + }
- + };
- + var HelpButtonName = main.Add(button);
- + if (HelpButtons.ContainsKey(player))
- + {
- + CuiHelper.DestroyUi(player, HelpButtons[player]);
- + HelpButtons.Remove(player);
- + }
- + CuiHelper.AddUi(player, main);
- + HelpButtons.Add(player, HelpButtonName);
- + }
- public void QuickMenuGuiCreate(BasePlayer player)
- {
- if (player == null)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement