private void OnHudReady() { hudCategory = new HudAPIv2.MenuRootCategory("Tool Switcher", HudAPIv2.MenuRootCategory.MenuFlag.PlayerMenu, "Tool Switcher"); modEnabledInput = new HudAPIv2.MenuItem("Mod Enabled - " + ModEnabled, hudCategory, OnModEnabledSubmit); toolsCat = new HudAPIv2.MenuSubCategory("Tools", hudCategory, "Tools"); if (modTools.Count == 0) { vanillaToolCat = toolsCat; } else { vanillaToolCat = new HudAPIv2.MenuSubCategory("Vanilla", toolsCat, "Vanilla Tools"); } welder.Menu = new ToolMenu(vanillaToolCat, welder, this); grinder.Menu = new ToolMenu(vanillaToolCat, grinder, this); drill.Menu = new ToolMenu(vanillaToolCat, drill, this); rifle.Menu = new ToolMenu(vanillaToolCat, rifle, this); pistol.Menu = new ToolMenu(vanillaToolCat, pistol, this); launcher.Menu = new ToolMenu(vanillaToolCat, launcher, this); HudAPIv2.MenuSubCategory unknownCategory = null; Dictionary <string, HudAPIv2.MenuSubCategory> modToolCats = new Dictionary <string, HudAPIv2.MenuSubCategory>(); for (int i = 0; i < modTools.Count; i++) { ModTool t = modTools[i]; HudAPIv2.MenuCategoryBase c; if (t.ModName == null) { if (unknownCategory == null) { unknownCategory = new HudAPIv2.MenuSubCategory("Mod: Unknown", toolsCat, "Unknown"); } c = unknownCategory; } else { HudAPIv2.MenuSubCategory subC; if (!modToolCats.TryGetValue(t.ModName, out subC)) { subC = new HudAPIv2.MenuSubCategory("Mod: " + t.ModName, toolsCat, t.ModName); modToolCats[t.ModName] = subC; } c = subC; } t.Menu = new ToolMenu(c, t, this); } this.modToolCats = modToolCats.Values.ToList(); equipInput = new HudAPIv2.MenuKeybindInput("Equip All Key - " + ToolSwitcherSession.GetKeyName(EquipAllKey), hudCategory, "Press any key.", OnEquipAllKeySubmit); upgradeInput = new HudAPIv2.MenuKeybindInput("Upgrade Key - " + ToolSwitcherSession.GetKeyName(UpgradeKey), hudCategory, "Press any key.", OnUpgradeKeySubmit); downgradeInput = new HudAPIv2.MenuKeybindInput("Downgrade Key - " + ToolSwitcherSession.GetKeyName(DowngradeKey), hudCategory, "Press any key.", OnDowngradeKeySubmit); }
private void OnDowngradeKeySubmit(MyKeys key, bool shift, bool ctrl, bool alt) { if (!menuEnabled) { return; } DowngradeKey = key; downgradeInput.Text = "Downgrade Key - " + ToolSwitcherSession.GetKeyName(key); Save(); }
private void OnEquipAllKeySubmit(MyKeys key, bool shift, bool ctrl, bool alt) { if (!menuEnabled) { return; } EquipAllKey = key; equipInput.Text = "Equip All Key - " + ToolSwitcherSession.GetKeyName(key); Save(); }
public void ToolEdited(Tool tool, bool?equip = null) { bool toolbar; if (equip.HasValue) { toolbar = equip.Value; } else { toolbar = ToolSwitcherSession.IsToolbarCharacter() && ModEnabled && loaded; } for (int i = groups.Count - 1; i >= 0; i--) { ToolGroup g = groups[i]; if (g.Remove(tool)) { if (g.Count == 0) { groups.RemoveAtFast(i); } else if (toolbar) { g.EquipAny(); } } } for (int i = 0; i < groups.Count; i++) { ToolGroup g = groups[i]; if (g.ShouldContain(tool)) { g.Add(tool); if (toolbar) { tool.Equip(); } return; } } groups.Add(new ToolGroup(tool.Page, tool.Slot, tool)); if (toolbar) { tool.Equip(); } }