Hack to allow multiple hard drives.

This commit is contained in:
James Sanford 2012-12-20 15:43:42 -08:00
parent 428315b553
commit cfad789cf8
4 changed files with 26 additions and 3 deletions

View File

@ -30,7 +30,13 @@
<string-array name="swapdisk_choices">
<item>Ignore this disk</item>
<item>Swap to this disk</item>
<item>Put disk into drive</item>
<item>Boot this disk</item>
</string-array>
<string-array name="swapdisk_hd_choices">
<item>Ignore this disk</item>
<item>Attach hard drive</item>
<item>Boot this disk</item>
</string-array>

View File

@ -57,6 +57,7 @@ public class KegsMain extends SherlockFragmentActivity implements KegsKeyboard.S
final Runnable mErrorFinish = new Runnable() { public void run() { finish(); } };
private DiskLoader mDiskLoader = null;
private int mNextDriveNumber = 2;
private void withUIActive(final Runnable runnable) {
if(!mPaused) {
@ -151,6 +152,14 @@ public class KegsMain extends SherlockFragmentActivity implements KegsKeyboard.S
mConfigFile.setConfig(image);
getThread().allowPowerOn();
} else if (image.action == DiskImage.SWAP) {
if (image.isHardDrive()) {
// Probably not the right place for this.
image.updateDriveNumber(mNextDriveNumber);
mNextDriveNumber += 1;
if (mNextDriveNumber > 7) {
mNextDriveNumber = 2;
}
}
getThread().getEventQueue().add(image.getDiskImageEvent());
}
}

View File

@ -116,6 +116,14 @@ class DiskImage implements Comparable {
}
}
public void updateDriveNumber(int drive) {
this.drive = this.drive.substring(0, 3) + drive;
}
public boolean isHardDrive() {
return this.drive.substring(0, 2).equals("s7");
}
public int compareTo(Object other) {
if (other instanceof DiskImage) {
return this.getTitle().compareToIgnoreCase(((DiskImage)other).getTitle());

View File

@ -21,8 +21,8 @@ public class SwapDiskFragment extends SherlockDialogFragment {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(mImage.getTitle());
builder.setIcon(mImage.getIconId());
builder.setItems(R.array.swapdisk_choices,
new DialogInterface.OnClickListener() {
final int choices = mImage.isHardDrive() ? R.array.swapdisk_hd_choices : R.array.swapdisk_choices;
builder.setItems(choices, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
dismiss();
if (item == 0) {