-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptions.java
More file actions
83 lines (74 loc) · 2.82 KB
/
Options.java
File metadata and controls
83 lines (74 loc) · 2.82 KB
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
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
public class Options extends JPanel {
private BufferedImage backgroundImage;
private Font Fonte;
private Game frame;
private InterfaceCaixa interfaceCaixa;
public Options(Game frame, InterfaceCaixa interfaceCaixa) { // Modificado
this.frame = frame;
this.interfaceCaixa = interfaceCaixa;
Fonte = DefinirFonte.fonte();
editar();
}
protected void paintComponent(Graphics g) {
super.paintComponent(g);
// Colocar a imagem como plano de fundo
if (backgroundImage != null) {
g.drawImage(backgroundImage, 0, 0, this.getWidth(), this.getHeight(), this);
}
}
private void editar() {
definirBackground();
setLayout(null);
botao("LUTAR", 40, 30);
botao("BOLSA", 270, 30);
botao("POKEMON", 40, 100);
botao("SAIR", 270, 100);
}
private void definirBackground() {
// Carregar background
try {
backgroundImage = ImageIO.read(new File("assets/battleElements/rightMenu.png"));
} catch (IOException e) {
e.printStackTrace(); // Erro se o arquivo não estiver lá
}
}
private void botao(String nome, int x, int y) {
JButton botao = new JButton(nome);
// Parte do background
botao.setContentAreaFilled(false); // Tirar qualquer coisa que faça os botões ficarem coloridos
botao.setBorderPainted(false); // Tirar as bordas
botao.setFont(Fonte.deriveFont(Font.PLAIN, 60)); // Definir fonte
botao.setBounds(x, y, botao.getPreferredSize().width, botao.getPreferredSize().height); // Definir posição e tamanho
botao.addActionListener(e -> {
switch (nome) {
case "LUTAR":
interfaceCaixa.mudarInterfaceBattleLayout("poderes");
System.out.println(nome + " apertado!");
break;
case "BOLSA":
Bag bag = new Bag(frame);
frame.mudarTela(bag);
System.out.println(nome + " apertado!");
break;
case "POKEMON":
PokemonsBagPage pokemonsBag = new PokemonsBagPage(frame);
frame.mudarTela(pokemonsBag);
System.out.println(nome + " apertado!");
break;
case "SAIR":
Home home = new Home(frame);
frame.mudarTela(home);
System.out.println(nome + " apertado!");
break;
default:
break;
}
});
add(botao);
}
}