From 4cf9d54c3dd06d79a478b672343f479645d42b8a Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 28 Jan 2025 21:59:40 -0500 Subject: [PATCH] Re-added old ingame editor UI, hid new UI behind a toggle --- .../mindustry/ui/fragments/HudFragment.java | 69 +++++-------------- .../ui/fragments/PlacementFragment.java | 17 ++--- 2 files changed, 20 insertions(+), 66 deletions(-) diff --git a/core/src/mindustry/ui/fragments/HudFragment.java b/core/src/mindustry/ui/fragments/HudFragment.java index 23c6d1a742..87733e627c 100644 --- a/core/src/mindustry/ui/fragments/HudFragment.java +++ b/core/src/mindustry/ui/fragments/HudFragment.java @@ -326,71 +326,32 @@ public class HudFragment{ editorMain.name = "editor"; editorMain.table(Tex.buttonEdge4, t -> { t.name = "teams"; + + t.top().table(teams -> { teams.left(); - int i = 0; for(Team team : Team.baseTeams){ - ImageButton button = teams.button(Tex.whiteui, Styles.clearNoneTogglei, 38f, () -> Call.setPlayerTeamEditor(player, team)) - .size(50f).margin(6f).get(); + ImageButton button = teams.button(Tex.whiteui, Styles.clearNoneTogglei, 33f, () -> Call.setPlayerTeamEditor(player, team)) + .size(45f).margin(6f).get(); button.getImageCell().grow(); button.getStyle().imageUpColor = team.color; button.update(() -> button.setChecked(player.team() == team)); - - if(++i % 6 == 0){ - teams.row(); - } } - }).top().left(); - t.row(); + teams.button(Icon.downOpen, Styles.emptyi, () -> Core.settings.put("editor-blocks-shown", !Core.settings.getBool("editor-blocks-shown"))) + .size(45f).update(m -> m.getStyle().imageUp = (Core.settings.getBool("editor-blocks-shown") ? Icon.upOpen : Icon.downOpen)); + }).top().left().row(); - t.table(control.input::buildPlacementUI).growX().left().with(in -> in.left()).row(); - - //hovering item display - t.table(h -> { - Runnable rebuild = () -> { - h.clear(); - h.left(); - - Displayable hover = blockfrag.hovered(); - UnlockableContent toDisplay = control.input.block; - - if(toDisplay == null && hover != null){ - if(hover instanceof Building b){ - toDisplay = b.block; - }else if(hover instanceof Tile tile){ - toDisplay = - tile.block().itemDrop != null ? tile.block() : - tile.overlay().itemDrop != null || tile.wallDrop() != null ? tile.overlay() : - tile.floor(); - }else if(hover instanceof Unit u){ - toDisplay = u.type; - } - } - - if(toDisplay != null){ - h.image(toDisplay.uiIcon).scaling(Scaling.fit).size(8 * 4); - h.add(toDisplay.localizedName).ellipsis(true).left().growX().padLeft(5); - } - }; - - Object[] hovering = {null}; - h.update(() -> { - Object nextHover = control.input.block != null ? control.input.block : blockfrag.hovered(); - if(nextHover != hovering[0]){ - hovering[0] = nextHover; - rebuild.run(); - } - }); - }).growX().left().minHeight(36f).row(); - - t.table(blocks -> { + t.collapser(blocks -> { addBlockSelection(blocks); - }).fillX().left(); - }).width(dsize * 5 + 4f); + }, () -> Core.settings.getBool("editor-blocks-shown")); + + + + }).width(dsize * 5 + 4f).top(); if(mobile){ editorMain.row().spacerY(() -> { - if(control.input instanceof MobileInput mob){ + if(control.input instanceof MobileInput mob && Core.settings.getBool("editor-blocks-shown")){ if(Core.graphics.isPortrait()) return Core.graphics.getHeight() / 2f / Scl.scl(1f); if(mob.hasSchematic()) return 156f; if(mob.showCancel()) return 50f; @@ -398,6 +359,8 @@ public class HudFragment{ return 0f; }); } + + editorMain.row().add().growY(); editorMain.visible(() -> shown && state.isEditor()); //fps display diff --git a/core/src/mindustry/ui/fragments/PlacementFragment.java b/core/src/mindustry/ui/fragments/PlacementFragment.java index 6b42c3c3fc..228d60289f 100644 --- a/core/src/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/mindustry/ui/fragments/PlacementFragment.java @@ -265,14 +265,7 @@ public class PlacementFragment{ public void build(Group parent){ parent.fill(full -> { toggler = full; - full.bottom().right().visible(() -> { - if(state.rules.editor){ - //force update the mouse picking, since it otherwise would not happen - updatePick(control.input); - } - - return ui.hudfrag.shown && !state.rules.editor; - }); + full.bottom().right().visible(() -> ui.hudfrag.shown); full.table(frame -> { @@ -750,12 +743,10 @@ public class PlacementFragment{ /** @return the thing being hovered over. */ public @Nullable Displayable hovered(){ - if(!state.rules.editor){ - Vec2 v = topTable.stageToLocalCoordinates(Core.input.mouse()); + Vec2 v = topTable.stageToLocalCoordinates(Core.input.mouse()); - //if the mouse intersects the table or the UI has the mouse, no hovering can occur - if(Core.scene.hasMouse() || topTable.hit(v.x, v.y, false) != null) return null; - } + //if the mouse intersects the table or the UI has the mouse, no hovering can occur + if(Core.scene.hasMouse() || topTable.hit(v.x, v.y, false) != null) return null; //check for a unit Unit unit = Units.closestOverlap(player.team(), Core.input.mouseWorldX(), Core.input.mouseWorldY(), 5f, u -> !u.isLocal() && u.displayable());