further progress
This commit is contained in:
@@ -47,6 +47,18 @@ task dist(type: Jar, dependsOn: classes){
|
||||
}
|
||||
}
|
||||
|
||||
task steamdist(dependsOn: dist){
|
||||
doLast{
|
||||
copy{
|
||||
from "build/libs/Mindustry-linux-release.jar"
|
||||
into "/home/anuke/.steam/steam/steamapps/common/Mindustry"
|
||||
rename { String fileName ->
|
||||
fileName.replace("Mindustry-linux-release", "desktop-release")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task ikZip(type: Zip){
|
||||
def filename = "$appName-${getTarget()}-${version}"
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import io.anuke.arc.Files.*;
|
||||
import io.anuke.arc.backends.sdl.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.desktopsdl.steam.*;
|
||||
import io.anuke.mindustry.net.*;
|
||||
|
||||
public class DesktopLauncher{
|
||||
@@ -12,7 +13,7 @@ public class DesktopLauncher{
|
||||
Platform.instance = new DesktopPlatform(arg);
|
||||
|
||||
Net.setClientProvider(new ArcNetClient());
|
||||
Net.setServerProvider(new ArcNetServer());
|
||||
Net.setServerProvider(new ServerSteam(new ArcNetServer()));
|
||||
|
||||
new SdlApplication(new Mindustry(), new SdlConfig(){{
|
||||
title = "Mindustry";
|
||||
|
||||
@@ -7,14 +7,15 @@ import io.anuke.arc.backends.sdl.jni.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.function.*;
|
||||
import io.anuke.arc.util.Timer;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.serialization.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.desktopsdl.steam.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.net.*;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.*;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
|
||||
import java.net.*;
|
||||
@@ -46,6 +47,7 @@ public class DesktopPlatform extends Platform{
|
||||
}
|
||||
|
||||
if(useSteam){
|
||||
Vars.steam = true;
|
||||
try{
|
||||
SteamAPI.loadLibraries();
|
||||
if(!SteamAPI.init()){
|
||||
@@ -53,14 +55,23 @@ public class DesktopPlatform extends Platform{
|
||||
}else{
|
||||
//times per second
|
||||
float interval = 20f;
|
||||
Interval i = new Interval();
|
||||
|
||||
//run steam callbacks
|
||||
Events.on(GameLoadEvent.class, event -> {
|
||||
Timer.schedule(() -> {
|
||||
if(SteamAPI.isSteamRunning()){
|
||||
SteamAPI.runCallbacks();
|
||||
//update callbacks
|
||||
Core.app.addListener(new ApplicationListener(){
|
||||
@Override
|
||||
public void update(){
|
||||
if(i.get(interval)){
|
||||
if(SteamAPI.isSteamRunning()){
|
||||
SteamAPI.runCallbacks();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0f, 1f / interval);
|
||||
});
|
||||
|
||||
Core.app.post(() -> new ClientSteam());
|
||||
});
|
||||
//steam shutdown hook
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(SteamAPI::shutdown));
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package io.anuke.mindustry.desktopsdl.steam;
|
||||
|
||||
import com.codedisaster.steamworks.*;
|
||||
import com.codedisaster.steamworks.SteamFriends.*;
|
||||
import com.codedisaster.steamworks.SteamMatchmaking.*;
|
||||
import com.codedisaster.steamworks.SteamNetworking.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.util.*;
|
||||
@@ -9,29 +11,36 @@ import io.anuke.mindustry.net.*;
|
||||
|
||||
import java.nio.*;
|
||||
|
||||
public class ClientSteam implements SteamNetworkingCallback{
|
||||
private SteamNetworking steam;
|
||||
public class ClientSteam implements SteamNetworkingCallback, SteamMatchmakingCallback{
|
||||
private SteamNetworking snet;
|
||||
private SteamMatchmaking smat;
|
||||
|
||||
private ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 128);
|
||||
//maps steam ID -> valid net connection
|
||||
private IntMap<SteamConnection> connections = new IntMap<>();
|
||||
|
||||
public ClientSteam(){
|
||||
steam = new SteamNetworking(this);
|
||||
//snet = new SteamNetworking(this);
|
||||
//smat = new SteamMatchmaking(this);
|
||||
|
||||
//Log.info("Calling createLobby");
|
||||
//SteamAPICall call = smat.createLobby(LobbyType.FriendsOnly, 16);
|
||||
|
||||
/*
|
||||
new Thread(() -> {
|
||||
int length;
|
||||
SteamID from = new SteamID();
|
||||
while((length = steam.isP2PPacketAvailable(0)) != 0){
|
||||
while((length = snet.isP2PPacketAvailable(0)) != 0){
|
||||
try{
|
||||
buffer.position(0);
|
||||
steam.readP2PPacket(from, buffer, 0);
|
||||
snet.readP2PPacket(from, buffer, 0);
|
||||
}catch(SteamException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}){{
|
||||
setDaemon(true);
|
||||
}}.start();
|
||||
}}.start();*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,7 +50,7 @@ public class ClientSteam implements SteamNetworkingCallback{
|
||||
|
||||
@Override
|
||||
public void onP2PSessionRequest(SteamID steamIDRemote){
|
||||
steam.acceptP2PSessionWithUser(steamIDRemote);
|
||||
snet.acceptP2PSessionWithUser(steamIDRemote);
|
||||
}
|
||||
|
||||
class SteamConnection extends NetConnection{
|
||||
@@ -83,4 +92,106 @@ public class ClientSteam implements SteamNetworkingCallback{
|
||||
//if(connection.isConnected()) connection.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFavoritesListChanged(int ip, int queryPort, int connPort, int appID, int flags, boolean add, int accountID){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLobbyInvite(SteamID steamIDUser, SteamID steamIDLobby, long gameID){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLobbyEnter(SteamID steamIDLobby, int chatPermissions, boolean blocked, ChatRoomEnterResponse response){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLobbyDataUpdate(SteamID steamIDLobby, SteamID steamIDMember, boolean success){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLobbyChatUpdate(SteamID steamIDLobby, SteamID steamIDUserChanged, SteamID steamIDMakingChange, ChatMemberStateChange stateChange){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLobbyChatMessage(SteamID steamIDLobby, SteamID steamIDUser, ChatEntryType entryType, int chatID){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLobbyGameCreated(SteamID steamIDLobby, SteamID steamIDGameServer, int ip, short port){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLobbyMatchList(int lobbiesMatching){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLobbyKicked(SteamID steamIDLobby, SteamID steamIDAdmin, boolean kickedDueToDisconnect){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLobbyCreated(SteamResult result, SteamID steamIDLobby){
|
||||
Log.info("Lobby create callback");
|
||||
Log.info("Lobby {1} created? {0}", result, steamIDLobby.getAccountID());
|
||||
if(result == SteamResult.OK){
|
||||
SteamFriends friends = new SteamFriends(new SteamFriendsCallback(){
|
||||
@Override
|
||||
public void onSetPersonaNameResponse(boolean success, boolean localSuccess, SteamResult result){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPersonaStateChange(SteamID steamID, PersonaChange change){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGameOverlayActivated(boolean active){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGameLobbyJoinRequested(SteamID steamIDLobby, SteamID steamIDFriend){
|
||||
Log.info("Requested {0} to join lobby {1}", steamIDFriend.getAccountID(), steamIDLobby.getAccountID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAvatarImageLoaded(SteamID steamID, int image, int width, int height){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFriendRichPresenceUpdate(SteamID steamIDFriend, int appID){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGameRichPresenceJoinRequested(SteamID steamIDFriend, String connect){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGameServerChangeRequested(String server, String password){
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
friends.activateGameOverlay(OverlayDialog.Friends);
|
||||
//friends.activateGameOverlayInviteDialog(steamIDLobby);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFavoritesListAccountsUpdated(SteamResult result){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
package io.anuke.mindustry.desktopsdl.steam;
|
||||
|
||||
import com.codedisaster.steamworks.*;
|
||||
import com.codedisaster.steamworks.SteamMatchmaking.*;
|
||||
import com.codedisaster.steamworks.SteamNetworking.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.desktopsdl.steam.ClientSteam.*;
|
||||
import io.anuke.mindustry.net.Net.*;
|
||||
import io.anuke.mindustry.net.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.*;
|
||||
|
||||
public class ServerSteam implements ServerProvider, SteamNetworkingCallback, SteamMatchmakingCallback{
|
||||
private final static int maxLobbyPlayers = 32;
|
||||
|
||||
private final SteamNetworking snet = new SteamNetworking(this);
|
||||
private final SteamMatchmaking smat = new SteamMatchmaking(this);
|
||||
private final ServerProvider server;
|
||||
|
||||
//buffer for steam API calls
|
||||
private ByteBuffer steamBuffer = ByteBuffer.allocateDirect(1024 * 128);
|
||||
//maps steam ID -> valid net connection
|
||||
private IntMap<SteamConnection> steamConnections = new IntMap<>();
|
||||
|
||||
private SteamID currentLobby;
|
||||
|
||||
public ServerSteam(ServerProvider server){
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
//server overrides
|
||||
|
||||
@Override
|
||||
public void host(int port) throws IOException{
|
||||
server.host(port);
|
||||
smat.createLobby(LobbyType.values()[Core.settings.getInt("lobbytype", 1)], maxLobbyPlayers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendStream(int id, Streamable stream){
|
||||
server.sendStream(id, stream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Object object, SendMode mode){
|
||||
server.send(object, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTo(int id, Object object, SendMode mode){
|
||||
server.sendTo(id, object, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendExcept(int id, Object object, SendMode mode){
|
||||
server.sendExcept(id, object, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close(){
|
||||
server.close();
|
||||
if(currentLobby != null){
|
||||
//TODO kick everyone who is in this lobby?
|
||||
smat.leaveLobby(currentLobby);
|
||||
currentLobby = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] compressSnapshot(byte[] input){
|
||||
return server.compressSnapshot(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array<? extends NetConnection> getConnections(){
|
||||
return server.getConnections();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetConnection getByID(int id){
|
||||
return server.getByID(id);
|
||||
}
|
||||
|
||||
//steam lobby overrides
|
||||
|
||||
@Override
|
||||
public void onFavoritesListChanged(int ip, int queryPort, int connPort, int appID, int flags, boolean add, int accountID){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLobbyInvite(SteamID steamIDUser, SteamID steamIDLobby, long gameID){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLobbyEnter(SteamID steamIDLobby, int chatPermissions, boolean blocked, ChatRoomEnterResponse response){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLobbyDataUpdate(SteamID steamIDLobby, SteamID steamIDMember, boolean success){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLobbyChatUpdate(SteamID steamIDLobby, SteamID steamIDUserChanged, SteamID steamIDMakingChange, ChatMemberStateChange stateChange){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLobbyChatMessage(SteamID steamIDLobby, SteamID steamIDUser, ChatEntryType entryType, int chatID){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLobbyGameCreated(SteamID steamIDLobby, SteamID steamIDGameServer, int ip, short port){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLobbyMatchList(int lobbiesMatching){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLobbyKicked(SteamID steamIDLobby, SteamID steamIDAdmin, boolean kickedDueToDisconnect){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLobbyCreated(SteamResult result, SteamID steamIDLobby){
|
||||
Log.info("Lobby create callback");
|
||||
Log.info("Lobby {1} created? {0}", result, steamIDLobby.getAccountID());
|
||||
if(result == SteamResult.OK){
|
||||
currentLobby = steamIDLobby;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFavoritesListAccountsUpdated(SteamResult result){
|
||||
|
||||
}
|
||||
|
||||
//steam p2p network overrides
|
||||
|
||||
@Override
|
||||
public void onP2PSessionConnectFail(SteamID steamIDRemote, P2PSessionError sessionError){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onP2PSessionRequest(SteamID steamIDRemote){
|
||||
//accept users on request
|
||||
snet.acceptP2PSessionWithUser(steamIDRemote);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package io.anuke.mindustry.desktopsdl.steam;
|
||||
|
||||
import com.codedisaster.steamworks.*;
|
||||
import com.codedisaster.steamworks.SteamRemoteStorage.*;
|
||||
import io.anuke.mindustry.maps.*;
|
||||
|
||||
public class WorkshopImpl implements SteamUGCCallback{
|
||||
private SteamUGC ugc = new SteamUGC(this);
|
||||
|
||||
public void publishMap(Map map){
|
||||
ugc.createItem(1127400, WorkshopFileType.GameManagedItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUGCQueryCompleted(SteamUGCQuery query, int numResultsReturned, int totalMatchingResults, boolean isCachedData, SteamResult result){
|
||||
//ugc.submitItemUpdate()
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribeItem(SteamPublishedFileID publishedFileID, SteamResult result){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnsubscribeItem(SteamPublishedFileID publishedFileID, SteamResult result){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestUGCDetails(SteamUGCDetails details, SteamResult result){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateItem(SteamPublishedFileID publishedFileID, boolean needsToAcceptWLA, SteamResult result){
|
||||
//TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubmitItemUpdate(SteamPublishedFileID publishedFileID, boolean needsToAcceptWLA, SteamResult result){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadItemResult(int appID, SteamPublishedFileID publishedFileID, SteamResult result){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserFavoriteItemsListChanged(SteamPublishedFileID publishedFileID, boolean wasAddRequest, SteamResult result){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetUserItemVote(SteamPublishedFileID publishedFileID, boolean voteUp, SteamResult result){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetUserItemVote(SteamPublishedFileID publishedFileID, boolean votedUp, boolean votedDown, boolean voteSkipped, SteamResult result){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartPlaytimeTracking(SteamResult result){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopPlaytimeTracking(SteamResult result){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopPlaytimeTrackingForAllItems(SteamResult result){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteItem(SteamPublishedFileID publishedFileID, SteamResult result){
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user