Tech tree usability improvements / Bugfixes
This commit is contained in:
@@ -46,9 +46,14 @@ public class EditorTile extends Tile{
|
||||
@Override
|
||||
public void setBlock(Block type){
|
||||
Block previous = block;
|
||||
byte pteam = getTeamID();
|
||||
if(previous == type) return;
|
||||
super.setBlock(type);
|
||||
if(pteam != getTeamID()){
|
||||
op(TileOp.get(x, y, (byte)OpType.team.ordinal(), pteam, getTeamID()));
|
||||
}
|
||||
op(TileOp.get(x, y, (byte)OpType.block.ordinal(), previous.id, type.id));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,8 +7,10 @@ import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Lines;
|
||||
import io.anuke.arc.math.Interpolation;
|
||||
import io.anuke.arc.scene.Element;
|
||||
import io.anuke.arc.scene.Group;
|
||||
import io.anuke.arc.scene.actions.Actions;
|
||||
import io.anuke.arc.scene.actions.RelativeTemporalAction;
|
||||
import io.anuke.arc.scene.event.Touchable;
|
||||
import io.anuke.arc.scene.style.TextureRegionDrawable;
|
||||
import io.anuke.arc.scene.ui.ImageButton;
|
||||
@@ -150,6 +152,21 @@ public class TechTreeDialog extends FloatingDialog{
|
||||
if(mobile){
|
||||
hoverNode = button;
|
||||
rebuild();
|
||||
float right = infoTable.getRight();
|
||||
if(right > Core.graphics.getWidth()){
|
||||
float moveBy = right - Core.graphics.getWidth();
|
||||
addAction(new RelativeTemporalAction(){
|
||||
{
|
||||
setDuration(0.1f);
|
||||
setInterpolation(Interpolation.fade);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateRelative(float percentDelta){
|
||||
panX -= moveBy * percentDelta;
|
||||
}
|
||||
});
|
||||
}
|
||||
}else if(data.hasItems(node.node.requirements) && locked(node.node)){
|
||||
unlock(node.node);
|
||||
}
|
||||
@@ -173,7 +190,7 @@ public class TechTreeDialog extends FloatingDialog{
|
||||
button.update(() -> {
|
||||
float offset = (Core.graphics.getHeight() % 2) / 2f;
|
||||
button.setPosition(node.x + panX + width / 2f, node.y + panY + height / 2f + offset, Align.center);
|
||||
button.getStyle().up = Core.scene.skin.getDrawable(!locked(node.node) ? "content-background" : "content-background-locked");
|
||||
button.getStyle().up = Core.scene.skin.getDrawable(!locked(node.node) ? "content-background" : !data.hasItems(node.node.requirements) ? "content-background-noitems" : "content-background-locked");
|
||||
((TextureRegionDrawable)button.getStyle().imageUp)
|
||||
.setRegion(node.visible ? node.node.block.icon(Icon.medium) : Core.atlas.find("icon-tree-locked"));
|
||||
button.getImage().setColor(!locked(node.node) ? Color.WHITE : Color.GRAY);
|
||||
@@ -181,6 +198,16 @@ public class TechTreeDialog extends FloatingDialog{
|
||||
addChild(button);
|
||||
}
|
||||
|
||||
if(mobile){
|
||||
tapped(() -> {
|
||||
Element e = hit(Core.input.mouseX(), Core.input.mouseY(), true);
|
||||
if(e == this){
|
||||
hoverNode = null;
|
||||
rebuild();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dragged((x, y) -> {
|
||||
moved = true;
|
||||
panX += x;
|
||||
@@ -257,6 +284,7 @@ public class TechTreeDialog extends FloatingDialog{
|
||||
|
||||
addChild(infoTable);
|
||||
infoTable.pack();
|
||||
infoTable.act(Core.graphics.getDeltaTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user