private void OnAutosaveValueChanged(int sliderValue)
    {
        int num = SliderValueToCycleCount(sliderValue);

        if (sliderValue == 0)
        {
            autosaveDescriptionLabel.SetText(UI.FRONTEND.COLONY_SAVE_OPTIONS_SCREEN.AUTOSAVE_NEVER);
        }
        else
        {
            autosaveDescriptionLabel.SetText(string.Format(UI.FRONTEND.COLONY_SAVE_OPTIONS_SCREEN.AUTOSAVE_FREQUENCY_DESCRIPTION, num));
        }
        SaveGame.Instance.AutoSaveCycleInterval = num;
    }
    private void OnTimelapseValueChanged(int sliderValue)
    {
        Vector2I timelapseResolution = SliderValueToResolution(sliderValue);

        if (timelapseResolution.x <= 0)
        {
            timelapseDescriptionLabel.SetText(UI.FRONTEND.COLONY_SAVE_OPTIONS_SCREEN.TIMELAPSE_DISABLED_DESCRIPTION);
        }
        else
        {
            timelapseDescriptionLabel.SetText(string.Format(UI.FRONTEND.COLONY_SAVE_OPTIONS_SCREEN.TIMELAPSE_RESOLUTION_DESCRIPTION, timelapseResolution.x, timelapseResolution.y));
        }
        SaveGame.Instance.TimelapseResolution = timelapseResolution;
        Game.Instance.Trigger(75424175, null);
    }
Exemple #3
0
 protected override void OnSpawn()
 {
     base.OnSpawn();
     title.SetText(UI.FRONTEND.PAUSE_SCREEN.TITLE);
     worldSeed.SetText(string.Format(UI.FRONTEND.PAUSE_SCREEN.WORLD_SEED, SaveLoader.Instance.worldDetailSave.globalWorldSeed));
     worldSeed.transform.SetAsLastSibling();
 }
 public void RefreshTitle()
 {
     if ((bool)currentSideScreen)
     {
         sideScreenTitle.SetText(currentSideScreen.GetTitle());
     }
 }
Exemple #5
0
 private void RebuildUGCButtons()
 {
     if (!((UnityEngine.Object)SteamUGCService.Instance == (UnityEngine.Object)null))
     {
         foreach (Mod mod in Global.Instance.modManager.mods)
         {
             if ((mod.available_content & Content.Translation) != 0 && mod.status == Mod.Status.Installed)
             {
                 GameObject gameObject = Util.KInstantiateUI(languageButtonPrefab, ugcLanguagesContainer, false);
                 gameObject.name = mod.title + "_button";
                 HierarchyReferences component      = gameObject.GetComponent <HierarchyReferences>();
                 PublishedFileId_t   file_id        = new PublishedFileId_t(ulong.Parse(mod.label.id));
                 TMP_FontAsset       fontForLangage = GetFontForLangage(file_id);
                 LocText             reference      = component.GetReference <LocText>("Title");
                 reference.SetText(string.Format(UI.FRONTEND.TRANSLATIONS_SCREEN.UGC_MOD_TITLE_FORMAT, mod.title));
                 reference.font = fontForLangage;
                 Texture2D texture2D = SteamUGCService.Instance.FindMod(file_id)?.previewImage;
                 if ((UnityEngine.Object)texture2D != (UnityEngine.Object)null)
                 {
                     Image reference2 = component.GetReference <Image>("Image");
                     reference2.sprite = Sprite.Create(texture2D, new Rect(Vector2.zero, new Vector2((float)texture2D.width, (float)texture2D.height)), Vector2.one * 0.5f);
                 }
                 KButton component2 = gameObject.GetComponent <KButton>();
                 component2.onClick += delegate
                 {
                     ConfirmLanguageChoiceDialog(string.Empty, file_id);
                 };
                 buttons.Add(gameObject);
             }
         }
     }
 }
Exemple #6
0
    protected override void OnSpawn()
    {
        base.OnSpawn();
        string arg = "LU-" + ((!Application.isEditor) ? 365655.ToString() : "<EDITOR>");

        textDisplay.SetText(string.Format(UI.DEVELOPMENTBUILDS.WATERMARK, arg));
    }
 private void Rebuild()
 {
     if ((UnityEngine.Object)controller == (UnityEngine.Object)null)
     {
         controller = GetComponentInChildren <KBatchedAnimController>();
         if ((UnityEngine.Object)controller == (UnityEngine.Object)null)
         {
             if ((UnityEngine.Object)targetImage != (UnityEngine.Object)null)
             {
                 targetImage.enabled = true;
             }
             Debug.LogWarning("Controller for [" + base.name + "] null");
             return;
         }
     }
     SetPortraitData(identityObject, controller, useDefaultExpression);
     if (useLabels && (UnityEngine.Object)duplicantName != (UnityEngine.Object)null)
     {
         duplicantName.SetText((identityObject == null) ? string.Empty : identityObject.GetProperName());
         if (identityObject is MinionIdentity && (UnityEngine.Object)duplicantJob != (UnityEngine.Object)null)
         {
             duplicantJob.SetText((identityObject == null) ? string.Empty : (identityObject as MinionIdentity).GetComponent <MinionResume>().GetSkillsSubtitle());
             duplicantJob.GetComponent <ToolTip>().toolTip = (identityObject as MinionIdentity).GetComponent <MinionResume>().GetSkillsSubtitle();
         }
     }
 }
        /// <summary>
        /// Updates an individual resource entry with the critters found.
        /// </summary>
        /// <param name="entry">The entry to update.</param>
        /// <param name="quantity">The quantity of this critter which is present.</param>
        private static void UpdateEntry(ResourceEntry entry, CritterTotals quantity)
        {
            var trEntry = Traverse.Create(entry);
            // Update the tool tip text
            var tooltip = trEntry.GetField <ToolTip>("tooltip");

            if (tooltip != null)
            {
                tooltip.OnToolTip = null;
                tooltip.toolTip   = CritterInventoryUtils.FormatTooltip(entry.NameLabel.text,
                                                                        quantity);
            }
            // Determine the color for the labels
            var color = trEntry.GetField <Color>("AvailableColor");

            if (quantity.Available <= 0)
            {
                color = trEntry.GetField <Color>("UnavailableColor");
            }
            LocText qLabel = entry.QuantityLabel, nLabel = entry.NameLabel;

            if (qLabel.color != color)
            {
                qLabel.color = color;
            }
            if (nLabel.color != color)
            {
                nLabel.color = color;
            }
            // Add up overall totals
            qLabel.SetText(quantity.Available.ToString());
        }
