Ajouté modes de sélection : pinceau (linéaire/ponctuel) + pot de
peinture (remplir)
This commit is contained in:
parent
9e98b7546b
commit
1c2d673bec
|
@ -21,6 +21,7 @@ import java.awt.event.WindowEvent;
|
||||||
import java.awt.event.WindowListener;
|
import java.awt.event.WindowListener;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
import javax.swing.ButtonGroup;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JMenu;
|
import javax.swing.JMenu;
|
||||||
|
@ -28,6 +29,7 @@ import javax.swing.JMenuBar;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JRadioButtonMenuItem;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTabbedPane;
|
import javax.swing.JTabbedPane;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
@ -51,6 +53,9 @@ public class EditorFrame extends JFrame implements ChangeListener, ActionListene
|
||||||
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 JMenu selectionMode = new JMenu("Mode de s\u00e9lection");
|
||||||
|
ButtonGroup group = new ButtonGroup();
|
||||||
|
private final JRadioButtonMenuItem pen = new JRadioButtonMenuItem("Pinceau");
|
||||||
|
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 JPanel tabEvents = new JPanel();
|
||||||
private final CollidPanel tabColl;
|
private final CollidPanel tabColl;
|
||||||
|
@ -103,6 +108,14 @@ public class EditorFrame extends JFrame implements ChangeListener, ActionListene
|
||||||
|
|
||||||
menuBar.add(fichier);
|
menuBar.add(fichier);
|
||||||
|
|
||||||
|
pen.setSelected(true);
|
||||||
|
pen.addActionListener(this);
|
||||||
|
pot.addActionListener(this);
|
||||||
|
group.add(pen);
|
||||||
|
group.add(pot);
|
||||||
|
selectionMode.add(pen);
|
||||||
|
selectionMode.add(pot);
|
||||||
|
|
||||||
tools.setMnemonic(KeyEvent.VK_O + KeyEvent.ALT_DOWN_MASK);
|
tools.setMnemonic(KeyEvent.VK_O + KeyEvent.ALT_DOWN_MASK);
|
||||||
|
|
||||||
tools.add(selectionMode);
|
tools.add(selectionMode);
|
||||||
|
@ -204,6 +217,7 @@ public class EditorFrame extends JFrame implements ChangeListener, ActionListene
|
||||||
couche2.repaint();
|
couche2.repaint();
|
||||||
couche3.repaint();
|
couche3.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resize()
|
public void resize()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -313,6 +327,11 @@ public class EditorFrame extends JFrame implements ChangeListener, ActionListene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSelectedPaintingMode()
|
||||||
|
{
|
||||||
|
return pen.isSelected() ? 0 : pot.isSelected() ? 1 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowActivated(WindowEvent event)
|
public void windowActivated(WindowEvent event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,9 @@ public class MapMouseListener extends MouseAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent event)
|
public void mouseClicked(MouseEvent event)
|
||||||
|
{
|
||||||
|
if (frame.getSelectedPaintingMode() == 0)
|
||||||
{
|
{
|
||||||
Map map = getFrame().getMap();
|
Map map = getFrame().getMap();
|
||||||
|
|
||||||
|
@ -50,9 +52,46 @@ public class MapMouseListener extends MouseAdapter
|
||||||
default : n = c; break;
|
default : n = c; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
map.setCase((event.getX() - x + 2) / 34, (event.getY() - y + 2) / 34, n);
|
map.setCase(n.getPosX(), n.getPosY(), n);
|
||||||
panel.repaint();
|
panel.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (frame.getSelectedPaintingMode() == 1)
|
||||||
|
{
|
||||||
|
for (Case c : getFrame().getMap().getAllCases())
|
||||||
|
{
|
||||||
|
Map map = getFrame().getMap();
|
||||||
|
|
||||||
|
if (getFrame().getSelectedSprite() != null)
|
||||||
|
{
|
||||||
|
if (getFrame().getSelectedSprite().getCouche() - 1 > getFrame().getSelectedLayerIndex())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Case n;
|
||||||
|
|
||||||
|
switch (getFrame().getSelectedSprite().getCouche())
|
||||||
|
{
|
||||||
|
case 0 : n = Case.create(c.getPosX(), c.getPosY(), getFrame().getSelectedSprite().getSprite(), c.getCoucheTwo(), c.getCoucheThree(), c.getCollision()); break;
|
||||||
|
case 1 : n = Case.create(c.getPosX(), c.getPosY(), c.getCoucheOne(), getFrame().getSelectedSprite().getSprite(), c.getCoucheThree(), c.getCollision()); break;
|
||||||
|
case 2 : n = Case.create(c.getPosX(), c.getPosY(), c.getCoucheOne(), c.getCoucheTwo(), getFrame().getSelectedSprite().getSprite(), c.getCollision()); break;
|
||||||
|
default : n = c; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
map.setCase(n.getPosX(), n.getPosY(), n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
panel.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseDragged(MouseEvent event)
|
||||||
|
{
|
||||||
|
if (frame.getSelectedPaintingMode() == 0)
|
||||||
|
{
|
||||||
|
mouseClicked(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue