Skip to content

Commit

Permalink
Streamers! <3
Browse files Browse the repository at this point in the history
  • Loading branch information
e3ndr committed Oct 29, 2024
1 parent 67abe05 commit a388a45
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.awt.RenderingHints;
import java.io.IOException;

import javax.swing.ImageIcon;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
import javax.swing.SpringLayout;

Expand All @@ -22,25 +22,31 @@ public class UpdaterPane extends JPanel {
private static final long serialVersionUID = -4429924866600191261L;

private static final String[] STREAMERS = {
"template" // TODO Find new streamers
"stallion",
"flankthomas",
"jcodude",
"himichannel",
"statice06",
};

private @Setter @NonNull DialogAnimation currentAnimation = new BlankAnimation();

private String chosenStreamer = STREAMERS[0]; // Default is required for WindowBuilder.
private Image chosenStreamerImage;

private @Getter UpdaterUI ui;
public static String chosenStreamer = STREAMERS[0]; // Default is required for WindowBuilder.
private static Image chosenStreamerImage;

public UpdaterPane(UpdaterDialog dialog, DialogAnimation animation) throws IOException {
static {
try {
this.chosenStreamer = STREAMERS[(int) Math.floor(Math.random() * STREAMERS.length)];
this.chosenStreamerImage = new ImageIcon(FileUtil.loadResourceAsUrl(String.format("assets/streamers/%s.png", this.chosenStreamer))).getImage();
FastLogger.logStatic("Chosen Streamer: %s", this.chosenStreamer);
chosenStreamer = STREAMERS[(int) Math.floor(Math.random() * STREAMERS.length)];
chosenStreamerImage = ImageIO.read(FileUtil.loadResourceAsUrl(String.format("assets/streamers/%s.png", chosenStreamer)));
FastLogger.logStatic("Chosen Streamer: %s", chosenStreamer);
} catch (Exception e) {
FastLogger.logException(e);
}
}

private @Setter @NonNull DialogAnimation currentAnimation = new BlankAnimation();

private @Getter UpdaterUI ui;

public UpdaterPane(UpdaterDialog dialog, DialogAnimation animation) throws IOException {
this.currentAnimation = animation;

SpringLayout layout = new SpringLayout();
Expand Down Expand Up @@ -77,9 +83,9 @@ public void paint(Graphics g) {
this.currentAnimation.paintOnBackground(g2d);

// Paint the background image if set
if (this.chosenStreamerImage != null) {
if (chosenStreamerImage != null) {
// The image is same size as the window.
g2d.drawImage(this.chosenStreamerImage, 0, 0, null);
g2d.drawImage(chosenStreamerImage, 0, 0, null);
}

// Paint the animation (over background)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
public class UpdaterUI extends JPanel {
private static final long serialVersionUID = -6590073036152631171L;

public static final Font FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 14);

private JLabel statusText;

private LoadingSpinner loadingSpinner;
Expand All @@ -35,12 +37,22 @@ public UpdaterUI(UpdaterDialog dialog, DialogAnimation animation) throws IOExcep
statusText = new JLabel();
layout.putConstraint(SpringLayout.SOUTH, statusText, -32, SpringLayout.SOUTH, this);
layout.putConstraint(SpringLayout.EAST, statusText, -10, SpringLayout.EAST, this);
statusText.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 14));
statusText.setFont(FONT);
statusText.setForeground(UpdaterDialog.TEXT_COLOR);
statusText.setOpaque(false);
statusText.setText("Checking for updates...");
this.add(statusText);

JLabel streamerText = new JLabel();
layout.putConstraint(SpringLayout.SOUTH, streamerText, -9, SpringLayout.SOUTH, this);
layout.putConstraint(SpringLayout.EAST, streamerText, -10, SpringLayout.EAST, this);
streamerText.setFont(FONT);
streamerText.setHorizontalAlignment(JLabel.RIGHT);
streamerText.setForeground(UpdaterDialog.TEXT_COLOR);
streamerText.setOpaque(false);
streamerText.setText("@" + UpdaterPane.chosenStreamer);
this.add(streamerText);

loadingSpinner = new LoadingSpinner();
layout.putConstraint(SpringLayout.NORTH, statusText, 13, SpringLayout.NORTH, loadingSpinner);
layout.putConstraint(SpringLayout.WEST, statusText, 6, SpringLayout.EAST, loadingSpinner);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/assets/streamers/jcodude.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/assets/streamers/stallion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/assets/streamers/statice06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a388a45

Please sign in to comment.