Discord rich presence tweaks, wave balancing

This commit is contained in:
Anuken
2018-01-08 22:57:07 -05:00
parent 2662c0a8fd
commit 5cac11b3fe
7 changed files with 53 additions and 22 deletions

View File

@ -41,6 +41,7 @@ _(not necessarily planned!)_
- Underground blocks - Underground blocks
- Configurable outputs/inputs - Configurable outputs/inputs
- Getting items out of the core - Getting items out of the core
- Map sharing/map browser
### Balance ### Balance
- Slow down progression slightly - Slow down progression slightly

View File

@ -94,8 +94,8 @@ public class AndroidLauncher extends AndroidApplication{
Net.setClientProvider(new KryoClient()); Net.setClientProvider(new KryoClient());
Net.setServerProvider(new KryoServer()); Net.setServerProvider(new KryoServer());
initialize(new Mindustry(), config); initialize(new Mindustry(), config);
} }
private boolean isPackageInstalled(String packagename) { private boolean isPackageInstalled(String packagename) {

View File

@ -4,7 +4,6 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.I18NBundle; import com.badlogic.gdx.utils.I18NBundle;
import com.badlogic.gdx.utils.OrderedMap;
import io.anuke.mindustry.core.*; import io.anuke.mindustry.core.*;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.io.PlatformFunction; import io.anuke.mindustry.io.PlatformFunction;
@ -21,8 +20,6 @@ public class Mindustry extends ModuleCore {
public static boolean hasDiscord = true; public static boolean hasDiscord = true;
public static Array<String> args = new Array<>(); public static Array<String> args = new Array<>();
public static PlatformFunction platforms = new PlatformFunction(){}; public static PlatformFunction platforms = new PlatformFunction(){};
public static OrderedMap<String, Integer> idMap = new OrderedMap<>();
public static boolean externalBundle = false; public static boolean externalBundle = false;
@Override @Override

View File

@ -197,5 +197,20 @@ public class UI extends SceneModule{
}); });
dialog.show(); dialog.show();
} }
public void showConfirmListen(String title, String text, Consumer<Boolean> listener){
FloatingDialog dialog = new FloatingDialog(title);
dialog.content().add(text).pad(4f);
dialog.buttons().defaults().size(200f, 54f).pad(2f);
dialog.buttons().addButton("$text.cancel", () -> {
dialog.hide();
listener.accept(true);
});
dialog.buttons().addButton("$text.ok", () -> {
dialog.hide();
listener.accept(true);
});
dialog.show();
}
} }

View File

@ -16,13 +16,13 @@ public class WaveCreator{
scaling = 1; scaling = 1;
after = 3; after = 3;
spacing = 5; spacing = 5;
amount = 4; amount = 3;
tierscaleback = 0; tierscaleback = 0;
}}, }},
new EnemySpawn(EnemyTypes.blast){{ new EnemySpawn(EnemyTypes.blast){{
after = 4; after = 4;
amount = 3; amount = 2;
spacing = 5; spacing = 5;
scaling = 2; scaling = 2;
tierscaleback = 0; tierscaleback = 0;
@ -65,7 +65,7 @@ public class WaveCreator{
new EnemySpawn(EnemyTypes.flamer){{ new EnemySpawn(EnemyTypes.flamer){{
after = 12; after = 12;
amount = 3; amount = 2;
spacing = 5; spacing = 5;
scaling = 3; scaling = 3;
}}, }},

View File

@ -41,6 +41,21 @@ public class DesktopLauncher {
DiscordRPC lib = DiscordRPC.INSTANCE; DiscordRPC lib = DiscordRPC.INSTANCE;
String applicationId = "398246104468291591"; String applicationId = "398246104468291591";
DiscordEventHandlers handlers = new DiscordEventHandlers(); DiscordEventHandlers handlers = new DiscordEventHandlers();
handlers.joinGame = secret -> {
};
handlers.joinRequest = request -> {
//TODO actual text
Vars.ui.showConfirmListen("$text.join.discord.title", "$text.join.discord", b -> {
if(b){
lib.Discord_Respond(request.userId, DiscordRPC.DISCORD_REPLY_YES);
}else{
lib.Discord_Respond(request.userId, DiscordRPC.DISCORD_REPLY_NO);
}
});
};
lib.Discord_Initialize(applicationId, handlers, true, ""); lib.Discord_Initialize(applicationId, handlers, true, "");
Mindustry.platforms = new PlatformFunction(){ Mindustry.platforms = new PlatformFunction(){
@ -71,19 +86,19 @@ public class DesktopLauncher {
DiscordRichPresence presence = new DiscordRichPresence(); DiscordRichPresence presence = new DiscordRichPresence();
if(!GameState.is(State.menu)){ if(!GameState.is(State.menu)){
presence.state = "Map: " + Strings.capitalize(Vars.world.getMap().name); presence.state = Strings.capitalize(Vars.control.getMode().toString()) + ", Solo";
presence.details = "Wave " + Vars.control.getWave(); presence.details = Strings.capitalize(Vars.world.getMap().name) + " | Wave " + Vars.control.getWave();
presence.largeImageText = "Wave " + Vars.control.getWave();
if(Net.active() ){ if(Net.active() ){
presence.partyMax = 16; presence.partyMax = 16;
presence.partySize = Vars.control.playerGroup.amount(); presence.partySize = Vars.control.playerGroup.amount();
presence.state = Strings.capitalize(Vars.control.getMode().toString());
} }
}else{ }else{
presence.state = "In Menu"; presence.state = "In Menu";
} }
//presence.startTimestamp = System.currentTimeMillis() / 1000; // epoch second
presence.largeImageKey = "logo"; presence.largeImageKey = "logo";
presence.largeImageText = presence.details;
lib.Discord_UpdatePresence(presence); lib.Discord_UpdatePresence(presence);
} }
@ -104,13 +119,9 @@ public class DesktopLauncher {
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
try{ //attempt to close connections
Net.closeServer(); try{ Net.closeServer(); }catch (Exception p){}
}catch (Exception p){} try{ Net.disconnect(); }catch (Exception p){}
try{
Net.disconnect();
}catch (Exception p){}
//don't create crash logs for me (anuke), as it's expected //don't create crash logs for me (anuke), as it's expected
if(System.getProperty("user.name").equals("anuke")) return; if(System.getProperty("user.name").equals("anuke")) return;

View File

@ -68,6 +68,8 @@ public class KryoServer implements ServerProvider {
@Override @Override
public void disconnected (Connection connection) { public void disconnected (Connection connection) {
connections.removeValue(connection.getID());
Disconnect c = new Disconnect(); Disconnect c = new Disconnect();
c.id = connection.getID(); c.id = connection.getID();
@ -77,8 +79,6 @@ public class KryoServer implements ServerProvider {
Gdx.app.exit(); Gdx.app.exit();
throw new RuntimeException(e); throw new RuntimeException(e);
} }
connections.removeValue(c.id);
} }
@Override @Override
@ -104,7 +104,14 @@ public class KryoServer implements ServerProvider {
@Override @Override
public void kick(int connection) { public void kick(int connection) {
Connection conn = getByID(connection); Connection conn;
try {
conn = getByID(connection);
}catch (Exception e){
e.printStackTrace();
connections.removeValue(connection);
return;
}
KickPacket p = new KickPacket(); KickPacket p = new KickPacket();
p.reason = (byte)KickReason.kick.ordinal(); p.reason = (byte)KickReason.kick.ordinal();