public void ClearSelection()
    {
        GameObject[] array = buttonObjects;
        foreach (GameObject gameObject in array)
        {
            KToggle component = gameObject.GetComponent <KToggle>();
            if ((UnityEngine.Object)component != (UnityEngine.Object)null)
            {
                component.Deselect();
                component.isOn = false;
            }
            else
            {
                KBasicToggle component2 = gameObject.GetComponent <KBasicToggle>();
                if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
                {
                    component2.isOn = false;
                }
            }
            ImageToggleState component3 = gameObject.GetComponent <ImageToggleState>();
            if (component3.GetIsActive())
            {
                component3.SetInactive();
            }
        }
        ToggleGroup component4 = GetComponent <ToggleGroup>();

        if ((UnityEngine.Object)component4 != (UnityEngine.Object)null)
        {
            component4.SetAllTogglesOff();
        }
        SelectToggle(null);
    }
    protected override void SpawnEntries()
    {
        base.SpawnEntries();
        foreach (MinionIdentity item in Components.LiveMinionIdentities.Items)
        {
            GameObject    gameObject = Util.KInstantiateUI(Prefab_CrewEntry, EntriesPanelTransform.gameObject, false);
            CrewJobsEntry component  = gameObject.GetComponent <CrewJobsEntry>();
            component.Populate(item);
            EntryObjects.Add(component);
        }
        SortEveryoneToggle.group = sortToggleGroup;
        ImageToggleState toggleImage = SortEveryoneToggle.GetComponentInChildren <ImageToggleState>(true);

        SortEveryoneToggle.onValueChanged.AddListener(delegate
        {
            SortByName(!SortEveryoneToggle.isOn);
            lastSortToggle   = SortEveryoneToggle;
            lastSortReversed = !SortEveryoneToggle.isOn;
            ResetSortToggles(SortEveryoneToggle);
            if (SortEveryoneToggle.isOn)
            {
                toggleImage.SetActive();
            }
            else
            {
                toggleImage.SetInactive();
            }
        });
        SortByPreviousSelected();
        dirty = true;
    }
    protected override void PositionColumnTitles()
    {
        base.PositionColumnTitles();
        int childCount = ColumnTitlesContainer.childCount;

        for (int i = 0; i < childCount; i++)
        {
            if (i < choreGroups.Count)
            {
                Toggle sortToggle = ColumnTitlesContainer.GetChild(i).Find("Title").GetComponentInChildren <Toggle>();
                ColumnTitlesContainer.GetChild(i).rectTransform().localScale = Vector3.one;
                ChoreGroup       chore_group = choreGroups[i];
                ImageToggleState toggleImage = sortToggle.GetComponentInChildren <ImageToggleState>(true);
                sortToggle.group = sortToggleGroup;
                sortToggle.onValueChanged.AddListener(delegate
                {
                    bool playSound = false;
                    if ((UnityEngine.Object)lastSortToggle == (UnityEngine.Object)sortToggle)
                    {
                        playSound = true;
                    }
                    SortByEffectiveness(chore_group, !sortToggle.isOn, playSound);
                    lastSortToggle   = sortToggle;
                    lastSortReversed = !sortToggle.isOn;
                    ResetSortToggles(sortToggle);
                    if (sortToggle.isOn)
                    {
                        toggleImage.SetActive();
                    }
                    else
                    {
                        toggleImage.SetInactive();
                    }
                });
            }
            ToolTip JobTooltip = ColumnTitlesContainer.GetChild(i).GetComponent <ToolTip>();
            ToolTip toolTip    = JobTooltip;
            toolTip.OnToolTip = (Func <string>)Delegate.Combine(toolTip.OnToolTip, (Func <string>)(() => GetJobTooltip(JobTooltip.gameObject)));
            Button componentInChildren = ColumnTitlesContainer.GetChild(i).GetComponentInChildren <Button>();
            EveryoneToggles.Add(componentInChildren, everyoneToggleState.on);
        }
        for (int j = 0; j < choreGroups.Count; j++)
        {
            ChoreGroup chore_group2 = choreGroups[j];
            Button     b            = EveryoneToggles.Keys.ElementAt(j);
            EveryoneToggles.Keys.ElementAt(j).onClick.AddListener(delegate
            {
                ToggleJobEveryone(b, chore_group2);
            });
        }
        Button key = EveryoneToggles.ElementAt(EveryoneToggles.Count - 1).Key;

        key.transform.parent.Find("Title").gameObject.GetComponentInChildren <Toggle>().gameObject.SetActive(false);
        key.onClick.AddListener(delegate
        {
            ToggleAllTasksEveryone();
        });
        EveryoneAllTaskToggle = new KeyValuePair <Button, everyoneToggleState>(key, EveryoneAllTaskToggle.Value);
    }
