private void Refresh(List <MinionAssignablesProxy> identities, bool rebuild)
    {
        Rotatable component = target.GetComponent <Rotatable>();
        bool      rotated   = (UnityEngine.Object)component != (UnityEngine.Object)null && component.IsRotated;

        defaultsRow.SetRotated(rotated);
        defaultsRow.SetContent(target.DefaultPermission, OnDefaultPermissionChanged);
        if (rebuild)
        {
            ClearContent();
        }
        foreach (MinionAssignablesProxy identity in identities)
        {
            AccessControlSideScreenRow accessControlSideScreenRow;
            if (rebuild)
            {
                accessControlSideScreenRow = rowPool.GetFreeElement(rowGroup, true);
                identityRowMap.Add(identity, accessControlSideScreenRow);
            }
            else
            {
                accessControlSideScreenRow = identityRowMap[identity];
            }
            AccessControl.Permission setPermission = target.GetSetPermission(identity);
            bool isDefault = target.IsDefaultPermission(identity);
            accessControlSideScreenRow.SetRotated(rotated);
            accessControlSideScreenRow.SetMinionContent(identity, setPermission, isDefault, OnPermissionChanged, OnPermissionDefault);
        }
        RefreshOnline();
        ContentContainer.SetActive(target.controlEnabled);
    }
Exemplo n.º 2
0
 private void Refresh(List <MinionAssignablesProxy> identities)
 {
     ClearContent();
     currentOwnerText.text = string.Format(UI.UISIDESCREENS.ASSIGNABLESIDESCREEN.UNASSIGNED);
     if (!((UnityEngine.Object)targetAssignable == (UnityEngine.Object)null))
     {
         if ((UnityEngine.Object)targetAssignable.GetComponent <Equippable>() == (UnityEngine.Object)null && !targetAssignable.HasTag(GameTags.NotRoomAssignable))
         {
             Room room = null;
             room = Game.Instance.roomProber.GetRoomOfGameObject(targetAssignable.gameObject);
             if (room != null)
             {
                 RoomType roomType = room.roomType;
                 if (roomType.primary_constraint != null && !roomType.primary_constraint.building_criteria(targetAssignable.GetComponent <KPrefabID>()))
                 {
                     AssignableSideScreenRow freeElement = rowPool.GetFreeElement(rowGroup, true);
                     freeElement.sideScreen = this;
                     identityRowMap.Add(room, freeElement);
                     freeElement.SetContent(room, OnRowClicked, this);
                     return;
                 }
             }
         }
         if (targetAssignable.canBePublic)
         {
             AssignableSideScreenRow freeElement2 = rowPool.GetFreeElement(rowGroup, true);
             freeElement2.sideScreen = this;
             freeElement2.transform.SetAsFirstSibling();
             identityRowMap.Add(Game.Instance.assignmentManager.assignment_groups["public"], freeElement2);
             freeElement2.SetContent(Game.Instance.assignmentManager.assignment_groups["public"], OnRowClicked, this);
         }
         foreach (MinionAssignablesProxy identity in identities)
         {
             AssignableSideScreenRow freeElement3 = rowPool.GetFreeElement(rowGroup, true);
             freeElement3.sideScreen = this;
             identityRowMap.Add(identity, freeElement3);
             freeElement3.SetContent(identity, OnRowClicked, this);
         }
         ExecuteSort(activeSortFunction);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Refreshes the list of available Duplicants.
 /// </summary>
 private void Refresh()
 {
     ClearContent();
     if (profile != null && rowPool != null)
     {
         var publicIdentity = Game.Instance.assignmentManager.assignment_groups[
             "public"];
         // "Public"
         var publicRow = rowPool.GetFreeElement(rowGroup, true);
         publicRow.sideScreen = this;
         publicRow.transform.SetAsFirstSibling();
         allowRows.Add(publicIdentity, publicRow);
         publicRow.SetContent(publicIdentity, this);
         // Each Duplicant
         foreach (var identity in identities)
         {
             var dupeRow = rowPool.GetFreeElement(rowGroup, true);
             dupeRow.sideScreen = this;
             allowRows.Add(identity, dupeRow);
             dupeRow.SetContent(identity, this);
         }
         ExecuteSort();
     }
 }
Exemplo n.º 4
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);
     }
 }
Exemplo n.º 5
0
 public void SetTarget(string path)
 {
     if (string.IsNullOrEmpty(path))
     {
         Debug.LogError("The directory path provided is empty.");
         Show(false);
     }
     else if (!Directory.Exists(path))
     {
         Debug.LogError("The directory provided does not exist.");
         Show(false);
     }
     else
     {
         if (buttonPool == null)
         {
             buttonPool = new UIPool <KButton>(backupBtnPrefab);
         }
         currentPath = path;
         List <string> list = (from filename in Directory.GetFiles(path)
                               where Path.GetExtension(filename).ToLower() == ".sav"
                               select filename).OrderByDescending(File.GetLastWriteTime).ToList();
         string text = list[0];
         if (File.Exists(text))
         {
             mainSaveBtn.gameObject.SetActive(true);
             AddNewSave(mainSaveBtn, text);
         }
         else
         {
             mainSaveBtn.gameObject.SetActive(false);
         }
         if (list.Count > 1)
         {
             for (int i = 1; i < list.Count; i++)
             {
                 AddNewSave(buttonPool.GetFreeElement(buttonGroup, true), list[i]);
             }
         }
         Show(true);
     }
 }
    private void BuildDisplay()
    {
        string text = screens[activeScreen];
        string key  = "STRINGS.INPUT_BINDINGS." + text.ToUpper() + ".NAME";

        screenTitle.text = Strings.Get(key);
        if (entryPool == null)
        {
            entryPool = new UIPool <HorizontalLayoutGroup>(entryPrefab.GetComponent <HorizontalLayoutGroup>());
        }
        DestroyDisplay();
        int num = 0;

        for (int i = 0; i < GameInputMapping.KeyBindings.Length; i++)
        {
            BindingEntry binding = GameInputMapping.KeyBindings[i];
            if (binding.mGroup == screens[activeScreen] && binding.mRebindable)
            {
                GameObject gameObject          = entryPool.GetFreeElement(parent, true).gameObject;
                LocText    componentInChildren = gameObject.transform.GetChild(0).GetComponentInChildren <LocText>();
                string     key2 = "STRINGS.INPUT_BINDINGS." + binding.mGroup.ToUpper() + "." + binding.mAction.ToString().ToUpper();
                componentInChildren.text = Strings.Get(key2);
                LocText key_label = gameObject.transform.GetChild(1).GetComponentInChildren <LocText>();
                key_label.text = GetBindingText(binding);
                KButton button = gameObject.GetComponentInChildren <KButton>();
                button.onClick += delegate
                {
                    waitingForKeyPress  = true;
                    actionToRebind      = binding.mAction;
                    ignoreRootConflicts = binding.mIgnoreRootConflics;
                    activeButton        = button;
                    key_label.text      = UI.FRONTEND.INPUT_BINDINGS_SCREEN.WAITING_FOR_INPUT;
                };
                gameObject.transform.SetSiblingIndex(num);
                num++;
            }
        }
    }
    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);
    }
Exemplo n.º 8
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();
    }