Skip to content

Commit

Permalink
Box Layout fixes (#2449)
Browse files Browse the repository at this point in the history
* Enforce box name length in Box Layout

* Fix G4 box renaming

* Fix G7 box renaming
  • Loading branch information
Ammako authored and kwsch committed Nov 19, 2019
1 parent 3aa3a29 commit acf5df0
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion PKHeX.Core/Saves/SAV4HGSS.cs
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion PKHeX.Core/Saves/SAV4Sinnoh.cs
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion PKHeX.Core/Saves/Substructures/Gen7/BoxLayout7.cs
Expand Up @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_BoxLayout.cs
Expand Up @@ -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;
}

Expand Down

0 comments on commit acf5df0

Please sign in to comment.