Example #1
0
 protected void EnableProceedButton()
 {
     proceedButton.isInteractable = true;
     proceedButton.ClearOnClick();
     proceedButton.onClick += delegate
     {
         OnProceed();
     };
 }
    private void ToggleNameEditing()
    {
        editNameButton.ClearOnClick();
        bool flag = !inputField.gameObject.activeInHierarchy;

        if ((UnityEngine.Object)randomNameButton != (UnityEngine.Object)null)
        {
            randomNameButton.gameObject.SetActive(flag);
        }
        SetEditingState(flag);
    }
 public void ShowComic(ComicData comic, bool isVictoryComic)
 {
     for (int i = 0; i < Mathf.Max(comic.images.Length, comic.stringKeys.Length); i++)
     {
         GameObject gameObject = Util.KInstantiateUI(panelPrefab, contentContainer, true);
         activePanels.Add(gameObject);
         gameObject.GetComponentInChildren <Image>().sprite = comic.images[i];
         gameObject.GetComponentInChildren <LocText>().SetText(comic.stringKeys[i]);
     }
     closeButton.ClearOnClick();
     if (isVictoryComic)
     {
         closeButton.onClick += delegate
         {
             Stop();
             Show(false);
         };
     }
     else
     {
         closeButton.onClick += delegate
         {
             Stop();
         };
     }
 }
Example #4
0
    private GameObject AddOrGetStorageLabel(Dictionary <string, GameObject> labels, GameObject panel, string id)
    {
        GameObject gameObject = null;

        if (labels.ContainsKey(id))
        {
            gameObject = labels[id];
            KButton component = gameObject.GetComponent <KButton>();
            component.ClearOnClick();
            Transform transform = gameObject.transform.Find("removeAttributeButton");
            if ((UnityEngine.Object)transform != (UnityEngine.Object)null)
            {
                KButton kButton = transform.FindComponent <KButton>();
                kButton.enabled = false;
                kButton.gameObject.SetActive(false);
                kButton.ClearOnClick();
            }
        }
        else
        {
            gameObject = Util.KInstantiate(attributesLabelButtonTemplate, panel.GetComponent <CollapsibleDetailContentPanel>().Content.gameObject, null);
            gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
            labels[id] = gameObject;
        }
        gameObject.SetActive(true);
        return(gameObject);
    }
    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);
                }
            };
        }
    }
Example #6
0
 public void Initialize(IEnumerable <IListableOption> contentKeys, Action <IListableOption, object> onEntrySelectedAction, Func <IListableOption, IListableOption, object, int> sortFunction = null, Action <DropDownEntry, object> refreshAction = null, bool displaySelectedValueWhenClosed = true, object targetData = null)
 {
     this.targetData                     = targetData;
     this.sortFunction                   = sortFunction;
     this.onEntrySelectedAction          = onEntrySelectedAction;
     this.displaySelectedValueWhenClosed = displaySelectedValueWhenClosed;
     rowRefreshAction                    = refreshAction;
     ChangeContent(contentKeys);
     openButton.ClearOnClick();
     openButton.onClick += delegate
     {
         OnClick();
     };
     canvasScaler = GameScreenManager.Instance.ssOverlayCanvas.GetComponent <KCanvasScaler>();
 }
Example #7
0
 public void Open()
 {
     base.gameObject.SetActive(true);
     buttonPool.ClearAll();
     foreach (MinionIdentity item in Components.MinionIdentities.Items)
     {
         KButton      btn = buttonPool.GetFreeElement(buttonParent, true);
         CrewPortrait componentInChildren = btn.GetComponentInChildren <CrewPortrait>();
         componentInChildren.SetIdentityObject(item, true);
         portraitList.Add(componentInChildren);
         btn.ClearOnClick();
         btn.onClick += delegate
         {
             SelectDuplicant(btn);
         };
         buttonIdentityMap.Add(btn, item);
     }
 }
