From 11a8931f6baf668e91462afd6e60a3ed2def9743 Mon Sep 17 00:00:00 2001 From: galaxyoyo Date: Thu, 8 Jan 2015 22:53:02 +0100 Subject: [PATCH] =?UTF-8?q?Fen=C3=AAtre=20d'=C3=A9dition=20am=C3=A9lior?= =?UTF-8?q?=C3=A9e=20(non=20termin=C3=A9e)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/editor/sprites/SpriteRegister.java | 12 ++ .../galaxyoyo/unknown/editor/EditorFrame.java | 146 ++++++++++++------ 2 files changed, 115 insertions(+), 43 deletions(-) diff --git a/src/main/java/galaxyoyo/unknown/api/editor/sprites/SpriteRegister.java b/src/main/java/galaxyoyo/unknown/api/editor/sprites/SpriteRegister.java index 777aed1..07938aa 100644 --- a/src/main/java/galaxyoyo/unknown/api/editor/sprites/SpriteRegister.java +++ b/src/main/java/galaxyoyo/unknown/api/editor/sprites/SpriteRegister.java @@ -76,4 +76,16 @@ public class SpriteRegister { return getCategory(new ArrayList(sprites.keySet()).get(index)); } + + public static List getAll() + { + List list = new ArrayList(); + + for (List l : sprites.values()) + { + list.addAll(l); + } + + return list; + } } diff --git a/src/main/java/galaxyoyo/unknown/editor/EditorFrame.java b/src/main/java/galaxyoyo/unknown/editor/EditorFrame.java index 93c078d..1bf22ea 100644 --- a/src/main/java/galaxyoyo/unknown/editor/EditorFrame.java +++ b/src/main/java/galaxyoyo/unknown/editor/EditorFrame.java @@ -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(); - } - - @Override - public void componentHidden(ComponentEvent event) - { - } - - @Override - public void componentMoved(ComponentEvent event) - { - componentShown(event); - } - - @Override - public void componentResized(ComponentEvent event) - { - componentShown(event); - } - - @Override - public void componentShown(ComponentEvent event) - { - revalidate(); - } - - @Override - public void revalidate() - { - 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(); + 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 paramComponentEvent) + { + } + + @Override + public void componentMoved(ComponentEvent paramComponentEvent) + { + } + + @Override + public void componentResized(ComponentEvent paramComponentEvent) + { + 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 paramComponentEvent) + { + } + + @Override + public void mouseClicked(MouseEvent paramMouseEvent) + { + this.componentResized(null); + } + + @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); } }