Skip to content

Commit

Permalink
Re-added old ingame editor UI, hid new UI behind a toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuken committed Jan 29, 2025
1 parent b5a6d71 commit 4cf9d54
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 64 deletions.
65 changes: 14 additions & 51 deletions core/src/mindustry/ui/fragments/HudFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,78 +326,41 @@ public void build(Group parent){
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;
}
}
t.collapser(blocks -> {
addBlockSelection(blocks);
}, () -> Core.settings.getBool("editor-blocks-shown"));

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 -> {
addBlockSelection(blocks);
}).fillX().left();
}).width(dsize * 5 + 4f);
}).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;
}
return 0f;
});
}

editorMain.row().add().growY();
editorMain.visible(() -> shown && state.isEditor());

//fps display
Expand Down
17 changes: 4 additions & 13 deletions core/src/mindustry/ui/fragments/PlacementFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,7 @@ boolean gridUpdate(InputHandler input){
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 -> {

Expand Down Expand Up @@ -750,12 +743,10 @@ boolean hasInfoBox(){

/** @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());
Expand Down

0 comments on commit 4cf9d54

Please sign in to comment.