Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Replaced panel footer by header, included new links. #84

Merged
merged 1 commit into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ private MapOrb()
public static final class Icons
{
private static final String folder = path(EmoteClueItemsImages.folder, "icons");

public static final BufferedImage CLOSE = getBufferedImage(Icons.folder, "close.png");
public static final BufferedImage GITHUB = getBufferedImage(Icons.folder, "github.png");
public static final BufferedImage PAYPAL = getBufferedImage(Icons.folder, "paypal.png");
public static final BufferedImage QUESTION = getBufferedImage(Icons.folder, "question.png");

private Icons()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ protected void startUp()
this::removeStashUnitMarkerFromMap,
"Emote Clue Items",
"v4.1.0",
"https://github.com/larsvansoest/emote-clue-items"
"https://github.com/larsvansoest/emote-clue-items",
"https://www.paypal.com/donate/?hosted_button_id=72AFNGL28LFEN"
);

this.progressManager = new ProgressManager(this.client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class EmoteClueItemsPanel extends PluginPanel
*/
public EmoteClueItemsPanel(
final EmoteClueItemsPalette palette, final ItemManager itemManager, final BiConsumer<StashUnit, Boolean> onStashFillStatusChanged, final BiConsumer<StashUnit, Boolean> onAddStashUnitToMap, final Runnable onRemoveStashUnitFromMap, final String pluginName, final String pluginVersion,
final String gitHubUrl)
final String gitHubUrl, final String payPalUrl)
{
super();
super.setLayout(new GridBagLayout());
Expand Down Expand Up @@ -155,14 +155,13 @@ public EmoteClueItemsPanel(
c.gridx = 0;
c.gridy = 0;

super.add(new HeaderPanel(pluginName, pluginVersion, gitHubUrl, payPalUrl), c);
c.gridy++;

super.add(tabMenu, c);
c.gridy++;
super.add(this.clueItemsGrid, c);
super.add(this.stashUnitGrid, c);

c.gridy++;
c.insets = new Insets(10, 20, 0, 20);
super.add(new FooterPanel(palette, pluginName, pluginVersion, gitHubUrl), c);
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.larsvansoest.runelite.clueitems.ui.components;

import com.larsvansoest.runelite.clueitems.EmoteClueItemsImages;
import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.components.shadowlabel.JShadowedLabel;

import javax.swing.*;
import java.awt.*;

/**
* Displays a plugin panel header with the title and useful links.
*/
public class HeaderPanel extends JPanel {

/**
* Creates a plugin panel header.
* @param title The title of the plugin panel.
* @param version The version of the plugin.
* @param gitHubUrl A URL to the GitHub repository page.
* @param payPalUrl A donation url.
*/
public HeaderPanel(final String title, final String version, final String gitHubUrl, final String payPalUrl) {
super(new GridBagLayout());

final GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.gridx = 0;
c.gridy = 0;
c.insets.bottom = 9;

c.insets.top = 6;
super.add(getTitle(title), c);
c.weightx = 0;
c.insets.left = 11;
c.gridx++;

final String patchNotesUrl = String.format("%s/releases/tag/%s", gitHubUrl, version);
super.add(new LinkButton(version, patchNotesUrl, "View patch notes.", FontManager.getRunescapeFont()), c);
c.gridx++;

c.insets.top = 4;
super.add(new LinkButton(EmoteClueItemsImages.Icons.GITHUB, gitHubUrl, "Visit GitHub webpage."), c);
c.gridx++;

super.add(new LinkButton(EmoteClueItemsImages.Icons.PAYPAL, payPalUrl, "Buy me a coffee!", 1.3f), c);
}

private JLabel getTitle(final String title) {
final JLabel label = new JShadowedLabel(title);
label.setHorizontalTextPosition(SwingConstants.LEFT);
return label;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package com.larsvansoest.runelite.clueitems.ui.components;

import net.runelite.client.ui.components.shadowlabel.JShadowedLabel;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.LinkBrowser;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.font.TextAttribute;
import java.util.Map;

/**
* Displays a button to open a URL in the web browser.
* <p>
* Supports text and images.
*/
public class LinkButton extends JShadowedLabel {
/**
* Creates the link button with an image.
* <p>
* The image is illuminated on hover with a factor of 2 by default.
* @param image The image displayed by the link button.
* @param url The url that should be opened by the web browser
* @param tooltip The tooltip that is displayed when hovering over the button.
*/
public LinkButton (final Image image, final String url, final String tooltip) {
this(image, url, tooltip, 2);
}

/**
* Creates the link button with an image.
* <p>
* The image is illuminated on hover.
* @param image The image displayed by the link button.
* @param url The url that should be opened by the web browser
* @param tooltip The tooltip that is displayed when hovering over the button.
* @param luminancePercentage The scale of the image illumination on hover.
*/
public LinkButton (final Image image, final String url, final String tooltip, final float luminancePercentage) {
final ImageIcon icon = new ImageIcon(image);
final ImageIcon illuminatedIcon = new ImageIcon(ImageUtil.luminanceScale(image, luminancePercentage));
super.setToolTipText(tooltip);
super.setIcon(icon);
super.setHorizontalAlignment(SwingConstants.CENTER);
super.setVerticalAlignment(SwingConstants.CENTER);
super.addMouseListener(new MouseAdapter()
{
@Override
public void mousePressed(final MouseEvent e)
{
LinkBrowser.browse(url);
}

@Override
public void mouseEntered(final MouseEvent e)
{
LinkButton.super.setIcon(illuminatedIcon);
}

@Override
public void mouseExited(final MouseEvent e)
{
LinkButton.super.setIcon(icon);
}
});
}

/**
* Creates the link button with text.
* <p>
* The text is underlined on hover.
* @param text The text displayed by the link button.
* @param url The url that should be opened by the web browser
* @param tooltip The tooltip that is displayed when hovering over the button.
* @param font The font of the text displayed by the button.
*/
public LinkButton(final String text, final String url, final String tooltip, final Font font) {
super.setText(text);
super.setToolTipText(tooltip);

Map attributes = LinkButton.super.getFont().getAttributes();
attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
Font underlinedFont = font.deriveFont(attributes);

super.addMouseListener(new MouseAdapter()
{
@Override
public void mousePressed(final MouseEvent e)
{
LinkBrowser.browse(url);
}

@Override
public void mouseEntered(final MouseEvent e)
{
LinkButton.super.setFont(underlinedFont);
}

@Override
public void mouseExited(final MouseEvent e)
{
LinkButton.super.setFont(font);
}
});
}

}
Binary file modified src/main/resources/images/icons/github.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/images/icons/paypal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.