Exemple #9
0
        /// <summary>
        /// Updates an individual resource entry with the critters found.
        /// </summary>
        /// <param name="quantity">The quantity of this critter which is present.</param>
        internal void UpdateEntry(CritterTotals quantity)
        {
            // Update the tool tip text
            var tooltip = entry.GetComponent <ToolTip>();

            if (tooltip != null)
            {
                tooltip.OnToolTip = OnEntryTooltip;
            }
            // Determine the color for the labels (overdrawn is impossible for critters)
            var color = AVAILABLE_COLOR.Get(entry);

            if (quantity.Available <= 0)
            {
                color = UNAVAILABLE_COLOR.Get(entry);
            }
            LocText qLabel = entry.QuantityLabel, nLabel = entry.NameLabel;

            if (qLabel.color != color)
            {
                qLabel.color = color;
            }
            if (nLabel.color != color)
            {
                nLabel.color = color;
            }
            // Add up overall totals
            qLabel.SetText(quantity.Available.ToString());
        }
Exemple #10
0
        public static void SetText(LocText text, string value)
        {
            if (SaveLoader.Instance == null)
            {
                text.SetText(value);
                return;
            }

            text.color = Color.white;
            text.SetText(new[]
            {
                value,
//                CustomGameSettings.Instance.GetSettingsCoordinate(),
                GetPlanetName(),
                GetTraits()
            }.Join(null, "\n"));
        }
 private void SetInfoText()
 {
     characterName.SetText(GetSpawnableName());
     description.SetText(GetSpawnableDescription());
     itemName.SetText(GetSpawnableName());
     quantity.SetText(GetSpawnableQuantityOnly());
     currentQuantity.SetText(GetCurrentQuantity());
 }
 /// <summary>
 /// Sets the displayed title and tool tip.
 /// </summary>
 /// <param name="titleText">The text to display in the side screen.</param>
 /// <param name="tooltipText">The text to display on hover.</param>
 internal void SetTitle(string titleText, string tooltipText)
 {
     if (titleText != text.text)
     {
         text.SetText(titleText);
     }
     tooltip.toolTip = tooltipText;
 }
        /// <summary>
        /// Refreshes the maximum available mass heading.
        /// </summary>
        /// <param name="harvestable">The POI to be harvested.</param>
        private void RefreshMassHeader(HarvestablePOIStates.Instance harvestable)
        {
            string mass = GameUtil.GetFormattedMass(harvestable.poiCapacity);

            if (massLabel.text != mass)
            {
                massLabel.SetText(mass);
            }
        }
