예제 #1
0
        private void refreshToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ParamFile selectedParam = (ParamFile)dgvRows.DataSource;

            PARAM64.Row selectedRow = (PARAM64.Row)dgvCells.DataSource;

            LoadRegulation(regulationPath);

            dgvParams.ClearSelection();
            foreach (DataGridViewRow row in dgvParams.Rows)
            {
                if (((ParamFile)row.DataBoundItem).Name == selectedParam.Name)
                {
                    row.Cells[0].Selected = true;
                }
            }

            dgvRows.ClearSelection();
            foreach (DataGridViewRow row in dgvRows.Rows)
            {
                if (((PARAM64.Row)row.DataBoundItem).ID == selectedRow.ID)
                {
                    row.Cells[0].Selected = true;
                }
            }
        }
예제 #2
0
 private void dgvRows_SelectionChanged(object sender, EventArgs e)
 {
     if (dgvRows.SelectedCells.Count > 0)
     {
         PARAM64.Row row = (PARAM64.Row)dgvRows.SelectedCells[0].OwningRow.DataBoundItem;
         dgvCells.DataSource = row;
         dgvCells.DataMember = "Cells";
     }
 }
예제 #3
0
    /// <summary>
    /// Initialize from DS3 item lot param
    /// </summary>
    /// <param name="lot"></param>
    public ItemLotParam(PARAM64.Row lot)
    {
        for (int i = 0; i < 8; i++)
        {
            ItemID[i] = (int)lot[$@"ItemLotId{i + 1}"].Value;
        }

        for (int i = 0; i < 8; i++)
        {
            ItemCategory[i] = (uint)lot[$@"LotItemCategory0{i + 1}"].Value;
        }

        for (int i = 0; i < 8; i++)
        {
            ItemBasePoint[i] = (short)lot[$@"LotItemBasePoint0{i + 1}"].Value;
        }

        for (int i = 0; i < 8; i++)
        {
            ItemCumulatePoint[i] = (short)lot[$@"cumulateLotPoint0{i + 1}"].Value;
        }

        for (int i = 0; i < 8; i++)
        {
            GetItemFlagID[i] = (int)lot[$@"GetItemFlagId0{i + 1}"].Value;
        }

        GetItemFlagIDG    = (int)lot["getItemFlagId"].Value;
        CumulateNumFlagID = (int)lot["cumulateNumFlagId"].Value;
        CumulateMaxNum    = (byte)lot["cumulateNumMax"].Value;
        ItemRarity        = (byte)lot["LotItemRarity"].Value;

        for (int i = 0; i < 8; i++)
        {
            ItemNum[i] = (byte)lot[$@"LotItemNum{i + 1}"].Value;
        }

        for (int i = 0; i < 8; i++)
        {
            EnableLuck[i] = (bool)lot[$@"EnableLuck0{i + 1}"].Value;
        }

        for (int i = 0; i < 8; i++)
        {
            CumulateReset[i] = (bool)lot[$@"cumulateReset0{i + 1}"].Value;
        }

        ClearCount = (sbyte)lot["ClearCount"].Value;
    }
예제 #4
0
        private void RandomizeSomeTogether(IEnumerable <PARAM64.Row> rows, string[] paramNames)
        {
            List <PARAM64.Row> options = rows.ToList();

            foreach (PARAM64.Row row in rows)
            {
                PARAM64.Row sampleRow = options.PopRandom(rand);
                foreach (PARAM64.Cell cell in sampleRow.Cells)
                {
                    Console.Out.WriteLine(cell.Name);
                }
                foreach (string param in paramNames)
                {
                    Console.Out.WriteLine(row[param]);
                    row[param].Value = sampleRow[param].Value;
                }
            }
        }
