Show text in Dialog Menu
This commit is contained in:
parent
87338c9484
commit
4621e60fc6
@ -8,7 +8,7 @@ public class WindowOfFreeMove extends JFrame {
|
||||
static final int CANVAS_WIDTH = 20;
|
||||
static final int CANVAS_HEIGHT = 20;
|
||||
|
||||
private static boolean isMoveablePerson;
|
||||
private static boolean canPersonMove;
|
||||
|
||||
static final int KEY_LEFT = 37;
|
||||
static final int KEY_UP = 38;
|
||||
@ -20,19 +20,32 @@ public class WindowOfFreeMove extends JFrame {
|
||||
private JLayeredPane lp;
|
||||
private static Map map;
|
||||
|
||||
public static Map getMap() { return map; }
|
||||
public static JPanel getDialogBar() { return dialogBar; }
|
||||
|
||||
public static void setIsMoveablePerson(boolean isMoveablePerson) {
|
||||
WindowOfFreeMove.isMoveablePerson = isMoveablePerson;
|
||||
public static Map getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public static void setDialogBar(JPanel dialogBar) { WindowOfFreeMove.dialogBar = dialogBar; }
|
||||
public static void setMap(Map map){ WindowOfFreeMove.map = map; }
|
||||
public static void paintMapOnWindow() {WindowOfFreeMove.map.createMap();}
|
||||
public static JPanel getDialogBar() {
|
||||
return dialogBar;
|
||||
}
|
||||
|
||||
public static void setCanPersonMove(boolean canPersonMove) {
|
||||
WindowOfFreeMove.canPersonMove = canPersonMove;
|
||||
}
|
||||
|
||||
public static void setDialogBar(JPanel dialogBar) {
|
||||
WindowOfFreeMove.dialogBar = dialogBar;
|
||||
}
|
||||
|
||||
public static void setMap(Map map) {
|
||||
WindowOfFreeMove.map = map;
|
||||
}
|
||||
|
||||
public static void paintMapOnWindow() {
|
||||
WindowOfFreeMove.map.createMap();
|
||||
}
|
||||
|
||||
public WindowOfFreeMove() {
|
||||
isMoveablePerson = true;
|
||||
canPersonMove = true;
|
||||
lp = getLayeredPane();
|
||||
|
||||
canvas = new Canvas();
|
||||
@ -50,17 +63,18 @@ public class WindowOfFreeMove extends JFrame {
|
||||
addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (isMoveablePerson)
|
||||
if (canPersonMove)
|
||||
map.getPerson().setDirection(e.getKeyCode());
|
||||
}
|
||||
});
|
||||
|
||||
lp.add(dialogBar, JLayeredPane.PALETTE_LAYER);
|
||||
lp.add(canvas, JLayeredPane.PALETTE_LAYER);
|
||||
lp.add(dialogBar, JLayeredPane.POPUP_LAYER);
|
||||
|
||||
|
||||
setTitle("Ahoj");
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
setBounds(0,0,CELL_SIZE*CANVAS_WIDTH + 15, CELL_SIZE*CANVAS_HEIGHT + 40);
|
||||
setBounds(0, 0, CELL_SIZE * CANVAS_WIDTH, CELL_SIZE * CANVAS_HEIGHT);
|
||||
setLocationRelativeTo(null);
|
||||
setResizable(true);
|
||||
setVisible(true);
|
||||
@ -71,7 +85,7 @@ public class WindowOfFreeMove extends JFrame {
|
||||
public void start() {
|
||||
Map m1 = new Map(CANVAS_HEIGHT, CANVAS_WIDTH, true);
|
||||
m1.setName("1");
|
||||
m1.setSpawnPoint(12,12);
|
||||
m1.setSpawnPoint(1, 1);
|
||||
Map m2 = new Map(CANVAS_HEIGHT, CANVAS_WIDTH, false);
|
||||
m2.setName("2");
|
||||
Map m3 = new Map(CANVAS_HEIGHT, CANVAS_WIDTH, true);
|
||||
@ -95,6 +109,30 @@ public class WindowOfFreeMove extends JFrame {
|
||||
setMap(m1);
|
||||
map.createMap();
|
||||
|
||||
lp.remove(dialogBar);
|
||||
|
||||
|
||||
JPanel jf = new JPanel() {
|
||||
Font f = new Font("Times New Roman", Font.ITALIC, 50);
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
g.setColor(Color.green);
|
||||
g.setFont(f);
|
||||
g.drawString("> Test", 10, 50);
|
||||
}
|
||||
};
|
||||
|
||||
jf.setBounds(0, WindowOfFreeMove.CELL_SIZE * WindowOfFreeMove.CANVAS_HEIGHT * 3 / 4, WindowOfFreeMove.CELL_SIZE * WindowOfFreeMove.CANVAS_WIDTH, WindowOfFreeMove.CELL_SIZE * WindowOfFreeMove.CANVAS_HEIGHT / 4);
|
||||
jf.setBackground(Color.BLACK);
|
||||
jf.setVisible(false);
|
||||
|
||||
setDialogBar(jf);
|
||||
dialogBar.setVisible(true);
|
||||
lp.add(jf, JLayeredPane.POPUP_LAYER);
|
||||
|
||||
|
||||
while (true) {
|
||||
map.getPerson().move();
|
||||
canvas.repaint();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user