Skip to content

Commit 06ce7ee

Browse files
committed
Add proper icon
1 parent b6c5ae6 commit 06ce7ee

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

launcher-gui/src/main/java/org/taumc/launcher/gui/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ static void start(String[] args) throws Exception {
3838
FlatDarkLaf.setup();
3939

4040
SwingUtilities.invokeLater(() -> {
41-
getDefaultRepositories().forEach(METADATA::addRepository);
4241
try {
42+
getDefaultRepositories().forEach(METADATA::addRepository);
4343
METADATA.updateIndex();
4444
} catch (Exception e) {
4545
LOGGER.error("Error updating metadata", e);

launcher-gui/src/main/java/org/taumc/launcher/gui/icon/IconRegistry.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import javax.swing.*;
55
import java.awt.*;
66
import java.awt.image.BufferedImage;
7+
import java.io.IOException;
78
import java.io.InputStream;
89
import java.nio.file.Files;
910
import java.nio.file.Path;
@@ -21,11 +22,15 @@ public static void resetCache() {
2122
CACHE.clear();
2223
}
2324

24-
private static ImageIcon loadAndScaleImageIcon(InputStream is, int fixedHeight) {
25+
public static ImageIcon loadAndScaleImageIcon(InputStream is, int fixedHeight) {
2526
try {
2627
BufferedImage img = ImageIO.read(is);
2728
if (img == null) throw new IllegalArgumentException("Unsupported image format");
2829

30+
if (img.getHeight() == fixedHeight) {
31+
return new ImageIcon(img);
32+
}
33+
2934
int originalWidth = img.getWidth();
3035
int originalHeight = img.getHeight();
3136
double scale = (double) fixedHeight / originalHeight;
@@ -36,6 +41,11 @@ private static ImageIcon loadAndScaleImageIcon(InputStream is, int fixedHeight)
3641
return new ImageIcon(scaled);
3742
} catch (Exception e) {
3843
throw new RuntimeException("Failed to load image", e);
44+
} finally {
45+
try {
46+
is.close();
47+
} catch (IOException ignored) {
48+
}
3949
}
4050
}
4151

launcher-gui/src/main/java/org/taumc/launcher/gui/screens/home/HomeView.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public String type() {
7676
public HomeView(HomeModel model) {
7777
this.model = model;
7878
this.setTitle("TauLauncher " + System.getProperty("taulauncher.version"));
79+
this.setIconImage(IconRegistry.loadAndScaleImageIcon(HomeView.class.getResourceAsStream("/taulauncher/icons/tau_logo.png"), 64).getImage());
7980
this.instanceButtonGroup = new ButtonGroup();
8081
var buttonLayout = new WrapLayout(FlowLayout.LEFT);
8182
buttonLayout.setAlignOnBaseline(false);
2.08 KB
Loading

0 commit comments

Comments
 (0)