Use cached learnset for learnset editors

Closes #298
This commit is contained in:
Kurt
2018-03-03 23:03:11 -08:00
parent 788958a4f1
commit 8a9a9686c5
2 changed files with 8 additions and 8 deletions

View File

@@ -7,10 +7,9 @@ public static class StructConverter
{
public static T ToStructure<T>(this byte[] bytes) where T : struct
{
GCHandle handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
T obj = (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T));
handle.Free();
return obj;
var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
try { return (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T)); }
finally { handle.Free(); }
}
public static byte[] ToBytes<T>(this T obj) where T : struct
{

View File

@@ -781,6 +781,7 @@ private void B_Move_Click(object sender, EventArgs e)
break;
}
g.Save();
Config.InitializeMoves();
}).Start();
}
private void B_LevelUp_Click(object sender, EventArgs e)
@@ -788,8 +789,7 @@ private void B_LevelUp_Click(object sender, EventArgs e)
if (threadActive()) return;
new Thread(() =>
{
var g = Config.getGARCData("levelup");
byte[][] d = g.Files;
byte[][] d = Config.GARCLearnsets.Files;
switch (Config.Generation)
{
case 6:
@@ -799,8 +799,9 @@ private void B_LevelUp_Click(object sender, EventArgs e)
Invoke((Action)(() => new LevelUpEditor7(d).ShowDialog()));
break;
}
g.Files = d;
g.Save();
Config.GARCLearnsets.Files = d;
Config.GARCLearnsets.Save();
Config.InitializePersonal();
}).Start();
}
private void B_EggMove_Click(object sender, EventArgs e)