예제 #1
0
        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);
        }
예제 #2
0
        public ToolGroups()
        {
            welder = new WelderTool(MyKeys.None, 0, 0);
            ToolEdited(welder, false);
            grinder = new GrinderTool(MyKeys.None, 1, 0);
            ToolEdited(grinder, false);
            drill = new DrillTool(MyKeys.None, 2, 0);
            ToolEdited(drill, false);
            pistol = new PistolTool(MyKeys.None, 3, 0);
            ToolEdited(pistol, false);
            launcher = new LauncherTool(MyKeys.None, 3, 0);
            ToolEdited(launcher, false);
            rifle = new RifleTool(MyKeys.None, 3, 0);
            ToolEdited(rifle, false);


            foreach (MyHandItemDefinition def in MyDefinitionManager.Static.GetHandItemDefinitions())
            {
                if (!def.Context.IsBaseGame)
                {
                    string modName = def.Context.ModName;
                    if (string.IsNullOrWhiteSpace(modName))
                    {
                        if (string.IsNullOrWhiteSpace(def.Context.ModId))
                        {
                            modName = null;
                        }
                        else
                        {
                            modName = def.Context.ModId.Trim();
                        }
                    }
                    else
                    {
                        modName = modName.Trim();
                    }

                    if (modName != null && modName.Length > 30)
                    {
                        modName = modName.Substring(0, 30);
                    }

                    ModTool modTool = new ModTool(MyKeys.None, 0, 0, def.PhysicalItemId, modName);
                    modTools.Add(modTool);
                    ToolEdited(modTool, false);
                }
            }
            serializableTools = modTools.ToArray();

            hud = new HudAPIv2(OnHudReady);
        }