/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package View;
import controler.Othello;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;
import Controller.OthelloController;
/**
*
* @author jul
*/
public class ListWaitingPlayerView implements CommandListener , ViewInterface {
private String[] PLAYER_LIST ;
private final Command SELECT_PLAYER = new Command("Sélectionner", Command.SCREEN, 1);
private final Command EXIT_GAME = new Command("Sortie", Command.EXIT, 1);
private final Command BACK_CMD = new Command("Retour", Command.BACK, 2);
private Display _display;
private Othello _controler ;
private ViewInterface _parent ;
private ViewInterface _child ;
public ListWaitingPlayerView( Display d , Othello c ) {
System.out.println("ListWaitingPlayerView : constructeur");
_display = d ;
_controler = c ;
}
public void setParentAndChild( ViewInterface p , ViewInterface c ) {
_parent = p ;
_child = c ;
}
/**
* Permet d'afficher la vue
* @return
*/
public void display() {
List list = new List( "Choix du joueur :", List.IMPLICIT , PLAYER_LIST, null);
list.addCommand(EXIT_GAME);
list.addCommand(SELECT_PLAYER);
list.setCommandListener(this);
_display.setCurrent(list);
System.out.println("ListWaitingPlayerView : display");
}
/**
* Permet de gérer les événements associés à des commandes
* @param c : Commande executer
* @param d : Objet affichage liée à la commande
* @return
*/
public void commandAction(Command c, Displayable d) {
if ( c == EXIT_GAME ) {
_controler.notifyDestroyed();
System.out.println("ListWaitingPlayerView : EXIT");
} else if( (c == List.SELECT_COMMAND) || (c == SELECT_PLAYER) ) {
String playerID = ((List) d).getString( ((List) d).getSelectedIndex() );
_child.display();
} else if ( c == BACK_CMD ) {
this.display();
}
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.702B7416-CCD4-FE88-F203-67809D8F94FF]
// </editor-fold>
public ListWaitingPlayerView (Display disp, OthelloController ctrl) {
}
}