Many small tweaks / Custom rules / Server run files / Balance

This commit is contained in:
Anuken
2019-03-24 16:29:25 -04:00
parent ea5c78f814
commit f7aa58e385
60 changed files with 4706 additions and 4711 deletions
@@ -27,7 +27,9 @@ public class AboutDialog extends FloatingDialog{
public AboutDialog(){
super("$about.button");
Contributors.getContributors(out -> contributors = out, Throwable::printStackTrace);
if(!ios){
Contributors.getContributors(out -> contributors = out, Throwable::printStackTrace);
}
shown(this::setup);
onResize(this::setup);
@@ -7,8 +7,8 @@ import io.anuke.arc.scene.ui.Dialog;
import io.anuke.arc.scene.ui.ImageButton;
import io.anuke.arc.scene.ui.layout.Table;
import static io.anuke.mindustry.Vars.player;
import static io.anuke.mindustry.Vars.playerColors;
import static io.anuke.mindustry.Vars.players;
public class ColorPickDialog extends Dialog{
private Consumer<Color> cons;
@@ -29,7 +29,7 @@ public class ColorPickDialog extends Dialog{
cons.accept(color);
hide();
}).size(48).get();
button.setChecked(players[0].color.equals(color));
button.setChecked(player.color.equals(color));
button.getStyle().imageUpColor = color;
if(i % 4 == 3){
@@ -21,6 +21,7 @@ import static io.anuke.mindustry.Vars.*;
public class CustomGameDialog extends FloatingDialog{
Difficulty difficulty = Difficulty.normal;
RulePreset lastPreset = RulePreset.survival;
CustomRulesDialog dialog = new CustomRulesDialog();
public CustomGameDialog(){
super("$customgame");
@@ -31,7 +32,9 @@ public class CustomGameDialog extends FloatingDialog{
}
void setup(){
state.rules = lastPreset.get();
if(lastPreset == null){
lastPreset = RulePreset.survival;
}
cont.clear();
Table maps = new Table();
@@ -51,12 +54,16 @@ public class CustomGameDialog extends FloatingDialog{
for(RulePreset mode : RulePreset.values()){
modes.addButton(mode.toString(), "toggle", () -> {
state.rules = mode.get();
lastPreset = mode;
}).update(b -> b.setChecked(lastPreset == mode)).group(group).size(140f, 54f);
if(i++ % 2 == 1) modes.row();
}
selmode.add(modes);
selmode.addButton("$mode.custom", "toggle", () -> {})
.update(b -> b.setChecked(lastPreset == null)).size(108f).group(group).get().tapped(() -> {
lastPreset = null;
dialog.show();
});
selmode.addButton("?", this::displayGameModeHelp).width(50f).fillY().padLeft(18f);
cont.add(selmode);
@@ -86,7 +93,7 @@ public class CustomGameDialog extends FloatingDialog{
state.wavetime = difficulty.waveTime;
}).width(s);
cont.add(sdif);
cont.add(sdif).visible(() -> lastPreset != null);
cont.row();
float images = 146f;
@@ -114,7 +121,7 @@ public class CustomGameDialog extends FloatingDialog{
image.clicked(() -> {
hide();
control.playMap(map, lastPreset.get());
control.playMap(map, lastPreset == null ? dialog.rules : lastPreset.get());
});
maps.add(image);
@@ -0,0 +1,56 @@
package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.function.FloatConsumer;
import io.anuke.arc.function.FloatProvider;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.util.Strings;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.game.Rules;
import static io.anuke.mindustry.Vars.tilesize;
public class CustomRulesDialog extends FloatingDialog{
public final Rules rules = new Rules();
private Table main;
public CustomRulesDialog(){
super("$mode.custom");
setFillParent(true);
shown(this::setup);
addCloseButton();
}
void setup(){
cont.clear();
cont.pane(m -> main = m);
main.margin(10f);
main.left().defaults().fillX().left().pad(5);
main.row();
main.addCheck("$rules.infiniteresources", b -> rules.infiniteResources = b).checked(b -> rules.infiniteResources);
main.row();
main.addCheck("$rules.wavetimer", b -> rules.waveTimer = b).checked(b -> rules.waveTimer);
main.row();
main.addCheck("$rules.waves", b -> rules.waves = b).checked(b -> rules.waves);
main.row();
main.addCheck("$rules.pvp", b -> rules.pvp = b).checked(b -> rules.pvp);
main.row();
main.addCheck("$rules.unitdrops", b -> rules.unitDrops = b).checked(b -> rules.unitDrops);
main.row();
number("$rules.enemycorebuildradius", f -> rules.enemyCoreBuildRadius = f*tilesize, () -> Math.min(rules.enemyCoreBuildRadius/tilesize, 200));
number("$rules.respawntime", f -> rules.respawnTime = f*60f, () -> rules.respawnTime/60f);
number("$rules.wavespacing", f -> rules.waveSpacing = f*60f, () -> rules.waveSpacing/60f);
}
void number(String text, FloatConsumer cons, FloatProvider prov){
main.table(t -> {
t.left();
t.add(text).left().padRight(5);
Platform.instance.addDialog(t.addField((int)prov.get() + "", s -> cons.accept(Strings.parseFloat(s)))
.valid(Strings::canParsePositiveFloat).width(120f).left().get());
});
main.row();
}
}
@@ -6,12 +6,11 @@ import io.anuke.arc.scene.ui.ImageButton;
import io.anuke.arc.util.Strings;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.type.Player;
import io.anuke.mindustry.net.Net;
import java.io.IOException;
import static io.anuke.mindustry.Vars.players;
import static io.anuke.mindustry.Vars.player;
import static io.anuke.mindustry.Vars.ui;
public class HostDialog extends FloatingDialog{
@@ -20,8 +19,6 @@ public class HostDialog extends FloatingDialog{
public HostDialog(){
super("$hostserver");
Player player = players[0];
addCloseButton();
cont.table(t -> {
@@ -14,7 +14,6 @@ import io.anuke.arc.util.Strings;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.entities.type.Player;
import io.anuke.mindustry.game.Version;
import io.anuke.mindustry.net.Host;
import io.anuke.mindustry.net.Net;
@@ -185,8 +184,6 @@ public class JoinDialog extends FloatingDialog{
void setup(){
float w = targetWidth();
Player player = players[0];
hosts.clear();
hosts.add(remote).growX();
@@ -1,61 +0,0 @@
package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.Core;
import io.anuke.arc.scene.ui.Image;
import io.anuke.arc.scene.ui.layout.Stack;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.util.Scaling;
import io.anuke.mindustry.entities.type.Player;
import static io.anuke.mindustry.Vars.control;
import static io.anuke.mindustry.Vars.players;
public class LocalPlayerDialog extends FloatingDialog{
public LocalPlayerDialog(){
super("$addplayers");
addCloseButton();
shown(this::rebuild);
}
private void rebuild(){
float size = 140f;
cont.clear();
if(players.length > 1){
cont.addImageButton("icon-cancel", 14 * 2, () -> {
control.removePlayer();
rebuild();
}).size(50f, size).pad(5).bottom();
}else{
cont.add().size(50f, size);
}
for(Player player : players){
Table table = new Table();
Stack stack = new Stack();
stack.add(new Image("button"));
Image img = new Image(Core.atlas.find("icon-chat"));
img.setScaling(Scaling.fill);
stack.add(img);
table.add("Player " + (player.playerIndex + 1)).update(label -> label.setColor(player.color));
table.row();
table.add(stack).size(size);
cont.add(table).pad(5);
}
if(players.length < 4){
cont.addImageButton("icon-add", 14 * 2, () -> {
control.addPlayer(players.length);
rebuild();
}).size(50f, size).pad(5).bottom();
}
}
}
@@ -14,6 +14,7 @@ import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.util.Align;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.graphics.Pal;
import io.anuke.mindustry.net.Net;
@@ -194,6 +195,18 @@ public class SettingsMenuDialog extends SettingsDialog{
if(Core.settings.getBool("fullscreen")){
Core.graphics.setFullscreenMode(Core.graphics.getDisplayMode());
}
}else{
graphics.checkPref("landscape", false, b -> {
if(b){
Platform.instance.beginForceLandscape();
}else{
Platform.instance.endForceLandscape();
}
});
if(Core.settings.getBool("landscape")){
Platform.instance.beginForceLandscape();
}
}
graphics.checkPref("fps", false);
@@ -14,8 +14,7 @@ import io.anuke.mindustry.input.InputHandler;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import static io.anuke.mindustry.Vars.state;
import static io.anuke.mindustry.Vars.tilesize;
import static io.anuke.mindustry.Vars.*;
public class BlockConfigFragment extends Fragment{
private Table table = new Table();
@@ -59,7 +58,7 @@ public class BlockConfigFragment extends Fragment{
return;
}
if(configTile != null && configTile.block().shouldHideConfigure(configTile, input.player)){
if(configTile != null && configTile.block().shouldHideConfigure(configTile, player)){
hideConfig();
return;
}
@@ -87,8 +87,6 @@ public class BlockInventoryFragment extends Fragment{
private void rebuild(boolean actions){
Player player = input.player;
IntSet container = new IntSet();
table.clearChildren();
@@ -109,7 +109,7 @@ public class ChatFragment extends Table{
fieldlabel.setStyle(fieldlabel.getStyle());
chatfield = new TextField("", new TextField.TextFieldStyle(scene.skin.get(TextField.TextFieldStyle.class)));
chatfield.setTextFieldFilter((field, c) -> field.getText().length() < Vars.maxTextLength);
chatfield.setFilter((field, c) -> field.getText().length() < Vars.maxTextLength);
chatfield.getStyle().background = null;
chatfield.getStyle().font = scene.skin.getFont("default-font-chat");
chatfield.getStyle().fontColor = Color.WHITE;
@@ -207,7 +207,7 @@ public class ChatFragment extends Table{
history.insert(1, message);
Call.sendMessage(players[0], message);
Call.sendMessage(player, message);
}
public void toggle(){
@@ -184,9 +184,9 @@ public class HudFragment extends Fragment{
t.table("flat", c -> c.add("")
.update(l ->{
l.setColor(Tmp.c1.set(Color.WHITE).lerp(Color.SCARLET, Mathf.absin(Time.time(), 10f, 1f)));
l.setText(Core.bundle.format("outofbounds", (int)((boundsCountdown - players[0].destructTime) / 60f)));
l.setText(Core.bundle.format("outofbounds", (int)((boundsCountdown - player.destructTime) / 60f)));
}).get().setAlignment(Align.center, Align.center)).margin(6).update(u -> {
u.color.a = Mathf.lerpDelta(u.color.a, Mathf.num(players[0].isOutOfBounds()), 0.1f);
u.color.a = Mathf.lerpDelta(u.color.a, Mathf.num(player.isOutOfBounds()), 0.1f);
}).get().color.a = 0f;
});
@@ -207,13 +207,13 @@ public class HudFragment extends Fragment{
});
t.top().visible(() -> {
if(state.is(State.menu) || state.teams.get(players[0].getTeam()).cores.size == 0 ||
state.teams.get(players[0].getTeam()).cores.first().entity == null){
if(state.is(State.menu) || state.teams.get(player.getTeam()).cores.size == 0 ||
state.teams.get(player.getTeam()).cores.first().entity == null){
coreAttackTime = 0f;
return false;
}
float curr = state.teams.get(players[0].getTeam()).cores.first().entity.health;
float curr = state.teams.get(player.getTeam()).cores.first().entity.health;
if(!Float.isNaN(lastCoreHP) && curr < lastCoreHP){
coreAttackTime = notifDuration;
}
@@ -470,13 +470,13 @@ public class HudFragment extends Fragment{
private void addPlayButton(Table table){
table.right().addImageButton("icon-play", "right", 30f, () -> {
if(Net.client() && players[0].isAdmin){
Call.onAdminRequest(players[0], AdminAction.wave);
if(Net.client() && player.isAdmin){
Call.onAdminRequest(player, AdminAction.wave);
}else{
state.wavetime = 0f;
}
}).growY().fillX().right().width(40f)
.visible(() -> state.rules.waves && ((Net.server() || players[0].isAdmin) || !Net.active()) && state.enemies() == 0
.visible(() -> state.rules.waves && ((Net.server() || player.isAdmin) || !Net.active()) && state.enemies() == 0
&& (!world.spawner.isSpawning() || !state.rules.waveTimer));
}
}
@@ -58,7 +58,7 @@ public class PlacementFragment extends Fragment{
public PlacementFragment(){
Events.on(WorldLoadEvent.class, event -> {
control.input(0).block = null;
control.input().block = null;
rebuild();
});
@@ -123,7 +123,7 @@ public class PlacementFragment extends Fragment{
full.bottom().right().visible(() -> !state.is(State.menu) && ui.hudfrag.shown());
full.table(frame -> {
InputHandler input = control.input(0);
InputHandler input = control.input();
//rebuilds the category table with the correct recipes
Runnable rebuildCategory = () -> {
@@ -154,7 +154,7 @@ public class PlacementFragment extends Fragment{
button.getStyle().imageUp = new TextureRegionDrawable(block.icon(Icon.medium));
button.update(() -> { //color unplacable things gray
TileEntity core = players[0].getClosestCore();
TileEntity core = player.getClosestCore();
Color color = core != null && (core.items.has(block.buildRequirements) || state.rules.infiniteResources) ? Color.WHITE : Color.GRAY;
button.forEach(elem -> elem.setColor(color));
button.setChecked(input.block == block);
@@ -211,7 +211,7 @@ public class PlacementFragment extends Fragment{
line.addImage(stack.item.icon(Item.Icon.small)).size(8 * 2);
line.add(stack.item.localizedName()).color(Color.LIGHT_GRAY).padLeft(2).left();
line.labelWrap(() -> {
TileEntity core = players[0].getClosestCore();
TileEntity core = player.getClosestCore();
if(core == null || state.rules.infiniteResources) return "*/*";
int amount = core.items.get(stack.item);
@@ -231,7 +231,7 @@ public class PlacementFragment extends Fragment{
t.add(new Image(lastDisplay.getDisplayIcon(hoverTile))).size(8 * 4);
t.labelWrap(lastDisplay.getDisplayName(hoverTile)).left().width(190f).padLeft(5);
}).growX().left();
if(hoverTile.getTeam() == players[0].getTeam()){
if(hoverTile.getTeam() == player.getTeam()){
topTable.row();
topTable.table(t -> {
t.left().defaults().left();
@@ -326,8 +326,8 @@ public class PlacementFragment extends Fragment{
}
//block currently selected
if(control.input(0).block != null){
toDisplay = control.input(0).block;
if(control.input().block != null){
toDisplay = control.input().block;
}
//block hovered on in build menu
@@ -98,7 +98,7 @@ public class PlayerListFragment extends Fragment{
button.addImage("icon-admin").size(14 * 2).visible(() -> player.isAdmin && !(!player.isLocal && Net.server())).padRight(5).get().updateVisibility();
if((Net.server() || players[0].isAdmin) && !player.isLocal && (!player.isAdmin || Net.server())){
if((Net.server() || player.isAdmin) && !player.isLocal && (!player.isAdmin || Net.server())){
button.add().growY();
float bs = (h) / 2f;