mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-02 20:33:50 +07:00
Discord integration, basic rich presence
This commit is contained in:
parent
b6845d5d10
commit
12fad819b5
@ -53,6 +53,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-platform:$gdxVersion:natives-desktop"
|
||||
compile "com.badlogicgames.gdx:gdx-controllers-lwjgl3:$gdxVersion"
|
||||
compile "com.esotericsoftware:kryonet:2.22.0-RC1"
|
||||
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);
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class Vars{
|
||||
//how much the zoom changes every zoom button press
|
||||
public static final int zoomScale = Math.round(Unit.dp.scl(1));
|
||||
//if true, player speed will be increased, massive amounts of resources will be given on start, and other debug options will be available
|
||||
public static boolean debug = false;
|
||||
public static boolean debug = true;
|
||||
//whether the player can clip through walls
|
||||
public static boolean noclip = false;
|
||||
//whether to draw chunk borders
|
||||
|
@ -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))
|
||||
@ -293,6 +295,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(){
|
||||
@ -323,6 +329,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;
|
||||
@ -68,7 +71,31 @@ public class DesktopLauncher {
|
||||
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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user