Refactoring of functional package
This commit is contained in:
@@ -8,7 +8,7 @@ import io.anuke.arc.backends.sdl.*;
|
||||
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.func.*;
|
||||
import io.anuke.arc.input.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.scene.event.*;
|
||||
@@ -232,12 +232,12 @@ public class DesktopLauncher extends ClientLauncher{
|
||||
}
|
||||
|
||||
static void handleCrash(Throwable e){
|
||||
Consumer<Runnable> dialog = Runnable::run;
|
||||
Cons<Runnable> dialog = Runnable::run;
|
||||
boolean badGPU = false;
|
||||
|
||||
if(e.getMessage() != null && (e.getMessage().contains("Couldn't create window") || e.getMessage().contains("OpenGL 2.0 or higher"))){
|
||||
|
||||
dialog.accept(() -> message(
|
||||
dialog.get(() -> message(
|
||||
e.getMessage().contains("Couldn't create window") ? "A graphics initialization error has occured! Try to update your graphics drivers:\n" + e.getMessage() :
|
||||
"Your graphics card does not support OpenGL 2.0!\n" +
|
||||
"Try to update your graphics drivers.\n\n" +
|
||||
@@ -253,7 +253,7 @@ public class DesktopLauncher extends ClientLauncher{
|
||||
if(fc == null) fc = Strings.getFinalCause(e);
|
||||
Throwable cause = fc;
|
||||
if(!fbgp){
|
||||
dialog.accept(() -> message("A crash has occured. It has been saved in:\n" + file.getAbsolutePath() + "\n" + cause.getClass().getSimpleName().replace("Exception", "") + (cause.getMessage() == null ? "" : ":\n" + cause.getMessage())));
|
||||
dialog.get(() -> message("A crash has occured. It has been saved in:\n" + file.getAbsolutePath() + "\n" + cause.getClass().getSimpleName().replace("Exception", "") + (cause.getMessage() == null ? "" : ":\n" + cause.getMessage())));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.codedisaster.steamworks.SteamMatchmaking.*;
|
||||
import com.codedisaster.steamworks.SteamNetworking.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.function.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.pooling.*;
|
||||
@@ -39,7 +40,7 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
|
||||
final IntMap<SteamConnection> steamConnections = new IntMap<>(); //maps steam ID -> valid net connection
|
||||
|
||||
SteamID currentLobby, currentServer;
|
||||
Consumer<Host> lobbyCallback;
|
||||
Cons<Host> lobbyCallback;
|
||||
Runnable lobbyDoneCallback, joinCallback;
|
||||
|
||||
public SNet(NetProvider provider){
|
||||
@@ -164,7 +165,7 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discoverServers(Consumer<Host> callback, Runnable done){
|
||||
public void discoverServers(Cons<Host> callback, Runnable done){
|
||||
smat.addRequestLobbyListResultCountFilter(32);
|
||||
smat.requestLobbyList();
|
||||
lobbyCallback = callback;
|
||||
@@ -172,7 +173,7 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pingHost(String address, int port, Consumer<Host> valid, Consumer<Exception> failed){
|
||||
public void pingHost(String address, int port, Cons<Host> valid, Cons<Exception> failed){
|
||||
provider.pingHost(address, port, valid, failed);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.codedisaster.steamworks.SteamUGC.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.function.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.util.*;
|
||||
@@ -22,8 +23,8 @@ public class SWorkshop implements SteamUGCCallback{
|
||||
public final SteamUGC ugc = new SteamUGC(this);
|
||||
|
||||
private ObjectMap<Class<? extends Publishable>, Array<FileHandle>> workshopFiles = new ObjectMap<>();
|
||||
private ObjectMap<SteamUGCQuery, BiConsumer<Array<SteamUGCDetails>, SteamResult>> detailHandlers = new ObjectMap<>();
|
||||
private Array<Consumer<SteamPublishedFileID>> itemHandlers = new Array<>();
|
||||
private ObjectMap<SteamUGCQuery, Cons2<Array<SteamUGCDetails>, SteamResult>> detailHandlers = new ObjectMap<>();
|
||||
private Array<Cons<SteamPublishedFileID>> itemHandlers = new Array<>();
|
||||
private ObjectMap<SteamPublishedFileID, Runnable> updatedHandlers = new ObjectMap<>();
|
||||
|
||||
public SWorkshop(){
|
||||
@@ -169,7 +170,7 @@ public class SWorkshop implements SteamUGCCallback{
|
||||
}, () -> p.addSteamID(sid));
|
||||
}
|
||||
|
||||
void showPublish(Consumer<SteamPublishedFileID> published){
|
||||
void showPublish(Cons<SteamPublishedFileID> published){
|
||||
FloatingDialog dialog = new FloatingDialog("$confirm");
|
||||
dialog.setFillParent(false);
|
||||
dialog.cont.add("$publish.confirm").width(600f).wrap();
|
||||
@@ -188,18 +189,18 @@ public class SWorkshop implements SteamUGCCallback{
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
void query(SteamUGCQuery query, BiConsumer<Array<SteamUGCDetails>, SteamResult> handler){
|
||||
void query(SteamUGCQuery query, Cons2<Array<SteamUGCDetails>, SteamResult> handler){
|
||||
Log.info("POST QUERY " + query);
|
||||
detailHandlers.put(query, handler);
|
||||
ugc.sendQueryUGCRequest(query);
|
||||
}
|
||||
|
||||
void updateItem(SteamPublishedFileID publishedFileID, Consumer<SteamUGCUpdateHandle> tagger, Runnable updated){
|
||||
void updateItem(SteamPublishedFileID publishedFileID, Cons<SteamUGCUpdateHandle> tagger, Runnable updated){
|
||||
try{
|
||||
SteamUGCUpdateHandle h = ugc.startItemUpdate(SVars.steamID, publishedFileID);
|
||||
Log.info("begin updateItem({0})", publishedFileID.toString());
|
||||
|
||||
tagger.accept(h);
|
||||
tagger.get(h);
|
||||
Log.info("Tagged.");
|
||||
|
||||
ItemUpdateInfo info = new ItemUpdateInfo();
|
||||
@@ -239,10 +240,10 @@ public class SWorkshop implements SteamUGCCallback{
|
||||
details.add(new SteamUGCDetails());
|
||||
ugc.getQueryUGCResult(query, i, details.get(i));
|
||||
}
|
||||
detailHandlers.get(query).accept(details, result);
|
||||
detailHandlers.get(query).get(details, result);
|
||||
}else{
|
||||
Log.info("Nothing found.");
|
||||
detailHandlers.get(query).accept(new Array<>(), SteamResult.FileNotFound);
|
||||
detailHandlers.get(query).get(new Array<>(), SteamResult.FileNotFound);
|
||||
}
|
||||
|
||||
detailHandlers.remove(query);
|
||||
@@ -272,7 +273,7 @@ public class SWorkshop implements SteamUGCCallback{
|
||||
if(!itemHandlers.isEmpty()){
|
||||
if(result == SteamResult.OK){
|
||||
Log.info("Passing to first handler.");
|
||||
itemHandlers.first().accept(publishedFileID);
|
||||
itemHandlers.first().get(publishedFileID);
|
||||
}else{
|
||||
ui.showErrorMessage(Core.bundle.format("publish.error ", result.name()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user