예제 #1
0
        private void UpdateMeta(MetaWriter.SaveType type, bool onlyUpdateChanged, bool showActionDialog = true)
        {
            if (type == MetaWriter.SaveType.File)
            {
                using (EndianStream stream = new EndianStream(_streamManager.OpenReadWrite(), _streamManager.SuggestedEndian))
                {
            #if DEBUG_SAVE_ALL
                    MetaWriter metaUpdate = new MetaWriter(writer, (uint)_tag.RawTag.MetaLocation.AsOffset(), _cache, _buildInfo, type, null);
            #else
                    MetaWriter metaUpdate = new MetaWriter(stream, (uint)_tag.RawTag.MetaLocation.AsOffset(), _cache, _buildInfo, type, _fileChanges);
            #endif
                    metaUpdate.WriteFields(_pluginVisitor.Values);
                    _cache.SaveChanges(stream);
                    _fileChanges.MarkAllUnchanged();
                }

                if (showActionDialog)
                    MetroMessageBox.Show("Meta Saved", "The metadata has been saved back to the original file.");
            }
            else if (_rteProvider != null)
            {
                using (IStream metaStream = _rteProvider.GetMetaStream(_cache))
                {
                    if (metaStream != null)
                    {
                        FieldChangeSet changes = onlyUpdateChanged ? _memoryChanges : null;
                        MetaWriter metaUpdate = new MetaWriter(metaStream, _tag.RawTag.MetaLocation.AsPointer(), _cache, _buildInfo, type, changes);
                        metaUpdate.WriteFields(_pluginVisitor.Values);

                        if (showActionDialog)
                        {
                            if (onlyUpdateChanged)
                                MetroMessageBox.Show("Meta Poked", "All changed metadata has been poked to the game.");
                            else
                                MetroMessageBox.Show("Meta Poked", "The metadata has been poked to the game.");
                        }
                    }
                    else
                    {
                        switch (_rteProvider.ConnectionType)
                        {
                            case RTEConnectionType.Console:
                                MetroMessageBox.Show("Connection Error", "Unable to connect to your Xbox 360 console. Make sure that XBDM is enabled, you have the Xbox 360 SDK installed, and that your console's IP has been set correctly.");
                                break;

                            case RTEConnectionType.LocalProcess:
                                MetroMessageBox.Show("Connection Error", "Unable to connect to the game. Make sure that it is running on your computer and that the map you are poking to is currently loaded.");
                                break;
                        }
                    }
                }
            }
        }
예제 #2
0
        private void UpdateMeta(MetaWriter.SaveType type, bool onlyUpdateChanged, bool showActionDialog = true)
        {
            if (type == MetaWriter.SaveType.File)
            {
                using (EndianWriter writer = new EndianWriter(_streamManager.OpenWrite(), Endian.BigEndian))
                {
                    MetaWriter metaUpdate = new MetaWriter(writer, _tag.RawTag.MetaLocation.AsOffset(), _cache, type, _fileChanges);
                    metaUpdate.WriteFields(_pluginVisitor.Values);
                    _fileChanges.MarkAllUnchanged();
                }

                if (showActionDialog)
                    MetroMessageBox.Show("Meta Saved", "The metadata has been saved back to the original file.");
            }
            else
            {
                if (Settings.xbdm.Connect())
                {
                    FieldChangeSet changes = onlyUpdateChanged ? _memoryChanges : null;
                    MetaWriter metaUpdate = new MetaWriter(Settings.xbdm.MemoryStream, _tag.RawTag.MetaLocation.AsAddress(), _cache, type, changes);
                    metaUpdate.WriteFields(_pluginVisitor.Values);
                    _memoryChanges.MarkAllUnchanged();

                    if (showActionDialog)
                    {
                        if (onlyUpdateChanged)
                            MetroMessageBox.Show("Meta Poked", "All changed metadata has been poked to your Xbox 360 console.");
                        else
                            MetroMessageBox.Show("Meta Poked", "The metadata has been poked to your Xbox 360 console.");
                    }
                }
                else
                {
                    MetroMessageBox.Show("Connection Error", "Unable to connect to your Xbox 360 console. Make sure that XBDM is enabled, you have the Xbox 360 SDK installed, and that your console's IP has been set correctly.");
                }
            }
        }