예제 #5
0
        private void btnDump_Click(object sender, EventArgs e)
        {
            BND4 bnd;

            try
            {
                bnd = SFUtil.DecryptDS3Regulation(txtRegulation.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Failed to load regulation:\r\n\r\n{txtRegulation.Text}\r\n\r\n{ex}");
                return;
            }

            var translations = new Dictionary <string, string>();
            var xml          = new XmlDocument();

            xml.Load("translations.xml");

            foreach (XmlNode text in xml.SelectNodes("translations/text"))
            {
                string jp = text.SelectSingleNode("jp").InnerText;
                string en = text.SelectSingleNode("en").InnerText;
                translations[WebUtility.HtmlDecode(jp)] = WebUtility.HtmlDecode(en);
            }

            var package = new ExcelPackage();

            foreach (BinderFile file in bnd.Files)
            {
                if (Path.GetExtension(file.Name) == ".param")
                {
                    PARAM64 param      = PARAM64.Read(file.Bytes);
                    string  layoutPath = $"Layouts\\{param.ID}.xml";

                    txtStatus.AppendText(file.Name + "\r\n");

                    var worksheet = package.Workbook.Worksheets.Add(Path.GetFileNameWithoutExtension(file.Name));

                    PARAM64.Layout layout;
                    if (File.Exists(layoutPath))
                    {
                        layout = PARAM64.Layout.ReadXMLFile(layoutPath);
                        if (layout.Size != param.DetectedSize)
                        {
                            layout = new PARAM64.Layout();
                            for (int i = 0; i < param.DetectedSize / 4; i++)
                            {
                                layout.Add(new PARAM64.Layout.Entry(CellType.u32, $"unk0x{i * 4:X4}", (uint)0));
                            }
                            for (int i = 0; i < param.DetectedSize % 4; i++)
                            {
                                layout.Add(new PARAM64.Layout.Entry(CellType.u8, "unkb" + i, (byte)0));
                            }
                        }
                    }
                    else
                    {
                        layout = new PARAM64.Layout();
                    }

                    param.SetLayout(layout);
                    List <PARAM64.Row> rows = param.Rows;

                    worksheet.Cells[1, 1].Value = "ID";
                    worksheet.Cells[1, 2].Value = "Name";
                    worksheet.Cells[1, 3].Value = "Translated";
                    int columnCount = 3;
                    foreach (PARAM64.Layout.Entry lv in layout)
                    {
                        if (lv.Type != CellType.dummy8)
                        {
                            worksheet.Cells[1, ++columnCount].Value = lv.Name;
                        }
                    }

                    for (int i = 0; i < rows.Count; i++)
                    {
                        PARAM64.Row row = rows[i];
                        worksheet.Cells[i + 2, 1].Value = row.ID;
                        if (row.Name != null)
                        {
                            if (translations.ContainsKey(row.Name))
                            {
                                worksheet.Cells[i + 2, 2].Value = row.Name;
                                worksheet.Cells[i + 2, 3].Value = translations[row.Name];
                            }
                            else if (row.Name.Contains(" -- "))
                            {
                                worksheet.Cells[i + 2, 2].Value = row.Name.Substring(row.Name.IndexOf(" -- ") + 4);
                                worksheet.Cells[i + 2, 3].Value = row.Name.Substring(0, row.Name.IndexOf(" -- "));
                            }
                        }
                        else
                        {
                            worksheet.Cells[i + 2, 2].Value = row.Name;
                        }
                        columnCount = 3;

                        foreach (PARAM64.Cell cell in row.Cells)
                        {
                            CellType type = cell.Type;
                            if (type != CellType.dummy8)
                            {
                                var range = worksheet.Cells[i + 2, ++columnCount];
                                if (type == CellType.f32)
                                {
                                    range.Value = (double)(float)cell.Value;
                                }
                                else if (type == CellType.b8 || type == CellType.b32)
                                {
                                    bool b = (bool)cell.Value;
                                    range.Value = b.ToString();
                                    range.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
                                    range.Style.Fill.BackgroundColor.SetColor(b ? Color.LightGreen : Color.LightPink);
                                }
                                else if (type == CellType.x8)
                                {
                                    range.Value = $"0x{cell.Value:X2}";
                                    range.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Right;
                                }
                                else if (type == CellType.x16)
                                {
                                    range.Value = $"0x{cell.Value:X4}";
                                    range.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Right;
                                }
                                else if (type == CellType.x32)
                                {
                                    range.Value = $"0x{cell.Value:X8}";
                                    range.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Right;
                                }
                                else
                                {
                                    range.Value = cell.Value;
                                }
                            }
                        }
                    }

                    worksheet.Row(1).Style.Font.Bold    = true;
                    worksheet.Column(1).Style.Font.Bold = true;
                    worksheet.View.FreezePanes(2, 4);
                    worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
                }
            }

            FileInfo f = new FileInfo(Path.Combine(txtOutput.Text, "dump.xlsx"));

            package.SaveAs(f);
        }