-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCredits.java
150 lines (118 loc) · 4.66 KB
/
Credits.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import javax.swing.*;
import java.awt.*;
import java.util.Timer;
import java.util.TimerTask;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
/**
* Credits
*/
public class Credits {
public static void Credits() {
ScrollingCredits creditsWindow = new ScrollingCredits(() -> {
});
SwingUtilities.invokeLater(() -> {
creditsWindow.setVisible(true);
});
}
}
class ScrollingCredits extends JFrame {
private CreditsPanel creditsPanel;
private Runnable onCloseCallback;
public ScrollingCredits(Runnable onCloseCallback) {
this.onCloseCallback = onCloseCallback;
createView();
setTitle("Credits");
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setSize(600, 800);
setLocationRelativeTo(null);
setResizable(false);
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
if (onCloseCallback != null) {
onCloseCallback.run();
}
}
});
}
private void createView() {
creditsPanel = new CreditsPanel();
getContentPane().add(creditsPanel);
}
class CreditsPanel extends JPanel {
private String[][] credits = {
{"Copyright © ", "SZABIST 2024"},
{"Developer", "Muhammad Hasnain"},
{"Designer", "Apka Bhai"},
{"Project Manager", "Akela mai hi hu"},
{"Tester", "Chat GPT"},
{"UX Specialist", "Nhi hai koi"},
{"Support", "Nhi karta koi support"},
{"", ""},
{"Marketing", "Nhi ati marketing"},
{"Beta Testers", "SZABIST Students"},
{"", ""},
{"", ""},
{"", "Open Source Libraries"},
{"", "Community Contributors"},
{"", "Special Thanks to Our Families"},
{"", "Thanks For Using My Code 😊"}
};
private int yPosition;
public CreditsPanel() {
yPosition = getHeight() + 600;
setBackground(Color.BLACK);
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
yPosition -= 2;
if (yPosition < -calculateTotalHeight() * 40) {
yPosition = getHeight() + 100;
}
repaint();
}
}, 0, 30);
}
private int calculateTotalHeight() {
int totalLines = credits.length + 2;
return totalLines;
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.setFont(new Font("Serif", Font.BOLD, 30));
g.setColor(Color.GRAY);
int xTitle = (getWidth() / 2) - 3 - g.getFontMetrics().stringWidth("APNA ZABDESK") / 2;
int titleY = yPosition - 30;
g.drawString("APNA", xTitle, titleY);
g.setColor(Color.WHITE);
g.drawString("ZABDESK", xTitle + g.getFontMetrics().stringWidth("APNA "), titleY);
int currentY = 60;
for (int i = 0; i < credits.length; i++) {
String category = credits[i][0];
String name = credits[i][1];
if (i >= 10) {
g.setColor(Color.WHITE);
g.setFont(new Font("Serif", Font.BOLD, 24));
int xCategory = (getWidth() / 2) - g.getFontMetrics().stringWidth(category) / 2;
int xName = (getWidth() / 2) - g.getFontMetrics().stringWidth(name) / 2;
g.drawString(category, xCategory, yPosition + currentY);
g.drawString(name, xName, yPosition + currentY);
currentY += 40;
} else if (!category.isEmpty()) {
g.setColor(Color.GRAY);
g.setFont(new Font("Serif", Font.BOLD, 20));
g.drawString(category, 100, yPosition + currentY);
g.setColor(Color.WHITE);
g.setFont(new Font("Serif", Font.BOLD, 20));
g.drawString(name, 300, yPosition + currentY);
currentY += 40;
} else {
currentY += 80;
}
}
}
}
}