Skip to content

Commit

Permalink
Update PKHeX.Core To 24.03.10 And Version To 1.7.0
Browse files Browse the repository at this point in the history
MAR10 Day Update

- Replace StringUtils.GetUnicodeString with StringConverter8.GetString
- Fix forgetting to account for the offset in Musical5.Data for the props that is done in commit 24cafd5 when switching to using PKHeX Gen 5 structures for BWTool
  • Loading branch information
foohyfooh committed Mar 11, 2024
1 parent 815b46e commit 37ee302
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<BaseOutputPath>$(SolutionDir)bin\</BaseOutputPath>
<Version>1.6.1</Version>
<Version>1.7.0</Version>
<Company>foohyfooh</Company>
<Authors>foohyfooh</Authors>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion PluginPile.Common/DrawingUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class DrawingUtil {
return (Image)getSpriteMethod.Invoke(null, [pkm])!;
}

public static Image GetSprite(ushort species, byte form, int gender, uint formarg, int item, bool isegg, Shiny shiny, EntityContext context = EntityContext.None) {
public static Image GetSprite(ushort species, byte form, byte gender, uint formarg, int item, bool isegg, Shiny shiny, EntityContext context = EntityContext.None) {
MethodInfo getSpriteMethod = SpriteUtilType.GetMethods(BindingFlags.Public | BindingFlags.Static)
.Single(m => m.Name == "GetSprite" && m.GetParameters().Length == 8);
return (Image)getSpriteMethod.Invoke(null, [species, form, gender, formarg, item, isegg, shiny, context])!;
Expand Down
2 changes: 1 addition & 1 deletion PluginPile.Common/PluginBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public abstract class PluginBase : IPlugin {
Type contextMenuSAVType = ((dynamic)SaveFileEditor).menu.GetType();
MethodInfo getSenderInfoMethod = contextMenuSAVType.GetMethods(BindingFlags.NonPublic | BindingFlags.Static)
.Single(m => m.Name.Contains("GetSenderInfo"));
return (SlotViewInfo<PictureBox>)getSenderInfoMethod.Invoke(null, new object[] { sender })!;
return (SlotViewInfo<PictureBox>)getSenderInfoMethod.Invoke(null, [sender])!;
}

protected BoxManipulator GetBoxManipulatorWF() {
Expand Down
2 changes: 1 addition & 1 deletion PluginPile.Common/PluginPile.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

</Project>
13 changes: 13 additions & 0 deletions PluginPile.Common/SavExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using PKHeX.Core;

namespace PluginPile.Common;
public static class SavExtensions {

public static string GetBoxName(this SaveFile sav, int index) {
return sav switch {
IBoxDetailNameRead bdn => bdn.GetBoxName(index),
_ => BoxDetailNameExtensions.GetDefaultBoxName(index)
};
}

}
9 changes: 0 additions & 9 deletions PluginPile.Common/StringUtils.cs

This file was deleted.

2 changes: 1 addition & 1 deletion PluginPile.RoamerTool/XYRoamerForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial class XYRoamerForm : Form {
Roamer = SAV.Encount.Roamer;

// Roamer Species is obtainable from roamer info but if player hasn't beaten the league then derive it from the starter choice
RoamerSpecies.SelectedIndex = Roamer.Species != 0 ? Roamer.Species - SpeciesOffset : sav.GetWork(StarterChoiceIndex);
RoamerSpecies.SelectedIndex = Roamer.Species != 0 ? Roamer.Species - SpeciesOffset : sav.EventWork.GetWork(StarterChoiceIndex);
Encountered.Value = Roamer.TimesEncountered;
State.SelectedIndex = (int)Roamer.RoamStatus;
}
Expand Down
2 changes: 1 addition & 1 deletion PluginPile.Sorting/SortingPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class SortingPlugin : PluginBase {
SortByButton.Text = Language.MenuItemName;
SortByButton.DropDownItems.Clear();
ToolStripItemCollection sortItems = SortByButton.DropDownItems;
int gen = SaveFileEditor.SAV.Generation;
byte gen = SaveFileEditor.SAV.Generation;
GameVersion version = SaveFileEditor.SAV.Version;
bool isLetsGo = version == GameVersion.GP || version == GameVersion.GE;
if (isLetsGo) {
Expand Down
2 changes: 1 addition & 1 deletion PluginPile.TeamViewer/BattleTeams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class BattleTeams : TeamsBase {
.Skip(i * nameSize)
.Take(nameSize)
.ToArray();
string name = StringUtils.GetUnicodeString(nameBytes);
string name = StringConverter8.GetString(nameBytes);
if (name.Length == 0) name = $"{Language.Team} {i + 1}";
List<PKM> mons = indexes.GetTeam(sav, i);
Teams.Add(new BattleTeam(name, mons));
Expand Down
12 changes: 6 additions & 6 deletions PluginPile.TeamViewer/RentalTeams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ public class RentalTeam8 : RentalTeam {
if (!Enabled) return;
byte[] teamBytes = allTeamBytes.Skip(Constants.SwSh.RentalStartingDataSize).ToArray();
byte[] codeBytes = teamBytes.Take(Constants.SwSh.RentalTeamCodeSize).ToArray();
Code = StringUtils.GetUnicodeString(codeBytes);
Code = StringConverter8.GetString(codeBytes);
Code = string.Join(" ", Code.Chunk(4).Select(c => new string(c)));
byte[] teamNameBytes = teamBytes.Skip(Constants.SwSh.RentalTeamCodeSize).Take(Constants.SwSh.TeamNameSize).ToArray();
Name = StringUtils.GetUnicodeString(teamNameBytes);
Name = StringConverter8.GetString(teamNameBytes);
byte[] teamCreatorBytes = teamBytes.Skip(Constants.SwSh.RentalTeamCodeSize + Constants.SwSh.TeamNameSize).Take(Constants.SwSh.RentalTeamCreatorNameSize).ToArray();
Creator = StringUtils.GetUnicodeString(teamCreatorBytes);
Creator = StringConverter8.GetString(teamCreatorBytes);
byte[] pokemonBytes = allTeamBytes.Skip(Constants.SwSh.RentalTeamHeaderSize).ToArray();
for (int i = 0; i < Constants.NumTeamMons; i++) {
byte[] partialData = pokemonBytes
Expand All @@ -74,11 +74,11 @@ public class RentalTeam9 : RentalTeam {
public RentalTeam9(byte[] codeBytes, byte[] teamBytes) : base() {
Enabled = teamBytes[Constants.SV.RentalTeamEnabledLocation] != 0;
if (!Enabled) return;
Code = StringUtils.GetUnicodeString(codeBytes);
Code = StringConverter8.GetString(codeBytes);
byte[] creatorNameBytes = teamBytes.Take(Constants.SV.RentalTeamCreatorNameSize).ToArray();
Creator = StringUtils.GetUnicodeString(creatorNameBytes);
Creator = StringConverter8.GetString(creatorNameBytes);
byte[] teamNameBytes = teamBytes.Skip(Constants.SV.RentalTeamCreatorNameSize).Take(Constants.SV.RentalTeamNameSize).ToArray();
Name = StringUtils.GetUnicodeString(teamNameBytes);
Name = StringConverter8.GetString(teamNameBytes);
byte[] pokemonBytes = teamBytes.Skip(Constants.SV.RentalTeamHeaderSize).ToArray();
for (int i = 0; i < Constants.NumTeamMons; i++) {
byte[] partialData = pokemonBytes
Expand Down
1 change: 0 additions & 1 deletion PluginPile.TeamViewer/TeamIndexesExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public static class TeamIndexesExtensions {
public static List<PKM> GetTeam(this ITeamIndexSet teamIndexes, SaveFile sav, int i) {
int[] slots = teamIndexes switch {
TeamIndexes8 indexes8 => indexes8.TeamSlots,
TeamIndexes9 indexes9 => indexes9.TeamSlots,
_ => throw new ArgumentException("Invalid Team Indexes")
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial class PropcaseForm : Form {
Musical = SAV.Musical;
Proplist.SelectedIndex = 0;
HasPropCheckbox.Checked = Musical.GetHasProp(Proplist.SelectedIndex);
PropHex.Text = "0x" + BitConverter.ToString(Musical.Data);
PropHex.Text = "0x" + BitConverter.ToString(Musical.Data[0x258..0x264].ToArray());
}

void ShowProp() {
Expand All @@ -32,7 +32,7 @@ public partial class PropcaseForm : Form {

void Hasprop_checkboxCheckedChanged(object sender, EventArgs e) {
Musical.SetHasProp(Proplist.SelectedIndex, HasPropCheckbox.Checked);
PropHex.Text = "0x" + BitConverter.ToString(Musical.Data);
PropHex.Text = "0x" + BitConverter.ToString(Musical.Data[0x258..0x264].ToArray());
}

void Exit_Click(object sender, EventArgs e) => Close();
Expand All @@ -54,13 +54,15 @@ public partial class PropcaseForm : Form {

void UnlockAll_Click(object sender, EventArgs e) {
Musical.UnlockAllMusicalProps();
PropHex.Text = "0x" + BitConverter.ToString(Musical.Data[0x258..0x264].ToArray());
HasPropCheckbox.Checked = Musical.GetHasProp(Proplist.SelectedIndex);
ShowProp();
}

void RemoveAll_Click(object sender, EventArgs e) {
for (int i = 0; i < 100; i++)
Musical.SetHasProp(i, false);
PropHex.Text = "0x" + BitConverter.ToString(Musical.Data);
PropHex.Text = "0x" + BitConverter.ToString(Musical.Data[0x258..0x264].ToArray());
HasPropCheckbox.Checked = Musical.GetHasProp(Proplist.SelectedIndex);
ShowProp();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class RaidManager {

public RaidManager(SAV8SWSH SAV) {
EventTableConverter.GetCurrentEventTable(SAV.Blocks, _raidTables);
DenList = InitializeDenList(SAV.Blocks.Raid, SAV.Blocks.RaidArmor, SAV.Blocks.RaidCrown);
DenList = InitializeDenList(SAV.Blocks.RaidGalar, SAV.Blocks.RaidArmor, SAV.Blocks.RaidCrown);

Game = SAV.Version;
BadgeCount = Util.NumberOfSetBits(SAV.Badges);
Expand Down

0 comments on commit 37ee302

Please sign in to comment.