Exemple #1
0
 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;
     }
 }
Exemple #2
0
 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);
 }