diff --git a/PKHeX.WinForms/Subforms/PKM Editors/Text.Designer.cs b/PKHeX.WinForms/Subforms/PKM Editors/Text.Designer.cs
index 8d4cdfaaa..541366cf6 100644
--- a/PKHeX.WinForms/Subforms/PKM Editors/Text.Designer.cs
+++ b/PKHeX.WinForms/Subforms/PKM Editors/Text.Designer.cs
@@ -38,18 +38,19 @@ private void InitializeComponent()
this.CB_Language = new System.Windows.Forms.ComboBox();
this.B_ApplyTrash = new System.Windows.Forms.Button();
this.GB_Trash = new System.Windows.Forms.GroupBox();
+ this.B_ClearTrash = new System.Windows.Forms.Button();
+ this.L_Generation = new System.Windows.Forms.Label();
+ this.NUD_Generation = new System.Windows.Forms.NumericUpDown();
this.L_Language = new System.Windows.Forms.Label();
this.L_Species = new System.Windows.Forms.Label();
- this.NUD_Generation = new System.Windows.Forms.NumericUpDown();
- this.L_Generation = new System.Windows.Forms.Label();
- this.B_ClearTrash = new System.Windows.Forms.Button();
+ this.label1 = new System.Windows.Forms.Label();
this.GB_Trash.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_Generation)).BeginInit();
this.SuspendLayout();
//
// TB_Text
//
- this.TB_Text.Location = new System.Drawing.Point(76, 12);
+ this.TB_Text.Location = new System.Drawing.Point(92, 12);
this.TB_Text.Name = "TB_Text";
this.TB_Text.Size = new System.Drawing.Size(136, 20);
this.TB_Text.TabIndex = 35;
@@ -90,6 +91,7 @@ private void InitializeComponent()
this.FLP_Characters.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
+ this.FLP_Characters.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.FLP_Characters.Location = new System.Drawing.Point(12, 126);
this.FLP_Characters.Name = "FLP_Characters";
this.FLP_Characters.Size = new System.Drawing.Size(305, 82);
@@ -100,6 +102,7 @@ private void InitializeComponent()
this.FLP_Hex.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.FLP_Hex.AutoScroll = true;
+ this.FLP_Hex.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.FLP_Hex.Location = new System.Drawing.Point(12, 38);
this.FLP_Hex.Name = "FLP_Hex";
this.FLP_Hex.Size = new System.Drawing.Size(305, 82);
@@ -148,6 +151,36 @@ private void InitializeComponent()
this.GB_Trash.Text = "Trash Byte Layers";
this.GB_Trash.Visible = false;
//
+ // B_ClearTrash
+ //
+ this.B_ClearTrash.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.B_ClearTrash.Location = new System.Drawing.Point(6, 100);
+ this.B_ClearTrash.Name = "B_ClearTrash";
+ this.B_ClearTrash.Size = new System.Drawing.Size(156, 23);
+ this.B_ClearTrash.TabIndex = 47;
+ this.B_ClearTrash.Text = "Clear Trash";
+ this.B_ClearTrash.UseVisualStyleBackColor = true;
+ this.B_ClearTrash.Click += new System.EventHandler(this.B_ClearTrash_Click);
+ //
+ // L_Generation
+ //
+ this.L_Generation.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.L_Generation.Location = new System.Drawing.Point(6, 67);
+ this.L_Generation.Name = "L_Generation";
+ this.L_Generation.Size = new System.Drawing.Size(103, 23);
+ this.L_Generation.TabIndex = 46;
+ this.L_Generation.Text = "Generation";
+ this.L_Generation.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
+ // NUD_Generation
+ //
+ this.NUD_Generation.Location = new System.Drawing.Point(115, 70);
+ this.NUD_Generation.Name = "NUD_Generation";
+ this.NUD_Generation.Size = new System.Drawing.Size(47, 20);
+ this.NUD_Generation.TabIndex = 45;
+ //
// L_Language
//
this.L_Language.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
@@ -170,41 +203,23 @@ private void InitializeComponent()
this.L_Species.Text = "Species";
this.L_Species.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
- // NUD_Generation
+ // label1
//
- this.NUD_Generation.Location = new System.Drawing.Point(115, 70);
- this.NUD_Generation.Name = "NUD_Generation";
- this.NUD_Generation.Size = new System.Drawing.Size(47, 20);
- this.NUD_Generation.TabIndex = 45;
- //
- // L_Generation
- //
- this.L_Generation.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
- this.L_Generation.Location = new System.Drawing.Point(6, 67);
- this.L_Generation.Name = "L_Generation";
- this.L_Generation.Size = new System.Drawing.Size(103, 23);
- this.L_Generation.TabIndex = 46;
- this.L_Generation.Text = "Generation";
- this.L_Generation.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
- //
- // B_ClearTrash
- //
- this.B_ClearTrash.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.B_ClearTrash.Location = new System.Drawing.Point(6, 100);
- this.B_ClearTrash.Name = "B_ClearTrash";
- this.B_ClearTrash.Size = new System.Drawing.Size(156, 23);
- this.B_ClearTrash.TabIndex = 47;
- this.B_ClearTrash.Text = "Clear Trash";
- this.B_ClearTrash.UseVisualStyleBackColor = true;
- this.B_ClearTrash.Click += new System.EventHandler(this.B_ClearTrash_Click);
+ this.label1.Location = new System.Drawing.Point(9, 9);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(77, 23);
+ this.label1.TabIndex = 44;
+ this.label1.Text = "String";
+ this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// f2_Text
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(503, 219);
+ this.Controls.Add(this.label1);
this.Controls.Add(this.GB_Trash);
this.Controls.Add(this.FLP_Hex);
this.Controls.Add(this.FLP_Characters);
@@ -240,5 +255,6 @@ private void InitializeComponent()
private System.Windows.Forms.NumericUpDown NUD_Generation;
private System.Windows.Forms.Label L_Generation;
private System.Windows.Forms.Button B_ClearTrash;
+ private System.Windows.Forms.Label label1;
}
}
\ No newline at end of file
diff --git a/PKHeX.WinForms/Subforms/PKM Editors/Text.cs b/PKHeX.WinForms/Subforms/PKM Editors/Text.cs
index 8ae05c94c..21ff5caf7 100644
--- a/PKHeX.WinForms/Subforms/PKM Editors/Text.cs
+++ b/PKHeX.WinForms/Subforms/PKM Editors/Text.cs
@@ -26,6 +26,17 @@ public f2_Text(TextBoxBase TB_NN, byte[] raw)
TB_Text.Text = TB_NN.Text;
TB_Text.Font = pkxFont;
+ if (FLP_Characters.Controls.Count == 0)
+ {
+ FLP_Characters.Visible = false;
+ FLP_Hex.Height *= 2;
+ }
+ else if (FLP_Hex.Controls.Count == 0)
+ {
+ FLP_Characters.Location = FLP_Hex.Location;
+ FLP_Characters.Height *= 2;
+ }
+
editing = false;
CenterToParent();
}
@@ -80,7 +91,7 @@ private void addTrashEditing(int length)
{
switch (ModifierKeys)
{
- case Keys.Control: n.Value = n.Maximum; break;
+ case Keys.Shift: n.Value = n.Maximum; break;
case Keys.Alt: n.Value = n.Minimum; break;
}
};
diff --git a/PKHeX/MysteryGifts/PGT.cs b/PKHeX/MysteryGifts/PGT.cs
index bb199fe28..aceca34a0 100644
--- a/PKHeX/MysteryGifts/PGT.cs
+++ b/PKHeX/MysteryGifts/PGT.cs
@@ -60,10 +60,10 @@ public override int CardID
}
public override string CardTitle
{
- get { return PKX.array2strG4(Data, 0x104, 0x48); }
+ get { return PKX.getString4(Data, 0x104, 0x48); }
set
{
- byte[] data = PKX.str2arrayG4(value);
+ byte[] data = PKX.setString4(value, 0x48/2-1, 0x48/2, 0xFFFF);
int len = data.Length;
Array.Resize(ref data, 0x48);
for (int i = 0; i < len; i++)
diff --git a/PKHeX/PKM/PK4.cs b/PKHeX/PKM/PK4.cs
index 5ab3160b7..79fe0a4da 100644
--- a/PKHeX/PKM/PK4.cs
+++ b/PKHeX/PKM/PK4.cs
@@ -29,7 +29,8 @@ public PK4(byte[] decryptedData = null, string ident = null)
// Trash Bytes
public override byte[] Nickname_Trash { get { return getData(0x48, 22); } set { if (value?.Length == 22) value.CopyTo(Data, 0x48); } }
- public override byte[] OT_Trash { get { return getData(0x68, 16); } set { if (value?.Length == 16) value.CopyTo(Data, 0x68); } }
+ public override byte[] OT_Trash { get { return getData(0x68, 16); }
+ set { if (value?.Length == 16) value.CopyTo(Data, 0x68); } }
// Future Attributes
public override uint EncryptionConstant { get { return PID; } set { } }
diff --git a/PKHeX/PKM/PKX.cs b/PKHeX/PKM/PKX.cs
index ad64ca9e7..c8c4ac39e 100644
--- a/PKHeX/PKM/PKX.cs
+++ b/PKHeX/PKM/PKX.cs
@@ -1248,48 +1248,7 @@ public static ushort char2valG4(ushort chr)
int index = Array.IndexOf(G4Chars, chr);
return index > -1 ? G4Values[index] : (ushort)0xFFFF;
}
-
- ///
- /// Converts Generation 4 Little Endian encoded character data to string.
- ///
- /// Byte array containing encoded character data.
- /// Offset to read from
- /// Length of data to read.
- /// Converted string.
- public static string array2strG4(byte[] strdata, int offset, int count)
- {
- string s = "";
- for (int i = 0; i < count; i += 2)
- {
- ushort val = BitConverter.ToUInt16(strdata, offset + i);
- if (val == 0xFFFF) break;
- ushort chr = val2charG4(val);
- if (chr == 0xFFFF) break;
- s += (char)chr;
- }
- return s;
- }
-
- ///
- /// Converts a string to Generation 4 Little Endian encoded character data.
- ///
- /// String to be converted.
- /// Byte array containing encoded character data
- public static byte[] str2arrayG4(string str)
- {
- byte[] strdata = new byte[str.Length * 2 + 2]; // +2 for 0xFFFF
- for (int i = 0; i < str.Length; i++)
- {
- ushort chr = str[i];
- ushort val = char2valG4(chr);
- if (val == 0xFFFF || chr == 0xFFFF)
- { Array.Resize(ref strdata, i * 2); break; }
- BitConverter.GetBytes(val).CopyTo(strdata, i * 2);
- }
- BitConverter.GetBytes((ushort)0xFFFF).CopyTo(strdata, strdata.Length - 2);
- return strdata;
- }
-
+
///
/// Converts Generation 4 Big Endian encoded character data to string.
///
@@ -2744,8 +2703,16 @@ public static byte[] setBEString3(string value, int maxLength, int padTo = 0, us
/// Decoded string.
public static string getString4(byte[] data, int offset, int count)
{
- string value = array2strG4(data, offset, count);
- return SanitizeString(value)
+ StringBuilder s = new StringBuilder();
+ for (int i = 0; i < count; i += 2)
+ {
+ ushort val = BitConverter.ToUInt16(data, offset + i);
+ if (val == 0xFFFF) break;
+ ushort chr = val2charG4(val);
+ if (chr == 0xFFFF) break;
+ s.Append((char)chr);
+ }
+ return s.ToString()
.Replace("\uFF0D", "\u30FC") // Japanese chōonpu
;
}
@@ -2764,7 +2731,15 @@ public static byte[] setString4(string value, int maxLength, int padTo = 0, usho
.Replace("\u30FC", "\uFF0D") // Japanese chōonpu
.PadRight(value.Length + 1, (char)0xFFFF) // Null Terminator
.PadRight(padTo, (char)padWith); // Padding
- return str2arrayG4(temp);
+
+ byte[] strdata = new byte[temp.Length * 2];
+ for (int i = 0; i < temp.Length; i++)
+ {
+ ushort chr = temp[i];
+ ushort val = char2valG4(chr);
+ BitConverter.GetBytes(val).CopyTo(strdata, i * 2);
+ }
+ return strdata;
}
/// Converts Generation 5 encoded data to decoded string.
diff --git a/PKHeX/Saves/SAV3Colosseum.cs b/PKHeX/Saves/SAV3Colosseum.cs
index 73b8bf1a6..3a855d259 100644
--- a/PKHeX/Saves/SAV3Colosseum.cs
+++ b/PKHeX/Saves/SAV3Colosseum.cs
@@ -155,7 +155,7 @@ public override SaveFile Clone()
public override int MaxEV => 255;
public override int Generation => 3;
protected override int GiftCountMax => 1;
- public override int OTLength => 8;
+ public override int OTLength => 7;
public override int NickLength => 10;
public override int MaxMoney => 999999;
diff --git a/PKHeX/Saves/SAV3RSBox.cs b/PKHeX/Saves/SAV3RSBox.cs
index 167ce5850..d5bd2a289 100644
--- a/PKHeX/Saves/SAV3RSBox.cs
+++ b/PKHeX/Saves/SAV3RSBox.cs
@@ -105,7 +105,7 @@ public override SaveFile Clone()
public override int MaxEV => 255;
public override int Generation => 3;
protected override int GiftCountMax => 1;
- public override int OTLength => 8;
+ public override int OTLength => 7;
public override int NickLength => 10;
public override int MaxMoney => 999999;
public override bool HasBoxWallpapers => false;
diff --git a/PKHeX/Saves/SAV3XD.cs b/PKHeX/Saves/SAV3XD.cs
index 8f158642c..4679ed062 100644
--- a/PKHeX/Saves/SAV3XD.cs
+++ b/PKHeX/Saves/SAV3XD.cs
@@ -167,7 +167,7 @@ public override SaveFile Clone()
public override int MaxEV => 255;
public override int Generation => 3;
protected override int GiftCountMax => 1;
- public override int OTLength => 8;
+ public override int OTLength => 7;
public override int NickLength => 10;
public override int MaxMoney => 999999;
diff --git a/PKHeX/Saves/SAV4.cs b/PKHeX/Saves/SAV4.cs
index 88853519a..57f46c9c3 100644
--- a/PKHeX/Saves/SAV4.cs
+++ b/PKHeX/Saves/SAV4.cs
@@ -52,7 +52,7 @@ public SAV4(byte[] data = null, GameVersion versionOverride = GameVersion.Any)
protected override int EventFlagMax => int.MinValue;
protected override int EventConstMax => int.MinValue;
protected override int GiftCountMax => 11;
- public override int OTLength => 8;
+ public override int OTLength => 7;
public override int NickLength => 10;
public override int MaxMoney => 999999;
@@ -519,7 +519,7 @@ public override string getBoxName(int box)
{
int offset = getBoxOffset(BoxCount);
if (Version == GameVersion.HGSS) offset += 0x8;
- return PKX.array2strG4(Data, offset + box*0x28, 0x28);
+ return getString(offset + box*0x28, 0x28);
}
public override void setBoxName(int box, string value)
{
@@ -527,7 +527,7 @@ public override void setBoxName(int box, string value)
value = value.Substring(0, 13); // Hard cap
int offset = getBoxOffset(BoxCount);
if (Version == GameVersion.HGSS) offset += 0x8;
- setData(PKX.str2arrayG4(value), offset + box*0x28);
+ setData(setString(value, 13), offset + box*0x28);
}
public override PKM getPKM(byte[] data)
{
diff --git a/PKHeX/Saves/SAV4BR.cs b/PKHeX/Saves/SAV4BR.cs
index fe3296c64..1df85a00a 100644
--- a/PKHeX/Saves/SAV4BR.cs
+++ b/PKHeX/Saves/SAV4BR.cs
@@ -86,7 +86,7 @@ public override byte[] Write(bool DSV)
public override int MaxEV => 255;
public override int Generation => 4;
protected override int GiftCountMax => 1;
- public override int OTLength => 8;
+ public override int OTLength => 7;
public override int NickLength => 10;
public override int MaxMoney => 999999;
diff --git a/PKHeX/Saves/SAV5.cs b/PKHeX/Saves/SAV5.cs
index 7cee59b37..90ad9ca64 100644
--- a/PKHeX/Saves/SAV5.cs
+++ b/PKHeX/Saves/SAV5.cs
@@ -103,7 +103,7 @@ public SAV5(byte[] data = null, GameVersion versionOverride = GameVersion.Any)
public override int BoxCount => 24;
public override int MaxEV => 255;
public override int Generation => 5;
- public override int OTLength => 8;
+ public override int OTLength => 7;
public override int NickLength => 10;
protected override int EventConstMax => 0x35E/2;
protected override int GiftCountMax => 12;