예제 #3
0
        private void UpdateMeta(MetaWriter.SaveType type, bool onlyUpdateChanged, bool showActionDialog = true)
        {
            if (type == MetaWriter.SaveType.File)
            {
                if (!ConfirmNewStringIds())
                    return;

                using (IStream stream = _fileManager.OpenReadWrite())
                {
            #if DEBUG_SAVE_ALL
                    MetaWriter metaUpdate = new MetaWriter(writer, (uint)_tag.RawTag.MetaLocation.AsOffset(), _cache, _buildInfo, type, null, _stringIdTrie);
            #else
                    var metaUpdate = new MetaWriter(stream, (uint) _tag.RawTag.MetaLocation.AsOffset(), _cache, _buildInfo, type,
                        _fileChanges, _stringIdTrie);
            #endif
                    metaUpdate.WriteFields(_pluginVisitor.Values);
                    _cache.SaveChanges(stream);
                    _fileChanges.MarkAllUnchanged();
                }

                if (showActionDialog)
                    MetroMessageBox.Show("Meta Saved", "The metadata has been saved back to the original file.");
            }
            else if (_rteProvider != null)
            {
                using (IStream metaStream = _rteProvider.GetMetaStream(_cache))
                {
                    if (metaStream != null)
                    {
                        FieldChangeSet changes = onlyUpdateChanged ? _memoryChanges : null;
                        var metaUpdate = new MetaWriter(metaStream, _tag.RawTag.MetaLocation.AsPointer(), _cache, _buildInfo, type,
                            changes, _stringIdTrie);
                        metaUpdate.WriteFields(_pluginVisitor.Values);

                        if (showActionDialog)
                        {
                            if (onlyUpdateChanged)
                                MetroMessageBox.Show("Meta Poked", "All changed metadata has been poked to the game.");
                            else
                                MetroMessageBox.Show("Meta Poked", "The metadata has been poked to the game.");
                        }
                    }
                    else
                    {
                        ShowConnectionError();
                    }
                }
            }
        }
예제 #4
0
        private void ReallocateCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var field = GetWrappedField(e.OriginalSource) as ReflexiveData;
            if (field == null)
                return;
            var newCount = MetroTagBlockReallocator.Show(_cache, field);
            if (newCount == null || (int)newCount == field.Length)
                return; // Canceled

            var oldAddress = field.FirstEntryAddress;
            var oldSize = field.Length * field.EntrySize;
            var newSize = (int)newCount * field.EntrySize;
            uint newAddress;
            using (var stream = _fileManager.OpenReadWrite())
            {
                // Reallocate the block
                newAddress = _cache.Allocator.Reallocate(oldAddress, (int)oldSize, (int)newSize, (uint)field.Align, stream);
                _cache.SaveChanges(stream);

                // If the block was made larger, zero extra data
                if (newAddress != 0 && newSize > oldSize)
                {
                    stream.SeekTo(_cache.MetaArea.PointerToOffset(newAddress) + oldSize);
                    StreamUtil.Fill(stream, 0, (int)(newSize - oldSize));
                }
            }

            // Changing these causes a read from the file, so the stream has to be closed first
            field.Length = (int)newCount;
            field.FirstEntryAddress = newAddress;

            using (var stream = _fileManager.OpenReadWrite())
            {
                // Force a save back to the file
                var changes = new FieldChangeSet();
                changes.MarkChanged(field);
                var metaUpdate = new MetaWriter(stream, (uint)_tag.RawTag.MetaLocation.AsOffset(), _cache, _buildInfo,
                    MetaWriter.SaveType.File, changes, _stringIdTrie);
                metaUpdate.WriteFields(_pluginVisitor.Values);
                _fileChanges.MarkUnchanged(field);
            }
            if (newAddress == oldAddress)
            {
                MetroMessageBox.Show("Tag Block Reallocator - Assembly",
                    "The tag block was resized successfully. Its address did not change.");
            }
            else if (oldAddress == 0)
            {
                MetroMessageBox.Show("Tag Block Reallocator - Assembly",
                    "The tag block was allocated successfully. Its address is 0x" + newAddress.ToString("X8") + ".");
            }
            else if (newAddress != 0)
            {
                MetroMessageBox.Show("Tag Block Reallocator - Assembly",
                    "The tag block was reallocated successfully. Its new address is 0x" + newAddress.ToString("X8") + ".");
            }
            else
            {
                MetroMessageBox.Show("Tag Block Reallocator - Assembly",
                    "The tag block was freed successfully.");
            }
        }