public static string GetString(string section, string name) { MelonPreferences_Category category = MelonPreferences.GetCategory(section); if (category == null) { return(null); } MelonPreferences_Entry entry = category.GetEntry(name); if (entry == null) { return(null); } return((entry.Type == MelonPreferences_Entry.TypeEnum.BOOL) ? entry.GetValue <bool>().ToString() : ((entry.Type == MelonPreferences_Entry.TypeEnum.INT) ? entry.GetValue <int>().ToString() : ((entry.Type == MelonPreferences_Entry.TypeEnum.FLOAT) ? entry.GetValue <float>().ToString() : entry.GetValue <string>()))); }
internal override void ConvertCurrentValueType(MelonPreferences_Entry entry) { byte val = GetDefaultValue <byte>(entry); if (entry.Type == MelonPreferences_Entry.TypeEnum.LONG) { val = (byte)entry.GetValue <long>(); } entry.Type = TypeEnum; entry.SetValue(val); }
internal override void ConvertCurrentValueType(MelonPreferences_Entry entry) { float val_float = GetDefaultValue <float>(entry); if (entry.Type == MelonPreferences_Entry.TypeEnum.DOUBLE) { val_float = (float)entry.GetValue <double>(); } entry.Type = TypeEnum; entry.SetValue(val_float); }
internal override void ConvertCurrentValueType(MelonPreferences_Entry entry) { byte[] val = GetDefaultValue <byte[]>(entry); if (entry.Type == MelonPreferences_Entry.TypeEnum.LONG_ARRAY) { long[] entryarr = entry.GetValue <long[]>(); int entryarr_size = entryarr.Length; val = new byte[entryarr_size]; for (int i = 0; i < entryarr_size; i++) { val[i] = (byte)entryarr[i]; } } entry.Type = TypeEnum; entry.SetValue(val); }
internal override void ConvertCurrentValueType(MelonPreferences_Entry entry) { float[] val_floatarr = GetDefaultValue <float[]>(entry); if (entry.Type == MelonPreferences_Entry.TypeEnum.DOUBLE_ARRAY) { double[] entryarr = entry.GetValue <double[]>(); int entryarr_size = entryarr.Length; val_floatarr = new float[entryarr_size]; for (int i = 0; i < entryarr_size; i++) { val_floatarr[i] = (float)entryarr[i]; } } entry.Type = TypeEnum; entry.SetValue(val_floatarr); }
internal override KeyValueSyntax Save(MelonPreferences_Entry entry) { entry.SetValue(entry.GetEditedValue <string>()); return(new KeyValueSyntax(entry.Name, new StringValueSyntax(entry.GetValue <string>()))); }
internal override KeyValueSyntax Save(MelonPreferences_Entry entry) { entry.SetValue(entry.GetEditedValue <byte[]>()); return(new KeyValueSyntax(entry.Name, new ArraySyntax(entry.GetValue <byte[]>()))); }