コード例 #1
0
    private BuildMenuCategoriesScreen CreateCategorySubMenu(HashedString category, int depth, object data, Dictionary <HashedString, List <BuildingDef> > categorized_building_map, Dictionary <HashedString, List <HashedString> > categorized_category_map, Dictionary <Tag, HashedString> tag_category_map, BuildMenuBuildingsScreen buildings_screen)
    {
        BuildMenuCategoriesScreen buildMenuCategoriesScreen = Util.KInstantiateUI <BuildMenuCategoriesScreen>(categoriesMenuPrefab.gameObject, base.gameObject, true);

        buildMenuCategoriesScreen.Show(false);
        buildMenuCategoriesScreen.Configure(category, depth, data, categorizedBuildingMap, categorizedCategoryMap, buildingsScreen);
        BuildMenuCategoriesScreen buildMenuCategoriesScreen2 = buildMenuCategoriesScreen;

        buildMenuCategoriesScreen2.onCategoryClicked = (Action <HashedString, int>)Delegate.Combine(buildMenuCategoriesScreen2.onCategoryClicked, new Action <HashedString, int>(OnCategoryClicked));
        buildMenuCategoriesScreen.name = "BuildMenu_" + category.ToString();
        return(buildMenuCategoriesScreen);
    }
コード例 #2
0
    private void Initialize()
    {
        foreach (KeyValuePair <HashedString, BuildMenuCategoriesScreen> submenu in submenus)
        {
            BuildMenuCategoriesScreen value = submenu.Value;
            value.Close();
            UnityEngine.Object.DestroyImmediate(value.gameObject);
        }
        submenuStack.Clear();
        tagCategoryMap         = new Dictionary <Tag, HashedString>();
        tagOrderMap            = new Dictionary <Tag, int>();
        categorizedBuildingMap = new Dictionary <HashedString, List <BuildingDef> >();
        categorizedCategoryMap = new Dictionary <HashedString, List <HashedString> >();
        int         building_index   = 0;
        DisplayInfo orderedBuildings = OrderedBuildings;

        PopulateCategorizedMaps(orderedBuildings.category, 0, orderedBuildings.data, tagCategoryMap, tagOrderMap, ref building_index, categorizedBuildingMap, categorizedCategoryMap);
        BuildMenuCategoriesScreen buildMenuCategoriesScreen = submenus[ROOT_HASHSTR];

        buildMenuCategoriesScreen.Show(true);
        buildMenuCategoriesScreen.modalKeyInputBehaviour = false;
        foreach (KeyValuePair <HashedString, BuildMenuCategoriesScreen> submenu2 in submenus)
        {
            HashedString key = submenu2.Key;
            if (!(key == ROOT_HASHSTR) && categorizedCategoryMap.TryGetValue(key, out List <HashedString> value2))
            {
                BuildMenuCategoriesScreen value3 = submenu2.Value;
                Image component = value3.GetComponent <Image>();
                if ((UnityEngine.Object)component != (UnityEngine.Object)null)
                {
                    component.enabled = (value2.Count > 0);
                }
            }
        }
        PositionMenus();
    }