示例#1
0
        public SgbGroup(SgbFile parent, byte[] buffer, int offset)
        {
            this.Parent = parent;

            var entriesOffset = offset;

            this.Header = buffer.ToStructure <HeaderData>(ref entriesOffset);
            this.Name   = buffer.ReadString(offset + Header.NameOffset);

            Entries = new ISgbGroupEntry[Header.EntryCount];
            for (var i = 0; i < Header.EntryCount; ++i)
            {
                var entryOffset = entriesOffset + BitConverter.ToInt32(buffer, entriesOffset + i * 4);

                var type = (SgbGroupEntryType)BitConverter.ToInt32(buffer, entryOffset);
                switch (type)
                {
                case SgbGroupEntryType.Model:
                    Entries[i] = new SgbModelEntry(Parent.File.Pack.Collection, buffer, entryOffset);
                    break;

                default:
                    //System.Diagnostics.Trace.WriteLine(string.Format("{0}: Type {1} at 0x{2:X} in {3}", Parent.File.Path, type, entryOffset, Name));
                    break;
                    // TODO: Work out other parts.
                }
            }
        }
示例#2
0
        public SgbGimmickEntry(IO.PackCollection packs, byte[] buffer, int offset)
        {
            this.Header = buffer.ToStructure <HeaderData>(offset);
            this.Name   = buffer.ReadString(offset + Header.NameOffset);

            var sgbFileName = buffer.ReadString(offset + Header.GimmickFileOffset);

            if (!string.IsNullOrWhiteSpace(sgbFileName))
            {
                SaintCoinach.IO.File file;
                if (packs.TryGetFile(sgbFileName, out file))
                {
                    this.Gimmick = new SgbFile(file);
                }
            }
        }
        public SgbGroup(SgbFile parent, byte[] buffer, int offset)
        {
            this.Parent = parent;

            var entriesOffset = offset;
            this.Header = buffer.ToStructure<HeaderData>(ref entriesOffset);
            this.Name = buffer.ReadString(offset + Header.NameOffset);

            Entries = new ISgbGroupEntry[Header.EntryCount];
            for(var i = 0; i < Header.EntryCount; ++i) {
                var entryOffset = entriesOffset + BitConverter.ToInt32(buffer, entriesOffset + i * 4);

                var type = (SgbGroupEntryType)BitConverter.ToInt32(buffer, entryOffset);
                switch (type) {
                    case SgbGroupEntryType.Model:
                        Entries[i] = new SgbModelEntry(Parent.File.Pack.Collection, buffer, entryOffset);
                        break;
                    default:
                        //System.Diagnostics.Trace.WriteLine(string.Format("{0}: Type {1} at 0x{2:X} in {3}", Parent.File.Path, type, entryOffset, Name));
                        break;
                        // TODO: Work out other parts.
                }
            }
        }
示例#4
0
        public SgbGroup(SgbFile parent, byte[] buffer, int offset, bool isOffset1C = false)
        {
            this.Parent = parent;

            var entriesOffset = offset;
            int count         = 0;

            if (isOffset1C)
            {
                this.Header         = buffer.ToStructure <HeaderData>(entriesOffset);
                this.Offset1CHeader = buffer.ToStructure <Offset1CHeaderData>(ref entriesOffset);
                this.Name           = buffer.ReadString(offset + Offset1CHeader.NameOffset);
                this.ModelFile1     = buffer.ReadString(offset + Offset1CHeader.ModelFileOffset + 1);
                this.ModelFile2     = buffer.ReadString(offset + Offset1CHeader.ModelFileOffset2 + 1);
                this.ModelFile3     = buffer.ReadString(offset + Offset1CHeader.NameOffset2 + 64);

                count   = Offset1CHeader.EntryCount;
                Entries = new ISgbGroupEntry[count];

                for (var i = 0; i < count; ++i)
                {
                    try {
                        var entryOffset = entriesOffset + (i * 24);
                        Entries[i] = new SgbGroup1CEntry(parent.File.Pack.Collection, buffer, entryOffset);
                        break;
                    }
                    catch (Exception e) {
                        System.Diagnostics.Debug.WriteLine(e.Message);
                    }
                }
            }
            else
            {
                this.Header = buffer.ToStructure <HeaderData>(ref entriesOffset);
                this.Name   = buffer.ReadString(offset + Header.NameOffset);
                count       = Header.EntryCount;
                Entries     = new ISgbGroupEntry[count];

                for (var i = 0; i < count; ++i)
                {
                    try {
                        var entryOffset = entriesOffset + BitConverter.ToInt32(buffer, entriesOffset + i * 4);

                        var type    = (SgbGroupEntryType)BitConverter.ToInt32(buffer, entryOffset);
                        var typeStr = ((Lgb.LgbEntryType)type).ToString();
                        switch (type)
                        {
                        case SgbGroupEntryType.Model:
                            Entries[i] = new SgbModelEntry(Parent.File.Pack.Collection, buffer, entryOffset);
                            break;

                        case SgbGroupEntryType.Gimmick:
                            Entries[i] = new SgbGimmickEntry(Parent.File.Pack.Collection, buffer, entryOffset);
                            break;

                        case SgbGroupEntryType.Light:
                            Entries[i] = new SgbLightEntry(Parent.File.Pack.Collection, buffer, entryOffset);
                            break;

                        case SgbGroupEntryType.Vfx:
                            Entries[i] = new SgbVfxEntry(Parent.File.Pack.Collection, buffer, entryOffset);
                            break;

                        default:
                            //System.Diagnostics.Trace.WriteLine(string.Format("{0}: Type {1} at 0x{2:X} in {3}", Parent.File.Path, type, entryOffset, Name));
                            break;
                            // TODO: Work out other parts.
                        }
                    }
                    catch (Exception e) {
                        System.Diagnostics.Debug.WriteLine(e.Message);
                    }
                }
            }
        }
        private bool TryGetModel(out SgbFile model)
        {
            model = null;
            if (SelectedFurniture == null)
                return false;

            try {
                model = SelectedFurniture.GetScene();

                var result = (model != null);
                if (!result)
                    System.Windows.MessageBox.Show(string.Format("Unable to find model for {0}.", SelectedFurniture.Item.Name), "Model not found", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                return result;
            } catch (Exception e) {
                System.Windows.MessageBox.Show(string.Format("Failed to load model for {0}:{2}{3}", SelectedFurniture.Item.Name, Environment.NewLine, e), "Read failure", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                return false;
            }
        }