public void SetTool(Tool tool) { this.tool = tool; SetCategoryText(); keyInput.Text = "Key - " + ToolSwitcherSession.GetKeyName(tool.Keybind); slotInput.Text = "Slot - " + (tool.Slot + 1); pageInput.Text = "Page - " + (tool.Page + 1); btnEnabled.Text = "Enabled - " + tool.Enabled; }
protected override void UnloadData() { Instance = null; config?.Unload(); MyVisualScriptLogicProvider.ToolbarItemChanged -= ToolbarItemChanged; MyVisualScriptLogicProvider.PlayerDropped -= ItemDropped; MyVisualScriptLogicProvider.PlayerPickedUp -= ItemPickedUp; MyVisualScriptLogicProvider.PlayerSpawned -= PlayerSpawned; MyAPIGateway.Multiplayer.UnregisterSecureMessageHandler(EventPacket.PacketId, EventPacket.Received); equippedTools.Clear(); }
public ToolMenu(HudAPIv2.MenuCategoryBase category, Tool tool, ToolGroups config) { this.tool = tool; this.config = config; toolCategory = new HudAPIv2.MenuSubCategory("", category, tool.Name); SetCategoryText(); keyInput = new HudAPIv2.MenuKeybindInput("Key - " + ToolSwitcherSession.GetKeyName(tool.Keybind), toolCategory, "Press any key.", OnKeySubmit); slotInput = new HudAPIv2.MenuTextInput("Slot - " + (tool.Slot + 1), toolCategory, "Enter a slot number 1-9.", OnSlotSubmit); pageInput = new HudAPIv2.MenuTextInput("Page - " + (tool.Page + 1), toolCategory, "Enter a page number 1-9.", OnPageSubmit); btnEnabled = new HudAPIv2.MenuItem("Enabled - " + tool.Enabled, toolCategory, OnEnabledSubmit); }
private void OnKeySubmit(MyKeys key, bool shift, bool ctrl, bool alt) { if (!interactable) { return; } tool.Keybind = key; config.Save(); keyInput.Text = "Key - " + ToolSwitcherSession.GetKeyName(key); }
public override void LoadData() { Instance = this; }