Hovering over blocks with a selection displays the selection (#10323)

* Selection display

Should this go in building or block?

* Apparently serpulo liquid icons are not square???

* simplify

* simplify further

* Add disabling w/ setting

Probably needs a better name

* Better name

* h
This commit is contained in:
MEEPofFaith
2025-02-08 18:21:09 -08:00
committed by GitHub
parent 07e573ac42
commit e9ecb2a576
10 changed files with 53 additions and 2 deletions

View File

@@ -1201,6 +1201,13 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
block.drawOverlay(x, y, rotation);
}
public void drawItemSelection(UnlockableContent selection){
if(selection != null && Core.settings.getBool("displayselection", true)){
TextureRegion region = selection.fullIcon;
Draw.rect(region, x, y + block.size * tilesize / 2f + 4, 8f * region.ratio(), 8f);
}
}
public void drawDisabled(){
Draw.color(Color.scarlet);
Draw.alpha(0.8f);

View File

@@ -453,6 +453,7 @@ public class SettingsMenuDialog extends BaseDialog{
graphics.checkPref("drawlight", true);
graphics.checkPref("destroyedblocks", true);
graphics.checkPref("blockstatus", false);
graphics.checkPref("displayselection", true);
graphics.checkPref("playerchat", true);
if(!mobile){
graphics.checkPref("coreitems", true);

View File

@@ -128,6 +128,12 @@ public class DirectionalUnloader extends Block{
}
@Override
public void drawSelect(){
super.drawSelect();
drawItemSelection(unloadItem);
}
@Override
public void buildConfiguration(Table table){
ItemSelection.buildTable(DirectionalUnloader.this, table, content.items(), () -> unloadItem, this::configure);

View File

@@ -89,6 +89,12 @@ public class DuctRouter extends Block{
}
}
@Override
public void drawSelect(){
super.drawSelect();
drawItemSelection(sortItem);
}
@Override
public void updateTile(){
progress += edelta() / speed * 2f;

View File

@@ -83,6 +83,12 @@ public class Sorter extends Block{
super.draw();
}
@Override
public void drawSelect(){
super.drawSelect();
drawItemSelection(sortItem);
}
@Override
public boolean acceptItem(Building source, Item item){
Building to = getTileTarget(item, source, false);

View File

@@ -78,6 +78,12 @@ public class ItemSource extends Block{
super.draw();
}
@Override
public void drawSelect(){
super.drawSelect();
drawItemSelection(outputItem);
}
@Override
public void updateTile(){
if(outputItem == null) return;
@@ -121,4 +127,4 @@ public class ItemSource extends Block{
outputItem = content.item(read.s());
}
}
}
}

View File

@@ -83,6 +83,12 @@ public class LiquidSource extends Block{
Draw.rect(block.region, x, y);
}
@Override
public void drawSelect(){
super.drawSelect();
drawItemSelection(source);
}
@Override
public void buildConfiguration(Table table){
ItemSelection.buildTable(LiquidSource.this, table, content.liquids(), () -> source, this::configure, selectionRows, selectionColumns);
@@ -111,4 +117,4 @@ public class LiquidSource extends Block{
source = id == -1 ? null : content.liquid(id);
}
}
}
}

View File

@@ -233,6 +233,12 @@ public class Unloader extends Block{
Draw.color();
}
@Override
public void drawSelect(){
super.drawSelect();
drawItemSelection(sortItem);
}
@Override
public void buildConfiguration(Table table){
ItemSelection.buildTable(Unloader.this, table, content.items(), () -> sortItem, this::configure, selectionRows, selectionColumns);

View File

@@ -50,6 +50,12 @@ public class UnitCargoUnloadPoint extends Block{
}
}
@Override
public void drawSelect(){
super.drawSelect();
drawItemSelection(item);
}
@Override
public void updateTile(){
super.updateTile();