Esempio n. 1
0
 public void SetContent(IAssignableIdentity identity_object, Action <IAssignableIdentity> selectionCallback, AssignableSideScreen assignableSideScreen)
 {
     if (refreshHandle == -1)
     {
         Game.Instance.Unsubscribe(refreshHandle);
     }
     refreshHandle = Game.Instance.Subscribe(-2146166042, delegate
     {
         if ((UnityEngine.Object) this != (UnityEngine.Object)null && (UnityEngine.Object)base.gameObject != (UnityEngine.Object)null && base.gameObject.activeInHierarchy)
         {
             Refresh(null);
         }
     });
     toggle         = GetComponent <MultiToggle>();
     sideScreen     = assignableSideScreen;
     targetIdentity = identity_object;
     if ((UnityEngine.Object)portraitInstance == (UnityEngine.Object)null)
     {
         portraitInstance = Util.KInstantiateUI <CrewPortrait>(crewPortraitPrefab.gameObject, base.gameObject, false);
         portraitInstance.transform.SetSiblingIndex(1);
         portraitInstance.SetAlpha(1f);
     }
     toggle.onClick = delegate
     {
         selectionCallback(targetIdentity);
     };
     portraitInstance.SetIdentityObject(identity_object, false);
     GetComponent <ToolTip>().OnToolTip = GetTooltip;
     Refresh(null);
 }
Esempio n. 2
0
        /// <summary>
        /// Creates the workshop profiles side screen.
        /// </summary>
        /// <param name="ss">The template Assignable side screen to use for the UI.</param>
        /// <returns>The Workshop Profiles side screen.</returns>
        private static WorkshopProfileSideScreen CreateScreen(AssignableSideScreen ss)
        {
            var template = Instantiate(ss.gameObject);

            template.name = nameof(WorkshopProfileSideScreen);
            // Copy the assignable screen
            bool active = template.activeSelf;

            template.SetActive(false);
            var oldScreen = template.GetComponent <AssignableSideScreen>();
            var ours      = template.AddComponent <WorkshopProfileSideScreen>();

            // Both toggles are named "ArrowToggle" so using Find won't work well
            ours.rowGroup             = ROW_GROUP.Get(oldScreen);
            ours.generalSortingToggle = ALLOW_SORT.Get(oldScreen);
            ours.dupeSortingToggle    = DUPE_SORT.Get(oldScreen);
            // Copy data from the Assignable row
            var rowObject = Instantiate(ROW_PREFAB.Get(oldScreen).gameObject);
            var oldRow    = rowObject.GetComponent <AssignableSideScreenRow>();
            var wpr       = rowObject.AddComponent <WorkshopProfileSideScreenRow>();

            wpr.assignment         = ASSIGN_TEXT.Get(oldRow);
            wpr.crewPortraitPrefab = CREW_IMAGE.Get(oldRow);
            ours.rowPrefab         = wpr;
            // Remove the old components
            DestroyImmediate(oldScreen);
            DestroyImmediate(oldRow);
            template.SetActive(active);
            return(ours);
        }