Refactor input, fix color crash bugs, prototype multi-block placement

This commit is contained in:
Anuken
2017-12-13 23:28:20 -05:00
parent a100ee0e91
commit 949288393b
20 changed files with 373 additions and 209 deletions
@@ -6,7 +6,6 @@ import com.badlogic.gdx.utils.Align;
import io.anuke.mindustry.core.GameState;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.input.AndroidInput;
import io.anuke.mindustry.input.PlaceMode;
import io.anuke.ucore.scene.builders.imagebutton;
import io.anuke.ucore.scene.builders.label;
@@ -29,7 +28,7 @@ public class PlacementFragment implements Fragment{
new table("pane"){{
get().setTouchable(Touchable.enabled);
new label(()->"Placement Mode: [orange]" + AndroidInput.mode.name()).pad(4).units(Unit.dp);
new label(()->"Placement Mode: [orange]" + player.placeMode.name()).pad(4).units(Unit.dp);
row();
aleft();
@@ -42,7 +41,7 @@ public class PlacementFragment implements Fragment{
for(PlaceMode mode : PlaceMode.values()){
new imagebutton("icon-" + mode.name(), "toggle", Unit.dp.inPixels(10*3), ()->{
AndroidInput.mode = mode;
player.placeMode = mode;
}){{
group.add(get());
}};
@@ -50,7 +49,7 @@ public class PlacementFragment implements Fragment{
new imagebutton("icon-cancel", Unit.dp.inPixels(14*3), ()->{
player.recipe = null;
}).visible(()->player.recipe != null && AndroidInput.mode == PlaceMode.touch);
}).visible(()->player.recipe != null && player.placeMode == PlaceMode.touch);
new imagebutton("icon-rotate-arrow", Unit.dp.inPixels(14*3), ()->{
player.rotation ++;
@@ -58,7 +57,7 @@ public class PlacementFragment implements Fragment{
}).update(i->{
i.getImage().setOrigin(Align.center);
i.getImage().setRotation(player.rotation*90);
}).visible(()->player.recipe != null && AndroidInput.mode == PlaceMode.touch
}).visible(()->player.recipe != null && player.placeMode == PlaceMode.touch
&& player.recipe.result.rotate);
}}.left().end();
@@ -7,7 +7,6 @@ import com.badlogic.gdx.utils.Align;
import io.anuke.mindustry.core.GameState;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.input.AndroidInput;
import io.anuke.mindustry.input.PlaceMode;
import io.anuke.ucore.core.Core;
import io.anuke.ucore.scene.ui.layout.Table;
@@ -28,18 +27,19 @@ public class ToolFragment implements Fragment{
});
tools.addIButton("icon-check", Unit.dp.inPixels(42), ()->{
AndroidInput.place();
player.placeMode.tapped(control.getInput().getBlockX(), control.getInput().getBlockY(),
control.getInput().getBlockEndX(), control.getInput().getBlockEndY());
});
Core.scene.add(tools);
tools.setVisible(()->
!GameState.is(State.menu) && android && player.recipe != null && control.hasItems(player.recipe.requirements) &&
AndroidInput.mode == PlaceMode.cursor
player.placeMode == PlaceMode.cursor
);
tools.update(()->{
tools.setPosition(AndroidInput.mousex, Gdx.graphics.getHeight()-AndroidInput.mousey-15*Core.cameraScale, Align.top);
tools.setPosition(control.getInput().getCursorX(), Gdx.graphics.getHeight() - control.getInput().getCursorY() - 15*Core.cameraScale, Align.top);
});
}
}