예제 #1
0
		public void CloneChanges(ObservableCollection<MetaField> changedFields, FieldChangeTracker tracker,
			FieldChangeSet changes)
		{
			for (int i = 0; i < changedFields.Count; i++)
			{
				MetaField field = changedFields[i];
				var reflexive = field as ReflexiveData;
				bool changed = changes.HasChanged(field);
				if (field != null && (changed || reflexive != null))
				{
					if (_fields[i] == null)
					{
						_fields[i] = field.CloneValue();
						tracker.AttachTo(_fields[i]);
						if (changed)
							tracker.MarkChanged(_fields[i]);
						tracker.MarkUnchanged(field);

						if (reflexive != null)
							reflexive.ResetPages();
					}
					else if (field != _fields[i])
					{
						throw new InvalidOperationException("Cannot cache changes in a meta field from a different page");
					}
				}
			}
		}
예제 #2
0
        public void CloneChanges(ObservableCollection <MetaField> changedFields, FieldChangeTracker tracker,
                                 FieldChangeSet changes)
        {
            for (int i = 0; i < changedFields.Count; i++)
            {
                MetaField field     = changedFields[i];
                var       reflexive = field as ReflexiveData;
                bool      changed   = changes.HasChanged(field);
                if (field != null && (changed || reflexive != null))
                {
                    if (_fields[i] == null)
                    {
                        _fields[i] = field.CloneValue();
                        tracker.AttachTo(_fields[i]);
                        if (changed)
                        {
                            tracker.MarkChanged(_fields[i]);
                        }
                        tracker.MarkUnchanged(field);

                        if (reflexive != null)
                        {
                            reflexive.ResetPages();
                        }
                    }
                    else if (field != _fields[i])
                    {
                        throw new InvalidOperationException("Cannot cache changes in a meta field from a different page");
                    }
                }
            }
        }
예제 #3
0
		public FlattenedReflexive(FlattenedReflexive parent, ReflexiveData template,
			ObservableCollection<MetaField> topLevelFields, FieldChangeTracker tracker, FieldChangeSet changes)
		{
			_parent = parent;
			_template = template;
			_activeReflexive = template;
			_synchronizedReflexives.Add(template);
			if (template.HasChildren)
				_lastPage = template.Pages[template.CurrentIndex];
			_topLevelFields = topLevelFields;
			_tracker = tracker;
			_changes = changes;
		}
예제 #4
0
 public FlattenedReflexive(FlattenedReflexive parent, ReflexiveData template,
                           ObservableCollection <MetaField> topLevelFields, FieldChangeTracker tracker, FieldChangeSet changes)
 {
     _parent          = parent;
     _template        = template;
     _activeReflexive = template;
     _synchronizedReflexives.Add(template);
     if (template.HasChildren)
     {
         _lastPage = template.Pages[template.CurrentIndex];
     }
     _topLevelFields = topLevelFields;
     _tracker        = tracker;
     _changes        = changes;
 }
예제 #5
0
        public void RefreshEditor()
        {
            if (File.Exists(_pluginPath))
            {
                // Load Plugin File
                using (XmlReader xml = XmlReader.Create(_pluginPath))
                {
                    _pluginVisitor = new ThirdGenPluginVisitor(_tags, _cache.StringIDs, _stringIDTrie, Settings.pluginsShowInvisibles);
                    AssemblyPluginLoader.LoadPlugin(xml, _pluginVisitor);
                }

                _changeTracker = new FieldChangeTracker();
                _fileChanges = new FieldChangeSet();
                _memoryChanges = new FieldChangeSet();

                uint baseOffset = (uint)_tag.RawTag.MetaLocation.AsOffset();
                MetaReader metaReader = new MetaReader(_streamManager, baseOffset, _cache, _buildInfo, _fileChanges);
                _flattener = new ReflexiveFlattener(metaReader, _changeTracker, _fileChanges);
                _flattener.Flatten(_pluginVisitor.Values);
                metaReader.ReadFields(_pluginVisitor.Values);

                panelMetaComponents.ItemsSource = _pluginVisitor.Values;

                // Start monitoring fields for changes
                _changeTracker.RegisterChangeSet(_fileChanges);
                _changeTracker.RegisterChangeSet(_memoryChanges);
                _changeTracker.Attach(_pluginVisitor.Values);

                // Update Meta Toolbar
                UpdateMetaButtons(true);
            }
            else
            {
                UpdateMetaButtons(false);
                StatusUpdater.Update("Plugin doesn't exist. It can't be loaded for this tag.");
            }
        }
예제 #6
0
 public ReflexiveFlattener(MetaReader reader, FieldChangeTracker tracker, FieldChangeSet changes)
 {
     _reader  = reader;
     _tracker = tracker;
     _changes = changes;
 }
예제 #7
0
 public ReflexiveFlattener(MetaReader reader, FieldChangeTracker tracker, FieldChangeSet changes)
 {
     _reader = reader;
     _tracker = tracker;
     _changes = changes;
 }
예제 #8
0
        public void RefreshEditor(MetaReader.LoadType type)
        {
            if (!File.Exists(_pluginPath))
            {
                UpdateMetaButtons(false);
                StatusUpdater.Update("Plugin doesn't exist. It can't be loaded for this tag.");
                return;
            }

            // Set the stream manager and base offset to use based upon the LoadType
            IStreamManager streamManager = null;
            uint baseOffset = 0;
            switch (type)
            {
                case MetaReader.LoadType.File:
                    streamManager = _fileManager;
                    baseOffset = (uint) _tag.RawTag.MetaLocation.AsOffset();
                    break;

                case MetaReader.LoadType.Memory:
                    if (_rteProvider == null)
                        goto default;

                    if (_rteProvider.GetMetaStream(_cache) == null)
                    {
                        ShowConnectionError();
                        return;
                    }

                    streamManager = new RTEStreamManager(_rteProvider, _cache);
                    baseOffset = _tag.RawTag.MetaLocation.AsPointer();
                    break;

                default:
                    MetroMessageBox.Show("Not Supported", "That feature is not supported for this game.");
                    return;
            }

            // Load Plugin File
            using (XmlReader xml = XmlReader.Create(_pluginPath))
            {
                _pluginVisitor = new ThirdGenPluginVisitor(_tags, _stringIdTrie, _cache.MetaArea,
                    App.AssemblyStorage.AssemblySettings.PluginsShowInvisibles);
                AssemblyPluginLoader.LoadPlugin(xml, _pluginVisitor);
            }

            _changeTracker = new FieldChangeTracker();
            _fileChanges = new FieldChangeSet();
            _memoryChanges = new FieldChangeSet();

            var metaReader = new MetaReader(streamManager, baseOffset, _cache, _buildInfo, type, _fileChanges);
            _flattener = new ReflexiveFlattener(metaReader, _changeTracker, _fileChanges);
            _flattener.Flatten(_pluginVisitor.Values);
            metaReader.ReadFields(_pluginVisitor.Values);
            panelMetaComponents.ItemsSource = _pluginVisitor.Values;

            // Start monitoring fields for changes
            _changeTracker.RegisterChangeSet(_fileChanges);
            _changeTracker.RegisterChangeSet(_memoryChanges);
            _changeTracker.Attach(_pluginVisitor.Values);

            // Update Meta Toolbar
            UpdateMetaButtons(true);
        }
예제 #9
0
 public TagBlockFlattener(MetaReader reader, FieldChangeTracker tracker, FieldChangeSet changes)
 {
     _reader  = reader;
     _tracker = tracker;
     _changes = changes;
 }