Exemplo n.º 1
0
 public static LureNames get()
 {
     if (obj == null)
     {
         obj = new LureNames();
     }
     return(obj);
 }
Exemplo n.º 2
0
        string getChar(ref int ofs, ref int bit)
        {
            int  val = 0;
            char ch  = '\0';

            for (int bts = 1; bts <= 18; ++bts)
            {
                if (getBit(ref ofs, ref bit))
                {
                    val |= 1 << (bts - 1);
                }
                if (TextDecoder.get().hasChar(val, bts, ref ch))
                {
                    if (ch >= 0xA0 && ch != '%')
                    {
                        return(LureNames.get().getName(ch - 0xa0));
                    }
                    return(TextDecoder.replaceChar(ch));
                }
            }
            return(null);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 public static LureNames get()
 {
     if (obj == null)
         obj = new LureNames();
     return obj;
 }