Exemple #14
0
    private void RebuildUGCButtons()
    {
        ListPool <SteamUGCService.Mod, ScenariosMenu> .PooledList pooledList = ListPool <SteamUGCService.Mod, ScenariosMenu> .Allocate();

        bool flag = pooledList.Count > 0;

        noScenariosText.gameObject.SetActive(!flag);
        contentRoot.gameObject.SetActive(flag);
        bool flag2 = true;

        if (pooledList.Count != 0)
        {
            for (int i = 0; i < pooledList.Count; i++)
            {
                GameObject gameObject = Util.KInstantiateUI(ugcButtonPrefab, ugcContainer, false);
                gameObject.name = pooledList[i].title + "_button";
                gameObject.gameObject.SetActive(true);
                HierarchyReferences component      = gameObject.GetComponent <HierarchyReferences>();
                TMP_FontAsset       fontForLangage = LanguageOptionsScreen.GetFontForLangage(pooledList[i].fileId);
                LocText             reference      = component.GetReference <LocText>("Title");
                reference.SetText(pooledList[i].title);
                reference.font = fontForLangage;
                Texture2D previewImage = pooledList[i].previewImage;
                if ((UnityEngine.Object)previewImage != (UnityEngine.Object)null)
                {
                    Image reference2 = component.GetReference <Image>("Image");
                    reference2.sprite = Sprite.Create(previewImage, new Rect(Vector2.zero, new Vector2((float)previewImage.width, (float)previewImage.height)), Vector2.one * 0.5f);
                }
                KButton           component2 = gameObject.GetComponent <KButton>();
                int               index      = i;
                PublishedFileId_t item       = pooledList[index].fileId;
                component2.onClick += delegate
                {
                    ShowDetails(item);
                };
                component2.onDoubleClick += delegate
                {
                    LoadScenario(item);
                };
                buttons.Add(gameObject);
                if (item == activeItem)
                {
                    flag2 = false;
                }
            }
        }
        if (flag2)
        {
            HideDetails();
        }
        pooledList.Recycle();
    }
 public bool TryUpdate(Attributes attributes)
 {
     foreach (AttributeInstance attribute2 in attributes)
     {
         if (attribute == attribute2.modifier && !attribute2.hide)
         {
             locText.SetText(attribute.GetDescription(attribute2));
             toolTip.toolTip = toolTipFunc(attribute2);
             return(true);
         }
     }
     return(false);
 }
    public void Apply(Chore.Precondition.Context context)
    {
        ChoreConsumer consumer = context.consumerState.consumer;

        if (targetChore != context.chore || !object.ReferenceEquals(context.chore.target, lastChoreTarget) || !(context.chore.masterPriority == lastPrioritySetting))
        {
            targetChore         = context.chore;
            lastChoreTarget     = context.chore.target;
            lastPrioritySetting = context.chore.masterPriority;
            string choreName = GameUtil.GetChoreName(context.chore, context.data);
            string text      = GameUtil.ChoreGroupsForChoreType(context.chore.choreType);
            string text2     = UI.UISIDESCREENS.MINIONTODOSIDESCREEN.CHORE_TARGET;
            text2 = text2.Replace("{Target}", (!((Object)context.chore.target.gameObject == (Object)consumer.gameObject)) ? context.chore.target.gameObject.GetProperName() : UI.UISIDESCREENS.MINIONTODOSIDESCREEN.SELF_LABEL.text);
            if (text != null)
            {
                text2 = text2.Replace("{Groups}", text);
            }
            string     text3      = (context.chore.masterPriority.priority_class != 0) ? string.Empty : context.chore.masterPriority.priority_value.ToString();
            Sprite     sprite     = (context.chore.masterPriority.priority_class != 0) ? null : prioritySprites[context.chore.masterPriority.priority_value - 1];
            ChoreGroup choreGroup = BestPriorityGroup(context, consumer);
            icon.sprite = ((choreGroup == null) ? null : Assets.GetSprite(choreGroup.sprite));
            label.SetText(choreName);
            subLabel.SetText(text2);
            priorityLabel.SetText(text3);
            priorityIcon.sprite = sprite;
            moreLabel.text      = string.Empty;
            GetComponent <ToolTip>().SetSimpleTooltip(TooltipForChore(context, consumer));
            KButton componentInChildren = GetComponentInChildren <KButton>();
            componentInChildren.ClearOnClick();
            if ((Object)componentInChildren.bgImage != (Object)null)
            {
                componentInChildren.bgImage.colorStyleSetting = ((!((Object)context.chore.driver == (Object)consumer.choreDriver)) ? buttonColorSettingStandard : buttonColorSettingCurrent);
                componentInChildren.bgImage.ApplyColorStyleSetting();
            }
            GameObject gameObject = context.chore.target.gameObject;
            componentInChildren.ClearOnPointerEvents();
            componentInChildren.GetComponentInChildren <KButton>().onClick += delegate
            {
                if (context.chore != null && !context.chore.target.isNull)
                {
                    Vector3 position  = context.chore.target.gameObject.transform.position;
                    float   x         = position.x;
                    Vector3 position2 = context.chore.target.gameObject.transform.position;
                    float   y         = position2.y + 1f;
                    Vector3 position3 = CameraController.Instance.transform.position;
                    Vector3 pos       = new Vector3(x, y, position3.z);
                    CameraController.Instance.SetTargetPos(pos, 10f, true);
                }
            };
        }
    }
 private void Start()
 {
     inputField.minValue     = 0f;
     inputField.maxValue     = (float)MAX_VALUE;
     inputField.currentValue = (float)SaveGame.Instance.minGermCountForDisinfect;
     inputField.SetDisplayValue(SaveGame.Instance.minGermCountForDisinfect.ToString());
     inputField.onEndEdit += delegate
     {
         ReceiveValueFromInput(inputField.currentValue);
     };
     inputField.decimalPlaces = 1;
     inputField.Activate();
     slider.minValue         = 0f;
     slider.maxValue         = (float)(MAX_VALUE / SLIDER_CONVERSION);
     slider.wholeNumbers     = true;
     slider.value            = (float)(SaveGame.Instance.minGermCountForDisinfect / SLIDER_CONVERSION);
     slider.onReleaseHandle += OnReleaseHandle;
     slider.onDrag          += delegate
     {
         ReceiveValueFromSlider(slider.value);
     };
     slider.onPointerDown += delegate
     {
         ReceiveValueFromSlider(slider.value);
     };
     slider.onMove += delegate
     {
         ReceiveValueFromSlider(slider.value);
         OnReleaseHandle();
     };
     unitsLabel.SetText(UI.OVERLAYS.DISEASE.DISINFECT_THRESHOLD_DIAGRAM.UNITS);
     minLabel.SetText(UI.OVERLAYS.DISEASE.DISINFECT_THRESHOLD_DIAGRAM.MIN_LABEL);
     maxLabel.SetText(UI.OVERLAYS.DISEASE.DISINFECT_THRESHOLD_DIAGRAM.MAX_LABEL);
     thresholdPrefix.SetText(UI.OVERLAYS.DISEASE.DISINFECT_THRESHOLD_DIAGRAM.THRESHOLD_PREFIX);
     toolTip.OnToolTip = delegate
     {
         toolTip.ClearMultiStringTooltip();
         if (SaveGame.Instance.enableAutoDisinfect)
         {
             toolTip.AddMultiStringTooltip(UI.OVERLAYS.DISEASE.DISINFECT_THRESHOLD_DIAGRAM.TOOLTIP.ToString().Replace("{NumberOfGerms}", SaveGame.Instance.minGermCountForDisinfect.ToString()), null);
         }
         else
         {
             toolTip.AddMultiStringTooltip(UI.OVERLAYS.DISEASE.DISINFECT_THRESHOLD_DIAGRAM.TOOLTIP_DISABLED.ToString(), null);
         }
         return(string.Empty);
     };
     disabledImage.gameObject.SetActive(!SaveGame.Instance.enableAutoDisinfect);
     toggle.isOn            = SaveGame.Instance.enableAutoDisinfect;
     toggle.onValueChanged += OnClickToggle;
 }
 public bool TryUpdate(Amounts amounts)
 {
     foreach (AmountInstance amount2 in amounts)
     {
         if (amount == amount2.amount && !amount2.hide)
         {
             locText.SetText(amount.GetDescription(amount2));
             toolTip.toolTip = toolTipFunc(amount2);
             imageToggle.SetValue(amount2);
             return(true);
         }
     }
     return(false);
 }
 public void SetSubTitle(string newTitle)
 {
     if ((UnityEngine.Object)subTitle != (UnityEngine.Object)null)
     {
         if (string.IsNullOrEmpty(newTitle))
         {
             subTitle.gameObject.SetActive(false);
         }
         else
         {
             subTitle.gameObject.SetActive(true);
             subTitle.SetText(newTitle);
         }
     }
 }
 private void RefreshPage()
 {
     for (int i = 0; i < base.transform.childCount; i++)
     {
         if (i < currentPage * childrenPerPage)
         {
             base.transform.GetChild(i).gameObject.SetActive(false);
         }
         else if (i >= currentPage * childrenPerPage + childrenPerPage)
         {
             base.transform.GetChild(i).gameObject.SetActive(false);
         }
         else
         {
             base.transform.GetChild(i).gameObject.SetActive(true);
         }
     }
     pageLabel.SetText(currentPage % pageCount + 1 + "/" + pageCount);
 }
Exemple #21
0
    protected override void OnSpawn()
    {
        base.OnSpawn();
        dismissButton.onClick += Deactivate;
        LocText reference = dismissButton.GetComponent <HierarchyReferences>().GetReference <LocText>("Title");

        reference.SetText(UI.FRONTEND.OPTIONS_SCREEN.BACK);
        closeButton.onClick    += Deactivate;
        workshopButton.onClick += delegate
        {
            OnClickOpenWorkshop();
        };
        uninstallButton.onClick += delegate
        {
            OnClickUninstall();
        };
        uninstallButton.gameObject.SetActive(false);
        RebuildScreen();
    }
Exemple #22
0
    protected override void OnSpawn()
    {
        base.OnSpawn();
        title.SetText(UI.FRONTEND.GRAPHICS_OPTIONS_SCREEN.TITLE);
        originalSettings           = CaptureSettings();
        applyButton.isInteractable = false;
        applyButton.onClick       += OnApply;
        applyButton.GetComponentInChildren <LocText>().SetText(UI.FRONTEND.GRAPHICS_OPTIONS_SCREEN.APPLYBUTTON);
        doneButton.onClick  += OnDone;
        closeButton.onClick += OnDone;
        doneButton.GetComponentInChildren <LocText>().SetText(UI.FRONTEND.GRAPHICS_OPTIONS_SCREEN.DONE_BUTTON);
        resolutionDropdown.ClearOptions();
        BuildOptions();
        resolutionDropdown.options = options;
        resolutionDropdown.onValueChanged.AddListener(OnResolutionChanged);
        fullscreenToggle.ChangeState(Screen.fullScreen ? 1 : 0);
        MultiToggle multiToggle = fullscreenToggle;

        multiToggle.onClick = (System.Action)Delegate.Combine(multiToggle.onClick, new System.Action(OnFullscreenToggle));
        fullscreenToggle.GetComponentInChildren <LocText>().SetText(UI.FRONTEND.GRAPHICS_OPTIONS_SCREEN.FULLSCREEN);
        resolutionDropdown.transform.parent.GetComponentInChildren <LocText>().SetText(UI.FRONTEND.GRAPHICS_OPTIONS_SCREEN.RESOLUTION);
        if (fullscreenToggle.CurrentState == 1)
        {
            int resolutionIndex = GetResolutionIndex(originalSettings.resolution);
            if (resolutionIndex != -1)
            {
                resolutionDropdown.value = resolutionIndex;
            }
        }
        CanvasScalers = UnityEngine.Object.FindObjectsOfType <KCanvasScaler>();
        UpdateSliderLabel();
        uiScaleSlider.onValueChanged.AddListener(delegate
        {
            sliderLabel.text = uiScaleSlider.value + "%";
        });
        uiScaleSlider.onReleaseHandle += delegate
        {
            UpdateUIScale(uiScaleSlider.value);
        };
    }
