-
Notifications
You must be signed in to change notification settings - Fork 0
/
LevelSelect.java
136 lines (116 loc) · 5.29 KB
/
LevelSelect.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import java.awt.*;
import javax.swing.*;
//import legacy.Debug;
public class LevelSelect extends JPanel {
JButton settingsButton, backButton, nextButton, enterButton, directoryButton/* , editorButton */;
JLabel info;
Image board;
Image bg;
Graphics2D g2D;
JButton button;
int mapButton_Type = 0;
int activeButton = -1;
boolean isTest = false;
int map = 0, unlocked = 0;
public LevelSelect() {
Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
// editorButton = new JButton("Editor");
// editorButton.setBounds(1170, 810, 100, 40);
// editorButton.setFocusable(true);
// editorButton.addActionListener((e) -> {
// this.setVisible(false);
// GameFrame.newEditor();
// Sound.playSfx(0);
// });
this.setBackground(Color.BLACK);
directoryButton = new JButton("Directory");
directoryButton.setBounds((int) size.getWidth() - 210, 10, 100, 40);
directoryButton.setFocusable(true);
directoryButton.addActionListener((e) -> {
this.setVisible(false);
GameFrame.directory.setVisible(true);
GameFrame.directory.displayButtons();
Sound.playSfx(0);
});
//settingsbutton
ImageIcon icon = new ImageIcon("Assets\\settings.png");
Image scaleImage = icon.getImage().getScaledInstance(40, 40, Image.SCALE_DEFAULT);
icon = new ImageIcon(scaleImage); // dw
settingsButton = new JButton();
settingsButton.setIcon(icon);
settingsButton.setBounds((int) size.getWidth() - 100, 10, 40, 40);
settingsButton.setFocusable(true);
settingsButton.addActionListener((e) -> {
this.setVisible(false);
GameFrame.settings.setVisible(true);
Sound.playSfx(0);
});
backButton = new JButton();
backButton.setIcon((new ImageIcon("Assets\\leftScrollButton.png")));
backButton.setBackground(Color.BLACK);
// backButton.setBorder(BorderFactory.createEmptyBorder(4, 4, 2, 20));
backButton.setBounds(((int) (size.getWidth() - 700)/2) - 100, 350, 80, 240);
backButton.setVisible(false);
backButton.addActionListener((e) -> {
this.map--;
info.setText("Level " + map);
// info.setIcon(new ImageIcon("Assets\\"+Bson.extractClassInfo(Bson.getClass(Integer.toString(map), "Saves\\Levels.txt"))[3]+"stars.png"));
info.setIcon(new ImageIcon("Assets\\"+Bson.extractClassInfo(Bson.getClass("Map" + map, "Saves\\Levels.txt"))[3]+"stars.png"));
if (this.map == 1) backButton.setVisible(false);
nextButton.setVisible(true);
enterButton.setText(String.valueOf(this.map));
Sound.playSfx(0);
});
nextButton = new JButton();
nextButton.setIcon((new ImageIcon("Assets\\rightScrollButton.png")));
nextButton.setBackground(Color.BLACK);
nextButton.setBounds(((int) (size.getWidth() - 700)/2) + 720, 350, 80, 240);
nextButton.setVisible(false);
nextButton.addActionListener((e) -> {
this.map++;
// Debug.print("Assets\\"+Bson.extractClassInfo(Bson.getClass(Integer.toString(map), "Saves\\Levels.txt"))[3]+"stars.png");
info.setText("Level " + map);
// info.setIcon(new ImageIcon("Assets\\"+Bson.extractClassInfo(Bson.getClass(Integer.toString(map), "Saves\\Levels.txt"))[3]+"stars.png"));
info.setIcon(new ImageIcon("Assets\\"+Bson.extractClassInfo(Bson.getClass("Map" + map, "Saves\\Levels.txt"))[3]+"stars.png"));
if (this.map == this.unlocked) nextButton.setVisible(false);
backButton.setVisible(true);
enterButton.setText(String.valueOf(this.map));
Sound.playSfx(0);
});
enterButton = new JButton("0");
enterButton.setBounds((int) (size.getWidth() - 700)/2, 250, 700, 400);
enterButton.addActionListener((e) -> {
GameFrame.newGame(this.map);
Sound.playSfx(0);
});
info = new JLabel("Level " + (map + 1), SwingConstants.CENTER);
info.setBounds((int) (size.getWidth()-300)/2, 700, 300, 60);
info.setFont(new Font("ocr a extended", Font.PLAIN, 15));
// info.setIcon(new ImageIcon("Assets\\"+Bson.extractClassInfo(Bson.getClass(Integer.toString(map + 1), "Saves\\Levels.txt"))[3]+"stars.png"));
info.setIcon(new ImageIcon("Assets\\"+Bson.extractClassInfo(Bson.getClass("Map" + Integer.toString(map + 1), "Saves\\Levels.txt"))[3]+"stars.png"));
info.setForeground(Color.WHITE);
info.setOpaque(true);
info.setBackground(Color.BLACK);
info.setVisible(true);
info.setVerticalAlignment(SwingConstants.BOTTOM);
info.setHorizontalTextPosition(JLabel.CENTER);
info.setVerticalTextPosition(JLabel.TOP);
this.setLayout(null);
this.setBounds(0, 0, (int) size.getWidth(), (int) size.getHeight());
// Debug.print("hallo");
ImageIcon board = new ImageIcon("Assets\\dead.png");
ImageIcon background = new ImageIcon("Assets\\levelSelect_background.png");
this.board = board.getImage();
bg = background.getImage();
this.setVisible(true);
this.setFocusable(true);
this.requestFocus();
this.add(backButton);
this.add(nextButton);
this.add(enterButton);
this.add(settingsButton);
this.add(directoryButton);
this.add(info);
// this.add(editorButton);
}
}