public PresetViewModel(Preset preset, bool isNew) { this.preset = (IPreset)preset.Clone(); this.original = preset; this.TagTypes = new ObservableCollection<TagTypes>(this.original.TagTypes); this.isNew = isNew; }
public SyphonEngine( Preset preset, Level level, bool enableAi) { _preset = PresetFactory.Create(preset); _level = level; _enableAi = enableAi; _parser = new TextParser(new ParsersCollection(_preset.Parsers), _preset); }
void Start() { var thisComponent = GetComponent <T>(); _preset = Preset.From(otherComponent); _preset.ApplyTo(thisComponent); //Removes the temporary object created to store the runtime preset if (removeTemporaryPresetObject) { _preset.Free(); } }
/// <summary> /// Save preset settings from current values. /// </summary> public void FillPreset(IPreset preset, bool addNewKeys) { preset.SettingsVersion = Version; if (addNewKeys) { preset.Values = Sections.ToDictionary(sk => sk.Name, sv => sv.Keys.ToDictionary(kn => kn.Name, kv => kv.TextValue)); } else { EnumeratePreset(preset, (key, presetKeys) => presetKeys[key.Name] = key.TextValue); } }
public GameSettings(int width, int height, IPreset preset) { if (width <= 0) { throw new ArgumentException("Width must be positive", nameof(width)); } if (height <= 0) { throw new ArgumentException("Height must be positive", nameof(height)); } Width = width; Height = height; Preset = preset ?? throw new ArgumentNullException(nameof(preset)); }
private void EnumeratePreset(IPreset preset, Action <Key, Dictionary <string, string> > action) { if (preset == null || preset.Values == null) { return; } foreach (var section in Sections) { Dictionary <string, string> presetSection; if (preset.Values.TryGetValue(section.Name, out presetSection)) { foreach (var key in section.Keys.Where(x => presetSection.ContainsKey(x.Name))) { action(key, presetSection); } } } }
public TextParser(ParsersCollection parsers, IPreset preset) { this.parsers = parsers; var sb = new StringBuilder(); sb.Append("("); for (var i = 0; i < preset.Boundaries.Length; i++) { foreach (var c in preset.Boundaries[i]) { sb.AppendFormat(@"\u{0:X4}", Convert.ToInt32(c)); } if (i < preset.Boundaries.Length - 1) { sb.Append("|"); } } sb.Append(")"); var pattern = sb.ToString(); split = new Regex(pattern); }
protected EmulationSlotBase(uint slotNumber, IVirtualGamepad gamepad, Keyboard keyboard, Mouse mouse, IPreset preset) : this() { if (gamepad == null) { throw new ArgumentNullException("gamepad"); } if (preset == null) { throw new ArgumentNullException("preset"); } if (keyboard == null) { throw new ArgumentNullException("keyboard"); } if (mouse == null) { throw new ArgumentNullException("mouse"); } this.SlotNumber = slotNumber; this.Gamepad = gamepad; this.Keyboard = keyboard; this.Mouse = mouse; this.Preset = preset; }
public void CloneTo(IPreset preset) { preset.Name = this.Name; preset.Notes = this.Notes == null ? null : new ObservableCollection<INote>(this.Notes); preset.IsFavorite = this.IsFavorite; }
/// <summary> /// Override current values with a preset. /// </summary> public void ApplyPreset(IPreset preset) { EnumeratePreset(preset, (key, presetKeys) => key.TextValue = presetKeys[key.Name]); }
/// <summary> /// True if preset has the same version of this instance. /// Do not rely on this for anything else. /// </summary> public bool IsCompatible(IPreset preset) { return(string.IsNullOrEmpty(Version) || Version == preset.SettingsVersion); }
public void CancelEdit() { this.preset = (IPreset)this.original.Clone(); }
protected void DefaultSelect() { SelectedPreset = Presets.FirstOrDefault(preset => preset.IsFavorite); if (SelectedPreset == null && Presets != null) SelectedPreset = Presets.FirstOrDefault(); }
public GameSettings(int size, IPreset preset) : this(size, size, preset) { }
public IGameWithPreset WithGlider() { _preset = new GliderAtTheMiddlePreset(); return(this); }
public IGameWithPreset WithRandomPreset(int fulfillPercent) { _preset = new RandomPreset(fulfillPercent); return(this); }
public IGameWithPreset WithPreset(IPreset preset) { _preset = preset ?? throw new ArgumentNullException(nameof(preset)); return(this); }
public static void loadPreset(IPreset preset) { presets.Add(preset); }
public RandomAreas(int areaSize, int areasCount, IPreset preset) { _areaSize = areaSize; _areasCount = areasCount; _preset = preset; }
public bool Equals(IPreset other) { if (ReferenceEquals(null, other)) { return false; } if (ReferenceEquals(this, other)) { return true; } return other.Name.Equals( this.Name); }