-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameResultsView.java
More file actions
113 lines (92 loc) · 3.55 KB
/
GameResultsView.java
File metadata and controls
113 lines (92 loc) · 3.55 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
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
import javax.swing.*;
import java.awt.*;
public class GameResultsView extends WallPaperPanel
{
private JPanel firstRow = new JPanel(); //Holds title
private JPanel secondRow = new JPanel(); //Holds WPM results
private JPanel thirdRow = new JPanel(); //Holds accuracy results
private JPanel fourthRow = new JPanel(); //Holds status (pass/fail)
private JPanel fifthRow = new JPanel(); // Holds next button
private JLabel resultsLabel = new JLabel();
private JLabel wpmLabel = new JLabel();
private JLabel accuracyLabel = new JLabel();
private JLabel statusLabel = new JLabel();
private CustomButton next = new CustomButton("Next",300,80,50f);
private FrameModel frameModel;
private JFrame window;
private Student currentStudent;
private int minSpeed;
private int minAccuracy;
private int speed;
private int accuracy;
private BoxLayout mainLayout = new BoxLayout(this,BoxLayout.Y_AXIS);
public GameResultsView(FrameModel model, JFrame frame,Student user, int reqSpeed, int reqAccuracy, int actualSpeed, int actualAccuracy)
{
super();
this.frameModel = model;
this.window = frame;
this.currentStudent = user;
this.minSpeed=reqSpeed;
this.minAccuracy = reqAccuracy;
this.speed=actualSpeed;
this.accuracy = actualAccuracy;
this.layoutView();
this.registerControllers();
}
public void layoutView()
{
this.setLayout(mainLayout);
this.resultsLabel.setText("Results");
this.resultsLabel.setFont(UIMethods.deriveFont("leaguespartan-bold.ttf",50f));
this.resultsLabel.setBorder(BorderFactory.createEmptyBorder(10,0,0,0));
if(this.speed<this.minSpeed)
{
this.wpmLabel.setForeground(Color.RED);
}
this.wpmLabel.setText("Typing Speed: "+this.speed+" WPM (Required "+ this.minSpeed +" WPM)");
this.wpmLabel.setFont(UIMethods.deriveFont("Barlow-Light.ttf",40f));
if(this.accuracy<this.minAccuracy)
{
this.accuracyLabel.setForeground(Color.RED);
}
this.accuracyLabel.setText("Accuracy: "+this.accuracy+"% (Required "+this.minAccuracy+"%)");
this.accuracyLabel.setFont(UIMethods.deriveFont("Barlow-Light.ttf",40f));
this.statusLabel.setFont(UIMethods.deriveFont("Barlow-Light.ttf",40f));
if(this.accuracy<this.minAccuracy || this.speed<this.minSpeed)
{
this.statusLabel.setText("Level Failed");
this.statusLabel.setForeground(Color.RED);
}
else
{
this.statusLabel.setForeground(Color.GREEN);
this.statusLabel.setText("Level Completed");
this.currentStudent.unlockNextStage();
}
firstRow.add(resultsLabel);
firstRow.setOpaque(false);
secondRow.add(wpmLabel);
secondRow.setOpaque(false);
thirdRow.add(accuracyLabel);
thirdRow.setOpaque(false);
fourthRow.add(statusLabel);
fourthRow.setOpaque(false);
fifthRow.add(next);
fifthRow.setOpaque(false);
this.add(firstRow);
this.add(secondRow);
this.add(thirdRow);
this.add(fourthRow);
this.add(fifthRow);
this.window.setSize(1366,768);
this.window.setTitle("Results");
this.window.setLocation(0,0);
this.window.setContentPane(this);
this.window.setVisible(true);
}
public void registerControllers()
{
FrameSwitchController backToSelection = new FrameSwitchController(this.next,this.frameModel,"Play");
next.addMouseListener(backToSelection);
}
}