Fixed android version / Smooth zoom
This commit is contained in:
@@ -299,7 +299,7 @@ public class Renderer implements ApplicationListener{
|
|||||||
|
|
||||||
public void clampScale(){
|
public void clampScale(){
|
||||||
float s = io.anuke.arc.scene.ui.layout.Unit.dp.scl(1f);
|
float s = io.anuke.arc.scene.ui.layout.Unit.dp.scl(1f);
|
||||||
targetscale = Mathf.clamp(targetscale, Math.round(s * 2), Math.round(s * 5));
|
targetscale = Mathf.clamp(targetscale, Math.round(s * 1), Math.round(s * 6));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void takeMapScreenshot(){
|
public void takeMapScreenshot(){
|
||||||
|
|||||||
@@ -14,7 +14,10 @@ import io.anuke.arc.math.Mathf;
|
|||||||
import io.anuke.arc.math.geom.Geometry;
|
import io.anuke.arc.math.geom.Geometry;
|
||||||
import io.anuke.arc.math.geom.Rectangle;
|
import io.anuke.arc.math.geom.Rectangle;
|
||||||
import io.anuke.arc.math.geom.Vector2;
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.Align;
|
||||||
|
import io.anuke.arc.util.Interval;
|
||||||
|
import io.anuke.arc.util.Pack;
|
||||||
|
import io.anuke.arc.util.Time;
|
||||||
import io.anuke.arc.util.pooling.Pools;
|
import io.anuke.arc.util.pooling.Pools;
|
||||||
import io.anuke.mindustry.content.Mechs;
|
import io.anuke.mindustry.content.Mechs;
|
||||||
import io.anuke.mindustry.content.fx.UnitFx;
|
import io.anuke.mindustry.content.fx.UnitFx;
|
||||||
@@ -23,7 +26,6 @@ import io.anuke.mindustry.entities.traits.*;
|
|||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.gen.Call;
|
import io.anuke.mindustry.gen.Call;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.mindustry.graphics.Trail;
|
|
||||||
import io.anuke.mindustry.input.Binding;
|
import io.anuke.mindustry.input.Binding;
|
||||||
import io.anuke.mindustry.io.TypeIO;
|
import io.anuke.mindustry.io.TypeIO;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
@@ -73,7 +75,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
private Queue<BuildRequest> placeQueue = new Queue<>();
|
private Queue<BuildRequest> placeQueue = new Queue<>();
|
||||||
private Tile mining;
|
private Tile mining;
|
||||||
private CarriableTrait carrying;
|
private CarriableTrait carrying;
|
||||||
private Trail trail = new Trail(12);
|
|
||||||
private Vector2 movement = new Vector2();
|
private Vector2 movement = new Vector2();
|
||||||
private boolean moved;
|
private boolean moved;
|
||||||
|
|
||||||
@@ -373,15 +374,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
if(dead) return;
|
if(dead) return;
|
||||||
|
|
||||||
drawBuilding(this);
|
drawBuilding(this);
|
||||||
|
|
||||||
if(mech.flying || boostHeat > 0.001f){
|
|
||||||
float wobblyness = 0.6f;
|
|
||||||
if(!state.isPaused()) trail.update(x + Angles.trnsx(rotation + 180f, 5f) + Mathf.range(wobblyness),
|
|
||||||
y + Angles.trnsy(rotation + 180f, 5f) + Mathf.range(wobblyness));
|
|
||||||
trail.draw(Tmp.c1.set(mech.trailColor).lerp(mech.trailColorTo, mech.flying ? 0f : boostHeat), 5f * (isFlying() ? 1f : boostHeat));
|
|
||||||
}else{
|
|
||||||
trail.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawName(){
|
public void drawName(){
|
||||||
@@ -772,7 +764,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
inventory.clear();
|
inventory.clear();
|
||||||
placeQueue.clear();
|
placeQueue.clear();
|
||||||
dead = true;
|
dead = true;
|
||||||
trail.clear();
|
|
||||||
target = null;
|
target = null;
|
||||||
moveTarget = null;
|
moveTarget = null;
|
||||||
carrier = null;
|
carrier = null;
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import io.anuke.mindustry.entities.Predict;
|
|||||||
import io.anuke.mindustry.entities.Units;
|
import io.anuke.mindustry.entities.Units;
|
||||||
import io.anuke.mindustry.entities.traits.CarriableTrait;
|
import io.anuke.mindustry.entities.traits.CarriableTrait;
|
||||||
import io.anuke.mindustry.entities.traits.CarryTrait;
|
import io.anuke.mindustry.entities.traits.CarryTrait;
|
||||||
import io.anuke.mindustry.graphics.Trail;
|
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.type.AmmoType;
|
import io.anuke.mindustry.type.AmmoType;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
@@ -20,9 +19,7 @@ import static io.anuke.mindustry.Vars.world;
|
|||||||
|
|
||||||
public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
||||||
protected static Vector2 vec = new Vector2();
|
protected static Vector2 vec = new Vector2();
|
||||||
protected static float wobblyness = 0.6f;
|
|
||||||
|
|
||||||
protected Trail trail = new Trail(8);
|
|
||||||
protected CarriableTrait carrying;
|
protected CarriableTrait carrying;
|
||||||
protected final UnitState
|
protected final UnitState
|
||||||
|
|
||||||
@@ -155,9 +152,6 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
|||||||
updateRotation();
|
updateRotation();
|
||||||
wobble();
|
wobble();
|
||||||
}
|
}
|
||||||
|
|
||||||
trail.update(x + Angles.trnsx(rotation + 180f, 6f) + Mathf.range(wobblyness),
|
|
||||||
y + Angles.trnsy(rotation + 180f, 6f) + Mathf.range(wobblyness));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -171,11 +165,6 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
|||||||
Draw.alpha(1f);
|
Draw.alpha(1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawOver(){
|
|
||||||
trail.draw(type.trailColor, 5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void behavior(){
|
public void behavior(){
|
||||||
if(health <= health * type.retreatPercent && !isCommanded() &&
|
if(health <= health * type.retreatPercent && !isCommanded() &&
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import io.anuke.mindustry.entities.units.UnitCommand;
|
|||||||
import io.anuke.mindustry.entities.units.UnitState;
|
import io.anuke.mindustry.entities.units.UnitState;
|
||||||
import io.anuke.mindustry.game.EventType.BuildSelectEvent;
|
import io.anuke.mindustry.game.EventType.BuildSelectEvent;
|
||||||
import io.anuke.mindustry.gen.Call;
|
import io.anuke.mindustry.gen.Call;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
|
||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.mindustry.type.ItemStack;
|
import io.anuke.mindustry.type.ItemStack;
|
||||||
import io.anuke.mindustry.type.ItemType;
|
import io.anuke.mindustry.type.ItemType;
|
||||||
@@ -333,7 +332,6 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawOver(){
|
public void drawOver(){
|
||||||
trail.draw(Palette.lightTrail, 3f);
|
|
||||||
drawBuilding(this);
|
drawBuilding(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class BlockRenderer{
|
|||||||
private final static int initialRequests = 32 * 32;
|
private final static int initialRequests = 32 * 32;
|
||||||
private final static int expandr = 6;
|
private final static int expandr = 6;
|
||||||
|
|
||||||
public final FloorRenderer floor;
|
public final FloorRenderer floor = new FloorRenderer();
|
||||||
|
|
||||||
private Array<BlockRequest> requests = new Array<>(true, initialRequests, BlockRequest.class);
|
private Array<BlockRequest> requests = new Array<>(true, initialRequests, BlockRequest.class);
|
||||||
private IntSet teamChecks = new IntSet();
|
private IntSet teamChecks = new IntSet();
|
||||||
@@ -34,7 +34,6 @@ public class BlockRenderer{
|
|||||||
private FrameBuffer shadows = new FrameBuffer(1, 1);
|
private FrameBuffer shadows = new FrameBuffer(1, 1);
|
||||||
|
|
||||||
public BlockRenderer(){
|
public BlockRenderer(){
|
||||||
floor = new FloorRenderer();
|
|
||||||
|
|
||||||
for(int i = 0; i < requests.size; i++){
|
for(int i = 0; i < requests.size; i++){
|
||||||
requests.set(i, new BlockRequest());
|
requests.set(i, new BlockRequest());
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
package io.anuke.mindustry.graphics;
|
|
||||||
|
|
||||||
import io.anuke.arc.collection.FloatArray;
|
|
||||||
import io.anuke.arc.graphics.Color;
|
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
|
||||||
import io.anuke.arc.graphics.g2d.Fill;
|
|
||||||
import io.anuke.arc.graphics.g2d.Lines;
|
|
||||||
import io.anuke.arc.math.Mathf;
|
|
||||||
import io.anuke.arc.util.Time;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class that renders a colored trail.
|
|
||||||
* TODO remove / recode
|
|
||||||
*/
|
|
||||||
public class Trail{
|
|
||||||
private final static float maxJump = 15f;
|
|
||||||
private final int length;
|
|
||||||
private final FloatArray points = new FloatArray();
|
|
||||||
private float lastX, lastY;
|
|
||||||
|
|
||||||
public Trail(int length){
|
|
||||||
this.length = length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(float curx, float cury){
|
|
||||||
if(Mathf.dst(curx, cury, lastX, lastY) >= maxJump){
|
|
||||||
points.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
points.add(curx, cury);
|
|
||||||
|
|
||||||
while(points.size > (int)(length * 2 / Math.min(Time.delta(), 1f))){
|
|
||||||
float[] items = points.items;
|
|
||||||
System.arraycopy(items, 2, items, 0, points.size - 2);
|
|
||||||
points.size -= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
lastX = curx;
|
|
||||||
lastY = cury;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear(){
|
|
||||||
points.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void draw(Color color, float stroke){
|
|
||||||
Draw.color(color);
|
|
||||||
|
|
||||||
for(int i = 0; i < points.size - 2; i += 2){
|
|
||||||
float x = points.get(i);
|
|
||||||
float y = points.get(i + 1);
|
|
||||||
float x2 = points.get(i + 2);
|
|
||||||
float y2 = points.get(i + 3);
|
|
||||||
float s = Mathf.clamp((float) (i) / points.size);
|
|
||||||
|
|
||||||
Lines.stroke(s * stroke);
|
|
||||||
Lines.line(x, y, x2, y2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(points.size >= 2){
|
|
||||||
Fill.circle(points.get(points.size - 2), points.get(points.size - 1), stroke / 2f);
|
|
||||||
}
|
|
||||||
|
|
||||||
Draw.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -48,7 +48,6 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
//gesture data
|
//gesture data
|
||||||
private Vector2 vector = new Vector2();
|
private Vector2 vector = new Vector2();
|
||||||
private boolean canPan;
|
private boolean canPan;
|
||||||
private boolean zoomed = false;
|
|
||||||
/** Set of completed guides. */
|
/** Set of completed guides. */
|
||||||
private ObjectSet<String> guides = new ObjectSet<>();
|
private ObjectSet<String> guides = new ObjectSet<>();
|
||||||
|
|
||||||
@@ -663,6 +662,9 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
@Override
|
@Override
|
||||||
public boolean pan(float x, float y, float deltaX, float deltaY){
|
public boolean pan(float x, float y, float deltaX, float deltaY){
|
||||||
if(!canPan) return false;
|
if(!canPan) return false;
|
||||||
|
float scale = Core.camera.width / Core.graphics.getWidth();
|
||||||
|
deltaX *= scale;
|
||||||
|
deltaY *= scale;
|
||||||
|
|
||||||
//can't pan in line mode with one finger or while dropping items!
|
//can't pan in line mode with one finger or while dropping items!
|
||||||
if((lineMode && !Core.input.isTouched(1)) || droppingItem){
|
if((lineMode && !Core.input.isTouched(1)) || droppingItem){
|
||||||
@@ -673,11 +675,11 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
for(PlaceRequest req : selection){
|
for(PlaceRequest req : selection){
|
||||||
if(req.remove) continue; //don't shift removal requests
|
if(req.remove) continue; //don't shift removal requests
|
||||||
req.x += deltaX;
|
req.x += deltaX;
|
||||||
req.y -= deltaY;
|
req.y += deltaY;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//pan player
|
//pan player
|
||||||
Core.camera.position.x -= deltaX;
|
Core.camera.position.x += deltaX;
|
||||||
Core.camera.position.y += deltaY;
|
Core.camera.position.y += deltaY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -686,20 +688,9 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean zoom(float initialDistance, float distance){
|
public boolean zoom(float initialDistance, float distance){
|
||||||
|
float amount = (distance > initialDistance ? 0.1f : -0.1f) * Time.delta();
|
||||||
if(Math.abs(distance - initialDistance) > io.anuke.arc.scene.ui.layout.Unit.dp.scl(100f) && !zoomed){
|
renderer.scaleCamera(io.anuke.arc.scene.ui.layout.Unit.dp.scl(amount));
|
||||||
int amount = (distance > initialDistance ? 1 : -1);
|
return true;
|
||||||
renderer.scaleCamera(Math.round(io.anuke.arc.scene.ui.layout.Unit.dp.scl(amount)));
|
|
||||||
zoomed = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void pinchStop(){
|
|
||||||
zoomed = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -148,7 +148,6 @@ public class HudFragment extends Fragment{
|
|||||||
});
|
});
|
||||||
|
|
||||||
//minimap
|
//minimap
|
||||||
//TODO screws everything up, somehow
|
|
||||||
//parent.fill(t -> t.top().right().add(new Minimap()).visible(() -> !state.is(State.menu) && Core.settings.getBool("minimap")));
|
//parent.fill(t -> t.top().right().add(new Minimap()).visible(() -> !state.is(State.menu) && Core.settings.getBool("minimap")));
|
||||||
|
|
||||||
//paused table
|
//paused table
|
||||||
|
|||||||
@@ -152,8 +152,7 @@ public class CoreBlock extends StorageBlock{
|
|||||||
Shaders.build.color.set(Palette.accent);
|
Shaders.build.color.set(Palette.accent);
|
||||||
Shaders.build.time = -entity.time / 10f;
|
Shaders.build.time = -entity.time / 10f;
|
||||||
|
|
||||||
Draw.shader(Shaders.build, false);
|
Draw.shader(Shaders.build, true);
|
||||||
Shaders.build.apply();
|
|
||||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
Draw.rect(region, tile.drawx(), tile.drawy());
|
||||||
Draw.shader();
|
Draw.shader();
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -105,7 +105,7 @@ public class ServerControl implements ApplicationListener{
|
|||||||
String[] commands = {};
|
String[] commands = {};
|
||||||
|
|
||||||
if(args.length > 0){
|
if(args.length > 0){
|
||||||
commands = String.join(" ", args).split(",");
|
commands = Strings.join(" ", args).split(",");
|
||||||
info("&lmFound {0} command-line arguments to parse. {1}", commands.length);
|
info("&lmFound {0} command-line arguments to parse. {1}", commands.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user