Esempio n. 4
0
 private void SetInteractable(bool state)
 {
     if (state)
     {
         if (!IsOpen)
         {
             expandArrow.SetInactive();
         }
         else
         {
             expandArrow.SetActive();
         }
     }
     else
     {
         SetOpen(false);
         expandArrow.SetDisabled();
     }
 }
Esempio n. 5
0
    private void ToggleOpen()
    {
        bool activeSelf = scalerMask.gameObject.activeSelf;

        activeSelf = !activeSelf;
        scalerMask.gameObject.SetActive(activeSelf);
        if (activeSelf)
        {
            ArrowIcon.SetActive();
            ForceLocTextsMeshRebuild();
        }
        else
        {
            ArrowIcon.SetInactive();
        }
    }
    public void DeselectDeliverable()
    {
        if ((UnityEngine.Object)controller != (UnityEngine.Object)null)
        {
            controller.RemoveDeliverable(info);
        }
        ImageToggleState component = selectButton.GetComponent <ImageToggleState>();

        component.SetInactive();
        selectButton.Deselect();
        selectButton.ClearOnClick();
        selectButton.onClick += delegate
        {
            SelectDeliverable();
        };
        selectedBorder.SetActive(false);
        titleBar.color = deselectedTitleColor;
    }
 public virtual void ActivateTabArtwork(int tabIdx)
 {
     if (tabIdx < base.transform.childCount)
     {
         for (int i = 0; i < base.transform.childCount; i++)
         {
             ImageToggleState component = base.transform.GetChild(i).GetComponent <ImageToggleState>();
             if ((Object)component != (Object)null)
             {
                 if (i == tabIdx)
                 {
                     component.SetActive();
                 }
                 else
                 {
                     component.SetInactive();
                 }
             }
             Canvas componentInChildren = base.transform.GetChild(i).GetComponentInChildren <Canvas>(true);
             if ((Object)componentInChildren != (Object)null)
             {
                 componentInChildren.overrideSorting = (tabIdx == i);
             }
             SetTextStyleSetting componentInChildren2 = base.transform.GetChild(i).GetComponentInChildren <SetTextStyleSetting>();
             if ((Object)componentInChildren2 != (Object)null && (Object)TextStyle_Active != (Object)null && (Object)TextStyle_Inactive != (Object)null)
             {
                 if (i == tabIdx)
                 {
                     componentInChildren2.SetStyle(TextStyle_Active);
                 }
                 else
                 {
                     componentInChildren2.SetStyle(TextStyle_Inactive);
                 }
             }
         }
     }
 }
