Merge pull request #43 from BeefEX/feature_rich_presence
Discord rich presence
This commit is contained in:
@@ -54,6 +54,16 @@ public class AndroidLauncher extends AndroidApplication{
|
||||
public void addDialog(TextField field){
|
||||
TextFieldDialogListener.add(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSceneChange(String state, String details, String icon) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGameExit() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Mindustry.donationsCallable = new Callable(){ @Override public void run(){ showDonations(); } };
|
||||
|
||||
@@ -42,6 +42,7 @@ project(":desktop") {
|
||||
compile "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
|
||||
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
||||
compile "com.badlogicgames.gdx:gdx-controllers-lwjgl3:$gdxVersion"
|
||||
compile "com.github.MinnDevelopment:Java-DiscordRPC:dbd4aac"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,10 @@ public class Mindustry extends ModuleCore {
|
||||
@Override public String format(int number){ return number + ""; }
|
||||
@Override public void openLink(String link){ }
|
||||
@Override public void addDialog(TextField field){}
|
||||
@Override public void onSceneChange(String state, String details, String icon) {}
|
||||
@Override public void onGameExit() { }
|
||||
};
|
||||
|
||||
public static boolean externalBundle = false;
|
||||
|
||||
@Override
|
||||
@@ -45,6 +48,12 @@ public class Mindustry extends ModuleCore {
|
||||
module(Vars.netClient = new NetClient());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
platforms.onGameExit();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public void loadBundle(){
|
||||
I18NBundle.setExceptionOnMissingKey(false);
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.graphics.Atlas;
|
||||
import io.anuke.ucore.modules.Module;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Input;
|
||||
import io.anuke.ucore.util.InputProxy;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
@@ -75,6 +76,7 @@ public class Control extends Module{
|
||||
private InputProxy proxy;
|
||||
private float controlx, controly;
|
||||
private boolean controlling;
|
||||
private Map map;
|
||||
|
||||
public Control(){
|
||||
if(Mindustry.args.contains("-debug", false))
|
||||
@@ -299,6 +301,10 @@ public class Control extends Module{
|
||||
});
|
||||
|
||||
Timers.run(18, ()-> ui.hideLoading());
|
||||
|
||||
this.map = map;
|
||||
|
||||
Mindustry.platforms.onSceneChange(Bundles.get("text.playing", "Playing on map") + ": " + map.name, Bundles.get("text.wavenumber", "Wave") + " 0", "fight");
|
||||
}
|
||||
|
||||
public GameMode getMode(){
|
||||
@@ -329,6 +335,7 @@ public class Control extends Module{
|
||||
}
|
||||
|
||||
public void runWave(){
|
||||
Mindustry.platforms.onSceneChange(Bundles.get("text.playing", "Playing on map") + ": " + map.name, Bundles.get("text.wavenumber", "Wave") + " " + wave, "fight");
|
||||
if(Net.client() && Net.active()){
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -9,4 +9,6 @@ public interface PlatformFunction{
|
||||
public String format(int number);
|
||||
public void openLink(String link);
|
||||
public void addDialog(TextField field);
|
||||
public void onSceneChange(String state, String details, String icon);
|
||||
public void onGameExit();
|
||||
}
|
||||
|
||||
@@ -2,10 +2,7 @@ package io.anuke.mindustry.resource;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.blocks.DefenseBlocks;
|
||||
import io.anuke.mindustry.world.blocks.DistributionBlocks;
|
||||
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||
import io.anuke.mindustry.world.blocks.WeaponBlocks;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
|
||||
import static io.anuke.mindustry.resource.Section.*;
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package io.anuke.mindustry.desktop;
|
||||
|
||||
import club.minnced.discord.rpc.DiscordEventHandlers;
|
||||
import club.minnced.discord.rpc.DiscordRPC;
|
||||
import club.minnced.discord.rpc.DiscordRichPresence;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
@@ -58,7 +61,33 @@ public class DesktopLauncher {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDialog(TextField field){ }
|
||||
public void addDialog(TextField field){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSceneChange(String state, String details, String icon) {
|
||||
DiscordRPC lib = DiscordRPC.INSTANCE;
|
||||
|
||||
String applicationId = "397335883319083018";
|
||||
|
||||
DiscordEventHandlers handlers = new DiscordEventHandlers();
|
||||
|
||||
lib.Discord_Initialize(applicationId, handlers, true, "");
|
||||
|
||||
DiscordRichPresence presence = new DiscordRichPresence();
|
||||
presence.startTimestamp = System.currentTimeMillis() / 1000; // epoch second
|
||||
presence.state = state;
|
||||
//presence.details = details;
|
||||
presence.largeImageKey = "logo";
|
||||
presence.largeImageText = details;
|
||||
lib.Discord_UpdatePresence(presence);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGameExit() {
|
||||
DiscordRPC.INSTANCE.Discord_Shutdown();
|
||||
}
|
||||
};
|
||||
|
||||
Mindustry.args = Array.with(arg);
|
||||
|
||||
@@ -112,7 +112,17 @@ public class HtmlLauncher extends GwtApplication {
|
||||
public void addDialog(TextField field){
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onSceneChange(String state, String details, String icon) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGameExit() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
return new Mindustry();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user