Remove unused PKHeX.Core code, add src disclaimer (#6)

This commit is contained in:
Kurt
2019-03-21 20:24:20 -07:00
committed by Kamron Batman
parent 683f3d886f
commit cc512ea396
9 changed files with 182 additions and 1149 deletions

View File

@@ -99,7 +99,7 @@ namespace WC3Tool
}
public bool isjap;
public string NAME { get { return PKHeX.PKM.getG3Str(Data.Take(7).ToArray(), isjap); } set { setData(PKHeX.PKM.setG3Str(value, isjap), 0); } }
public string NAME { get { return StringConverter.GetG3Str(Data.Take(7).ToArray(), isjap); } set { setData(StringConverter.SetG3Str(value, isjap), 0); } }
public byte FIRMNESS { get { return Data[0x7]; } set { Data[0x7] = (byte) value; } }
public UInt16 SIZE { get { return BitConverter.ToUInt16(Data, 0x8); } set { BitConverter.GetBytes((UInt16)value).CopyTo(Data, 0x8);; } }
public byte YIELD_MAX { get { return Data[0xA]; } set { Data[0xA] = (byte) value; } }
@@ -112,8 +112,8 @@ namespace WC3Tool
public byte SOUR { get { return Data[0x19]; } set { Data[0x19] = (byte) value; } }
public byte SMOOTH { get { return Data[0x1A]; } set { Data[0x1A] = (byte) value; } }
public string DESC_1 { get { return PKHeX.PKM.getG3Str(Data.Skip(0x4BC).Take(45).ToArray(), isjap); } set { setData(PKHeX.PKM.setG3Str(value, isjap), 0x4BC); } }
public string DESC_2 { get { return PKHeX.PKM.getG3Str(Data.Skip(0x4E9).Take(45).ToArray(), isjap); } set { setData(PKHeX.PKM.setG3Str(value, isjap), 0x4E9); } }
public string DESC_1 { get { return StringConverter.GetG3Str(Data.Skip(0x4BC).Take(45).ToArray(), isjap); } set { setData(StringConverter.SetG3Str(value, isjap), 0x4BC); } }
public string DESC_2 { get { return StringConverter.GetG3Str(Data.Skip(0x4E9).Take(45).ToArray(), isjap); } set { setData(StringConverter.SetG3Str(value, isjap), 0x4E9); } }
public byte HITEM { get { return Data[0x528]; } set { Data[0x528] = (byte) value; } }

View File

@@ -144,7 +144,7 @@ namespace WC3Tool
trainer_class_value.Value= ectfile.Data[0x1];
tower_floor.Value = ectfile.Data[0x2];
name.Text = PKHeX.PKM.getG3Str(ectfile.getData(0x4, 8), jap_check.Checked);
name.Text = StringConverter.GetG3Str(ectfile.getData(0x4, 8), jap_check.Checked);
TID.Value = BitConverter.ToUInt16(ectfile.getData(0xC, 2), 0);
SID.Value = BitConverter.ToUInt16(ectfile.getData(0xE, 2), 0);
@@ -181,7 +181,7 @@ namespace WC3Tool
ectfile.Data[0x1] = (byte) trainer_class_value.Value;
ectfile.Data[0x2] = (byte) tower_floor.Value;
ectfile.setData(PKHeX.PKM.setG3Str(name.Text, jap_check.Checked), (int)0x04);
ectfile.setData(StringConverter.SetG3Str(name.Text, jap_check.Checked), (int)0x04);
ectfile.setData(BitConverter.GetBytes((UInt16)TID.Value).ToArray(), (int)0xC);
ectfile.setData(BitConverter.GetBytes((UInt16)SID.Value).ToArray(), (int)0xC);
@@ -266,7 +266,7 @@ namespace WC3Tool
}
void Jap_checkCheckedChanged(object sender, EventArgs e)
{
name.Text = PKHeX.PKM.getG3Str(ectfile.getData(0x4, 8), jap_check.Checked);
name.Text = StringConverter.GetG3Str(ectfile.getData(0x4, 8), jap_check.Checked);
if (jap_check.Checked)
MessageBox.Show("Remember Japanese names have a maximum of 5 characters.");
}

View File

