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

@@ -1332,7 +1332,7 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
out.set(u.fullIcon); out.set(u.fullIcon);
}else if(texture instanceof LogicDisplayBuild d && d.isAdded()){ }else if(texture instanceof LogicDisplayBuild d && d.isAdded()){
d.ensureBuffer(); d.ensureBuffer();
out.set(d.buffer.getTexture()); d.getBufferRegion(out);
}else if(texture instanceof CanvasBuild c && c.isAdded()){ }else if(texture instanceof CanvasBuild c && c.isAdded()){
c.updateTexture(); c.updateTexture();
if(c.texture != null) out.set(c.texture); if(c.texture != null) out.set(c.texture);

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

View File

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