Example #8
0
    private void AddExistingMod(string filename)
    {
        KButton freeElement = this.saveButtonPool.GetFreeElement(this.saveButtonRoot, true);

        freeElement.ClearOnClick();
        LocText componentInChildren = freeElement.GetComponentInChildren <LocText>();

        System.DateTime lastWriteTime = File.GetLastWriteTime(filename);
        componentInChildren.text = string.Format("{0}\n{1:H:mm:ss}\n" + Localization.GetFileDateFormat(1), Path.GetFileNameWithoutExtension(filename), lastWriteTime);
        freeElement.onClick     += delegate
        {
            this.onClick(filename);
        };
        bool flag = false;

        try
        {
            SaveGame.Header header;
            flag = (SaveLoader.LoadHeader(filename, out header).saveMajorVersion >= 7);
        }
        catch (Exception ex)
        {
            global::Debug.LogWarning("Corrupted save file: " + filename + "\n" + ex.ToString(), null);
        }
        if (flag)
        {
            freeElement.onDoubleClick += delegate
            {
                this.onClick(filename);
                this.DoLoad();
            };
        }
        ImageToggleState component = freeElement.GetComponent <ImageToggleState>();

        component.colorStyleSetting = ((!flag) ? this.invalidSaveFileStyle : this.validSaveFileStyle);
        component.RefreshColorStyle();
        component.SetState(ImageToggleState.State.Inactive);
        component.ResetColor();
        freeElement.transform.SetAsLastSibling();
        this.fileButtonMap.Add(filename, freeElement);
    }
