Esempio n. 1
0
        public Bitmap export(int w, int h, string pal)
        {
            Bitmap       bmp    = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
            ColorPalette tmppal = bmp.Palette;

            LureConfig.LurePalette p = LureConfig.get().getPalette(pal);
            for (int i = 0; i < 256; i++)
            {
                tmppal.Entries[i] = p.cols[i];
            }
            byte[] tdata = new byte[w * h];
            int    xlen  = xdata.Length;

            if (w * h < xlen)
            {
                xlen = w * h;
            }
            Array.Copy(xdata, 0, tdata, 0, xlen);
            unused = xdata.Length - xlen;
            while (xlen < tdata.Length)
            {
                tdata[xlen++] = 0;
            }
            bmp.Palette = tmppal;
            BitmapData bd = bmp.LockBits(new Rectangle(0, 0, w, h),
                                         ImageLockMode.WriteOnly, bmp.PixelFormat);

            for (int i = 0; i < bd.Height; i++)
            {
                System.Runtime.InteropServices.Marshal.Copy(tdata, i * bd.Width, new IntPtr(bd.Scan0.ToInt64() + i * bd.Stride), bd.Width);
            }
            bmp.UnlockBits(bd);
            return(bmp);
        }
Esempio n. 2
0
        public void readDecoder(bool old)
        {
            byte[] dec = null;
            if (old)
            {
                if (olddec == null)
                {
                    dec    = LureConfig.get().DecodeTable;
                    olddec = new byte[dec.Length];
                    Array.Copy(dec, olddec, dec.Length);
                }
                else
                {
                    dec = new byte[olddec.Length];
                    Array.Copy(olddec, dec, dec.Length);
                }
            }
            else
            {
                dec = LureConfig.get().DecodeTable;
            }
            letters.Clear();
            int pos = 0;

            while (dec[pos] != 0xff)
            {
                char c = (char)dec[pos];
                pos++;
                string s = BinaryHelper.readZString(dec, pos);
                pos += s.Length + 1;
                letters.Add(new Letter(s, c));
            }
        }
Esempio n. 3
0
        public void import(Bitmap bmp)
        {
            if (bmp.Width != width || bmp.Height != height)
            {
                throw new Exception(String.Format("Wrong bmp size {0}x{1} (need {2}x{3})", bmp.Width, bmp.Height, width, height));
            }
            ColorPalette pal = bmp.Palette;

            LureConfig.LurePalette xpal = LureConfig.get().getPalette(palette);
            for (int i = 0; i < 256; i++)
            {
                if (pal.Entries[i].ToArgb() != xpal.cols[i].ToArgb())
                {
                    throw new Exception("Palette differs");
                }
            }
            byte[]     res = new byte[width * height];
            BitmapData bd  = bmp.LockBits(new Rectangle(0, 0, width, height),
                                          ImageLockMode.ReadWrite, bmp.PixelFormat);

            for (int i = 0; i < height; i++)
            {
                System.Runtime.InteropServices.Marshal.Copy(new IntPtr(bd.Scan0.ToInt64() + i * bd.Stride), res, i * bd.Width, bd.Width);
            }
            bmp.UnlockBits(bd);
            byte[] nr = Compressor.compress(res);
            LureDisks.setResource(resnum, nr);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Console.WriteLine("vlure v" + VERSION + " by Br. John Fn None");
#if !NO_CATCH
            try
#endif
            {
                string[] argv = LureConfig.get().setParams(args);
                if (LureConfig.get().help || argv.Length == 0 || argv[0] == "help")
                {
                    usage();
                    return;
                }
                switch (argv[0])
                {
                case "list":
                    list(argv);
                    return;

                case "dump":
                    dump(LureCommon.strToInt(getarg(argv, 1)));
                    return;

                case "export":
                    export(getarg(argv, 1) == "all"?-1:LureCommon.strToInt(argv[1]));
                    return;

                case "import":
                    import(getarg(argv, 1) == "all" ? -1 : LureCommon.strToInt(argv[1]));
                    return;

                case "img":
                    int w = 0;
                    int h = 0;
                    try
                    {
                        w = LureCommon.strToInt(argv[2]);
                        h = LureCommon.strToInt(argv[3]);
                    }catch {}
                    Application.Run(viewImage(LureCommon.strToInt(argv[1]), w, h));
                    return;

                case "test":
                    test(argv);
                    return;

                default:
                    throw new Exception("unknown command " + argv[0]);
                }
            }
#if !NO_CATCH
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: " + ex.Message + "\n" + ex.StackTrace);
                Console.ReadKey();
            }
