Skip to content

Commit a22e5ae

Browse files
Save Function almost completed
Switched out the array of table items for a list of SFO Table items Also ended up not using ascii and using utf8null which seems to work way better and is more acurate only thing that is currently an issue is that for some reason when you save the file APP_TYPE gets over written with bytes to TYPE (Looking at this now )
1 parent 4b1cfb2 commit a22e5ae

15 files changed

Lines changed: 176 additions & 91 deletions
4.5 KB
Binary file not shown.

PARAM.SFO Editor/PARAM.SFO Editor/Form1.cs

Lines changed: 61 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public enum Playstation
4848
ps3 = 0,
4949
psvita = 1,
5050
ps4 = 2,
51+
psp = 3,
5152
}
5253

5354
#region << Header >>
@@ -1110,11 +1111,12 @@ private void cbxAddon_SelectedIndexChanged(object sender, EventArgs e)
11101111
private void txtAddonData_Leave(object sender, EventArgs e)
11111112
{
11121113
//on leave save the info to the table
1113-
for (int i = 0; i < psfo.Tables.Length; i++)
1114+
for (int i = 0; i < psfo.Tables.Count; i++)
11141115
{
11151116
if(psfo.Tables[i].Name == cbxAddon.SelectedItem.ToString().Trim())
11161117
{
1117-
psfo.Tables[i].Value = txtAddonData.Text.Trim();
1118+
var tempitem = psfo.Tables[i];
1119+
tempitem.Value = txtAddonData.Text.Trim();
11181120
}
11191121
}
11201122
}
@@ -1463,11 +1465,12 @@ private void txtAddonData_TextChanged(object sender, EventArgs e)
14631465
#endregion << PS3 Resolution >>
14641466
}
14651467
//set all other data
1466-
for (int i = 0; i < psfo.Tables.Length; i++)
1468+
for (int i = 0; i < psfo.Tables.Count; i++)
14671469
{
14681470
if (psfo.Tables[i].Name == cbxAddon.SelectedText.ToString())
14691471
{
1470-
psfo.Tables[i].Value = txtAddonData.Text.Trim();
1472+
var tempitem = psfo.Tables[i];
1473+
tempitem.Value = txtAddonData.Text.Trim();
14711474
}
14721475
}
14731476
}
@@ -1484,7 +1487,7 @@ private void chb720_CheckedChanged(object sender, EventArgs e)
14841487
//first get the value from param table
14851488
int iValue = 0, psfoValue = 0;
14861489

1487-
for (int i = 0; i < psfo.Tables.Length; i++)
1490+
for (int i = 0; i < psfo.Tables.Count; i++)
14881491
{
14891492
if (psfo.Tables[i].Name == "RESOLUTION")
14901493
{
@@ -1496,7 +1499,9 @@ private void chb720_CheckedChanged(object sender, EventArgs e)
14961499
//now we add or subtract
14971500
if (chb720.Checked == true)
14981501
{
1499-
psfo.Tables[iValue].Value = (psfoValue + 4).ToString();
1502+
1503+
var tempitem = psfo.Tables[iValue];
1504+
tempitem.Value = (psfoValue + 4).ToString();
15001505
if (cbxAddon.SelectedItem.ToString() == "RESOLUTION")
15011506
{
15021507
txtAddonData.Text = psfo.Tables[iValue].Value.ToString();
@@ -1505,7 +1510,8 @@ private void chb720_CheckedChanged(object sender, EventArgs e)
15051510
}
15061511
else
15071512
{
1508-
psfo.Tables[iValue].Value = (psfoValue - 4).ToString();
1513+
var tempitem = psfo.Tables[iValue];
1514+
tempitem.Value = (psfoValue - 4).ToString();
15091515
if (cbxAddon.SelectedItem.ToString() == "RESOLUTION")
15101516
{
15111517
txtAddonData.Text = psfo.Tables[iValue].Value.ToString();
@@ -1526,7 +1532,7 @@ private void chbx576Wide_CheckedChanged(object sender, EventArgs e)
15261532
//first get the value from param table
15271533
int iValue = 0, psfoValue = 0;
15281534

1529-
for (int i = 0; i < psfo.Tables.Length; i++)
1535+
for (int i = 0; i < psfo.Tables.Count; i++)
15301536
{
15311537
if (psfo.Tables[i].Name == "RESOLUTION")
15321538
{
@@ -1538,7 +1544,8 @@ private void chbx576Wide_CheckedChanged(object sender, EventArgs e)
15381544
//now we add or subtract
15391545
if (chbx576Wide.Checked == true)
15401546
{
1541-
psfo.Tables[iValue].Value = (psfoValue + 32).ToString();
1547+
var tempitem = psfo.Tables[iValue];
1548+
tempitem.Value = (psfoValue + 32).ToString();
15421549
if (cbxAddon.SelectedItem.ToString() == "RESOLUTION")
15431550
{
15441551
txtAddonData.Text = psfo.Tables[iValue].Value.ToString();
@@ -1547,7 +1554,8 @@ private void chbx576Wide_CheckedChanged(object sender, EventArgs e)
15471554
}
15481555
else
15491556
{
1550-
psfo.Tables[iValue].Value = (psfoValue - 32).ToString();
1557+
var tempitem = psfo.Tables[iValue];
1558+
tempitem.Value = (psfoValue - 32).ToString();
15511559
if (cbxAddon.SelectedItem.ToString() == "RESOLUTION")
15521560
{
15531561
txtAddonData.Text = psfo.Tables[iValue].Value.ToString();
@@ -1568,7 +1576,7 @@ private void chbx576_CheckedChanged(object sender, EventArgs e)
15681576
//first get the value from param table
15691577
int iValue = 0, psfoValue = 0;
15701578

1571-
for (int i = 0; i < psfo.Tables.Length; i++)
1579+
for (int i = 0; i < psfo.Tables.Count; i++)
15721580
{
15731581
if (psfo.Tables[i].Name == "RESOLUTION")
15741582
{
@@ -1580,7 +1588,8 @@ private void chbx576_CheckedChanged(object sender, EventArgs e)
15801588
//now we add or subtract
15811589
if (chbx576.Checked == true)
15821590
{
1583-
psfo.Tables[iValue].Value = (psfoValue + 2).ToString();
1591+
var tempitem = psfo.Tables[iValue];
1592+
tempitem.Value = (psfoValue + 2).ToString();
15841593
if (cbxAddon.SelectedItem.ToString() == "RESOLUTION")
15851594
{
15861595
txtAddonData.Text = psfo.Tables[iValue].Value.ToString();
@@ -1589,7 +1598,8 @@ private void chbx576_CheckedChanged(object sender, EventArgs e)
15891598
}
15901599
else
15911600
{
1592-
psfo.Tables[iValue].Value = (psfoValue - 2).ToString();
1601+
var tempitem = psfo.Tables[iValue];
1602+
tempitem.Value = (psfoValue - 2).ToString();
15931603
if (cbxAddon.SelectedItem.ToString() == "RESOLUTION")
15941604
{
15951605
txtAddonData.Text = psfo.Tables[iValue].Value.ToString();
@@ -1610,7 +1620,7 @@ private void chbx480Wide_CheckedChanged(object sender, EventArgs e)
16101620
//first get the value from param table
16111621
int iValue = 0, psfoValue = 0;
16121622

1613-
for (int i = 0; i < psfo.Tables.Length; i++)
1623+
for (int i = 0; i < psfo.Tables.Count; i++)
16141624
{
16151625
if (psfo.Tables[i].Name == "RESOLUTION")
16161626
{
@@ -1622,7 +1632,8 @@ private void chbx480Wide_CheckedChanged(object sender, EventArgs e)
16221632
//now we add or subtract
16231633
if (chbx480Wide.Checked == true)
16241634
{
1625-
psfo.Tables[iValue].Value = (psfoValue + 16).ToString();
1635+
var tempitem = psfo.Tables[iValue];
1636+
tempitem.Value = (psfoValue + 16).ToString();
16261637
if (cbxAddon.SelectedItem.ToString() == "RESOLUTION")
16271638
{
16281639
txtAddonData.Text = psfo.Tables[iValue].Value.ToString();
@@ -1631,7 +1642,8 @@ private void chbx480Wide_CheckedChanged(object sender, EventArgs e)
16311642
}
16321643
else
16331644
{
1634-
psfo.Tables[iValue].Value = (psfoValue - 16).ToString();
1645+
var tempitem = psfo.Tables[iValue];
1646+
tempitem.Value = (psfoValue - 16).ToString();
16351647
if (cbxAddon.SelectedItem.ToString() == "RESOLUTION")
16361648
{
16371649
txtAddonData.Text = psfo.Tables[iValue].Value.ToString();
@@ -1652,7 +1664,7 @@ private void chbx480_CheckedChanged(object sender, EventArgs e)
16521664
//first get the value from param table
16531665
int iValue = 0, psfoValue = 0;
16541666

1655-
for (int i = 0; i < psfo.Tables.Length; i++)
1667+
for (int i = 0; i < psfo.Tables.Count; i++)
16561668
{
16571669
if (psfo.Tables[i].Name == "RESOLUTION")
16581670
{
@@ -1664,7 +1676,8 @@ private void chbx480_CheckedChanged(object sender, EventArgs e)
16641676
//now we add or subtract
16651677
if (chbx480.Checked == true)
16661678
{
1667-
psfo.Tables[iValue].Value = (psfoValue + 1).ToString();
1679+
var tempitem = psfo.Tables[iValue];
1680+
tempitem.Value = (psfoValue + 1).ToString();
16681681
if (cbxAddon.SelectedItem.ToString() == "RESOLUTION")
16691682
{
16701683
txtAddonData.Text = psfo.Tables[iValue].Value.ToString();
@@ -1673,7 +1686,8 @@ private void chbx480_CheckedChanged(object sender, EventArgs e)
16731686
}
16741687
else
16751688
{
1676-
psfo.Tables[iValue].Value = (psfoValue - 1).ToString();
1689+
var tempitem = psfo.Tables[iValue];
1690+
tempitem.Value = (psfoValue - 1).ToString();
16771691
if (cbxAddon.SelectedItem.ToString() == "RESOLUTION")
16781692
{
16791693
txtAddonData.Text = psfo.Tables[iValue].Value.ToString();
@@ -1694,7 +1708,7 @@ private void chbx1080_CheckedChanged(object sender, EventArgs e)
16941708
//first get the value from param table
16951709
int iValue = 0, psfoValue = 0;
16961710

1697-
for (int i = 0; i < psfo.Tables.Length; i++)
1711+
for (int i = 0; i < psfo.Tables.Count; i++)
16981712
{
16991713
if (psfo.Tables[i].Name == "RESOLUTION")
17001714
{
@@ -1706,7 +1720,8 @@ private void chbx1080_CheckedChanged(object sender, EventArgs e)
17061720
//now we add or subtract
17071721
if (chbx1080.Checked == true)
17081722
{
1709-
psfo.Tables[iValue].Value = (psfoValue + 8).ToString();
1723+
var tempitem = psfo.Tables[iValue];
1724+
tempitem.Value = (psfoValue + 8).ToString();
17101725
if(cbxAddon.SelectedItem.ToString() == "RESOLUTION")
17111726
{
17121727
txtAddonData.Text = psfo.Tables[iValue].Value.ToString();
@@ -1715,7 +1730,8 @@ private void chbx1080_CheckedChanged(object sender, EventArgs e)
17151730
}
17161731
else
17171732
{
1718-
psfo.Tables[iValue].Value = (psfoValue - 8).ToString();
1733+
var tempitem = psfo.Tables[iValue];
1734+
tempitem.Value = (psfoValue - 8).ToString();
17191735
if (cbxAddon.SelectedItem.ToString() == "RESOLUTION")
17201736
{
17211737
txtAddonData.Text = psfo.Tables[iValue].Value.ToString();
@@ -1738,8 +1754,8 @@ private void button2_Click(object sender, EventArgs e)
17381754
if(dlg.ShowDialog() == DialogResult.OK)
17391755
{
17401756
//user wants to save in a new location or whatever
1741-
//psfo.SaveFile(psfo,dlg.FileName); //this will be added back as soon as this code is working this is for the initial release of the tool for PS4 sfo saving
1742-
CreateSFX(psfo, dlg);
1757+
psfo.SaveSFO(psfo, dlg.FileName); //this will be added back as soon as this code is working this is for the initial release of the tool for PS4 sfo saving
1758+
//CreateSFX(psfo, dlg);/*Old Method using CMD*/
17431759
}
17441760
}
17451761

@@ -1820,77 +1836,84 @@ public string CreateSFXHeader()
18201836

18211837
private void txtTitleId_TextChanged(object sender, EventArgs e)
18221838
{
1823-
for (int i = 0; i < psfo.Tables.Length; i++)
1839+
for (int i = 0; i < psfo.Tables.Count; i++)
18241840
{
18251841
if(psfo.Tables[i].Name == "TITLE_ID")
18261842
{
1827-
psfo.Tables[i].Value = txtTitleId.Text.Trim();
1843+
var tempitem = psfo.Tables[i];
1844+
tempitem.Value = txtTitleId.Text.Trim();
18281845
}
18291846
}
18301847
}
18311848

18321849
private void txtTitle_TextChanged(object sender, EventArgs e)
18331850
{
1834-
for (int i = 0; i < psfo.Tables.Length; i++)
1851+
for (int i = 0; i < psfo.Tables.Count; i++)
18351852
{
18361853
if (psfo.Tables[i].Name == "TITLE")
18371854
{
1838-
psfo.Tables[i].Value = txtTitle.Text.Trim();
1855+
var tempitem = psfo.Tables[i];
1856+
tempitem.Value = txtTitle.Text.Trim();
18391857
}
18401858
}
18411859
}
18421860

18431861
private void cbSystemVersion_TextChanged(object sender, EventArgs e)
18441862
{
1845-
for (int i = 0; i < psfo.Tables.Length; i++)
1863+
for (int i = 0; i < psfo.Tables.Count; i++)
18461864
{
18471865
if (psfo.Tables[i].Name == "SYSTEM_VER" || psfo.Tables[i].Name == "PS3_SYSTEM_VER")
18481866
{
1849-
psfo.Tables[i].Value = cbSystemVersion.Text.Trim();
1867+
var tempitem = psfo.Tables[i];
1868+
tempitem.Value = cbSystemVersion.Text.Trim();
18501869
}
18511870
}
18521871
}
18531872

18541873
private void cbxParent_TextChanged(object sender, EventArgs e)
18551874
{
1856-
for (int i = 0; i < psfo.Tables.Length; i++)
1875+
for (int i = 0; i < psfo.Tables.Count; i++)
18571876
{
18581877
if (psfo.Tables[i].Name == cbxParent.Tag.ToString())
18591878
{
1860-
psfo.Tables[i].Value = cbxParent.Text.Trim();
1879+
var tempitem = psfo.Tables[i];
1880+
tempitem.Value = cbxParent.Text.Trim();
18611881
}
18621882
}
18631883
}
18641884

18651885
private void cbxParent_SelectedIndexChanged(object sender, EventArgs e)
18661886
{
1867-
for (int i = 0; i < psfo.Tables.Length; i++)
1887+
for (int i = 0; i < psfo.Tables.Count; i++)
18681888
{
18691889
if (psfo.Tables[i].Name == cbxParent.Tag.ToString())
18701890
{
1871-
psfo.Tables[i].Value = cbxParent.Text.Trim();
1891+
var tempitem = psfo.Tables[i];
1892+
tempitem.Value = cbxParent.Text.Trim();
18721893
}
18731894
}
18741895
}
18751896

18761897
private void cbVersion_SelectedIndexChanged(object sender, EventArgs e)
18771898
{
1878-
for (int i = 0; i < psfo.Tables.Length; i++)
1899+
for (int i = 0; i < psfo.Tables.Count; i++)
18791900
{
18801901
if (psfo.Tables[i].Name == cbVersion.Tag.ToString())
18811902
{
1882-
psfo.Tables[i].Value = cbVersion.Text.Trim();
1903+
var tempitem = psfo.Tables[i];
1904+
tempitem.Value = cbVersion.Text.Trim();
18831905
}
18841906
}
18851907
}
18861908

18871909
private void cbxAppVersion_SelectedIndexChanged(object sender, EventArgs e)
18881910
{
1889-
for (int i = 0; i < psfo.Tables.Length; i++)
1911+
for (int i = 0; i < psfo.Tables.Count; i++)
18901912
{
18911913
if (psfo.Tables[i].Name == cbxAppVersion.Tag.ToString())
18921914
{
1893-
psfo.Tables[i].Value = cbxAppVersion.Text.Trim();
1915+
var tempitem = psfo.Tables[i];
1916+
tempitem.Value = cbxAppVersion.Text.Trim();
18941917
}
18951918
}
18961919
}

0 commit comments

Comments
 (0)