package View;
import Controller.OthelloController;
import Model.Othello.ModeJeu;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.List;
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.721C5EBE-249D-17F1-178F-0669A8F88700]
// </editor-fold>
public class ChoiceGameView extends ViewAbstract implements CommandListener {
private final String[] MENU_LABELS = {"Jouer_contre_ordi", "Jouer_plusieurs", "Jouer_plusieurs_serveur" , "Aide" , "A propos de..." };
private final Command NEW_GAME = 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);
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.49C2444D-2C04-3D39-E0B6-A506A9865720]
// </editor-fold>
private String _helpText = "aide!!!";
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.92107E4C-16C1-0E1C-B389-73452D501388]
// </editor-fold>
private Alert _helpScreen = new Alert("Aide");
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.075974D9-9FB8-50F9-66E3-1CCEA9790C3F]
// </editor-fold>
private String _aboutText = "a propos!!!";
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.74007115-C2FA-16FB-5B16-57D36C37F667]
// </editor-fold>
private Alert _aboutScreen = new Alert("A propos de ...");
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.5251DF14-7D8A-9E64-610E-BB440F834555]
// </editor-fold>
public ChoiceGameView (Display disp, OthelloController ctrl) {
super(disp,ctrl);
System.out.println("ChoiceGameView : constructeur");
// prepare help screen
_helpScreen.addCommand(BACK_CMD);
_helpScreen.setTimeout(Alert.FOREVER);
_helpScreen.setString(_helpText);
_helpScreen.setCommandListener(this);
// prepare about screen
_aboutScreen.addCommand(BACK_CMD);
_aboutScreen.setTimeout(Alert.FOREVER);
_aboutScreen.setString(_aboutText);
_aboutScreen.setCommandListener(this);
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.D7FB5338-9DC3-6E82-1FB1-B757134CBA8F]
// </editor-fold>
public void commandAction (Command c, Displayable d) {
if ( c == EXIT_GAME ) {
super.get_othelloController().notifyDestroyed();
System.out.println("VueChoiceGame : EXIT");
} else if( (c == List.SELECT_COMMAND) || (c == NEW_GAME) ) {
if (((List) d).getString(((List) d).getSelectedIndex()).equals("Jouer_contre_ordi")) {
System.out.println("VueChoiceGame : jouer contre l'ordi");
super.get_othelloController().set_modeJeu(new ModeJeu(ModeJeu.TYPE_JOUER_SEUL) ) ;
super.get_child().display();
} else if (((List) d).getString(((List) d).getSelectedIndex()).equals("Jouer_plusieurs_serveur")) {
System.out.println("VueChoiceGame : jouer contre un autre joueur");
super.get_othelloController().set_modeJeu(new ModeJeu(ModeJeu.TYPE_JOUER_PLUSIEURS_SERVEUR) ) ;
super.get_child().display() ;
} else if (((List) d).getString(((List) d).getSelectedIndex()).equals("Jouer_plusieurs")) {
System.out.println("VueChoiceGame : jouer contre un autre joueur");
super.get_othelloController().set_modeJeu(new ModeJeu(ModeJeu.TYPE_JOUER_PLUSIEURS) ) ;
super.get_child().display() ;
} else if (((List) d).getString(((List) d).getSelectedIndex()).equals("Aide")) {
System.out.println("VueChoiceGame : Choix du mode Aide");
super.get_display().setCurrent(_helpScreen);
} else if (((List) d).getString(((List) d).getSelectedIndex()).equals("A propos de...")) {
System.out.println("VueChoiceGame : Choix du mode A propos de...");
super.get_display().setCurrent(_aboutScreen);
}
} else if ( (c == BACK_CMD) && ( (d == _helpScreen) || (d == _aboutScreen) ) ) {
this.display();
}
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.E8635472-EACA-CC7C-F479-41F024E0C240]
// </editor-fold>
public void display () {
List list = new List( "Choix du jeu :", List.IMPLICIT , MENU_LABELS, null);
list.addCommand(EXIT_GAME);
list.addCommand(NEW_GAME);
list.setCommandListener(this);
super.get_display().setCurrent(list);
System.out.println("VueChoiceGame : display");
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,regenBody=yes,id=DCE.C9EAD193-6FA8-CCAC-DB4E-128E8AC0B131]
// </editor-fold>
public Alert get_aboutScreen () {
return _aboutScreen;
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,regenBody=yes,id=DCE.F27A74E8-D5DF-47B1-D5AD-55156EF9A613]
// </editor-fold>
public void set_aboutScreen (Alert val) {
this._aboutScreen = val;
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,regenBody=yes,id=DCE.51EEA0BA-D0F1-A01F-2F90-83683DA67537]
// </editor-fold>
public String get_aboutText () {
return _aboutText;
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,regenBody=yes,id=DCE.77EE6438-7021-5DC1-8A1C-50F80A0D4390]
// </editor-fold>
public void set_aboutText (String val) {
this._aboutText = val;
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,regenBody=yes,id=DCE.3E7E042E-8707-D53F-B4D2-485830299476]
// </editor-fold>
public Alert get_helpScreen () {
return _helpScreen;
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,regenBody=yes,id=DCE.337245C0-1F72-28E2-9FFA-4FEE318DE0D1]
// </editor-fold>
public void set_helpScreen (Alert val) {
this._helpScreen = val;
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,regenBody=yes,id=DCE.9BD296D0-1417-BAFE-42C0-A05417071524]
// </editor-fold>
public String get_helpText () {
return _helpText;
}
// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,regenBody=yes,id=DCE.B758095D-36B0-8A70-B36B-E04015204810]
// </editor-fold>
public void set_helpText (String val) {
this._helpText = val;
}
}