diff --git a/runelite-client/pom.xml b/runelite-client/pom.xml index 2ce144ec45..29412e540f 100644 --- a/runelite-client/pom.xml +++ b/runelite-client/pom.xml @@ -112,6 +112,12 @@ + + + src/main/resources + true + + org.apache.maven.plugins diff --git a/runelite-client/src/main/java/net/runelite/client/RuneLite.java b/runelite-client/src/main/java/net/runelite/client/RuneLite.java index 10002bb12b..fb4c961385 100644 --- a/runelite-client/src/main/java/net/runelite/client/RuneLite.java +++ b/runelite-client/src/main/java/net/runelite/client/RuneLite.java @@ -24,6 +24,7 @@ */ package net.runelite.client; +import com.google.common.base.Strings; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.SubscriberExceptionContext; import com.google.gson.Gson; @@ -79,6 +80,7 @@ public class RuneLite private static RuneLite runelite; private static TrayIcon trayIcon; + private final RuneliteProperties properties = new RuneliteProperties(); private ClientUI gui; private PluginManager pluginManager; private final MenuManager menuManager = new MenuManager(this); @@ -139,6 +141,7 @@ public class RuneLite } gui = new ClientUI(); + setTitle(null); setupTrayIcon(); }); @@ -164,6 +167,18 @@ public class RuneLite loadSession(); } + public void setTitle(String extra) + { + if (!Strings.isNullOrEmpty(extra)) + { + gui.setTitle("RuneLite " + properties.getVersion() + " " + extra); + } + else + { + gui.setTitle("RuneLite " + properties.getVersion()); + } + } + private void setupTrayIcon() { if (!SystemTray.isSupported()) @@ -318,6 +333,11 @@ public class RuneLite return runelite; } + public RuneliteProperties getProperties() + { + return properties; + } + public ClientUI getGui() { return gui; diff --git a/runelite-client/src/main/java/net/runelite/client/RuneliteProperties.java b/runelite-client/src/main/java/net/runelite/client/RuneliteProperties.java new file mode 100644 index 0000000000..b5f64b0198 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/RuneliteProperties.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2017, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RuneliteProperties +{ + private static final Logger logger = LoggerFactory.getLogger(RuneliteProperties.class); + + private static final String RUNELITE_VERSION = "runelite.version"; + + private final Properties properties = new Properties(); + + public RuneliteProperties() + { + InputStream in = getClass().getResourceAsStream("runelite.properties"); + try + { + properties.load(in); + } + catch (IOException ex) + { + logger.warn("unable to load propertries", ex); + } + } + + public String getVersion() + { + return properties.getProperty(RUNELITE_VERSION); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/account/AccountPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/account/AccountPlugin.java index dc5a6a1222..c0373dbcd7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/account/AccountPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/account/AccountPlugin.java @@ -167,7 +167,6 @@ public class AccountPlugin extends Plugin { logger.debug("Now logged in as {}", loginResponse.getUsername()); - //runelite.getGui().setTitle("RuneLite (" + loginResponse.getUsername() + ")"); AccountSession session = runelite.getAccountSession(); session.setUsername(loginResponse.getUsername()); @@ -191,7 +190,7 @@ public class AccountPlugin extends Plugin logger.debug("Session opened as {}", session.getUsername()); - runelite.getGui().setTitle("RuneLite (" + session.getUsername() + ")"); + runelite.setTitle("(" + session.getUsername() + ")"); replaceLoginWithLogout(); } @@ -207,7 +206,7 @@ public class AccountPlugin extends Plugin @Subscribe public void onSessionClose(SessionClose sessionClose) { - runelite.getGui().setTitle("RuneLite"); + runelite.setTitle(null); } } diff --git a/runelite-client/src/main/resources/net/runelite/client/runelite.properties b/runelite-client/src/main/resources/net/runelite/client/runelite.properties new file mode 100644 index 0000000000..ecbd5d4477 --- /dev/null +++ b/runelite-client/src/main/resources/net/runelite/client/runelite.properties @@ -0,0 +1,2 @@ +runelite.version=${project.version} +