public static MTX3 Parse(BinaryReader f)
        {
            MTX3 info = new MTX3();

            info.cnt1     = f.ReadInt32();
            info.text1    = "";
            info.unknown1 = "";
            for (int i = 0; i < info.cnt1; i++)
            {
                info.text1 += L2DatTool.ReadStringSimple_UnicodeInt32Length(f);
                if (i < info.cnt1 - 1)
                {
                    info.text1 += L2DatTool.DELIMITER;
                }

                byte[] temp = f.ReadBytes(2);
                info.unknown1 += BitConverter.ToString(temp);
                if (i < info.cnt1 - 1)
                {
                    info.unknown1 += L2DatTool.DELIMITER;
                }
            }
            info.cnt2  = f.ReadInt32();
            info.text2 = "";
            for (int i = 0; i < info.cnt2; i++)
            {
                info.text2 += L2DatTool.ReadStringSimple_UnicodeInt32Length(f);
                if (i < info.cnt2 - 1)
                {
                    info.text2 += L2DatTool.DELIMITER;
                }
            }
            info.text3 += L2DatTool.ReadStringSimple_UnicodeInt32Length(f);
            return(info);
        }
 public static void Compile(BinaryWriter f, MTX3 info)
 {
     string[] TmpStr  = info.text1.Split(new char[] { L2DatTool.DELIMITER });
     string[] TmpStr2 = info.unknown1.Split(new char[] { L2DatTool.DELIMITER });
     f.Write(info.cnt1);
     for (int i = 0; i < info.cnt1; i++)
     {
         L2DatTool.WriteStringSimple_UnicodeInt32Length(f, TmpStr[i]);
         string[] TmpStr3 = TmpStr2[i].Split(new char[] { '-' });
         for (int j = 0; j < TmpStr3.Length; j++)
         {
             f.Write(Convert.ToByte(TmpStr3[j], 16));
         }
     }
     TmpStr = info.text2.Split(new char[] { L2DatTool.DELIMITER });
     f.Write(info.cnt2);
     for (int i = 0; i < info.cnt2; i++)
     {
         L2DatTool.WriteStringSimple_UnicodeInt32Length(f, TmpStr[i]);
     }
     L2DatTool.WriteStringSimple_UnicodeInt32Length(f, info.text3);
 }
Beispiel #3
0
        public static MTX3 Parse(BinaryReader f)
        {

            MTX3 info = new MTX3();
            info.cnt1 = f.ReadInt32();
            info.text1 = "";
            info.unknown1 = "";
            for (int i = 0; i < info.cnt1; i++)
            {
                info.text1 += L2DatTool.ReadStringSimple_UnicodeInt32Length(f);
                if (i < info.cnt1 - 1)
                    info.text1 += L2DatTool.DELIMITER;

                byte[] temp = f.ReadBytes(2);
                info.unknown1 += BitConverter.ToString(temp);
                if (i < info.cnt1 - 1)
                    info.unknown1 += L2DatTool.DELIMITER;
            }
            info.cnt2 = f.ReadInt32();
            info.text2 = "";
            for (int i = 0; i < info.cnt2; i++)
            {
                info.text2 += L2DatTool.ReadStringSimple_UnicodeInt32Length(f);
                if (i < info.cnt2 - 1)
                    info.text2 += L2DatTool.DELIMITER;
            }
            info.text3 += L2DatTool.ReadStringSimple_UnicodeInt32Length(f);
            return info;
        }
Beispiel #4
0
 public static void Compile(BinaryWriter f, MTX3 info)
 {
     string[] TmpStr = info.text1.Split(new char[] { L2DatTool.DELIMITER });
     string[] TmpStr2 = info.unknown1.Split(new char[] { L2DatTool.DELIMITER });
     f.Write(info.cnt1);
     for (int i = 0; i < info.cnt1; i++)
     {
         L2DatTool.WriteStringSimple_UnicodeInt32Length(f, TmpStr[i]);
         string[] TmpStr3 = TmpStr2[i].Split(new char[] { '-' });
         for (int j = 0; j < TmpStr3.Length; j++)
         {
             f.Write(Convert.ToByte(TmpStr3[j], 16));
         }
     }
     TmpStr = info.text2.Split(new char[] { L2DatTool.DELIMITER });
     f.Write(info.cnt2);
     for (int i = 0; i < info.cnt2; i++)
     {
         L2DatTool.WriteStringSimple_UnicodeInt32Length(f, TmpStr[i]);
     }
     L2DatTool.WriteStringSimple_UnicodeInt32Length(f, info.text3);
 }
