コード例 #1
0
    private void UpdateBuildingButtonList(ToggleInfo toggle_info)
    {
        KToggle toggle = toggle_info.toggle;

        if ((UnityEngine.Object)toggle == (UnityEngine.Object)null)
        {
            foreach (ToggleInfo item in toggleInfo)
            {
                if (item.userData == toggle_info.userData)
                {
                    toggle = item.toggle;
                }
            }
        }
        int num = 2;

        if ((UnityEngine.Object)toggle != (UnityEngine.Object)null && ActiveToggles.Count != 0)
        {
            for (int i = 0; i < num; i++)
            {
                if (building_button_refresh_idx >= ActiveToggles.Count)
                {
                    building_button_refresh_idx = 0;
                }
                RefreshBuildingButton(ActiveToggles.ElementAt(building_button_refresh_idx).Key, ActiveToggles.ElementAt(building_button_refresh_idx).Value, (HashedString)toggle_info.userData);
                building_button_refresh_idx++;
            }
        }
        if (productInfoScreen.gameObject.activeSelf)
        {
            productInfoScreen.materialSelectionPanel.UpdateResourceToggleValues();
        }
    }
    private void OnClickCategory(ToggleInfo toggle_info)
    {
        UserData userData = (UserData)toggle_info.userData;

        PlanScreen.RequirementsState requirementsState = userData.requirementsState;
        if (requirementsState == PlanScreen.RequirementsState.Complete || requirementsState == PlanScreen.RequirementsState.Materials)
        {
            if (selectedCategory != userData.category)
            {
                selectedCategory = userData.category;
                KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click", false));
            }
            else
            {
                selectedCategory = HashedString.Invalid;
                ClearSelection();
                KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click_Deselect", false));
            }
        }
        else
        {
            selectedCategory = HashedString.Invalid;
            ClearSelection();
            KMonoBehaviour.PlaySound(GlobalAssets.GetSound("Negative", false));
        }
        toggle_info.toggle.GetComponent <PlanCategoryNotifications>().ToggleAttention(false);
        if (onCategoryClicked != null)
        {
            onCategoryClicked(selectedCategory, userData.depth);
        }
    }
コード例 #3
0
    public void Refresh()
    {
        List <ToggleInfo> list = new List <ToggleInfo>();

        if (tagCategoryMap == null)
        {
            int building_index = 0;
            tagCategoryMap = new Dictionary <Tag, HashedString>();
            tagOrderMap    = new Dictionary <Tag, int>();
            if (TUNING.BUILDINGS.PLANORDER.Count > 12)
            {
                DebugUtil.LogWarningArgs("Insufficient keys to cover root plan menu", "Max of 12 keys supported but TUNING.BUILDINGS.PLANORDER has " + TUNING.BUILDINGS.PLANORDER.Count);
            }
            toggleEntries.Clear();
            for (int i = 0; i < TUNING.BUILDINGS.PLANORDER.Count; i++)
            {
                PlanInfo   planInfo   = TUNING.BUILDINGS.PLANORDER[i];
                Action     hotkey     = (Action)((i >= 12) ? 247 : (36 + i));
                string     icon       = iconNameMap[planInfo.category];
                string     str        = HashCache.Get().Get(planInfo.category).ToUpper();
                ToggleInfo toggleInfo = new ToggleInfo(UI.StripLinkFormatting(Strings.Get("STRINGS.UI.BUILDCATEGORIES." + str + ".NAME")), icon, planInfo.category, hotkey, Strings.Get("STRINGS.UI.BUILDCATEGORIES." + str + ".TOOLTIP"), string.Empty);
                list.Add(toggleInfo);
                PopulateOrderInfo(planInfo.category, planInfo.data, tagCategoryMap, tagOrderMap, ref building_index);
                List <BuildingDef> list2 = new List <BuildingDef>();
                foreach (BuildingDef buildingDef in Assets.BuildingDefs)
                {
                    HashedString value;
                    if (!buildingDef.Deprecated && tagCategoryMap.TryGetValue(buildingDef.Tag, out value) && !(value != planInfo.category))
                    {
                        list2.Add(buildingDef);
                    }
                }
                toggleEntries.Add(new ToggleEntry(toggleInfo, planInfo.category, list2, planInfo.hideIfNotResearched));
            }
            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;
            });
            for (int j = 0; j < toggleEntries.Count; j++)
            {
                ToggleEntry value2 = toggleEntries[j];
                value2.CollectToggleImages();
                toggleEntries[j] = value2;
            }
        }
    }
