Initial creation of Arc port
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package io.anuke.mindustry.input;
|
||||
|
||||
import com.badlogic.gdx.Application.ApplicationType;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
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;
|
||||
@@ -31,7 +31,7 @@ public class DefaultKeybinds{
|
||||
"zoom_hold", Input.CONTROL_LEFT,
|
||||
"zoom", new Axis(Input.SCROLL),
|
||||
"zoom_minimap", new Axis(Input.MINUS, Input.PLUS),
|
||||
"menu", Gdx.app.getType() == ApplicationType.Android ? Input.BACK : Input.ESCAPE,
|
||||
"menu", Core.app.getType() == ApplicationType.Android ? Input.BACK : Input.ESCAPE,
|
||||
"pause", Input.SPACE,
|
||||
"toggle_menus", Input.C,
|
||||
"screenshot", Input.P,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.anuke.mindustry.input;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
@@ -71,8 +71,8 @@ public class DesktopInput extends InputHandler{
|
||||
|
||||
@Override
|
||||
public void drawOutlined(){
|
||||
int cursorX = tileX(Gdx.input.getX());
|
||||
int cursorY = tileY(Gdx.input.getY());
|
||||
int cursorX = tileX(Core.input.getX());
|
||||
int cursorY = tileY(Core.input.getY());
|
||||
|
||||
//draw selection(s)
|
||||
if(mode == placing && recipe != null){
|
||||
@@ -169,7 +169,7 @@ public class DesktopInput extends InputHandler{
|
||||
|
||||
rotation = Mathf.mod(rotation + (int) Inputs.getAxisTapped(section, "rotate"), 4);
|
||||
|
||||
Tile cursor = tileAt(Gdx.input.getX(), Gdx.input.getY());
|
||||
Tile cursor = tileAt(Core.input.getX(), Core.input.getY());
|
||||
|
||||
if(player.isDead()){
|
||||
cursorType = normal;
|
||||
@@ -199,9 +199,9 @@ public class DesktopInput extends InputHandler{
|
||||
}
|
||||
|
||||
void pollInput(){
|
||||
Tile selected = tileAt(Gdx.input.getX(), Gdx.input.getY());
|
||||
int cursorX = tileX(Gdx.input.getX());
|
||||
int cursorY = tileY(Gdx.input.getY());
|
||||
Tile selected = tileAt(Core.input.getX(), Core.input.getY());
|
||||
int cursorX = tileX(Core.input.getX());
|
||||
int cursorY = tileY(Core.input.getY());
|
||||
|
||||
if(Inputs.keyTap(section, "deselect")){
|
||||
player.setMineTile(null);
|
||||
@@ -232,8 +232,8 @@ public class DesktopInput extends InputHandler{
|
||||
}else if(Inputs.keyTap(section, "break") && !ui.hasMouse()){
|
||||
//is recalculated because setting the mode to breaking removes potential multiblock cursor offset
|
||||
mode = breaking;
|
||||
selectX = tileX(Gdx.input.getX());
|
||||
selectY = tileY(Gdx.input.getY());
|
||||
selectX = tileX(Core.input.getX());
|
||||
selectY = tileY(Core.input.getY());
|
||||
}
|
||||
|
||||
|
||||
@@ -278,12 +278,12 @@ public class DesktopInput extends InputHandler{
|
||||
|
||||
@Override
|
||||
public float getMouseX(){
|
||||
return !controlling ? Gdx.input.getX() : controlx;
|
||||
return !controlling ? Core.input.getX() : controlx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMouseY(){
|
||||
return !controlling ? Gdx.input.getY() : controly;
|
||||
return !controlling ? Core.input.getY() : controly;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -295,7 +295,7 @@ public class DesktopInput extends InputHandler{
|
||||
public void updateController(){
|
||||
//TODO no controller support
|
||||
//TODO move controller input to new class, ControllerInput
|
||||
boolean mousemove = Gdx.input.getDeltaX() > 1 || Gdx.input.getDeltaY() > 1;
|
||||
boolean mousemove = Core.input.getDeltaX() > 1 || Core.input.getDeltaY() > 1;
|
||||
|
||||
if(state.is(State.menu)){
|
||||
droppingItem = false;
|
||||
@@ -316,22 +316,22 @@ public class DesktopInput extends InputHandler{
|
||||
controlling = true;
|
||||
|
||||
if(player.playerIndex == 0){
|
||||
Gdx.input.setCursorCatched(true);
|
||||
Core.input.setCursorCatched(true);
|
||||
}
|
||||
|
||||
Inputs.getProcessor().touchDragged((int) getMouseX(), (int) getMouseY(), player.playerIndex);
|
||||
}
|
||||
|
||||
controlx = Mathf.clamp(controlx, 0, Gdx.graphics.getWidth());
|
||||
controly = Mathf.clamp(controly, 0, Gdx.graphics.getHeight());
|
||||
controlx = Mathf.clamp(controlx, 0, Core.graphics.getWidth());
|
||||
controly = Mathf.clamp(controly, 0, Core.graphics.getHeight());
|
||||
}else{
|
||||
controlling = false;
|
||||
Gdx.input.setCursorCatched(false);
|
||||
Core.input.setCursorCatched(false);
|
||||
}
|
||||
|
||||
if(!controlling){
|
||||
controlx = Gdx.input.getX();
|
||||
controly = Gdx.input.getY();
|
||||
controlx = Core.input.getX();
|
||||
controly = Core.input.getY();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package io.anuke.mindustry.input;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.InputAdapter;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
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.mindustry.content.blocks.Blocks;
|
||||
@@ -130,11 +130,11 @@ public abstract class InputHandler extends InputAdapter{
|
||||
}
|
||||
|
||||
public float getMouseX(){
|
||||
return Gdx.input.getX();
|
||||
return Core.input.getX();
|
||||
}
|
||||
|
||||
public float getMouseY(){
|
||||
return Gdx.input.getY();
|
||||
return Core.input.getY();
|
||||
}
|
||||
|
||||
public void resetCursor(){
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package io.anuke.mindustry.input;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.input.GestureDetector;
|
||||
import com.badlogic.gdx.input.GestureDetector.GestureListener;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.input.GestureDetector;
|
||||
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.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.content.fx.Fx;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
@@ -321,8 +321,8 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
|
||||
//Draw lines
|
||||
if(lineMode){
|
||||
int tileX = tileX(Gdx.input.getX());
|
||||
int tileY = tileY(Gdx.input.getY());
|
||||
int tileX = tileX(Core.input.getX());
|
||||
int tileY = tileY(Core.input.getY());
|
||||
|
||||
//draw placing
|
||||
if(mode == placing && recipe != null){
|
||||
@@ -615,7 +615,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
lineScale = Mathf.lerpDelta(lineScale, 1f, 0.1f);
|
||||
|
||||
//When in line mode, pan when near screen edges automatically
|
||||
if(Gdx.input.isTouched(0) && lineMode){
|
||||
if(Core.input.isTouched(0) && lineMode){
|
||||
float screenX = Graphics.mouse().x, screenY = Graphics.mouse().y;
|
||||
|
||||
float panX = 0, panY = 0;
|
||||
@@ -624,19 +624,19 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
panX = -(edgePan - screenX);
|
||||
}
|
||||
|
||||
if(screenX >= Gdx.graphics.getWidth() - edgePan){
|
||||
panX = (screenX - Gdx.graphics.getWidth()) + edgePan;
|
||||
if(screenX >= Core.graphics.getWidth() - edgePan){
|
||||
panX = (screenX - Core.graphics.getWidth()) + edgePan;
|
||||
}
|
||||
|
||||
if(screenY <= edgePan){
|
||||
panY = -(edgePan - screenY);
|
||||
}
|
||||
|
||||
if(screenY >= Gdx.graphics.getHeight() - edgePan){
|
||||
panY = (screenY - Gdx.graphics.getHeight()) + edgePan;
|
||||
if(screenY >= Core.graphics.getHeight() - edgePan){
|
||||
panY = (screenY - Core.graphics.getHeight()) + edgePan;
|
||||
}
|
||||
|
||||
vector.set(panX, panY).scl((Core.camera.viewportWidth * Core.camera.zoom) / Gdx.graphics.getWidth());
|
||||
vector.set(panX, panY).scl((Core.camera.viewportWidth * Core.camera.zoom) / Core.graphics.getWidth());
|
||||
vector.limit(maxPanSpeed);
|
||||
|
||||
//pan view
|
||||
@@ -663,7 +663,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
if(!canPan) return false;
|
||||
|
||||
//can't pan in line mode with one finger or while dropping items!
|
||||
if((lineMode && !Gdx.input.isTouched(1)) || droppingItem){
|
||||
if((lineMode && !Core.input.isTouched(1)) || droppingItem){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user