mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-13 00:05:23 +07:00
Right menu removed in editor mode
This commit is contained in:
parent
15ca672179
commit
9ceaa0339b
@ -540,8 +540,6 @@ public class DesktopInput extends InputHandler{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildPlacementUI(Table table){
|
public void buildPlacementUI(Table table){
|
||||||
table.image().color(Pal.gray).height(4f).colspan(4).growX();
|
|
||||||
table.row();
|
|
||||||
table.left().margin(0f).defaults().size(48f).left();
|
table.left().margin(0f).defaults().size(48f).left();
|
||||||
|
|
||||||
table.button(Icon.paste, Styles.clearNonei, () -> {
|
table.button(Icon.paste, Styles.clearNonei, () -> {
|
||||||
|
@ -188,8 +188,6 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildPlacementUI(Table table){
|
public void buildPlacementUI(Table table){
|
||||||
table.image().color(Pal.gray).height(4f).colspan(4).growX();
|
|
||||||
table.row();
|
|
||||||
table.left().margin(0f).defaults().size(48f);
|
table.left().margin(0f).defaults().size(48f);
|
||||||
|
|
||||||
table.button(Icon.hammer, Styles.clearNoneTogglei, () -> {
|
table.button(Icon.hammer, Styles.clearNoneTogglei, () -> {
|
||||||
|
@ -344,6 +344,46 @@ public class HudFragment{
|
|||||||
|
|
||||||
t.row();
|
t.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.table(blocks -> {
|
||||||
addBlockSelection(blocks);
|
addBlockSelection(blocks);
|
||||||
}).fillX().left();
|
}).fillX().left();
|
||||||
|
@ -124,9 +124,7 @@ public class PlacementFragment{
|
|||||||
toggler.setZIndex(index);
|
toggler.setZIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean gridUpdate(InputHandler input){
|
boolean updatePick(InputHandler input){
|
||||||
scrollPositions.put(currentCategory, blockPane.getScrollY());
|
|
||||||
|
|
||||||
if(Core.input.keyTap(Binding.pick) && player.isBuilder() && !Core.scene.hasDialog()){ //mouse eyedropper select
|
if(Core.input.keyTap(Binding.pick) && player.isBuilder() && !Core.scene.hasDialog()){ //mouse eyedropper select
|
||||||
var build = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
var build = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
||||||
|
|
||||||
@ -150,9 +148,9 @@ public class PlacementFragment{
|
|||||||
var tile = world.tileWorld(Core.input.mouseWorldX(), Core.input.mouseWorldY());
|
var tile = world.tileWorld(Core.input.mouseWorldX(), Core.input.mouseWorldY());
|
||||||
if(tile != null){
|
if(tile != null){
|
||||||
tryRecipe =
|
tryRecipe =
|
||||||
tile.block() != Blocks.air ? tile.block() :
|
tile.block() != Blocks.air ? tile.block() :
|
||||||
tile.overlay() != Blocks.air ? tile.overlay() :
|
tile.overlay() != Blocks.air ? tile.overlay() :
|
||||||
tile.floor() != Blocks.air ? tile.floor() : null;
|
tile.floor() != Blocks.air ? tile.floor() : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,6 +163,15 @@ public class PlacementFragment{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean gridUpdate(InputHandler input){
|
||||||
|
scrollPositions.put(currentCategory, blockPane.getScrollY());
|
||||||
|
|
||||||
|
if(updatePick(input)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if(ui.chatfrag.shown() || ui.consolefrag.shown() || Core.scene.hasKeyboard()) return false;
|
if(ui.chatfrag.shown() || ui.consolefrag.shown() || Core.scene.hasKeyboard()) return false;
|
||||||
|
|
||||||
@ -258,7 +265,14 @@ public class PlacementFragment{
|
|||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
parent.fill(full -> {
|
parent.fill(full -> {
|
||||||
toggler = full;
|
toggler = full;
|
||||||
full.bottom().right().visible(() -> ui.hudfrag.shown);
|
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.table(frame -> {
|
full.table(frame -> {
|
||||||
|
|
||||||
@ -644,7 +658,11 @@ public class PlacementFragment{
|
|||||||
}).grow().get();
|
}).grow().get();
|
||||||
blockPane.setStyle(Styles.smallPane);
|
blockPane.setStyle(Styles.smallPane);
|
||||||
blocksSelect.row();
|
blocksSelect.row();
|
||||||
blocksSelect.table(control.input::buildPlacementUI).name("inputTable").growX();
|
blocksSelect.table(t -> {
|
||||||
|
t.image().color(Pal.gray).height(4f).colspan(4).growX();
|
||||||
|
t.row();
|
||||||
|
control.input.buildPlacementUI(t);
|
||||||
|
}).name("inputTable").growX();
|
||||||
}).fillY().bottom().touchable(Touchable.enabled);
|
}).fillY().bottom().touchable(Touchable.enabled);
|
||||||
blockCatTable.table(categories -> {
|
blockCatTable.table(categories -> {
|
||||||
categories.bottom();
|
categories.bottom();
|
||||||
@ -730,13 +748,14 @@ public class PlacementFragment{
|
|||||||
return control.input.block != null || menuHoverBlock != null || hover != null;
|
return control.input.block != null || menuHoverBlock != null || hover != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the thing being hovered over. */
|
/** @return the thing being hovered over. */
|
||||||
@Nullable
|
public @Nullable Displayable hovered(){
|
||||||
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 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(Core.scene.hasMouse() || topTable.hit(v.x, v.y, false) != null) return null;
|
||||||
|
}
|
||||||
|
|
||||||
//check for a unit
|
//check for a unit
|
||||||
Unit unit = Units.closestOverlap(player.team(), Core.input.mouseWorldX(), Core.input.mouseWorldY(), 5f, u -> !u.isLocal() && u.displayable());
|
Unit unit = Units.closestOverlap(player.team(), Core.input.mouseWorldX(), Core.input.mouseWorldY(), 5f, u -> !u.isLocal() && u.displayable());
|
||||||
|
Loading…
Reference in New Issue
Block a user