Skip to content

Commit

Permalink
RPC in Quark!
Browse files Browse the repository at this point in the history
  • Loading branch information
XorTroll committed Oct 19, 2019
1 parent 9efa15c commit 651c1ed
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
13 changes: 13 additions & 0 deletions Quark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com</url>
<name>jcenter-bintray</name>
</repository>
</repositories>

<dependencies>

<dependency>
Expand Down Expand Up @@ -114,6 +122,11 @@
<version>1.2.0</version> <!-- Must be 1.2.0 for macOS lower than Mojave -->
<scope>compile</scope>
</dependency>
<dependency>
<groupId>club.minnced</groupId>
<artifactId>java-discord-rpc</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@
import java.util.Optional;
import java.util.Vector;

import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXAlert;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXDialogLayout;

import club.minnced.discord.rpc.DiscordEventHandlers;
import club.minnced.discord.rpc.DiscordRPC;
import club.minnced.discord.rpc.DiscordRichPresence;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.concurrent.Task;
Expand All @@ -41,14 +44,13 @@
import javafx.scene.layout.Pane;
import javafx.scene.text.Text;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import javafx.stage.Modality;
import javafx.stage.Stage;
import xorTroll.goldleaf.quark.Config;
import xorTroll.goldleaf.quark.Version;
import xorTroll.goldleaf.quark.fs.FileSystem;
import xorTroll.goldleaf.quark.usb.Command;
import xorTroll.goldleaf.quark.usb.USBInterface;
import xorTroll.goldleaf.quark.fs.FileSystem;
import xorTroll.goldleaf.quark.ui.MainController;

public class MainApplication extends Application
{
Expand Down Expand Up @@ -475,12 +477,43 @@ protected Void call() throws Exception
}
};

Task<Void> rpctask = new Task<Void>()
{
@Override
protected Void call() throws Exception
{
DiscordRPC rpc = DiscordRPC.INSTANCE;
DiscordEventHandlers handlers = new DiscordEventHandlers();
rpc.Discord_Initialize("584769559441965134", handlers, true, "");
DiscordRichPresence presence = new DiscordRichPresence();
presence.startTimestamp = System.currentTimeMillis() / 1000;
presence.details = "Details";
presence.largeImageKey = "icon";
presence.largeImageText = "Quark PC tool";
rpc.Discord_UpdatePresence(presence);

while(!Thread.currentThread().isInterrupted())
{
rpc.Discord_RunCallbacks();
try
{
Thread.sleep(2000);
} catch (InterruptedException ignored) {}
}
return null;
}
};

controller.prepare(this, usbtask);
stage.show();

Thread usb = new Thread(usbtask);
usb.setDaemon(true);
usb.start();

Thread rpc = new Thread(rpctask);
rpc.setDaemon(true);
rpc.start();
}

public static void main(String[] args)
Expand Down

0 comments on commit 651c1ed

Please sign in to comment.