コード例 #4
0
ファイル: SignInPanel.cs プロジェクト: ocy1011/Capstone
    ToggleInfo Toggle(Transform parent, string text)
    {
        Transform newToggle = Instantiate(toggle);

        newToggle.SetParent(parent);
        newToggle.GetChild(1).GetComponent <Text>().text = text;
        ToggleInfo toggleInfo = newToggle.GetComponent <ToggleInfo>();

        return(toggleInfo);
    }
コード例 #5
0
 private void OnToggleSelect(ToggleInfo toggle_info)
 {
     if (SimDebugView.Instance.GetMode() == ((OverlayToggleInfo)toggle_info).simView)
     {
         OverlayScreen.Instance.ToggleOverlay(OverlayModes.None.ID, true);
     }
     else if (((OverlayToggleInfo)toggle_info).IsUnlocked())
     {
         OverlayScreen.Instance.ToggleOverlay(((OverlayToggleInfo)toggle_info).simView, true);
     }
 }
コード例 #6
0
ファイル: ToggleGroupInfo.cs プロジェクト: ocy1011/Capstone
    public int ActiveToggle()
    {
        ToggleInfo toggle = toggleList.Find(a => a.isOn == true);

        if (toggle == null)
        {
            SelectToggle(0);
            return(0);
        }
        else
        {
            return(toggleList.Find(a => a.isOn == true).id);
        }
    }
コード例 #7
0
 private void CloseCategoryPanel(bool playSound = true)
 {
     activeCategoryInfo = null;
     if (playSound)
     {
         KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click_Close", false));
     }
     buildingGroupsRoot.GetComponent <ExpandRevealUIContent>().Collapse(delegate
     {
         ClearButtons();
         buildingGroupsRoot.gameObject.SetActive(false);
     });
     PlanCategoryLabel.text = string.Empty;
 }
コード例 #8
0
    private void OpenCategoryPanel(ToggleInfo toggle_info, bool play_sound = true)
    {
        HashedString plan_category = (HashedString)toggle_info.userData;

        ClearButtons();
        buildingGroupsRoot.gameObject.SetActive(true);
        activeCategoryInfo = toggle_info;
        if (play_sound)
        {
            UISounds.PlaySound(UISounds.Sound.ClickObject);
        }
        BuildButtonList(plan_category, GroupsTransform.gameObject);
        PlanCategoryLabel.text = activeCategoryInfo.text.ToUpper();
        buildingGroupsRoot.GetComponent <ExpandRevealUIContent>().Expand(null);
    }
    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);
    }
コード例 #10
0
ファイル: ToggleGroupInfo.cs プロジェクト: ocy1011/Capstone
 public void SelectToggle(int id)
 {
     for (int i = 0; i < toggleList.Count; i++)
     {
         ToggleInfo nowToggle = toggleList[i];
         if (nowToggle.id == id)
         {
             nowToggle.isOn = true;
         }
         else
         {
             nowToggle.isOn = false;
         }
         nowToggle.Check();
     }
 }
コード例 #11
0
ファイル: SignInPanel.cs プロジェクト: ocy1011/Capstone
 float AgeGroup(Transform parent, float yMax)
 {
     ageGroup = GroupInfo(parent, "연령대", yMax);
     yMax    -= titleHeight;
     for (int i = 0; i < 7; i++)
     {
         string text = "선택 안 함";
         if (i == 1)
         {
             text = "20대 미만";
         }
         if (i == 2)
         {
             text = "20대";
         }
         if (i == 3)
         {
             text = "30대";
         }
         if (i == 4)
         {
             text = "40대";
         }
         if (i == 5)
         {
             text = "50대";
         }
         if (i == 6)
         {
             text = "60대 이상";
         }
         ToggleInfo toggleInfo = Toggle(parent, text);
         toggleInfo.toggleGroup = ageGroup;
         toggleInfo.id          = i;
         RectTransform rectTransform = toggleInfo.GetComponent <RectTransform>();
         float         yMin          = yMax - toggleHeight;
         rectTransform = AnchorChange(rectTransform, new Vector2(0, yMin), new Vector2(1 / 3f, yMax));
         yMax          = yMin;
     }
     return(yMax);
 }
