Skip to content

Commit 13bfacf

Browse files
committed
Change styling of the application, add a link to the wiki in-app, bump version
1 parent 2f284b7 commit 13bfacf

8 files changed

Lines changed: 326 additions & 21 deletions

File tree

bootstrap/src/main/java/org/geysermc/pack/converter/bootstrap/BootstrapLogListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ public void error(@NotNull String message, @Nullable Throwable exception) {
7878
private void appendText(String text) {
7979
if (gui.outputArea.getText().isEmpty()) {
8080
gui.outputArea.setText(
81-
text
81+
" " + text
8282
);
8383
return;
8484
}
8585

8686
gui.outputArea.setText(
87-
gui.outputArea.getText() + "\n" + text
87+
gui.outputArea.getText() + "\n " + text
8888
);
8989

9090
gui.outputArea.setCaretPosition(gui.outputArea.getDocument().getLength());

bootstrap/src/main/java/org/geysermc/pack/converter/bootstrap/Main.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
package org.geysermc.pack.converter.bootstrap;
2828

29-
import com.formdev.flatlaf.intellijthemes.FlatArcDarkIJTheme;
3029
import org.geysermc.pack.converter.PackConverter;
3130
import org.geysermc.pack.converter.converter.Converters;
3231

@@ -80,8 +79,7 @@ public static void main(String[] arguments) throws IOException {
8079
.convert()
8180
.pack();
8281
} else {
83-
FlatArcDarkIJTheme.setup();
84-
new ThunderGUI(debug);
82+
ThunderGUI.start(debug);
8583
}
8684
}
8785
}

bootstrap/src/main/java/org/geysermc/pack/converter/bootstrap/ThunderGUI.java

Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,27 @@
2626

2727
package org.geysermc.pack.converter.bootstrap;
2828

29+
import com.formdev.flatlaf.intellijthemes.FlatArcDarkIJTheme;
2930
import com.twelvemonkeys.image.BufferedImageIcon;
3031
import org.geysermc.pack.converter.PackConverter;
32+
import org.geysermc.pack.converter.bootstrap.components.DefaultButtonBorder;
33+
import org.geysermc.pack.converter.bootstrap.components.HelpButton;
34+
import org.geysermc.pack.converter.bootstrap.components.PrideButtonBorder;
35+
import org.geysermc.pack.converter.bootstrap.components.StaticButtonBorder;
3136
import org.geysermc.pack.converter.converter.Converters;
3237
import org.geysermc.pack.converter.util.ImageUtil;
3338
import org.geysermc.pack.converter.util.ZipUtils;
3439