#endif
        }
Esempio n. 5
0
        static Form viewImage(int fileid, int w, int h)
        {
            LureConfig.LureFile f = LureConfig.get().findFile(fileid);
            string pal            = "";
            string nm             = "";

            if (f != null)
            {
                pal = f.node.Attributes["palette"].Value;
                if (f.node.Attributes["name"] != null)
                {
                    nm = f.node.Attributes["name"].Value;
                }
                if (w == 0)
                {
                    w = LureCommon.strToInt(f.node.Attributes["width"].Value);
                }
                if (h == 0)
                {
                    h = LureCommon.strToInt(f.node.Attributes["height"].Value);
                }
            }
            if (w == 0)
            {
                w = 320;
            }
            if (h == 0)
            {
                h = 200;
            }
            return(new ImgForm(fileid, w, h, pal, nm));
        }
Esempio n. 6
0
 public ImgForm(int fileid, int w, int h, string pal, string name)
 {
     InitializeComponent();
     if (pal == "")
     {
         pal = "GRAYSCALE";
     }
     if (name == "")
     {
         name = "image" + fileid.ToString();
     }
     for (int i = 0; i < LureConfig.get().palettes.Count; i++)
     {
         cb_pal.Items.Add(LureConfig.get().palettes[i].name);
     }
     nud_w.Value = w;
     nud_h.Value = h;
     if (pal != "")
     {
         cb_pal.SelectedItem = pal;
     }
     textBox1.Text = name;
     //cb_pal.SelectedText = pal;
     img = new LureImage(fileid, w, h, pal);
     //nud_w_ValueChanged(null, null);
 }
Esempio n. 7
0
        public void import(XmlDocument doc)
        {
            XmlNode blk = null;

            if (doc.DocumentElement.Name == "lure-strings")
            {
                blk = LureCommon.findNode(doc.DocumentElement, "block");
            }
            else if (doc.DocumentElement.Name == "lure-texts")
            {
                blk = LureCommon.findNode(LureCommon.findNode(doc.DocumentElement, "file", "id", resnum.ToString()), "block");
            }
            else
            {
                throw new Exception("bad strings xml");
            }
            ushort count  = BinaryHelper.readU16_LE(data, 0);
            int    curofs = 2;

            for (int i = 0; i < count; i++)
            {
                XmlNode nd  = LureCommon.findNode(blk, "text", "id", i.ToString());
                string  val = "";
                if (nd.ChildNodes.Count > 0)
                {
                    val = LureConfig.get().convert(nd.ChildNodes[0].Value);
                }
                data = LureCommon.checkArrLength(data, curofs + val.Length + 1);
                BinaryHelper.writeZString(data, ref curofs, val);
            }
            LureDisks.setResource(resnum, data);
        }
