Respond to a commands issued on any Screen
if (c == undoCommand) {
canvas.undoMove();
} else if (c == restartCommand) {
canvas.restartLevel();
} else if (c == levelCommand) {
levelScreen = canvas.getLevelScreen();
levelScreen.addCommand(okCommand);
levelScreen.setCommandListener(this);
display.setCurrent(levelScreen);
} else if (c == okCommand && s == levelScreen) {
if (!canvas.gotoLevel()) {
alert.setString("Could not load level");
display.setCurrent(alert, canvas);
} else {
display.setCurrent(canvas);
}
} else if (c == scoresCommand) {
scoreScreen = canvas.getScoreScreen();
scoreScreen.addCommand(okCommand);
scoreScreen.setCommandListener(this);
display.setCurrent(scoreScreen);
} else if (c == okCommand && s == scoreScreen) {
display.setCurrent(canvas);
} else if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
} else if (c == List.SELECT_COMMAND && s == canvas) {
// Solved the level
scoreScreen = canvas.getScoreScreen();
scoreScreen.addCommand(okCommand);
scoreScreen.setCommandListener(this);
display.setCurrent(scoreScreen);
// Read the next screen.
canvas.nextLevel(1);
} else if (c == nextCommand) {
if (!canvas.nextLevel(1)) {
alert.setString("Could not load level " +
(canvas.getLevel() + 1));
display.setCurrent(alert, canvas);
} else {
display.setCurrent(canvas);
}
if (s == canvas) {
canvas.repaint();
}
} else if (c == prevCommand) {
if (!canvas.nextLevel(-1)) {
alert.setString("Could not load level " +
(canvas.getLevel() - 1));
display.setCurrent(alert, canvas);
} else {
display.setCurrent(canvas);
}
if (s == canvas) {
canvas.repaint();
}
} else if (c == aboutCommand) {
About.showAbout(display);
} else if (c == themeCommand) {
canvas.changeTheme();
}