-
Notifications
You must be signed in to change notification settings - Fork 1
/
InputScore.java
68 lines (54 loc) · 2.12 KB
/
InputScore.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
import javax.imageio.ImageIO;
import java.io.File;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
import java.awt.Graphics2D;
public class InputScore extends Input{
private Score s;
public InputScore(Window w, Score s){
super(w);
this.s = s;
/*s.getCanvas().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
s.getCanvas().addMouseListener(this);
s.getCanvas().addMouseMotionListener(this);*/
}
public void update(){}
public void draw(Graphics2D g){}
//===================MOUSE EVENT========================================================
public void updateButtons(){
changeMainMenueButton();
}
public void mouseMoved(MouseEvent e){
posXmouse = (int)(e.getX()*((1.0*s.getWidth())/(1.0*w.getFrame().getContentPane().getWidth())));
posYmouse = (int)(e.getY()*((1.0*s.getHeight())/(1.0*w.getFrame().getContentPane().getHeight())));
updateButtons();
}
public void mouseClicked(MouseEvent e) {
//Invoked when the mouse has been clicked on a component.
int posXclic = (int)(e.getX()*((1.0*s.getWidth())/(1.0*w.getFrame().getContentPane().getWidth())));
int posYclic = (int)(e.getY()*((1.0*s.getHeight())/(1.0*w.getFrame().getContentPane().getHeight())));
//System.out.println(""+posXclic+","+posYclic);
if (posXclic >=560 && posXclic <=590 && posYclic>=360 && posYclic<=390) w.resetMap();
else if(posXclic >= 450 && posXclic <=570 && posYclic>=300 && posYclic <=350){
w.moveToMainMenu();
}
if (resetMapPressed(w.getCurrentWorld(), posXclic, posYclic)) return;
}
public void changeMainMenueButton(){
if(posXmouse >= 450 && posXmouse <=570 && posYmouse>=300 && posYmouse <=350){
s.showSelectButton();
}
else{
s.showDefaultButton();
}
if(posXmouse >= 560 && posXmouse <=590 && posYmouse>=360 && posYmouse <=390){
s.showResetMapSelectButton();
}
else{
s.showResetMapDefaultButton();
}
}
}