Skip to content

Commit

Permalink
Switch menu type when picking block
Browse files Browse the repository at this point in the history
  • Loading branch information
MEEPofFaith committed Mar 31, 2024
1 parent e3bb657 commit 5b6ebaa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/testing/editor/PainterTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void touched(int x, int y){
if(!Structs.inBounds(x, y, painter.width(), painter.height())) return;

Tile tile = painter.tile(x, y);
painter.drawBlock = tile.block() == Blocks.air || !tile.block().inEditor ? tile.overlay() == Blocks.air ? tile.floor() : tile.overlay() : tile.block();
painter.setDrawBlock(tile.block() == Blocks.air || !tile.block().inEditor ? tile.overlay() == Blocks.air ? tile.floor() : tile.overlay() : tile.block());
}
},
line("replace", "orthogonal"){
Expand Down
6 changes: 6 additions & 0 deletions src/testing/editor/TerrainPainter.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import mindustry.game.*;
import mindustry.world.*;
import mindustry.world.blocks.environment.*;
import testing.util.*;

import static mindustry.Vars.*;
import static testing.util.TUVars.*;
Expand Down Expand Up @@ -85,6 +86,11 @@ public float brushSize(){
return drawBlock instanceof SteamVent ? 2 : brushSize;
}

public void setDrawBlock(Block block){
drawBlock = block;
Setup.terrainFrag.updateMenu();
}

public void drawBlocksReplace(int x, int y){
drawBlocks(x, y, data -> data.block() != Blocks.air || drawBlock.isFloor());
}
Expand Down
5 changes: 5 additions & 0 deletions src/testing/ui/TerrainPainterFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,11 @@ private void rebuild(){
}).fillX().left().padBottom(10);
}

public void updateMenu(){
buildings = isBuilding(painter.drawBlock);
rebuild();
}

private boolean blockFilter(Block b){
if(buildings){
return isBuilding(b);
Expand Down

0 comments on commit 5b6ebaa

Please sign in to comment.