Esempio n. 8
0
        public Bitmap export(string pal)
        {
            byte[] tdata = new byte[xlen];
            int    iOfs  = xlen;

            Array.Copy(xdata, 0, tdata, 0, xlen);
            List <byte[]> imgs = new List <byte[]>();

            imgs.Add((byte[])tdata.Clone());
            int cOfs = 0;

            while (cOfs < cdata.Length && iOfs < xdata.Length)
            {
                int sOfs = 0;
                while (sOfs < xlen)
                {
                    UInt16 len = cdata[cOfs++];
                    if (len == 0)
                    {
                        len   = BinaryHelper.readU16_LE(cdata, cOfs);
                        cOfs += 2;
                    }
                    if (len > 0)
                    {
                        Array.Copy(xdata, iOfs, tdata, sOfs, len);
                        iOfs += len;
                        sOfs += len;
                    }
                    len = cdata[cOfs++];
                    if (len == 0)
                    {
                        len   = BinaryHelper.readU16_LE(cdata, cOfs);
                        cOfs += 2;
                    }
                    sOfs += len;
                }
                //next screen
                imgs.Add((byte[])tdata.Clone());
            }
            Bitmap       bmp    = new Bitmap(320, 200 * imgs.Count, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
            ColorPalette tmppal = bmp.Palette;

            LureConfig.LurePalette p = LureConfig.get().getPalette(pal);
            for (int i = 0; i < 256; i++)
            {
                tmppal.Entries[i] = p.cols[i];
            }
            bmp.Palette = tmppal;
            BitmapData bd = bmp.LockBits(new Rectangle(0, 0, 320, 200 * imgs.Count),
                                         ImageLockMode.WriteOnly, bmp.PixelFormat);

            for (int i = 0; i < bd.Height; i++)
            {
                System.Runtime.InteropServices.Marshal.Copy(imgs[i / 200], (i % 200) * bd.Width, new IntPtr(bd.Scan0.ToInt64() + i * bd.Stride), bd.Width);
            }
            bmp.UnlockBits(bd);
            return(bmp);
        }
Esempio n. 9
0
        public void import(Bitmap bmp)
        {
            if (bmp.Width != 320 || bmp.Height % 200 != 0)
            {
                throw new Exception(String.Format("Wrong bmp size {0}x{1} (need 320x200n)", bmp.Width, bmp.Height));
            }
            ColorPalette pal = bmp.Palette;

            LureConfig.LurePalette xpal = LureConfig.get().getPalette(palette);
            for (int i = 0; i < 256; i++)
            {
                if (pal.Entries[i].ToArgb() != xpal.cols[i].ToArgb())
                {
                    throw new Exception("Palette differs");
                }
            }
            byte[] data = new byte[320 * bmp.Height];

            BitmapData bd = bmp.LockBits(new Rectangle(0, 0, 320, bmp.Height),
                                         ImageLockMode.ReadWrite, bmp.PixelFormat);

            for (int i = 0; i < bmp.Height; i++)
            {
                System.Runtime.InteropServices.Marshal.Copy(new IntPtr(bd.Scan0.ToInt64() + i * bd.Stride), data, i * bd.Width, bd.Width);
            }
            bmp.UnlockBits(bd);

            int screens = bmp.Height / 200;

            byte[] dt2  = new byte[xlen];
            byte[] cmd  = new byte[0];
            int    rOfs = xlen;
            int    cOfs = 0;

            Array.Copy(data, dt2, xlen);

            for (int i = 1; i < screens; i++)
            {
                byte[] pix;
                byte[] code;
                compressScreen(data, i, out pix, out code);
                Array.Resize <byte>(ref dt2, dt2.Length + pix.Length);
                Array.Copy(pix, 0, dt2, rOfs, pix.Length);
                rOfs += pix.Length;
                Array.Resize <byte>(ref cmd, cmd.Length + code.Length);
                Array.Copy(code, 0, cmd, cOfs, code.Length);
                cOfs += code.Length;
            }
            data = null;

            byte[] nr = Compressor.compress(dt2);

            LureDisks.setResource(resnum, nr);
            LureDisks.setResource(resnum + 1, cmd);
        }
Esempio n. 10
0
 public LureDisk getDisk(int id)
 {
     if (id > 4)
     {
         throw new Exception("Bad Disk ID " + id.ToString());
     }
     if (dsk[id] == null)
     {
         dsk[id] = new LureDisk(id, LureConfig.get().path);
     }
     return(dsk[id]);
 }
Esempio n. 11
0
        static void dump(int id)
        {
            string of = LureConfig.get().outputFile(id.ToString() + ".bin");

            Console.WriteLine("dumping " + id.ToString() + " to " + of);
            byte[] data = LureDisks.getResource(id);
            if (LureConfig.get().compress)
            {
                data = Decompressor.decompress(data);
            }
            LureCommon.dumpFile(data, of);
        }
Esempio n. 12
0
 public void setAllTexts(XmlDocument xml)
 {
     foreach (LureConfig.LureFile f in LureConfig.get().lureFiles)
     {
         if (f.type == "text")
         {
             new LureText(f.id).import(xml);
         }
         else if (f.type == "string_list")
         {
             new LureStringList(f.id).import(xml);
         }
     }
 }
Esempio n. 13
0
 public static LureTexts getAllTexts()
 {
     get().xml.DocumentElement.RemoveAll();
     foreach (LureConfig.LureFile f in LureConfig.get().lureFiles)
     {
         if (f.type == "text")
         {
             get().addText(new LureText(f.id).export(), f.id);
         }
         else if (f.type == "string_list")
         {
             get().addText(new LureStringList(f.id).export(), f.id);
         }
     }
     return(get());
 }
Esempio n. 14
0
        static void list(string[] argv)
        {
            bool known = false;
            int  dsk   = -1;
            int  aid   = 1;

            while (aid < argv.Length)
            {
                string s = argv[aid];
                aid++;
                switch (s)
                {
                case "known":
                    known = true;
                    break;

                case "disk":
                    dsk = LureCommon.strToInt(argv[aid]);
                    aid++;
                    break;

                default:
                    throw new Exception("unknown param " + s);
                }
            }
            Console.WriteLine("  id     offset      size       type");
            for (int i = 0; i < 5; i++)
            {
                if (dsk == -1 || dsk == i)
                {
                    Console.WriteLine("-=DISK " + i.ToString() + "=-");
                    foreach (LureDisk.FileEntry f in LureDisks.get(i).entries)
                    {
                        if (f.id == 0xFFFF)
                        {
                            break;
                        }
                        LureConfig.LureFile lf = LureConfig.get().findFile(f.id);
                        if (!known || lf != null)
                        {
                            Console.WriteLine(string.Format("{0,5:D}{1,12:X8}{2,12:X8}{3,20:s}", f.id, f.realOfs, f.realSize, (lf == null?"":lf.type)));
                        }
                    }
                }
            }
        }
Esempio n. 15
0
        public void import(XmlDocument doc)
        {
            if (doc.DocumentElement.Name != "lure-decoder")
            {
                throw new Exception("bad decoder xml");
            }
            byte[] dec = new byte[1];
            int    pos = 0;

            foreach (XmlNode nd in doc.DocumentElement.ChildNodes)
            {
                impNode(nd, ref dec, ref pos);
            }
            dec      = LureCommon.checkArrLength(dec, pos + 1);
            dec[pos] = 0xff;
            pos++;
            LureDisks.setResource(LureConfig.get().decode_tbl, dec);
            //readDecoder();
        }
Esempio n. 16
0
        public Bitmap export()
        {
            Bitmap bmp = new Bitmap(61 * 8, 16);
            int    cnt = 122;

            if (LureConfig.get().lang_id == 6)
            {
                cnt = 115;
            }
            for (int i = 0; i < cnt; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    byte ln   = data[i * 8 + j];
                    int  xofs = i * 8 - (i < 61?0:61 * 8);
                    for (int k = 0; k < 8; k++)
                    {
                        bool bit = (((ln >> (8 - 1 - k)) & 1) == 1);
                        bmp.SetPixel(xofs + k, j + (i < 61?0:8), bit?Color.Black:Color.White);
                    }
                }
            }
            return(bmp);
        }
