package main;
import java.awt.Point;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import world.Editor;
import world.Game;
import menu.MenuGame;
import menu.MenuEditor;
import anim.Anim;
public class Core {
public static Fenetre fen;
//ANIM
public static Anim anim;
private static Game game;
private static Editor editor;
//MENU
public static JPanel menu = null;
private static MenuGame menuGame;
private static MenuEditor menuEditor;
public static void main ( String[] args ) {
set_look_and_feel();
init();
fen = new Fenetre();
setGameMode();
}
private static void init(){
anim = new Anim();
game = new Game();
editor = new Editor();
menuGame = new MenuGame();
menuEditor = new MenuEditor();
}
/* **************************** */
public static void showMenu(){
anim.pause();
fen.clear();
fen.add(menu);
fen.setCursor(null);
fen.affiche();
}
public static void showAnim(){
anim.start();
fen.clear();
fen.add(anim);
fen.setCursor(fen.getToolkit().createCustomCursor(new BufferedImage(3, 3, BufferedImage.TYPE_INT_ARGB), new Point(0, 0), null));
fen.affiche();
}
public static void setGameMode(){
anim.pause();
menu = menuGame;
anim.getScene().setWorld(game);
showMenu();
}
public static void setEditorMode(){
anim.pause();
menu = menuEditor;
anim.getScene().setWorld(editor);
showMenu();
}
/* **************************** */
public static void loadFile(File fic){
anim.loadFile(fic);
}
public static void exit(){
anim.stop();
fen.clear();
System.exit(0);
}
/* **************************** */
public static void set_look_and_feel(){
/* Choix du look :
* Metal style JAVA
* Nimbus style Fashion
* CDE/Motif style Moche
* Windows style Windows 7
* Windows Classic style Windows 98
*/
String look = "Nimbus";
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
//System.out.println(info.getName());
if (look.equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception e) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e1) {
System.exit(1);
}
}
}
}