Steam client init
This commit is contained in:
@@ -24,6 +24,7 @@ allprojects{
|
|||||||
appName = 'Mindustry'
|
appName = 'Mindustry'
|
||||||
gdxVersion = '1.9.10'
|
gdxVersion = '1.9.10'
|
||||||
roboVMVersion = '2.3.7'
|
roboVMVersion = '2.3.7'
|
||||||
|
steamworksVersion = '1.8.0'
|
||||||
arcHash = null
|
arcHash = null
|
||||||
|
|
||||||
debugged = {
|
debugged = {
|
||||||
@@ -171,6 +172,9 @@ project(":desktop-sdl"){
|
|||||||
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
||||||
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
|
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
|
||||||
|
|
||||||
|
compile "com.code-disaster.steamworks4j:steamworks4j:$steamworksVersion"
|
||||||
|
compile "com.code-disaster.steamworks4j:steamworks4j-server:$steamworksVersion"
|
||||||
|
|
||||||
compile arcModule("backends:backend-sdl")
|
compile arcModule("backends:backend-sdl")
|
||||||
compile 'com.github.MinnDevelopment:java-discord-rpc:v2.0.2'
|
compile 'com.github.MinnDevelopment:java-discord-rpc:v2.0.2'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package io.anuke.mindustry.desktopsdl;
|
package io.anuke.mindustry.desktopsdl;
|
||||||
|
|
||||||
import club.minnced.discord.rpc.*;
|
import club.minnced.discord.rpc.*;
|
||||||
import io.anuke.arc.backends.sdl.jni.SDL;
|
import com.codedisaster.steamworks.*;
|
||||||
|
import io.anuke.arc.backends.sdl.jni.*;
|
||||||
import io.anuke.arc.collection.*;
|
import io.anuke.arc.collection.*;
|
||||||
import io.anuke.arc.files.*;
|
import io.anuke.arc.files.*;
|
||||||
import io.anuke.arc.function.*;
|
import io.anuke.arc.function.*;
|
||||||
|
import io.anuke.arc.util.Timer;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.arc.util.serialization.*;
|
import io.anuke.arc.util.serialization.*;
|
||||||
import io.anuke.mindustry.core.GameState.*;
|
import io.anuke.mindustry.core.GameState.*;
|
||||||
@@ -19,7 +21,7 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
|
|
||||||
|
|
||||||
public class DesktopPlatform extends Platform{
|
public class DesktopPlatform extends Platform{
|
||||||
static boolean useDiscord = OS.is64Bit;
|
static boolean useDiscord = OS.is64Bit, useSteam = true;
|
||||||
final static String applicationId = "610508934456934412";
|
final static String applicationId = "610508934456934412";
|
||||||
String[] args;
|
String[] args;
|
||||||
|
|
||||||
@@ -39,6 +41,30 @@ public class DesktopPlatform extends Platform{
|
|||||||
Log.err("Failed to initialize discord.", t);
|
Log.err("Failed to initialize discord.", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(useSteam){
|
||||||
|
try{
|
||||||
|
SteamAPI.loadLibraries();
|
||||||
|
if(!SteamAPI.init()){
|
||||||
|
Log.info("Steam client not running.");
|
||||||
|
}else{
|
||||||
|
//times per second
|
||||||
|
float interval = 20f;
|
||||||
|
//run steam callbacks
|
||||||
|
Timer.schedule(() -> {
|
||||||
|
if(SteamAPI.isSteamRunning()){
|
||||||
|
SteamAPI.runCallbacks();
|
||||||
|
}
|
||||||
|
}, 1 / interval, 1f / interval);
|
||||||
|
|
||||||
|
//steam shutdown hook
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread(SteamAPI::shutdown));
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
Log.err("Failed to load Steam native libraries.");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleCrash(Throwable e){
|
static void handleCrash(Throwable e){
|
||||||
|
|||||||
Reference in New Issue
Block a user