Box Layout fixes (#2449)

* Enforce box name length in Box Layout

* Fix G4 box renaming

* Fix G7 box renaming
This commit is contained in:
Ammako
2019-11-18 19:01:36 -05:00
committed by Kurt
parent 3aa3a29264
commit acf5df07be
4 changed files with 4 additions and 3 deletions

View File

@@ -80,7 +80,7 @@ public int Counter
public override void SetBoxName(int box, string value)
{
const int maxlen = BOX_NAME_LEN / 2;
const int maxlen = 8;
if (value.Length > maxlen)
value = value.Substring(0, maxlen); // Hard cap
int offset = GetBoxNameOffset(box);

View File

@@ -47,7 +47,7 @@ public int Unknown
public override void SetBoxName(int box, string value)
{
const int maxlen = BOX_NAME_LEN / 2;
const int maxlen = 8;
if (value.Length > maxlen)
value = value.Substring(0, maxlen); // Hard cap
int offset = GetBoxNameOffset(box);

View File

@@ -47,7 +47,7 @@ public string GetBoxName(int box)
public void SetBoxName(int box, string value)
{
var data = SAV.SetString(value, strlen, strlen, 0);
var offset = GetBoxNameOffset(box) + (SAV6.LongStringLength * box);
var offset = GetBoxNameOffset(box - 1) + (SAV6.LongStringLength);
SAV.SetData(data, offset);
}

View File

@@ -28,6 +28,7 @@ public SAV_BoxLayout(SaveFile sav, int box)
LoadUnlockedCount();
LB_BoxSelect.SelectedIndex = box;
TB_BoxName.MaxLength = SAV.Generation >= 6 ? 14 : 8;
editing = false;
}