Esempio n. 17
0
 private void button1_Click(object sender, EventArgs e)
 {
     LureConfig.get().saveImage(img.resnum, (int)nud_w.Value, (int)nud_h.Value, cb_pal.Text, textBox1.Text);
     Close();
 }
Esempio n. 18
0
        public static void importResource(int id)
        {
            LureConfig.LureFile f = LureConfig.get().findFile(id);
            if (f == null)
            {
                throw new Exception("File not found in config " + id.ToString());
            }
            string infile = "";

            switch (f.type)
            {
            case "text":
            case "string_list":
            case "text_decode_table":
                infile = LureConfig.get().inputFile(id.ToString() + ".xml");
                LureCommon.checkFile(infile);
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.Load(infile);
                if (f.type == "text")
                {
                    new LureText(f.id).import(doc);
                }
                else if (f.type == "text_decode_table")
                {
                    TextDecoder.get().import(doc);
                }
                else
                {
                    new LureStringList(f.id).import(doc);
                }
                break;

            case "font":
                infile = LureConfig.get().inputFile(id.ToString() + ".bmp");
                LureCommon.checkFile(infile);
                System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(infile);
                new LureFont(f.id).import(bmp);
                break;

            case "image":
                int    w   = LureCommon.strToInt(f.node.Attributes["width"].Value);
                int    h   = LureCommon.strToInt(f.node.Attributes["height"].Value);
                string pal = f.node.Attributes["palette"].Value;
                string nm  = "image" + f.id.ToString();
                if (f.node.Attributes["name"] != null)
                {
                    nm = f.node.Attributes["name"].Value;
                }
                infile = LureConfig.get().outputFile(nm + ".bmp");
                new LureImage(f.id, w, h, pal).import(new System.Drawing.Bitmap(infile));
                break;

            case "anim":
                string apal = f.node.Attributes["palette"].Value;
                string anm  = "image" + f.id.ToString();
                if (f.node.Attributes["name"] != null)
                {
                    anm = f.node.Attributes["name"].Value;
                }
                infile = LureConfig.get().outputFile(anm + ".bmp");
                new LureAnim(f.id, apal).import(new System.Drawing.Bitmap(infile));
                break;

            default:
                throw new Exception("dont know how to import " + f.type);
            }
        }