コード例 #12
0
 private void RefreshButtons()
 {
     foreach (KToggle toggle in toggles)
     {
         if ((Object)toggle != (Object)null)
         {
             Object.Destroy(toggle.gameObject);
         }
     }
     toggles.Clear();
     if (this.toggleInfo != null)
     {
         Transform parent = (!((Object)toggleParent != (Object)null)) ? base.transform : toggleParent;
         for (int i = 0; i < this.toggleInfo.Count; i++)
         {
             int        idx        = i;
             ToggleInfo toggleInfo = this.toggleInfo[i];
             if (toggleInfo == null)
             {
                 toggles.Add(null);
             }
             else
             {
                 KToggle kToggle = Object.Instantiate(prefab, Vector3.zero, Quaternion.identity);
                 kToggle.gameObject.name = "Toggle:" + toggleInfo.text;
                 kToggle.transform.SetParent(parent, false);
                 kToggle.group    = group;
                 kToggle.onClick += delegate
                 {
                     OnClick(idx);
                 };
                 Text text = kToggle.GetComponentsInChildren <Text>(true)[0];
                 text.text         = toggleInfo.text;
                 toggleInfo.toggle = kToggle;
                 toggles.Add(kToggle);
             }
         }
     }
 }
コード例 #13
0
 private void OnClickCategory(ToggleInfo toggle_info)
 {
     CloseRecipe(false);
     if (!CategoryInteractive.ContainsKey(toggle_info) || !CategoryInteractive[toggle_info])
     {
         CloseCategoryPanel(false);
         KMonoBehaviour.PlaySound(GlobalAssets.GetSound("Negative", false));
     }
     else
     {
         if (activeCategoryInfo == toggle_info)
         {
             CloseCategoryPanel(true);
         }
         else
         {
             OpenCategoryPanel(toggle_info, true);
         }
         ConfigurePanelSize();
         SetScrollPoint(0f);
     }
 }
コード例 #14
0
ファイル: SignInPanel.cs プロジェクト: ocy1011/Capstone
 float GenderGroup(Transform parent, float yMax)
 {
     genderGroup = GroupInfo(parent, "성별", yMax);
     yMax       -= titleHeight;
     for (int i = 0; i < 3; i++)
     {
         string text = "선택 안 함";
         if (i == 1)
         {
             text = "여성";
         }
         if (i == 2)
         {
             text = "남성";
         }
         ToggleInfo toggleInfo = Toggle(parent, text);
         toggleInfo.toggleGroup = genderGroup;
         toggleInfo.id          = i;
         RectTransform rectTransform = toggleInfo.GetComponent <RectTransform>();
         rectTransform = AnchorChange(rectTransform, new Vector2(i * 1 / 3f, yMax - toggleHeight), new Vector2((i + 1) * 1 / 3f, yMax));
     }
     return(yMax - toggleHeight);
 }
コード例 #15
0
 public ToggleEntry(ToggleInfo toggle_info, HashedString plan_category, List <BuildingDef> building_defs, bool hideIfNotResearched)
 {
     toggleInfo                = toggle_info;
     planCategory              = plan_category;
     buildingDefs              = building_defs;
     this.hideIfNotResearched  = hideIfNotResearched;
     pendingResearchAttentions = new List <Tag>();
     requiredTechItems         = new List <TechItem>();
     toggleImages              = null;
     foreach (BuildingDef building_def in building_defs)
     {
         TechItem techItem = Db.Get().TechItems.TryGet(building_def.PrefabID);
         if (techItem == null)
         {
             requiredTechItems.Clear();
             break;
         }
         if (!requiredTechItems.Contains(techItem))
         {
             requiredTechItems.Add(techItem);
         }
     }
 }
