This commit is contained in:
Anuken
2025-12-29 10:38:11 -05:00
parent b7049f35e6
commit 90d32abd6b
3 changed files with 20 additions and 6 deletions

View File

@@ -140,6 +140,12 @@ public class LogicDisplay extends Block{
}
}
public void getBufferRegion(TextureRegion region){
if(buffer != null){
region.set(buffer.getTexture(), 0, buffer.getTexture().height, buffer.getTexture().width, -buffer.getTexture().height);
}
}
public void processCommands(){
//don't bother processing commands if displays are off
if(!commands.isEmpty() && buffer != null){
@@ -182,8 +188,8 @@ public class LogicDisplay extends Block{
int id = packed >> 5;
if(ctype == displayDrawType){
if(id != index && id < displays.size && id >= 0 && displays.get(id).buffer != null){
Tmp.tr1.set(displays.get(id).buffer.getTexture());
Draw.rect(Tmp.tr1, x, y, p2, p2, p3 + 90);
displays.get(id).getBufferRegion(Tmp.tr1);
Draw.rect(Tmp.tr1, x, y, p2, p2 / Tmp.tr1.ratio(), p3);
}
}else if(ctype < ContentType.all.length && Vars.content.getByID(ContentType.all[ctype], id) instanceof UnlockableContent u){
var icon = u.fullIcon;

View File

@@ -27,6 +27,7 @@ public class TileableLogicDisplay extends LogicDisplay{
public int maxDisplayDimensions = 16;
public @Load(value = "@-#", length = 47) TextureRegion[] tileRegion;
public @Load("@-back") TextureRegion backRegion;
public int frameSize = 6;
public TileableLogicDisplay(String name){
super(name);
@@ -128,8 +129,8 @@ public class TileableLogicDisplay extends LogicDisplay{
@Override
public double sense(LAccess sensor){
return switch(sensor){
case displayWidth -> tilesWidth * 32f - 12f; // accounts for display frame (2 * 6 pixels)
case displayHeight -> tilesHeight * 32f - 12f;
case displayWidth -> tilesWidth * 32f - frameSize * 2; // accounts for display frame (2 * 6 pixels)
case displayHeight -> tilesHeight * 32f - frameSize * 2;
default -> super.sense(sensor);
};
}
@@ -157,6 +158,13 @@ public class TileableLogicDisplay extends LogicDisplay{
}
}
@Override
public void getBufferRegion(TextureRegion region){
if(buffer != null){
region.set(buffer.getTexture(), 0, buffer.getTexture().height - frameSize*2, buffer.getTexture().width - frameSize*2, -(buffer.getTexture().height - frameSize*2));
}
}
@Override
public void draw(){
//TODO if this is called before draw() on the root display is called, it will wipe it
@@ -219,7 +227,7 @@ public class TileableLogicDisplay extends LogicDisplay{
int rtx = (tile.x - originX), rty = (tile.y - originY);
// Offset the region to account for display frame (6 pixels)
Tmp.tr1.set(rootDisplay.buffer.getTexture(), rtx * 32 - 6, rty * 32 - 6, 32, 32);
Tmp.tr1.set(rootDisplay.buffer.getTexture(), rtx * 32 - frameSize, rty * 32 - frameSize, 32, 32);
Draw.rect(Tmp.tr1, x, y, tilesize, -tilesize);
}
});