Example #9
0
 private void ConfigButtons()
 {
     closeButton.ClearOnClick();
     closeButton.onClick += delegate
     {
         Show(false);
     };
     viewOtherColoniesButton.ClearOnClick();
     viewOtherColoniesButton.onClick += delegate
     {
         ToggleExplorer(true);
     };
     quitToMainMenuButton.ClearOnClick();
     quitToMainMenuButton.onClick += delegate
     {
         ConfirmDecision(UI.FRONTEND.MAINMENU.QUITCONFIRM, OnQuitConfirm);
     };
     closeScreenButton.ClearOnClick();
     closeScreenButton.onClick += delegate
     {
         Show(false);
     };
     viewOtherColoniesButton.gameObject.SetActive(false);
     if ((UnityEngine.Object)Game.Instance != (UnityEngine.Object)null)
     {
         closeScreenButton.gameObject.SetActive(true);
         closeScreenButton.GetComponentInChildren <LocText>().SetText(UI.RETIRED_COLONY_INFO_SCREEN.BUTTONS.RETURN_TO_GAME);
         quitToMainMenuButton.gameObject.SetActive(true);
     }
     else
     {
         closeScreenButton.gameObject.SetActive(true);
         closeScreenButton.GetComponentInChildren <LocText>().SetText(UI.RETIRED_COLONY_INFO_SCREEN.BUTTONS.CLOSE);
         quitToMainMenuButton.gameObject.SetActive(false);
     }
 }
 private void UpdateState(object data)
 {
     requestSelectedEntityBtn.ClearOnClick();
     if (!((Object)targetReceptacle == (Object)null))
     {
         if (CheckReceptacleOccupied())
         {
             Uprootable uprootable = targetReceptacle.Occupant.GetComponent <Uprootable>();
             if ((Object)uprootable != (Object)null && uprootable.IsMarkedForUproot)
             {
                 requestSelectedEntityBtn.onClick += delegate
                 {
                     uprootable.ForceCancelUproot(null);
                     UpdateState(null);
                 };
                 requestSelectedEntityBtn.GetComponentInChildren <LocText>().text = Strings.Get(requestStringCancelRemove).ToString();
                 requestSelectedEntityBtn.isInteractable = true;
                 subtitleLabel.SetText(string.Format(Strings.Get(subtitleStringAwaitingRemoval).ToString(), targetReceptacle.Occupant.GetProperName()));
             }
             else
             {
                 requestSelectedEntityBtn.onClick += delegate
                 {
                     targetReceptacle.OrderRemoveOccupant();
                     UpdateState(null);
                 };
                 requestSelectedEntityBtn.GetComponentInChildren <LocText>().text = Strings.Get(requestStringRemove).ToString();
                 requestSelectedEntityBtn.isInteractable = true;
                 subtitleLabel.SetText(string.Format(Strings.Get(subtitleStringEntityDeposited).ToString(), targetReceptacle.Occupant.GetProperName()));
             }
             ToggleObjectPicker(false);
             Tag tag = targetReceptacle.Occupant.GetComponent <KSelectable>().PrefabID();
             ConfigureActiveEntity(tag);
             SetResultDescriptions(targetReceptacle.Occupant);
         }
         else if (targetReceptacle.GetActiveRequest != null)
         {
             requestSelectedEntityBtn.onClick += delegate
             {
                 targetReceptacle.CancelActiveRequest();
                 ClearSelection();
                 UpdateAvailableAmounts(null);
                 UpdateState(null);
             };
             requestSelectedEntityBtn.GetComponentInChildren <LocText>().text = Strings.Get(requestStringCancelDeposit).ToString();
             requestSelectedEntityBtn.isInteractable = true;
             ToggleObjectPicker(false);
             ConfigureActiveEntity(targetReceptacle.GetActiveRequest.tags[0]);
             GameObject prefab = Assets.GetPrefab(targetReceptacle.GetActiveRequest.tags[0]);
             if ((Object)prefab != (Object)null)
             {
                 subtitleLabel.SetText(string.Format(Strings.Get(subtitleStringAwaitingDelivery).ToString(), prefab.GetProperName()));
                 SetResultDescriptions(prefab);
             }
         }
         else if ((Object)selectedEntityToggle != (Object)null)
         {
             requestSelectedEntityBtn.onClick += delegate
             {
                 targetReceptacle.CreateOrder(selectedDepositObjectTag);
                 UpdateAvailableAmounts(null);
                 UpdateState(null);
             };
             requestSelectedEntityBtn.GetComponentInChildren <LocText>().text = Strings.Get(requestStringDeposit).ToString();
             targetReceptacle.SetPreview(depositObjectMap[selectedEntityToggle].tag, false);
             bool flag = CanDepositEntity(depositObjectMap[selectedEntityToggle]);
             requestSelectedEntityBtn.isInteractable = flag;
             SetImageToggleState(selectedEntityToggle.toggle, (!flag) ? ImageToggleState.State.DisabledActive : ImageToggleState.State.Active);
             ToggleObjectPicker(true);
             GameObject prefab2 = Assets.GetPrefab(selectedDepositObjectTag);
             if ((Object)prefab2 != (Object)null)
             {
                 subtitleLabel.SetText(string.Format(Strings.Get(subtitleStringAwaitingSelection).ToString(), prefab2.GetProperName()));
                 SetResultDescriptions(prefab2);
             }
         }
         else
         {
             requestSelectedEntityBtn.GetComponentInChildren <LocText>().text = Strings.Get(requestStringDeposit).ToString();
             requestSelectedEntityBtn.isInteractable = false;
             ToggleObjectPicker(true);
         }
         UpdateAvailableAmounts(null);
         UpdateListeners();
     }
 }