Exemple #23
0
        /// <summary>
        /// Creates a new blank label.
        /// </summary>
        /// <param name="sis">The info screen for the label prefab.</param>
        /// <param name="parent">The parent object for the label.</param>
        /// <param name="id">The unique ID of this label.</param>
        internal CachedStorageLabel(SimpleInfoScreen sis, GameObject parent, string id)
        {
            var label     = Util.KInstantiate(sis.attributesLabelButtonTemplate, parent, id);
            var transform = label.transform;

            transform.localScale = Vector3.one;
            labelObj             = label;
            freeze = label.AddOrGet <LayoutElement>();
            frozen = FREEZE_THAWED;
            label.TryGetComponent(out selectButton);
            label.TryGetComponent(out thaw);
            Lines = 0;
            selectButton.onClick += Select;
            tooltip = label.GetComponentInChildren <ToolTip>();
            text    = label.GetComponentInChildren <LocText>();
            if (id == EMPTY_ITEM)
            {
                text.SetText(STRINGS.UI.DETAILTABS.DETAILS.STORAGE_EMPTY);
            }
            // Set up the manual drop button, but default disable
            transform = transform.Find("removeAttributeButton");
            if (transform != null)
            {
                var remove = transform.FindComponent <KButton>();
                remove.enabled = false;
                remove.gameObject.SetActive(false);
                remove.onClick += Drop;
                removeButton    = remove;
            }
            else
            {
                removeButton = null;
            }
            active         = false;
            this.id        = id;
            item           = null;
            storage        = null;
            freeze.enabled = false;
        }
 public void Initialize(SingleEntityReceptacle target)
 {
     if ((Object)target == (Object)null)
     {
         Debug.LogError("SingleObjectReceptacle provided was null.");
     }
     else
     {
         targetReceptacle = target;
         base.gameObject.SetActive(true);
         depositObjectMap = new Dictionary <ReceptacleToggle, SelectableEntity>();
         entityToggles.ForEach(delegate(ReceptacleToggle rbi)
         {
             Object.Destroy(rbi.gameObject);
         });
         entityToggles.Clear();
         Tag[]            possibleDepositObjectTags = target.possibleDepositObjectTags;
         ReceptacleToggle newToggle;
         foreach (Tag tag in possibleDepositObjectTags)
         {
             List <GameObject> prefabsWithTag = Assets.GetPrefabsWithTag(tag);
             if ((Object)targetReceptacle.rotatable == (Object)null)
             {
                 prefabsWithTag.RemoveAll(delegate(GameObject go)
                 {
                     IReceptacleDirection component3 = go.GetComponent <IReceptacleDirection>();
                     return(component3 != null && component3.Direction != targetReceptacle.Direction);
                 });
             }
             List <IHasSortOrder> list = new List <IHasSortOrder>();
             foreach (GameObject item in prefabsWithTag)
             {
                 IHasSortOrder component = item.GetComponent <IHasSortOrder>();
                 if (component != null)
                 {
                     list.Add(component);
                 }
             }
             Debug.Assert(list.Count == prefabsWithTag.Count, "Not all entities in this receptacle implement IHasSortOrder!");
             list.Sort((IHasSortOrder a, IHasSortOrder b) => a.sortOrder - b.sortOrder);
             foreach (IHasSortOrder item2 in list)
             {
                 GameObject gameObject  = (item2 as MonoBehaviour).gameObject;
                 GameObject gameObject2 = Util.KInstantiateUI(entityToggle, requestObjectList, false);
                 gameObject2.SetActive(true);
                 newToggle = gameObject2.GetComponent <ReceptacleToggle>();
                 IReceptacleDirection component2 = gameObject.GetComponent <IReceptacleDirection>();
                 string properName = gameObject.GetProperName();
                 newToggle.title.text = properName;
                 Sprite entityIcon = GetEntityIcon(gameObject.PrefabID());
                 if ((Object)entityIcon == (Object)null)
                 {
                     entityIcon = elementPlaceholderSpr;
                 }
                 newToggle.image.sprite    = entityIcon;
                 newToggle.toggle.onClick += delegate
                 {
                     ToggleClicked(newToggle);
                 };
                 newToggle.toggle.onPointerEnter += delegate
                 {
                     CheckAmountsAndUpdate(null);
                 };
                 depositObjectMap.Add(newToggle, new SelectableEntity
                 {
                     tag       = gameObject.PrefabID(),
                     direction = (component2?.Direction ?? SingleEntityReceptacle.ReceptacleDirection.Top),
                     asset     = gameObject
                 });
                 entityToggles.Add(newToggle);
             }
         }
         selectedEntityToggle = null;
         if (entityToggles.Count > 0)
         {
             if (entityPreviousSelectionMap.ContainsKey(targetReceptacle))
             {
                 int index = entityPreviousSelectionMap[targetReceptacle];
                 ToggleClicked(entityToggles[index]);
             }
             else
             {
                 subtitleLabel.SetText(Strings.Get(subtitleStringSelect).ToString());
                 requestSelectedEntityBtn.isInteractable = false;
                 descriptionLabel.SetText(Strings.Get(subtitleStringSelectDescription).ToString());
                 HideAllDescriptorPanels();
             }
         }
         onStorageChangedHandle       = targetReceptacle.gameObject.Subscribe(-1697596308, CheckAmountsAndUpdate);
         onOccupantValidChangedHandle = targetReceptacle.gameObject.Subscribe(-1820564715, OnOccupantValidChanged);
         UpdateState(null);
         SimAndRenderScheduler.instance.Add(this, false);
     }
 }