Beispiel #5
0
        private void ImpBtn_Click(object sender, EventArgs e)
        {
            String FName = "";
            String FValue = "";
            long RecNo = 1;

            try
            {
                this.StatusLabel.Text = Program.language.getMessage(MsgList.PleaseWait);
                this.FileNameCombo.Enabled = false;
                this.Enabled = false;

                this.ImportDialog.InitialDirectory = Application.StartupPath;
                this.ImportDialog.FileName = this.selectedComboName.Substring(0, this.selectedComboName.LastIndexOf("."));
                this.ImportDialog.Filter = "Tab-SeparatedValues files (*.tsv)|*.tsv";
                this.ImportDialog.FilterIndex = 1;
                this.ImportDialog.RestoreDirectory = true;
                if (this.ImportDialog.ShowDialog() == DialogResult.OK)
                {
                    this.DatInfo_init();
                    string line = "";
                    System.Text.Encoding enc = System.Text.Encoding.GetEncoding(Program.config.TextEncoding);
                    System.IO.StreamReader sr = new System.IO.StreamReader(this.ImportDialog.FileName, enc);

                    this.StatusProgress.Minimum = 0;
                    this.StatusProgress.Maximum = (int)sr.BaseStream.Length;
                    this.StatusProgress.Value = 0;
                    this.StatusProgress.Visible = true;

                    while ((line = sr.ReadLine()) != null)
                    {
                        if (line.StartsWith("#")) continue;

                        String[] TmpStr = line.Split(new char[] { '\t' });
                        for (int i = 0; i < TmpStr.Length; i++)
                        {
                            TmpStr[i] = TmpStr[i].Trim(new char[] { '"' });
                        }

                        L2DatDefinition item = this.DatInfo.getDefinition();
                        for (int i = 0, j = 0; i < this.DatInfo.getFieldNames().Count; i++, j++)
                        {
                            FName = this.DatInfo.getFieldNames()[i];
                            FValue = TmpStr[j];
                            FieldInfo FType = this.DatInfo.getDefinition().GetType().GetField(FName);
                            if (FType == null) continue;
                            if (FType.FieldType.FullName.EndsWith("UInt32"))
                                FType.SetValue(item, Convert.ToUInt32(TmpStr[j]));
                            else if (FType.FieldType.FullName.EndsWith("Int32"))
                                FType.SetValue(item, Convert.ToInt32(TmpStr[j]));
                            else if (FType.FieldType.FullName.EndsWith("Single"))
                                FType.SetValue(item, Convert.ToSingle(TmpStr[j]));
                            else if (FType.FieldType.FullName.EndsWith("Color"))
                                FType.SetValue(item, LmUtils.ConvertUtilities.HtmlColorToColor(TmpStr[j]));
                            else if (FType.FieldType.FullName.EndsWith("CNTINT_PAIR"))
                            {
                                CNTINT_PAIR tmpMtx = new CNTINT_PAIR();
                                string[] TmpStr2 = new string[tmpMtx.getFieldCount()];
                                for (int k = 0; k < tmpMtx.getFieldCount(); k++)
                                {
                                    TmpStr2[k] = TmpStr[j];
                                    if (k < tmpMtx.getFieldCount() - 1)
                                        j++;
                                }
                                tmpMtx.setText(TmpStr2);
                                FType.SetValue(item, tmpMtx);
                            }
                            else if (FType.FieldType.FullName.EndsWith("CNTRINT_PAIR"))
                            {
                                CNTRINT_PAIR tmpMtx = new CNTRINT_PAIR();
                                string[] TmpStr2 = new string[tmpMtx.getFieldCount()];
                                for (int k = 0; k < tmpMtx.getFieldCount(); k++)
                                {
                                    TmpStr2[k] = TmpStr[j];
                                    if (k < tmpMtx.getFieldCount() - 1)
                                        j++;
                                }
                                tmpMtx.setText(TmpStr2);
                                FType.SetValue(item, tmpMtx);
                            }
                            else if (FType.FieldType.FullName.EndsWith("CNTTXT_PAIR"))
                            {
                                CNTTXT_PAIR tmpMtx = new CNTTXT_PAIR();
                                string[] TmpStr2 = new string[tmpMtx.getFieldCount()];
                                for (int k = 0; k < tmpMtx.getFieldCount(); k++)
                                {
                                    TmpStr2[k] = TmpStr[j];
                                    if (k < tmpMtx.getFieldCount() - 1)
                                        j++;
                                }
                                tmpMtx.setText(TmpStr2);
                                FType.SetValue(item, tmpMtx);
                            }
                            else if (FType.FieldType.FullName.EndsWith("CNTTXT_PAIR2"))
                            {
                                CNTTXT_PAIR2 tmpMtx = new CNTTXT_PAIR2();
                                string[] TmpStr2 = new string[tmpMtx.getFieldCount()];
                                for (int k = 0; k < tmpMtx.getFieldCount(); k++)
                                {
                                    TmpStr2[k] = TmpStr[j];
                                    if (k < tmpMtx.getFieldCount() - 1)
                                        j++;
                                }
                                tmpMtx.setText(TmpStr2);
                                FType.SetValue(item, tmpMtx);
                            }
                            else if (FType.FieldType.FullName.EndsWith("CNTASCF_PAIR"))
                            {
                                CNTASCF_PAIR tmpMtx = new CNTASCF_PAIR();
                                string[] TmpStr2 = new string[tmpMtx.getFieldCount()];
                                for (int k = 0; k < tmpMtx.getFieldCount(); k++)
                                {
                                    TmpStr2[k] = TmpStr[j];
                                    if (k < tmpMtx.getFieldCount() - 1)
                                        j++;
                                }
                                tmpMtx.setText(TmpStr2);
                                FType.SetValue(item, tmpMtx);
                            }
                            else if (FType.FieldType.FullName.EndsWith("MTX"))
                            {
                                MTX tmpMtx = new MTX();
                                string[] TmpStr2 = new string[tmpMtx.getFieldCount()];
                                for (int k = 0; k < tmpMtx.getFieldCount(); k++)
                                {
                                    TmpStr2[k] = TmpStr[j];
                                    if (k < tmpMtx.getFieldCount() - 1)
                                        j++;
                                }
                                tmpMtx.setText(TmpStr2);
                                FType.SetValue(item, tmpMtx);
                            }
                            else if (FType.FieldType.FullName.EndsWith("MTX2"))
                            {
                                MTX2 tmpMtx = new MTX2();
                                string[] TmpStr2 = new string[tmpMtx.getFieldCount()];
                                for (int k = 0; k < tmpMtx.getFieldCount(); k++)
                                {
                                    TmpStr2[k] = TmpStr[j];
                                    if (k < tmpMtx.getFieldCount() - 1)
                                        j++;
                                }
                                tmpMtx.setText(TmpStr2);
                                FType.SetValue(item, tmpMtx);
                            }
                            else if (FType.FieldType.FullName.EndsWith("MTX3"))
                            {
                                MTX3 tmpMtx = new MTX3();
                                string[] TmpStr2 = new string[tmpMtx.getFieldCount()];
                                for (int k = 0; k < tmpMtx.getFieldCount(); k++)
                                {
                                    TmpStr2[k] = TmpStr[j];
                                    if (k < tmpMtx.getFieldCount() - 1)
                                        j++;
                                }
                                tmpMtx.setText(TmpStr2);
                                FType.SetValue(item, tmpMtx);
                            }
                            else if (FType.FieldType.FullName.EndsWith("ASCF"))
                            {
                                ASCF tmpStr2 = new ASCF();
                                tmpStr2.Text = TmpStr[j];
                                FType.SetValue(item, tmpStr2);
                            }
                            else if (FType.FieldType.FullName.EndsWith("HEX"))
                            {
                                HEX tmpStr2 = new HEX();
                                tmpStr2.Text = TmpStr[j];
                                FType.SetValue(item, tmpStr2);
                            }
                            else if (FType.FieldType.FullName.EndsWith("UNICODE"))
                            {
                                UNICODE tmpStr2 = new UNICODE();
                                tmpStr2.Text = TmpStr[j];
                                FType.SetValue(item, tmpStr2);
                            }
                            else
                                FType.SetValue(item, TmpStr[j]);
                        }
                        this.DatDatas.Add(item);
                        this.StatusProgress.Value = (int)sr.BaseStream.Position;
                        RecNo++;
                    }
                    sr.Close();

                    this.SaveBtn.Enabled = true;
                    this.ExpBtn.Enabled = true;
                }
                else
                    return;
            }
            catch (Exception ex)
            {
                ex = new ApplicationException(
                    String.Format("Error importing string file (RecNo: {0} FieldName: {1} FieldValue: {2})",
                                  RecNo, FName, FValue), ex);
                Program.log.Add(ex, true);
            }
            finally
            {
                this.Enabled = true;
                this.FileNameCombo.Enabled = true;
                this.StatusProgress.Visible = false;
                this.Forms_Update();
            }
            this.StatusLabel.Text = Program.language.getMessage(MsgList.COMPLETE) +
                                        String.Format(Program.language.getMessage(MsgList.CompleteImp), this.DatDatas.Count);
        }