コード例 #1
0
        public static FILLER_360 Parse(BinaryReader f)
        {
            FILLER_360 info = new FILLER_360();

            for (int i = 0; i < 360; i++)
            {
                f.ReadByte();
            }
            info.Text = "0";
            return(info);
        }
コード例 #2
0
ファイル: L2DatFileTools.cs プロジェクト: Pipoden/l2datencdec
 public static void Compile(BinaryWriter f, FILLER_360 info)
 {
     L2DatTool.WriteString(f, info.Text);
 }
コード例 #3
0
ファイル: L2DatFileTools.cs プロジェクト: Pipoden/l2datencdec
 public static FILLER_360 Parse(BinaryReader f)
 {
     FILLER_360 info = new FILLER_360();
     for (int i = 0; i < 360; i++ )
     {
         f.ReadByte();
     }
     info.Text = "0";
     return info;
 }
コード例 #4
0
 public static void Compile(BinaryWriter f, FILLER_360 info)
 {
     L2DatTool.WriteString(f, info.Text);
 }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: Pipoden/l2datencdec
        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 if (FType.FieldType.FullName.EndsWith("FILLER_360"))
                            {
                                FILLER_360 tmpStr2 = new FILLER_360();
                                tmpStr2.Text = TmpStr[j];
                                FType.SetValue(item, tmpStr2);
                            }
                            else if (FType.FieldType.FullName.EndsWith("FILLER_90"))
                            {
                                FILLER_90 tmpStr2 = new FILLER_90();
                                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);
        }