Esempio n. 19
0
        public LureDisk(int id, string paths)
        {
            string file2 = "";

            dskid = id;
            string[] pts = paths.Split(';');
            file = "lure.dat";
            if (id > 0)
            {
                file  = "disk" + id.ToString() + ".vga";
                file2 = "Disk" + id.ToString() + ".vga";
            }
            if (!File.Exists(file))
            {
                if (File.Exists(file2))
                {
                    file = file2;
                }
                else
                {
                    foreach (string p in pts)
                    {
                        string s = p;
                        if (s[s.Length - 1] != '/')
                        {
                            s += "/";
                        }
                        if (File.Exists(s + file))
                        {
                            file = s + file;
                            break;
                        }
                        if (File.Exists(s + file2))
                        {
                            file = s + file2;
                            break;
                        }
                    }
                }
            }
            if (!File.Exists(file))
            {
                throw new Exception("Disk not found " + file);
            }
            string xfile = file;

            if (File.Exists(xfile + ".bak"))
            {
                xfile += ".bak";
            }
            FileStream fs = new FileStream(xfile, FileMode.Open);

            diskData = new byte[fs.Length];
            fs.Read(diskData, 0, diskData.Length);
            fs.Close();
            if (id == 0)
            {
                if (BinaryHelper.readString(diskData, 0, 4) != "lure")
                {
                    throw new Exception("bad lure.dat");
                }
                int b = 6;
                while (diskData[b] != LureConfig.get().lang_id)
                {
                    b += 5;
                    if (diskData[b] == 0xff)
                    {
                        throw new Exception("lure.dat language " + LureConfig.get().lang_id.ToString() + " not found");
                    }
                }
                int dofs = (int)BinaryHelper.readU32_LE(diskData, b + 1);
                b = 6;
                int dsz = int.MaxValue;
                while (diskData[b] != 0xFF)
                {
                    int sofs = (int)BinaryHelper.readU32_LE(diskData, b + 1);
                    b += 5;
                    if (sofs > dofs)
                    {
                        if (sofs - dofs < dsz)
                        {
                            dsz = sofs - dofs;
                        }
                    }
                }
                byte[] newdisk = new byte[dsz];
                Array.Copy(diskData, dofs, newdisk, 0, dsz);
                diskData = newdisk;
            }
            readEntries();
        }
Esempio n. 20
0
        public static void exportResource(int id)
        {
            LureConfig.LureFile f = LureConfig.get().findFile(id);
            if (f == null)
            {
                throw new Exception("File not found in config " + id.ToString());
            }
            string outfile = "";

            switch (f.type)
            {
            case "text":
            case "string_list":
            case "text_decode_table":
                outfile = LureConfig.get().outputFile(id.ToString() + ".xml");
                if (f.type == "text")
                {
                    new LureText(f.id).export().Save(outfile);
                }
                else if (f.type == "text_decode_table")
                {
                    TextDecoder.get().export().Save(outfile);
                }
                else
                {
                    new LureStringList(f.id).export().Save(outfile);
                }
                break;

            case "font":
                outfile = LureConfig.get().outputFile(id.ToString() + ".bmp");
                new LureFont(f.id).export().Save(outfile, ImageFormat.Bmp);
                break;

            case "image":
                int    w   = LureCommon.strToInt(f.node.Attributes["width"].Value);
                int    h   = LureCommon.strToInt(f.node.Attributes["height"].Value);
                string pal = f.node.Attributes["palette"].Value;
                string nm  = "image" + f.id.ToString();
                if (f.node.Attributes["name"] != null)
                {
                    nm = f.node.Attributes["name"].Value;
                }
                outfile = LureConfig.get().outputFile(nm + ".bmp");
                new LureImage(f.id, w, h, pal).export().Save(outfile, ImageFormat.Bmp);
                break;

            case "anim":
                string apal = f.node.Attributes["palette"].Value;
                string anm  = "image" + f.id.ToString();
                if (f.node.Attributes["name"] != null)
                {
                    anm = f.node.Attributes["name"].Value;
                }
                outfile = LureConfig.get().outputFile(anm + ".bmp");
                new LureAnim(f.id, apal).export().Save(outfile, ImageFormat.Bmp);
                break;

            default:
                throw new Exception("dont know how to export " + f.type);
            }
        }
