예제 #1
0
        internal static MelonPreferences_Entry.TypeEnum TypeToTypeEnum <T>()
        {
            TypeParser parser = GetParser(typeof(T));

            if (parser == null)
            {
                return(MelonPreferences_Entry.TypeEnum.UNKNOWN);
            }
            return(parser.GetTypeEnum());
        }
예제 #2
0
        internal static void ConvertCurrentValueType <T>(MelonPreferences_Entry entry, T defaultvalue)
        {
            TypeParser parser = GetParser(typeof(T));

            if ((parser == null) || (entry.Type == parser.GetTypeEnum()))
            {
                return;
            }
            parser.SetDefaultValue(entry, defaultvalue);
            parser.ConvertCurrentValueType(entry);
        }
예제 #3
0
        internal static MelonPreferences_Entry ConstructEntry <T>(MelonPreferences_Category category, string name, T value, string displayname = null, bool hidden = false)
        {
            TypeParser parser = GetParser(typeof(T));

            if (parser == null)
            {
                return(null);
            }
            MelonPreferences_Entry entry = new MelonPreferences_Entry();

            entry.Category    = category;
            entry.Name        = name;
            entry.DisplayName = displayname;
            entry.Hidden      = hidden;
            entry.Type        = parser.GetTypeEnum();
            parser.Construct(entry, value);
            category.prefstbl.Add(entry);
            if (MelonPreferences.SaveAfterEntryCreation)
            {
                MelonPreferences.Save_Internal();
            }
            return(entry);
        }