Fixed android version / Smooth zoom
This commit is contained in:
@@ -299,7 +299,7 @@ public class Renderer implements ApplicationListener{
|
||||
|
||||
public void clampScale(){
|
||||
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(){
|
||||
|
||||
@@ -14,7 +14,10 @@ import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Geometry;
|
||||
import io.anuke.arc.math.geom.Rectangle;
|
||||
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.mindustry.content.Mechs;
|
||||
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.gen.Call;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.graphics.Trail;
|
||||
import io.anuke.mindustry.input.Binding;
|
||||
import io.anuke.mindustry.io.TypeIO;
|
||||
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 Tile mining;
|
||||
private CarriableTrait carrying;
|
||||
private Trail trail = new Trail(12);
|
||||
private Vector2 movement = new Vector2();
|
||||
private boolean moved;
|
||||
|
||||
@@ -373,15 +374,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
if(dead) return;
|
||||
|
||||
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(){
|
||||
@@ -772,7 +764,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
inventory.clear();
|
||||
placeQueue.clear();
|
||||
dead = true;
|
||||
trail.clear();
|
||||
target = null;
|
||||
moveTarget = null;
|
||||
carrier = null;
|
||||
|
||||
@@ -10,7 +10,6 @@ import io.anuke.mindustry.entities.Predict;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.entities.traits.CarriableTrait;
|
||||
import io.anuke.mindustry.entities.traits.CarryTrait;
|
||||
import io.anuke.mindustry.graphics.Trail;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.AmmoType;
|
||||
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{
|
||||
protected static Vector2 vec = new Vector2();
|
||||
protected static float wobblyness = 0.6f;
|
||||
|
||||
protected Trail trail = new Trail(8);
|
||||
protected CarriableTrait carrying;
|
||||
protected final UnitState
|
||||
|
||||
@@ -155,9 +152,6 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
||||
updateRotation();
|
||||
wobble();
|
||||
}
|
||||
|
||||
trail.update(x + Angles.trnsx(rotation + 180f, 6f) + Mathf.range(wobblyness),
|
||||
y + Angles.trnsy(rotation + 180f, 6f) + Mathf.range(wobblyness));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -171,11 +165,6 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
||||
Draw.alpha(1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawOver(){
|
||||
trail.draw(type.trailColor, 5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void behavior(){
|
||||
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.game.EventType.BuildSelectEvent;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.ItemType;
|
||||
@@ -333,7 +332,6 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
||||
|
||||
@Override
|
||||
public void drawOver(){
|
||||
trail.draw(Palette.lightTrail, 3f);
|
||||
drawBuilding(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class BlockRenderer{
|
||||
private final static int initialRequests = 32 * 32;
|
||||
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 IntSet teamChecks = new IntSet();
|
||||
@@ -34,7 +34,6 @@ public class BlockRenderer{
|
||||
private FrameBuffer shadows = new FrameBuffer(1, 1);
|
||||
|
||||
public BlockRenderer(){
|
||||
floor = new FloorRenderer();
|
||||
|
||||
for(int i = 0; i < requests.size; i++){
|
||||
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
|
||||
private Vector2 vector = new Vector2();
|
||||
private boolean canPan;
|
||||
private boolean zoomed = false;
|
||||
/** Set of completed guides. */
|
||||
private ObjectSet<String> guides = new ObjectSet<>();
|
||||
|
||||
@@ -663,6 +662,9 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
@Override
|
||||
public boolean pan(float x, float y, float deltaX, float deltaY){
|
||||
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!
|
||||
if((lineMode && !Core.input.isTouched(1)) || droppingItem){
|
||||
@@ -673,11 +675,11 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
for(PlaceRequest req : selection){
|
||||
if(req.remove) continue; //don't shift removal requests
|
||||
req.x += deltaX;
|
||||
req.y -= deltaY;
|
||||
req.y += deltaY;
|
||||
}
|
||||
}else{
|
||||
//pan player
|
||||
Core.camera.position.x -= deltaX;
|
||||
Core.camera.position.x += deltaX;
|
||||
Core.camera.position.y += deltaY;
|
||||
}
|
||||
|
||||
@@ -686,20 +688,9 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
|
||||
@Override
|
||||
public boolean zoom(float initialDistance, float distance){
|
||||
|
||||
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.arc.scene.ui.layout.Unit.dp.scl(amount)));
|
||||
zoomed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pinchStop(){
|
||||
zoomed = false;
|
||||
float amount = (distance > initialDistance ? 0.1f : -0.1f) * Time.delta();
|
||||
renderer.scaleCamera(io.anuke.arc.scene.ui.layout.Unit.dp.scl(amount));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -148,7 +148,6 @@ public class HudFragment extends Fragment{
|
||||
});
|
||||
|
||||
//minimap
|
||||
//TODO screws everything up, somehow
|
||||
//parent.fill(t -> t.top().right().add(new Minimap()).visible(() -> !state.is(State.menu) && Core.settings.getBool("minimap")));
|
||||
|
||||
//paused table
|
||||
|
||||
@@ -152,8 +152,7 @@ public class CoreBlock extends StorageBlock{
|
||||
Shaders.build.color.set(Palette.accent);
|
||||
Shaders.build.time = -entity.time / 10f;
|
||||
|
||||
Draw.shader(Shaders.build, false);
|
||||
Shaders.build.apply();
|
||||
Draw.shader(Shaders.build, true);
|
||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
||||
Draw.shader();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user