@@ -52,7 +52,7 @@ namespace WC3Tool
void populate()
{
item_box.SelectedIndex = BitConverter.ToUInt16( ECT_editor.ectfile.getData(pk+0x2, 2), 0);
namebox.Text = PKHeX.PKM.getG3Str(ECT_editor.ectfile.getData(pk+0x20, 11), jap_check.Checked);
namebox.Text = StringConverter.GetG3Str(ECT_editor.ectfile.getData(pk+0x20, 11), jap_check.Checked);
move1.SelectedIndex = BitConverter.ToUInt16( ECT_editor.ectfile.getData(pk+0x4, 2), 0);
move2.SelectedIndex = BitConverter.ToUInt16( ECT_editor.ectfile.getData(pk+0x6, 2), 0);
@@ -94,7 +94,7 @@ namespace WC3Tool
{
ECT_editor.ectfile.setData(BitConverter.GetBytes((UInt16)item_box.SelectedIndex).ToArray(),pk+0x2);
ECT_editor.ectfile.setData(PKHeX.PKM.setG3Str(namebox.Text, jap_check.Checked), pk+0x20);
ECT_editor.ectfile.setData(StringConverter.SetG3Str(namebox.Text, jap_check.Checked), pk+0x20);
ECT_editor.ectfile.setData(BitConverter.GetBytes((UInt16)move1.SelectedIndex).ToArray(),pk+0x4);
ECT_editor.ectfile.setData(BitConverter.GetBytes((UInt16)move2.SelectedIndex).ToArray(),pk+0x6);
@@ -145,7 +145,7 @@ namespace WC3Tool
}
void Jap_checkCheckedChanged(object sender, EventArgs e)
{
namebox.Text = PKHeX.PKM.getG3Str(ECT_editor.ectfile.getData(pk+0x20, 11), jap_check.Checked);
namebox.Text = StringConverter.GetG3Str(ECT_editor.ectfile.getData(pk+0x20, 11), jap_check.Checked);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,61 @@
using System;
namespace WC3Tool
{
/// <summary>
/// This class is loaned from PKHeX.Core with permission.
/// PKHeX's current license (GPLv3 as of 2019) applies if any of this class's contents are used outside of WC3Tool.
/// </summary>
public static class SpeciesConverter
{
internal static int GetG4Species(int g3index)
{
int index = Array.IndexOf(oldindex, g3index);
return newindex[index > -1 ? index : 0];
}
internal static readonly int[] newindex =
{
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,
31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,
59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,77,79,80,81,82,83,84,85,86,
87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,
111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,
132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,
153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,
174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,
195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,
216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,
237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,
258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,290,291,292,
276,277,285,286,327,278,279,283,284,320,321,300,301,352,343,344,299,324,302,339,340,
370,341,342,349,350,318,319,328,329,330,296,297,309,310,322,323,363,364,365,331,332,
361,362,337,338,298,325,326,311,312,303,307,308,333,334,360,355,356,315,287,288,289,
316,317,357,293,294,295,366,367,368,359,353,354,336,335,369,304,305,306,351,313,314,
345,346,347,348,280,281,282,371,372,373,374,375,376,377,378,379,382,383,384,380,381,
385,386,358,
};
internal static readonly int[] oldindex =
{
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,
31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,
59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,
87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,
111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,
132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,
153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,
174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,
195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,
216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,
237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,277,278,279,280,281,282,
283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,
304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,
325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,
346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,
367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,
388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,
409,410,411,
};
}
}

View File

@@ -0,0 +1,105 @@
using System;
using System.Linq;
namespace WC3Tool
{
/// <summary>
/// This class is loaned from PKHeX.Core with permission.
/// PKHeX's current license (GPLv3 as of 2019) applies if any of this class's contents are used outside of WC3Tool.
/// </summary>
public static class StringConverter
{
/// <summary>
/// Decodes a character from a Generation 3 encoded value.
/// </summary>
/// <param name="chr">Generation 4 decoded character.</param>
/// <param name="jp">Character destination is Japanese font.</param>
/// <returns>Generation 3 encoded value.</returns>
private static char GetG3Char(byte chr, bool jp)
{
var table = jp ? G3_JP : G3_EN;
if (chr >= table.Length)
return (char)0xFF;
return table[chr];
}
/// <summary>
/// Encodes a character to a Generation 3 encoded value.
/// </summary>
/// <param name="chr">Generation 4 decoded character.</param>
/// <param name="jp">Character destination is Japanese font.</param>
/// <returns>Generation 3 encoded value.</returns>
private static byte SetG3Char(char chr, bool jp)
{
var table = jp ? G3_JP : G3_EN;
var index = Array.IndexOf(table, chr);
return (byte)(index > -1 ? index : 0xFF);
}
internal static string GetG3Str(byte[] strdata, bool jp)
{
return strdata
.TakeWhile(val => val < 247) // Take valid values
.Select(val => GetG3Char(val, jp)) // Convert to Unicode
.TakeWhile(chr => chr != 0xFF) // Stop if Terminator
.Aggregate("", (current, chr) => current + chr);
}
internal static byte[] SetG3Str(string str, bool jp)
{
byte[] strdata = new byte[str.Length + 1]; // +1 for 0xFF
for (int i = 0; i < str.Length; i++)
{
var chr = str[i];
byte val = SetG3Char(chr, jp);
if (val == 0xFF || chr == 0xFF)
{ Array.Resize(ref strdata, i); break; }
strdata[i] = val;
}
strdata[str.Length] = 0xFF;
return strdata;
}
internal static byte[] SetG3Str_WONDER(string str, bool jp) => SetG3Str(str, jp);
private static readonly char[] G3_EN =
{
' ', 'À', 'Á', 'Â', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'こ', 'Î', 'Ï', 'Ò', 'Ó', 'Ô', // 0
'Œ', 'Ù', 'Ú', 'Û', 'Ñ', 'ß', 'à', 'á', 'ね', 'Ç', 'È', 'é', 'ê', 'ë', 'ì', 'í', // 1
'î', 'ï', 'ò', 'ó', 'ô', 'œ', 'ù', 'ú', 'û', 'ñ', 'º', 'ª', '⒅', '&', '+', 'あ', // 2
'ぃ', 'ぅ', 'ぇ', 'ぉ', 'ゃ', '=', 'ょ', 'が', 'ぎ', 'ぐ', 'げ', 'ご', 'ざ', 'じ', 'ず', 'ぜ', // 3
'ぞ', 'だ', 'ぢ', 'づ', 'で', 'ど', 'ば', 'び', 'ぶ', 'べ', 'ぼ', 'ぱ', 'ぴ', 'ぷ', 'ぺ', 'ぽ', // 4
'っ', '¿', '¡', '⒆', '⒇', 'オ', 'カ', 'キ', 'ク', 'ケ', 'Í', 'コ', 'サ', 'ス', 'セ', 'ソ', // 5
'タ', 'チ', 'ツ', 'テ', 'ト', 'ナ', 'ニ', 'ヌ', 'â', '', 'ハ', 'ヒ', 'フ', 'ヘ', 'ホ', 'í', // 6
'ミ', 'ム', 'メ', 'モ', 'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', 'ル', 'レ', 'ロ', 'ワ', 'ヲ', 'ン', 'ァ', // 7
'ィ', 'ゥ', 'ェ', 'ォ', 'ャ', 'ュ', 'ョ', 'ガ', 'ギ', 'グ', 'ゲ', 'ゴ', 'ザ', 'ジ', 'ズ', 'ゼ', // 8
'ゾ', 'ダ', 'ヂ', 'ヅ', 'デ', 'ド', 'バ', 'ビ', 'ブ', 'ベ', 'ボ', 'パ', 'ピ', 'プ', 'ペ', 'ポ', // 9
'ッ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '!', '?', '.', '-', '・',// A
'⑬', '“', '”', '', '', '♂', '♀', '$', ',', '⑧', '/', 'A', 'B', 'C', 'D', 'E', // B
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', // C
'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', // D
'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', // E
':', 'Ä', 'Ö', 'Ü', 'ä', 'ö', 'ü', // F
};
private static readonly char[] G3_JP =
{
' ', 'あ', 'い', 'う', 'え', 'お', 'か', 'き', 'く', 'け', 'こ', 'さ', 'し', 'す', 'せ', 'そ', // 0
'た', 'ち', 'つ', 'て', 'と', 'な', 'に', 'ぬ', 'ね', 'の', 'は', 'ひ', 'ふ', 'へ', 'ほ', 'ま', // 1
'み', 'む', 'め', 'も', 'や', 'ゆ', 'よ', 'ら', 'り', 'る', 'れ', 'ろ', 'わ', 'を', 'ん', 'ぁ', // 2
'ぃ', 'ぅ', 'ぇ', 'ぉ', 'ゃ', 'ゅ', 'ょ', 'が', 'ぎ', 'ぐ', 'げ', 'ご', 'ざ', 'じ', 'ず', 'ぜ', // 3
'ぞ', 'だ', 'ぢ', 'づ', 'で', 'ど', 'ば', 'び', 'ぶ', 'べ', 'ぼ', 'ぱ', 'ぴ', 'ぷ', 'ぺ', 'ぽ', // 4
'っ', 'ア', 'イ', 'ウ', 'エ', 'オ', 'カ', 'キ', 'ク', 'ケ', 'コ', 'サ', 'シ', 'ス', 'セ', 'ソ', // 5
'タ', 'チ', 'ツ', 'テ', 'ト', 'ナ', 'ニ', 'ヌ', 'ネ', '', 'ハ', 'ヒ', 'フ', 'ヘ', 'ホ', 'マ', // 6
'ミ', 'ム', 'メ', 'モ', 'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', 'ル', 'レ', 'ロ', 'ワ', 'ヲ', 'ン', 'ァ', // 7
'ィ', 'ゥ', 'ェ', 'ォ', 'ャ', 'ュ', 'ョ', 'ガ', 'ギ', 'グ', 'ゲ', 'ゴ', 'ザ', 'ジ', 'ズ', 'ゼ', // 8
'ゾ', 'ダ', 'ヂ', 'ヅ', 'デ', 'ド', 'バ', 'ビ', 'ブ', 'ベ', 'ボ', 'パ', 'ピ', 'プ', 'ペ', 'ポ', // 9
'ッ', '', '', '', '', '', '', '', '', '', '', '', '', '。', 'ー', '・', // A
'⋯', '『', '』', '「', '」', '♂', '♀', '$', '.', '⑧', '/', '', '', '', '', '', // B
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', // C
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', // D
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '0', // E
':', 'Ä', 'Ö', 'Ü', 'ä', 'ö', 'ü', // F
};
}
}

View File

@@ -310,7 +310,7 @@ namespace WC3Tool
if (icon_num.Value <= 251 || icon_num.Value >= 277 && icon_num.Value <= 411)
{
bitmap2 = (Image)resources2.GetObject(PKHeX.PKM.getG4Species((int)icon_num.Value).ToString());
bitmap2 = (Image)resources2.GetObject(SpeciesConverter.GetG4Species((int)icon_num.Value).ToString());
GFX.DrawImage(bitmap2, 700, 140, 40, 40);
}else if (icon_num.Value >= 412 && icon_num.Value <= 439) // Egg and unown forms
{

View File

@@ -402,7 +402,7 @@ namespace WC3Tool
break;
}
}
return PKHeX.PKM.getG3Str(Data.Skip(text_start+offset[index]).Take(size).ToArray(), japanese);
return StringConverter.GetG3Str(Data.Skip(text_start+offset[index]).Take(size).ToArray(), japanese);
}
public void insert_wc_text(string text, int index)
{
@@ -416,7 +416,7 @@ namespace WC3Tool
offset[0]=0;offset[1]=18;offset[2]=18+13;offset[3]=18+13+20;
offset[4]=18+13+40;offset[5]=18+13+60;offset[6]=18+13+80;offset[7]=18+13+100;
}
setData(PKHeX.PKM.setG3Str_WONDER(text, japanese), text_start+offset[index]);
setData(StringConverter.SetG3Str_WONDER(text, japanese), text_start+offset[index]);
}
public void clear_wc_text()
{
@@ -456,7 +456,7 @@ namespace WC3Tool
offset[i]=0x14*i;
}
}
return PKHeX.PKM.getG3Str(Data.Skip(text_start+offset[index]).Take(size).ToArray(), japanese);
return StringConverter.GetG3Str(Data.Skip(text_start+offset[index]).Take(size).ToArray(), japanese);
}
public void insert_wn_text_2(string text, int index)
{
@@ -468,7 +468,7 @@ namespace WC3Tool
offset[i]=0x14*i;
}
}
setData(PKHeX.PKM.setG3Str_WONDER(text, japanese), text_start+offset[index]);
setData(StringConverter.SetG3Str_WONDER(text, japanese), text_start+offset[index]);
}
public void fakeWC()
{

View File

@@ -102,7 +102,8 @@
<Compile Include="WC3\ME3_editor.Designer.cs">
<DependentUpon>ME3_editor.cs</DependentUpon>
</Compile>
<Compile Include="WC3\PKHEX\PKM.cs" />
<Compile Include="WC3\PKHEX\SpeciesConverter.cs" />
<Compile Include="WC3\PKHEX\StringConverter.cs" />
<Compile Include="WC3\SAV3.cs" />
<Compile Include="WC3\TV.cs" />
<Compile Include="WC3\TV_editor.cs">