Example #1
0
        public List <ElementTable> CreateElTable(eListCollection e)
        {
            List <ElementTable> etl = new List <ElementTable>();

            for (int a = 0; a < e.Lists.Length; ++a)
            {
                for (int b = 0; b < e.Lists[a].elementValues.Length; ++b)
                {
                    ElementTable et = new ElementTable();
                    et.list = e.Lists[a].listName;
                    if (e.Lists[a].elementFields[0] == "ID")
                    {
                        et.id = Convert.ToInt32(e.GetValue(a, b, 0));
                    }
                    et.f = new List <Fields>();
                    for (int c = 0; c < e.Lists[a].elementFields.Length; ++c)
                    {
                        if (e.Lists[a].elementTypes[c].Contains("string"))
                        {
                            Fields f = new Fields()
                            {
                                field = e.Lists[a].elementFields[c],
                                value = e.GetValue(a, b, c)
                            };
                            if (!f.value.Contains(".dds") && !f.value.Contains(".ecm"))
                            {
                                et.f.Add(f);
                            }
                        }
                    }
                    etl.Add(et);
                }
            }
            return(etl);
        }
Example #2
0
        private void src_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                src_el       = new eListCollection(ofd.FileName, this);
                src_txt.Text = string.Format("Версия: {0}", src_el.Version);
            }
        }
Example #3
0
        private void dst_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                dst_el        = new eListCollection(ofd.FileName, this);
                dst_txt.Text  = string.Format("Версия: {0}", dst_el.Version);
                split.Enabled = true;
            }
        }
Example #4
0
        private void open_el_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                src = ed.LoadElements(ofd.FileName);
                etl = ed.CreateElTable(src);
                import_el.Enabled = true;
                src_status.Text   = "Загружена версия: " + src.Version + "; Загружено элементов: " + etl.Count;
            }
        }
