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;
        }
Beispiel #2
0
        public SyphonEngine(
            Preset preset,
            Level level,
            bool enableAi)
        {
            _preset   = PresetFactory.Create(preset);
            _level    = level;
            _enableAi = enableAi;

            _parser = new TextParser(new ParsersCollection(_preset.Parsers), _preset);
        }
Beispiel #3
0
    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();
        }
    }
Beispiel #4
0
        /// <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);
            }
        }
Beispiel #5
0
        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));
        }
Beispiel #6
0
        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);
                    }
                }
            }
        }
Beispiel #7
0
        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;
        }
Beispiel #9
0
 public void CloneTo(IPreset preset)
 {
     preset.Name = this.Name;
     preset.Notes = this.Notes == null ? null : new ObservableCollection<INote>(this.Notes);
     preset.IsFavorite = this.IsFavorite;
 }
Beispiel #10
0
 /// <summary>
 /// Override current values with a preset.
 /// </summary>
 public void ApplyPreset(IPreset preset)
 {
     EnumeratePreset(preset, (key, presetKeys) => key.TextValue = presetKeys[key.Name]);
 }
Beispiel #11
0
 /// <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();
 }
Beispiel #13
0
 protected void DefaultSelect()
 {
     SelectedPreset = Presets.FirstOrDefault(preset => preset.IsFavorite);
     if (SelectedPreset == null && Presets != null)
         SelectedPreset = Presets.FirstOrDefault();
 }
Beispiel #14
0
 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);
 }
Beispiel #18
0
 public static void loadPreset(IPreset preset)
 {
     presets.Add(preset);
 }
Beispiel #19
0
 public RandomAreas(int areaSize, int areasCount, IPreset preset)
 {
     _areaSize   = areaSize;
     _areasCount = areasCount;
     _preset     = preset;
 }
Beispiel #20
0
        public bool Equals(IPreset other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }

            if (ReferenceEquals(this, other))
            {
                return true;
            }

            return other.Name.Equals( this.Name);
        }