🔥🔥🔥🔥🔥🔥maximum breakage
This commit is contained in:
44
core/src/io/anuke/mindustry/input/Binding.java
Normal file
44
core/src/io/anuke/mindustry/input/Binding.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package io.anuke.mindustry.input;
|
||||
|
||||
import io.anuke.arc.Application.ApplicationType;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.KeyBinds.Axis;
|
||||
import io.anuke.arc.KeyBinds.KeyBind;
|
||||
import io.anuke.arc.KeyBinds.KeybindValue;
|
||||
import io.anuke.arc.input.InputDevice.DeviceType;
|
||||
import io.anuke.arc.input.KeyCode;
|
||||
|
||||
public enum Binding implements KeyBind{
|
||||
move_x(new Axis(KeyCode.A, KeyCode.D), "general"),
|
||||
move_y(new Axis(KeyCode.S, KeyCode.W)),
|
||||
select(KeyCode.MOUSE_LEFT),
|
||||
deselect(KeyCode.MOUSE_RIGHT),
|
||||
break_block(KeyCode.MOUSE_RIGHT),
|
||||
rotate(new Axis(KeyCode.SCROLL)),
|
||||
dash(KeyCode.SHIFT_LEFT),
|
||||
drop_unit(KeyCode.SHIFT_LEFT),
|
||||
gridMode(KeyCode.CONTROL_LEFT),
|
||||
gridModeShift(KeyCode.SHIFT_LEFT),
|
||||
zoom_hold(KeyCode.CONTROL_LEFT, "view"),
|
||||
zoom(new Axis(KeyCode.SCROLL)),
|
||||
zoom_minimap(new Axis(KeyCode.MINUS, KeyCode.PLUS)),
|
||||
menu(Core.app.getType() == ApplicationType.Android ? KeyCode.BACK : KeyCode.ESCAPE),
|
||||
pause(KeyCode.SPACE),
|
||||
toggle_menus(KeyCode.C),
|
||||
screenshot(KeyCode.P),
|
||||
player_list(KeyCode.TAB, "multiplayer"),
|
||||
chat(KeyCode.ENTER),
|
||||
chat_history_prev(KeyCode.UP),
|
||||
chat_history_next(KeyCode.DOWN),
|
||||
chat_scroll(new Axis(KeyCode.SCROLL))
|
||||
;
|
||||
|
||||
private final KeybindValue defaultValue;
|
||||
private final String category;
|
||||
|
||||
Binding(KeybindValue defaultValue, String category){ this.defaultValue = defaultValue; this.category = category; }
|
||||
Binding(KeybindValue defaultValue){ this(defaultValue, null); }
|
||||
|
||||
@Override public KeybindValue defaultValue(DeviceType type){ return defaultValue; }
|
||||
@Override public String category(){ return category; }
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.anuke.mindustry.input;
|
||||
|
||||
import io.anuke.ucore.scene.utils.Cursors;
|
||||
import io.anuke.arc.scene.utils.Cursors;
|
||||
|
||||
/**
|
||||
* Type of cursor for displaying on desktop.
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
package io.anuke.mindustry.input;
|
||||
|
||||
import io.anuke.arc.Application.ApplicationType;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.ucore.core.Inputs.Axis;
|
||||
import io.anuke.ucore.core.Inputs.DeviceType;
|
||||
import io.anuke.ucore.core.KeyBinds;
|
||||
import io.anuke.ucore.core.KeyBinds.Category;
|
||||
import io.anuke.ucore.input.Input;
|
||||
|
||||
public class DefaultKeybinds{
|
||||
|
||||
public static void load(){
|
||||
String[] sections = {"player_1"};
|
||||
|
||||
for(String section : sections){
|
||||
|
||||
KeyBinds.defaultSection(section, DeviceType.keyboard,
|
||||
new Category("general"),
|
||||
"move_x", new Axis(Input.A, Input.D),
|
||||
"move_y", new Axis(Input.S, Input.W),
|
||||
"select", Input.MOUSE_LEFT,
|
||||
"deselect", Input.MOUSE_RIGHT,
|
||||
"break", Input.MOUSE_RIGHT,
|
||||
"rotate", new Axis(Input.SCROLL),
|
||||
"dash", Input.SHIFT_LEFT,
|
||||
"drop_unit", Input.SHIFT_LEFT,
|
||||
"gridMode", Input.CONTROL_LEFT,
|
||||
"gridModeShift", Input.SHIFT_LEFT,
|
||||
new Category("view"),
|
||||
"zoom_hold", Input.CONTROL_LEFT,
|
||||
"zoom", new Axis(Input.SCROLL),
|
||||
"zoom_minimap", new Axis(Input.MINUS, Input.PLUS),
|
||||
"menu", Core.app.getType() == ApplicationType.Android ? Input.BACK : Input.ESCAPE,
|
||||
"pause", Input.SPACE,
|
||||
"toggle_menus", Input.C,
|
||||
"screenshot", Input.P,
|
||||
new Category("multiplayer"),
|
||||
"player_list", Input.TAB,
|
||||
"chat", Input.ENTER,
|
||||
"chat_history_prev", Input.UP,
|
||||
"chat_history_next", Input.DOWN,
|
||||
"chat_scroll", new Axis(Input.SCROLL)
|
||||
);
|
||||
|
||||
KeyBinds.defaultSection(section, DeviceType.controller,
|
||||
new Category("general"),
|
||||
"move_x", new Axis(Input.CONTROLLER_L_STICK_HORIZONTAL_AXIS),
|
||||
"move_y", new Axis(Input.CONTROLLER_L_STICK_VERTICAL_AXIS),
|
||||
"cursor_x", new Axis(Input.CONTROLLER_R_STICK_HORIZONTAL_AXIS),
|
||||
"cursor_y", new Axis(Input.CONTROLLER_R_STICK_VERTICAL_AXIS),
|
||||
//"select", Input.CONTROLLER_R_BUMPER,
|
||||
//"break", Input.CONTROLLER_L_BUMPER,
|
||||
//"shoot", Input.CONTROLLER_R_TRIGGER,
|
||||
"dash", Input.CONTROLLER_Y,
|
||||
"rotate_alt", new Axis(Input.CONTROLLER_DPAD_RIGHT, Input.CONTROLLER_DPAD_LEFT),
|
||||
"rotate", new Axis(Input.CONTROLLER_A, Input.CONTROLLER_B),
|
||||
new Category("view"),
|
||||
"zoom_hold", Input.ANY_KEY,
|
||||
"zoom", new Axis(Input.CONTROLLER_DPAD_DOWN, Input.CONTROLLER_DPAD_UP),
|
||||
"menu", Input.CONTROLLER_X,
|
||||
"pause", Input.CONTROLLER_L_TRIGGER,
|
||||
new Category("multiplayer"),
|
||||
"player_list", Input.CONTROLLER_START
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
KeyBinds.setSectionAlias("default", "player_1");
|
||||
}
|
||||
}
|
||||
@@ -11,15 +11,15 @@ import io.anuke.mindustry.input.PlaceUtils.NormalizeResult;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
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.Settings;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.arc.core.Graphics;
|
||||
import io.anuke.arc.core.Inputs;
|
||||
import io.anuke.arc.core.Inputs.DeviceType;
|
||||
import io.anuke.arc.core.KeyBinds;
|
||||
import io.anuke.arc.core.Settings;
|
||||
import io.anuke.arc.graphics.Draw;
|
||||
import io.anuke.arc.graphics.Lines;
|
||||
import io.anuke.arc.scene.ui.layout.Unit;
|
||||
import io.anuke.arc.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.mindustry.input.CursorType.*;
|
||||
@@ -310,7 +310,7 @@ public class DesktopInput extends InputHandler{
|
||||
float ya = Inputs.getAxis(section, "cursor_y");
|
||||
|
||||
if(Math.abs(xa) > controllerMin || Math.abs(ya) > controllerMin){
|
||||
float scl = Settings.getInt("sensitivity", 100) / 100f * Unit.dp.scl(1f);
|
||||
float scl = Core.settings.getInt("sensitivity", 100) / 100f * Unit.dp.scl(1f);
|
||||
controlx += xa * baseControllerSpeed * scl;
|
||||
controly -= ya * baseControllerSpeed * scl;
|
||||
controlling = true;
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package io.anuke.mindustry.input;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.InputAdapter;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.math.Vector2;
|
||||
import io.anuke.annotations.Annotations.Loc;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.Graphics;
|
||||
import io.anuke.arc.entities.Effects;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.arc.scene.event.InputListener;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.utils.Time;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.content.fx.EnvironmentFx;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
@@ -21,23 +26,15 @@ import io.anuke.mindustry.ui.fragments.OverlayFragment;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Build;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.core.Inputs;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Translator;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public abstract class InputHandler extends InputAdapter{
|
||||
public abstract class InputHandler implements InputListener{
|
||||
/**Used for dropping items.*/
|
||||
final static float playerSelectRange = mobile ? 17f : 11f;
|
||||
/**Maximum line length.*/
|
||||
final static int maxLength = 100;
|
||||
final static Translator stackTrns = new Translator();
|
||||
final static Vector2 stackTrns = new Vector2();
|
||||
/**Distance on the back from where items originate.*/
|
||||
final static float backTrns = 3f;
|
||||
|
||||
@@ -89,12 +86,12 @@ public abstract class InputHandler extends InputAdapter{
|
||||
|
||||
for(int i = 0; i < sent; i++){
|
||||
boolean end = i == sent - 1;
|
||||
Timers.run(i * 3, () -> {
|
||||
Time.run(i * 3, () -> {
|
||||
tile.block().getStackOffset(item, tile, stackTrns);
|
||||
|
||||
ItemTransfer.create(item,
|
||||
player.x + Angles.trnsx(player.rotation + 180f, backTrns), player.y + Angles.trnsy(player.rotation + 180f, backTrns),
|
||||
new Translator(tile.drawx() + stackTrns.x, tile.drawy() + stackTrns.y), () -> {
|
||||
player.x + Mathf.trnsx(player.rotation + 180f, backTrns), player.y + Mathf.trnsy(player.rotation + 180f, backTrns),
|
||||
new Vector2(tile.drawx() + stackTrns.x, tile.drawy() + stackTrns.y), () -> {
|
||||
if(tile.block() != block || tile.entity == null || tile.entity.items == null) return;
|
||||
|
||||
tile.block().handleStack(item, removed, tile, player);
|
||||
|
||||
@@ -27,11 +27,11 @@ import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.arc.core.*;
|
||||
import io.anuke.arc.graphics.Draw;
|
||||
import io.anuke.arc.graphics.Lines;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.mindustry.input.PlaceMode.*;
|
||||
@@ -41,7 +41,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
private static final float maxPanSpeed = 1.3f;
|
||||
private static Rectangle r1 = new Rectangle(), r2 = new Rectangle();
|
||||
/** Distance to edge of screen to start panning. */
|
||||
private final float edgePan = io.anuke.ucore.scene.ui.layout.Unit.dp.scl(60f);
|
||||
private final float edgePan = io.anuke.arc.scene.ui.layout.Unit.dp.scl(60f);
|
||||
|
||||
//gesture data
|
||||
private Vector2 vector = new Vector2();
|
||||
@@ -191,15 +191,15 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
}
|
||||
|
||||
void showGuide(String type){
|
||||
if(!guides.contains(type) && !Settings.getBool(type, false)){
|
||||
if(!guides.contains(type) && !Core.settings.getBool(type, false)){
|
||||
FloatingDialog dialog = new FloatingDialog("$text." + type + ".title");
|
||||
dialog.addCloseButton();
|
||||
dialog.content().left();
|
||||
dialog.content().add("$text." + type).growX().wrap();
|
||||
dialog.content().row();
|
||||
dialog.content().addCheck("$text.showagain", false, checked -> {
|
||||
Settings.putBool(type, checked);
|
||||
Settings.save();
|
||||
Core.settings.putBool(type, checked);
|
||||
Core.settings.save();
|
||||
}).growX().left().get().left();
|
||||
dialog.show();
|
||||
guides.add(type);
|
||||
@@ -397,8 +397,8 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
|
||||
float radius = Interpolation.swingIn.apply(crosshairScale);
|
||||
|
||||
Lines.poly(target.getX(), target.getY(), 4, 7f * radius, Timers.time() * 1.5f);
|
||||
Lines.spikes(target.getX(), target.getY(), 3f * radius, 6f * radius, 4, Timers.time() * 1.5f);
|
||||
Lines.poly(target.getX(), target.getY(), 4, 7f * radius, Time.time() * 1.5f);
|
||||
Lines.spikes(target.getX(), target.getY(), 3f * radius, 6f * radius, 4, Time.time() * 1.5f);
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
@@ -697,9 +697,9 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
@Override
|
||||
public boolean zoom(float initialDistance, float distance){
|
||||
|
||||
if(Math.abs(distance - initialDistance) > io.anuke.ucore.scene.ui.layout.Unit.dp.scl(100f) && !zoomed){
|
||||
if(Math.abs(distance - initialDistance) > io.anuke.arc.scene.ui.layout.Unit.dp.scl(100f) && !zoomed){
|
||||
int amount = (distance > initialDistance ? 1 : -1);
|
||||
renderer.scaleCamera(Math.round(io.anuke.ucore.scene.ui.layout.Unit.dp.scl(amount)));
|
||||
renderer.scaleCamera(Math.round(io.anuke.arc.scene.ui.layout.Unit.dp.scl(amount)));
|
||||
zoomed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.anuke.mindustry.input;
|
||||
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.arc.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user