Beispiel #1
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.");
            }
        }
Beispiel #2
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);
        }