Remove warnings

This commit is contained in:
Yohann D'ANELLO 2020-02-25 00:48:55 +01:00
parent d36800ab13
commit 94ee23c881
17 changed files with 58 additions and 154 deletions

View File

@ -19,7 +19,7 @@ public class EditorAPI {
private static File LAST_FILE; private static File LAST_FILE;
public static RawMap toRawMap(int width, int height) { public static RawMap toRawMap(int width, int height) {
List<RawCase> cases = new ArrayList<RawCase>(); List<RawCase> cases = new ArrayList<>();
for (int y = 1; y < height; y += 16) { for (int y = 1; y < height; y += 16) {
for (int x = 1; x < width; x += 16) { for (int x = 1; x < width; x += 16) {
@ -48,7 +48,7 @@ public class EditorAPI {
jfc.setFileHidingEnabled(true); jfc.setFileHidingEnabled(true);
jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
File dir = new File("maps"); File dir = new File("maps");
dir.mkdirs(); assert dir.mkdirs();
jfc.setCurrentDirectory(dir); jfc.setCurrentDirectory(dir);
return jfc; return jfc;
@ -56,7 +56,7 @@ public class EditorAPI {
public static void saveAs(RawMap map) { public static void saveAs(RawMap map) {
JFileChooser jfc = createJFC(); JFileChooser jfc = createJFC();
File file = null; File file;
jfc.showSaveDialog(null); jfc.showSaveDialog(null);
file = jfc.getSelectedFile(); file = jfc.getSelectedFile();
@ -83,7 +83,7 @@ public class EditorAPI {
String json = createGson().toJson(map); String json = createGson().toJson(map);
try { try {
file.createNewFile(); assert file.createNewFile();
BufferedOutputStream bos = new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(file))); BufferedOutputStream bos = new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(file)));
bos.write(json.getBytes(StandardCharsets.UTF_8)); bos.write(json.getBytes(StandardCharsets.UTF_8));
@ -96,7 +96,7 @@ public class EditorAPI {
public static Map open() { public static Map open() {
JFileChooser jfc = createJFC(); JFileChooser jfc = createJFC();
File file = null; File file;
jfc.showOpenDialog(null); jfc.showOpenDialog(null);
file = jfc.getSelectedFile(); file = jfc.getSelectedFile();
@ -114,15 +114,14 @@ public class EditorAPI {
try { try {
GZIPInputStream gis = new GZIPInputStream(new BufferedInputStream(new FileInputStream(f))); GZIPInputStream gis = new GZIPInputStream(new BufferedInputStream(new FileInputStream(f)));
byte[] bytes = new byte[512 * 1024]; byte[] bytes = new byte[512 * 1024];
int count = 0; int count;
String text = ""; StringBuilder text = new StringBuilder();
while ((count = gis.read(bytes)) != -1) { while ((count = gis.read(bytes)) != -1) {
text += new String(bytes, 0, count, StandardCharsets.UTF_8); text.append(new String(bytes, 0, count, StandardCharsets.UTF_8));
} }
gis.close(); gis.close();
bytes = null;
json = text; json = text.toString();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -24,7 +24,7 @@ public class RawMap {
RawMap raw = new RawMap(); RawMap raw = new RawMap();
raw.width = map.getWidth(); raw.width = map.getWidth();
raw.height = map.getHeight(); raw.height = map.getHeight();
raw.cases = new ArrayList<RawCase>(); raw.cases = new ArrayList<>();
for (Case c : map.getAllCases()) { for (Case c : map.getAllCases()) {
RawCase rc = RawCase.create(c); RawCase rc = RawCase.create(c);
raw.cases.add(rc); raw.cases.add(rc);

View File

@ -5,16 +5,14 @@ import java.util.List;
public class Category { public class Category {
private List<Sprite> sprites; private List<Sprite> sprites;
private String name; private String name;
private int index;
private Category() { private Category() {
} }
public static Category create(String name, int index, List<Sprite> sprites) { public static Category create(String name, List<Sprite> sprites) {
Category c = new Category(); Category c = new Category();
c.name = name; c.name = name;
c.index = index;
c.sprites = sprites; c.sprites = sprites;
return c; return c;
@ -28,7 +26,4 @@ public class Category {
return sprites; return sprites;
} }
public int getIndex() {
return index;
}
} }

View File

@ -5,7 +5,7 @@ import java.awt.image.BufferedImage;
import java.util.ArrayList; import java.util.ArrayList;
public class Sprite { public class Sprite {
public static final Sprite BLANK = new Sprite(new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB), Category.create("blank", 0, new ArrayList<Sprite>()), 0); public static final Sprite BLANK = new Sprite(new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB), Category.create("blank", new ArrayList<>()), 0);
static { static {
Graphics2D g = BLANK.getImage().createGraphics(); Graphics2D g = BLANK.getImage().createGraphics();

View File

@ -17,7 +17,7 @@ import java.util.jar.JarFile;
public class SpriteRegister { public class SpriteRegister {
private static Map<String, List<List<Double>>> nameToCoords; private static Map<String, List<List<Double>>> nameToCoords;
private static Map<String, Category> sprites = new HashMap<String, Category>(); private static final Map<String, Category> sprites = new HashMap<>();
public static void unpack() throws IOException, URISyntaxException { public static void unpack() throws IOException, URISyntaxException {
if (Main.isInDevelopmentMode()) { if (Main.isInDevelopmentMode()) {
@ -38,7 +38,7 @@ public class SpriteRegister {
if (name.startsWith("assets/")) { if (name.startsWith("assets/")) {
File f = new File(name); File f = new File(name);
if (name.endsWith("/")) if (name.endsWith("/"))
f.mkdirs(); assert f.mkdirs();
else if (!f.isFile()) else if (!f.isFile())
Files.copy(jar.getInputStream(je), Paths.get(f.toURI())); Files.copy(jar.getInputStream(je), Paths.get(f.toURI()));
} }
@ -49,7 +49,7 @@ public class SpriteRegister {
} }
private static void unpackDir(File dir) throws IOException { private static void unpackDir(File dir) throws IOException {
for (File f : dir.listFiles()) { for (File f : Objects.requireNonNull(dir.listFiles())) {
if (f.isDirectory()) { if (f.isDirectory()) {
unpackDir(f); unpackDir(f);
continue; continue;
@ -57,9 +57,8 @@ public class SpriteRegister {
String path = f.getAbsolutePath().substring(f.getAbsolutePath().indexOf(File.separatorChar + "assets") + 1); String path = f.getAbsolutePath().substring(f.getAbsolutePath().indexOf(File.separatorChar + "assets") + 1);
File local = new File(path); File local = new File(path);
local.getParentFile().mkdirs(); assert local.getParentFile().mkdirs();
if (local.exists()) assert !local.exists() || local.delete();
local.delete();
Files.copy(Paths.get(f.toURI()), Paths.get(local.toURI())); Files.copy(Paths.get(f.toURI()), Paths.get(local.toURI()));
} }
} }
@ -71,16 +70,16 @@ public class SpriteRegister {
} }
File assetsDir = new File("assets"); File assetsDir = new File("assets");
List<String> assets = new ArrayList<String>(); List<String> assets = new ArrayList<>();
for (File dir : assetsDir.listFiles()) { for (File dir : Objects.requireNonNull(assetsDir.listFiles())) {
assets.add(dir.getName()); assets.add(dir.getName());
} }
for (String asset : assets) { for (String asset : assets) {
try { try {
File f = new File(assetsDir.getAbsolutePath() + "/" + asset + "/textures/sprites"); File f = new File(assetsDir.getAbsolutePath() + "/" + asset + "/textures/sprites");
f.mkdirs(); assert f.mkdirs();
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(f, "sprites.json")))); BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(f, "sprites.json"))));
nameToCoords = new Gson().fromJson(br, Map.class); nameToCoords = new Gson().fromJson(br, Map.class);
br.close(); br.close();
@ -90,7 +89,7 @@ public class SpriteRegister {
BufferedInputStream is = new BufferedInputStream(new FileInputStream(new File(f, key + ".png"))); BufferedInputStream is = new BufferedInputStream(new FileInputStream(new File(f, key + ".png")));
BufferedImage img = ImageIO.read(is); BufferedImage img = ImageIO.read(is);
Category cat = Category.create(key, new ArrayList<String>(nameToCoords.keySet()).indexOf(key), new ArrayList<Sprite>()); Category cat = Category.create(key, new ArrayList<>());
for (List<Double> list : nameToCoords.get(key)) { for (List<Double> list : nameToCoords.get(key)) {
int x = list.get(0).intValue(); int x = list.get(0).intValue();
@ -102,7 +101,6 @@ public class SpriteRegister {
sprites.put(key, cat); sprites.put(key, cat);
} catch (Throwable t) { } catch (Throwable t) {
LogManager.getLogger("SpriteRegister").fatal("Erreur lors de la lecture du sprite '" + key + "'", t); LogManager.getLogger("SpriteRegister").fatal("Erreur lors de la lecture du sprite '" + key + "'", t);
continue;
} }
} }
} catch (IOException e) { } catch (IOException e) {
@ -115,21 +113,8 @@ public class SpriteRegister {
return sprites.get(name); return sprites.get(name);
} }
public static Category getCategory(int index) {
return getCategory(new ArrayList<String>(sprites.keySet()).get(index));
}
public static List<Category> getAllCategories() { public static List<Category> getAllCategories() {
return new ArrayList<Category>(sprites.values()); return new ArrayList<>(sprites.values());
} }
public static List<Sprite> getAllSprites() {
List<Sprite> list = new ArrayList<Sprite>();
for (Category c : sprites.values()) {
list.addAll(c.getSprites());
}
return list;
}
} }

View File

@ -1,6 +1,3 @@
/**
* @author ÿnérant
*/
package fr.ynerant.leveleditor.client.main; package fr.ynerant.leveleditor.client.main;
import fr.ynerant.leveleditor.api.editor.EditorAPI; import fr.ynerant.leveleditor.api.editor.EditorAPI;
@ -33,15 +30,6 @@ import java.util.Map;
* @see #main(String...) * @see #main(String...)
*/ */
public class Main { public class Main {
/**
* Variable disant si le jeu est en d&eacute;bogage ou non. S'active en ins&eacute;rant l'argument --debug dans le lancement.
*
* @see #isInDebugMode()
* @see #main(String...)
* @since 0.1-aplha
*/
private static boolean DEBUG;
/** /**
* Variable disant si le jeu est lanc&eacute; en d&eacute;veloppement ou non. * Variable disant si le jeu est lanc&eacute; en d&eacute;veloppement ou non.
* *
@ -87,7 +75,6 @@ public class Main {
OptionParser parser = new OptionParser(); OptionParser parser = new OptionParser();
OptionSpec<String> edit = parser.accepts("edit", "Lancer l'\u00e9diteur de monde").withOptionalArg(); OptionSpec<String> edit = parser.accepts("edit", "Lancer l'\u00e9diteur de monde").withOptionalArg();
OptionSpec<Boolean> debug = parser.accepts("debug").withOptionalArg().ofType(Boolean.class).defaultsTo(true);
OptionSpec<String> help = parser.accepts("help", "Affiche ce menu d'aide").withOptionalArg().forHelp(); OptionSpec<String> help = parser.accepts("help", "Affiche ce menu d'aide").withOptionalArg().forHelp();
OptionSet set = parser.parse(args); OptionSet set = parser.parse(args);
@ -102,14 +89,6 @@ public class Main {
} }
} }
if (set.has(debug)) {
DEBUG = set.valueOf(debug);
if (DEBUG) {
LOGGER.setLevel(Level.ALL);
}
}
try { try {
SpriteRegister.unpack(); SpriteRegister.unpack();
} catch (IOException | URISyntaxException e) { } catch (IOException | URISyntaxException e) {
@ -165,7 +144,6 @@ public class Main {
/** /**
* Permet de lancer l'&eacute;diteur de carte * Permet de lancer l'&eacute;diteur de carte
* *
* @return
* @see #main(String...) * @see #main(String...)
* @see #launchFrame() * @see #launchFrame()
* @since 0.1-aplha * @since 0.1-aplha
@ -187,8 +165,7 @@ public class Main {
if (baseWidth == 0) if (baseWidth == 0)
return false; return false;
break; break;
} catch (NumberFormatException ex) { } catch (NumberFormatException ignored) {
continue;
} }
} }
@ -203,8 +180,7 @@ public class Main {
if (baseHeight == 0) if (baseHeight == 0)
return false; return false;
break; break;
} catch (NumberFormatException ex) { } catch (NumberFormatException ignored) {
continue;
} }
} }
@ -234,17 +210,6 @@ public class Main {
return true; return true;
} }
/**
* Accesseur disant si le jeu est en d&eacute;bogage ou non. S'active en ins&eacute;rant l'argument --debug dans le lancement.
*
* @see #DEBUG
* @since 0.1-aplha
*/
public static boolean isInDebugMode() {
return DEBUG;
}
/** /**
* Accesseur disant si le jeu est lanc&eacute; en d&eacute;veloppement ou non. * Accesseur disant si le jeu est lanc&eacute; en d&eacute;veloppement ou non.
* *

View File

@ -3,7 +3,4 @@
* *
* @author ÿnérant * @author ÿnérant
*/ */
/**
* @author ÿnérant
*/
package fr.ynerant.leveleditor.client.main; package fr.ynerant.leveleditor.client.main;

View File

@ -17,10 +17,6 @@ public class CollidPanel extends JPanel {
this.frame = frame; this.frame = frame;
} }
public EditorFrame getFrame() {
return frame;
}
public Map getMap() { public Map getMap() {
return frame.getMap(); return frame.getMap();
} }

View File

@ -20,32 +20,23 @@ public class EditorFrame extends JFrame implements ChangeListener, ActionListene
private final Map map; private final Map map;
private final JPanel content = new JPanel();
private final JMenuBar menuBar = new JMenuBar();
private final JMenu fichier = new JMenu("Fichier");
private final JMenu tools = new JMenu("Outils");
private final JMenuItem nouveau = new JMenuItem("Nouveau");
private final JMenuItem open = new JMenuItem("Ouvrir");
private final JMenuItem save = new JMenuItem("Sauvegarder"); private final JMenuItem save = new JMenuItem("Sauvegarder");
private final JMenuItem saveAs = new JMenuItem("Sauvegarder sous ..."); private final JMenuItem saveAs = new JMenuItem("Sauvegarder sous ...");
private final JMenuItem exit = new JMenuItem("Quitter"); private final JMenuItem exit = new JMenuItem("Quitter");
private final JMenu selectionMode = new JMenu("Mode de s\u00e9lection");
private final JRadioButtonMenuItem pen = new JRadioButtonMenuItem("Pinceau"); private final JRadioButtonMenuItem pen = new JRadioButtonMenuItem("Pinceau");
private final JRadioButtonMenuItem pot = new JRadioButtonMenuItem("Pot de peinture"); private final JRadioButtonMenuItem pot = new JRadioButtonMenuItem("Pot de peinture");
private final JTabbedPane tabs = new JTabbedPane(); private final JTabbedPane tabs = new JTabbedPane();
private final JPanel tabEvents = new JPanel();
private final CollidPanel tabColl; private final CollidPanel tabColl;
private final MapPanel mapPanel; private final MapPanel mapPanel;
private final JTabbedPane resources = new JTabbedPane(); private final JTabbedPane resources = new JTabbedPane();
private final JPanel couche1 = new JPanel(); private final JPanel couche1 = new JPanel();
private final JPanel couche2 = new JPanel(); private final JPanel couche2 = new JPanel();
private final JPanel couche3 = new JPanel(); private final JPanel couche3 = new JPanel();
ButtonGroup group = new ButtonGroup(); final ButtonGroup group = new ButtonGroup();
private SpriteComp selectedSprite; private SpriteComp selectedSprite;
public EditorFrame(Map map) { public EditorFrame(Map map) {
super("Alice Game Engine"); super("Level Editor");
this.map = map; this.map = map;
this.setSize(600, 600); this.setSize(600, 600);
this.setPreferredSize(getSize()); this.setPreferredSize(getSize());
@ -53,17 +44,21 @@ public class EditorFrame extends JFrame implements ChangeListener, ActionListene
this.setExtendedState(JFrame.MAXIMIZED_BOTH); this.setExtendedState(JFrame.MAXIMIZED_BOTH);
this.setLocationRelativeTo(null); this.setLocationRelativeTo(null);
this.addWindowListener(this); this.addWindowListener(this);
JPanel content = new JPanel();
content.setLayout(new BorderLayout()); content.setLayout(new BorderLayout());
this.setContentPane(content); this.setContentPane(content);
this.setVisible(true); this.setVisible(true);
this.setVisible(false); this.setVisible(false);
JMenu fichier = new JMenu("Fichier");
fichier.setMnemonic(KeyEvent.VK_F + KeyEvent.ALT_DOWN_MASK); fichier.setMnemonic(KeyEvent.VK_F + KeyEvent.ALT_DOWN_MASK);
JMenuItem nouveau = new JMenuItem("Nouveau");
nouveau.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK, true)); nouveau.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK, true));
nouveau.addActionListener(new CreateMapListener()); nouveau.addActionListener(new CreateMapListener());
fichier.add(nouveau); fichier.add(nouveau);
JMenuItem open = new JMenuItem("Ouvrir");
open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_DOWN_MASK, true)); open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_DOWN_MASK, true));
open.addActionListener(new OpenMapListener()); open.addActionListener(new OpenMapListener());
fichier.add(open); fichier.add(open);
@ -84,6 +79,7 @@ public class EditorFrame extends JFrame implements ChangeListener, ActionListene
exit.addActionListener(this); exit.addActionListener(this);
fichier.add(exit); fichier.add(exit);
JMenuBar menuBar = new JMenuBar();
menuBar.add(fichier); menuBar.add(fichier);
pen.setSelected(true); pen.setSelected(true);
@ -91,9 +87,11 @@ public class EditorFrame extends JFrame implements ChangeListener, ActionListene
pot.addActionListener(this); pot.addActionListener(this);
group.add(pen); group.add(pen);
group.add(pot); group.add(pot);
JMenu selectionMode = new JMenu("Mode de s\u00e9lection");
selectionMode.add(pen); selectionMode.add(pen);
selectionMode.add(pot); selectionMode.add(pot);
JMenu tools = new JMenu("Outils");
tools.setMnemonic(KeyEvent.VK_O + KeyEvent.ALT_DOWN_MASK); tools.setMnemonic(KeyEvent.VK_O + KeyEvent.ALT_DOWN_MASK);
tools.add(selectionMode); tools.add(selectionMode);
@ -118,6 +116,7 @@ public class EditorFrame extends JFrame implements ChangeListener, ActionListene
scrollCollidMap.getVerticalScrollBar().setUnitIncrement(34); scrollCollidMap.getVerticalScrollBar().setUnitIncrement(34);
tabs.addTab("Carte", scrollMap); tabs.addTab("Carte", scrollMap);
JPanel tabEvents = new JPanel();
tabs.addTab("\u00c9vennments", new JScrollPane(tabEvents)); tabs.addTab("\u00c9vennments", new JScrollPane(tabEvents));
tabs.addTab("Collisions", scrollCollidMap); tabs.addTab("Collisions", scrollCollidMap);
tabs.addChangeListener(this); tabs.addChangeListener(this);

View File

@ -14,13 +14,13 @@ public class Map {
@Deprecated @Deprecated
private static List<Case> cases; private static List<Case> cases;
private final EditorFrame frame; private final EditorFrame frame;
private int width; private final int width;
private int height; private final int height;
private java.util.Map<Integer, java.util.Map<Integer, Case>> casesMap = new HashMap<Integer, java.util.Map<Integer, Case>>(); private final java.util.Map<Integer, java.util.Map<Integer, Case>> casesMap = new HashMap<>();
private transient BufferedImage font; private final transient BufferedImage font;
public Map(RawMap raw) { public Map(RawMap raw) {
cases = new ArrayList<Case>(); cases = new ArrayList<>();
this.width = raw.getWidth(); this.width = raw.getWidth();
this.height = raw.getHeight(); this.height = raw.getHeight();
this.font = raw.getFont(); this.font = raw.getFont();
@ -49,7 +49,7 @@ public class Map {
} }
public Case getCase(int x, int y) { public Case getCase(int x, int y) {
return casesMap.getOrDefault(x, new HashMap<Integer, Case>()).get(y); return casesMap.getOrDefault(x, new HashMap<>()).get(y);
} }
public void setCase(int x, int y, Case c) { public void setCase(int x, int y, Case c) {
@ -60,13 +60,9 @@ public class Map {
return font; return font;
} }
public void setFont(BufferedImage font) {
this.font = font;
}
private void reorganizeMap() { private void reorganizeMap() {
for (int i = 0; i < width; ++i) { for (int i = 0; i < width; ++i) {
casesMap.put(i, new HashMap<Integer, Case>()); casesMap.put(i, new HashMap<>());
} }
for (Case c : cases) { for (Case c : cases) {
@ -75,7 +71,7 @@ public class Map {
} }
public List<Case> getAllCases() { public List<Case> getAllCases() {
List<Case> list = new ArrayList<Case>(); List<Case> list = new ArrayList<>();
for (java.util.Map<Integer, Case> l : casesMap.values()) { for (java.util.Map<Integer, Case> l : casesMap.values()) {
list.addAll(l.values()); list.addAll(l.values());

View File

@ -16,10 +16,6 @@ public class MapPanel extends JPanel {
this.frame = frame; this.frame = frame;
} }
public EditorFrame getFrame() {
return frame;
}
public Map getMap() { public Map getMap() {
return frame.getMap(); return frame.getMap();
} }
@ -66,6 +62,7 @@ public class MapPanel extends JPanel {
} }
} }
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean isEmpty(BufferedImage image) { private boolean isEmpty(BufferedImage image) {
int allrgba = 0; int allrgba = 0;

View File

@ -8,8 +8,8 @@ import java.awt.*;
public class SpriteComp extends JComponent { public class SpriteComp extends JComponent {
private static final long serialVersionUID = -6512257366877053285L; private static final long serialVersionUID = -6512257366877053285L;
private Sprite sprite; private final Sprite sprite;
private int couche; private final int couche;
private boolean selected; private boolean selected;
public SpriteComp(Sprite sprite, int couche) { public SpriteComp(Sprite sprite, int couche) {
@ -28,18 +28,10 @@ public class SpriteComp extends JComponent {
return sprite; return sprite;
} }
public void setSprite(Sprite s) {
this.sprite = s;
}
public int getCouche() { public int getCouche() {
return couche; return couche;
} }
public void setCouche(int couche) {
this.couche = couche;
}
public boolean isSelected() { public boolean isSelected() {
return selected; return selected;
} }

View File

@ -6,18 +6,10 @@ import java.awt.*;
public class WrapLayout extends FlowLayout { public class WrapLayout extends FlowLayout {
private static final long serialVersionUID = 8777237960365591646L; private static final long serialVersionUID = 8777237960365591646L;
public WrapLayout() {
super();
}
public WrapLayout(int align) { public WrapLayout(int align) {
super(align); super(align);
} }
public WrapLayout(int align, int hgap, int vgap) {
super(align, hgap, vgap);
}
@Override @Override
public Dimension preferredLayoutSize(Container target) { public Dimension preferredLayoutSize(Container target) {
return layoutSize(target, true); return layoutSize(target, true);

View File

@ -1,6 +1,3 @@
/**
* @author ÿnérant
*/
package fr.ynerant.leveleditor.frame; package fr.ynerant.leveleditor.frame;
import fr.ynerant.leveleditor.client.main.Main; import fr.ynerant.leveleditor.client.main.Main;
@ -22,8 +19,6 @@ import java.awt.event.KeyEvent;
public class MainFrame extends JFrame { public class MainFrame extends JFrame {
/** /**
* ID de s&eacute;rie * ID de s&eacute;rie
*
* @see {@link JFrame}
*/ */
private static final long serialVersionUID = -3168760121879418534L; private static final long serialVersionUID = -3168760121879418534L;
@ -40,18 +35,7 @@ public class MainFrame extends JFrame {
* *
* @see LogManager#getLogger(String) * @see LogManager#getLogger(String)
*/ */
private static Logger LOGGER = (Logger) LogManager.getLogger("MainFrame"); private static final Logger LOGGER = (Logger) LogManager.getLogger("MainFrame");
private JMenuBar menuBar = new JMenuBar();
private JMenu fichier = new JMenu("Fichier");
private JMenu display = new JMenu("Affichage");
private JMenu editMaps = new JMenu("Cartes");
private JMenu changeLAF = new JMenu("Modfier l'apparence");
private JMenuItem createMap = new JMenuItem("Cr\u00e9er");
private JMenuItem openMap = new JMenuItem("Ouvrir");
private JMenuItem systemLAF = new JMenuItem("Apparence syst\u00e8me");
private JMenuItem javaLAF = new JMenuItem("Apparence Java");
private JMenuItem darkLAF = new JMenuItem("Apparence sombre");
/** /**
* Constructeur * Constructeur
@ -69,25 +53,35 @@ public class MainFrame extends JFrame {
this.setExtendedState(JFrame.MAXIMIZED_BOTH); this.setExtendedState(JFrame.MAXIMIZED_BOTH);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenu fichier = new JMenu("Fichier");
fichier.setMnemonic(KeyEvent.VK_F + KeyEvent.ALT_DOWN_MASK); fichier.setMnemonic(KeyEvent.VK_F + KeyEvent.ALT_DOWN_MASK);
JMenu display = new JMenu("Affichage");
display.setMnemonic(KeyEvent.VK_A + KeyEvent.ALT_DOWN_MASK); display.setMnemonic(KeyEvent.VK_A + KeyEvent.ALT_DOWN_MASK);
JMenuItem createMap = new JMenuItem("Cr\u00e9er");
createMap.addActionListener(new CreateMapListener()); createMap.addActionListener(new CreateMapListener());
JMenu editMaps = new JMenu("Cartes");
editMaps.add(createMap); editMaps.add(createMap);
JMenuItem openMap = new JMenuItem("Ouvrir");
openMap.addActionListener(new OpenMapListener()); openMap.addActionListener(new OpenMapListener());
editMaps.add(openMap); editMaps.add(openMap);
fichier.add(editMaps); fichier.add(editMaps);
JMenuItem systemLAF = new JMenuItem("Apparence syst\u00e8me");
systemLAF.addActionListener(new ChangeLAFListener(systemLAF, this)); systemLAF.addActionListener(new ChangeLAFListener(systemLAF, this));
JMenu changeLAF = new JMenu("Modfier l'apparence");
changeLAF.add(systemLAF); changeLAF.add(systemLAF);
JMenuItem javaLAF = new JMenuItem("Apparence Java");
javaLAF.addActionListener(new ChangeLAFListener(javaLAF, this)); javaLAF.addActionListener(new ChangeLAFListener(javaLAF, this));
changeLAF.add(javaLAF); changeLAF.add(javaLAF);
JMenuItem darkLAF = new JMenuItem("Apparence sombre");
darkLAF.addActionListener(new ChangeLAFListener(darkLAF, this)); darkLAF.addActionListener(new ChangeLAFListener(darkLAF, this));
changeLAF.add(darkLAF); changeLAF.add(darkLAF);
display.add(changeLAF); display.add(changeLAF);
JMenuBar menuBar = new JMenuBar();
menuBar.add(fichier); menuBar.add(fichier);
menuBar.add(display); menuBar.add(display);

View File

@ -28,7 +28,7 @@ public class CollidMapMouseListener extends MouseAdapter {
int x = panel.getWidth() / 2 - map.getFont().getWidth(); int x = panel.getWidth() / 2 - map.getFont().getWidth();
int y = panel.getHeight() / 2 - map.getFont().getHeight(); int y = panel.getHeight() / 2 - map.getFont().getHeight();
Case c = null; Case c;
if ((c = map.getCase((event.getX() - x + 2) / 34, (event.getY() - y + 2) / 34)) != null && event.getX() - x >= 2 && event.getY() - y >= 2) { if ((c = map.getCase((event.getX() - x + 2) / 34, (event.getY() - y + 2) / 34)) != null && event.getX() - x >= 2 && event.getY() - y >= 2) {
int colIndex = c.getCollision().ordinal(); int colIndex = c.getCollision().ordinal();

View File

@ -1,6 +1,3 @@
/**
* @author ÿnérant
*/
package fr.ynerant.leveleditor.frame.listeners; package fr.ynerant.leveleditor.frame.listeners;
import fr.ynerant.leveleditor.client.main.Main; import fr.ynerant.leveleditor.client.main.Main;

View File

@ -28,7 +28,7 @@ public class MapMouseListener extends MouseAdapter {
int x = panel.getWidth() / 2 - map.getFont().getWidth(); int x = panel.getWidth() / 2 - map.getFont().getWidth();
int y = panel.getHeight() / 2 - map.getFont().getHeight(); int y = panel.getHeight() / 2 - map.getFont().getHeight();
Case c = null; Case c;
if ((c = map.getCase((event.getX() - x + 2) / 34, (event.getY() - y + 2) / 34)) != null && event.getX() - x >= 2 && event.getY() - y >= 2) { if ((c = map.getCase((event.getX() - x + 2) / 34, (event.getY() - y + 2) / 34)) != null && event.getX() - x >= 2 && event.getY() - y >= 2) {
if (getFrame().getSelectedSprite() != null) { if (getFrame().getSelectedSprite() != null) {