Skip to content

Commit

Permalink
Merge pull request #8 from Owain94/night-night-bby
Browse files Browse the repository at this point in the history
launcher: Nightlies support
  • Loading branch information
Owain94 committed Oct 5, 2019
2 parents 3df010a + f1ba299 commit ed3fcc2
Show file tree
Hide file tree
Showing 7 changed files with 274 additions and 107 deletions.
24 changes: 0 additions & 24 deletions .github/workflows/build.yml
Expand Up @@ -72,29 +72,5 @@ jobs:
- name: Approve pull request
if: github.event_name == 'pull_request' && github.actor == 'OpenOSRS'
uses: hmarr/auto-approve-action@master
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

merge:
name: Merge
needs: approve
runs-on: ubuntu-latest

steps:
- name: Merge pull request
if: github.event_name == 'pull_request' && github.actor == 'OpenOSRS'
uses: managedkaos/merge-pull-request@master
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

cleanup:
name: Cleanup
needs: merge
runs-on: ubuntu-latest

steps:
- name: Remove merged branch
if: github.event_name == 'pull_request' && github.actor == 'OpenOSRS'
uses: jessfraz/branch-cleanup-action@master
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Update Gradle Wrapper
run: ./gradlew wrapper --gradle-version $(curl -s https://api.github.com/repos/gradle/gradle/releases/latest | grep -Po '"name":.*?[^\\]",' | sed -r 's/[\"name:, ]+//g') --distribution-type all --console=plain
- name: Create Gradle wrapper update Pull Request
uses: peter-evans/create-pull-request@master
uses: Owain94/create-pull-request@master
env:
GITHUB_TOKEN: ${{ secrets.OpenOSRS }}
PULL_REQUEST_BRANCH: GRADLE-WRAPPER-UPDATE
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Update Gradle dependencies
run: ./gradlew useLatestVersions --console=plain
- name: Create Gradle dependencies update Pull Request
uses: peter-evans/create-pull-request@master
uses: Owain94/create-pull-request@master
env:
GITHUB_TOKEN: ${{ secrets.OpenOSRS }}
PULL_REQUEST_BRANCH: GRADLE-DEPENDENCY-UPDATE
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/runelite/launcher/ColorScheme.java
Expand Up @@ -37,6 +37,8 @@ class ColorScheme
/* The blue color used for the branding's accents, with lowered opacity */
static final Color BRAND_BLUE_TRANSPARENT = new Color(25, 194, 255, 120);


static final Color DARK_GRAY_COLOR = new Color(40, 40, 40);
static final Color DARKER_GRAY_COLOR = new Color(30, 30, 30);
static final Color MEDIUM_GRAY_COLOR = new Color(77, 77, 77);

Expand Down
70 changes: 69 additions & 1 deletion src/main/java/net/runelite/launcher/InfoPanel.java
Expand Up @@ -24,6 +24,7 @@
*/
package net.runelite.launcher;

import com.google.common.io.ByteStreams;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
Expand All @@ -33,14 +34,25 @@
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.MatteBorder;
import lombok.extern.slf4j.Slf4j;
import static net.runelite.launcher.Launcher.LAUNCHER_BUILD;
import static net.runelite.launcher.Launcher.USER_AGENT;

@Slf4j
class InfoPanel extends JPanel
Expand All @@ -57,7 +69,7 @@ class InfoPanel extends JPanel
private static final String TROUBLESHOOTING_URL = "https://github.com/runelite/runelite/wiki/Troubleshooting-problems-with-the-client";
private static final String DISCORD_INVITE_LINK = "https://discordapp.com/invite/HN5gf3m";

InfoPanel()
InfoPanel(boolean disabled, String mode)
{
this.setLayout(new GridBagLayout());
this.setPreferredSize(PANEL_SIZE);
Expand Down Expand Up @@ -85,10 +97,29 @@ class InfoPanel extends JPanel
c.anchor = GridBagConstraints.SOUTH;
c.weighty = 0;

String latestLauncher = getLatestLauncher();

// Latest version
if (!latestLauncher.equals("-1") && !latestLauncher.equals(LauncherProperties.getVersion()))
{
this.add(createPanelTextButton("Update available!"), c);
c.gridy++;

this.add(createPanelTextButton("Latest Version: " + latestLauncher), c);
c.gridy++;
}

// Version
this.add(createPanelTextButton("Launcher Version: " + LauncherProperties.getVersion()), c);
c.gridy++;

if (!disabled)
{
// bootstrap
this.add(createPanelTextButton("Mode: " + mode), c);
c.gridy++;
}

final JLabel logsFolder = createPanelButton("Open logs folder", null, () -> LinkBrowser.openLocalFile(LOGS_DIR));
this.add(logsFolder, c);
c.gridy++;
Expand All @@ -106,6 +137,43 @@ class InfoPanel extends JPanel
c.gridy++;
}




private static String getLatestLauncher()
{
try
{
URL u = new URL(LAUNCHER_BUILD);

URLConnection conn = u.openConnection();

conn.setRequestProperty("User-Agent", USER_AGENT);

try (InputStream i = conn.getInputStream())
{
byte[] bytes = ByteStreams.toByteArray(i);
Pattern pattern = Pattern.compile("version = '(\\d{1}).(\\d{1}).(\\d{1})'");

BufferedReader buf = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(bytes)));
String str;
while ((str = buf.readLine()) != null)
{
Matcher m = pattern.matcher(str);
if (m.find())
{
return String.format("%s.%s.%s", m.group(1), m.group(2), m.group(3));
}
}
}
}
catch (IOException ignored)
{
}

return "-1";
}

private static JLabel createPanelTextButton(final String title)
{
final JLabel textButton = new JLabel(title);
Expand Down

0 comments on commit ed3fcc2

Please sign in to comment.