示例#1
0
 private string OnPriorityButtonTooltip(PriorityButton b)
 {
     b.tooltip.ClearMultiStringTooltip();
     if ((UnityEngine.Object)identity != (UnityEngine.Object)null)
     {
         Attributes attributes = identity.GetAttributes();
         if (attributes != null)
         {
             if (!consumer.IsPermittedByTraits(b.choreGroup))
             {
                 string newString = string.Format(UI.TOOLTIPS.JOBSSCREEN_CANNOTPERFORMTASK, consumer.GetComponent <MinionIdentity>().GetProperName());
                 b.tooltip.AddMultiStringTooltip(newString, TooltipTextStyle_AbilityNegativeModifier);
                 return(string.Empty);
             }
             b.tooltip.AddMultiStringTooltip(UI.TOOLTIPS.JOBSSCREEN_RELEVANT_ATTRIBUTES, TooltipTextStyle_Ability);
             Klei.AI.Attribute attribute         = b.choreGroup.attribute;
             AttributeInstance attributeInstance = attributes.Get(attribute);
             float             totalValue        = attributeInstance.GetTotalValue();
             TextStyleSetting  styleSetting      = TooltipTextStyle_Ability;
             if (totalValue > 0f)
             {
                 styleSetting = TooltipTextStyle_AbilityPositiveModifier;
             }
             else if (totalValue < 0f)
             {
                 styleSetting = TooltipTextStyle_AbilityNegativeModifier;
             }
             b.tooltip.AddMultiStringTooltip(attribute.Name + " " + attributeInstance.GetTotalValue(), styleSetting);
         }
     }
     return(string.Empty);
 }
        private void BuildGUI()
        {
            int width  = panelContent.Width,
                height = panelContent.Height;

            int buttonWidth  = width / 3,
                buttonHeight = height / 3;

            for (var y = 0; y < 3; y++)
            {
                for (int x = 0; x < 3; x++)
                {
                    var symbolAlignment = GetAlignment(y * 3 + x);
                    var button          = GetPriorityButton(symbolAlignment);

                    if (button == null)
                    {
                        button = new PriorityButton(symbolAlignment)
                        {
                            Text      = "0",
                            BackColor = Color.White
                        };

                        button.Click += Button_Click;
                        panelContent.Controls.Add(button);
                    }

                    button.Width  = buttonWidth;
                    button.Height = buttonHeight;
                    button.Left   = x * buttonWidth;
                    button.Top    = y * buttonHeight;
                }
            }
        }
示例#3
0
 public void InstantiateButtons(Action <PrioritySetting> on_click, bool playSelectionSound = true)
 {
     onClick = on_click;
     for (int i = 1; i <= 9; i++)
     {
         int            num            = i;
         PriorityButton priorityButton = Util.KInstantiateUI <PriorityButton>(buttonPrefab_basic.gameObject, buttonPrefab_basic.transform.parent.gameObject, false);
         buttons_basic.Add(priorityButton);
         priorityButton.playSelectionSound = playSelectionSound;
         priorityButton.onClick            = onClick;
         priorityButton.text.text          = num.ToString();
         priorityButton.priority           = new PrioritySetting(PriorityClass.basic, num);
         priorityButton.tooltip.SetSimpleTooltip(string.Format(UI.PRIORITYSCREEN.BASIC, num));
     }
     buttonPrefab_basic.gameObject.SetActive(false);
     button_emergency.playSelectionSound = playSelectionSound;
     button_emergency.onClick            = onClick;
     button_emergency.priority           = new PrioritySetting(PriorityClass.topPriority, 1);
     button_emergency.tooltip.SetSimpleTooltip(UI.PRIORITYSCREEN.TOP_PRIORITY);
     button_toggleHigh.gameObject.SetActive(false);
     PriorityMenuContainer.SetActive(true);
     button_priorityMenu.gameObject.SetActive(true);
     button_priorityMenu.onClick += PriorityButtonClicked;
     button_priorityMenu.GetComponent <ToolTip>().SetSimpleTooltip(UI.PRIORITYSCREEN.OPEN_JOBS_SCREEN);
     diagram.SetActive(false);
     SetScreenPriority(new PrioritySetting(PriorityClass.basic, 5), false);
 }
示例#4
0
 private void RefreshButton(PriorityButton b, PrioritySetting priority, bool play_sound)
 {
     if (b.priority == priority)
     {
         b.toggle.Select();
         b.toggle.isOn = true;
         if (play_sound)
         {
             b.toggle.soundPlayer.Play(0);
         }
     }
     else
     {
         b.toggle.isOn = false;
     }
 }
示例#5
0
    private void CreateAllTaskButton()
    {
        GameObject gameObject = Util.KInstantiateUI(Prefab_JobPriorityButtonAllTasks, base.transform.gameObject, false);

        gameObject.GetComponent <OverviewColumnIdentity>().columnID           = "AllTasks";
        gameObject.GetComponent <OverviewColumnIdentity>().Column_DisplayName = string.Empty;
        Button b = gameObject.GetComponent <Button>();

        b.onClick.AddListener(delegate
        {
            ToggleTasksAll(b);
        });
        PriorityButton allTasksButton = default(PriorityButton);

        allTasksButton.button              = gameObject.GetComponent <Button>();
        allTasksButton.border              = gameObject.transform.GetChild(1).GetComponent <Image>();
        allTasksButton.baseBorderColor     = allTasksButton.border.color;
        allTasksButton.background          = gameObject.transform.GetChild(0).GetComponent <Image>();
        allTasksButton.baseBackgroundColor = allTasksButton.background.color;
        allTasksButton.ToggleIcon          = gameObject.transform.GetChild(2).gameObject;
        allTasksButton.tooltip             = gameObject.GetComponent <ToolTip>();
        AllTasksButton = allTasksButton;
    }
示例#6
0
    private void CreateChoreButton(ChoreGroup chore_group)
    {
        GameObject gameObject = Util.KInstantiateUI(Prefab_JobPriorityButton, base.transform.gameObject, false);

        gameObject.GetComponent <OverviewColumnIdentity>().columnID           = chore_group.Id;
        gameObject.GetComponent <OverviewColumnIdentity>().Column_DisplayName = chore_group.Name;
        PriorityButton priorityButton = default(PriorityButton);

        priorityButton.button              = gameObject.GetComponent <Button>();
        priorityButton.border              = gameObject.transform.GetChild(1).GetComponent <Image>();
        priorityButton.baseBorderColor     = priorityButton.border.color;
        priorityButton.background          = gameObject.transform.GetChild(0).GetComponent <Image>();
        priorityButton.baseBackgroundColor = priorityButton.background.color;
        priorityButton.choreGroup          = chore_group;
        priorityButton.ToggleIcon          = gameObject.transform.GetChild(2).gameObject;
        priorityButton.tooltip             = gameObject.GetComponent <ToolTip>();
        priorityButton.tooltip.OnToolTip   = (() => OnPriorityButtonTooltip(priorityButton));
        priorityButton.button.onClick.AddListener(delegate
        {
            OnPriorityPress(chore_group);
        });
        PriorityButtons.Add(priorityButton);
    }
示例#7
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;
        }
    }