コード例 #16
0
 public void OnButtonClick(ToggleInfo toggle_info)
 {
     ToggleScreen(ScreenInfoMatch[toggle_info]);
 }
    private void OnClickFabricator(ToggleInfo toggle_info)
    {
        Fabricator fabricator = (Fabricator)toggle_info.userData;

        SelectTool.Instance.Select(fabricator.GetComponent <KSelectable>(), false);
    }
    public void Configure(HashedString category, IList <BuildMenu.BuildingInfo> building_infos)
    {
        ClearButtons();
        SetHasFocus(true);
        List <ToggleInfo> list = new List <ToggleInfo>();
        string            text = HashCache.Get().Get(category).ToUpper();

        text            = text.Replace(" ", string.Empty);
        titleLabel.text = Strings.Get("STRINGS.UI.NEWBUILDCATEGORIES." + text + ".BUILDMENUTITLE");
        foreach (BuildMenu.BuildingInfo building_info in building_infos)
        {
            BuildMenu.BuildingInfo current = building_info;
            BuildingDef            def     = Assets.GetBuildingDef(current.id);
            if (def.ShowInBuildMenu && !def.Deprecated)
            {
                ToggleInfo item = new ToggleInfo(def.Name, new UserData(def, PlanScreen.RequirementsState.Tech), def.HotKey, () => def.GetUISprite("ui", false));
                list.Add(item);
            }
        }
        Setup(list);
        for (int i = 0; i < toggleInfo.Count; i++)
        {
            RefreshToggle(toggleInfo[i]);
        }
        int         num         = 0;
        IEnumerator enumerator2 = gridSizer.transform.GetEnumerator();

        try
        {
            while (enumerator2.MoveNext())
            {
                Transform transform = (Transform)enumerator2.Current;
                if (transform.gameObject.activeSelf)
                {
                    num++;
                }
            }
        }
        finally
        {
            IDisposable disposable;
            if ((disposable = (enumerator2 as IDisposable)) != null)
            {
                disposable.Dispose();
            }
        }
        gridSizer.constraintCount = Mathf.Min(num, 3);
        int     num2      = Mathf.Min(num, gridSizer.constraintCount);
        int     num3      = (num + gridSizer.constraintCount - 1) / gridSizer.constraintCount;
        int     num4      = num2 - 1;
        int     num5      = num3 - 1;
        float   num6      = (float)num2;
        Vector2 cellSize  = gridSizer.cellSize;
        float   num7      = num6 * cellSize.x;
        float   num8      = (float)num4;
        Vector2 spacing   = gridSizer.spacing;
        float   x         = num7 + num8 * spacing.x + (float)gridSizer.padding.left + (float)gridSizer.padding.right;
        float   num9      = (float)num3;
        Vector2 cellSize2 = gridSizer.cellSize;
        float   num10     = num9 * cellSize2.y;
        float   num11     = (float)num5;
        Vector2 spacing2  = gridSizer.spacing;
        Vector2 vector    = new Vector2(x, num10 + num11 * spacing2.y + (float)gridSizer.padding.top + (float)gridSizer.padding.bottom);

        contentSizeLayout.minWidth  = vector.x;
        contentSizeLayout.minHeight = vector.y;
    }
    private void OnClickBuilding(ToggleInfo toggle_info)
    {
        UserData userData = toggle_info.userData as UserData;

        OnSelectBuilding(userData.def);
    }
 private void RefreshToggle(ToggleInfo info)
 {
     if (info != null && !((UnityEngine.Object)info.toggle == (UnityEngine.Object)null))
     {
         UserData    userData = info.userData as UserData;
         BuildingDef def      = userData.def;
         TechItem    techItem = Db.Get().TechItems.TryGet(def.PrefabID);
         bool        flag     = DebugHandler.InstantBuildMode || techItem == null || techItem.IsComplete();
         bool        flag2    = flag || techItem == null || techItem.parentTech.ArePrerequisitesComplete();
         KToggle     toggle   = info.toggle;
         if (toggle.gameObject.activeSelf != flag2)
         {
             toggle.gameObject.SetActive(flag2);
         }
         if (!((UnityEngine.Object)toggle.bgImage == (UnityEngine.Object)null))
         {
             Image  image  = toggle.bgImage.GetComponentsInChildren <Image>()[1];
             Sprite sprite = image.sprite = def.GetUISprite("ui", false);
             image.SetNativeSize();
             image.rectTransform().sizeDelta /= 4f;
             ToolTip component = toggle.gameObject.GetComponent <ToolTip>();
             component.ClearMultiStringTooltip();
             string text   = def.Name;
             string effect = def.Effect;
             if (def.HotKey != Action.NumActions)
             {
                 text = GameUtil.AppendHotkeyString(text, def.HotKey);
             }
             component.AddMultiStringTooltip(text, buildingToolTipSettings.BuildButtonName);
             component.AddMultiStringTooltip(effect, buildingToolTipSettings.BuildButtonDescription);
             LocText componentInChildren = toggle.GetComponentInChildren <LocText>();
             if ((UnityEngine.Object)componentInChildren != (UnityEngine.Object)null)
             {
                 componentInChildren.text = def.Name;
             }
             PlanScreen.RequirementsState requirementsState = BuildMenu.Instance.BuildableState(def);
             ImageToggleState.State       state             = (requirementsState == PlanScreen.RequirementsState.Complete) ? ImageToggleState.State.Inactive : ImageToggleState.State.Disabled;
             state = ((!((UnityEngine.Object)def == (UnityEngine.Object)selectedBuilding) || (requirementsState != PlanScreen.RequirementsState.Complete && !DebugHandler.InstantBuildMode)) ? ((requirementsState == PlanScreen.RequirementsState.Complete || DebugHandler.InstantBuildMode) ? ImageToggleState.State.Inactive : ImageToggleState.State.Disabled) : ImageToggleState.State.Active);
             if ((UnityEngine.Object)def == (UnityEngine.Object)selectedBuilding && state == ImageToggleState.State.Disabled)
             {
                 state = ImageToggleState.State.DisabledActive;
             }
             else if (state == ImageToggleState.State.Disabled)
             {
                 state = ImageToggleState.State.Disabled;
             }
             toggle.GetComponent <ImageToggleState>().SetState(state);
             Material material;
             Color    color;
             if (requirementsState == PlanScreen.RequirementsState.Complete || DebugHandler.InstantBuildMode)
             {
                 material = defaultUIMaterial;
                 color    = Color.white;
             }
             else
             {
                 material = desaturatedUIMaterial;
                 Color color2;
                 if (flag)
                 {
                     color2 = new Color(1f, 1f, 1f, 0.6f);
                 }
                 else
                 {
                     Color color4 = image.color = new Color(1f, 1f, 1f, 0.15f);
                     color2 = color4;
                 }
                 color = color2;
             }
             if ((UnityEngine.Object)image.material != (UnityEngine.Object)material)
             {
                 image.material = material;
                 image.color    = color;
             }
             Image fgImage = toggle.gameObject.GetComponent <KToggle>().fgImage;
             fgImage.gameObject.SetActive(false);
             if (!flag)
             {
                 fgImage.sprite = Overlay_NeedTech;
                 fgImage.gameObject.SetActive(true);
                 string newString = string.Format(UI.PRODUCTINFO_REQUIRESRESEARCHDESC, techItem.parentTech.Name);
                 component.AddMultiStringTooltip("\n", buildingToolTipSettings.ResearchRequirement);
                 component.AddMultiStringTooltip(newString, buildingToolTipSettings.ResearchRequirement);
             }
             else if (requirementsState != PlanScreen.RequirementsState.Complete)
             {
                 fgImage.gameObject.SetActive(false);
                 component.AddMultiStringTooltip("\n", buildingToolTipSettings.ResearchRequirement);
                 string newString2 = UI.PRODUCTINFO_MISSINGRESOURCES_HOVER;
                 component.AddMultiStringTooltip(newString2, buildingToolTipSettings.ResearchRequirement);
                 foreach (Recipe.Ingredient ingredient in def.CraftRecipe.Ingredients)
                 {
                     string newString3 = string.Format("{0}{1}: {2}", "• ", ingredient.tag.ProperName(), GameUtil.GetFormattedMass(ingredient.amount, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}"));
                     component.AddMultiStringTooltip(newString3, buildingToolTipSettings.ResearchRequirement);
                 }
                 component.AddMultiStringTooltip(string.Empty, buildingToolTipSettings.ResearchRequirement);
             }
         }
     }
 }
コード例 #21
0
 protected virtual void RefreshButtons()
 {
     foreach (KToggle toggle in toggles)
     {
         if ((UnityEngine.Object)toggle != (UnityEngine.Object)null)
         {
             if (!dontDestroyToggles.Contains(toggle))
             {
                 UnityEngine.Object.Destroy(toggle.gameObject);
             }
             else
             {
                 toggle.ClearOnClick();
             }
         }
     }
     toggles.Clear();
     dontDestroyToggles.Clear();
     if (this.toggleInfo != null)
     {
         Transform transform = (!((UnityEngine.Object)toggleParent != (UnityEngine.Object)null)) ? base.transform : toggleParent;
         for (int i = 0; i < this.toggleInfo.Count; i++)
         {
             int        idx        = i;
             ToggleInfo toggleInfo = this.toggleInfo[i];
             KToggle    kToggle;
             if (!((UnityEngine.Object)toggleInfo.instanceOverride != (UnityEngine.Object)null))
             {
                 kToggle = ((!(bool)toggleInfo.prefabOverride) ? Util.KInstantiateUI <KToggle>(prefab.gameObject, transform.gameObject, true) : Util.KInstantiateUI <KToggle>(toggleInfo.prefabOverride.gameObject, transform.gameObject, true));
             }
             else
             {
                 kToggle = toggleInfo.instanceOverride;
                 dontDestroyToggles.Add(kToggle);
             }
             kToggle.Deselect();
             kToggle.gameObject.name = "Toggle:" + toggleInfo.text;
             kToggle.group           = group;
             kToggle.onClick        += delegate
             {
                 OnClick(idx);
             };
             Transform transform2 = kToggle.transform.Find("Text");
             if ((UnityEngine.Object)transform2 != (UnityEngine.Object)null)
             {
                 LocText component = transform2.GetComponent <LocText>();
                 if ((UnityEngine.Object)component != (UnityEngine.Object)null)
                 {
                     component.text = toggleInfo.text;
                 }
             }
             ToolTip component2 = kToggle.GetComponent <ToolTip>();
             if ((bool)component2)
             {
                 if (toggleInfo.tooltipHeader != string.Empty)
                 {
                     component2.AddMultiStringTooltip(toggleInfo.tooltipHeader, (!((UnityEngine.Object)ToggleToolTipHeaderTextStyleSetting != (UnityEngine.Object)null)) ? ToggleToolTipTextStyleSetting : ToggleToolTipHeaderTextStyleSetting);
                     if ((UnityEngine.Object)ToggleToolTipHeaderTextStyleSetting == (UnityEngine.Object)null)
                     {
                         Debug.Log("!");
                     }
                 }
                 component2.AddMultiStringTooltip(GameUtil.ReplaceHotkeyString(toggleInfo.tooltip, toggleInfo.hotKey), ToggleToolTipTextStyleSetting);
             }
             if (toggleInfo.getSpriteCB != null)
             {
                 kToggle.fgImage.sprite = toggleInfo.getSpriteCB();
             }
             else if (toggleInfo.icon != null)
             {
                 kToggle.fgImage.sprite = Assets.GetSprite(toggleInfo.icon);
             }
             toggleInfo.toggle = kToggle;
             toggles.Add(kToggle);
         }
     }
 }
コード例 #22
0
    protected override void OnPrefabInit()
    {
        base.OnPrefabInit();
        Instance = this;
        CodexCache.Init();
        ScheduledUIInstantiation component = GameScreenManager.Instance.ssOverlayCanvas.GetComponent <ScheduledUIInstantiation>();

        instantiator.Instantiate();
        jobsScreen        = instantiator.GetComponentInChildren <JobsTableScreen>(true);
        consumablesScreen = instantiator.GetComponentInChildren <ConsumablesTableScreen>(true);
        vitalsScreen      = instantiator.GetComponentInChildren <VitalsTableScreen>(true);
        starmapScreen     = component.GetInstantiatedObject <StarmapScreen>();
        codexScreen       = instantiator.GetComponentInChildren <CodexScreen>(true);
        scheduleScreen    = instantiator.GetComponentInChildren <ScheduleScreen>(true);
        skillsScreen      = component.GetInstantiatedObject <SkillsScreen>();
        Subscribe(Game.Instance.gameObject, 288942073, OnUIClear);
        consumablesInfo            = new ToggleInfo(UI.CONSUMABLES, "OverviewUI_consumables_icon", null, Action.ManageConsumables, UI.TOOLTIPS.MANAGEMENTMENU_CONSUMABLES, string.Empty);
        vitalsInfo                 = new ToggleInfo(UI.VITALS, "OverviewUI_vitals_icon", null, Action.ManageVitals, UI.TOOLTIPS.MANAGEMENTMENU_VITALS, string.Empty);
        reportsInfo                = new ToggleInfo(UI.REPORT, "OverviewUI_reports_icon", null, Action.ManageReport, UI.TOOLTIPS.MANAGEMENTMENU_DAILYREPORT, string.Empty);
        reportsInfo.prefabOverride = smallPrefab;
        researchInfo               = new ToggleInfo(UI.RESEARCH, "OverviewUI_research_nav_icon", null, Action.ManageResearch, UI.TOOLTIPS.MANAGEMENTMENU_RESEARCH, string.Empty);
        jobsInfo    = new ToggleInfo(UI.JOBS, "OverviewUI_priority_icon", null, Action.ManagePriorities, UI.TOOLTIPS.MANAGEMENTMENU_JOBS, string.Empty);
        skillsInfo  = new ToggleInfo(UI.SKILLS, "OverviewUI_jobs_icon", null, Action.ManageSkills, UI.TOOLTIPS.MANAGEMENTMENU_SKILLS, string.Empty);
        starmapInfo = new ToggleInfo(UI.STARMAP.MANAGEMENT_BUTTON, "OverviewUI_starmap_icon", null, Action.ManageStarmap, UI.TOOLTIPS.MANAGEMENTMENU_STARMAP, string.Empty);
        codexInfo   = new ToggleInfo(UI.CODEX.MANAGEMENT_BUTTON, "OverviewUI_database_icon", null, Action.ManageDatabase, UI.TOOLTIPS.MANAGEMENTMENU_CODEX, string.Empty);
        codexInfo.prefabOverride = smallPrefab;
        scheduleInfo             = new ToggleInfo(UI.SCHEDULE, "OverviewUI_schedule2_icon", null, Action.ManageSchedule, UI.TOOLTIPS.MANAGEMENTMENU_SCHEDULE, string.Empty);
        ScreenInfoMatch.Add(consumablesInfo, new ScreenData
        {
            screen     = consumablesScreen,
            tabIdx     = 3,
            toggleInfo = consumablesInfo
        });
        ScreenInfoMatch.Add(vitalsInfo, new ScreenData
        {
            screen     = vitalsScreen,
            tabIdx     = 2,
            toggleInfo = vitalsInfo
        });
        ScreenInfoMatch.Add(reportsInfo, new ScreenData
        {
            screen     = reportsScreen,
            tabIdx     = 4,
            toggleInfo = reportsInfo
        });
        ScreenInfoMatch.Add(jobsInfo, new ScreenData
        {
            screen     = jobsScreen,
            tabIdx     = 1,
            toggleInfo = jobsInfo
        });
        ScreenInfoMatch.Add(skillsInfo, new ScreenData
        {
            screen     = skillsScreen,
            tabIdx     = 0,
            toggleInfo = skillsInfo
        });
        ScreenInfoMatch.Add(codexInfo, new ScreenData
        {
            screen     = codexScreen,
            tabIdx     = 6,
            toggleInfo = codexInfo
        });
        ScreenInfoMatch.Add(scheduleInfo, new ScreenData
        {
            screen     = scheduleScreen,
            tabIdx     = 7,
            toggleInfo = scheduleInfo
        });
        ScreenInfoMatch.Add(starmapInfo, new ScreenData
        {
            screen     = starmapScreen,
            tabIdx     = 7,
            toggleInfo = starmapInfo
        });
        List <ToggleInfo> list = new List <ToggleInfo>();

        list.Add(vitalsInfo);
        list.Add(consumablesInfo);
        list.Add(scheduleInfo);
        list.Add(jobsInfo);
        list.Add(skillsInfo);
        list.Add(researchInfo);
        list.Add(starmapInfo);
        list.Add(reportsInfo);
        list.Add(codexInfo);
        Setup(list);
        base.onSelect           += OnButtonClick;
        PauseMenuButton.onClick += OnPauseMenuClicked;
        PauseMenuButton.transform.SetAsLastSibling();
        PauseMenuButton.GetComponent <ToolTip>().toolTip = GameUtil.ReplaceHotkeyString(UI.TOOLTIPS.MANAGEMENTMENU_PAUSEMENU, Action.Escape);
        Components.ResearchCenters.OnAdd    += CheckResearch;
        Components.ResearchCenters.OnRemove += CheckResearch;
        Components.RoleStations.OnAdd       += CheckSkills;
        Components.RoleStations.OnRemove    += CheckSkills;
        Game.Instance.Subscribe(-809948329, CheckResearch);
        Game.Instance.Subscribe(-809948329, CheckSkills);
        Components.Telescopes.OnAdd    += CheckStarmap;
        Components.Telescopes.OnRemove += CheckStarmap;
        skillsTooltipDisabled           = UI.TOOLTIPS.MANAGEMENTMENU_REQUIRES_SKILL_STATION;
        skillsTooltip           = GameUtil.ReplaceHotkeyString(UI.TOOLTIPS.MANAGEMENTMENU_SKILLS, Action.ManageSkills);
        researchTooltipDisabled = UI.TOOLTIPS.MANAGEMENTMENU_REQUIRES_RESEARCH;
        researchTooltip         = GameUtil.ReplaceHotkeyString(UI.TOOLTIPS.MANAGEMENTMENU_RESEARCH, Action.ManageResearch);
        starmapTooltipDisabled  = UI.TOOLTIPS.MANAGEMENTMENU_REQUIRES_TELESCOPE;
        starmapTooltip          = GameUtil.ReplaceHotkeyString(UI.TOOLTIPS.MANAGEMENTMENU_STARMAP, Action.ManageStarmap);
        CheckResearch(null);
        CheckSkills(null);
        CheckStarmap(null);
        researchInfo.toggle.soundPlayer.AcceptClickCondition = (() => ResearchAvailable() || activeScreen == ScreenInfoMatch[Instance.researchInfo]);
        KButton[] closeButtons = CloseButtons;
        foreach (KButton kButton in closeButtons)
        {
            kButton.onClick            += CloseAll;
            kButton.soundPlayer.Enabled = false;
        }
        foreach (KToggle toggle in toggles)
        {
            toggle.soundPlayer.toggle_widget_sound_events[0].PlaySound = false;
            toggle.soundPlayer.toggle_widget_sound_events[1].PlaySound = false;
        }
    }
コード例 #23
0
 private void SetCategoryButtonState()
 {
     foreach (ToggleEntry toggleEntry in toggleEntries)
     {
         ToggleEntry current    = toggleEntry;
         ToggleInfo  toggleInfo = current.toggleInfo;
         toggleInfo.toggle.ActivateFlourish(activeCategoryInfo != null && toggleInfo.userData == activeCategoryInfo.userData);
         bool flag  = false;
         bool flag2 = true;
         if (DebugHandler.InstantBuildMode || Game.Instance.SandboxModeActive)
         {
             flag  = true;
             flag2 = false;
         }
         else
         {
             foreach (BuildingDef buildingDef in current.buildingDefs)
             {
                 RequirementsState requirementsState = BuildableState(buildingDef);
                 if (requirementsState == RequirementsState.Complete)
                 {
                     flag  = true;
                     flag2 = false;
                     break;
                 }
             }
             if (flag2 && current.AreAnyRequiredTechItemsAvailable())
             {
                 flag2 = false;
             }
         }
         CategoryInteractive[toggleInfo] = !flag2;
         GameObject gameObject = toggleInfo.toggle.fgImage.transform.Find("ResearchIcon").gameObject;
         if (!flag)
         {
             if (flag2 && current.hideIfNotResearched)
             {
                 toggleInfo.toggle.gameObject.SetActive(false);
             }
             else if (flag2)
             {
                 toggleInfo.toggle.gameObject.SetActive(true);
                 toggleInfo.toggle.fgImage.SetAlpha(0.2509804f);
                 gameObject.gameObject.SetActive(true);
             }
             else
             {
                 toggleInfo.toggle.gameObject.SetActive(true);
                 toggleInfo.toggle.fgImage.SetAlpha(1f);
                 gameObject.gameObject.SetActive(false);
             }
             ImageToggleState.State state        = (activeCategoryInfo != null && toggleInfo.userData == activeCategoryInfo.userData) ? ImageToggleState.State.DisabledActive : ImageToggleState.State.Disabled;
             ImageToggleState[]     toggleImages = current.toggleImages;
             foreach (ImageToggleState imageToggleState in toggleImages)
             {
                 imageToggleState.SetState(state);
             }
         }
         else
         {
             toggleInfo.toggle.gameObject.SetActive(true);
             toggleInfo.toggle.fgImage.SetAlpha(1f);
             gameObject.gameObject.SetActive(false);
             ImageToggleState.State state2        = (activeCategoryInfo == null || toggleInfo.userData != activeCategoryInfo.userData) ? ImageToggleState.State.Inactive : ImageToggleState.State.Active;
             ImageToggleState[]     toggleImages2 = current.toggleImages;
             foreach (ImageToggleState imageToggleState2 in toggleImages2)
             {
                 imageToggleState2.SetState(state2);
             }
         }
     }
 }
コード例 #24
0
ファイル: ToggleGroupInfo.cs プロジェクト: ocy1011/Capstone
 public void AddToggle(ToggleInfo toggleInfo)
 {
     toggleList.Add(toggleInfo);
     toggleList.OrderBy(a => a.id);
     SelectToggle(0);
 }