Esempio n. 8
0
    private void Refresh(object data = null)
    {
        if ((UnityEngine.Object)identity == (UnityEngine.Object)null)
        {
            dirty = false;
        }
        else if (dirty)
        {
            Attributes attributes = identity.GetAttributes();
            foreach (PriorityButton priorityButton in PriorityButtons)
            {
                PriorityButton current = priorityButton;
                bool           flag    = consumer.IsPermittedByUser(current.choreGroup);
                if (current.ToggleIcon.activeSelf != flag)
                {
                    current.ToggleIcon.SetActive(flag);
                }
                float             num = 0f;
                AttributeInstance attributeInstance = attributes.Get(current.choreGroup.attribute);
                num = Mathf.Min(attributeInstance.GetTotalValue() / 10f, 1f);
                Color baseBorderColor = current.baseBorderColor;
                baseBorderColor.r = Mathf.Lerp(current.baseBorderColor.r, 0.721568644f, num);
                baseBorderColor.g = Mathf.Lerp(current.baseBorderColor.g, 0.443137258f, num);
                baseBorderColor.b = Mathf.Lerp(current.baseBorderColor.b, 0.5803922f, num);
                if (current.border.color != baseBorderColor)
                {
                    current.border.color = baseBorderColor;
                }
                Color color = current.baseBackgroundColor;
                color.a = Mathf.Lerp(0f, 1f, num);
                bool flag2 = consumer.IsPermittedByTraits(current.choreGroup);
                if (!flag2)
                {
                    color = Color.clear;
                    current.border.color = Color.clear;
                    current.ToggleIcon.SetActive(false);
                }
                current.button.interactable = flag2;
                if (current.background.color != color)
                {
                    current.background.color = color;
                }
            }
            int num2 = 0;
            int num3 = 0;
            foreach (ChoreGroup resource in Db.Get().ChoreGroups.resources)
            {
                if (consumer.IsPermittedByTraits(resource))
                {
                    num3++;
                    if (consumer.IsPermittedByUser(resource))
                    {
                        num2++;
                    }
                }
            }
            if (num2 == 0)
            {
                rowToggleState = CrewJobsScreen.everyoneToggleState.off;
            }
            else if (num2 < num3)
            {
                rowToggleState = CrewJobsScreen.everyoneToggleState.mixed;
            }
            else
            {
                rowToggleState = CrewJobsScreen.everyoneToggleState.on;
            }
            ImageToggleState component = AllTasksButton.ToggleIcon.GetComponent <ImageToggleState>();
            switch (rowToggleState)
            {
            case CrewJobsScreen.everyoneToggleState.mixed:
                component.SetInactive();
                break;

            case CrewJobsScreen.everyoneToggleState.on:
                component.SetActive();
                break;

            case CrewJobsScreen.everyoneToggleState.off:
                component.SetDisabled();
                break;
            }
            dirty = false;
        }
    }
