示例#1
0
        public static T CreatePreset <T>(IPresetableType type, string name) where T : Presetable
        {
            var preset = (T)Activator.CreateInstance(typeof(T), type, name);

            AddPreset(preset);
            return(preset);
        }
示例#2
0
        public static IEnumerable <T> GetPresets <T>(IPresetableType type) where T : Presetable
        {
            if (!Instance._presets.ContainsKey(typeof(T)) || !Instance._presets[typeof(T)].ContainsKey(type))
            {
                return(new T[] { });
            }

            return(Instance._presets[typeof(T)][type].Values.Cast <T>().ToArray());
        }
示例#3
0
        public static T GetPreset <T>(IPresetableType type, string name) where T : Presetable
        {
            if (!Instance._presets.ContainsKey(typeof(T)) || !Instance._presets[typeof(T)].ContainsKey(type) || !Instance._presets[typeof(T)][type].ContainsKey(name))
            {
                return(null);
            }

            return((T)Instance._presets[typeof(T)][type][name]);
        }
示例#4
0
 public Listing_Preset(IPresetableType type, T selected, T[] fixedPresets, Action onSelect, Action onSave, Action onRevert)
 {
     Type         = type;
     Selected     = selected;
     FixedPresets = fixedPresets;
     OnSelect     = onSelect;
     OnSave       = onSave;
     OnRevert     = onRevert;
 }
示例#5
0
 public static T GetVoidPreset <T>(IPresetableType type) where T : Presetable => (T)Instance._voidPresets[typeof(T)][type];
示例#6
0
 public static bool PresetNameExists <T>(IPresetableType type, string name) => Instance._presets.ContainsKey(typeof(T)) && Instance._presets[typeof(T)].ContainsKey(type) && Instance._presets[typeof(T)][type].ContainsKey(name);
示例#7
0
 public Dialog_PresetName(IPresetableType type, Action <T> onCommit) : this(Lang.Get("Dialog_PresetName.TitleNew"))
 {
     _type     = type;
     _onCommit = onCommit;
 }