private void OnBuildingSelected(BuildingDef def) { if (!selecting) { selecting = true; selectedBuilding = def; buildingsScreen.SetHasFocus(false); foreach (KeyValuePair <HashedString, BuildMenuCategoriesScreen> submenu in submenus) { BuildMenuCategoriesScreen value = submenu.Value; value.SetHasFocus(false); } ToolMenu.Instance.ClearSelection(); if ((UnityEngine.Object)def != (UnityEngine.Object)null) { Vector2 anchoredPosition = productInfoScreen.rectTransform().anchoredPosition; RectTransform rectTransform = buildingsScreen.rectTransform(); Vector2 anchoredPosition2 = rectTransform.anchoredPosition; anchoredPosition.y = anchoredPosition2.y; Vector2 anchoredPosition3 = rectTransform.anchoredPosition; float x = anchoredPosition3.x; Vector2 sizeDelta = rectTransform.sizeDelta; anchoredPosition.x = x + sizeDelta.x + 10f; productInfoScreen.rectTransform().anchoredPosition = anchoredPosition; productInfoScreen.ClearProduct(false); productInfoScreen.Show(true); productInfoScreen.ConfigureScreen(def); } else { productInfoScreen.Close(); } selecting = false; } }
private void PositionMenus() { foreach (KeyValuePair <HashedString, BuildMenuCategoriesScreen> submenu in submenus) { HashedString key = submenu.Key; BuildMenuCategoriesScreen value = submenu.Value; LayoutGroup component = value.GetComponent <LayoutGroup>(); Vector2 anchoredPosition; PadInfo padInfo; if (key == ROOT_HASHSTR) { anchoredPosition = rootMenuOffset; padInfo = rootMenuPadding; Image component2 = value.GetComponent <Image>(); component2.enabled = false; } else { anchoredPosition = nestedMenuOffset; padInfo = nestedMenuPadding; } value.rectTransform().anchoredPosition = anchoredPosition; component.padding.left = padInfo.left; component.padding.right = padInfo.right; component.padding.top = padInfo.top; component.padding.bottom = padInfo.bottom; } buildingsScreen.rectTransform().anchoredPosition = buildingsMenuOffset; }
public void Refresh() { foreach (KeyValuePair <HashedString, BuildMenuCategoriesScreen> submenu in submenus) { BuildMenuCategoriesScreen value = submenu.Value; value.UpdateBuildableStates(true); } }
private void UpdateNotifications(ICollection <HashedString> updated_categories, object data) { foreach (KeyValuePair <HashedString, BuildMenuCategoriesScreen> submenu in submenus) { BuildMenuCategoriesScreen value = submenu.Value; value.UpdateNotifications(updated_categories); } }
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); }
private void OnCategoryClicked(HashedString new_category, int depth) { while (submenuStack.Count > depth) { KIconToggleMenu kIconToggleMenu = submenuStack.Pop(); kIconToggleMenu.ClearSelection(); kIconToggleMenu.Close(); } productInfoScreen.Close(); if (new_category != selectedCategory && new_category.IsValid) { foreach (KIconToggleMenu item in submenuStack) { if (item is BuildMenuCategoriesScreen) { BuildMenuCategoriesScreen buildMenuCategoriesScreen = item as BuildMenuCategoriesScreen; buildMenuCategoriesScreen.SetHasFocus(false); } } selectedCategory = new_category; submenus.TryGetValue(new_category, out BuildMenuCategoriesScreen value); if ((UnityEngine.Object)value != (UnityEngine.Object)null) { value.Show(true); value.SetHasFocus(true); submenuStack.Push(value); } } else { selectedCategory = HashedString.Invalid; } foreach (KIconToggleMenu item2 in submenuStack) { if (item2 is BuildMenuCategoriesScreen) { (item2 as BuildMenuCategoriesScreen).UpdateBuildableStates(true); } } submenus[ROOT_HASHSTR].UpdateBuildableStates(true); }
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(); }