runelite-client: add icon image and tray icon
This commit is contained in:
@@ -22,14 +22,18 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.runelite.client;
|
package net.runelite.client;
|
||||||
|
|
||||||
import com.google.common.eventbus.EventBus;
|
import com.google.common.eventbus.EventBus;
|
||||||
import com.google.common.eventbus.SubscriberExceptionContext;
|
import com.google.common.eventbus.SubscriberExceptionContext;
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.SystemTray;
|
||||||
|
import java.awt.TrayIcon;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
import joptsimple.OptionParser;
|
import joptsimple.OptionParser;
|
||||||
import joptsimple.OptionSet;
|
import joptsimple.OptionSet;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
@@ -39,7 +43,6 @@ import net.runelite.client.ui.overlay.OverlayRenderer;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
public class RuneLite
|
public class RuneLite
|
||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(RuneLite.class);
|
private static final Logger logger = LoggerFactory.getLogger(RuneLite.class);
|
||||||
@@ -47,9 +50,12 @@ public class RuneLite
|
|||||||
public static final File RUNELITE_DIR = new File(System.getProperty("user.home"), ".runelite");
|
public static final File RUNELITE_DIR = new File(System.getProperty("user.home"), ".runelite");
|
||||||
public static final File REPO_DIR = new File(RUNELITE_DIR, "repository");
|
public static final File REPO_DIR = new File(RUNELITE_DIR, "repository");
|
||||||
|
|
||||||
|
public static Image ICON;
|
||||||
|
|
||||||
private static OptionSet options;
|
private static OptionSet options;
|
||||||
private static Client client;
|
private static Client client;
|
||||||
private static RuneLite runelite;
|
private static RuneLite runelite;
|
||||||
|
private static TrayIcon trayIcon;
|
||||||
|
|
||||||
private ClientUI gui;
|
private ClientUI gui;
|
||||||
private PluginManager pluginManager;
|
private PluginManager pluginManager;
|
||||||
@@ -57,12 +63,24 @@ public class RuneLite
|
|||||||
private EventBus eventBus = new EventBus(this::eventExceptionHandler);
|
private EventBus eventBus = new EventBus(this::eventExceptionHandler);
|
||||||
private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ICON = ImageIO.read(ClientUI.class.getResourceAsStream("/runelite.png"));
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
logger.warn(null, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
{
|
{
|
||||||
OptionParser parser = new OptionParser();
|
OptionParser parser = new OptionParser();
|
||||||
parser.accepts("developer-mode");
|
parser.accepts("developer-mode");
|
||||||
options = parser.parse(args);
|
options = parser.parse(args);
|
||||||
|
|
||||||
runelite = new RuneLite();
|
runelite = new RuneLite();
|
||||||
runelite.start();
|
runelite.start();
|
||||||
}
|
}
|
||||||
@@ -71,6 +89,15 @@ public class RuneLite
|
|||||||
{
|
{
|
||||||
gui = new ClientUI();
|
gui = new ClientUI();
|
||||||
|
|
||||||
|
if (SystemTray.isSupported())
|
||||||
|
{
|
||||||
|
SystemTray systemTray = SystemTray.getSystemTray();
|
||||||
|
|
||||||
|
trayIcon = new TrayIcon(ICON, "RuneLite");
|
||||||
|
trayIcon.setImageAutoSize(true);
|
||||||
|
systemTray.add(trayIcon);
|
||||||
|
}
|
||||||
|
|
||||||
pluginManager = new PluginManager(this);
|
pluginManager = new PluginManager(this);
|
||||||
pluginManager.loadAll();
|
pluginManager.loadAll();
|
||||||
|
|
||||||
@@ -126,4 +153,9 @@ public class RuneLite
|
|||||||
{
|
{
|
||||||
return executor;
|
return executor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TrayIcon getTrayIcon()
|
||||||
|
{
|
||||||
|
return trayIcon;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import javax.swing.JPanel;
|
|||||||
import javax.swing.JPopupMenu;
|
import javax.swing.JPopupMenu;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.UnsupportedLookAndFeelException;
|
import javax.swing.UnsupportedLookAndFeelException;
|
||||||
|
import net.runelite.client.RuneLite;
|
||||||
|
|
||||||
public final class ClientUI extends JFrame
|
public final class ClientUI extends JFrame
|
||||||
{
|
{
|
||||||
@@ -53,6 +54,7 @@ public final class ClientUI extends JFrame
|
|||||||
init();
|
init();
|
||||||
pack();
|
pack();
|
||||||
setTitle("RuneLite");
|
setTitle("RuneLite");
|
||||||
|
setIconImage(RuneLite.ICON);
|
||||||
setLocationRelativeTo(getOwner());
|
setLocationRelativeTo(getOwner());
|
||||||
setResizable(true);
|
setResizable(true);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
|
|||||||
BIN
runelite-client/src/main/resources/runelite.png
Normal file
BIN
runelite-client/src/main/resources/runelite.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
Reference in New Issue
Block a user