Esempio n. 9
0
 protected override void PositionColumnTitles()
 {
     base.PositionColumnTitles();
     for (int i = 0; i < ColumnTitlesContainer.childCount; i++)
     {
         OverviewColumnIdentity component = ColumnTitlesContainer.GetChild(i).GetComponent <OverviewColumnIdentity>();
         if (component.Sortable)
         {
             Toggle toggle = ColumnTitlesContainer.GetChild(i).GetComponent <Toggle>();
             toggle.group = sortToggleGroup;
             ImageToggleState toggleImage = toggle.GetComponentInChildren <ImageToggleState>(true);
             if (component.columnID == "name")
             {
                 toggle.onValueChanged.AddListener(delegate
                 {
                     SortByName(!toggle.isOn);
                     lastSortToggle   = toggle;
                     lastSortReversed = !toggle.isOn;
                     ResetSortToggles(toggle);
                     if (toggle.isOn)
                     {
                         toggleImage.SetActive();
                     }
                     else
                     {
                         toggleImage.SetInactive();
                     }
                 });
             }
             if (component.columnID == "health")
             {
                 toggle.onValueChanged.AddListener(delegate
                 {
                     SortByAmount("HitPoints", !toggle.isOn);
                     lastSortToggle   = toggle;
                     lastSortReversed = !toggle.isOn;
                     ResetSortToggles(toggle);
                     if (toggle.isOn)
                     {
                         toggleImage.SetActive();
                     }
                     else
                     {
                         toggleImage.SetInactive();
                     }
                 });
             }
             if (component.columnID == "stress")
             {
                 toggle.onValueChanged.AddListener(delegate
                 {
                     SortByAmount("Stress", !toggle.isOn);
                     lastSortToggle   = toggle;
                     lastSortReversed = !toggle.isOn;
                     ResetSortToggles(toggle);
                     if (toggle.isOn)
                     {
                         toggleImage.SetActive();
                     }
                     else
                     {
                         toggleImage.SetInactive();
                     }
                 });
             }
             if (component.columnID == "calories")
             {
                 toggle.onValueChanged.AddListener(delegate
                 {
                     SortByAmount("Calories", !toggle.isOn);
                     lastSortToggle   = toggle;
                     lastSortReversed = !toggle.isOn;
                     ResetSortToggles(toggle);
                     if (toggle.isOn)
                     {
                         toggleImage.SetActive();
                     }
                     else
                     {
                         toggleImage.SetInactive();
                     }
                 });
             }
         }
     }
 }
    private void Refresh()
    {
        if (dirty)
        {
            int  childCount = ColumnTitlesContainer.childCount;
            bool flag       = false;
            bool flag2      = false;
            for (int i = 0; i < childCount; i++)
            {
                bool flag3 = false;
                bool flag4 = false;
                if (choreGroups.Count - 1 >= i)
                {
                    ChoreGroup chore_group = choreGroups[i];
                    for (int j = 0; j < EntryObjects.Count; j++)
                    {
                        ChoreConsumer consumer = EntryObjects[j].GetComponent <CrewJobsEntry>().consumer;
                        if (consumer.IsPermittedByTraits(chore_group))
                        {
                            if (consumer.IsPermittedByUser(chore_group))
                            {
                                flag3 = true;
                                flag  = true;
                            }
                            else
                            {
                                flag4 = true;
                                flag2 = true;
                            }
                        }
                    }
                    if (flag3 && flag4)
                    {
                        EveryoneToggles[EveryoneToggles.ElementAt(i).Key] = everyoneToggleState.mixed;
                    }
                    else if (flag3)
                    {
                        EveryoneToggles[EveryoneToggles.ElementAt(i).Key] = everyoneToggleState.on;
                    }
                    else
                    {
                        EveryoneToggles[EveryoneToggles.ElementAt(i).Key] = everyoneToggleState.off;
                    }
                    Button           componentInChildren = ColumnTitlesContainer.GetChild(i).GetComponentInChildren <Button>();
                    ImageToggleState component           = componentInChildren.GetComponentsInChildren <Image>(true)[1].GetComponent <ImageToggleState>();
                    switch (EveryoneToggles[componentInChildren])
                    {
                    case everyoneToggleState.off:
                        component.SetDisabled();
                        break;

                    case everyoneToggleState.mixed:
                        component.SetInactive();
                        break;

                    case everyoneToggleState.on:
                        component.SetActive();
                        break;
                    }
                }
            }
            if (flag && flag2)
            {
                EveryoneAllTaskToggle = new KeyValuePair <Button, everyoneToggleState>(EveryoneAllTaskToggle.Key, everyoneToggleState.mixed);
            }
            else if (flag)
            {
                EveryoneAllTaskToggle = new KeyValuePair <Button, everyoneToggleState>(EveryoneAllTaskToggle.Key, everyoneToggleState.on);
            }
            else if (flag2)
            {
                EveryoneAllTaskToggle = new KeyValuePair <Button, everyoneToggleState>(EveryoneAllTaskToggle.Key, everyoneToggleState.off);
            }
            ImageToggleState component2 = EveryoneAllTaskToggle.Key.GetComponentsInChildren <Image>(true)[1].GetComponent <ImageToggleState>();
            switch (EveryoneAllTaskToggle.Value)
            {
            case everyoneToggleState.off:
                component2.SetDisabled();
                break;

            case everyoneToggleState.mixed:
                component2.SetInactive();
                break;

            case everyoneToggleState.on:
                component2.SetActive();
                break;
            }
            Vector2 sizeDelta = EntriesPanelTransform.rectTransform().sizeDelta;
            screenWidth = sizeDelta.x;
            ScrollRectTransform.GetComponent <LayoutElement>().minWidth = screenWidth;
            float num = 31f;
            GetComponent <LayoutElement>().minWidth = screenWidth + num;
            dirty = false;
        }
    }