Example #1
0
        private unsafe void exportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BrawlBoxViewerSettings settings = CollectSettings();

            SaveFileDialog sd = new SaveFileDialog();

            sd.Filter   = "Brawlbox Settings (*.settings)|*.settings";
            sd.FileName = Application.StartupPath;
            if (sd.ShowDialog() == DialogResult.OK)
            {
                string path = sd.FileName;
                using (FileStream stream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite, 8, FileOptions.SequentialScan))
                {
                    CompactStringTable s = new CompactStringTable();
                    s.Add(ScreenCapBgLocText.Text);
                    stream.SetLength((long)BrawlBoxViewerSettings.Size + s.TotalSize);
                    using (FileMap map = FileMap.FromStream(stream))
                    {
                        *(BrawlBoxViewerSettings *)map.Address = settings;
                        s.WriteTable(map.Address + BrawlBoxViewerSettings.Size);
                        ((BrawlBoxViewerSettings *)map.Address)->_screenCapPathOffset = (uint)s[ScreenCapBgLocText.Text] - (uint)map.Address;
                    }
                }
                MessageBox.Show("Settings successfully saved to " + path);
            }
        }
Example #2
0
        public int GetSize()
        {
            _calculatingSize = true;

            //Reset variables
            _lookupCount          = _lookupLen = 0;
            _lookupManager        = new LookupManager();
            _postProcessNodes     = new List <SakuraiEntryNode>();
            _referenceStringTable = new CompactStringTable();

            //Add header size
            _size = SakuraiArchiveHeader.Size;

            //Calculate the size of each section and add names to string table
            foreach (TableEntryNode section in _rootNode.SectionList)
            {
                SakuraiEntryNode entry = section;

                //Sections *usually* have only one reference in data or dataCommon
                //An example of an exception to this is the 'AnimCmd' section
                //If a reference exists, calculate the size of that reference instead
                if (section.References.Count > 0)
                {
                    entry = section.References[0];
                }

                //Add the size of the entry's data, and the entry itself
                _size += entry.GetSize() + 8;

                //Add the lookup count
                _lookupCount += entry.GetLookupCount();

                //Add the section's name to the string table
                _referenceStringTable.Add(entry.Name);
            }

            //Calculate reference table size and add names to string table
            foreach (TableEntryNode reference in _rootNode.ReferenceList)
            {
                if (reference.References.Count > 0 || AddUnreferencedReferences)
                {
                    //Add entry name to string table
                    _referenceStringTable.Add(reference.Name);

                    //Add entry size (reference don't have any actual 'data' size)
                    _size += 8;
                }

                //TODO: Does each reference offset throughout the file
                //have a lookup offset?
                //Also, subtract 1 because the initial offset has no lookup entry
                //lookupCount += e.References.Count - 1;
            }

            _calculatingSize = false;

            //Add the lookup size and reference table size
            _size += (_lookupLen = _lookupCount * 4) + _referenceStringTable.TotalSize;

            return(_size);
        }
        public override int OnCalculateSize(bool force)
        {
            int size = 16;
            foreach (GCTCodeEntryNode n in Children)
                size += n._lines.Length * 8;
            if (_writeInfo)
            {
                _stringTable = new CompactStringTable();
                _stringTable.Add(_name);
                if (!String.IsNullOrEmpty(_gameName))
                    _stringTable.Add(_gameName);

                size += 12;
                foreach (GCTCodeEntryNode n in Children)
                {
                    size += 16;
                    _stringTable.Add(n._name);
                    if (!String.IsNullOrEmpty(n._description))
                        _stringTable.Add(n._description);
                }
                size += _stringTable.TotalSize;
            }
            return size;
        }