public void destroyApp( boolean unconditional ) {
}
public void commandAction( Command c, Displayable d ) {
Display display = Display.getDisplay( this );
try {
if( c == quitCommand ) {
warehouseCanvas.saveGameData();
notifyDestroyed();
} else if( c == undoCommand ) {
warehouseCanvas.undoMove();
} else if( c == gameCommand ) {
display.setCurrent( gameList );
} else if( c == List.SELECT_COMMAND && d == gameList ) {
String name = gameList.getString( gameList.getSelectedIndex() );
warehouseCanvas.loadGame( "/warehouse/levels/" + name + ".lev" );
display.setCurrent( warehouseCanvas );
} else if( c == levelCommand ) {
levelField.setString( String.valueOf( warehouseCanvas.getLevel() ) );
display.setCurrent( levelForm );
} else if( c == resetCommand ) {
warehouseCanvas.setLevel( warehouseCanvas.getLevel() );
display.setCurrent( warehouseCanvas );
} else if( c == nextCommand ) {
warehouseCanvas.setLevel( warehouseCanvas.getLevel() + 1 );
display.setCurrent( warehouseCanvas );
} else if( c == randomCommand ) {
warehouseCanvas.randomLevel();
display.setCurrent( warehouseCanvas );
} else if( c == clearCommand ) {
warehouseCanvas.clearGameData();
warehouseCanvas.setLevel( warehouseCanvas.getLevel() );
display.setCurrent( warehouseCanvas );
} else if( c == helpCommand ) {
display.setCurrent( helpForm );
} else if( c == okCommand && d == levelForm ) {
int level = 1;
try {
level = Integer.parseInt( levelField.getString() );
} catch( NumberFormatException e ) {
}
warehouseCanvas.setLevel( level );
display.setCurrent( warehouseCanvas );
} else if( c == backCommand ) {
display.setCurrent( warehouseCanvas );
}
} catch( Exception e ) {
display.setCurrent( new Alert( "Error", e.getMessage(), null, null ) );
}
}