Implemented window resizing for the lulz
Target size is static for the time being
This commit is contained in:
		@@ -19,6 +19,8 @@ public class ApplicationFrame implements Runnable
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private JList<File> filelist;
 | 
					    private JList<File> filelist;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Dimension menuDimension = new Dimension(640, 395);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private KeyListener keyHandler = new Control.KeyHandler();
 | 
					    private KeyListener keyHandler = new Control.KeyHandler();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private class ListMouseHandler extends MouseAdapter{
 | 
					    private class ListMouseHandler extends MouseAdapter{
 | 
				
			||||||
@@ -41,7 +43,7 @@ public class ApplicationFrame implements Runnable
 | 
				
			|||||||
    public void init(){
 | 
					    public void init(){
 | 
				
			||||||
        jframe = new JFrame();
 | 
					        jframe = new JFrame();
 | 
				
			||||||
        jframe.setFocusable(true);
 | 
					        jframe.setFocusable(true);
 | 
				
			||||||
        jframe.setMinimumSize(new Dimension(640, 395));
 | 
					        jframe.setMinimumSize(new Dimension(menuDimension));
 | 
				
			||||||
        jframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
 | 
					        jframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        initMapselector();
 | 
					        initMapselector();
 | 
				
			||||||
@@ -54,6 +56,8 @@ public class ApplicationFrame implements Runnable
 | 
				
			|||||||
        jframe.removeKeyListener(keyHandler);
 | 
					        jframe.removeKeyListener(keyHandler);
 | 
				
			||||||
        initMapselector();
 | 
					        initMapselector();
 | 
				
			||||||
        jframe.add(mapselectorpanel);
 | 
					        jframe.add(mapselectorpanel);
 | 
				
			||||||
 | 
					        jframe.setMinimumSize(menuDimension);
 | 
				
			||||||
 | 
					        jframe.pack();
 | 
				
			||||||
        jframe.revalidate();
 | 
					        jframe.revalidate();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -111,6 +115,8 @@ public class ApplicationFrame implements Runnable
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    private void setGameParams(File dungeonFile) throws IOException {
 | 
					    private void setGameParams(File dungeonFile) throws IOException {
 | 
				
			||||||
        gamepanel = new Display();
 | 
					        gamepanel = new Display();
 | 
				
			||||||
 | 
					        jframe.setMinimumSize(gamepanel.getDimension());
 | 
				
			||||||
 | 
					        jframe.pack();
 | 
				
			||||||
        jframe.addKeyListener(keyHandler);
 | 
					        jframe.addKeyListener(keyHandler);
 | 
				
			||||||
        Game.instance.setDisplay(gamepanel);
 | 
					        Game.instance.setDisplay(gamepanel);
 | 
				
			||||||
        Game.instance.setDungeon(new Dungeon());
 | 
					        Game.instance.setDungeon(new Dungeon());
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
package cicaprojekt;
 | 
					package cicaprojekt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.awt.Graphics;
 | 
					import java.awt.*;
 | 
				
			||||||
import java.io.File;
 | 
					import java.io.File;
 | 
				
			||||||
import java.io.IOException;
 | 
					import java.io.IOException;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
@@ -15,6 +15,8 @@ public class Display extends JPanel{
 | 
				
			|||||||
    private List<Drawer> visuals;
 | 
					    private List<Drawer> visuals;
 | 
				
			||||||
    private Clip clip;
 | 
					    private Clip clip;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Dimension dimension = new Dimension(64*5, 64*5);  //TODO make this dependent on dungeon size
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    public Display() {
 | 
					    public Display() {
 | 
				
			||||||
        visuals = new ArrayList<>();
 | 
					        visuals = new ArrayList<>();
 | 
				
			||||||
        setVisible(false);
 | 
					        setVisible(false);
 | 
				
			||||||
@@ -25,6 +27,8 @@ public class Display extends JPanel{
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    public void drawVisuals() throws IOException {
 | 
					    public void drawVisuals() throws IOException {
 | 
				
			||||||
 | 
					        setPreferredSize(dimension);
 | 
				
			||||||
 | 
					        setMinimumSize(dimension);
 | 
				
			||||||
        for(Drawer visual : visuals)
 | 
					        for(Drawer visual : visuals)
 | 
				
			||||||
            visual.draw();
 | 
					            visual.draw();
 | 
				
			||||||
        repaint();
 | 
					        repaint();
 | 
				
			||||||
@@ -62,4 +66,8 @@ public class Display extends JPanel{
 | 
				
			|||||||
            Control.ioErrorMessage();
 | 
					            Control.ioErrorMessage();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Dimension getDimension() {
 | 
				
			||||||
 | 
					        return dimension;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user