ctrl-shift-f
This commit is contained in:
@@ -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.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;
|
||||
import io.anuke.arc.Inputs;
|
||||
import io.anuke.arc.Core.input.DeviceType;
|
||||
import io.anuke.arc.KeyBinds;
|
||||
import io.anuke.arc.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 io.anuke.arc.math.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.mindustry.input.CursorType.*;
|
||||
@@ -128,11 +128,11 @@ public class DesktopInput extends InputHandler{
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
if(Net.active() && Inputs.keyTap("player_list")){
|
||||
if(Net.active() && Core.input.keyTap("player_list")){
|
||||
ui.listfrag.toggle();
|
||||
}
|
||||
|
||||
if(Inputs.keyRelease(section, "select")){
|
||||
if(Core.input.keyRelease(section, "select")){
|
||||
player.isShooting = false;
|
||||
}
|
||||
|
||||
@@ -141,11 +141,11 @@ public class DesktopInput extends InputHandler{
|
||||
boolean controller = KeyBinds.getSection(section).device.type == DeviceType.controller;
|
||||
|
||||
//zoom and rotate things
|
||||
if(Inputs.getAxisActive("zoom") && (Inputs.keyDown(section, "zoom_hold") || controller)){
|
||||
renderer.scaleCamera((int) Inputs.getAxisTapped(section, "zoom"));
|
||||
if(Core.input.getAxisActive("zoom") && (Core.input.keyDown(section, "zoom_hold") || controller)){
|
||||
renderer.scaleCamera((int) Core.input.getAxisTapped(section, "zoom"));
|
||||
}
|
||||
|
||||
renderer.minimap.zoomBy(-(int) Inputs.getAxisTapped(section, "zoom_minimap"));
|
||||
renderer.minimap.zoomBy(-(int) Core.input.getAxisTapped(section, "zoom_minimap"));
|
||||
|
||||
if(player.isDead()) return;
|
||||
|
||||
@@ -167,7 +167,7 @@ public class DesktopInput extends InputHandler{
|
||||
selectScale = 0f;
|
||||
}
|
||||
|
||||
rotation = Mathf.mod(rotation + (int) Inputs.getAxisTapped(section, "rotate"), 4);
|
||||
rotation = Mathf.mod(rotation + (int) Core.input.getAxisTapped(section, "rotate"), 4);
|
||||
|
||||
Tile cursor = tileAt(Core.input.getX(), Core.input.getY());
|
||||
|
||||
@@ -203,11 +203,11 @@ public class DesktopInput extends InputHandler{
|
||||
int cursorX = tileX(Core.input.getX());
|
||||
int cursorY = tileY(Core.input.getY());
|
||||
|
||||
if(Inputs.keyTap(section, "deselect")){
|
||||
if(Core.input.keyTap(section, "deselect")){
|
||||
player.setMineTile(null);
|
||||
}
|
||||
|
||||
if(Inputs.keyTap(section, "select") && !ui.hasMouse()){
|
||||
if(Core.input.keyTap(section, "select") && !ui.hasMouse()){
|
||||
if(isPlacing()){
|
||||
selectX = cursorX;
|
||||
selectY = cursorY;
|
||||
@@ -221,7 +221,7 @@ public class DesktopInput extends InputHandler{
|
||||
}else if(!ui.chatfrag.chatOpen()){ //if it's out of bounds, shooting is just fine
|
||||
player.isShooting = true;
|
||||
}
|
||||
}else if(Inputs.keyTap(section, "deselect") && (recipe != null || mode != none || player.isBuilding()) &&
|
||||
}else if(Core.input.keyTap(section, "deselect") && (recipe != null || mode != none || player.isBuilding()) &&
|
||||
!(player.getCurrentRequest() != null && player.getCurrentRequest().breaking && KeyBinds.get(section, "deselect") == KeyBinds.get(section, "break"))){
|
||||
if(recipe == null){
|
||||
player.clearBuilding();
|
||||
@@ -229,7 +229,7 @@ public class DesktopInput extends InputHandler{
|
||||
|
||||
recipe = null;
|
||||
mode = none;
|
||||
}else if(Inputs.keyTap(section, "break") && !ui.hasMouse()){
|
||||
}else if(Core.input.keyTap(section, "break") && !ui.hasMouse()){
|
||||
//is recalculated because setting the mode to breaking removes potential multiblock cursor offset
|
||||
mode = breaking;
|
||||
selectX = tileX(Core.input.getX());
|
||||
@@ -237,7 +237,7 @@ public class DesktopInput extends InputHandler{
|
||||
}
|
||||
|
||||
|
||||
if(Inputs.keyRelease(section, "break") || Inputs.keyRelease(section, "select")){
|
||||
if(Core.input.keyRelease(section, "break") || Core.input.keyRelease(section, "select")){
|
||||
|
||||
if(mode == placing){ //touch up while placing, place everything in selection
|
||||
NormalizeResult result = PlaceUtils.normalizeArea(selectX, selectY, cursorX, cursorY, rotation, true, maxLength);
|
||||
@@ -306,8 +306,8 @@ public class DesktopInput extends InputHandler{
|
||||
controlling = true;
|
||||
}
|
||||
|
||||
float xa = Inputs.getAxis(section, "cursor_x");
|
||||
float ya = Inputs.getAxis(section, "cursor_y");
|
||||
float xa = Core.input.getAxis(section, "cursor_x");
|
||||
float ya = Core.input.getAxis(section, "cursor_y");
|
||||
|
||||
if(Math.abs(xa) > controllerMin || Math.abs(ya) > controllerMin){
|
||||
float scl = Core.settings.getInt("sensitivity", 100) / 100f * Unit.dp.scl(1f);
|
||||
@@ -319,7 +319,7 @@ public class DesktopInput extends InputHandler{
|
||||
Core.input.setCursorCatched(true);
|
||||
}
|
||||
|
||||
Inputs.getProcessor().touchDragged((int) getMouseX(), (int) getMouseY(), player.playerIndex);
|
||||
Core.input.getProcessor().touchDragged((int) getMouseX(), (int) getMouseY(), player.playerIndex);
|
||||
}
|
||||
|
||||
controlx = Mathf.clamp(controlx, 0, Core.graphics.getWidth());
|
||||
|
||||
@@ -6,11 +6,11 @@ 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.input.InputProcessor;
|
||||
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.arc.util.Time;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.content.fx.EnvironmentFx;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
@@ -29,7 +29,7 @@ import io.anuke.mindustry.world.Tile;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public abstract class InputHandler implements InputListener{
|
||||
public abstract class InputHandler implements InputProcessor{
|
||||
/**Used for dropping items.*/
|
||||
final static float playerSelectRange = mobile ? 17f : 11f;
|
||||
/**Maximum line length.*/
|
||||
@@ -69,47 +69,45 @@ public abstract class InputHandler implements InputListener{
|
||||
throw new ValidateException(player, "Player cannot transfer an item.");
|
||||
}
|
||||
|
||||
threads.run(() -> {
|
||||
if(player == null || tile.entity == null) return;
|
||||
if(player == null || tile.entity == null) return;
|
||||
|
||||
player.isTransferring = true;
|
||||
player.isTransferring = true;
|
||||
|
||||
Item item = player.inventory.getItem().item;
|
||||
int amount = player.inventory.getItem().amount;
|
||||
int accepted = tile.block().acceptStack(item, amount, tile, player);
|
||||
player.inventory.getItem().amount -= accepted;
|
||||
Item item = player.inventory.getItem().item;
|
||||
int amount = player.inventory.getItem().amount;
|
||||
int accepted = tile.block().acceptStack(item, amount, tile, player);
|
||||
player.inventory.getItem().amount -= accepted;
|
||||
|
||||
int sent = Mathf.clamp(accepted / 4, 1, 8);
|
||||
int removed = accepted / sent;
|
||||
int[] remaining = {accepted, accepted};
|
||||
Block block = tile.block();
|
||||
int sent = Mathf.clamp(accepted / 4, 1, 8);
|
||||
int removed = accepted / sent;
|
||||
int[] remaining = {accepted, accepted};
|
||||
Block block = tile.block();
|
||||
|
||||
for(int i = 0; i < sent; i++){
|
||||
boolean end = i == sent - 1;
|
||||
Time.run(i * 3, () -> {
|
||||
tile.block().getStackOffset(item, tile, stackTrns);
|
||||
for(int i = 0; i < sent; i++){
|
||||
boolean end = i == sent - 1;
|
||||
Time.run(i * 3, () -> {
|
||||
tile.block().getStackOffset(item, tile, stackTrns);
|
||||
|
||||
ItemTransfer.create(item,
|
||||
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;
|
||||
ItemTransfer.create(item,
|
||||
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);
|
||||
remaining[1] -= removed;
|
||||
tile.block().handleStack(item, removed, tile, player);
|
||||
remaining[1] -= removed;
|
||||
|
||||
if(end && remaining[1] > 0){
|
||||
tile.block().handleStack(item, remaining[1], tile, player);
|
||||
}
|
||||
});
|
||||
if(end && remaining[1] > 0){
|
||||
tile.block().handleStack(item, remaining[1], tile, player);
|
||||
}
|
||||
});
|
||||
|
||||
remaining[0] -= removed;
|
||||
remaining[0] -= removed;
|
||||
|
||||
if(end){
|
||||
player.isTransferring = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if(end){
|
||||
player.isTransferring = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Remote(targets = Loc.both, called = Loc.server, forward = true)
|
||||
@@ -246,7 +244,7 @@ public abstract class InputHandler implements InputListener{
|
||||
&& tile.floor().drops != null && tile.floor().drops.item.hardness <= player.mech.drillPower
|
||||
&& !tile.floor().playerUnmineable
|
||||
&& player.inventory.canAcceptItem(tile.floor().drops.item)
|
||||
&& tile.block() == Blocks.air && player.distanceTo(tile.worldx(), tile.worldy()) <= Player.mineDistance;
|
||||
&& tile.block() == Blocks.air && player.dst(tile.worldx(), tile.worldy()) <= Player.mineDistance;
|
||||
}
|
||||
|
||||
/**Returns the tile at the specified MOUSE coordinates.*/
|
||||
@@ -283,7 +281,7 @@ public abstract class InputHandler implements InputListener{
|
||||
}
|
||||
|
||||
public void remove(){
|
||||
Inputs.removeProcessor(this);
|
||||
Core.input.removeProcessor(this);
|
||||
frag.remove();
|
||||
}
|
||||
|
||||
@@ -334,7 +332,7 @@ public abstract class InputHandler implements InputListener{
|
||||
|
||||
public boolean validPlace(int x, int y, Block type, int rotation){
|
||||
for(Tile tile : state.teams.get(player.getTeam()).cores){
|
||||
if(tile.distanceTo(x * tilesize, y * tilesize) < coreBuildRange){
|
||||
if(tile.dst(x * tilesize, y * tilesize) < coreBuildRange){
|
||||
return Build.validPlace(player.getTeam(), x, y, type, rotation) &&
|
||||
Vector2.dst(player.x, player.y, x * tilesize, y * tilesize) < Player.placeDistance;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ import io.anuke.arc.input.GestureDetector.GestureListener;
|
||||
import io.anuke.arc.math.Interpolation;
|
||||
import io.anuke.arc.math.Rectangle;
|
||||
import io.anuke.arc.math.Vector2;
|
||||
import io.anuke.arc.utils.Align;
|
||||
import io.anuke.arc.utils.Array;
|
||||
import io.anuke.arc.utils.ObjectSet;
|
||||
import io.anuke.arc.util.Align;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.collection.ObjectSet;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.content.fx.Fx;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
@@ -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.arc.core.*;
|
||||
import io.anuke.arc.*;
|
||||
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 io.anuke.arc.math.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.mindustry.input.PlaceMode.*;
|
||||
@@ -76,7 +76,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
|
||||
public MobileInput(Player player){
|
||||
super(player);
|
||||
Inputs.addProcessor(new GestureDetector(20, 0.5f, 0.4f, 0.15f, this));
|
||||
Core.input.addProcessor(new GestureDetector(20, 0.5f, 0.4f, 0.15f, this));
|
||||
}
|
||||
|
||||
//region utility methods
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.anuke.mindustry.input;
|
||||
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.arc.util.Mathf;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user