Example #11
0
    private void AddExistingSaveFile(string savename, List <SaveGameFileDetails> fileDetailsList)
    {
        HierarchyReferences savenameRow  = savenameRowPool.GetFreeElement(saveButtonRoot, true);
        KButton             headerButton = savenameRow.GetReference <RectTransform>("Button").GetComponent <KButton>();

        headerButton.ClearOnClick();
        LocText       headerTitle         = savenameRow.GetReference <RectTransform>("HeaderTitle").GetComponent <LocText>();
        LocText       component           = savenameRow.GetReference <RectTransform>("SaveTitle").GetComponent <LocText>();
        LocText       component2          = savenameRow.GetReference <RectTransform>("HeaderDate").GetComponent <LocText>();
        RectTransform saveDetailsRow      = savenameRow.GetReference <RectTransform>("SaveDetailsRow");
        LocText       component3          = savenameRow.GetReference <RectTransform>("SaveDetailsBaseName").GetComponent <LocText>();
        RectTransform savefileRowTemplate = savenameRow.GetReference <RectTransform>("SavefileRowTemplate");

        fileDetailsList.Sort((SaveGameFileDetails x, SaveGameFileDetails y) => y.FileDate.CompareTo(x.FileDate));
        LocText             locText             = headerTitle;
        SaveGameFileDetails saveGameFileDetails = fileDetailsList[0];

        locText.text   = saveGameFileDetails.BaseName;
        component.text = savename;
        LocText             locText2             = component2;
        string              format               = "{0:H:mm:ss} - " + Localization.GetFileDateFormat(0);
        SaveGameFileDetails saveGameFileDetails2 = fileDetailsList[0];

        locText2.text = string.Format(format, saveGameFileDetails2.FileDate);
        LocText             locText3             = component3;
        LocString           bASE_NAME            = UI.FRONTEND.LOADSCREEN.BASE_NAME;
        SaveGameFileDetails saveGameFileDetails3 = fileDetailsList[0];

        locText3.text = $"{bASE_NAME}: {saveGameFileDetails3.BaseName}";
        for (int i = 0; i < savenameRow.transform.childCount; i++)
        {
            GameObject gameObject = savenameRow.transform.GetChild(i).gameObject;
            if ((UnityEngine.Object)gameObject != (UnityEngine.Object)null && gameObject.name.Contains("Clone"))
            {
                UnityEngine.Object.Destroy(gameObject);
            }
        }
        bool active = true;

        foreach (SaveGameFileDetails fileDetails2 in fileDetailsList)
        {
            SaveGameFileDetails fileDetails   = fileDetails2;
            RectTransform       rectTransform = UnityEngine.Object.Instantiate(savefileRowTemplate, savenameRow.transform);
            HierarchyReferences component4    = rectTransform.GetComponent <HierarchyReferences>();
            KButton             component5    = rectTransform.GetComponent <KButton>();
            RectTransform       reference     = component4.GetReference <RectTransform>("NewestLabel");
            RectTransform       reference2    = component4.GetReference <RectTransform>("AutoLabel");
            LocText             component6    = component4.GetReference <RectTransform>("SaveText").GetComponent <LocText>();
            LocText             component7    = component4.GetReference <RectTransform>("DateText").GetComponent <LocText>();
            reference.gameObject.SetActive(active);
            active = false;
            reference2.gameObject.SetActive(fileDetails.FileInfo.isAutoSave);
            component6.text     = Path.GetFileNameWithoutExtension(fileDetails.FileName);
            component7.text     = string.Format("{0:H:mm:ss} - " + Localization.GetFileDateFormat(0), fileDetails.FileDate);
            component5.onClick += delegate
            {
                onClick(fileDetails.FileName, savename);
            };
            component5.onDoubleClick += delegate
            {
                onClick(fileDetails.FileName, savename);
                Load();
            };
            fileButtonMap.Add(fileDetails.FileName, component5);
        }
        headerButton.onClick += delegate
        {
            bool activeSelf = saveDetailsRow.gameObject.activeSelf;
            bool flag       = (UnityEngine.Object)headerButton == (UnityEngine.Object)currentExpanded;
            if (flag)
            {
                SetChildrenActive(savenameRow, !activeSelf);
            }
            else if (!activeSelf && !flag)
            {
                SetChildrenActive(savenameRow, true);
            }
            if ((UnityEngine.Object)currentExpanded != (UnityEngine.Object)null && !flag)
            {
                SetHeaderButtonActive(currentExpanded, false);
            }
            currentExpanded = headerButton;
            SetHeaderButtonActive(currentExpanded, true);
            headerTitle.transform.parent.gameObject.SetActive(true);
            savefileRowTemplate.gameObject.SetActive(false);
            Action <string, string> action2 = onClick;
            SaveGameFileDetails     saveGameFileDetails5 = fileDetailsList[0];
            action2(saveGameFileDetails5.FileName, savename);
        };
        headerButton.onDoubleClick += delegate
        {
            Action <string, string> action = onClick;
            SaveGameFileDetails     saveGameFileDetails4 = fileDetailsList[0];
            action(saveGameFileDetails4.FileName, savename);
            LoadingOverlay.Load(DoLoad);
        };
        savenameRow.transform.SetAsLastSibling();
    }