mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-09-21 21:38:29 +03:00
Discord rich presence tweaks, wave balancing
This commit is contained in:
parent
2662c0a8fd
commit
5cac11b3fe
1
TODO.md
1
TODO.md
@ -41,6 +41,7 @@ _(not necessarily planned!)_
|
||||
- Underground blocks
|
||||
- Configurable outputs/inputs
|
||||
- Getting items out of the core
|
||||
- Map sharing/map browser
|
||||
|
||||
### Balance
|
||||
- Slow down progression slightly
|
||||
|
@ -94,8 +94,8 @@ public class AndroidLauncher extends AndroidApplication{
|
||||
|
||||
Net.setClientProvider(new KryoClient());
|
||||
Net.setServerProvider(new KryoServer());
|
||||
|
||||
initialize(new Mindustry(), config);
|
||||
|
||||
initialize(new Mindustry(), config);
|
||||
}
|
||||
|
||||
private boolean isPackageInstalled(String packagename) {
|
||||
|
@ -4,7 +4,6 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.I18NBundle;
|
||||
import com.badlogic.gdx.utils.OrderedMap;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.io.PlatformFunction;
|
||||
@ -21,8 +20,6 @@ public class Mindustry extends ModuleCore {
|
||||
public static boolean hasDiscord = true;
|
||||
public static Array<String> args = new Array<>();
|
||||
public static PlatformFunction platforms = new PlatformFunction(){};
|
||||
public static OrderedMap<String, Integer> idMap = new OrderedMap<>();
|
||||
|
||||
public static boolean externalBundle = false;
|
||||
|
||||
@Override
|
||||
|
@ -197,5 +197,20 @@ public class UI extends SceneModule{
|
||||
});
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,13 +16,13 @@ public class WaveCreator{
|
||||
scaling = 1;
|
||||
after = 3;
|
||||
spacing = 5;
|
||||
amount = 4;
|
||||
amount = 3;
|
||||
tierscaleback = 0;
|
||||
}},
|
||||
|
||||
new EnemySpawn(EnemyTypes.blast){{
|
||||
after = 4;
|
||||
amount = 3;
|
||||
amount = 2;
|
||||
spacing = 5;
|
||||
scaling = 2;
|
||||
tierscaleback = 0;
|
||||
@ -65,7 +65,7 @@ public class WaveCreator{
|
||||
|
||||
new EnemySpawn(EnemyTypes.flamer){{
|
||||
after = 12;
|
||||
amount = 3;
|
||||
amount = 2;
|
||||
spacing = 5;
|
||||
scaling = 3;
|
||||
}},
|
||||
|
@ -41,6 +41,21 @@ public class DesktopLauncher {
|
||||
DiscordRPC lib = DiscordRPC.INSTANCE;
|
||||
String applicationId = "398246104468291591";
|
||||
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, "");
|
||||
|
||||
Mindustry.platforms = new PlatformFunction(){
|
||||
@ -71,19 +86,19 @@ public class DesktopLauncher {
|
||||
DiscordRichPresence presence = new DiscordRichPresence();
|
||||
|
||||
if(!GameState.is(State.menu)){
|
||||
presence.state = "Map: " + Strings.capitalize(Vars.world.getMap().name);
|
||||
presence.details = "Wave " + Vars.control.getWave();
|
||||
presence.state = Strings.capitalize(Vars.control.getMode().toString()) + ", Solo";
|
||||
presence.details = Strings.capitalize(Vars.world.getMap().name) + " | Wave " + Vars.control.getWave();
|
||||
presence.largeImageText = "Wave " + Vars.control.getWave();
|
||||
if(Net.active() ){
|
||||
presence.partyMax = 16;
|
||||
presence.partySize = Vars.control.playerGroup.amount();
|
||||
presence.state = Strings.capitalize(Vars.control.getMode().toString());
|
||||
}
|
||||
}else{
|
||||
presence.state = "In Menu";
|
||||
}
|
||||
|
||||
//presence.startTimestamp = System.currentTimeMillis() / 1000; // epoch second
|
||||
presence.largeImageKey = "logo";
|
||||
presence.largeImageText = presence.details;
|
||||
|
||||
lib.Discord_UpdatePresence(presence);
|
||||
}
|
||||
@ -104,13 +119,9 @@ public class DesktopLauncher {
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
|
||||
try{
|
||||
Net.closeServer();
|
||||
}catch (Exception p){}
|
||||
|
||||
try{
|
||||
Net.disconnect();
|
||||
}catch (Exception p){}
|
||||
//attempt to close connections
|
||||
try{ Net.closeServer(); }catch (Exception p){}
|
||||
try{ Net.disconnect(); }catch (Exception p){}
|
||||
|
||||
//don't create crash logs for me (anuke), as it's expected
|
||||
if(System.getProperty("user.name").equals("anuke")) return;
|
||||
|
@ -68,6 +68,8 @@ public class KryoServer implements ServerProvider {
|
||||
|
||||
@Override
|
||||
public void disconnected (Connection connection) {
|
||||
connections.removeValue(connection.getID());
|
||||
|
||||
Disconnect c = new Disconnect();
|
||||
c.id = connection.getID();
|
||||
|
||||
@ -77,8 +79,6 @@ public class KryoServer implements ServerProvider {
|
||||
Gdx.app.exit();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
connections.removeValue(c.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -104,7 +104,14 @@ public class KryoServer implements ServerProvider {
|
||||
|
||||
@Override
|
||||
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();
|
||||
p.reason = (byte)KickReason.kick.ordinal();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user