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