Beispiel #1
0
        public static bool MyInit()
        {
            if (ClassicData != null)
            {
                return(true);
            }
            //d2 = true;
            string dir = "c:\\games\\d1x-rebirth\\data";
            string d2dir = "c:\\games\\descent2";
            string hogFile = Path.Combine(dir, "descent.hog"), palFile = "palette.256";

            if (d2)
            {
                hogFile = Path.Combine(d2dir, "descent2.hog");
                palFile = "groupa.256";
            }
            hog = new Hog(hogFile);
            byte[] vgapal = hog.ItemData(palFile);
            pal = ClassicLoader.VgaPalConv(vgapal);

            pal32 = new Color32[256];
            for (int i = 0; i < 256; i++)
            {
                pal32[i] = new Color32(pal[i * 3], pal[i * 3 + 1], pal[i * 3 + 2], 255);
            }

            palu = new uint[256];
            for (int i = 0; i < 256; i++)
            {
                palu[i] = ((uint)pal[i * 3] << 0) | ((uint)pal[i * 3 + 1] << 8) | ((uint)pal[i * 3 + 2] << 16) | (255u << 24);
            }

            var pigFile = Path.Combine(dir, "descent.pig");

            if (d2)
            {
                pigFile = Path.Combine(d2dir, "groupa.pig");
            }

            pig = new Pig(pigFile);


            if (d2)
            {
                pig.ReadD2Sound(Path.Combine(d2dir, "descent2.s11"));
                byte[] data = File.ReadAllBytes(Path.Combine(d2dir, "descent2.ham"));
                ClassicData = new ClassicData();
                ClassicData.Read(new BinaryReader(new MemoryStream(data, 8, data.Length - 8)), Version.D2);
            }
            else
            {
                pig.ReadTableData(out ClassicData);
            }

            shader = Shader.Find("Standard");
            //shader = Shader.Find("Diffuse");
            return(true);
        }
Beispiel #2
0
        public static bool ClassicInit()
        {
            if (ClassicData != null)
            {
                return(true);
            }
            string dir = Environment.GetEnvironmentVariable("OLMODDIR");
            string hogFile = Path.Combine(dir, "descent.hog"), pigFile = Path.Combine(dir, "descent.pig");

            if (!File.Exists(hogFile) || !File.Exists(pigFile))
            {
                return(false);
            }
            Hog hog = new Hog(hogFile);

            byte[] vgapal = hog.ItemData("palette.256");
            pal = ClassicLoader.VgaPalConv(vgapal);

            pal32 = new Color32[256];
            for (int i = 0; i < 256; i++)
            {
                pal32[i] = new Color32(pal[i * 3], pal[i * 3 + 1], pal[i * 3 + 2], 255);
            }

            palu = new uint[256];
            for (int i = 0; i < 256; i++)
            {
                palu[i] = ((uint)pal[i * 3] << 0) | ((uint)pal[i * 3 + 1] << 8) | ((uint)pal[i * 3 + 2] << 16) | (255u << 24);
            }

            pig = new Pig(pigFile);

            pig.ReadTableData(out ClassicData);

            shader = Shader.Find("Standard");
            //shader = Shader.Find("Diffuse");
            return(true);
        }