package chip8emu;
/*
This file is part of JavaCHIP8.
Copyright 2004 Kustaa Nyholm / SpareTimeLabs
JavaCHIP8 is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
JavaCHIP8 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with JavaCHIP8; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import javax.microedition.lcdui.*;
import chip8emu.games.*;
import java.io.*;
class GamesScreen
extends List
implements CommandListener {
private Chip8MIDlet midlet;
private Games games=new Games();
private Command quitCommand;
private Command helpCommand;
private Command copyrightCommand;
GamesScreen(Chip8MIDlet midlet) {
super("Classic CHIP8-Games", List.IMPLICIT);
this.midlet = midlet;
// append(""+midlet.chip8Screen.width+"x"+midlet.chip8Screen.height, null);
int n=Games.getNumberOfGames();
for (int i = 0; i < n; ++i) {
append(Games.getGameName(i), null);
}
addCommand(quitCommand = new Command("Quit", Command.EXIT, 1));
addCommand(helpCommand = new Command("Help", Command.HELP, 2));
addCommand(copyrightCommand = new Command("Copyright", Command.HELP, 3));
setCommandListener(this);
}
public void commandAction(Command c, Displayable d) {
if (c == List.SELECT_COMMAND) {
int i = getSelectedIndex();
if (i != -1) {
midlet.gotoChip8Screen();
InputStream is = Games.getGameAsStream(Games.getGameName(i));
midlet.emulator.loadGame(is);
midlet.chip8Screen.configureKeys(Games.getGameKeys(i));
midlet.emulator.start(0);
}
}
if (c == quitCommand) {
midlet.quitApplication();
}
if (c == helpCommand) {
midlet.gotoHelpScreen();
}
if (c == copyrightCommand) {
midlet.gotoCopyrightScreen();
}
}
}
|