New tech tree layout
This commit is contained in:
@@ -22,7 +22,6 @@ public class TechTree implements ContentList{
|
|||||||
node(conveyor, () -> {
|
node(conveyor, () -> {
|
||||||
|
|
||||||
node(junction, () -> {
|
node(junction, () -> {
|
||||||
node(itemBridge);
|
|
||||||
node(router, () -> {
|
node(router, () -> {
|
||||||
node(launchPad, () -> {
|
node(launchPad, () -> {
|
||||||
node(launchPadLarge, () -> {
|
node(launchPadLarge, () -> {
|
||||||
@@ -45,16 +44,18 @@ public class TechTree implements ContentList{
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
node(titaniumConveyor, () -> {
|
node(itemBridge, () -> {
|
||||||
node(phaseConveyor, () -> {
|
node(titaniumConveyor, () -> {
|
||||||
node(massDriver, () -> {
|
node(phaseConveyor, () -> {
|
||||||
|
node(massDriver, () -> {
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
node(armoredConveyor, () -> {
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
node(armoredConveyor, () -> {
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -102,23 +103,25 @@ public class TechTree implements ContentList{
|
|||||||
|
|
||||||
|
|
||||||
node(copperWall, () -> {
|
node(copperWall, () -> {
|
||||||
node(copperWallLarge);
|
node(copperWallLarge, () -> {
|
||||||
node(titaniumWall, () -> {
|
node(titaniumWall, () -> {
|
||||||
node(door, () -> {
|
node(titaniumWallLarge);
|
||||||
node(doorLarge);
|
|
||||||
});
|
|
||||||
node(plastaniumWall, () -> {
|
|
||||||
node(plastaniumWallLarge, () -> {
|
|
||||||
|
|
||||||
|
node(door, () -> {
|
||||||
|
node(doorLarge);
|
||||||
});
|
});
|
||||||
});
|
node(plastaniumWall, () -> {
|
||||||
node(titaniumWallLarge);
|
node(plastaniumWallLarge, () -> {
|
||||||
node(thoriumWall, () -> {
|
|
||||||
node(thoriumWallLarge);
|
});
|
||||||
node(surgeWall, () -> {
|
});
|
||||||
node(surgeWallLarge);
|
node(thoriumWall, () -> {
|
||||||
node(phaseWall, () -> {
|
node(thoriumWallLarge);
|
||||||
node(phaseWallLarge);
|
node(surgeWall, () -> {
|
||||||
|
node(surgeWallLarge);
|
||||||
|
node(phaseWall, () -> {
|
||||||
|
node(phaseWallLarge);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package mindustry.ui.dialogs;
|
package mindustry.ui.dialogs;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
|
import arc.scene.ui.layout.Stack;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
@@ -25,6 +26,8 @@ import mindustry.ui.Cicon;
|
|||||||
import mindustry.ui.layout.*;
|
import mindustry.ui.layout.*;
|
||||||
import mindustry.ui.layout.TreeLayout.*;
|
import mindustry.ui.layout.TreeLayout.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class TechTreeDialog extends FloatingDialog{
|
public class TechTreeDialog extends FloatingDialog{
|
||||||
@@ -110,9 +113,24 @@ public class TechTreeDialog extends FloatingDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void treeLayout(){
|
void treeLayout(){
|
||||||
TreeLayout layout = new RadialTreeLayout();
|
float spacing = 20f;
|
||||||
LayoutNode node = new LayoutNode(root, null);
|
LayoutNode node = new LayoutNode(root, null);
|
||||||
layout.layout(node);
|
LayoutNode[] children = node.children;
|
||||||
|
LayoutNode[] leftHalf = Arrays.copyOfRange(node.children, 0, Mathf.ceil(node.children.length/2f));
|
||||||
|
LayoutNode[] rightHalf = Arrays.copyOfRange(node.children, Mathf.ceil(node.children.length/2f), node.children.length);
|
||||||
|
node.children = leftHalf;
|
||||||
|
new BranchTreeLayout(){{
|
||||||
|
gapBetweenLevels = gapBetweenNodes = spacing;
|
||||||
|
}}.layout(node);
|
||||||
|
node.children = rightHalf;
|
||||||
|
|
||||||
|
new BranchTreeLayout(){{
|
||||||
|
gapBetweenLevels = gapBetweenNodes = spacing;
|
||||||
|
rootLocation = TreeLocation.bottom;
|
||||||
|
}}.layout(node);
|
||||||
|
|
||||||
|
node.children = children;
|
||||||
|
|
||||||
float minx = 0f, miny = 0f, maxx = 0f, maxy = 0f;
|
float minx = 0f, miny = 0f, maxx = 0f, maxy = 0f;
|
||||||
copyInfo(node);
|
copyInfo(node);
|
||||||
|
|
||||||
@@ -378,7 +396,12 @@ public class TechTreeDialog extends FloatingDialog{
|
|||||||
|
|
||||||
Lines.stroke(Scl.scl(4f), locked(node.node) || locked(child.node) ? Pal.gray : Pal.accent);
|
Lines.stroke(Scl.scl(4f), locked(node.node) || locked(child.node) ? Pal.gray : Pal.accent);
|
||||||
Draw.alpha(parentAlpha);
|
Draw.alpha(parentAlpha);
|
||||||
Lines.line(node.x + offsetX, node.y + offsetY, child.x + offsetX, child.y + offsetY);
|
if(Mathf.equal(Math.abs(node.y - child.y), Math.abs(node.x - child.x), 1f) && Mathf.dstm(node.x, node.y, child.x, child.y) <= node.width*3){
|
||||||
|
Lines.line(node.x + offsetX, node.y + offsetY, child.x + offsetX, child.y + offsetY);
|
||||||
|
}else{
|
||||||
|
Lines.line(node.x + offsetX, node.y + offsetY, child.x + offsetX, node.y + offsetY);
|
||||||
|
Lines.line(child.x + offsetX, node.y + offsetY, child.x + offsetX, child.y + offsetY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,8 +148,7 @@ public class BranchTreeLayout implements TreeLayout{
|
|||||||
wPlus.mode = wPlus.mode + shift;
|
wPlus.mode = wPlus.mode + shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TreeNode apportion(TreeNode v, TreeNode defaultAncestor,
|
private TreeNode apportion(TreeNode v, TreeNode defaultAncestor, TreeNode leftSibling, TreeNode parentOfV){
|
||||||
TreeNode leftSibling, TreeNode parentOfV){
|
|
||||||
if(leftSibling == null){
|
if(leftSibling == null){
|
||||||
return defaultAncestor;
|
return defaultAncestor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=e5894c1aaa00d4ba1c75ba16c7f341d2ea70344c
|
archash=ad4050f9b828c264c5e70e48679064ef5e4152fb
|
||||||
|
|||||||
Reference in New Issue
Block a user