diff --git a/core/src/mindustry/ui/ItemsDisplay.java b/core/src/mindustry/ui/ItemsDisplay.java index d59a579c16..995918895f 100644 --- a/core/src/mindustry/ui/ItemsDisplay.java +++ b/core/src/mindustry/ui/ItemsDisplay.java @@ -1,6 +1,7 @@ package mindustry.ui; import arc.graphics.*; +import arc.scene.ui.*; import arc.scene.ui.layout.*; import mindustry.core.GameState.*; import mindustry.gen.*; @@ -21,18 +22,31 @@ public class ItemsDisplay extends Table{ top().left(); margin(0); - table(Tex.button,t -> { - t.margin(10).marginLeft(15).marginTop(15f); - t.label(() -> state.is(State.menu) ? "$launcheditems" : "$launchinfo").colspan(3).padBottom(4).left().colspan(3).width(210f).wrap(); - t.row(); - for(Item item : content.items()){ - if(item.type == ItemType.material && data.isUnlocked(item)){ - t.label(() -> format(item)).left(); - t.addImage(item.icon(Cicon.small)).size(8 * 3).padLeft(4).padRight(4); - t.add(item.localizedName).color(Color.lightGray).left(); - t.row(); + table(Tex.button, c -> { + c.margin(10).marginLeft(12).marginTop(15f); + c.marginRight(12f); + c.left(); + + Collapser col = new Collapser(base -> base.pane(t -> { + t.marginRight(30f); + t.left(); + for(Item item : content.items()){ + if(item.type == ItemType.material && data.isUnlocked(item)){ + t.label(() -> format(item)).left(); + t.addImage(item.icon(Cicon.small)).size(8 * 3).padLeft(4).padRight(4); + t.add(item.localizedName).color(Color.lightGray).left(); + t.row(); + } } - } + }).get().setScrollingDisabled(true, false), false).setDuration(0.3f); + + c.addImageTextButton("$launcheditems", Icon.downOpen, Styles.clearTogglet, col::toggle).update(t -> { + t.setText(state.is(State.menu) ? "$launcheditems" : "$launchinfo"); + t.setChecked(col.isCollapsed()); + ((Image)t.getChildren().get(1)).setDrawable(col.isCollapsed() ? Icon.upOpen : Icon.downOpen); + }).padBottom(4).left().fillX().margin(12f); + c.row(); + c.add(col); }); } diff --git a/core/src/mindustry/ui/dialogs/TechTreeDialog.java b/core/src/mindustry/ui/dialogs/TechTreeDialog.java index 8e9d4609fb..4abf44e1a9 100644 --- a/core/src/mindustry/ui/dialogs/TechTreeDialog.java +++ b/core/src/mindustry/ui/dialogs/TechTreeDialog.java @@ -110,7 +110,7 @@ public class TechTreeDialog extends FloatingDialog{ } void treeLayout(){ - RadialTreeLayout layout = new RadialTreeLayout(); + TreeLayout layout = new RadialTreeLayout(); LayoutNode node = new LayoutNode(root, null); layout.layout(node); float minx = 0f, miny = 0f, maxx = 0f, maxy = 0f; diff --git a/core/src/mindustry/ui/fragments/PlacementFragment.java b/core/src/mindustry/ui/fragments/PlacementFragment.java index cf454a288f..b4bf78cfd8 100644 --- a/core/src/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/mindustry/ui/fragments/PlacementFragment.java @@ -31,11 +31,13 @@ public class PlacementFragment extends Fragment{ Array returnArray = new Array<>(); Array returnCatArray = new Array<>(); boolean[] categoryEmpty = new boolean[Category.all.length]; - ObjectMap selectedBlocks = new ObjectMap(); + ObjectMap selectedBlocks = new ObjectMap<>(); + ObjectFloatMap scrollPositions = new ObjectFloatMap<>(); Block hovered, lastDisplay; Tile lastHover; Tile hoverTile; Table blockTable, toggler, topTable; + ScrollPane blockPane; boolean lastGround; boolean blockSelectEnd; int blockSelectSeq; @@ -86,6 +88,8 @@ public class PlacementFragment extends Fragment{ } boolean gridUpdate(InputHandler input){ + scrollPositions.put(currentCategory, blockPane.getScrollY()); + if(Core.input.keyDown(Binding.pick)){ //mouse eyedropper select Tile tile = world.ltileWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y); Block tryRecipe = tile == null ? null : tile.block(); @@ -240,6 +244,9 @@ public class PlacementFragment extends Fragment{ } } blockTable.act(0f); + blockPane.act(0f); + blockPane.setScrollYForce(scrollPositions.get(currentCategory, 0)); + Core.app.post(() -> blockPane.setScrollYForce(scrollPositions.get(currentCategory, 0))); }; //top table with hover info @@ -343,14 +350,15 @@ public class PlacementFragment extends Fragment{ frame.row(); frame.table(Tex.pane2, blocksSelect -> { blocksSelect.margin(4).marginTop(0); - blocksSelect.pane(blocks -> blockTable = blocks).height(194f).update(pane -> { + blockPane = blocksSelect.pane(blocks -> blockTable = blocks).height(194f).update(pane -> { if(pane.hasScroll()){ Element result = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true); if(result == null || !result.isDescendantOf(pane)){ Core.scene.setScrollFocus(null); } } - }).grow().get().setStyle(Styles.smallPane); + }).grow().get(); + blockPane.setStyle(Styles.smallPane); blocksSelect.row(); blocksSelect.table(control.input::buildPlacementUI).name("inputTable").growX(); }).fillY().bottom().touchable(Touchable.enabled); diff --git a/core/src/mindustry/ui/layout/RadialTreeLayout.java b/core/src/mindustry/ui/layout/RadialTreeLayout.java index 65096e86f6..88b13a5efa 100644 --- a/core/src/mindustry/ui/layout/RadialTreeLayout.java +++ b/core/src/mindustry/ui/layout/RadialTreeLayout.java @@ -12,7 +12,7 @@ public class RadialTreeLayout implements TreeLayout{ @Override public void layout(TreeNode root){ startRadius = root.height * 2.4f; - delta = root.height * 2.4f; + delta = root.height * 20.4f; bfs(root, true); diff --git a/core/src/mindustry/ui/layout/RowTreeLayout.java b/core/src/mindustry/ui/layout/RowTreeLayout.java new file mode 100644 index 0000000000..58fa8596e4 --- /dev/null +++ b/core/src/mindustry/ui/layout/RowTreeLayout.java @@ -0,0 +1,36 @@ +package mindustry.ui.layout; + +import arc.struct.*; + +public class RowTreeLayout implements TreeLayout{ + + @Override + public void layout(TreeNode root){ + layout(root, 0, new IntArray()); + + /* + def minimum_ws(tree, depth=0): + tree.x = nexts[depth] + tree.y = depth + nexts[depth] += 1 + for c in tree.children: + minimum_ws(tree, c) + */ + } + + void layout(TreeNode node, int depth, IntArray nexts){ + float size = node.height * 5f; + + if(nexts.size < depth + 1){ + nexts.ensureCapacity(depth + 1); + nexts.size = depth + 1; + } + + node.x = size * nexts.get(depth); + node.y = size * depth; + nexts.incr(depth, 1); + for(TreeNode child : node.children){ + layout(child, depth + 1, nexts); + } + } +} diff --git a/gradle.properties b/gradle.properties index daa72c1573..20adabc721 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=85e020b1565d7f6490d2281411b810916046e5ee +archash=e5894c1aaa00d4ba1c75ba16c7f341d2ea70344c