From 59c3b18a6f53edffbb3422c646ac6e0d3bf3dbf1 Mon Sep 17 00:00:00 2001 From: Redstonneur1256 <29004178+Redstonneur1256@users.noreply.github.com> Date: Sun, 28 Dec 2025 03:37:03 +0100 Subject: [PATCH] Allow markers to use content/displays as textures (#11142) * Allow markers to use content/displays as textures * Don't process empty commands * Allow canvases to be used as marker textures * Proper Json serialization --------- Co-authored-by: Anuken --- .../mindustry/editor/MapObjectivesDialog.java | 5 + core/src/mindustry/game/MapObjectives.java | 124 ++++++++++++++---- core/src/mindustry/logic/LExecutor.java | 6 +- .../world/blocks/logic/CanvasBlock.java | 3 +- .../world/blocks/logic/LogicDisplay.java | 21 +-- 5 files changed, 118 insertions(+), 41 deletions(-) diff --git a/core/src/mindustry/editor/MapObjectivesDialog.java b/core/src/mindustry/editor/MapObjectivesDialog.java index 36c513478f..408a09a25d 100644 --- a/core/src/mindustry/editor/MapObjectivesDialog.java +++ b/core/src/mindustry/editor/MapObjectivesDialog.java @@ -290,6 +290,11 @@ public class MapObjectivesDialog extends BaseDialog{ }, () -> {}); }); + setInterpreter(TextureHolder.class, (cont, name, type, field, remover, indexer, get, set) -> { + name(cont, name, remover, indexer); + cont.field(String.valueOf(get.get().value), s -> get.get().value = s).growX(); + }); + // Types that use the default interpreter. It would be nice if all types could use it, but I don't know how to reliably prevent classes like [? extends Content] from using it. for(var obj : MapObjectives.allObjectiveTypes) setInterpreter(obj.get().getClass(), defaultInterpreter()); for(var mark : MapObjectives.allMarkerTypes) setInterpreter(mark.get().getClass(), defaultInterpreter()); diff --git a/core/src/mindustry/game/MapObjectives.java b/core/src/mindustry/game/MapObjectives.java index 1cf552149c..7cbd9612de 100644 --- a/core/src/mindustry/game/MapObjectives.java +++ b/core/src/mindustry/game/MapObjectives.java @@ -10,6 +10,9 @@ 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.*; import mindustry.content.*; import mindustry.core.*; @@ -21,8 +24,12 @@ import mindustry.io.*; import mindustry.logic.*; import mindustry.type.*; 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.*; @@ -665,7 +672,7 @@ public class MapObjectives implements Iterable, Eachable, Eachable, Eachable, Eachable, Eachable, Eachable, Eachable, Eachable, Eachable, Eachable= 0 && i < 4){ - if(fetchedRegion == null) setTexture(textureName); + if(fetchedRegion == null) setTexture(texture); if(!Double.isNaN(u)){ boolean clampU = fetchedRegion.texture.getUWrap() != TextureWrap.mirroredRepeat && fetchedRegion.texture.getUWrap() != TextureWrap.repeat; @@ -1304,16 +1321,71 @@ public class MapObjectives implements Iterable, Eachable= 0 && index >= 0 && index < palette.length){ diff --git a/core/src/mindustry/world/blocks/logic/LogicDisplay.java b/core/src/mindustry/world/blocks/logic/LogicDisplay.java index 393378f440..c238da05d3 100644 --- a/core/src/mindustry/world/blocks/logic/LogicDisplay.java +++ b/core/src/mindustry/world/blocks/logic/LogicDisplay.java @@ -89,15 +89,7 @@ public class LogicDisplay extends Block{ //don't even bother processing anything when displays are off. if(!Vars.renderer.drawDisplays) return; - Draw.draw(Draw.z(), () -> { - if(buffer == null){ - buffer = new FrameBuffer(displaySize, displaySize); - //clear the buffer - some OSs leave garbage in it - buffer.begin(Pal.darkerMetal); - buffer.end(); - } - }); - + Draw.draw(Draw.z(), this::ensureBuffer); processCommands(); Draw.blend(Blending.disabled); @@ -129,11 +121,20 @@ public class LogicDisplay extends Block{ operations++; } + public void ensureBuffer() { + if(buffer == null){ + buffer = new FrameBuffer(displaySize, displaySize); + //clear the buffer - some OSs leave garbage in it + buffer.begin(Pal.darkerMetal); + buffer.end(); + } + } + public void processCommands(){ //don't bother processing commands if displays are off if(!commands.isEmpty() && buffer != null){ Draw.draw(Draw.z(), () -> { - if(buffer == null) return; + if(buffer == null || commands.isEmpty()) return; Tmp.m1.set(Draw.proj()); Tmp.m2.set(Draw.trans());