package gui;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;
import main.BTMIDlet;
/**
*
* @author TeXteR
*/
public class MultiplayerSelection extends List implements CommandListener {
private final Command backCommand;
private ClientConnection clientConnection;
private ServerConection serverConection;
private BTMIDlet bTMIDlet;
public MultiplayerSelection(BTMIDlet bTMIDlet) {
super("Multiplayer", IMPLICIT);
this.bTMIDlet = bTMIDlet;
backCommand = new Command("Back", Command.BACK, 1);
append("Start server", null);
append("Connect to server", null);
addCommand(backCommand);
setCommandListener(this);
}
public void commandAction(Command c, Displayable d) {
int selectedIndex = getSelectedIndex();
if (c.equals(backCommand)) {
bTMIDlet.showMenu();
} else if (c.getCommandType() == Command.SCREEN) {
if(getString(selectedIndex).equals("Connect to server")) {
clientConnection = new ClientConnection(bTMIDlet);
} else if(getString(selectedIndex).equals("Start server")) {
serverConection = new ServerConection(bTMIDlet);
}
}
}
}