Esempio n. 21
0
        public void import(XmlDocument xml)
        {
            XmlNode blkhld = null;

            if (xml.DocumentElement.Name == "lure-text")
            {
                blkhld = xml.DocumentElement;
            }
            else if (xml.DocumentElement.Name == "lure-texts")
            {
                blkhld = LureCommon.findNode(xml.DocumentElement, "file", "id", resnum.ToString());
            }
            else
            {
                throw new Exception("Bad text xml");
            }
            TextDecoder.get().readDecoder(true);
            XmlDocument prev = export(true);

            TextDecoder.get().readDecoder(false);
            uint          bitbuf  = 0;
            int           bitpos  = 0;
            List <byte>   txtdata = new List <byte>();
            List <UInt16> bs      = new List <UInt16>();
            List <byte>   skp     = new List <byte>();
            int           prevblk = 0;

            foreach (XmlNode nd in prev.DocumentElement.ChildNodes)
            {
                XmlNode blk     = LureCommon.findNode(blkhld, "block", "id", nd.Attributes["id"].Value);
                int     prevtxt = prevblk;
                foreach (XmlNode tnd in nd.ChildNodes)
                {
                    //bool art = tnd.Attributes["art"].Value == "1";
                    XmlNode txt = LureCommon.findNode(blk, "text", "id", tnd.Attributes["id"].Value);
                    string  val = "";
                    if (txt.ChildNodes.Count > 0)
                    {
                        val = txt.ChildNodes[0].Value;
                    }
                    val = LureNames.get().processNames(LureConfig.get().convert(val));
                    addText(val, txtdata, ref bitbuf, ref bitpos, tnd.Attributes["art"].Value == "1");
                    if (bitpos % 2 == 1)
                    {
                        addbit(false, txtdata, ref bitbuf, ref bitpos);
                    }
                    // if (tnd != nd.LastChild)
                    {
                        int ofs = (txtdata.Count << 2) + bitpos / 2;
                        int d   = ofs - prevtxt;
                        if (d > 0x7F)
                        {
                            while ((d & 7) != 0)
                            {
                                addbit(false, txtdata, ref bitbuf, ref bitpos);
                                ofs = (txtdata.Count << 2) + bitpos / 2;
                                d   = ofs - prevtxt;
                            }
                            d = (d >> 3) | 0x80;
                        }
                        skp.Add((byte)d);
                        prevtxt = ofs;
                    }
                }
                if (nd != prev.DocumentElement.LastChild)
                {
                    int offset = (txtdata.Count << 2) + bitpos / 2;
                    bs.Add((UInt16)(offset - prevblk));
                    prevblk = offset;
                }
            }
            while (bitpos != 0)
            {
                addbit(false, txtdata, ref bitbuf, ref bitpos);
            }
            data = new byte[4 + bs.Count * 2 + skp.Count + txtdata.Count];
            int o = 4;

            for (int i = 0; i < bs.Count; i++)
            {
                BinaryHelper.write_LE(data, o, bs[i]);
                o += 2;
            }
            BinaryHelper.write_LE(data, 0, (UInt16)o);
            for (int i = 0; i < skp.Count; i++)
            {
                data[o++] = skp[i];
            }
            BinaryHelper.write_LE(data, 2, (UInt16)o);
            for (int i = 0; i < txtdata.Count; i++)
            {
                data[o++] = txtdata[i];
            }
            LureDisks.setResource(resnum, data);
        }
Esempio n. 22
0
 public LureNames()
 {
     data = LureConfig.get().Names;
 }
Esempio n. 23
0
        static void import(int id)
        {
            if (id == -1)
            {
                Console.WriteLine("import all");
                int    mode = LureConfig.get().textfmt;
                string ext  = ".xml";
                if (mode == 1)
                {
                    ext = ".txt";
                }
                string d = LureConfig.get().direcroty("./");
                if (!Directory.Exists(d))
                {
                    Directory.CreateDirectory(d);
                }
                if (d[d.Length - 1] != '\\' && d[d.Length - 1] != '/')
                {
                    d += "/";
                }
                foreach (LureConfig.LureFile f in LureConfig.get().lureFiles)
                {
                    switch (f.type)
                    {
                    case "font":
                        new LureFont(f.id).import(new System.Drawing.Bitmap(d + "lure_font.bmp"));
                        break;

                    case "text_decode_table":
                        TextDecoder.get().import(LureCommon.loadXml(d + "decoder.xml"));
                        break;

                    case "image":
                        int    w   = LureCommon.strToInt(f.node.Attributes["width"].Value);
                        int    h   = LureCommon.strToInt(f.node.Attributes["height"].Value);
                        string pal = f.node.Attributes["palette"].Value;
                        string nm  = "image" + f.id.ToString();
                        if (f.node.Attributes["name"] != null)
                        {
                            nm = f.node.Attributes["name"].Value;
                        }
                        new LureImage(f.id, w, h, pal).import(new System.Drawing.Bitmap(d + nm + ".bmp"));
                        break;

                    case "anim":
                        string apal = f.node.Attributes["palette"].Value;
                        string anm  = "anim" + f.id.ToString();
                        if (f.node.Attributes["name"] != null)
                        {
                            anm = f.node.Attributes["name"].Value;
                        }
                        new LureAnim(f.id, apal).import(new System.Drawing.Bitmap(d + anm + ".bmp"));
                        break;
                    }
                }
                LureTexts.getAllTexts().load(d + "lure_text" + ext, mode);
            }
            else
            {
                Console.WriteLine("import " + id.ToString());
                importResource(id);
            }
            LureDisks.saveAll();
        }