public static void AddBuildingToHotkeyBuildMenu(HashedString category, string building_id, Action hotkey)
 {
     BuildMenu.DisplayInfo info = BuildMenu.OrderedBuildings.GetInfo(category);
     if (!(info.category != category))
     {
         IList <BuildMenu.BuildingInfo> list = info.data as IList <BuildMenu.BuildingInfo>;
         list.Add(new BuildMenu.BuildingInfo(building_id, hotkey));
     }
 }
    public void Configure(HashedString category, int depth, object data, Dictionary <HashedString, List <BuildingDef> > categorized_building_map, Dictionary <HashedString, List <HashedString> > categorized_category_map, BuildMenuBuildingsScreen buildings_screen)
    {
        this.category          = category;
        categorizedBuildingMap = categorized_building_map;
        categorizedCategoryMap = categorized_category_map;
        buildingsScreen        = buildings_screen;
        List <ToggleInfo> list = new List <ToggleInfo>();

        if (typeof(IList <BuildMenu.BuildingInfo>).IsAssignableFrom(data.GetType()))
        {
            buildingInfos = (IList <BuildMenu.BuildingInfo>)data;
        }
        else if (typeof(IList <BuildMenu.DisplayInfo>).IsAssignableFrom(data.GetType()))
        {
            subcategories = new List <HashedString>();
            IList <BuildMenu.DisplayInfo> list2 = (IList <BuildMenu.DisplayInfo>)data;
            foreach (BuildMenu.DisplayInfo item2 in list2)
            {
                BuildMenu.DisplayInfo current = item2;
                string iconName = current.iconName;
                string text     = HashCache.Get().Get(current.category).ToUpper();
                text = text.Replace(" ", string.Empty);
                ToggleInfo item = new ToggleInfo(Strings.Get("STRINGS.UI.NEWBUILDCATEGORIES." + text + ".NAME"), iconName, new UserData
                {
                    category          = current.category,
                    depth             = depth,
                    requirementsState = PlanScreen.RequirementsState.Tech
                }, current.hotkey, Strings.Get("STRINGS.UI.NEWBUILDCATEGORIES." + text + ".TOOLTIP"), string.Empty);
                list.Add(item);
                subcategories.Add(current.category);
            }
            Setup(list);
            toggles.ForEach(delegate(KToggle to)
            {
                ImageToggleState[] components = to.GetComponents <ImageToggleState>();
                ImageToggleState[] array      = components;
                foreach (ImageToggleState imageToggleState in array)
                {
                    if ((UnityEngine.Object)imageToggleState.TargetImage.sprite != (UnityEngine.Object)null && imageToggleState.TargetImage.name == "FG" && !imageToggleState.useSprites)
                    {
                        imageToggleState.SetSprites(Assets.GetSprite(imageToggleState.TargetImage.sprite.name + "_disabled"), imageToggleState.TargetImage.sprite, imageToggleState.TargetImage.sprite, Assets.GetSprite(imageToggleState.TargetImage.sprite.name + "_disabled"));
                    }
                }
                to.GetComponent <KToggle>().soundPlayer.Enabled = false;
            });
        }
        UpdateBuildableStates(true);
    }
Пример #3
0
 private static void AddBindings(HashedString parent_category, BuildMenu.DisplayInfo display_info, List <BindingEntry> bindings)
 {
     if (display_info.data != null)
     {
         Type type = display_info.data.GetType();
         if (typeof(IList <BuildMenu.DisplayInfo>).IsAssignableFrom(type))
         {
             IList <BuildMenu.DisplayInfo> list = (IList <BuildMenu.DisplayInfo>)display_info.data;
             foreach (BuildMenu.DisplayInfo item2 in list)
             {
                 AddBindings(display_info.category, item2, bindings);
             }
         }
         else if (typeof(IList <BuildMenu.BuildingInfo>).IsAssignableFrom(type))
         {
             string       str      = HashCache.Get().Get(parent_category);
             TextInfo     textInfo = new CultureInfo("en-US", false).TextInfo;
             string       group    = textInfo.ToTitleCase(str) + " Menu";
             BindingEntry item     = new BindingEntry(group, GamepadButton.NumButtons, display_info.keyCode, Modifier.None, display_info.hotkey, true, true);
             bindings.Add(item);
         }
     }
 }