Input fixes

This commit is contained in:
Anuken
2018-12-30 11:41:06 -05:00
parent 745d8122f5
commit b91510efb3
7 changed files with 430 additions and 536 deletions

View File

@@ -66,7 +66,8 @@ public class Control implements ApplicationListener{
content.initialize(Content::load);
if(Core.atlas.getTextures().size != 1){
throw new IllegalStateException("Atlas must be exactly one texture.");
throw new IllegalStateException("Atlas must be exactly one texture. " +
"If more textures are used, the map editor will not display them correctly.");
}
unlocks.load();

View File

@@ -1,12 +1,10 @@
package io.anuke.mindustry.core;
import io.anuke.arc.Core;
import io.anuke.arc.Input.TextInput;
import io.anuke.arc.files.FileHandle;
import io.anuke.arc.function.Consumer;
import io.anuke.arc.input.KeyCode;
import io.anuke.arc.scene.ui.Dialog;
import io.anuke.arc.scene.ui.TextField;
import io.anuke.arc.util.Time;
import io.anuke.arc.util.serialization.Base64Coder;
import java.util.Random;
@@ -26,6 +24,17 @@ public abstract class Platform {
if(!mobile) return; //this is mobile only, desktop doesn't need dialogs
field.tapped(() -> {
TextInput input = new TextInput();
input.text = field.getText();
input.maxLength = maxLength;
input.accepted = text -> {
field.clearText();
field.appendText(text);
field.change();
Core.input.setOnscreenKeyboardVisible(false);
};
Core.input.getTextInput(input);
/*
Dialog dialog = new Dialog("", "dialog");
dialog.setFillParent(true);
dialog.content().top();
@@ -59,7 +68,7 @@ public abstract class Platform {
to.setCursorPosition(to.getText().length());
Core.scene.setKeyboardFocus(to);
Core.input.setOnscreenKeyboardVisible(true);
});
});*/
});
}
/**Update discord RPC.*/

View File

@@ -1,115 +0,0 @@
package io.anuke.mindustry.entities.units.types;
import io.anuke.annotations.Annotations.Loc;
import io.anuke.annotations.Annotations.Remote;
import io.anuke.arc.Core;
import io.anuke.arc.entities.Effects;
import io.anuke.arc.math.Angles;
import io.anuke.arc.math.geom.Vector2;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.fx.UnitFx;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.Predict;
import io.anuke.mindustry.entities.traits.TargetTrait;
import io.anuke.mindustry.entities.units.BaseUnit;
import io.anuke.mindustry.entities.units.FlyingUnit;
import io.anuke.mindustry.entities.units.UnitCommand;
import io.anuke.mindustry.entities.units.UnitState;
import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.AmmoType;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import static io.anuke.mindustry.Vars.headless;
import static io.anuke.mindustry.Vars.players;
public class AlphaDrone extends FlyingUnit {
static final float followDistance = 80f;
public Player leader;
public final UnitState attack = new UnitState() {
@Override
public void update() {
if(leader == null || leader.isDead() || !leader.isAdded()){
damage(99999f);
return;
}
TargetTrait last = target;
target = leader;
if(last == null){
circle(leader.isShooting ? 60f : 0f);
}
target = last;
if(dst(leader) < followDistance){
targetClosest();
}else{
target = null;
}
if(target != null){
attack(50f);
if((Angles.near(angleTo(target), rotation, 15f) && dst(target) < getWeapon().getAmmo().getRange())){
AmmoType ammo = getWeapon().getAmmo();
Vector2 to = Predict.intercept(AlphaDrone.this, target, ammo.bullet.speed);
getWeapon().update(AlphaDrone.this, to.x, to.y);
}
}
if(!leader.isShooting && dst(leader) < 7f){
Call.onAlphaDroneFade(AlphaDrone.this);
}
}
};
@Remote(called = Loc.server)
public static void onAlphaDroneFade(BaseUnit drone){
if(drone == null) return;
Effects.effect(UnitFx.pickup, drone);
//must run afterwards so the unit's group is not null when sending the removal packet
Core.app.post(drone::remove);
}
@Override
public void onCommand(UnitCommand command){
//nuh
}
@Override
public void behavior(){
//nope
}
@Override
public UnitState getStartState() {
return attack;
}
@Override
public void write(DataOutput stream) throws IOException {
super.write(stream);
stream.writeInt(leader == null ? -1 : leader.id);
}
@Override
public void read(DataInput stream) throws IOException {
super.read(stream);
leader = Vars.playerGroup.getByID(stream.readInt());
}
@Override
public void readSave(DataInput stream) throws IOException{
super.readSave(stream);
if(!Net.active() && !headless){
leader = players[0];
}
}
}

View File

@@ -23,7 +23,7 @@ public class BackgroundFragment extends Fragment{
Draw.shader();
boolean portrait = Core.graphics.getWidth() < Core.graphics.getHeight();
float logoscl = (int) Unit.dp.scl(1) * (portrait ? 5f / 7f : 1f);
float logoscl = (int) Unit.dp.scl(1) * (portrait ? 0.5f : 0.75f);
TextureRegion logo = Core.atlas.find("logotext");
float logow = logo.getWidth() * logoscl;
float logoh = logo.getHeight() * logoscl;