Skip to content
This repository has been archived by the owner on Mar 25, 2023. It is now read-only.

Commit

Permalink
Add Settings To Control Which Boxes To Sort
Browse files Browse the repository at this point in the history
  • Loading branch information
foohyfooh committed Nov 25, 2022
1 parent 00e9583 commit fa95d0a
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 18 deletions.
17 changes: 10 additions & 7 deletions SortingPlugin/PluginMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,7 @@ public static void LoadMenuStrip() {

if(gen != 1) {
ToolStripMenuItem nationalDexSortButton = new ToolStripMenuItem("National Pokédex");
nationalDexSortButton.Click += (s, e) => {
saveFileEditor.SAV.SortBoxes();
saveFileEditor.ReloadSlots();
};
nationalDexSortButton.Click += (s, e) => SortByFunctions();
sortItems.Add(nationalDexSortButton);

if(gen >= 7 && !isBDSP) {
Expand All @@ -163,9 +160,15 @@ public static void LoadMenuStrip() {
sortItems.Add(settingsButton);
}

private static void SortByFunctions(Func<PKM, IComparable>[] sortFunctions) {
IEnumerable<PKM> sortMethod(IEnumerable<PKM> pkms, int start) => pkms.OrderByCustom(sortFunctions);
saveFileEditor.SAV.SortBoxes(0, -1, sortMethod);
private static void SortByFunctions(Func<PKM, IComparable>[] sortFunctions = null) {
int beginIndex = PluginSettings.Default.SortBeginBox - 1;
int endIndex = PluginSettings.Default.SortEndBox < 0 ? -1 : PluginSettings.Default.SortEndBox - 1;
if (sortFunctions != null) {
IEnumerable<PKM> sortMethod(IEnumerable<PKM> pkms, int start) => pkms.OrderByCustom(sortFunctions);
saveFileEditor.SAV.SortBoxes(beginIndex, endIndex, sortMethod);
} else {
saveFileEditor.SAV.SortBoxes(beginIndex, endIndex);
}
saveFileEditor.ReloadSlots();
}

Expand Down
50 changes: 43 additions & 7 deletions SortingPlugin/PluginSettings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions SortingPlugin/PluginSettings.settings
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="SortingPlugin.Properties" GeneratedClassName="PluginSettings">
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="SortingPlugin" GeneratedClassName="PluginSettings">
<Profiles />
<Settings>
<Setting Name="ShowIndividualPokedéxes" Type="System.Boolean" Scope="User">
<Setting Name="ShowIndividualPokedéxes" Description="Show the individual area Pokedéxes for those that have it." Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="SortBeginBox" Description="The box to begin sorting from." Type="System.Int32" Scope="User">
<Value Profile="(Default)">1</Value>
</Setting>
<Setting Name="SortEndBox" Description="The box to ending sorting in. -1 can be used to specify the last box." Type="System.Int32" Scope="User">
<Value Profile="(Default)">-1</Value>
</Setting>
</Settings>
</SettingsFile>
</SettingsFile>
8 changes: 7 additions & 1 deletion SortingPlugin/app.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="SortingPlugin.Properties.PluginSettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="SortingPlugin.PluginSettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
Expand All @@ -27,6 +27,12 @@
<setting name="ShowIndividualPokedéxes" serializeAs="String">
<value>False</value>
</setting>
<setting name="SortBeginBox" serializeAs="String">
<value>1</value>
</setting>
<setting name="SortEndBox" serializeAs="String">
<value>-1</value>
</setting>
</SortingPlugin.PluginSettings>
</userSettings>
</configuration>

0 comments on commit fa95d0a

Please # to comment.