Placement toggle support
This commit is contained in:
@@ -16,6 +16,7 @@ import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.OreBlock;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.actions.Actions;
|
||||
import io.anuke.ucore.scene.event.Touchable;
|
||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
@@ -30,16 +31,19 @@ public class PlacementFragment extends Fragment{
|
||||
|
||||
Array<Recipe> returned = new Array<>();
|
||||
Category currentCategory = Category.turret;
|
||||
Block hovered;
|
||||
Block lastDisplay;
|
||||
Block hovered, lastDisplay;
|
||||
Tile hoverTile;
|
||||
Table blockTable;
|
||||
Table blockTable, toggler;
|
||||
boolean shown = true;
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
parent.fill(frame -> {
|
||||
InputHandler input = control.input(0);
|
||||
parent.fill(full -> {
|
||||
toggler = full;
|
||||
full.bottom().right().visible(() -> !state.is(State.menu));
|
||||
|
||||
full.table(frame -> {
|
||||
InputHandler input = control.input(0);
|
||||
//rebuilds the category table with the correct recipes
|
||||
Runnable rebuildCategory = () -> {
|
||||
blockTable.clear();
|
||||
@@ -94,8 +98,6 @@ public class PlacementFragment extends Fragment{
|
||||
blockTable.act(0f);
|
||||
};
|
||||
|
||||
frame.bottom().right().visible(() -> !state.is(State.menu));
|
||||
|
||||
frame.table("clear", top -> {
|
||||
top.add(new Table()).growX().update(topTable -> {
|
||||
if((tileDisplayBlock() == null && lastDisplay == getSelected()) ||
|
||||
@@ -174,6 +176,7 @@ public class PlacementFragment extends Fragment{
|
||||
|
||||
rebuildCategory.run();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**Returns the currently displayed block in the top box.*/
|
||||
@@ -220,6 +223,12 @@ public class PlacementFragment extends Fragment{
|
||||
}
|
||||
|
||||
void toggle(float t, Interpolation ip){
|
||||
|
||||
if(shown){
|
||||
shown = false;
|
||||
toggler.actions(Actions.translateBy(toggler.getTranslation().x + toggler.getWidth(), 0, t, ip));
|
||||
}else{
|
||||
shown = true;
|
||||
toggler.actions(Actions.translateBy(-toggler.getTranslation().x, 0, t, ip));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user