Exemple #25
0
    private void PopulateElements(object data = null)
    {
        refreshHandle.ClearScheduler();
        refreshHandle = UIScheduler.Instance.Schedule("RefreshToDoList", 0.1f, PopulateElements, null, null);
        ListPool <Chore.Precondition.Context, BuildingChoresPanel> .PooledList pooledList = ListPool <Chore.Precondition.Context, BuildingChoresPanel> .Allocate();

        ChoreConsumer.PreconditionSnapshot lastPreconditionSnapshot = choreConsumer.GetLastPreconditionSnapshot();
        if (lastPreconditionSnapshot.doFailedContextsNeedSorting)
        {
            lastPreconditionSnapshot.failedContexts.Sort();
            lastPreconditionSnapshot.doFailedContextsNeedSorting = false;
        }
        pooledList.AddRange(lastPreconditionSnapshot.failedContexts);
        pooledList.AddRange(lastPreconditionSnapshot.succeededContexts);
        Chore.Precondition.Context choreB = default(Chore.Precondition.Context);
        MinionTodoChoreEntry       minionTodoChoreEntry = null;
        int         num       = 0;
        Schedulable component = DetailsScreen.Instance.target.GetComponent <Schedulable>();
        string      arg       = string.Empty;
        Schedule    schedule  = component.GetSchedule();

        if (schedule != null)
        {
            ScheduleBlock block = schedule.GetBlock(Schedule.GetBlockIdx());
            arg = block.name;
        }
        currentScheduleBlockLabel.SetText(string.Format(UI.UISIDESCREENS.MINIONTODOSIDESCREEN.CURRENT_SCHEDULE_BLOCK, arg));
        choreTargets.Clear();
        bool flag = false;

        activeChoreEntries = 0;
        for (int num2 = pooledList.Count - 1; num2 >= 0; num2--)
        {
            Chore.Precondition.Context context = pooledList[num2];
            if (context.chore != null)
            {
                Chore.Precondition.Context context2 = pooledList[num2];
                if (!context2.chore.target.isNull)
                {
                    Chore.Precondition.Context context3 = pooledList[num2];
                    if (!((UnityEngine.Object)context3.chore.target.gameObject == (UnityEngine.Object)null) && pooledList[num2].IsPotentialSuccess())
                    {
                        Chore.Precondition.Context context4 = pooledList[num2];
                        if ((UnityEngine.Object)context4.chore.driver == (UnityEngine.Object)choreConsumer.choreDriver)
                        {
                            currentTask.Apply(pooledList[num2]);
                            minionTodoChoreEntry = currentTask;
                            choreB = pooledList[num2];
                            num    = 0;
                            flag   = true;
                        }
                        else if (!flag && activeChoreEntries != 0 && GameUtil.AreChoresUIMergeable(pooledList[num2], choreB))
                        {
                            num++;
                            minionTodoChoreEntry.SetMoreAmount(num);
                        }
                        else
                        {
                            ChoreConsumer obj = choreConsumer;
                            Chore.Precondition.Context context5            = pooledList[num2];
                            HierarchyReferences        hierarchyReferences = PriorityGroupForPriority(obj, context5.chore);
                            MinionTodoChoreEntry       choreEntry          = GetChoreEntry(hierarchyReferences.GetReference <RectTransform>("EntriesContainer"));
                            choreEntry.Apply(pooledList[num2]);
                            minionTodoChoreEntry = choreEntry;
                            choreB = pooledList[num2];
                            num    = 0;
                            flag   = false;
                        }
                    }
                }
            }
        }
        pooledList.Recycle();
        for (int num3 = choreEntries.Count - 1; num3 >= activeChoreEntries; num3--)
        {
            choreEntries[num3].gameObject.SetActive(false);
        }
        foreach (Tuple <PriorityScreen.PriorityClass, int, HierarchyReferences> priorityGroup in priorityGroups)
        {
            RectTransform reference = priorityGroup.third.GetReference <RectTransform>("EntriesContainer");
            priorityGroup.third.gameObject.SetActive(reference.childCount > 0);
        }
    }
