コード例 #1
0
        public override void Load(string filePath)
        {
            base.Load(filePath);

            if (!filePath.EndsWith(".spr", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            string spriteDatabaseFilePath = Path.ChangeExtension(filePath, "spi");

            if (!File.Exists(spriteDatabaseFilePath))
            {
                return;
            }

            var spriteDatabase = BinaryFile.Load <SpriteDatabase>(spriteDatabaseFilePath);
            var spriteSetEntry = spriteDatabase.SpriteSets[0];

            foreach (var spriteEntry in spriteSetEntry.Sprites)
            {
                Sprites[spriteEntry.Index].Name = spriteEntry.Name;
            }

            foreach (var textureEntry in spriteSetEntry.Textures)
            {
                TextureSet.Textures[textureEntry.Index].Name = textureEntry.Name;
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var stgFarc = BinaryFile.Load <FarcArchive>(args[0]);

            foreach (string fileName in stgFarc)
            {
                if (fileName.EndsWith(".txd"))
                {
                    MemoryStream stream    = new MemoryStream();
                    var          oldTexSet = BinaryFile.Load <TextureSet>(stgFarc.Open(fileName, EntryStreamMode.MemoryStream));
                    var          newTexSet = new TextureSet();

                    foreach (var tex in oldTexSet.Textures)
                    {
                        Texture newTex = TextureEncoder.EncodeFromFile(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\white.dds", tex.Format, true);
                        newTex.Id   = tex.Id;
                        newTex.Name = tex.Name;
                        newTexSet.Textures.Add(newTex);
                    }
                    newTexSet.Endianness = oldTexSet.Endianness;
                    newTexSet.Format     = oldTexSet.Format;

                    newTexSet.Save(stream, true);
                    stgFarc.Add(fileName, stream, false, ConflictPolicy.Replace);
                }
            }
            stgFarc.Save(args[0]);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            if (args[0].EndsWith("spr_db.bin"))
            {
                var SpriteDb = BinaryFile.Load <SpriteDatabase>(args[0]);

                foreach (var SpriteSet in SpriteDb.SpriteSets)
                {
                    Console.WriteLine(SpriteSet.Name);
                    SpriteSet.Id = MurmurHash.Calculate(SpriteSet.Name);
                    Console.WriteLine("Murmur Hashed Id: " + SpriteSet.Id + "\n");

                    foreach (var Sprite in SpriteSet.Sprites)
                    {
                        Console.WriteLine(Sprite.Name);
                        Sprite.Id = MurmurHash.Calculate(Sprite.Name);
                        Console.WriteLine("Murmur Hashed Id: " + Sprite.Id + "\n");
                    }
                }
                SpriteDb.Save(args[0]);
            }

            if (args[0].EndsWith("aet_db.bin"))
            {
                var AetDb = BinaryFile.Load <AetDatabase>(args[0]);

                foreach (var AetSet in AetDb.AetSets)
                {
                    AetSet.SpriteSetId = MurmurHash.Calculate(AetSet.Name.Replace("AET_", "SPR_"));
                }
                AetDb.Save(args[0]);
            }
        }
コード例 #4
0
        public static void LoadRecipe(int RecipeNum)
        {
            string filename;
            int    i;

            CheckRecipes();

            filename = Path.Combine(Application.StartupPath, "data", "recipes", string.Format("recipe{0}.dat", RecipeNum));
            ByteStream reader = new ByteStream();

            BinaryFile.Load(filename, ref reader);

            Recipe[RecipeNum].Name           = reader.ReadString();
            Recipe[RecipeNum].RecipeType     = reader.ReadByte();
            Recipe[RecipeNum].MakeItemNum    = reader.ReadInt32();
            Recipe[RecipeNum].MakeItemAmount = reader.ReadInt32();

            Recipe[RecipeNum].Ingredients = new IngredientsRec[Constants.MAX_INGREDIENT + 1];
            for (i = 1; i <= Constants.MAX_INGREDIENT; i++)
            {
                Recipe[RecipeNum].Ingredients[i].ItemNum = reader.ReadInt32();
                Recipe[RecipeNum].Ingredients[i].Value   = reader.ReadInt32();
            }

            Recipe[RecipeNum].CreateTime = reader.ReadByte();
        }
コード例 #5
0
        static void FracReader(string fracFile)
        {
            string outPath = Path.ChangeExtension(fracFile, null);

            using (var stream = File.OpenRead(fracFile))
                using (var farcArchive = BinaryFile.Load <FarcArchive>(stream))
                {
                    Directory.CreateDirectory(outPath);

                    foreach (string fileName in farcArchive)
                    {
                        using (var source = farcArchive.Open(fileName, EntryStreamMode.MemoryStream))
                            using (var spriteSet = BinaryFile.Load <SpriteSet>(source))
                            {
                                Bitmap[] sourceBitmaps = new Bitmap[spriteSet.TextureSet.Textures.Count];
                                for (var i = 0; i < sourceBitmaps.Length; i++)
                                {
                                    sourceBitmaps[i] = TextureDecoder.Decode(spriteSet.TextureSet.Textures[i]);
                                    sourceBitmaps[i].RotateFlip(RotateFlipType.RotateNoneFlipY);
                                }

                                foreach (Sprite sprite in spriteSet.Sprites)
                                {
                                    Console.WriteLine("Writing {0} - {1}", Path.GetFileName(fracFile), sprite.Name);
                                    Rectangle rec          = new Rectangle((int)sprite.X, (int)sprite.Y, (int)sprite.Width, (int)sprite.Height);
                                    Bitmap    targetBitmap = new Bitmap(rec.Width, rec.Height);
                                    Graphics  graphics     = Graphics.FromImage(targetBitmap);
                                    graphics.DrawImage(sourceBitmaps[sprite.TextureIndex], -rec.X, -rec.Y);
                                    targetBitmap.Save(Path.Combine(outPath, sprite.Name + ".png"), ImageFormat.Png);
                                }
                            }
                    }
                }
        }
コード例 #6
0
        public static void LoadProjectiles()
        {
            string filename;
            int    i;

            CheckProjectile();

            for (i = 1; i <= MAX_PROJECTILES; i++)
            {
                filename = Path.Combine(Application.StartupPath, "data", "projectiles", string.Format("projectile{0}.dat", i));
                ByteStream reader = new ByteStream();
                BinaryFile.Load(filename, ref reader);

                Projectiles[i].Name   = reader.ReadString();
                Projectiles[i].Sprite = reader.ReadInt32();
                Projectiles[i].Range  = reader.ReadByte();
                Projectiles[i].Speed  = reader.ReadInt32();
                Projectiles[i].Damage = reader.ReadInt32();
                //Logic
                Projectiles[i].OnInstantiate = reader.ReadString();
                Projectiles[i].OnUpdate      = reader.ReadString();
                Projectiles[i].OnHitWall     = reader.ReadString();
                Projectiles[i].OnHitEntity   = reader.ReadString();
            }
        }
コード例 #7
0
        private Skin PrompImportExData()
        {
            string filePath =
                ModuleImportUtilities.SelectModuleImport(new[]
                                                         { typeof(FarcArchive), typeof(ObjectSet) });

            if (string.IsNullOrEmpty(filePath))
            {
                return(null);
            }

            ObjectSet objSet;

            if (filePath.EndsWith(".farc", StringComparison.OrdinalIgnoreCase))
            {
                objSet = BinaryFileNode <ObjectSet> .PromptFarcArchiveViewForm(filePath,
                                                                               "Select a file to replace with.",
                                                                               "This archive has no object set file.");
            }

            else
            {
                objSet = BinaryFile.Load <ObjectSet>(filePath);
            }

            if (objSet == null)
            {
                return(null);
            }

            if (objSet.Objects.Count == 0 || !objSet.Objects.Any(x => x.Skin != null && x.Skin.Blocks.Count > 0))
            {
                MessageBox.Show("This object set has no objects with ex data.", Program.Name, MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return(null);
            }

            if (objSet.Objects.Count == 1)
            {
                return(objSet.Objects[0].Skin);
            }

            using (var listNode = new ListNode <Object>("Objects", objSet.Objects, x => x.Name))
                using (var nodeSelectForm =
                           new NodeSelectForm <Object>(listNode, obj => obj.Skin != null && obj.Skin.Blocks.Count > 0))
                {
                    nodeSelectForm.Text = "Please select an object.";

                    if (nodeSelectForm.ShowDialog() == DialogResult.OK)
                    {
                        return((( Object )nodeSelectForm.TopNode.Data).Skin);
                    }
                }

            return(null);
        }
コード例 #8
0
        private void ConvertOsageSkinParameters(BinaryFormat format)
        {
            var filePaths =
                ModuleImportUtilities.SelectModuleImportMultiselect <OsageSkinParameterSet>(
                    "Select file(s) to convert.");

            if (filePaths == null)
            {
                return;
            }

            using (var folderBrowserDialog = new VistaFolderBrowserDialog
            {
                Description = "Select a folder to save file(s) to.", UseDescriptionForTitle = true
            })
            {
                if (folderBrowserDialog.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                new Thread(() =>
                {
                    try
                    {
                        Invoke(new Action(() => Enabled = false));

                        string extension = format.IsModern() ? ".osp" : ".txt";

                        foreach (string filePath in filePaths)
                        {
                            var ospSet = BinaryFile.Load <OsageSkinParameterSet>(filePath);

                            ospSet.Format = format;
                            ospSet.Save(Path.Combine(folderBrowserDialog.SelectedPath,
                                                     Path.GetFileNameWithoutExtension(filePath) + extension));
                        }
                    }
                    finally
                    {
                        Invoke(new Action(() => Enabled = true));
                    }
                }).Start();
            }
        }
コード例 #9
0
        public static void ProcessFile(string path)
        {
            string destinationFileName = path;

            if (path.EndsWith(".spr"))
            {
                destinationFileName = Path.ChangeExtension(destinationFileName, "bin");
                SpriteSet spr = BinaryFile.Load <SpriteSet>(path);
                foreach (Sprite sprite in spr.Sprites)
                {
                    sprite.ResolutionMode = ResolutionMode.HDTV720;
                    sprite.Name           = "MD_IMG";
                }
                spr.Format                = BinaryFormat.DT;
                spr.TextureSet.Format     = BinaryFormat.DT;
                spr.Endianness            = Endianness.Little;
                spr.TextureSet.Endianness = Endianness.Little;
                spr.Save(destinationFileName);
            }
        }
コード例 #10
0
        public static void LoadAnimation(int AnimationNum)
        {
            string filename;

            filename = Path.Combine(Application.StartupPath, "data", "animations", string.Format("animation{0}.dat", AnimationNum));
            ByteStream reader = new ByteStream();

            BinaryFile.Load(filename, ref reader);

            Types.Animation[AnimationNum].Name  = reader.ReadString();
            Types.Animation[AnimationNum].Sound = reader.ReadString();
            var loopTo = Information.UBound(Types.Animation[AnimationNum].Sprite);

            for (var x = 0; x <= loopTo; x++)
            {
                Types.Animation[AnimationNum].Sprite[x] = reader.ReadInt32();
            }
            var loopTo1 = Information.UBound(Types.Animation[AnimationNum].Frames);

            for (int x = 0; x <= loopTo1; x++)
            {
                Types.Animation[AnimationNum].Frames[x] = reader.ReadInt32();
            }
            var loopTo2 = Information.UBound(Types.Animation[AnimationNum].LoopCount);

            for (int x = 0; x <= loopTo2; x++)
            {
                Types.Animation[AnimationNum].LoopCount[x] = reader.ReadInt32();
            }
            var loopTo3 = Information.UBound(Types.Animation[AnimationNum].LoopTime);

            for (int x = 0; x <= loopTo3; x++)
            {
                Types.Animation[AnimationNum].LoopTime[x] = reader.ReadInt32();
            }

            if (Types.Animation[AnimationNum].Name == null)
            {
                Types.Animation[AnimationNum].Name = "";
            }
        }
コード例 #11
0
ファイル: objset.cs プロジェクト: lybxlpsv/ft_parser
        public models Stripify(string filePath)
        {
            var stgpv    = new Model();
            var textures = new MikuMikuLibrary.Textures.TextureSet();
            var texdb    = new TextureDatabase();

            using (var farcArchive = BinaryFile.Load <FarcArchive>(filePath))
            {
                using (var entryStream = farcArchive.Open(farcArchive.Entries.Where(c => c.Contains("txi")).First(), EntryStreamMode.MemoryStream))
                    texdb.Load(entryStream);
                using (var entryStream = farcArchive.Open(farcArchive.Entries.Where(c => c.Contains("txd")).First(), EntryStreamMode.MemoryStream))
                    textures.Load(entryStream);
                using (var entryStream = farcArchive.Open(farcArchive.Entries.First(), EntryStreamMode.MemoryStream))
                    stgpv.Load(entryStream, textures, texdb);
            }

            foreach (var meshes in stgpv.Meshes)
            {
                foreach (var submeshes in meshes.SubMeshes)
                {
                    foreach (var indexTable in submeshes.IndexTables)
                    {
                        ushort[] triangleStrip = Stripifier.Stripify(indexTable.Indices);
                        if (triangleStrip != null)
                        {
                            indexTable.PrimitiveType = PrimitiveType.TriangleStrip;
                            indexTable.Indices       = triangleStrip;
                        }
                    }
                }
            }

            var le_model = new models();

            le_model.model    = stgpv;
            le_model.fileName = filePath;
            Logs.WriteLine("Stripified " + Path.GetFileName(filePath));
            return(le_model);
        }
コード例 #12
0
        public static void LoadResource(int ResourceNum)
        {
            string filename;

            filename = Path.Combine(Application.StartupPath, "data", "resources", string.Format("resource{0}.dat", ResourceNum));
            ByteStream reader = new ByteStream();

            BinaryFile.Load(filename, ref reader);

            Types.Resource[ResourceNum].Name           = reader.ReadString();
            Types.Resource[ResourceNum].SuccessMessage = reader.ReadString();
            Types.Resource[ResourceNum].EmptyMessage   = reader.ReadString();
            Types.Resource[ResourceNum].ResourceType   = reader.ReadInt32();
            Types.Resource[ResourceNum].ResourceImage  = reader.ReadInt32();
            Types.Resource[ResourceNum].ExhaustedImage = reader.ReadInt32();
            Types.Resource[ResourceNum].ExpReward      = reader.ReadInt32();
            Types.Resource[ResourceNum].ItemReward     = reader.ReadInt32();
            Types.Resource[ResourceNum].LvlRequired    = reader.ReadInt32();
            Types.Resource[ResourceNum].ToolRequired   = reader.ReadInt32();
            Types.Resource[ResourceNum].Health         = reader.ReadInt32();
            Types.Resource[ResourceNum].RespawnTime    = reader.ReadInt32();
            Types.Resource[ResourceNum].Walkthrough    = reader.ReadBoolean();
            Types.Resource[ResourceNum].Animation      = reader.ReadInt32();

            if (Types.Resource[ResourceNum].Name == null)
            {
                Types.Resource[ResourceNum].Name = "";
            }
            if (Types.Resource[ResourceNum].EmptyMessage == null)
            {
                Types.Resource[ResourceNum].EmptyMessage = "";
            }
            if (Types.Resource[ResourceNum].SuccessMessage == null)
            {
                Types.Resource[ResourceNum].SuccessMessage = "";
            }
        }
コード例 #13
0
        private static void Main(string[] args)
        {
            string sourceFileName      = null;
            string destinationFileName = null;

            bool compress  = false;
            int  alignment = 16;

            for (int i = 0; i < args.Length; i++)
            {
                string arg = args[i];

                if (EqualsAny("-c", "--compress"))
                {
                    compress = true;
                }

                else if (EqualsAny("-a", "--alignment"))
                {
                    alignment = int.Parse(args[++i]);
                }

                else if (sourceFileName == null)
                {
                    sourceFileName = arg;
                }

                else if (destinationFileName == null)
                {
                    destinationFileName = arg;
                }

                bool EqualsAny(params string[] strings)
                {
                    return(strings.Contains(arg, StringComparer.OrdinalIgnoreCase));
                }
            }

            if (sourceFileName == null)
            {
                Console.WriteLine(Resources.HelpText);
                Console.ReadLine();
                return;
            }

            if (destinationFileName == null)
            {
                destinationFileName = sourceFileName;
            }

            if (sourceFileName.EndsWith(".farc", StringComparison.OrdinalIgnoreCase))
            {
                destinationFileName = Path.ChangeExtension(destinationFileName, null);

                using (var stream = File.OpenRead(sourceFileName))
                {
                    var farcArchive = BinaryFile.Load <FarcArchive>(stream);

                    Directory.CreateDirectory(destinationFileName);

                    foreach (string fileName in farcArchive)
                    {
                        using (var destination = File.Create(Path.Combine(destinationFileName, fileName)))
                            using (var source = farcArchive.Open(fileName, EntryStreamMode.OriginalStream))
                                source.CopyTo(destination);
                    }
                }
            }
            else
            {
                destinationFileName = Path.ChangeExtension(destinationFileName, "farc");

                var farcArchive = new FarcArchive {
                    IsCompressed = compress, Alignment = alignment
                };

                if (File.GetAttributes(sourceFileName).HasFlag(FileAttributes.Directory))
                {
                    foreach (string filePath in Directory.EnumerateFiles(sourceFileName))
                    {
                        farcArchive.Add(Path.GetFileName(filePath), filePath);
                    }
                }

                else
                {
                    farcArchive.Add(Path.GetFileName(sourceFileName), sourceFileName);
                }

                farcArchive.Save(destinationFileName);
            }
        }
コード例 #14
0
 public override FarcArchive Import(string filePath) =>
 BinaryFile.Load <FarcArchive>(filePath);
コード例 #15
0
 protected override BoneDatabase ImportCore(Stream source, string fileName)
 {
     return(BinaryFile.Load <BoneDatabase>(source, true));
 }
コード例 #16
0
 public override SpriteSet Import(string filePath)
 {
     return(BinaryFile.Load <SpriteSet>(filePath));
 }
コード例 #17
0
 protected override ObjectDatabase ImportCore(Stream source, string fileName) =>
 BinaryFile.Load <ObjectDatabase>(source, true);
 protected override OsageSkinParameterSet ImportCore(Stream source, string fileName)
 {
     return(BinaryFile.Load <OsageSkinParameterSet>(source, true));
 }
コード例 #19
0
 protected override ObjectSet ImportCore(Stream source, string fileName)
 {
     return(BinaryFile.Load <ObjectSet>(source, true));
 }
コード例 #20
0
        protected override void InitializeCore()
        {
            mValueMap = new Dictionary <DataNode, object>();

            if (Data.Flags.HasFlag(BinaryFileFlags.Load))
            {
                mFlags |= DataNodeActionFlags.Replace;
                RegisterReplaceHandler <TArchive>((path) => BinaryFile.Load <TArchive>(path));
            }
            if (Data.Flags.HasFlag(BinaryFileFlags.Save))
            {
                mFlags |= DataNodeActionFlags.Export;
                RegisterExportHandler <TArchive>((path) => Data.Save(path));
            }
            if (Data.CanAdd)
            {
                mFlags |= DataNodeActionFlags.Import | DataNodeActionFlags.Move;
                RegisterImportHandler <Stream>((path) => DataNodeFactory.Create(path));
            }
            if (Data.CanRemove)
            {
                mFlags |= DataNodeActionFlags.Remove;
            }

            RegisterCustomHandler("Export All", () =>
            {
                using (var saveFileDialog = new SaveFileDialog())
                {
                    saveFileDialog.AutoUpgradeEnabled = true;
                    saveFileDialog.CheckPathExists    = true;
                    saveFileDialog.Title    = "Select a folder to export textures to.";
                    saveFileDialog.FileName = "Enter into a directory and press Save";

                    if (saveFileDialog.ShowDialog() == DialogResult.OK)
                    {
                    }
                }
            }, Keys.Control | Keys.Shift | Keys.E);

            RegisterDataUpdateHandler(() =>
            {
                // We're gonna work with the original data always
                foreach (var node in Nodes)
                {
                    Stream stream = null;

                    bool exists;
                    if ((exists = mValueMap.TryGetValue(node, out object value) && !value.Equals(node.Data)) || !exists)
                    {
                        stream = new FormatModuleStream(node.Data, node.Name);
                    }

                    if (stream != null)
                    {
                        Data.Add(node.Name, stream, false, ConflictPolicy.Replace);
                        mValueMap[node] = node.Data;
                    }
                }

                return(Data);
            });
        }
コード例 #21
0
 protected override FarcArchive ImportCore(Stream source, string fileName) =>
 BinaryFile.Load <FarcArchive>(source, true);
コード例 #22
0
ファイル: Program.cs プロジェクト: samnyan/MikuMikuLibrary
        private static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine(Resources.HelpText);
                Console.ReadLine();
                return;
            }

            string sourceFileName      = null;
            string destinationFileName = null;

            foreach (string arg in args)
            {
                if (sourceFileName == null)
                {
                    sourceFileName = arg;
                }

                else if (destinationFileName == null)
                {
                    destinationFileName = arg;
                }
            }

            if (destinationFileName == null)
            {
                destinationFileName = sourceFileName;
            }

            if (File.GetAttributes(sourceFileName).HasFlag(FileAttributes.Directory))
            {
                destinationFileName = Path.ChangeExtension(destinationFileName, "bin");

                var textureSet = new TextureSet();
                var textures   = new SortedList <int, Texture>();
                foreach (string textureFileName in Directory.EnumerateFiles(sourceFileName))
                {
                    if (textureFileName.EndsWith(".dds", StringComparison.OrdinalIgnoreCase) ||
                        textureFileName.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
                    {
                        string cleanFileName = Path.GetFileNameWithoutExtension(textureFileName);
                        if (int.TryParse(cleanFileName, out int index))
                        {
                            Texture texture;

                            if (textureFileName.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
                            {
                                var bitmap = new Bitmap(textureFileName);
                                var format = TextureFormat.RGB;

                                if (DDSCodec.HasTransparency(bitmap))
                                {
                                    format = TextureFormat.RGBA;
                                }

                                texture = TextureEncoder.Encode(new Bitmap(textureFileName), format, false);
                            }

                            else
                            {
                                texture = TextureEncoder.Encode(textureFileName);
                            }

                            textures.Add(index, texture);
                        }

                        else
                        {
                            Console.WriteLine(
                                "WARNING: Skipped '{0}' because it didn't match the expected name format",
                                Path.GetFileName(textureFileName));
                        }
                    }
                }

                textureSet.Textures.Capacity = textures.Count;
                foreach (var texture in textures.Values)
                {
                    textureSet.Textures.Add(texture);
                }

                textureSet.Save(destinationFileName);
            }

            else if (sourceFileName.EndsWith(".bin", StringComparison.OrdinalIgnoreCase) ||
                     sourceFileName.EndsWith(".txd", StringComparison.OrdinalIgnoreCase))
            {
                destinationFileName = Path.ChangeExtension(destinationFileName, null);

                var textureSet = BinaryFile.Load <TextureSet>(sourceFileName);

                Directory.CreateDirectory(destinationFileName);
                for (int i = 0; i < textureSet.Textures.Count; i++)
                {
                    var    texture = textureSet.Textures[i];
                    string name    = string.IsNullOrEmpty(texture.Name) ? $"{i}" : texture.Name;

                    if (TextureFormatUtilities.IsCompressed(texture.Format))
                    {
                        TextureDecoder.DecodeToDDS(texture, Path.Combine(destinationFileName, $"{name}.dds"));
                    }

                    else
                    {
                        TextureDecoder.DecodeToPNG(texture, Path.Combine(destinationFileName, $"{name}.png"));
                    }
                }
            }
        }
コード例 #23
0
        public static void LoadItem(int ItemNum)
        {
            string filename;
            int    s;

            filename = Path.Combine(Application.StartupPath, "data", "items", string.Format("item{0}.dat", ItemNum));

            ByteStream reader = new ByteStream();

            BinaryFile.Load(filename, ref reader);

            Types.Item[ItemNum].Name        = reader.ReadString();
            Types.Item[ItemNum].Pic         = reader.ReadInt32();
            Types.Item[ItemNum].Description = reader.ReadString();

            Types.Item[ItemNum].Type      = reader.ReadByte();
            Types.Item[ItemNum].SubType   = reader.ReadByte();
            Types.Item[ItemNum].Data1     = reader.ReadInt32();
            Types.Item[ItemNum].Data2     = reader.ReadInt32();
            Types.Item[ItemNum].Data3     = reader.ReadInt32();
            Types.Item[ItemNum].ClassReq  = reader.ReadInt32();
            Types.Item[ItemNum].AccessReq = reader.ReadInt32();
            Types.Item[ItemNum].LevelReq  = reader.ReadInt32();
            Types.Item[ItemNum].Mastery   = reader.ReadByte();
            Types.Item[ItemNum].Price     = reader.ReadInt32();

            for (s = 0; s <= (int)Enums.StatType.Count - 1; s++)
            {
                Types.Item[ItemNum].Add_Stat[s] = reader.ReadByte();
            }

            Types.Item[ItemNum].Rarity    = reader.ReadByte();
            Types.Item[ItemNum].Speed     = reader.ReadInt32();
            Types.Item[ItemNum].TwoHanded = reader.ReadInt32();
            Types.Item[ItemNum].BindType  = reader.ReadByte();

            for (s = 0; s <= (int)Enums.StatType.Count - 1; s++)
            {
                Types.Item[ItemNum].Stat_Req[s] = reader.ReadByte();
            }

            Types.Item[ItemNum].Animation = reader.ReadInt32();
            Types.Item[ItemNum].Paperdoll = reader.ReadInt32();

            // Housing
            Types.Item[ItemNum].FurnitureWidth  = reader.ReadInt32();
            Types.Item[ItemNum].FurnitureHeight = reader.ReadInt32();

            for (var a = 0; a <= 3; a++)
            {
                for (var b = 0; b <= 3; b++)
                {
                    Types.Item[ItemNum].FurnitureBlocks[a, b] = reader.ReadInt32();
                    Types.Item[ItemNum].FurnitureFringe[a, b] = reader.ReadInt32();
                }
            }

            Types.Item[ItemNum].KnockBack      = reader.ReadByte();
            Types.Item[ItemNum].KnockBackTiles = reader.ReadByte();

            Types.Item[ItemNum].Randomize = reader.ReadByte();
            Types.Item[ItemNum].RandomMin = reader.ReadByte();
            Types.Item[ItemNum].RandomMax = reader.ReadByte();

            Types.Item[ItemNum].Stackable = reader.ReadByte();

            Types.Item[ItemNum].ItemLevel = reader.ReadByte();

            Types.Item[ItemNum].Projectile = reader.ReadInt32();
            Types.Item[ItemNum].Ammo       = reader.ReadInt32();
        }
コード例 #24
0
 protected override TextureSet ImportCore(Stream source, string fileName) =>
 BinaryFile.Load <TextureSet>(source, true);
コード例 #25
0
        private void do2DConvert()
        {
            string ac_path   = "";
            string ft_path   = "";
            string fs_path   = "";
            string ct_path   = "";
            bool   ask_user  = false;
            bool   skip_robs = false;

            if (File.Exists("config.txt"))
            {
                StreamReader sr = new StreamReader("config.txt");
                while (sr.Peek() > -1)
                {
                    var line  = sr.ReadLine();
                    var lines = line.Split('=');
                    if (lines[0] == "AC")
                    {
                        ac_path = lines[1];
                    }
                    if (lines[0] == "FT")
                    {
                        ft_path = lines[1];
                    }
                    if (lines[0] == "FS")
                    {
                        fs_path = lines[1];
                    }
                    if (lines[0] == "CT")
                    {
                        ct_path = lines[1];
                    }
                    if (lines[0] == "I_HAVE_CHANGED_THIS")
                    {
                        if (lines[1] == "TRUE")
                        {
                            ask_user = true;
                        }
                    }
                    if (lines[0] == "SKIP_2D")
                    {
                        if (lines[1] == "TRUE")
                        {
                            skip_robs = true;
                        }
                    }
                }
                sr.Close();
            }

            if ((ask_user) && (!skip_robs))
            {
                Logs.WriteLine("Sel2D Start");
                string[] filespl = System.IO.Directory.GetFiles(ft_path + @"\2d\", "spr_sel_pv*.farc", SearchOption.AllDirectories);
                string[] filesfs = { };
                string[] filesct = { };
                if (fs_path != "")
                {
                    filesfs = System.IO.Directory.GetFiles(fs_path + @"\2d\", "spr_sel_pv*.farc", SearchOption.AllDirectories);
                }
                if (ct_path != "")
                {
                    filesct = System.IO.Directory.GetFiles(ct_path + @"\2d\", "spr_sel_pv*.farc", SearchOption.AllDirectories);
                }
                string[] files = filespl.Concat(filesfs).ToArray().Concat(filesct).ToArray();


                foreach (var filePath in files)
                {
                    if ((!File.Exists(ac_path + @"\2d\" + Path.GetFileNameWithoutExtension(filePath) + ".farc")) && (Path.GetFileNameWithoutExtension(filePath) != "spr_sel_pv"))
                    {
                        Logs.WriteLine("Processing " + Path.GetFileNameWithoutExtension(filePath));
                        string farcpath = filePath;

                        var spriteset = new SpriteSet();

                        using (var farcArchive = BinaryFile.Load <FarcArchive>(farcpath))
                            using (var entryStream = farcArchive.Open(farcArchive.Entries.First(), EntryStreamMode.MemoryStream))
                                spriteset.Load(entryStream);

                        foreach (var i in spriteset.Sprites)
                        {
                            i.Field01 = 0x0000000D;
                        }


                        spriteset.Save("temp");

                        FarcArchive newfarc = new FarcArchive();
                        newfarc.Add(Path.GetFileNameWithoutExtension(filePath) + ".bin", "temp");
                        newfarc.Save(ac_path + "\\2d\\" + Path.GetFileName(filePath));
                    }
                    //newfarc.Dispose();
                }
            }
        }
コード例 #26
0
ファイル: S_Quest.cs プロジェクト: limocute/OrionPlusSharp
        public static void LoadQuest(int QuestNum)
        {
            string FileName;
            int    I;

            FileName = Path.Combine(Application.StartupPath, "data", "quests", string.Format("quest{0}.dat", QuestNum));

            ByteStream reader = new ByteStream();

            BinaryFile.Load(FileName, ref reader);

            Quest[QuestNum].Name       = reader.ReadString();
            Quest[QuestNum].QuestLog   = reader.ReadString();
            Quest[QuestNum].Repeat     = reader.ReadByte();
            Quest[QuestNum].Cancelable = reader.ReadByte();

            Quest[QuestNum].ReqCount         = reader.ReadInt32();
            Quest[QuestNum].Requirement      = new int[Quest[QuestNum].ReqCount + 1];
            Quest[QuestNum].RequirementIndex = new int[Quest[QuestNum].ReqCount + 1];
            var loopTo = Quest[QuestNum].ReqCount;

            for (I = 1; I <= loopTo; I++)
            {
                Quest[QuestNum].Requirement[I]      = reader.ReadInt32();
                Quest[QuestNum].RequirementIndex[I] = reader.ReadInt32();
            }

            Quest[QuestNum].QuestGiveItem        = reader.ReadInt32();
            Quest[QuestNum].QuestGiveItemValue   = reader.ReadInt32();
            Quest[QuestNum].QuestRemoveItem      = reader.ReadInt32();
            Quest[QuestNum].QuestRemoveItemValue = reader.ReadInt32();

            for (I = 1; I <= 3; I++)
            {
                Quest[QuestNum].Chat[I] = reader.ReadString();
            }

            Quest[QuestNum].RewardCount      = reader.ReadInt32();
            Quest[QuestNum].RewardItem       = new int[Quest[QuestNum].RewardCount + 1];
            Quest[QuestNum].RewardItemAmount = new int[Quest[QuestNum].RewardCount + 1];
            var loopTo1 = Quest[QuestNum].RewardCount;

            for (I = 1; I <= loopTo1; I++)
            {
                Quest[QuestNum].RewardItem[I]       = reader.ReadInt32();
                Quest[QuestNum].RewardItemAmount[I] = reader.ReadInt32();
            }
            Quest[QuestNum].RewardExp = reader.ReadInt32();

            Quest[QuestNum].TaskCount = reader.ReadInt32();
            Quest[QuestNum].Task      = new TaskRec[Quest[QuestNum].TaskCount + 1];
            var loopTo2 = Quest[QuestNum].TaskCount;

            for (I = 1; I <= loopTo2; I++)
            {
                Quest[QuestNum].Task[I].Order    = reader.ReadInt32();
                Quest[QuestNum].Task[I].NPC      = reader.ReadInt32();
                Quest[QuestNum].Task[I].Item     = reader.ReadInt32();
                Quest[QuestNum].Task[I].Map      = reader.ReadInt32();
                Quest[QuestNum].Task[I].Resource = reader.ReadInt32();
                Quest[QuestNum].Task[I].Amount   = reader.ReadInt32();
                Quest[QuestNum].Task[I].Speech   = reader.ReadString();
                Quest[QuestNum].Task[I].TaskLog  = reader.ReadString();
                Quest[QuestNum].Task[I].QuestEnd = reader.ReadByte();
                Quest[QuestNum].Task[I].TaskType = reader.ReadInt32();
            }
        }
コード例 #27
0
        private void doRobConvert()
        {
            string ac_path   = "";
            string ft_path   = "";
            string fs_path   = "";
            string ct_path   = "";
            bool   ask_user  = false;
            bool   skip_robs = false;

            if (File.Exists("config.txt"))
            {
                StreamReader sr = new StreamReader("config.txt");
                while (sr.Peek() > -1)
                {
                    var line  = sr.ReadLine();
                    var lines = line.Split('=');
                    if (lines[0] == "AC")
                    {
                        ac_path = lines[1];
                    }
                    if (lines[0] == "FT")
                    {
                        ft_path = lines[1];
                    }
                    if (lines[0] == "FS")
                    {
                        fs_path = lines[1];
                    }
                    if (lines[0] == "CT")
                    {
                        ct_path = lines[1];
                    }
                    if (lines[0] == "I_HAVE_CHANGED_THIS")
                    {
                        if (lines[1] == "TRUE")
                        {
                            ask_user = true;
                        }
                    }
                    if (lines[0] == "SKIP_ROBS")
                    {
                        if (lines[1] == "TRUE")
                        {
                            skip_robs = true;
                        }
                    }
                }
                sr.Close();
            }
            if ((ask_user) && (!skip_robs))
            {
                Logs.WriteLine("Rob Retarget Start");
                string[] filespl = System.IO.Directory.GetFiles(ft_path + @"\rob\", "*.farc", SearchOption.AllDirectories);
                string[] filesfs = { };
                string[] filesct = { };
                if (fs_path != "")
                {
                    filesfs = System.IO.Directory.GetFiles(fs_path + @"\rob\", "*.farc", SearchOption.AllDirectories);
                }
                if (ct_path != "")
                {
                    filesct = System.IO.Directory.GetFiles(ct_path + @"\rob\", "*.farc", SearchOption.AllDirectories);
                }
                string[] files = filespl.Concat(filesfs).ToArray().Concat(filesct).ToArray();


                var BoneDatabaseFT   = new BoneDatabase();
                var BoneDatabaseAC   = new BoneDatabase();
                var MotionDatabaseFT = new MotionDatabase();
                var MotionDatabaseAC = new MotionDatabase();

                BoneDatabaseFT.Load(ft_path + "\\bone_data.bin");
                BoneDatabaseAC.Load(ac_path + "\\bone_data.bin");

                using (var farcArchive = BinaryFile.Load <FarcArchive>(ac_path + "\\rob\\mot_db.farc"))
                    using (var entryStream = farcArchive.Open(farcArchive.Entries.First(), EntryStreamMode.MemoryStream))
                        MotionDatabaseAC.Load(entryStream);

                using (var farcArchive = BinaryFile.Load <FarcArchive>(ft_path + "\\rob\\mot_db.farc"))
                    using (var entryStream = farcArchive.Open(farcArchive.Entries.First(), EntryStreamMode.MemoryStream))
                        MotionDatabaseFT.Load(entryStream);

                var SkeletonEntryAC = BoneDatabaseAC.Skeletons[0];
                var SkeletonEntryFT = BoneDatabaseFT.Skeletons[0];

                foreach (var filePath in files)
                {
                    var motionset = new MotionSet();
                    if (!File.Exists(ac_path + "\\rob\\" + Path.GetFileName(filePath)))
                    {
                        if (!filePath.Contains("db"))
                        {
                            Logs.WriteLine("Processing " + Path.GetFileNameWithoutExtension(filePath));

                            string farcpath = filePath;

                            using (var farcArchive = BinaryFile.Load <FarcArchive>(farcpath))
                                using (var entryStream = farcArchive.Open(farcArchive.Entries.First(), EntryStreamMode.MemoryStream))
                                    motionset.Load(entryStream, SkeletonEntryFT, MotionDatabaseFT);
                            {
                                motionset.Save("temp", SkeletonEntryAC, MotionDatabaseAC);
                                //motionset.Dispose();


                                FarcArchive newfarc = new FarcArchive();
                                newfarc.Add(Path.GetFileNameWithoutExtension(filePath) + ".bin", "temp");
                                newfarc.Save(ac_path + "\\rob\\" + Path.GetFileName(filePath));
                            }
                        }
                    }
                }
            }
        }
コード例 #28
0
ファイル: ModelModule.cs プロジェクト: nastys/LukaLukaLibrary
 protected override Model ImportCore(Stream source, string fileName) =>
 BinaryFile.Load <Model>(source, true);
コード例 #29
0
        static void Main(string[] args)
        {
            bool   matFix         = false;
            bool   texCoordFix    = true;
            bool   texIdFix       = false;
            string sourceFileName = null;

            for (int i = 0; i < args.Length; i++)
            {
                string arg = args[i];

                if (EqualsAny("-m", "--matfix"))
                {
                    matFix = true;
                }

                else if (EqualsAny("-tc=f", "--texcoordfix=f"))
                {
                    texCoordFix = false;
                }

                else if (EqualsAny("-tid", "--texidfix"))
                {
                    texIdFix = true;
                }

                else if (sourceFileName == null)
                {
                    sourceFileName = arg;
                }

                bool EqualsAny(params string[] strings)
                {
                    return(strings.Contains(arg, StringComparer.OrdinalIgnoreCase));
                }
            }

            var farcArchive = BinaryFile.Load <FarcArchive>(sourceFileName);

            foreach (var fileName in farcArchive)
            {
                var memoryStream = new MemoryStream();

                if (fileName.EndsWith("_obj.bin"))
                {
                    var source = farcArchive.Open(fileName, EntryStreamMode.MemoryStream);
                    var ObjSet = BinaryFile.Load <ObjectSet>(source);

                    foreach (var obj in ObjSet.Objects)
                    {
                        if (matFix)
                        {
                            foreach (var mat in obj.Materials)
                            {
                                mat.PhongShading   = true;
                                mat.LambertShading = true;
                            }
                        }

                        if (texCoordFix)
                        {
                            foreach (var mesh in obj.Meshes)
                            {
                                foreach (var submesh in mesh.SubMeshes)
                                {
                                    submesh.TexCoordIndices[0] = 0;
                                    submesh.TexCoordIndices[1] = 1;
                                    submesh.TexCoordIndices[2] = 0;
                                    submesh.TexCoordIndices[3] = 0;
                                    submesh.TexCoordIndices[4] = 0;
                                    submesh.TexCoordIndices[5] = 0;
                                    submesh.TexCoordIndices[6] = 0;
                                    submesh.TexCoordIndices[7] = 0;
                                }
                            }
                        }
                    }

                    if (texIdFix)
                    {
                        var TexIds    = ObjSet.TextureIds;
                        var NewTexIds = new List <uint>();

                        foreach (var Id in TexIds)
                        {
                            NewTexIds.Add(Id + 100000);
                        }
                        ObjSet.TextureIds.Clear();
                        ObjSet.TextureIds.AddRange(NewTexIds);

                        if (ObjSet.Objects.Count != 0)
                        {
                            foreach (var obj in ObjSet.Objects)
                            {
                                foreach (var mat in obj.Materials)
                                {
                                    foreach (var matTex in mat.MaterialTextures)
                                    {
                                        matTex.TextureId += 100000;
                                    }
                                }
                            }
                        }
                    }
                    ObjSet.Save(memoryStream, true);
                    farcArchive.Add(fileName, memoryStream, false, ConflictPolicy.Replace);
                }
            }
            farcArchive.Save(sourceFileName);
        }
コード例 #30
0
        private void fixObjSet()
        {
            string ac_path       = "";
            string ft_path       = "";
            bool   ask_user      = false;
            bool   skip_objset   = false;
            bool   skip_robs     = false;
            bool   skip_ui       = false;
            bool   skip_filecopy = false;
            bool   skip_2d       = false;
            bool   skip_db       = false;
            bool   alt_db        = false;
            bool   skip_movie    = false;

            if (File.Exists("config.txt"))
            {
                StreamReader sr = new StreamReader("config.txt");
                while (sr.Peek() > -1)
                {
                    var line  = sr.ReadLine();
                    var lines = line.Split('=');
                    if (lines[0] == "AC")
                    {
                        ac_path = lines[1];
                    }
                    if (lines[0] == "FT")
                    {
                        ft_path = lines[1];
                    }
                    if (lines[0] == "I_HAVE_CHANGED_THIS")
                    {
                        if (lines[1] == "TRUE")
                        {
                            ask_user = true;
                        }
                    }

                    if (lines[0] == "SKIP_OBJSET")
                    {
                        if (lines[1] == "TRUE")
                        {
                            skip_objset = true;
                        }
                    }

                    if (lines[0] == "SKIP_ROBS")
                    {
                        if (lines[1] == "TRUE")
                        {
                            skip_robs = true;
                        }
                    }

                    if (lines[0] == "UI_MOD")
                    {
                        if (lines[1] == "TRUE")
                        {
                            skip_ui = true;
                        }
                    }

                    if (lines[0] == "SKIP_2D")
                    {
                        if (lines[1] == "TRUE")
                        {
                            skip_2d = true;
                        }
                    }

                    if (lines[0] == "SKIP_FILECOPY")
                    {
                        if (lines[1] == "TRUE")
                        {
                            skip_filecopy = true;
                        }
                    }

                    if (lines[0] == "SKIP_DB")
                    {
                        if (lines[1] == "TRUE")
                        {
                            skip_filecopy = true;
                        }
                    }

                    if (lines[0] == "SKIP_MOVIE")
                    {
                        if (lines[1] == "TRUE")
                        {
                            skip_movie = true;
                        }
                    }

                    if (lines[0] == "ALT_DB")
                    {
                        if (lines[1] == "TRUE")
                        {
                            alt_db = true;
                        }
                    }
                }
                sr.Close();
            }

            string path  = ft_path;
            string path2 = ac_path;

            List <string> files = new List <string>();

            string[] filess = System.IO.Directory.GetFiles(path + @"\objset\", "*hrc.farc", SearchOption.AllDirectories);

            foreach (var i in filess)
            {
                files.Add(i);
            }

            filess = System.IO.Directory.GetFiles(path + @"\objset\", "effchrpv*.farc", SearchOption.AllDirectories);

            foreach (var i in filess)
            {
                files.Add(i);
            }

            foreach (var filePath in files)
            {
                try
                {
                    //if ((!File.Exists(ac_path + @"\2d\" + Path.GetFileNameWithoutExtension(filePath) + ".farc")) && (Path.GetFileNameWithoutExtension(filePath) != "spr_sel_pv"))
                    {
                        Logs.WriteLine("Processing " + Path.GetFileNameWithoutExtension(filePath));

                        var models = new Model();

                        string obj = "";
                        string tex = "";

                        using (var farcArchive = BinaryFile.Load <FarcArchive>(filePath))
                            using (var entryStream = farcArchive.Open(farcArchive.Entries.Where(c => c.Contains("obj")).First(), EntryStreamMode.MemoryStream))
                            {
                                models.Load(entryStream);
                                obj = farcArchive.Entries.Where(c => c.Contains("obj")).First();
                            }

                        using (var farcArchive = BinaryFile.Load <FarcArchive>(filePath))
                            using (var entryStream = farcArchive.Open(farcArchive.Entries.Where(c => c.Contains("tex")).First(), EntryStreamMode.MemoryStream))
                            {
                                tex = farcArchive.Entries.Where(c => c.Contains("tex")).First();
                            }

                        foreach (var mesh in models.Meshes)
                        {
                            foreach (var mat in mesh.Materials)
                            {
                                mat.Shader = "ITEM";
                            }
                        }

                        models.Save("temp");
                        var newfarc = new FarcArchive();
                        newfarc.Add(obj, "temp");

                        using (var farcArchive = BinaryFile.Load <FarcArchive>(filePath))
                            using (var entryStream = farcArchive.Open(farcArchive.Entries.Where(c => c.Contains("tex")).First(), EntryStreamMode.MemoryStream))
                                newfarc.Add(tex, entryStream, false);

                        newfarc.Save(ac_path + "\\" + "objset" + "\\" + Path.GetFileName(filePath));
                    }
                } catch (Exception e)
                {
                    Logs.WriteLine(e.ToString());
                    //Console.WriteLine(e.ToString());
                }
            }
        }