NScumm.Scumm.IO.ResourceIndex8.LoadIndex C# (CSharp) Method

LoadIndex() protected method

protected LoadIndex ( GameInfo game ) : void
game GameInfo
return void
        protected override void LoadIndex(GameInfo game)
        {
            Directory = ServiceLocator.FileStorage.GetDirectoryName(game.Path);
            using (var file = ServiceLocator.FileStorage.OpenFileRead(game.Path))
            {
                var br = new BinaryReader(file);
                while (br.BaseStream.Position < br.BaseStream.Length)
                {
                    var tag = System.Text.Encoding.UTF8.GetString(br.ReadBytes(4));
                    br.ReadUInt32BigEndian();

                    switch (tag)
                    {
                        case "DCHR":
                        case "DIRF":
                            var charset = ReadResTypeList(br);
                            CharsetResources = new ReadOnlyCollection<Resource>(charset);
                            break;

                        case "DOBJ":
                            ReadDirectoryOfObjects(br);
                            break;

                        case "RNAM":
                            ReadRoomNames(br);
                            break;

                        case "DROO":
                        case "DIRR":
                            var rooms = ReadResTypeList(br);
                            RoomResources = new ReadOnlyCollection<Resource>(rooms);
                            break;

                        case "DSCR":
                        case "DIRS":
                            var scripts = ReadResTypeList(br);
                            ScriptResources = new ReadOnlyCollection<Resource>(scripts);
                            break;

                        case "DRSC":
                            var roomScripts = ReadResTypeList(br);
                            RoomScriptResources = new ReadOnlyCollection<Resource>(roomScripts);
                            break;

                        case "DCOS":
                        case "DIRC":
                            var costumes = ReadResTypeList(br);
                            CostumeResources = new ReadOnlyCollection<Resource>(costumes);
                            break;

                        case "MAXS":
                            ReadMaxSizes(br);
                            break;

                        case "DIRN":
                        case "DSOU":
                            var sounds = ReadResTypeList(br);
                            SoundResources = new ReadOnlyCollection<Resource>(sounds);
                            break;

                        case "AARY":
                            ReadArrayFromIndexFile(br);
                            break;

                        case "ANAM":        // Used by: The Dig, FT
                            {
                                var num = br.ReadUInt16();
                                AudioNames = new string[num];
                                for (int i = 0; i < num; i++)
                                {
									AudioNames[i] = br.ReadBytes(9).GetText();
                                }
                            }
                            break;

//                        default:
//                            Console.Error.WriteLine("Unknown tag {0} found in index file directory", tag);
//                            break;
                    }
                }
            }
        }

Usage Example

コード例 #1
0
ファイル: ResourceIndex.cs プロジェクト: scemino/nscumm
        public static ResourceIndex Load(GameInfo game)
        {
            ResourceIndex index;
            switch (game.Version)
            {
                case 0:
                    index = new ResourceIndex0();
                    break;
                case 1:
                    if (game.Platform == Platform.C64)
                    {
                        index = new ResourceIndex0();
                    }
                    else
                    {
                        index = new ResourceIndex2();
                    }
                    break;
                case 2:
                    index = new ResourceIndex2();
                    break;
                case 3:
                    if (game.IsOldBundle)
                    {
                        index = new ResourceIndex3_16();
                    }
                    else
                    {
                        index = new ResourceIndex3();
                    }
                    break;
                case 4:
                    index = new ResourceIndex4();
                    break;
                case 5:
                    index = new ResourceIndex5();
                    break;
                case 6:
                    index = new ResourceIndex6();
                    break;
                case 7:
                    index = new ResourceIndex7();
                    break;
                case 8:
                    index = new ResourceIndex8();
                    break;
                default:
                    throw new NotSupportedException("The SCUMM version {0} is not supported.");
            }

            index.Game = game;
            index.LoadIndex(game);
            return index;
        }
All Usage Examples Of NScumm.Scumm.IO.ResourceIndex8::LoadIndex