Allow displays on draw image (#11140)

* Display on display drawing

* Update draw image description
This commit is contained in:
Redstonneur1256
2025-12-28 03:38:44 +01:00
committed by GitHub
parent 59c3b18a6f
commit 1a89fc9f8e
3 changed files with 36 additions and 11 deletions

View File

@@ -2661,7 +2661,7 @@ graphicstype.linerect = Draw a rectangle outline.
graphicstype.poly = Fill a regular polygon. graphicstype.poly = Fill a regular polygon.
graphicstype.linepoly = Draw a regular polygon outline. graphicstype.linepoly = Draw a regular polygon outline.
graphicstype.triangle = Fill a triangle. graphicstype.triangle = Fill a triangle.
graphicstype.image = Draw an image of some content.\nex: [accent]@router[] or [accent]@dagger[]. graphicstype.image = Draw an image of some content or copies another display.\nex content: [accent]@router[], [accent]@dagger[] or a display [accent]display1[].
graphicstype.print = Draws text from the print buffer.\nOnly ASCII characters are allowed.\nClears the print buffer. graphicstype.print = Draws text from the print buffer.\nOnly ASCII characters are allowed.\nClears the print buffer.
lenum.always = Always true. lenum.always = Always true.

View File

@@ -943,25 +943,24 @@ public class LExecutor{
exec.textBuffer.setLength(0); exec.textBuffer.setLength(0);
} }
}else{ }else{
int num1 = p1.numi(), num4 = p4.numi(), xval = packSign(x.numi()), yval = packSign(y.numi()); int num1 = packSign(p1.numi()), num4 = packSign(p4.numi()), xval = packSign(x.numi()), yval = packSign(y.numi());
if(type == LogicDisplay.commandImage){ if(type == LogicDisplay.commandImage){
int packed = -1;
if(p1.obj() instanceof UnlockableContent u){ if(p1.obj() instanceof UnlockableContent u){
//TODO: with mods, this will overflow (ID >= 512), but that's better than the previous system, at least packed = (u.id << 5) | (u.getContentType().ordinal() & 31);
num1 = u.id; }else if(p1.obj() instanceof LogicDisplayBuild d){
num4 = u.getContentType().ordinal(); packed = (d.index << 5) | 30;
}else{
num1 = -1;
num4 = -1;
} }
//num1 = p1.obj() instanceof UnlockableContent u ? u.iconId : 0; num1 = packed & 0x3FF;
num4 = packed >> 10;
}else if(type == LogicDisplay.commandScale){ }else if(type == LogicDisplay.commandScale){
xval = packSign((int)(x.numf() / LogicDisplay.scaleStep)); xval = packSign((int)(x.numf() / LogicDisplay.scaleStep));
yval = packSign((int)(y.numf() / LogicDisplay.scaleStep)); yval = packSign((int)(y.numf() / LogicDisplay.scaleStep));
} }
//add graphics calls, cap graphics buffer size //add graphics calls, cap graphics buffer size
exec.graphicsBuffer.add(DisplayCmd.get(type, xval, yval, packSign(num1), packSign(p2.numi()), packSign(p3.numi()), packSign(num4))); exec.graphicsBuffer.add(DisplayCmd.get(type, xval, yval, num1, packSign(p2.numi()), packSign(p3.numi()), num4));
} }
} }

View File

@@ -41,6 +41,8 @@ public class LogicDisplay extends Block{
commandResetTransform = 15 commandResetTransform = 15
; ;
public static final Seq<LogicDisplayBuild> displays = new Seq<>(false);
public static final float scaleStep = 0.05f; public static final float scaleStep = 0.05f;
public int maxSides = 25; public int maxSides = 25;
@@ -81,6 +83,7 @@ public class LogicDisplay extends Block{
public LongQueue commands = new LongQueue(256); public LongQueue commands = new LongQueue(256);
public @Nullable Mat transform; public @Nullable Mat transform;
public long operations; public long operations;
public int index = -1;
@Override @Override
public void draw(){ public void draw(){
@@ -167,7 +170,15 @@ public class LogicDisplay extends Block{
case commandColor -> Draw.color(this.color = Color.toFloatBits(x, y, p1, p2)); case commandColor -> Draw.color(this.color = Color.toFloatBits(x, y, p1, p2));
case commandStroke -> Lines.stroke(this.stroke = x); case commandStroke -> Lines.stroke(this.stroke = x);
case commandImage -> { case commandImage -> {
if(p4 >= 0 && p4 < ContentType.all.length && Vars.content.getByID(ContentType.all[p4], p1) instanceof UnlockableContent u){ int packed = (DisplayCmd.p4(c) << 10) | DisplayCmd.p1(c);
int ctype = packed & 0x1F;
int id = packed >> 5;
if(ctype == 30){
if(id != index && id < displays.size && displays.get(id).buffer != null){
Tmp.tr1.set(displays.get(id).buffer.getTexture());
Draw.rect(Tmp.tr1, x, y, p2, p2, p3 + 90);
}
}else if(ctype < ContentType.all.length && Vars.content.getByID(ContentType.all[p4], id) instanceof UnlockableContent u){
var icon = u.fullIcon; var icon = u.fullIcon;
Draw.rect(icon, x, y, p2, p2 / icon.ratio(), p3); Draw.rect(icon, x, y, p2, p2 / icon.ratio(), p3);
} }
@@ -231,9 +242,24 @@ public class LogicDisplay extends Block{
} }
} }
@Override
public void add(){
super.add();
index = displays.size;
displays.add(this);
}
@Override @Override
public void remove(){ public void remove(){
super.remove(); super.remove();
if(index != -1){
displays.get(displays.size - 1).index = index;
displays.remove(index);
index = -1;
}
if(buffer != null){ if(buffer != null){
buffer.dispose(); buffer.dispose();
buffer = null; buffer = null;