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.UnsupportedLookAndFeelException;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import java.awt.AWTException;
|
import java.awt.AWTException;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Cursor;
|
||||||
|
import java.awt.Desktop;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
@@ -56,18 +60,23 @@ import java.awt.SystemTray;
|
|||||||
import java.awt.TrayIcon;
|
import java.awt.TrayIcon;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.awt.event.WindowStateListener;
|
import java.awt.event.WindowStateListener;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
public class GuiSwing extends JFrame implements Gui {
|
public class GuiSwing extends JFrame implements Gui {
|
||||||
public static final String type = "swing";
|
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 final int WIDTH = 540;
|
||||||
|
|
||||||
public static void drawVersionStringOnImage(final BufferedImage image, String versionString) {
|
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() {
|
@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 logo cannot be found, return dummy image
|
||||||
if (logoURL == null) {
|
if (logoSheepItURL == null || logoDiscordURL == null || logoWebURL == null) {
|
||||||
System.err.println("Error: Unable to find logo " + logoPath);
|
System.err.println("Error: Unable to find logos");
|
||||||
return new JLabel();
|
return new JLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
JLabel labelImage;
|
JLabel labelImage;
|
||||||
try {
|
try {
|
||||||
// Include the version of the app as a watermark in the SheepIt logo.
|
// 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;
|
String versionString = "v" + Configuration.jarVersion;
|
||||||
drawVersionStringOnImage(watermark, versionString);
|
drawVersionStringOnImage(watermark, versionString);
|
||||||
|
|
||||||
@@ -109,9 +120,50 @@ public class GuiSwing extends JFrame implements Gui {
|
|||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
// If something fails, we just show the SheepIt logo (without any watermark)
|
// 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);
|
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;
|
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