For those interested, I have a patch that will alphabetize the HP and MP restorer lists in KoLMafia. It's a hack and isn't optimal, but it works. I think they should be alphabetized by default, so I'm including this here in case a developer wants to integrate it as the default sort option (Perhaps in a way that isn't stupid about memory).
Code:
Index: src/net/sourceforge/kolmafia/moods/HPRestoreItemList.java
===================================================================
--- src/net/sourceforge/kolmafia/moods/HPRestoreItemList.java (revision 11440)
+++ src/net/sourceforge/kolmafia/moods/HPRestoreItemList.java (working copy)
@@ -178,13 +178,28 @@
String hpRestoreSetting = Preferences.getString( "hpAutoRecoveryItems" );
JCheckBox[] restoreCheckbox = new JCheckBox[ HPRestoreItemList.CONFIGURES.length ];
+ String[] names = new String[ HPRestoreItemList.CONFIGURES.length ];
+ String[] names2 = new String[ HPRestoreItemList.CONFIGURES.length ];
+
for ( int i = 0; i < HPRestoreItemList.CONFIGURES.length; ++i )
{
restoreCheckbox[ i ] = new JCheckBox( HPRestoreItemList.CONFIGURES[ i ].toString() );
restoreCheckbox[ i ].setSelected( hpRestoreSetting.indexOf( HPRestoreItemList.CONFIGURES[ i ].toString().toLowerCase() ) != -1 );
+ names[ i ] = HPRestoreItemList.CONFIGURES[ i ].toString().toLowerCase();
+ names2[ i ] = HPRestoreItemList.CONFIGURES[ i ].toString().toLowerCase();
}
+ java.util.Arrays.sort(names);
- return restoreCheckbox;
+ JCheckBox[] newRestore = new JCheckBox[ HPRestoreItemList.CONFIGURES.length ];
+ for (int j = 0; j < names.length; j++) {
+ for (int k = 0; k < names2.length; k++) {
+ if (names2[k].compareTo(names[j]) == 0) {
+ newRestore[j] = restoreCheckbox[k];
+ }
+ }
+ }
+
+ return newRestore;
}
public static final void updateCheckboxes( final JCheckBox[] restoreCheckbox )
Index: src/net/sourceforge/kolmafia/moods/MPRestoreItemList.java
===================================================================
--- src/net/sourceforge/kolmafia/moods/MPRestoreItemList.java (revision 11440)
+++ src/net/sourceforge/kolmafia/moods/MPRestoreItemList.java (working copy)
@@ -189,13 +189,29 @@
String mpRestoreSetting = Preferences.getString( "mpAutoRecoveryItems" );
JCheckBox[] restoreCheckbox = new JCheckBox[ MPRestoreItemList.CONFIGURES.length ];
+ String[] names = new String[ MPRestoreItemList.CONFIGURES.length ];
+ String[] names2 = new String[ MPRestoreItemList.CONFIGURES.length ];
+
+
for ( int i = 0; i < MPRestoreItemList.CONFIGURES.length; ++i )
{
restoreCheckbox[ i ] = new JCheckBox( MPRestoreItemList.CONFIGURES[ i ].toString() );
restoreCheckbox[ i ].setSelected( mpRestoreSetting.indexOf( MPRestoreItemList.CONFIGURES[ i ].toString().toLowerCase() ) != -1 );
+ names[ i ] = MPRestoreItemList.CONFIGURES[ i ].toString().toLowerCase();
+ names2[ i ] = MPRestoreItemList.CONFIGURES[ i ].toString().toLowerCase();
}
+ java.util.Arrays.sort(names);
- return restoreCheckbox;
+ JCheckBox[] newRestore = new JCheckBox[ MPRestoreItemList.CONFIGURES.length ];
+ for (int j = 0; j < names.length; j++) {
+ for (int k = 0; k < names2.length; k++) {
+ if (names2[k].compareTo(names[j]) == 0) {
+ newRestore[j] = restoreCheckbox[k];
+ }
+ }
+ }
+
+ return newRestore;
}
public static final void updateCheckboxes( final JCheckBox[] restoreCheckbox