Minor fixes for markers and empty floor edges
This commit is contained in:
@@ -10,7 +10,6 @@ import arc.math.geom.*;
|
|||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.io.*;
|
|
||||||
import arc.util.serialization.*;
|
import arc.util.serialization.*;
|
||||||
import arc.util.serialization.Json.*;
|
import arc.util.serialization.Json.*;
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
@@ -27,9 +26,7 @@ import mindustry.world.*;
|
|||||||
import mindustry.world.blocks.logic.CanvasBlock.*;
|
import mindustry.world.blocks.logic.CanvasBlock.*;
|
||||||
import mindustry.world.blocks.logic.LogicDisplay.*;
|
import mindustry.world.blocks.logic.LogicDisplay.*;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
import java.nio.*;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static java.lang.annotation.ElementType.*;
|
import static java.lang.annotation.ElementType.*;
|
||||||
@@ -1333,29 +1330,28 @@ public class MapObjectives implements Iterable<MapObjective>, Eachable<MapObject
|
|||||||
}
|
}
|
||||||
}else if(texture instanceof UnlockableContent u){
|
}else if(texture instanceof UnlockableContent u){
|
||||||
out.set(u.fullIcon);
|
out.set(u.fullIcon);
|
||||||
}else if(texture instanceof LogicDisplayBuild d){
|
}else if(texture instanceof LogicDisplayBuild d && d.isAdded()){
|
||||||
d.ensureBuffer();
|
d.ensureBuffer();
|
||||||
out.set(d.buffer.getTexture());
|
out.set(d.buffer.getTexture());
|
||||||
}else if(texture instanceof CanvasBuild c){
|
}else if(texture instanceof CanvasBuild c && c.isAdded()){
|
||||||
if(c.texture == null) c.updateTexture();
|
c.updateTexture();
|
||||||
out.set(c.texture);
|
if(c.texture != null) out.set(c.texture);
|
||||||
}else{
|
}else{
|
||||||
out.set(Core.atlas.find("error"));
|
out.set(Core.atlas.find("error"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void prepareTexture(ObjectiveMarker marker, Object texture){
|
private static void prepareTexture(ObjectiveMarker marker, Object texture){
|
||||||
if(texture instanceof LogicDisplayBuild d){
|
if(texture instanceof LogicDisplayBuild d && d.isAdded()){
|
||||||
if(d.buffer == null || d.buffer.isDisposed()){
|
if(d.buffer == null || d.buffer.isDisposed()){
|
||||||
marker.setTexture("error");
|
marker.setTexture("error");
|
||||||
}else{
|
}else{
|
||||||
d.processCommands();
|
d.processCommands();
|
||||||
}
|
}
|
||||||
}else if(texture instanceof CanvasBuild c){
|
}else if(texture instanceof CanvasBuild c && c.isAdded()){
|
||||||
if(c.texture == null || c.texture.isDisposed()){
|
if(c.texture == null || c.texture.isDisposed()){
|
||||||
marker.setTexture("error");
|
marker.setTexture("error");
|
||||||
}else if(c.updated){
|
}else{
|
||||||
c.updated = false;
|
|
||||||
c.updateTexture();
|
c.updateTexture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class EmptyFloor extends Floor{
|
|||||||
canShadow = false;
|
canShadow = false;
|
||||||
placeableOn = false;
|
placeableOn = false;
|
||||||
solid = true;
|
solid = true;
|
||||||
|
drawEdgeOut = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ public class CanvasBlock extends Block{
|
|||||||
config(byte[].class, (CanvasBuild build, byte[] bytes) -> {
|
config(byte[].class, (CanvasBuild build, byte[] bytes) -> {
|
||||||
if(build.data.length == bytes.length){
|
if(build.data.length == bytes.length){
|
||||||
System.arraycopy(bytes, 0, build.data, 0, bytes.length);
|
System.arraycopy(bytes, 0, build.data, 0, bytes.length);
|
||||||
|
build.invalidated = true;
|
||||||
build.updateTexture();
|
build.updateTexture();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -149,19 +150,19 @@ public class CanvasBlock extends Block{
|
|||||||
public @Nullable Texture texture;
|
public @Nullable Texture texture;
|
||||||
public byte[] data = new byte[Mathf.ceil(canvasSize * canvasSize * bitsPerPixel / 8f)];
|
public byte[] data = new byte[Mathf.ceil(canvasSize * canvasSize * bitsPerPixel / 8f)];
|
||||||
public int blending;
|
public int blending;
|
||||||
public boolean updated = false;
|
protected boolean invalidated = false;
|
||||||
|
|
||||||
public void setPixel(int pos, int index){
|
public void setPixel(int pos, int index){
|
||||||
if(pos < canvasSize * canvasSize && pos >= 0 && index >= 0 && index < palette.length){
|
if(pos < canvasSize * canvasSize && pos >= 0 && index >= 0 && index < palette.length){
|
||||||
setByte(data, pos * bitsPerPixel, index);
|
setByte(data, pos * bitsPerPixel, index);
|
||||||
updated = true;
|
invalidated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPixel(int x, int y, int index){
|
public void setPixel(int x, int y, int index){
|
||||||
if(x >= 0 && y >= 0 && x < canvasSize && y < canvasSize && index >= 0 && index < palette.length){
|
if(x >= 0 && y >= 0 && x < canvasSize && y < canvasSize && index >= 0 && index < palette.length){
|
||||||
setByte(data, (y * canvasSize + x) * bitsPerPixel, index);
|
setByte(data, (y * canvasSize + x) * bitsPerPixel, index);
|
||||||
updated = true;
|
invalidated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +181,7 @@ public class CanvasBlock extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateTexture(){
|
public void updateTexture(){
|
||||||
if(headless) return;
|
if(headless || (texture != null && !invalidated)) return;
|
||||||
|
|
||||||
Pixmap pix = makePixmap(data, previewPixmap);
|
Pixmap pix = makePixmap(data, previewPixmap);
|
||||||
if(texture != null){
|
if(texture != null){
|
||||||
@@ -188,6 +189,8 @@ public class CanvasBlock extends Block{
|
|||||||
}else{
|
}else{
|
||||||
texture = new Texture(pix);
|
texture = new Texture(pix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
invalidated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] packPixmap(Pixmap pixmap){
|
public byte[] packPixmap(Pixmap pixmap){
|
||||||
@@ -260,10 +263,10 @@ public class CanvasBlock extends Block{
|
|||||||
super.draw();
|
super.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(texture == null || updated){
|
if(texture == null || invalidated){
|
||||||
updated = false;
|
|
||||||
updateTexture();
|
updateTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
Tmp.tr1.set(texture);
|
Tmp.tr1.set(texture);
|
||||||
float pad = blending == 0 ? padding : 0f;
|
float pad = blending == 0 ? padding : 0f;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user