Example #5
0
        public void Import(object filename)
        {
            dst = ed.LoadElements((string)filename);
            ProgressStatus.Maximum = dst.Lists.Length;
            int a, b, c, d;

            for (a = 0; a < dst.Lists.Length; ++a)
            {
                if (a == dst.ConversationListIndex)
                {
                    dst.Lists[a] = src.Lists[a];
                }
                for (c = 0; c < etl.Count; ++c)
                {
                    if (dst.Lists[a].listName == etl[c].list)
                    {
                        for (b = 0; b < dst.Lists[a].elementValues.Length; ++b)
                        {
                            if (dst.Lists[a].elementFields[0] == "ID")
                            {
                                if (Convert.ToInt32(dst.GetValue(a, b, 0)) == etl[c].id)
                                {
                                    for (d = 0; d < dst.Lists[a].elementFields.Length; ++d)
                                    {
                                        foreach (Fields f in etl[c].f)
                                        {
                                            if (dst.Lists[a].elementFields[d].IndexOf(f.field) > -1)
                                            {
                                                dst.SetValue(a, b, d, f.value);
                                                //debugBox.Text += "ID: " + dst.GetValue(a, b, 0) + " => " + f.value + "\n";
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                ProgressStatus.Value++;
            }
            dst.Save((string)filename);
            ProgressStatus.Value = 0;
            debugBox.Text       += "Русификация Elements.data успешно завершена\n";
        }
Example #6
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog eLoad = new OpenFileDialog();

            eLoad.Filter           = "Elements File (*.data)|*.data|All Files (*.*)|*.*";
            eLoad.RestoreDirectory = false;
            if (eLoad.ShowDialog() == DialogResult.OK && File.Exists(eLoad.FileName))
            {
                locked = true;
                path   = eLoad.FileName;
                eLC    = new eListCollection();
                Dictionary <int, eItemCollection> data = eLC.Load(eLoad.FileName);
                comboBox_lists.Items.Clear();
                foreach (KeyValuePair <int, eItemCollection> sub in data)
                {
                    comboBox_lists.Items.Add(sub.Value.listName);
                }
                locked = false;
                comboBox_lists.SelectedIndex = 0;
            }
        }
Example #7
0
        private void OpenToolStripMenuItem_Click(object sender, EventArgs exxx)
        {
            BrakeReading = false;
            list_id      = 0;
            bool isParse = int.TryParse(textBox2.Text, out list_id);

            if (!isParse)
            {
                MessageBox.Show("Please specify the list!");
                return;
            }
            LastList = list_id;
            bool tryparse2 = int.TryParse(textBox4.Text, out int version);

            if (!tryparse2)
            {
                MessageBox.Show("Please specify an element version!");
                return;
            }

            bool tryparse3 = int.TryParse(textBox3.Text, out int countx);

            OpenFileDialog eLoad = new OpenFileDialog
            {
                Filter           = "Elements File (*.data)|*.data|All Files (*.*)|*.*",
                RestoreDirectory = false
            };

            if (eLoad.ShowDialog() == System.Windows.Forms.DialogResult.OK && File.Exists(eLoad.FileName))
            {
                GC.Collect();
                sameFile = eLoad.FileName;
                try
                {
                    Blocked           = true;
                    LastAddress       = textBox1.Text;
                    eLC               = new eListCollection();
                    eLC.progress_bar += Progress_bar;
                    eList[] Li = new eList[0];
                    Li        = eLC.LoadEmptyConfigs(version);
                    eLC.Lists = Li;
                    listBox_items.Rows.Clear();
                    using (FileStream fs = File.OpenRead(eLoad.FileName))
                    {
                        using (BinaryReader br = new BinaryReader(fs))
                        {
                            int pos = Convert.ToInt32(textBox1.Text.ToUpper().Trim().Normalize(), 16);
                            br.BaseStream.Seek(pos, SeekOrigin.Begin);
                            for (int l = list_id; l < list_id + 1; l++)
                            {
                                eLC.Lists[l].elementValues   = new SortedList <int, SortedList <int, object> >();
                                eLC.Lists[l].elementPosition = new SortedList <int, int>();

                                for (int e = 0; e < (tryparse3 && countx > 0 ? countx : 999999); e++)
                                {
                                    eLC.Lists[l].elementValues[e] = new SortedList <int, object>();
                                    Application.DoEvents();
                                    Progress_bar("Read :" + e + "/" + 99999, e, 99999);
                                    try
                                    {
                                        for (int f = 0; f < eLC.Lists[l].elementTypes.Length; f++)
                                        {
                                            eLC.Lists[l].elementValues[e][f] = eLC.ReadValue(br, eLC.Lists[l].elementTypes[f]);

                                            if (eLC.Lists[l].elementFields[f] == "Name")
                                            {
                                                int  id         = Int32.Parse(eLC.Lists[l].elementValues[e][0].ToString());
                                                bool isNegative = (id & (1 << 31)) != 0;
                                                if (isNegative)
                                                {
                                                    break;
                                                }
                                                listBox_items.Rows.Add(new object[] { id.ToString(), eLC.Lists[l].GetValue(e, f) });

                                                if (checkBox1.Checked)
                                                {
                                                    Application.DoEvents();
                                                    listBox_items.Rows[e].Selected = true;
                                                    listBox_items.CurrentCell      = listBox_items.Rows[e].Cells[0];
                                                }
                                            }
                                        }

                                        eLC.Lists[l].elementPosition[e] = (Int32)br.BaseStream.Position;
                                        textBox5.Text = eLC.Lists[l].elementPosition[e].ToString("X4").ToUpper();
                                    }
                                    catch
                                    {
                                        break;
                                    }

                                    if (BrakeReading)
                                    {
                                        break;
                                    }
                                }
                            }

                            BrakeReading = false;
                            Blocked      = false;
                        }
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }
            }
        }
Example #8
0
        private void OpenSameFile()
        {
            list_id = 0;
            bool isParse = int.TryParse(textBox2.Text, out list_id);

            if (!isParse)
            {
                MessageBox.Show("Please specify the list!");
                return;
            }

            bool tryparse2 = int.TryParse(textBox4.Text, out int version);

            if (!tryparse2)
            {
                MessageBox.Show("Please specify an element version!");
                return;
            }

            bool tryparse3 = int.TryParse(textBox3.Text, out int countx);


            if (sameFile != null)
            {
                GC.Collect();
                try
                {
                    Blocked = true;
                    eLC     = new eListCollection();
                    eList[] Li = new eList[0];
                    Li        = eLC.LoadEmptyConfigs(version);
                    eLC.Lists = Li;
                    listBox_items.Rows.Clear();


                    using (FileStream fs = File.OpenRead(sameFile))
                    {
                        using (BinaryReader br = new BinaryReader(fs))
                        {
                            int pos = Convert.ToInt32(textBox1.Text.ToUpper().Trim().Normalize(), 16);
                            br.BaseStream.Seek(pos, SeekOrigin.Begin);
                            for (int l = list_id; l < list_id + 1; l++)
                            {
                                eLC.Lists[l].elementValues   = new SortedList <int, SortedList <int, object> >();
                                eLC.Lists[l].elementPosition = new SortedList <int, int>();

                                for (int e = 0; e < (tryparse3 && countx > 0 ? countx : 999999); e++)
                                {
                                    eLC.Lists[l].elementValues[e] = new SortedList <int, object>();
                                    Application.DoEvents();
                                    Progress_bar("Read :" + e + "/" + 99999, e, 99999);
                                    try
                                    {
                                        for (int f = 0; f < eLC.Lists[l].elementTypes.Length; f++)
                                        {
                                            eLC.Lists[l].elementValues[e][f] = eLC.ReadValue(br, eLC.Lists[l].elementTypes[f]);

                                            if (eLC.Lists[l].elementFields[f] == "Name")
                                            {
                                                int  id         = Int32.Parse(eLC.Lists[l].elementValues[e][0].ToString());
                                                bool isNegative = (id & (1 << 31)) != 0;
                                                if (isNegative)
                                                {
                                                    break;
                                                }
                                                listBox_items.Rows.Add(new object[] { id.ToString(), eLC.Lists[l].GetValue(e, f) });



                                                if (checkBox1.Checked)
                                                {
                                                    Application.DoEvents();
                                                    listBox_items.Rows[e].Selected = true;
                                                    listBox_items.CurrentCell      = listBox_items.Rows[e].Cells[0];
                                                }
                                            }
                                        }

                                        eLC.Lists[l].elementPosition[e] = (Int32)br.BaseStream.Position;
                                        textBox5.Text = eLC.Lists[l].elementPosition[e].ToString("X4").ToUpper();
                                    }
                                    catch
                                    {
                                        break;
                                    }

                                    if (BrakeReading)
                                    {
                                        break;
                                    }
                                }
                            }

                            BrakeReading = false;
                            Blocked      = false;
                        }
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }
            }
        }
Example #9
0
        private void convert_Click(object sender, EventArgs e)
        {
            short.TryParse(version_list.Text, out short dst_version);
            if (src_el.Version < dst_version)
            {
                MetroMessageBox.Show(this, "Мы крайне не рекомендуем использовать конвертирование в версию выше!", "Предупреждение");
            }
            if (src_el.Version == dst_version)
            {
                MetroMessageBox.Show(this, "Странно конвертировать в ту же версию!", "Предупреждение");
            }
            eListCollection dst_el = new eListCollection(this);

            eList[] conf = dst_el.loadConfiguration(files.Where(x => x.Contains(string.Format("v{0}.cfg", dst_version))).First());
            dst_el.Lists     = conf;
            dst_el.Version   = dst_version;
            dst_el.Signature = src_el.Signature;
            Progress.Visible = true;
            Progress.Maximum = dst_el.Lists.Length;
            for (int i = 0; i < dst_el.Lists.Length; ++i)
            {
                ++Progress.Value;
                if (i != dst_el.ConversationListIndex)
                {
                    var list = src_el.Lists.Where(x => x.listName == dst_el.Lists[i].listName).ToList();
                    if (list.Count > 0)
                    {
                        Dictionary <int, int> field_index = new Dictionary <int, int>();
                        for (int j = 0; j < dst_el.Lists[i].elementFields.Length; ++j)
                        {
                            int src = Array.IndexOf(list.First().elementFields, dst_el.Lists[i].elementFields[j]);
                            field_index.Add(j, src);
                        }
                        dst_el.Lists[i].elementValues = new object[list.First().elementValues.Length][];
                        dst_el.Lists[i].listOffset    = list.First().listOffset;
                        for (int j = 0; j < list.First().elementValues.Length; ++j)
                        {
                            Application.DoEvents();
                            object[] values = new object[dst_el.Lists[i].elementFields.Length];
                            for (int k = 0; k < dst_el.Lists[i].elementFields.Length; ++k)
                            {
                                if (field_index.ContainsKey(k) && field_index[k] != -1)
                                {
                                    values[k] = list.First().elementValues[j][field_index[k]];
                                }
                                else
                                {
                                    values[k] = GetEmptyValue(dst_el.Lists[i].elementTypes[k]);
                                }
                            }
                            dst_el.Lists[i].elementValues[j] = values;
                        }
                    }
                    else
                    {
                        dst_el.Lists[i].elementValues = new object[0][];
                        dst_el.Lists[i].listOffset    = BitConverter.GetBytes(0);
                    }
                }
                else
                {
                    dst_el.Lists[i] = src_el.Lists[i];
                }
            }
            Progress.Visible = false;
            Progress.Value   = 0;
            SaveFileDialog sfd = new SaveFileDialog();

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                dst_el.Save(sfd.FileName);
            }
        }