3540
import javax.imageio.ImageIO;
3641
import javax.swing.*;
42+
import javax.swing.border.Border;
3743
import java.awt.*;
3844
import java.awt.image.BufferedImage;
3945
import java.io.IOException;
4046
import java.io.InputStream;
4147
import java.math.RoundingMode;
48+
import java.net.URI;
49+
import java.net.URISyntaxException;
4250
import java.nio.file.Files;
4351
import java.nio.file.Path;
4452
import java.text.DecimalFormat;
@@ -62,12 +70,26 @@ public class ThunderGUI extends JFrame {
6270
private Path outputPath = null;
6371
private BufferedImage currentIcon = null;
6472

73+
public static void start(boolean debug) throws IOException {
74+
FlatArcDarkIJTheme.setup();
75+
76+
new ThunderGUI(debug);
77+
}
78+
6579
public ThunderGUI(boolean debug) throws IOException {
6680
vanillaPackPath = Path.of(System.getenv("LOCALAPPDATA") != null ? System.getenv("LOCALAPPDATA") : System.getProperty("user.home"), "Thunder", "Vanilla-Assets.zip");
6781

6882
decimalFormat = new DecimalFormat("#.##");
6983
decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
7084

85+
Border border;
86+
87+
if (LocalDate.now().getMonth().equals(Month.JUNE)) {
88+
border = new PrideButtonBorder();
89+
} else {
90+
border = new DefaultButtonBorder();
91+
}
92+
7193
this.setTitle("Thunder");
7294
InputStream iconStream = Main.class.getResourceAsStream("/icon.png");
7395
if (iconStream != null) this.setIconImage(ImageIO.read(iconStream));
@@ -82,9 +104,26 @@ public ThunderGUI(boolean debug) throws IOException {
82104
this.add(packNameLabel);
83105

84106
JTextField packName = new JTextField("");
85-
packName.setBounds(295, 20, 475, 30);
107+
packName.setBorder(border);
108+
packName.setEnabled(false);
109+
packName.setToolTipText("Please select a pack first!");
110+
packName.setBounds(295, 20, 425, 30);
86111
this.add(packName);
87112

113+
JButton helpButton = new JButton(new HelpButton());
114+
helpButton.setToolTipText("Open the wiki page");
115+
helpButton.setFocusPainted(false);
116+
helpButton.setBorder(border);
117+
helpButton.setBounds(730, 20, 30, 30);
118+
helpButton.addActionListener(event -> {
119+
try {
120+
Desktop.getDesktop().browse(new URI("https://geysermc.org/wiki/other/thunder"));
121+
} catch (IOException | URISyntaxException e) {
122+
throw new RuntimeException(e);
123+
}
124+
});
125+
this.add(helpButton);
126+
88127
JLabel dataLabel = new JLabel("Input: None | Output: None");
89128
dataLabel.setBounds(225, 50, 535, 30);
90129
this.add(dataLabel);
@@ -94,9 +133,11 @@ public ThunderGUI(boolean debug) throws IOException {
94133
this.outputArea.setFocusable(false);
95134
this.outputArea.setLineWrap(true);
96135
this.outputArea.setTabSize(2);
136+
this.outputArea.setBorder(BorderFactory.createEmptyBorder());
97137

98138
JScrollPane scrollArea = new JScrollPane(this.outputArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
99-
scrollArea.setBounds(225, 90, 535, 125);
139+
scrollArea.setBounds(225, 90, 535, 130);
140+
scrollArea.setBorder(new StaticButtonBorder());
100141

101142
this.add(scrollArea);
102143

@@ -105,15 +146,15 @@ public ThunderGUI(boolean debug) throws IOException {
105146
if (debug) {
106147
debugCheckbox = new JCheckBox("Debug Mode");
107148
debugCheckbox.setBounds(650, 225, 105, 25);
108-
debugCheckbox.addActionListener(event -> {
109-
this.debugMode.set(debugCheckbox.isSelected());
110-
});
149+
debugCheckbox.addActionListener(event -> this.debugMode.set(debugCheckbox.isSelected()));
111150
this.add(debugCheckbox);
112151
} else {
113152
debugCheckbox = null;
114153
}
115154

116155
JButton convertButton = new JButton("Convert");
156+
convertButton.setBorder(border);
157+
convertButton.setFocusPainted(false);
117158
convertButton.setBounds(20, 225, debug ? 625 : 740, 25);
118159
convertButton.setEnabled(false);
119160
convertButton.addActionListener(event -> {
@@ -123,6 +164,7 @@ public ThunderGUI(boolean debug) throws IOException {
123164
converting.set(true);
124165
if (debugCheckbox != null) debugCheckbox.setEnabled(false);
125166
convertButton.setEnabled(false);
167+
this.requestFocus();
126168
this.outputArea.setText("");
127169
dataLabel.setText("Converting %s...".formatted(inputPath.getFileName().toString()));
128170
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
@@ -160,6 +202,8 @@ public ThunderGUI(boolean debug) throws IOException {
160202
this.add(convertButton);
161203

162204
JButton javaPackButton = new JButton("Select Pack");
205+
javaPackButton.setBorder(border);
206+
javaPackButton.setFocusPainted(false);
163207
javaPackButton.setBounds(20, 20, 200, 200);
164208
javaPackButton.addActionListener(event -> {
165209
if (converting.get()) return;
@@ -186,9 +230,9 @@ public ThunderGUI(boolean debug) throws IOException {
186230
);
187231
convertButton.setEnabled(true);
188232

189-
if (packName.getText().isEmpty()) {
190-
packName.setText(chooser.getFile().replaceFirst("[.][^.]+$", ""));
191-
}
233+
packName.setToolTipText(null);
234+
packName.setEnabled(true);
235+
packName.setText(chooser.getFile().replaceFirst("[.][^.]+$", ""));
192236

193237
try {
194238
ZipUtils.openFileSystem(inputPath, true, path -> {
@@ -202,13 +246,10 @@ public ThunderGUI(boolean debug) throws IOException {
202246

203247
LocalDate date = LocalDate.now();
204248

205-
currentIcon = ImageUtil.borderRadias(
206-
ImageUtil.resize(
207-
ImageIO.read(Files.newInputStream(iconPath)),
208-
198,
209-
198
210-
),
211-
5
249+
currentIcon = ImageUtil.resize(
250+
ImageIO.read(Files.newInputStream(iconPath)),
251+
198,
252+
198
212253
);
213254

214255
if (date.getMonth().equals(Month.APRIL) && date.getDayOfMonth() == 1) {
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* Copyright (c) 2025 GeyserMC. http://geysermc.org
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*
22+
* @author GeyserMC
23+
* @link https://github.com/GeyserMC/PackConverter
24+
*
25+
*/
26+
27+
package org.geysermc.pack.converter.bootstrap.components;
28+
29+
import com.formdev.flatlaf.ui.FlatButtonBorder;
30+
31+
import java.awt.*;
32+
import java.awt.geom.Point2D;
33+
34+
public class DefaultButtonBorder extends FlatButtonBorder {
35+
@Override
36+
protected Paint getBorderColor(Component c) {
37+
Color[] colors = getColors(c);
38+
39+
if (colors.length == 1) {
40+
return colors[0];
41+
}
42+
43+
float size = ((float) 90 / colors.length) / 100;
44+
float[] sizes = new float[colors.length];
45+
for (int i = 0; i < colors.length; i++) {
46+
sizes[i] = size * (i + 1);
47+
}
48+
49+
return new LinearGradientPaint(getStartPoint(c), getEndPoint(c), sizes, colors);
50+
}
51+
52+
@Override
53+
protected float getBorderWidth(Component c) {
54+
float base = super.getBorderWidth(c);
55+
if (c.isFocusOwner()) {
56+
return base * 2f;
57+
} else if (!c.isEnabled()) {
58+
return base;
59+
} else {
60+
return base * 0.5f;
61+
}
62+
}
63+
64+
@Override
65+
protected int getFocusWidth(Component c) {
66+
return 0;
67+
}
68+
69+
public Color[] getColors(Component c) {
70+
if (c.isFocusOwner()) {
71+
return new Color[]{
72+
new Color(51, 140, 242),
73+
new Color(35, 118, 213)
74+
};
75+
} else if (c.isEnabled()) {
76+
return new Color[]{
77+
new Color(151, 162, 168, 120),
78+
new Color(124, 136, 143, 120)
79+
};
80+
} else {
81+
return new Color[]{
82+
new Color(151, 162, 168, 80),
83+
new Color(124, 136, 143, 80)
84+
};
85+
}
86+
}
87+
88+
public Point2D getStartPoint(Component ignoredC) {
89+
return new Point2D.Float(0, 0);
90+
}
91+
92+
public Point2D getEndPoint(Component c) {
93+
return new Point2D.Float(0, c.getHeight());
94+
}
95+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright (c) 2025 GeyserMC. http://geysermc.org
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*
22+
* @author GeyserMC
23+
* @link https://github.com/GeyserMC/PackConverter
24+
*
25+
*/
26+
27+
package org.geysermc.pack.converter.bootstrap.components;
28+
29+
import com.formdev.flatlaf.ui.FlatUIUtils;
30+
import com.formdev.flatlaf.util.UIScale;
31+
32+
import javax.swing.*;
33+
import java.awt.*;
34+
import java.awt.geom.Ellipse2D;
35+
import java.awt.geom.Path2D;
36+
37+
// Based on FlatHelpButtonIcon and FlatAbstractIcon from FlatLaf
38+
// Path is entirely from FlatHelpButtonIcon
39+
public class HelpButton implements Icon {
40+
@Override
41+
public void paintIcon(Component c, Graphics graphics, int x, int y) {
42+
Graphics2D g = (Graphics2D)graphics.create();
43+
FlatUIUtils.setRenderingHints(g);
44+
g.translate(x, y);
45+
UIScale.scaleGraphics(g);
46+
Path2D q = new Path2D.Float(1, 10);
47+
q.moveTo(8.0F, 8.5F);
48+
q.curveTo(8.25F, 7.0F, 9.66585007, 6.0F, 11.0F, 6.0F);
49+
q.curveTo(12.5F, 6.0F, 14.0F, 7.0F, 14.0F, 8.5F);
50+
q.curveTo(14.0F, 10.5F, 11.0F, 11.0F, 11.0F, 13.0F);
51+
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
52+
g.setStroke(new BasicStroke(2.0F, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
53+
g.setColor(Color.WHITE);
54+
g.draw(q);
55+
g.fill(new Ellipse2D.Float(9.8F, 14.8F, 2.4F, 2.4F));
56+
}
57+
58+
@Override
59+
public int getIconWidth() {
60+
return 22;
61+
}
62+
63+
@Override
64+
public int getIconHeight() {
65+
return 22;
66+
}
67+
}

0 commit comments

Comments
 (0)