Fenêtre d'édition améliorée (non terminée)

This commit is contained in:
galaxyoyo 2015-01-08 22:53:02 +01:00
parent 71362d1f27
commit 11a8931f6b
2 changed files with 115 additions and 43 deletions

View File

@ -76,4 +76,16 @@ public class SpriteRegister
{
return getCategory(new ArrayList<String>(sprites.keySet()).get(index));
}
public static List<Sprite> getAll()
{
List<Sprite> list = new ArrayList<Sprite>();
for (List<Sprite> l : sprites.values())
{
list.addAll(l);
}
return list;
}
}

View File

@ -1,13 +1,23 @@
package galaxyoyo.unknown.editor;
import galaxyoyo.unknown.api.editor.sprites.Sprite;
import galaxyoyo.unknown.api.editor.sprites.SpriteRegister;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
public class EditorFrame extends JFrame implements ComponentListener
public class EditorFrame extends JFrame implements ComponentListener, MouseListener, ChangeListener
{
private static final long serialVersionUID = -2705122356101556462L;
@ -35,60 +45,110 @@ public class EditorFrame extends JFrame implements ComponentListener
this.setLocationRelativeTo(null);
this.setContentPane(content);
this.addComponentListener(this);
revalidate();
repaint();
tabs.addTab("Carte", new JPanel());
tabs.addTab("\u00c9vennements", tabEvents);
tabs.addTab("Collisions", tabColl);
tabs.addMouseListener(this);
tabs.addChangeListener(this);
content.add(tabs);
content.add(mapPanel);
resources.addTab("1", couche1);
resources.addTab("2", couche2);
resources.addTab("3", couche3);
resources.addTab("1", new JScrollPane(couche1, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER));
resources.addTab("2", new JScrollPane(couche2, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER));
resources.addTab("3", new JScrollPane(couche3, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER));
resources.addMouseListener(this);
resources.addChangeListener(this);
content.add(resources);
revalidate();
repaint();
this.componentResized(null);
drawResources();
}
private void drawResources()
{
JScrollPane scroll1 = (JScrollPane) resources.getComponentAt(1);
JScrollPane scroll2 = (JScrollPane) resources.getComponentAt(2);
JScrollPane scroll3 = (JScrollPane) resources.getComponentAt(3);
scroll1.getHorizontalScrollBar().setMaximum(0);
scroll2.getHorizontalScrollBar().setMaximum(0);
scroll3.getHorizontalScrollBar().setMaximum(0);
couche1.setBackground(Color.white);
couche2.setBackground(Color.white);
couche3.setBackground(Color.white);
for (Sprite spr : SpriteRegister.getAll())
{
}
}
@Override
public void componentHidden(ComponentEvent event)
public void componentHidden(ComponentEvent paramComponentEvent)
{
}
@Override
public void componentMoved(ComponentEvent event)
public void componentMoved(ComponentEvent paramComponentEvent)
{
componentShown(event);
}
@Override
public void componentResized(ComponentEvent event)
public void componentResized(ComponentEvent paramComponentEvent)
{
componentShown(event);
tabs.setPreferredSize(new Dimension(getWidth(), getHeight() / 5));
tabs.setLocation(0, 0);
mapPanel.setPreferredSize(new Dimension(getWidth() / 4 * 3, getHeight() / 5 * 4));
mapPanel.setLocation(0, getHeight() / 5);
resources.setPreferredSize(new Dimension(getWidth() / 4, getHeight() / 5 * 4));
resources.setLocation(getWidth() / 4 * 3, getHeight() / 5);
}
@Override
public void componentShown(ComponentEvent event)
public void componentShown(ComponentEvent paramComponentEvent)
{
revalidate();
}
@Override
public void revalidate()
public void mouseClicked(MouseEvent paramMouseEvent)
{
tabs.setBounds(0, 0, getWidth(), getHeight() / 5);
mapPanel.setBounds(0, getWidth() / 5, getWidth() / 4 * 3, getHeight() / 5 * 4);
resources.setBounds(getWidth() / 4 * 3, getHeight() / 5, getWidth() / 4, getHeight() / 5 * 4);
this.componentResized(null);
}
tabs.revalidate();
mapPanel.revalidate();
resources.revalidate();
super.revalidate();
@Override
public void mouseEntered(MouseEvent paramMouseEvent)
{
this.componentResized(null);
}
@Override
public void mouseExited(MouseEvent paramMouseEvent)
{
this.componentResized(null);
}
@Override
public void mousePressed(MouseEvent paramMouseEvent)
{
this.componentResized(null);
}
@Override
public void mouseReleased(MouseEvent paramMouseEvent)
{
this.componentResized(null);
}
@Override
public void stateChanged(ChangeEvent paramChangeEvent)
{
this.componentResized(null);
}
}