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