Crash fixes, additional controller support
This commit is contained in:
@@ -21,7 +21,7 @@ allprojects {
|
|||||||
appName = "Mindustry"
|
appName = "Mindustry"
|
||||||
gdxVersion = '1.9.8'
|
gdxVersion = '1.9.8'
|
||||||
aiVersion = '1.8.1'
|
aiVersion = '1.8.1'
|
||||||
uCoreVersion = '2d75159';
|
uCoreVersion = '0de709f';
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|||||||
@@ -142,7 +142,6 @@ public class Control extends Module{
|
|||||||
"select", Input.MOUSE_LEFT,
|
"select", Input.MOUSE_LEFT,
|
||||||
"break", Input.MOUSE_RIGHT,
|
"break", Input.MOUSE_RIGHT,
|
||||||
"shoot", Input.MOUSE_LEFT,
|
"shoot", Input.MOUSE_LEFT,
|
||||||
"weapon_alt_select", Input.Q,
|
|
||||||
"zoom_hold", Input.CONTROL_LEFT,
|
"zoom_hold", Input.CONTROL_LEFT,
|
||||||
"zoom", new Axis(Input.SCROLL),
|
"zoom", new Axis(Input.SCROLL),
|
||||||
"menu", Gdx.app.getType() == ApplicationType.Android ? Input.BACK : Input.ESCAPE,
|
"menu", Gdx.app.getType() == ApplicationType.Android ? Input.BACK : Input.ESCAPE,
|
||||||
@@ -174,7 +173,7 @@ public class Control extends Module{
|
|||||||
"menu", Input.CONTROLLER_X,
|
"menu", Input.CONTROLLER_X,
|
||||||
"pause", Input.CONTROLLER_L_TRIGGER,
|
"pause", Input.CONTROLLER_L_TRIGGER,
|
||||||
"dash", Input.CONTROLLER_Y,
|
"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),
|
"rotate", new Axis(Input.CONTROLLER_A, Input.CONTROLLER_B),
|
||||||
"player_list", Input.CONTROLLER_START,
|
"player_list", Input.CONTROLLER_START,
|
||||||
"weapon_1", Input.NUM_1,
|
"weapon_1", Input.NUM_1,
|
||||||
|
|||||||
@@ -191,8 +191,10 @@ public class NetClient extends Module {
|
|||||||
|
|
||||||
Net.handle(BlockDestroyPacket.class, packet -> {
|
Net.handle(BlockDestroyPacket.class, packet -> {
|
||||||
Tile tile = Vars.world.tile(packet.position % Vars.world.width(), packet.position / Vars.world.width());
|
Tile tile = Vars.world.tile(packet.position % Vars.world.width(), packet.position / Vars.world.width());
|
||||||
if(tile.entity != null){
|
if(tile != null && tile.entity != null){
|
||||||
Gdx.app.postRunnable(() -> tile.entity.onDeath(true));
|
Gdx.app.postRunnable(() ->{
|
||||||
|
if(tile.entity != null) tile.entity.onDeath(true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -211,13 +211,13 @@ public class EnemyType {
|
|||||||
public void onDeath(Enemy enemy){
|
public void onDeath(Enemy enemy){
|
||||||
if(Net.active() && Net.server()){
|
if(Net.active() && Net.server()){
|
||||||
Vars.netServer.handleEnemyDeath(enemy);
|
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){
|
public void removed(Enemy enemy){
|
||||||
|
|||||||
@@ -56,7 +56,10 @@ public class AndroidInput extends InputHandler{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown(int screenX, int screenY, int pointer, int button){
|
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;
|
lmousex = screenX;
|
||||||
lmousey = screenY;
|
lmousey = screenY;
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import io.anuke.mindustry.resource.Weapon;
|
|||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Graphics;
|
import io.anuke.ucore.core.Graphics;
|
||||||
import io.anuke.ucore.core.Inputs;
|
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.core.Timers;
|
||||||
import io.anuke.ucore.scene.utils.Cursors;
|
import io.anuke.ucore.scene.utils.Cursors;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
@@ -21,7 +23,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
int endx, endy;
|
int endx, endy;
|
||||||
private boolean enableHold = false;
|
private boolean enableHold = false;
|
||||||
private boolean beganBreak;
|
private boolean beganBreak;
|
||||||
private boolean rotated = false, rotatedAlt;
|
private boolean rotated = false, rotatedAlt, zoomed;
|
||||||
|
|
||||||
@Override public float getCursorEndX(){ return endx; }
|
@Override public float getCursorEndX(){ return endx; }
|
||||||
@Override public float getCursorEndY(){ return endy; }
|
@Override public float getCursorEndY(){ return endy; }
|
||||||
@@ -54,9 +56,17 @@ public class DesktopInput extends InputHandler{
|
|||||||
|
|
||||||
endx = Gdx.input.getX();
|
endx = Gdx.input.getX();
|
||||||
endy = Gdx.input.getY();
|
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()){
|
if(Inputs.getAxisActive("zoom") && (Inputs.keyDown("zoom_hold") || controller)
|
||||||
renderer.scaleCamera((int)Inputs.getAxis("zoom"));
|
&& !GameState.is(State.menu) && !ui.hasDialog()){
|
||||||
|
if((!zoomed || !controller)) {
|
||||||
|
renderer.scaleCamera((int) Inputs.getAxis("zoom"));
|
||||||
|
}
|
||||||
|
zoomed = true;
|
||||||
|
}else{
|
||||||
|
zoomed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!rotated) {
|
if(!rotated) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.files.FileHandle;
|
|||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.Pixmap;
|
import com.badlogic.gdx.graphics.Pixmap;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
import io.anuke.mindustry.Mindustry;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.ui.dialogs.FileChooser;
|
import io.anuke.mindustry.ui.dialogs.FileChooser;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
@@ -141,7 +142,11 @@ public class MapEditorDialog extends Dialog{
|
|||||||
blockgroup.getButtons().get(2).setChecked(true);
|
blockgroup.getButtons().get(2).setChecked(true);
|
||||||
Core.scene.setScrollFocus(view);
|
Core.scene.setScrollFocus(view);
|
||||||
view.clearStack();
|
view.clearStack();
|
||||||
|
|
||||||
|
Mindustry.platforms.updateRPC();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
hidden(() -> Mindustry.platforms.updateRPC());
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapView getView() {
|
public MapView getView() {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class JoinDialog extends FloatingDialog {
|
|||||||
Mindustry.platforms.addDialog(join.content().addField(Settings.getString("ip"),text ->{
|
Mindustry.platforms.addDialog(join.content().addField(Settings.getString("ip"),text ->{
|
||||||
Settings.putString("ip", text);
|
Settings.putString("ip", text);
|
||||||
Settings.save();
|
Settings.save();
|
||||||
}).size(180f, 54f).get());
|
}).size(180f, 54f).get(), 100);
|
||||||
|
|
||||||
join.content().row();
|
join.content().row();
|
||||||
join.content().add("$text.server.port").left();
|
join.content().add("$text.server.port").left();
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class PausedDialog extends FloatingDialog{
|
|||||||
content().row();
|
content().row();
|
||||||
content().addButton("$text.loadgame", () -> {
|
content().addButton("$text.loadgame", () -> {
|
||||||
load.show();
|
load.show();
|
||||||
}).disabled(Net.active());
|
}).disabled(b -> Net.active());
|
||||||
|
|
||||||
content().row();
|
content().row();
|
||||||
|
|
||||||
@@ -93,16 +93,19 @@ public class PausedDialog extends FloatingDialog{
|
|||||||
|
|
||||||
content().row();
|
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){
|
if(Vars.world.getMap().custom){
|
||||||
ui.showError("$text.nohost");
|
ui.showError("$text.nohost");
|
||||||
}else {
|
}else {
|
||||||
ui.host.show();
|
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, () -> {
|
new imagebutton("icon-quit", isize, () -> {
|
||||||
Vars.ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> {
|
Vars.ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> {
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ public class ChatFragment extends Table implements Fragment{
|
|||||||
if(Net.active() && Inputs.keyTap("chat")){
|
if(Net.active() && Inputs.keyTap("chat")){
|
||||||
toggle();
|
toggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(GameState.is(State.menu) && messages.size > 0){
|
||||||
|
messages.clear();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
@@ -80,7 +84,7 @@ public class ChatFragment extends Table implements Fragment{
|
|||||||
add(chatfield).padBottom(offsety).padLeft(offsetx).growX().padRight(offsetx).height(28);
|
add(chatfield).padBottom(offsety).padLeft(offsetx).growX().padRight(offsetx).height(28);
|
||||||
|
|
||||||
if(Vars.android) {
|
if(Vars.android) {
|
||||||
marginBottom(110f);
|
marginBottom(105f);
|
||||||
marginRight(240f);
|
marginRight(240f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ public class HudFragment implements Fragment{
|
|||||||
new imagebutton("icon-play", 30f, ()->{
|
new imagebutton("icon-play", 30f, ()->{
|
||||||
Vars.control.runWave();
|
Vars.control.runWave();
|
||||||
}).height(uheight).fillX().right().padTop(-8f).padBottom(-12f).padRight(-36).width(40f).update(l->{
|
}).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;
|
boolean paused = GameState.is(State.paused) || !vis;
|
||||||
|
|
||||||
l.setVisible(vis);
|
l.setVisible(vis);
|
||||||
|
|||||||
@@ -131,7 +131,11 @@ public class PlacementFragment implements Fragment{
|
|||||||
new imagebutton("icon-" + mode.name(), "toggle", 10 * 3, () -> {
|
new imagebutton("icon-" + mode.name(), "toggle", 10 * 3, () -> {
|
||||||
control.getInput().resetCursor();
|
control.getInput().resetCursor();
|
||||||
input.breakMode = mode;
|
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()));
|
modeText(Bundles.format("text.mode.break", mode.toString()));
|
||||||
}).group(breakGroup).get().setName(mode.name());
|
}).group(breakGroup).get().setName(mode.name());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class Teleporter extends PowerBlock{
|
|||||||
private Array<Tile> removal = new Array<>();
|
private Array<Tile> removal = new Array<>();
|
||||||
private Array<Tile> returns = new Array<>();
|
private Array<Tile> returns = new Array<>();
|
||||||
|
|
||||||
protected float powerPerItem = 1f;
|
protected float powerPerItem = 0.8f;
|
||||||
|
|
||||||
static{
|
static{
|
||||||
for(int i = 0; i < colors; i ++){
|
for(int i = 0; i < colors; i ++){
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class Generator extends PowerBlock{
|
|||||||
|
|
||||||
public int laserRange = 6;
|
public int laserRange = 6;
|
||||||
public int laserDirections = 4;
|
public int laserDirections = 4;
|
||||||
public float powerSpeed = 0.1f;
|
public float powerSpeed = 0.5f;
|
||||||
public boolean explosive = true;
|
public boolean explosive = true;
|
||||||
public boolean hasLasers = true;
|
public boolean hasLasers = true;
|
||||||
public boolean outputOnly = false;
|
public boolean outputOnly = false;
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ public class NuclearReactor extends LiquidPowerGenerator{
|
|||||||
explosionEffect = Fx.nuclearShockwave;
|
explosionEffect = Fx.nuclearShockwave;
|
||||||
explosive = true;
|
explosive = true;
|
||||||
powerCapacity = 80f;
|
powerCapacity = 80f;
|
||||||
|
powerSpeed = 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -63,7 +64,7 @@ public class NuclearReactor extends LiquidPowerGenerator{
|
|||||||
if(fuel > 0){
|
if(fuel > 0){
|
||||||
entity.heat += fullness * heating;
|
entity.heat += fullness * heating;
|
||||||
entity.power += powerMultiplier * fullness * Timers.delta();
|
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)){
|
if(entity.timer.get(timerFuel, fuelUseTime)){
|
||||||
entity.removeItem(generateItem, 1);
|
entity.removeItem(generateItem, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,11 @@ public class DesktopLauncher {
|
|||||||
presence.state = Strings.capitalize(Vars.control.getMode().toString());
|
presence.state = Strings.capitalize(Vars.control.getMode().toString());
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
presence.state = "In Menu";
|
if(Vars.ui.editor != null && Vars.ui.editor.isShown()){
|
||||||
|
presence.state = "In Editor";
|
||||||
|
}else {
|
||||||
|
presence.state = "In Menu";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
presence.largeImageKey = "logo";
|
presence.largeImageKey = "logo";
|
||||||
|
|||||||
Reference in New Issue
Block a user