Exemple #26
0
 protected override void OnSpawn()
 {
     base.OnSpawn();
     title.SetText(UI.FRONTEND.OPTIONS_SCREEN.TITLE);
     backButton.transform.SetAsLastSibling();
 }
    protected override void OnSpawn()
    {
        base.OnSpawn();
        closeButton.onClick += delegate
        {
            OnClose(base.gameObject);
        };
        doneButton.onClick += delegate
        {
            OnClose(base.gameObject);
        };
        sliderPool = new UIPool <SliderContainer>(sliderPrefab);
        Dictionary <string, AudioMixer.UserVolumeBus> userVolumeSettings = AudioMixer.instance.userVolumeSettings;

        foreach (KeyValuePair <string, AudioMixer.UserVolumeBus> item in userVolumeSettings)
        {
            SliderContainer newSlider = sliderPool.GetFreeElement(sliderGroup, true);
            sliderBusMap.Add(newSlider.slider, item.Key);
            newSlider.slider.value   = item.Value.busLevel;
            newSlider.nameLabel.text = item.Value.labelString;
            newSlider.UpdateSliderLabel(item.Value.busLevel);
            newSlider.slider.ClearReleaseHandleEvent();
            newSlider.slider.onValueChanged.AddListener(delegate
            {
                OnReleaseHandle(newSlider.slider);
            });
            if (item.Key == "Master")
            {
                newSlider.transform.SetSiblingIndex(2);
                newSlider.slider.onValueChanged.AddListener(CheckMasterValue);
                CheckMasterValue(item.Value.busLevel);
            }
        }
        HierarchyReferences component  = alwaysPlayMusicButton.GetComponent <HierarchyReferences>();
        GameObject          gameObject = component.GetReference("Button").gameObject;

        gameObject.GetComponent <ToolTip>().SetSimpleTooltip(UI.FRONTEND.AUDIO_OPTIONS_SCREEN.MUSIC_EVERY_CYCLE_TOOLTIP);
        component.GetReference("CheckMark").gameObject.SetActive(MusicManager.instance.alwaysPlayMusic);
        gameObject.GetComponent <KButton>().onClick += delegate
        {
            ToggleAlwaysPlayMusic();
        };
        LocText reference = component.GetReference <LocText>("Label");

        reference.SetText(UI.FRONTEND.AUDIO_OPTIONS_SCREEN.MUSIC_EVERY_CYCLE);
        if (!KPlayerPrefs.HasKey(AlwaysPlayAutomation))
        {
            KPlayerPrefs.SetInt(AlwaysPlayAutomation, 1);
        }
        HierarchyReferences component2  = alwaysPlayAutomationButton.GetComponent <HierarchyReferences>();
        GameObject          gameObject2 = component2.GetReference("Button").gameObject;

        gameObject2.GetComponent <ToolTip>().SetSimpleTooltip(UI.FRONTEND.AUDIO_OPTIONS_SCREEN.AUTOMATION_SOUNDS_ALWAYS_TOOLTIP);
        gameObject2.GetComponent <KButton>().onClick += delegate
        {
            ToggleAlwaysPlayAutomation();
        };
        LocText reference2 = component2.GetReference <LocText>("Label");

        reference2.SetText(UI.FRONTEND.AUDIO_OPTIONS_SCREEN.AUTOMATION_SOUNDS_ALWAYS);
        component2.GetReference("CheckMark").gameObject.SetActive((KPlayerPrefs.GetInt(AlwaysPlayAutomation) == 1) ? true : false);
        if (!KPlayerPrefs.HasKey(MuteOnFocusLost))
        {
            KPlayerPrefs.SetInt(MuteOnFocusLost, 0);
        }
        HierarchyReferences component3  = muteOnFocusLostToggle.GetComponent <HierarchyReferences>();
        GameObject          gameObject3 = component3.GetReference("Button").gameObject;

        gameObject3.GetComponent <ToolTip>().SetSimpleTooltip(UI.FRONTEND.AUDIO_OPTIONS_SCREEN.MUTE_ON_FOCUS_LOST_TOOLTIP);
        gameObject3.GetComponent <KButton>().onClick += delegate
        {
            ToggleMuteOnFocusLost();
        };
        LocText reference3 = component3.GetReference <LocText>("Label");

        reference3.SetText(UI.FRONTEND.AUDIO_OPTIONS_SCREEN.MUTE_ON_FOCUS_LOST);
        component3.GetReference("CheckMark").gameObject.SetActive((KPlayerPrefs.GetInt(MuteOnFocusLost) == 1) ? true : false);
    }
    private void SetDescription(string str, HierarchyReferences refs)
    {
        LocText reference = refs.GetReference <LocText>("Desc");

        reference.SetText(str);
    }
    public void Initialize(ComplexFabricator target)
    {
        if ((Object)target == (Object)null)
        {
            Debug.LogError("ComplexFabricator provided was null.");
        }
        else
        {
            targetFab = target;
            base.gameObject.SetActive(true);
            recipeMap = new Dictionary <GameObject, ComplexRecipe>();
            recipeToggles.ForEach(delegate(GameObject rbi)
            {
                Object.Destroy(rbi.gameObject);
            });
            recipeToggles.Clear();
            GridLayoutGroup component = recipeGrid.GetComponent <GridLayoutGroup>();
            switch (targetFab.sideScreenStyle)
            {
            case StyleSetting.ListResult:
            case StyleSetting.ListInput:
            case StyleSetting.ListInputOutput:
            {
                component.constraintCount = 1;
                GridLayoutGroup gridLayoutGroup2 = component;
                Vector2         cellSize2        = component.cellSize;
                gridLayoutGroup2.cellSize = new Vector2(262f, cellSize2.y);
                break;
            }

            case StyleSetting.ClassicFabricator:
                component.constraintCount       = 128;
                component.cellSize              = new Vector2(78f, 96f);
                buttonScrollContainer.minHeight = 100f;
                break;

            case StyleSetting.ListQueueHybrid:
                component.constraintCount       = 1;
                component.cellSize              = new Vector2(264f, 64f);
                buttonScrollContainer.minHeight = 66f;
                break;

            default:
            {
                component.constraintCount = 3;
                GridLayoutGroup gridLayoutGroup = component;
                Vector2         cellSize        = component.cellSize;
                gridLayoutGroup.cellSize = new Vector2(116f, cellSize.y);
                break;
            }
            }
            int             num     = 0;
            ComplexRecipe[] recipes = targetFab.GetRecipes();
            ComplexRecipe[] array   = recipes;
            foreach (ComplexRecipe recipe in array)
            {
                bool flag = false;
                if (DebugHandler.InstantBuildMode)
                {
                    flag = true;
                }
                else if (recipe.RequiresTechUnlock() && recipe.IsRequiredTechUnlocked())
                {
                    flag = true;
                }
                else if (target.GetRecipeQueueCount(recipe) != 0)
                {
                    flag = true;
                }
                else if (AnyRecipeRequirementsDiscovered(recipe))
                {
                    flag = true;
                }
                else if (HasAnyRecipeRequirements(recipe))
                {
                    flag = true;
                }
                if (flag)
                {
                    num++;
                    Tuple <Sprite, Color> uISprite  = Def.GetUISprite(recipe.ingredients[0].material, "ui", false);
                    Tuple <Sprite, Color> uISprite2 = Def.GetUISprite(recipe.results[0].material, "ui", false);
                    KToggle    newToggle            = null;
                    GameObject entryGO;
                    switch (target.sideScreenStyle)
                    {
                    case StyleSetting.ListInputOutput:
                    case StyleSetting.GridInputOutput:
                    {
                        newToggle = Util.KInstantiateUI <KToggle>(recipeButtonMultiple, recipeGrid, false);
                        entryGO   = newToggle.gameObject;
                        HierarchyReferences           component2  = newToggle.GetComponent <HierarchyReferences>();
                        ComplexRecipe.RecipeElement[] ingredients = recipe.ingredients;
                        foreach (ComplexRecipe.RecipeElement recipeElement in ingredients)
                        {
                            GameObject gameObject = Util.KInstantiateUI(component2.GetReference("FromIconPrefab").gameObject, component2.GetReference("FromIcons").gameObject, true);
                            gameObject.GetComponent <Image>().sprite = Def.GetUISprite(recipeElement.material, "ui", false).first;
                            gameObject.GetComponent <Image>().color  = Def.GetUISprite(recipeElement.material, "ui", false).second;
                            gameObject.gameObject.name = recipeElement.material.Name;
                        }
                        ComplexRecipe.RecipeElement[] results = recipe.results;
                        foreach (ComplexRecipe.RecipeElement recipeElement2 in results)
                        {
                            GameObject gameObject2 = Util.KInstantiateUI(component2.GetReference("ToIconPrefab").gameObject, component2.GetReference("ToIcons").gameObject, true);
                            gameObject2.GetComponent <Image>().sprite = Def.GetUISprite(recipeElement2.material, "ui", false).first;
                            gameObject2.GetComponent <Image>().color  = Def.GetUISprite(recipeElement2.material, "ui", false).second;
                            gameObject2.gameObject.name = recipeElement2.material.Name;
                        }
                        break;
                    }

                    case StyleSetting.ListQueueHybrid:
                    {
                        newToggle = Util.KInstantiateUI <KToggle>(recipeButtonQueueHybrid, recipeGrid, false);
                        entryGO   = newToggle.gameObject;
                        recipeMap.Add(entryGO, recipe);
                        Image image = entryGO.GetComponentsInChildrenOnly <Image>()[2];
                        if (recipe.nameDisplay == ComplexRecipe.RecipeNameDisplay.Ingredient)
                        {
                            image.sprite = uISprite.first;
                            image.color  = uISprite.second;
                        }
                        else
                        {
                            image.sprite = uISprite2.first;
                            image.color  = uISprite2.second;
                        }
                        entryGO.GetComponentInChildren <LocText>().text = recipe.GetUIName();
                        bool flag2 = HasAllRecipeRequirements(recipe);
                        image.material = ((!flag2) ? Assets.UIPrefabs.TableScreenWidgets.DesaturatedUIMaterial : Assets.UIPrefabs.TableScreenWidgets.DefaultUIMaterial);
                        RefreshQueueCountDisplay(entryGO, targetFab);
                        entryGO.GetComponent <HierarchyReferences>().GetReference <MultiToggle>("DecrementButton").onClick = delegate
                        {
                            target.DecrementRecipeQueueCount(recipe, false);
                            RefreshQueueCountDisplay(entryGO, target);
                        };
                        entryGO.GetComponent <HierarchyReferences>().GetReference <MultiToggle>("IncrementButton").onClick = delegate
                        {
                            target.IncrementRecipeQueueCount(recipe);
                            RefreshQueueCountDisplay(entryGO, target);
                        };
                        entryGO.gameObject.SetActive(true);
                        break;
                    }

                    default:
                    {
                        newToggle = Util.KInstantiateUI <KToggle>(recipeButton, recipeGrid, false);
                        entryGO   = newToggle.gameObject;
                        Image componentInChildrenOnly = newToggle.gameObject.GetComponentInChildrenOnly <Image>();
                        if (target.sideScreenStyle == StyleSetting.GridInput || target.sideScreenStyle == StyleSetting.ListInput)
                        {
                            componentInChildrenOnly.sprite = uISprite.first;
                            componentInChildrenOnly.color  = uISprite.second;
                        }
                        else
                        {
                            componentInChildrenOnly.sprite = uISprite2.first;
                            componentInChildrenOnly.color  = uISprite2.second;
                        }
                        break;
                    }
                    }
                    if (targetFab.sideScreenStyle == StyleSetting.ClassicFabricator)
                    {
                        newToggle.GetComponentInChildren <LocText>().text = recipe.results[0].material.ProperName();
                    }
                    else if (targetFab.sideScreenStyle != StyleSetting.ListQueueHybrid)
                    {
                        newToggle.GetComponentInChildren <LocText>().text = string.Format(UI.UISIDESCREENS.REFINERYSIDESCREEN.RECIPE_FROM_TO_WITH_NEWLINES, recipe.ingredients[0].material.ProperName(), recipe.results[0].material.ProperName());
                    }
                    ToolTip component3 = entryGO.GetComponent <ToolTip>();
                    component3.toolTipPosition       = ToolTip.TooltipPosition.Custom;
                    component3.parentPositionAnchor  = new Vector2(0f, 0.5f);
                    component3.tooltipPivot          = new Vector2(1f, 1f);
                    component3.tooltipPositionOffset = new Vector2(-24f, 20f);
                    component3.ClearMultiStringTooltip();
                    component3.AddMultiStringTooltip(recipe.GetUIName(), styleTooltipHeader);
                    component3.AddMultiStringTooltip(recipe.description, styleTooltipBody);
                    newToggle.onClick += delegate
                    {
                        ToggleClicked(newToggle);
                    };
                    entryGO.SetActive(true);
                    recipeToggles.Add(entryGO);
                }
            }
            if (recipeToggles.Count > 0)
            {
                LayoutElement component4 = buttonScrollContainer.GetComponent <LayoutElement>();
                float         num2       = (float)num;
                Vector2       sizeDelta  = recipeButtonQueueHybrid.rectTransform().sizeDelta;
                component4.minHeight = Mathf.Min(451f, 2f + num2 * sizeDelta.y);
                subtitleLabel.SetText(UI.UISIDESCREENS.FABRICATORSIDESCREEN.SUBTITLE);
                noRecipesDiscoveredLabel.gameObject.SetActive(false);
            }
            else
            {
                subtitleLabel.SetText(UI.UISIDESCREENS.FABRICATORSIDESCREEN.NORECIPEDISCOVERED);
                noRecipesDiscoveredLabel.SetText(UI.UISIDESCREENS.FABRICATORSIDESCREEN.NORECIPEDISCOVERED_BODY);
                noRecipesDiscoveredLabel.gameObject.SetActive(true);
                LayoutElement component5 = buttonScrollContainer.GetComponent <LayoutElement>();
                Vector2       sizeDelta2 = noRecipesDiscoveredLabel.rectTransform.sizeDelta;
                component5.minHeight = sizeDelta2.y + 10f;
            }
            RefreshIngredientAvailabilityVis();
        }
    }