Crash fixes, additional controller support

This commit is contained in:
Anuken
2018-01-10 14:43:29 -05:00
parent d6532c26bb
commit a9546de894
16 changed files with 63 additions and 28 deletions

View File

@@ -142,7 +142,6 @@ public class Control extends Module{
"select", Input.MOUSE_LEFT,
"break", Input.MOUSE_RIGHT,
"shoot", Input.MOUSE_LEFT,
"weapon_alt_select", Input.Q,
"zoom_hold", Input.CONTROL_LEFT,
"zoom", new Axis(Input.SCROLL),
"menu", Gdx.app.getType() == ApplicationType.Android ? Input.BACK : Input.ESCAPE,
@@ -174,7 +173,7 @@ public class Control extends Module{
"menu", Input.CONTROLLER_X,
"pause", Input.CONTROLLER_L_TRIGGER,
"dash", Input.CONTROLLER_Y,
"rotate_alt", new Axis(Input.UNSET),
"rotate_alt", new Axis(Input.CONTROLLER_DPAD_RIGHT, Input.CONTROLLER_DPAD_LEFT),
"rotate", new Axis(Input.CONTROLLER_A, Input.CONTROLLER_B),
"player_list", Input.CONTROLLER_START,
"weapon_1", Input.NUM_1,

View File

@@ -191,8 +191,10 @@ public class NetClient extends Module {
Net.handle(BlockDestroyPacket.class, packet -> {
Tile tile = Vars.world.tile(packet.position % Vars.world.width(), packet.position / Vars.world.width());
if(tile.entity != null){
Gdx.app.postRunnable(() -> tile.entity.onDeath(true));
if(tile != null && tile.entity != null){
Gdx.app.postRunnable(() ->{
if(tile.entity != null) tile.entity.onDeath(true);
});
}
});

View File

@@ -211,13 +211,13 @@ public class EnemyType {
public void onDeath(Enemy enemy){
if(Net.active() && Net.server()){
Vars.netServer.handleEnemyDeath(enemy);
}else if(!Net.active()){ //must be client
Effects.effect(Fx.explosion, enemy);
Effects.shake(3f, 4f, enemy);
Effects.sound("bang2", enemy);
enemy.remove();
enemy.dead = true;
}
Effects.effect(Fx.explosion, enemy);
Effects.shake(3f, 4f, enemy);
Effects.sound("bang2", enemy);
enemy.remove();
enemy.dead = true;
}
public void removed(Enemy enemy){

View File

@@ -56,7 +56,10 @@ public class AndroidInput extends InputHandler{
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button){
if(ui.hasMouse()) return false;
if(ui.hasMouse()){
brokeBlock = true;
return false;
}
lmousex = screenX;
lmousey = screenY;

View File

@@ -10,6 +10,8 @@ import io.anuke.mindustry.resource.Weapon;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.core.Inputs;
import io.anuke.ucore.core.Inputs.DeviceType;
import io.anuke.ucore.core.KeyBinds;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.scene.utils.Cursors;
import io.anuke.ucore.util.Mathf;
@@ -21,7 +23,7 @@ public class DesktopInput extends InputHandler{
int endx, endy;
private boolean enableHold = false;
private boolean beganBreak;
private boolean rotated = false, rotatedAlt;
private boolean rotated = false, rotatedAlt, zoomed;
@Override public float getCursorEndX(){ return endx; }
@Override public float getCursorEndY(){ return endy; }
@@ -54,9 +56,17 @@ public class DesktopInput extends InputHandler{
endx = Gdx.input.getX();
endy = Gdx.input.getY();
boolean controller = KeyBinds.getSection("default").device.type == DeviceType.controller;
if(Inputs.getAxisActive("zoom") && Inputs.keyDown("zoom_hold") && !GameState.is(State.menu) && !ui.hasDialog()){
renderer.scaleCamera((int)Inputs.getAxis("zoom"));
if(Inputs.getAxisActive("zoom") && (Inputs.keyDown("zoom_hold") || controller)
&& !GameState.is(State.menu) && !ui.hasDialog()){
if((!zoomed || !controller)) {
renderer.scaleCamera((int) Inputs.getAxis("zoom"));
}
zoomed = true;
}else{
zoomed = false;
}
if(!rotated) {

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import io.anuke.mindustry.Mindustry;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.ui.dialogs.FileChooser;
import io.anuke.mindustry.world.Block;
@@ -141,7 +142,11 @@ public class MapEditorDialog extends Dialog{
blockgroup.getButtons().get(2).setChecked(true);
Core.scene.setScrollFocus(view);
view.clearStack();
Mindustry.platforms.updateRPC();
});
hidden(() -> Mindustry.platforms.updateRPC());
}
public MapView getView() {

View File

@@ -31,7 +31,7 @@ public class JoinDialog extends FloatingDialog {
Mindustry.platforms.addDialog(join.content().addField(Settings.getString("ip"),text ->{
Settings.putString("ip", text);
Settings.save();
}).size(180f, 54f).get());
}).size(180f, 54f).get(), 100);
join.content().row();
join.content().add("$text.server.port").left();

View File

@@ -51,7 +51,7 @@ public class PausedDialog extends FloatingDialog{
content().row();
content().addButton("$text.loadgame", () -> {
load.show();
}).disabled(Net.active());
}).disabled(b -> Net.active());
content().row();
@@ -93,16 +93,19 @@ public class PausedDialog extends FloatingDialog{
content().row();
new imagebutton("icon-load", isize, load::show).text("$text.load").padTop(4f).disabled(Net.active());
imagebutton lo = new imagebutton("icon-load", isize, load::show);
lo.text("$text.load").padTop(4f);
lo.cell.disabled(b -> Net.active());
new imagebutton("icon-host", isize, () -> {
imagebutton ho = new imagebutton("icon-host", isize, () -> {
if(Vars.world.getMap().custom){
ui.showError("$text.nohost");
}else {
ui.host.show();
}
}).text("$text.host")
.disabled(b -> Net.active()).padTop(4f);
});
ho.text("$text.host").padTop(4f);
ho.cell.disabled(b -> Net.active());
new imagebutton("icon-quit", isize, () -> {
Vars.ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> {

View File

@@ -52,6 +52,10 @@ public class ChatFragment extends Table implements Fragment{
if(Net.active() && Inputs.keyTap("chat")){
toggle();
}
if(GameState.is(State.menu) && messages.size > 0){
messages.clear();
}
});
setup();
@@ -80,7 +84,7 @@ public class ChatFragment extends Table implements Fragment{
add(chatfield).padBottom(offsety).padLeft(offsetx).growX().padRight(offsetx).height(28);
if(Vars.android) {
marginBottom(110f);
marginBottom(105f);
marginRight(240f);
}

View File

@@ -209,7 +209,7 @@ public class HudFragment implements Fragment{
new imagebutton("icon-play", 30f, ()->{
Vars.control.runWave();
}).height(uheight).fillX().right().padTop(-8f).padBottom(-12f).padRight(-36).width(40f).update(l->{
boolean vis = Vars.control.getMode().toggleWaves && Vars.control.getEnemiesRemaining() <= 0;
boolean vis = Vars.control.getMode().toggleWaves && Vars.control.getEnemiesRemaining() <= 0 && (Net.server() || !Net.active());
boolean paused = GameState.is(State.paused) || !vis;
l.setVisible(vis);

View File

@@ -131,7 +131,11 @@ public class PlacementFragment implements Fragment{
new imagebutton("icon-" + mode.name(), "toggle", 10 * 3, () -> {
control.getInput().resetCursor();
input.breakMode = mode;
if (!mode.both) input.placeMode = mode;
if (!mode.both){
input.placeMode = mode;
}else{
input.placeMode = input.lastPlaceMode;
}
modeText(Bundles.format("text.mode.break", mode.toString()));
}).group(breakGroup).get().setName(mode.name());
}

View File

@@ -30,7 +30,7 @@ public class Teleporter extends PowerBlock{
private Array<Tile> removal = new Array<>();
private Array<Tile> returns = new Array<>();
protected float powerPerItem = 1f;
protected float powerPerItem = 0.8f;
static{
for(int i = 0; i < colors; i ++){

View File

@@ -26,7 +26,7 @@ public class Generator extends PowerBlock{
public int laserRange = 6;
public int laserDirections = 4;
public float powerSpeed = 0.1f;
public float powerSpeed = 0.5f;
public boolean explosive = true;
public boolean hasLasers = true;
public boolean outputOnly = false;

View File

@@ -45,6 +45,7 @@ public class NuclearReactor extends LiquidPowerGenerator{
explosionEffect = Fx.nuclearShockwave;
explosive = true;
powerCapacity = 80f;
powerSpeed = 0.5f;
}
@Override
@@ -63,7 +64,7 @@ public class NuclearReactor extends LiquidPowerGenerator{
if(fuel > 0){
entity.heat += fullness * heating;
entity.power += powerMultiplier * fullness * Timers.delta();
entity.power = Mathf.clamp(entity.power);
entity.power = Mathf.clamp(entity.power, 0f, powerCapacity);
if(entity.timer.get(timerFuel, fuelUseTime)){
entity.removeItem(generateItem, 1);
}