Exemple #1
0
        public void PopulateShifter()
        {
            if (LoadedSkin == null)
            {
                LoadedSkin = JsonConvert.DeserializeObject <Skin>(JsonConvert.SerializeObject(SkinEngine.LoadedSkin));
            }

            settings.Clear();

            foreach (var field in LoadedSkin.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance))
            {
                if (ShiftoriumFrontend.UpgradeAttributesUnlocked(field))
                {
                    bool           addToShifter = true;
                    ShifterSetting setting      = new Applications.ShifterSetting();
                    foreach (var attr in field.GetCustomAttributes(false))
                    {
                        if (attr is ShifterHiddenAttribute)
                        {
                            addToShifter = false;
                            continue;
                        }

                        if (attr is ShifterMetaAttribute)
                        {
                            setting.Category = (attr as ShifterMetaAttribute).Meta;
                        }
                        if (attr is ShifterCategoryAttribute)
                        {
                            setting.SubCategory = (attr as ShifterCategoryAttribute).Category;
                        }
                        if (attr is ShifterNameAttribute)
                        {
                            setting.Name = (attr as ShifterNameAttribute).Name;
                        }
                        if (attr is ShifterDescriptionAttribute)
                        {
                            setting.Description = (attr as ShifterDescriptionAttribute).Description;
                        }
                    }
                    if (addToShifter == true)
                    {
                        setting.Field = field;
                        settings.Add(setting);
                    }
                }
            }

            PopulateCategories();
        }
Exemple #2
0
        public void ResetAllKeywords()
        {
            string primary   = SaveSystem.CurrentSave.Username + " ";
            string secondary = "shiftos ";


            var asm = Assembly.GetExecutingAssembly();

            var types = asm.GetTypes();

            foreach (var type in types)
            {
                foreach (var a in type.GetCustomAttributes(false))
                {
                    if (ShiftoriumFrontend.UpgradeAttributesUnlocked(type))
                    {
                        if (a is Namespace)
                        {
                            var ns = a as Namespace;
                            if (!primary.Contains(ns.name))
                            {
                                primary += ns.name + " ";
                            }
                            foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static))
                            {
                                if (ShiftoriumFrontend.UpgradeAttributesUnlocked(method))
                                {
                                    foreach (var ma in method.GetCustomAttributes(false))
                                    {
                                        if (ma is Command)
                                        {
                                            var cmd = ma as Command;
                                            if (!secondary.Contains(cmd.name))
                                            {
                                                secondary += cmd.name + " ";
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }