modif gui
This commit is contained in:
parent
b0f9825d94
commit
92c3b7d56a
@ -14,6 +14,8 @@ import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
import modeles.Labyrinthe;
|
||||
import modeles.Menu;
|
||||
import modeles.Salle;
|
||||
|
||||
/**
|
||||
@ -21,7 +23,9 @@ import modeles.Salle;
|
||||
*
|
||||
*/
|
||||
public class JeuSalle extends JFrame implements KeyListener,ActionListener{
|
||||
public char nb;
|
||||
public int nb;
|
||||
public Menu menu;
|
||||
public Labyrinthe lab = null;
|
||||
public JeuSalle() {
|
||||
setTitle("Labyrinthe");
|
||||
setSize(1200,600);
|
||||
@ -44,7 +48,8 @@ public class JeuSalle extends JFrame implements KeyListener,ActionListener{
|
||||
this.setContentPane(panel);
|
||||
this.addKeyListener(this);
|
||||
this.requestFocus();
|
||||
|
||||
//this.menu = new Menu();
|
||||
this.setVisible(true);
|
||||
return panel;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
@ -90,13 +95,26 @@ public class JeuSalle extends JFrame implements KeyListener,ActionListener{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
|
||||
}
|
||||
public char toucheint() {
|
||||
public int toucheint() {
|
||||
System.out.println("sortie"+nb);
|
||||
return nb;
|
||||
}
|
||||
public void cacher(JPanel panel) {
|
||||
panel.setVisible(false);
|
||||
}
|
||||
/**
|
||||
* @return the lab
|
||||
*/
|
||||
public Labyrinthe getLab() {
|
||||
return lab;
|
||||
}
|
||||
/**
|
||||
* @param lab the lab to set
|
||||
*/
|
||||
public void setLab(Labyrinthe lab) {
|
||||
this.lab = lab;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -42,11 +42,16 @@ import org.eclipse.swt.SWT;
|
||||
public class jeu extends JFrame implements ActionListener {
|
||||
JButton continuer =new JButton("Continuer");
|
||||
JButton nouvelle = new JButton("Nouvelle Partie");
|
||||
public JeuSalle salle;
|
||||
|
||||
public JPanel panel;
|
||||
|
||||
public Menu menu;
|
||||
|
||||
public jeu() throws IOException {
|
||||
super();
|
||||
|
||||
build();
|
||||
this.menu=new Menu();
|
||||
}
|
||||
|
||||
public void build() throws IOException{
|
||||
@ -78,10 +83,7 @@ public class jeu extends JFrame implements ActionListener {
|
||||
this.setVisible(true);
|
||||
|
||||
}
|
||||
public void buildContentPane() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public BufferedImage image() throws IOException {
|
||||
BufferedImage image = ImageIO.read(new File("/home/nicolas/eclipse-workspace/Projet_Java/JAVA/PROJET-PMT_STRI1A/test.jpg"));
|
||||
return image;
|
||||
@ -95,18 +97,33 @@ public class jeu extends JFrame implements ActionListener {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
Object source=arg0.getSource();
|
||||
choix(source);
|
||||
if(source==nouvelle) {
|
||||
|
||||
//if(source==nouvelle) {
|
||||
//JPanel panel = new JPanel();
|
||||
Menu menu = new Menu();
|
||||
/*Menu menu = new Menu();
|
||||
Labyrinthe lab=menu.nouvellePartie();
|
||||
JeuSalle salle = new JeuSalle();
|
||||
|
||||
repaint();
|
||||
|
||||
Personnage perso = menu.menuSelection(lab, salle);
|
||||
panel =salle.ecrire(menu.textePerso(lab));
|
||||
int test =1;
|
||||
if(perso!=null) {
|
||||
panel.setVisible(false);
|
||||
repaint();
|
||||
System.out.println("test");
|
||||
|
||||
Marche marche= (Marche) lab.listePorte.get(0).getSalle1();
|
||||
panel =salle.ecrire(marche.creerObjetsAVendre(lab));
|
||||
repaint();
|
||||
}
|
||||
|
||||
//menu.Menu_Marche(marche, perso, lab);
|
||||
/*
|
||||
//Bug
|
||||
//Personnage perso = menu.menuSelection(lab);
|
||||
|
||||
//System.out.println();
|
||||
panel =salle.ecrire(menu.textePerso(lab));
|
||||
|
||||
//salle.cacher(panel);
|
||||
//menu.menuSelection(lab);
|
||||
|
||||
@ -114,22 +131,38 @@ public class jeu extends JFrame implements ActionListener {
|
||||
if(source==continuer) {
|
||||
Menu menu = new Menu();
|
||||
Labyrinthe lab = menu.continuer();
|
||||
}
|
||||
}
|
||||
public Labyrinthe choix(Object source) {
|
||||
if(source==nouvelle) {
|
||||
Menu menu = new Menu();
|
||||
Labyrinthe lab=menu.nouvellePartie();
|
||||
return lab;
|
||||
}
|
||||
if(source==nouvelle) {
|
||||
Menu menu = new Menu();
|
||||
Labyrinthe lab = menu.continuer();
|
||||
return lab;
|
||||
}
|
||||
return null;
|
||||
}*/
|
||||
|
||||
}
|
||||
public void choix(Object source) {
|
||||
|
||||
if(source==nouvelle) {
|
||||
System.out.println("1");
|
||||
|
||||
//menu =new Menu();
|
||||
Labyrinthe lab =new Labyrinthe();
|
||||
|
||||
|
||||
this.menu.getJs().setLab(lab) ;
|
||||
this.menu.menuSelection(this.menu.getJs().getLab());
|
||||
}
|
||||
if(source==continuer) {
|
||||
System.out.println("2");
|
||||
//menu = new Menu();
|
||||
//recupMenu(menu);
|
||||
//lab = menu.continuer();
|
||||
//return lab;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/* public Menu creersalle() {
|
||||
salle = new Menu();
|
||||
return salle;
|
||||
}*/
|
||||
public Menu getMenu() {
|
||||
return menu;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,9 @@ import java.io.IOException;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import modeles.Labyrinthe;
|
||||
import modeles.Menu;
|
||||
|
||||
/**
|
||||
* @author nicolas
|
||||
*
|
||||
@ -28,6 +31,14 @@ public class main {
|
||||
try {
|
||||
|
||||
fenetre = new jeu();
|
||||
//Menu menu =fenetre.glob;
|
||||
/*if(fenetre.menu.getJs().getLab()!=null) {
|
||||
System.out.println("passer");
|
||||
fenetre.menu.menuSelection(fenetre.menu.getJs().getLab());
|
||||
//Menu menu =fenetre.creersalle();
|
||||
}*/
|
||||
|
||||
//fenetre.salle.ecrire(fenetre.menu.textePerso(fenetre.lab));
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
@ -18,6 +18,7 @@ public class Labyrinthe {
|
||||
return Labyrinthe1();
|
||||
break;
|
||||
}*/
|
||||
|
||||
labyrinthe1();
|
||||
}
|
||||
public void labyrinthe1() {
|
||||
|
@ -2,12 +2,21 @@ package modeles;
|
||||
import gui.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
import java.awt.*;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
public class Menu {
|
||||
|
||||
private JeuSalle js= new JeuSalle();
|
||||
/**
|
||||
* @return the js
|
||||
*/
|
||||
|
||||
public String menuCombat(Monstre mons, Personnage perso, Labyrinthe lab) throws IOException {
|
||||
int degat;
|
||||
int reponse = 0;
|
||||
System.out.println("Un monstre du nom de "+mons.getNom()+" se présente devant vous et il est trés en colère :");
|
||||
|
||||
js.ecrire("Un monstre du nom de "+mons.getNom()+" se présente devant vous et il est trés en colère :");
|
||||
while (true){
|
||||
System.out.println("\t - 1 attaquer\n\t - 2 Potion \n\t- 3 Fuir");
|
||||
try{
|
||||
@ -56,7 +65,8 @@ public class Menu {
|
||||
}
|
||||
|
||||
public Labyrinthe menuStartGame() {
|
||||
System.out.println("L'Aventure vous appelle ! Le choix s'offre à vous, une histoire peut s'écrire une autre peut continuer :\n1) Nouvelle Partie\n2) Continuer votre progression");
|
||||
js.ecrire("L'Aventure vous appelle ! Le choix s'offre à vous, une histoire peut s'écrire une autre peut continuer :\n1) Nouvelle Partie\n2) Continuer votre progression");
|
||||
|
||||
switch(Clavier.entrerClavierInt()) {
|
||||
case 1:
|
||||
return new Labyrinthe();
|
||||
@ -68,23 +78,24 @@ public class Menu {
|
||||
}
|
||||
}
|
||||
|
||||
public Personnage menuSelection(Labyrinthe lab, JeuSalle salle) {
|
||||
System.out.println("Bonjour Etranger, je suis le narrateur de votre histoire. Comment dois-je vous appeler ? ");
|
||||
public Personnage menuSelection(Labyrinthe lab) {
|
||||
JPanel panel =js.ecrire("Bonjour Etranger, je suis le narrateur de votre histoire. Comment dois-je vous appeler ? ");
|
||||
js.cacher(panel);
|
||||
int i = 0;
|
||||
for (Personnage per : lab.listePersonnage) {
|
||||
System.out.println(i++ + ") "+per.getNom());
|
||||
js.ecrire(i++ + ") "+per.getNom());
|
||||
}
|
||||
|
||||
Personnage pers;
|
||||
try{
|
||||
pers =lab.listePersonnage.get(salle.nb);
|
||||
pers =lab.listePersonnage.get(js.toucheint());
|
||||
|
||||
}
|
||||
catch(Exception e) {
|
||||
System.out.println("Le personnage dont vous me parlez n'existe pas.");
|
||||
js.ecrire("Le personnage dont vous me parlez n'existe pas.");
|
||||
return null;
|
||||
}
|
||||
System.out.println("Enchante de vous rencontrer "+pers.getNom()+".");
|
||||
js.ecrire("Enchante de vous rencontrer "+pers.getNom()+".");
|
||||
return pers;
|
||||
}
|
||||
|
||||
@ -161,5 +172,9 @@ public class Menu {
|
||||
return str;
|
||||
|
||||
}
|
||||
public JeuSalle getJs() {
|
||||
return js;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user