Added rotation to Android placement
This commit is contained in:
@@ -19,12 +19,24 @@ public class ContentLoader {
|
||||
public static void load(){
|
||||
|
||||
ContentList[] content = {
|
||||
//effects
|
||||
new BlockFx(),
|
||||
new BulletFx(),
|
||||
new EnvironmentFx(),
|
||||
new ExplosionFx(),
|
||||
new Fx(),
|
||||
new ShootFx(),
|
||||
new UnitFx(),
|
||||
|
||||
//items
|
||||
new Items(),
|
||||
|
||||
//liquids
|
||||
new Liquids(),
|
||||
|
||||
//status effects
|
||||
new StatusEffects(),
|
||||
|
||||
//bullets
|
||||
new ArtilleryBullets(),
|
||||
new FlakBullets(),
|
||||
@@ -39,24 +51,9 @@ public class ContentLoader {
|
||||
//mechs
|
||||
new Mechs(),
|
||||
|
||||
//units
|
||||
new UnitTypes(),
|
||||
|
||||
//weapons
|
||||
new Weapons(),
|
||||
|
||||
//status effects
|
||||
new StatusEffects(),
|
||||
|
||||
//effects
|
||||
new BlockFx(),
|
||||
new BulletFx(),
|
||||
new EnvironmentFx(),
|
||||
new ExplosionFx(),
|
||||
new Fx(),
|
||||
new ShootFx(),
|
||||
new UnitFx(),
|
||||
|
||||
//blocks
|
||||
new Blocks(),
|
||||
new DefenseBlocks(),
|
||||
@@ -72,6 +69,9 @@ public class ContentLoader {
|
||||
|
||||
//recipes
|
||||
new Recipes(),
|
||||
|
||||
//units
|
||||
new UnitTypes(),
|
||||
};
|
||||
|
||||
for (ContentList list : content){
|
||||
|
||||
@@ -134,6 +134,8 @@ public class UI extends SceneModule{
|
||||
|
||||
act();
|
||||
|
||||
Graphics.begin();
|
||||
|
||||
for(int i = 0; i < players.length; i ++){
|
||||
InputHandler input = control.input(i);
|
||||
|
||||
@@ -142,11 +144,12 @@ public class UI extends SceneModule{
|
||||
|
||||
float scl = Unit.dp.scl(3f);
|
||||
|
||||
Graphics.begin();
|
||||
Draw.rect("controller-cursor", input.getMouseX(), Gdx.graphics.getHeight() - input.getMouseY(), 16*scl, 16*scl);
|
||||
Graphics.end();
|
||||
}
|
||||
}
|
||||
|
||||
Graphics.end();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -181,7 +184,7 @@ public class UI extends SceneModule{
|
||||
placefrag.build(group);
|
||||
chatfrag.build(group);
|
||||
listfrag.build(group);
|
||||
debugfrag.build(group);
|
||||
//debugfrag.build(group);
|
||||
playermenufrag.build(group);
|
||||
loadfrag.build(group);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import static io.anuke.mindustry.Vars.world;
|
||||
public interface BlockBuilder {
|
||||
//temporary static final values
|
||||
Translator[] tmptr = {new Translator(), new Translator(), new Translator(), new Translator()};
|
||||
float placeDistance = 80f;
|
||||
float placeDistance = 200f;
|
||||
|
||||
/**Returns the queue for storing build requests.*/
|
||||
Queue<BuildRequest> getPlaceQueue();
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.badlogic.gdx.input.GestureDetector;
|
||||
import com.badlogic.gdx.input.GestureDetector.GestureListener;
|
||||
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 io.anuke.mindustry.content.fx.Fx;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
@@ -147,27 +148,38 @@ public class AndroidInput extends InputHandler implements GestureListener{
|
||||
//Create confirm/cancel table
|
||||
new table(){{
|
||||
abottom().aleft();
|
||||
defaults().size(60f);
|
||||
|
||||
//Add a cancel button, which clears the selection.
|
||||
new imagebutton("icon-cancel", 14*2f, () -> recipe = null);
|
||||
new table("pane"){{
|
||||
margin(5);
|
||||
defaults().size(60f);
|
||||
|
||||
//Add an accept button, which places everything.
|
||||
new imagebutton("icon-check", 14*2f, () -> {
|
||||
for(PlaceRequest request : placement){
|
||||
Tile tile = request.tile();
|
||||
//Add a cancel button, which clears the selection.
|
||||
new imagebutton("icon-cancel", 16 * 2f, () -> recipe = null);
|
||||
|
||||
if(tile != null){
|
||||
rotation = request.rotation;
|
||||
recipe = request.recipe;
|
||||
tryPlaceBlock(tile.x, tile.y);
|
||||
//Add an accept button, which places everything.
|
||||
new imagebutton("icon-check", 16 * 2f, () -> {
|
||||
for (PlaceRequest request : placement) {
|
||||
Tile tile = request.tile();
|
||||
|
||||
if (tile != null) {
|
||||
rotation = request.rotation;
|
||||
recipe = request.recipe;
|
||||
tryPlaceBlock(tile.x, tile.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
removals.addAll(placement);
|
||||
placement.clear();
|
||||
selecting = false;
|
||||
});
|
||||
removals.addAll(placement);
|
||||
placement.clear();
|
||||
selecting = false;
|
||||
});
|
||||
|
||||
//Add a rotate button
|
||||
new imagebutton("icon-arrow", 16 * 2f, () -> rotation = Mathf.mod(rotation + 1, 4))
|
||||
.update(i -> {
|
||||
i.getImage().setRotation(rotation * 90);
|
||||
i.getImage().setOrigin(Align.center);
|
||||
}).cell.disabled(i -> recipe == null || !recipe.result.rotate);
|
||||
}}.end();
|
||||
}}.visible(() -> isPlacing() && placement.size > 0).end();
|
||||
}
|
||||
|
||||
@@ -233,7 +245,7 @@ public class AndroidInput extends InputHandler implements GestureListener{
|
||||
|
||||
for(TextureRegion region : regions){
|
||||
Draw.rect(region, x *tilesize + recipe.result.offset(), y * tilesize + recipe.result.offset(),
|
||||
region.getRegionWidth() * lineScale, region.getRegionHeight() * lineScale, recipe.result.rotate ? rotation * 90 : 0);
|
||||
region.getRegionWidth() * lineScale, region.getRegionHeight() * lineScale, recipe.result.rotate ? result.rotation * 90 : 0);
|
||||
}
|
||||
}else{
|
||||
Draw.color(Palette.breakInvalid);
|
||||
@@ -315,7 +327,7 @@ public class AndroidInput extends InputHandler implements GestureListener{
|
||||
|
||||
@Override
|
||||
public boolean longPress(float x, float y) {
|
||||
if(state.is(State.menu)) return false;
|
||||
if(state.is(State.menu) || !isPlacing()) return false;
|
||||
|
||||
//get tile on cursor
|
||||
Tile cursor = tileAt(x, y);
|
||||
|
||||
@@ -24,7 +24,8 @@ import io.anuke.ucore.util.Translator;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public abstract class InputHandler extends InputAdapter{
|
||||
float playerSelectRange = Unit.dp.scl(80f);
|
||||
/**Used for dropping items.*/
|
||||
float playerSelectRange = Unit.dp.scl(40f);
|
||||
Translator stackTrns = new Translator();
|
||||
|
||||
public final Player player;
|
||||
|
||||
@@ -44,7 +44,6 @@ public class DebugFragment implements Fragment {
|
||||
public void build(Group parent){
|
||||
|
||||
Player player = players[0];
|
||||
|
||||
new table(){{
|
||||
visible(() -> debug);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user