Skip to content

Commit

Permalink
Fixed RM3 Editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Bl4ckSh4rk committed Mar 19, 2024
1 parent e7c3e60 commit 81be811
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 45 deletions.
56 changes: 20 additions & 36 deletions Test/ME3Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,12 @@ namespace Test
{
public class ME3Test
{
private const string CleanSavesDir = "../../../data/saves/clean/";
private const string ExpectedSavesDir = "../../../data/saves/expected/";
private const string MysteryDataDir = "../../../data/mysterydata/";
private const string EM_EN = "em_en.sav";
private const string RS_EN = "rs_en.sav";
private const string EM_JP = "em_jp.sav";
private const string RS_JP = "rs_jp.sav";
private const string EM_EN_ME3 = "em_en_me3.sav";
private const string RS_EN_ME3 = "rs_en_me3.sav";
private const string EM_JP_ME3 = "em_jp_me3.sav";
private const string RS_JP_ME3 = "rs_jp_me3.sav";
private const string Eonticket_RS_EN = "eonticket_rs_en.me3";
private const string Eonticket_RS_JP = "eonticket_rs_jp.me3";
private const string Eonticket_EM_EN = "eonticket_em_en.me3";
private const string Eonticket_EM_JP = "eonticket_em_jp.me3";

[Test]
public void ImportEmeraldEnglish()
{
byte[] clean = File.ReadAllBytes($"{CleanSavesDir}{EM_EN}");
byte[] expected = File.ReadAllBytes($"{ExpectedSavesDir}{EM_EN_ME3}");
byte[] me3 = File.ReadAllBytes($"{MysteryDataDir}{Eonticket_EM_EN}");
byte[] clean = File.ReadAllBytes($"{Data.CleanSavesDir}{Data.EM_EN}");
byte[] expected = File.ReadAllBytes($"{Data.ExpectedSavesDir}{Data.EM_EN_ME3}");
byte[] me3 = File.ReadAllBytes($"{Data.MysteryDataDir}{Data.Eonticket_EM_EN}");

SAV3E sav = new(clean);
sav.ImportME3(me3);
Expand All @@ -38,9 +22,9 @@ public void ImportEmeraldEnglish()
[Test]
public void ImportEmeraldJapanese()
{
byte[] clean = File.ReadAllBytes($"{CleanSavesDir}{EM_JP}");
byte[] expected = File.ReadAllBytes($"{ExpectedSavesDir}{EM_JP_ME3}");
byte[] me3 = File.ReadAllBytes($"{MysteryDataDir}{Eonticket_EM_JP}");
byte[] clean = File.ReadAllBytes($"{Data.CleanSavesDir}{Data.EM_JP}");
byte[] expected = File.ReadAllBytes($"{Data.ExpectedSavesDir}{Data.EM_JP_ME3}");
byte[] me3 = File.ReadAllBytes($"{Data.MysteryDataDir}{Data.Eonticket_EM_JP}");

SAV3E sav = new(clean);
sav.ImportME3(me3);
Expand All @@ -52,9 +36,9 @@ public void ImportEmeraldJapanese()
[Test]
public void ImportRSEnglish()
{
byte[] clean = File.ReadAllBytes($"{CleanSavesDir}{RS_EN}");
byte[] expected = File.ReadAllBytes($"{ExpectedSavesDir}{RS_EN_ME3}");
byte[] me3 = File.ReadAllBytes($"{MysteryDataDir}{Eonticket_RS_EN}");
byte[] clean = File.ReadAllBytes($"{Data.CleanSavesDir}{Data.RS_EN}");
byte[] expected = File.ReadAllBytes($"{Data.ExpectedSavesDir}{Data.RS_EN_ME3}");
byte[] me3 = File.ReadAllBytes($"{Data.MysteryDataDir}{Data.Eonticket_RS_EN}");

SAV3RS sav = new(clean);
sav.ImportME3(me3);
Expand All @@ -65,9 +49,9 @@ public void ImportRSEnglish()
[Test]
public void ImportRSJapanese()
{
byte[] clean = File.ReadAllBytes($"{CleanSavesDir}{RS_JP}");
byte[] expected = File.ReadAllBytes($"{ExpectedSavesDir}{RS_JP_ME3}");
byte[] me3 = File.ReadAllBytes($"{MysteryDataDir}{Eonticket_RS_JP}");
byte[] clean = File.ReadAllBytes($"{Data.CleanSavesDir}{Data.RS_JP}");
byte[] expected = File.ReadAllBytes($"{Data.ExpectedSavesDir}{Data.RS_JP_ME3}");
byte[] me3 = File.ReadAllBytes($"{Data.MysteryDataDir}{Data.Eonticket_RS_JP}");

SAV3RS sav = new(clean);
sav.ImportME3(me3);
Expand All @@ -78,8 +62,8 @@ public void ImportRSJapanese()
[Test]
public void ExportEmeraldEnglish()
{
byte[] sav_me3 = File.ReadAllBytes($"{ExpectedSavesDir}{EM_EN_ME3}");
byte[] me3 = File.ReadAllBytes($"{MysteryDataDir}{Eonticket_EM_EN}");
byte[] sav_me3 = File.ReadAllBytes($"{Data.ExpectedSavesDir}{Data.EM_EN_ME3}");
byte[] me3 = File.ReadAllBytes($"{Data.MysteryDataDir}{Data.Eonticket_EM_EN}");

SAV3E sav = new(sav_me3);

Expand All @@ -88,8 +72,8 @@ public void ExportEmeraldEnglish()
[Test]
public void ExportEmeraldJapanese()
{
byte[] sav_me3 = File.ReadAllBytes($"{ExpectedSavesDir}{EM_JP_ME3}");
byte[] me3 = File.ReadAllBytes($"{MysteryDataDir}{Eonticket_EM_JP}");
byte[] sav_me3 = File.ReadAllBytes($"{Data.ExpectedSavesDir}{Data.EM_JP_ME3}");
byte[] me3 = File.ReadAllBytes($"{Data.MysteryDataDir}{Data.Eonticket_EM_JP}");

SAV3E sav = new(sav_me3);

Expand All @@ -98,8 +82,8 @@ public void ExportEmeraldJapanese()
[Test]
public void ExportRSEnglish()
{
byte[] sav_me3 = File.ReadAllBytes($"{ExpectedSavesDir}{RS_EN_ME3}");
byte[] me3 = File.ReadAllBytes($"{MysteryDataDir}{Eonticket_RS_EN}");
byte[] sav_me3 = File.ReadAllBytes($"{Data.ExpectedSavesDir}{Data.RS_EN_ME3}");
byte[] me3 = File.ReadAllBytes($"{Data.MysteryDataDir}{Data.Eonticket_RS_EN}");

SAV3RS sav = new(sav_me3);

Expand All @@ -108,8 +92,8 @@ public void ExportRSEnglish()
[Test]
public void ExportRSJapanese()
{
byte[] sav_me3 = File.ReadAllBytes($"{ExpectedSavesDir}{RS_JP_ME3}");
byte[] me3 = File.ReadAllBytes($"{MysteryDataDir}{Eonticket_RS_JP}");
byte[] sav_me3 = File.ReadAllBytes($"{Data.ExpectedSavesDir}{Data.RS_JP_ME3}");
byte[] me3 = File.ReadAllBytes($"{Data.MysteryDataDir}{Data.Eonticket_RS_JP}");

SAV3RS sav = new(sav_me3);

Expand Down
2 changes: 1 addition & 1 deletion Test/Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit.Analyzers" Version="3.6.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="PKHeX.Core" Version="24.1.12" />
<PackageReference Include="PKHeX.Core" Version="24.3.10" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions WC3Plugin/Forms/RM3Form.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public RM3Form(SAV3 sav)

InitializeComponent();

List<ComboItem> items = sav.GetRecordMixingItemDataSource();
ItemComboBox.DataSource = new BindingSource(items, null);
ItemComboBox.DataSource = new BindingSource(sav.GetRecordMixingItemDataSource(), null);
ItemComboBox.DisplayMember = "Text";
ItemComboBox.ValueMember = "Value";

Expand All @@ -23,12 +22,13 @@ public RM3Form(SAV3 sav)

private void SaveButton_Click(object sender, EventArgs e)
{
sav.SetRecordMixing((ushort)((ushort)ItemComboBox.SelectedValue! & 0xFFFF), (byte)CountBox.Value);
sav.SetRecordMixing((ushort)((ComboItem)ItemComboBox.SelectedItem!).Value, (byte)CountBox.Value);
Close();
}

private void ItemComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
ushort selected = (ushort)((int)ItemComboBox.SelectedValue! & 0xFFFF);
ushort selected = (ushort)((ComboItem)ItemComboBox.SelectedItem!).Value;
if (selected == 0)
{
CountBox.Value = 0;
Expand Down
5 changes: 3 additions & 2 deletions WC3Plugin/MysteryDataUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private static uint GetECTChecksum(byte[] data)
public static void ImportECB(this SAV3 sav, byte[] data)
{
FixECBChecksum(data).CopyTo(sav.EReaderBerry());
sav.SetWork((sav is SAV3RS or SAV3E) ? VAR_ENIGMA_BERRY_AVAILABLE_RSE : VAR_ENIGMA_BERRY_AVAILABLE_FRLG, 1);
sav.SetWork((sav is IGen3Hoenn) ? VAR_ENIGMA_BERRY_AVAILABLE_RSE : VAR_ENIGMA_BERRY_AVAILABLE_FRLG, 1);
}

public static byte[] ExportECB(this SAV3 sav)
Expand Down Expand Up @@ -248,7 +248,8 @@ public static bool IsValidForRecordMixing(this SAV3 sav, ushort item)
return storage.GetItems(InventoryType.PCItems).Contains(item);
}

public static List<ComboItem> GetRecordMixingItemDataSource(this SAV3 sav) => [
public static IReadOnlyList<ComboItem> GetRecordMixingItemDataSource(this SAV3 sav) =>
[
.. GameInfo.FilteredSources.Items,
new(GameInfo.Strings.GetItemStrings(sav.Context, sav.Version)[EONTICKET], EONTICKET),
];
Expand Down
4 changes: 2 additions & 2 deletions WC3Plugin/WC3Plugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>WC3 Plugin</Description>
<FileVersion>2.2.1.0</FileVersion>
<FileVersion>2.2.2.0</FileVersion>
<TargetFramework>net8.0-windows</TargetFramework>
<LangVersion>12</LangVersion>
<UseWindowsForms>true</UseWindowsForms>
Expand All @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="PKHeX.Core" Version="24.1.12" />
<PackageReference Include="PKHeX.Core" Version="24.3.10" />
</ItemGroup>

</Project>

0 comments on commit 81be811

Please sign in to comment.