mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-24 04:53:08 +00:00
Fix gender symbol setting
if nidoran is not nicknamed, it will use full width if it's not named Nidoran. if anything else is nicknamed, it will check to see if any non-latin/special characters are used to determine if half width should be set. possibly applies to gen4/5, if so, please open an issue/post on forums.
This commit is contained in:
parent
1c335c9389
commit
2c395d3634
3 changed files with 52 additions and 66 deletions
|
@ -209,21 +209,12 @@ namespace PKHeX
|
|||
#region Block B
|
||||
public override string Nickname
|
||||
{
|
||||
get
|
||||
{
|
||||
return Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0x40, 24))
|
||||
.Replace("\uE08F", "\u2640") // nidoran
|
||||
.Replace("\uE08E", "\u2642") // nidoran
|
||||
.Replace("\u2019", "\u0027"); // farfetch'd
|
||||
}
|
||||
get { return PKX.SanitizeString(Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0x40, 24))); }
|
||||
set
|
||||
{
|
||||
if (value.Length > 12)
|
||||
value = value.Substring(0, 12); // Hard cap
|
||||
string TempNick = value // Replace Special Characters and add Terminator
|
||||
.Replace("\u2640", "\uE08F") // nidoran
|
||||
.Replace("\u2642", "\uE08E") // nidoran
|
||||
.Replace("\u0027", "\u2019") // farfetch'd
|
||||
string TempNick = PKX.UnSanitizeString(value)
|
||||
.PadRight(value.Length + 1, '\0'); // Null Terminator
|
||||
Encoding.Unicode.GetBytes(TempNick).CopyTo(Data, 0x40);
|
||||
}
|
||||
|
@ -292,21 +283,12 @@ namespace PKHeX
|
|||
#region Block C
|
||||
public override string HT_Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0x78, 24))
|
||||
.Replace("\uE08F", "\u2640") // nidoran
|
||||
.Replace("\uE08E", "\u2642") // nidoran
|
||||
.Replace("\u2019", "\u0027"); // farfetch'd
|
||||
}
|
||||
get { return PKX.SanitizeString(Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0x78, 24))); }
|
||||
set
|
||||
{
|
||||
if (value.Length > 12)
|
||||
value = value.Substring(0, 12); // Hard cap
|
||||
string TempNick = value // Replace Special Characters and add Terminator
|
||||
.Replace("\u2640", "\uE08F") // nidoran
|
||||
.Replace("\u2642", "\uE08E") // nidoran
|
||||
.Replace("\u0027", "\u2019") // farfetch'd
|
||||
string TempNick = PKX.UnSanitizeString(value)
|
||||
.PadRight(value.Length + 1, '\0'); // Null Terminator
|
||||
Encoding.Unicode.GetBytes(TempNick).CopyTo(Data, 0x78);
|
||||
}
|
||||
|
@ -344,21 +326,12 @@ namespace PKHeX
|
|||
#region Block D
|
||||
public override string OT_Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0xB0, 24))
|
||||
.Replace("\uE08F", "\u2640") // Nidoran ♂
|
||||
.Replace("\uE08E", "\u2642") // Nidoran ♀
|
||||
.Replace("\u2019", "\u0027"); // farfetch'd
|
||||
}
|
||||
get { return PKX.SanitizeString(Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0xB0, 24))); }
|
||||
set
|
||||
{
|
||||
if (value.Length > 12)
|
||||
value = value.Substring(0, 12); // Hard cap
|
||||
string TempNick = value // Replace Special Characters and add Terminator
|
||||
.Replace("\u2640", "\uE08F") // Nidoran ♂
|
||||
.Replace("\u2642", "\uE08E") // Nidoran ♀
|
||||
.Replace("\u0027", "\u2019") // Farfetch'd
|
||||
string TempNick = PKX.UnSanitizeString(value)
|
||||
.PadRight(value.Length + 1, '\0'); // Null Terminator
|
||||
Encoding.Unicode.GetBytes(TempNick).CopyTo(Data, 0xB0);
|
||||
}
|
||||
|
|
|
@ -217,21 +217,12 @@ namespace PKHeX
|
|||
#region Block B
|
||||
public override string Nickname
|
||||
{
|
||||
get
|
||||
{
|
||||
return Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0x40, 24))
|
||||
.Replace("\uE08F", "\u2640") // nidoran
|
||||
.Replace("\uE08E", "\u2642") // nidoran
|
||||
.Replace("\u2019", "\u0027"); // farfetch'd
|
||||
}
|
||||
get { return PKX.SanitizeString(Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0x40, 24))); }
|
||||
set
|
||||
{
|
||||
if (value.Length > 12)
|
||||
value = value.Substring(0, 12); // Hard cap
|
||||
string TempNick = value // Replace Special Characters and add Terminator
|
||||
.Replace("\u2640", "\uE08F") // nidoran
|
||||
.Replace("\u2642", "\uE08E") // nidoran
|
||||
.Replace("\u0027", "\u2019") // farfetch'd
|
||||
string TempNick = PKX.UnSanitizeString(value)
|
||||
.PadRight(value.Length + 1, '\0'); // Null Terminator
|
||||
Encoding.Unicode.GetBytes(TempNick).CopyTo(Data, 0x40);
|
||||
}
|
||||
|
@ -300,21 +291,12 @@ namespace PKHeX
|
|||
#region Block C
|
||||
public override string HT_Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0x78, 24))
|
||||
.Replace("\uE08F", "\u2640") // nidoran
|
||||
.Replace("\uE08E", "\u2642") // nidoran
|
||||
.Replace("\u2019", "\u0027"); // farfetch'd
|
||||
}
|
||||
get { return PKX.SanitizeString(Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0x78, 24))); }
|
||||
set
|
||||
{
|
||||
if (value.Length > 12)
|
||||
value = value.Substring(0, 12); // Hard cap
|
||||
string TempNick = value // Replace Special Characters and add Terminator
|
||||
.Replace("\u2640", "\uE08F") // nidoran
|
||||
.Replace("\u2642", "\uE08E") // nidoran
|
||||
.Replace("\u0027", "\u2019") // farfetch'd
|
||||
string TempNick = PKX.UnSanitizeString(value)
|
||||
.PadRight(value.Length + 1, '\0'); // Null Terminator
|
||||
Encoding.Unicode.GetBytes(TempNick).CopyTo(Data, 0x78);
|
||||
}
|
||||
|
@ -352,21 +334,12 @@ namespace PKHeX
|
|||
#region Block D
|
||||
public override string OT_Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0xB0, 24))
|
||||
.Replace("\uE08F", "\u2640") // Nidoran ♂
|
||||
.Replace("\uE08E", "\u2642") // Nidoran ♀
|
||||
.Replace("\u2019", "\u0027"); // farfetch'd
|
||||
}
|
||||
get { return PKX.SanitizeString(Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0xB0, 24))); }
|
||||
set
|
||||
{
|
||||
if (value.Length > 12)
|
||||
value = value.Substring(0, 12); // Hard cap
|
||||
string TempNick = value // Replace Special Characters and add Terminator
|
||||
.Replace("\u2640", "\uE08F") // Nidoran ♂
|
||||
.Replace("\u2642", "\uE08E") // Nidoran ♀
|
||||
.Replace("\u0027", "\u2019") // Farfetch'd
|
||||
string TempNick = PKX.UnSanitizeString(value)
|
||||
.PadRight(value.Length + 1, '\0'); // Null Terminator
|
||||
Encoding.Unicode.GetBytes(TempNick).CopyTo(Data, 0xB0);
|
||||
}
|
||||
|
|
|
@ -1122,6 +1122,46 @@ namespace PKHeX
|
|||
{ 1, 0, 1, 1, 1, 1 }, // Dragon
|
||||
{ 1, 1, 1, 1, 1, 1 }, // Dark
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Converts full width to single width
|
||||
/// </summary>
|
||||
/// <param name="str">Input string to sanitize.</param>
|
||||
/// <returns></returns>
|
||||
public static string SanitizeString(string str)
|
||||
{
|
||||
if (str.Length == 0)
|
||||
return str;
|
||||
var s = str.Replace("\u2019", "\u0027"); // farfetch'd
|
||||
s = s.Replace("\uE08F", "\u2640"); // ♀
|
||||
s = s.Replace("\uE08E", "\u2642"); // ♂
|
||||
return s;
|
||||
}
|
||||
/// <summary>
|
||||
/// Converts full width to half width when appropriate
|
||||
/// </summary>
|
||||
/// <param name="str">Input string to set.</param>
|
||||
/// <param name="species"></param>
|
||||
/// <param name="nicknamed"></param>
|
||||
/// <returns></returns>
|
||||
public static string UnSanitizeString(string str, int species = -1, bool nicknamed = true)
|
||||
{
|
||||
var s = str.Replace("\u0027", "\u2019"); // farfetch'd
|
||||
|
||||
bool foreign = true;
|
||||
if ((species == 029 || species == 032) && !nicknamed)
|
||||
foreign = str[0] != 'N';
|
||||
else if (nicknamed)
|
||||
foreign = str.Select(c => c >> 12).Any(c => c != 0 && c != 0xE);
|
||||
|
||||
if (foreign)
|
||||
return s;
|
||||
|
||||
// Convert back to half width
|
||||
s = s.Replace("\u2640", "\uE08F"); // ♀
|
||||
s = s.Replace("\u2642", "\uE08E"); // ♂
|
||||
return s;
|
||||
}
|
||||
|
||||
public static string TrimFromFFFF(string input)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue