public static void CheckTypeCache()
        {
            //SL.Log("Getting implementations of SLPackCategory in all assemblies...");
            var allTypes = At.GetImplementationsOf(typeof(SLPackCategory));

            if (allTypes.Count == s_lastTypeCount)
            {
                return;
            }

            s_lastTypeCount = allTypes.Count;

            var list = new List <SLPackCategory>();

            //var lateList = new List<SLPackCategory>();

            foreach (var type in allTypes)
            {
                try
                {
                    SLPackCategory ctg;
                    if (s_slPackCategories != null && s_slPackCategories.ContainsKey(type))
                    {
                        ctg = s_slPackCategories[type];
                    }
                    else
                    {
                        ctg = (SLPackCategory)At.TryCreateDefault(type);
                    }

                    if (ctg != null)
                    {
                        list.Add(ctg);
                        //if (ctg.HasLateContent)
                        //    lateList.Add(ctg);
                    }
                    else
                    {
                        SL.Log("SLPack categories internal: could not create instance of type '" + type.FullName + "'");
                    }
                }
                catch (Exception ex)
                {
                    SL.LogWarning("Exception checking SLPackCategory '" + type.FullName + "'");
                    SL.LogInnerException(ex);
                }
            }

            s_slPackCategories = new Dictionary <Type, SLPackCategory>();
            foreach (var instance in list.OrderBy(it => it.LoadOrder))
            {
                s_slPackCategories.Add(instance.GetType(), instance);
            }

            //s_slPackLateCategories = new Dictionary<Type, SLPackCategory>();
            //if (lateList.Any())
            //    foreach (var instance in lateList.OrderBy(it => it.LoadOrder))
            //        s_slPackLateCategories.Add(instance.GetType(), instance);
        }
Esempio n. 2
0
        public TypeTreeDropdown(Type type, GameObject parent, Type currentType, Action <Type> listener)
        {
            m_baseType    = type;
            m_typeOptions = At.GetImplementationsOf(m_baseType).OrderBy(it => it.Name).ToList();

            OnValueSelected += listener;

            ConstructUI(parent, currentType);
        }
Esempio n. 3
0
        public SLPackListView()
        {
            Instance = this;

            m_currentCategory = SLPackManager.GetCategoryInstance <ItemCategory>();

            var list = At.GetImplementationsOf(typeof(ContentTemplate));

            s_templateTypes = list.OrderBy(it => it.Name).ToList();

            ConstructUI();
        }
        internal void ConstructAddRow()
        {
            var addRowObj = UIFactory.CreateHorizontalGroup(m_subContentParent, new Color(1, 1, 1, 0));
            var rowGroup  = addRowObj.GetComponent <HorizontalLayoutGroup>();

            rowGroup.childForceExpandWidth = false;
            rowGroup.spacing = 5;
            rowGroup.padding = new RectOffset(3, 3, 3, 3);
            var addRowLayout = addRowObj.AddComponent <LayoutElement>();

            addRowLayout.minHeight      = 25;
            addRowLayout.flexibleHeight = 0;

            var inherited = At.GetImplementationsOf(this.m_baseEntryType);

            if (inherited.Count > 1 || m_baseEntryType.IsAbstract || m_baseEntryType.IsInterface)
            {
                m_typeDrop = new TypeTreeDropdown(m_baseEntryType, addRowObj, m_baseEntryType, (Type val) =>
                {
                    m_typeToAdd = val;
                });

                if (m_baseEntryType.IsAbstract || m_baseEntryType.IsInterface)
                {
                    m_typeDrop.m_dropdown.value = 0;
                }
            }

            var addBtnObj    = UIFactory.CreateButton(addRowObj, new Color(0.15f, 0.45f, 0.15f));
            var addBtn       = addBtnObj.GetComponent <Button>();
            var addbtnLayout = addBtnObj.AddComponent <LayoutElement>();

            addbtnLayout.minHeight     = 25;
            addbtnLayout.minWidth      = 120;
            addbtnLayout.flexibleWidth = 0;
            addBtn.onClick.AddListener(() =>
            {
                AddEntry();
            });
            addBtnObj.GetComponentInChildren <Text>().text = "Add...";
        }
Esempio n. 5
0
 internal static void LoadExtensionTypes()
 {
     s_registeredModels = At.GetImplementationsOf(typeof(PlayerSaveExtension));
 }