diff --git a/img.png b/img.png new file mode 100644 index 0000000..1b41e9c Binary files /dev/null and b/img.png differ diff --git a/src/main/java/galaxyoyo/unknown/client/main/Main.java b/src/main/java/galaxyoyo/unknown/client/main/Main.java index ac2b11e..10dad62 100644 --- a/src/main/java/galaxyoyo/unknown/client/main/Main.java +++ b/src/main/java/galaxyoyo/unknown/client/main/Main.java @@ -5,8 +5,15 @@ package galaxyoyo.unknown.client.main; import galaxyoyo.unknown.frame.MainFrame; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.io.File; import java.io.IOException; +import javax.imageio.ImageIO; +import javax.swing.JOptionPane; + import joptsimple.OptionParser; import joptsimple.OptionSet; import joptsimple.OptionSpec; @@ -123,6 +130,68 @@ public class Main private static void launchEditMode() { System.out.println("Lancement de l'\u00e9diteur de monde ..."); + int baseWidth; + int baseHeight; + int width; + int height; + while (true) + { + try + { + baseWidth = Integer.parseInt(JOptionPane.showInputDialog("Veuillez entrez le nombre de cases longueur de votre carte :")) * 16; + if (baseWidth <= 0) + throw new NumberFormatException(); + break; + } + catch (NumberFormatException ex) + { + continue; + } + } + + while (true) + { + try + { + baseHeight = Integer.parseInt(JOptionPane.showInputDialog("Veuillez entrez le nombre de cases hauteur de votre carte :")) * 16; + if (baseHeight <= 0) + throw new NumberFormatException(); + break; + } + catch (NumberFormatException ex) + { + continue; + } + } + + width = baseWidth + ((int) baseWidth / 16) + 1; + height = baseHeight + ((int) baseHeight / 16) + 1; + + BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + Graphics2D g = image.createGraphics(); + g.setColor(Color.white); + g.fillRect(0, 0, width, height); + g.setColor(Color.black); + g.drawLine(0, 0, width, 0); + g.drawLine(0, 0, 0, height); + for (int x = 17; x <= width; x += 17) + { + g.drawLine(x, 0, x, height); + } + + for (int y = 17; y <= height; y += 17) + { + g.drawLine(0, y, width, y); + } + + try + { + ImageIO.write(image, "png", new File("img.png")); + } + catch (IOException e) + { + e.printStackTrace(); + } } /** diff --git a/src/main/java/galaxyoyo/unknown/frame/MainFrame.java b/src/main/java/galaxyoyo/unknown/frame/MainFrame.java index bfd8bb8..2c60fee 100644 --- a/src/main/java/galaxyoyo/unknown/frame/MainFrame.java +++ b/src/main/java/galaxyoyo/unknown/frame/MainFrame.java @@ -3,7 +3,7 @@ */ package galaxyoyo.unknown.frame; -import galaxyoyo.unknown.frame.listeners.EditMapsListener; +import galaxyoyo.unknown.frame.listeners.CreateMapListener; import java.awt.Dimension; @@ -43,7 +43,9 @@ public class MainFrame extends JFrame private JMenuBar menuBar = new JMenuBar(); private JMenu fichier = new JMenu("Fichier"); private JMenu editer = new JMenu("\u00c9diter"); - private JMenuItem editMaps = new JMenuItem("Cartes"); + private JMenu editMaps = new JMenu("Cartes"); + private JMenuItem createMap = new JMenuItem("Cr\u00e9er"); + private JMenuItem editMap = new JMenuItem("\u00c9diter"); /** * Constructeur @@ -62,7 +64,9 @@ public class MainFrame extends JFrame menuBar.add(fichier); - editMaps.addActionListener(new EditMapsListener()); + createMap.addActionListener(new CreateMapListener()); + editMaps.add(createMap); + editMaps.add(editMap); editer.add(editMaps); menuBar.add(editer); diff --git a/src/main/java/galaxyoyo/unknown/frame/listeners/EditMapsListener.java b/src/main/java/galaxyoyo/unknown/frame/listeners/CreateMapListener.java similarity index 81% rename from src/main/java/galaxyoyo/unknown/frame/listeners/EditMapsListener.java rename to src/main/java/galaxyoyo/unknown/frame/listeners/CreateMapListener.java index eb0dae7..6e394c8 100644 --- a/src/main/java/galaxyoyo/unknown/frame/listeners/EditMapsListener.java +++ b/src/main/java/galaxyoyo/unknown/frame/listeners/CreateMapListener.java @@ -11,12 +11,12 @@ import java.awt.event.ActionListener; /** * @author galaxyoyo */ -public class EditMapsListener implements ActionListener +public class CreateMapListener implements ActionListener { /** * */ - public EditMapsListener() + public CreateMapListener() { } diff --git a/src/main/resources/assets/unknown/textures/tiles/gazon.png b/src/main/resources/assets/unknown/textures/tiles/gazon.png new file mode 100644 index 0000000..8d95b91 Binary files /dev/null and b/src/main/resources/assets/unknown/textures/tiles/gazon.png differ