Feat: add link to discord and www on header
This commit is contained in:
@@ -44,7 +44,11 @@ import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.AWTException;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GridBagLayout;
|
||||
@@ -56,18 +60,23 @@ import java.awt.SystemTray;
|
||||
import java.awt.TrayIcon;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowStateListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class GuiSwing extends JFrame implements Gui {
|
||||
public static final String type = "swing";
|
||||
private static final String logoPath = "/sheepit-logo.png";
|
||||
private static final String logoSheepItPath = "/sheepit-logo.png";
|
||||
private static final String logoDiscordPath = "/discord-logo.png";
|
||||
private static final String logoWebPath = "/web-logo.png";
|
||||
public static final int WIDTH = 540;
|
||||
|
||||
public static void drawVersionStringOnImage(final BufferedImage image, String versionString) {
|
||||
@@ -90,18 +99,20 @@ public class GuiSwing extends JFrame implements Gui {
|
||||
}
|
||||
|
||||
@NotNull public static JLabel createLogoWithWatermark() {
|
||||
final URL logoURL = GuiSwing.class.getResource(logoPath);
|
||||
final URL logoSheepItURL = GuiSwing.class.getResource(logoSheepItPath);
|
||||
final URL logoDiscordURL = GuiSwing.class.getResource(logoDiscordPath);
|
||||
final URL logoWebURL = GuiSwing.class.getResource(logoWebPath);
|
||||
|
||||
// If logo cannot be found, return dummy image
|
||||
if (logoURL == null) {
|
||||
System.err.println("Error: Unable to find logo " + logoPath);
|
||||
if (logoSheepItURL == null || logoDiscordURL == null || logoWebURL == null) {
|
||||
System.err.println("Error: Unable to find logos");
|
||||
return new JLabel();
|
||||
}
|
||||
|
||||
JLabel labelImage;
|
||||
try {
|
||||
// Include the version of the app as a watermark in the SheepIt logo.
|
||||
final BufferedImage watermark = ImageIO.read(logoURL);
|
||||
final BufferedImage watermark = ImageIO.read(logoSheepItURL);
|
||||
String versionString = "v" + Configuration.jarVersion;
|
||||
drawVersionStringOnImage(watermark, versionString);
|
||||
|
||||
@@ -109,9 +120,50 @@ public class GuiSwing extends JFrame implements Gui {
|
||||
}
|
||||
catch (Exception e) {
|
||||
// If something fails, we just show the SheepIt logo (without any watermark)
|
||||
ImageIcon image = new ImageIcon(logoURL);
|
||||
ImageIcon image = new ImageIcon(logoSheepItURL);
|
||||
labelImage = new JLabel(image);
|
||||
}
|
||||
|
||||
ImageIcon logoImageDiscord = new ImageIcon(logoDiscordURL);
|
||||
ImageIcon logoImageWeb = new ImageIcon(logoWebURL);
|
||||
|
||||
labelImage.setLayout(new BorderLayout());
|
||||
|
||||
JPanel overlayPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));
|
||||
overlayPanel.setOpaque(false);
|
||||
|
||||
JLabel logoLabelDiscord = new JLabel(logoImageDiscord);
|
||||
logoLabelDiscord.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
logoLabelDiscord.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI("https://discord.gg/nZu9thzXfx"));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
JLabel logoLabelWeb = new JLabel(logoImageWeb);
|
||||
logoLabelWeb.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
logoLabelWeb.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI("https://www.sheepit-renderfarm.com"));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
overlayPanel.add(logoLabelWeb);
|
||||
overlayPanel.add(logoLabelDiscord);
|
||||
labelImage.add(overlayPanel, BorderLayout.SOUTH);
|
||||
|
||||
return labelImage;
|
||||
}
|
||||
|
||||
|
||||
BIN
src/main/resources/discord-logo.png
Normal file
BIN
src/main/resources/discord-logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 919 B |
Binary file not shown.
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 21 KiB |
BIN
src/main/resources/web-logo.png
Normal file
BIN
src/main/resources/web-logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 904 B |
Reference in New Issue
Block a user