Logic icon support for all blocks

This commit is contained in:
Anuken
2024-06-16 01:11:54 -04:00
parent 5c23abf2d8
commit 7f9eb87313
5 changed files with 18 additions and 34 deletions
+11 -3
View File
@@ -889,17 +889,25 @@ public class LExecutor{
exec.textBuffer.setLength(0);
}
}else{
int num1 = p1.numi(), xval = packSign(x.numi()), yval = packSign(y.numi());
int num1 = p1.numi(), num4 = p4.numi(), xval = packSign(x.numi()), yval = packSign(y.numi());
if(type == LogicDisplay.commandImage){
num1 = p1.obj() instanceof UnlockableContent u ? u.iconId : 0;
if(p1.obj() instanceof UnlockableContent u){
//TODO: with mods, this will overflow (ID >= 512), but that's better than the previous system, at least
num1 = u.id;
num4 = u.getContentType().ordinal();
}else{
num1 = -1;
num4 = -1;
}
//num1 = p1.obj() instanceof UnlockableContent u ? u.iconId : 0;
}else if(type == LogicDisplay.commandScale){
xval = packSign((int)(x.numf() / LogicDisplay.scaleStep));
yval = packSign((int)(y.numf() / LogicDisplay.scaleStep));
}
//add graphics calls, cap graphics buffer size
exec.graphicsBuffer.add(DisplayCmd.get(type, xval, yval, packSign(num1), packSign(p2.numi()), packSign(p3.numi()), packSign(p4.numi())));
exec.graphicsBuffer.add(DisplayCmd.get(type, xval, yval, packSign(num1), packSign(p2.numi()), packSign(p3.numi()), packSign(num4)));
}
}
-20
View File
@@ -20,7 +20,6 @@ import arc.struct.*;
import arc.util.*;
import mindustry.*;
import mindustry.core.*;
import mindustry.ctype.*;
import mindustry.game.*;
import mindustry.gen.*;
@@ -33,15 +32,9 @@ public class Fonts{
private static IntMap<String> unicodeToName = new IntMap<>();
private static ObjectMap<String, String> stringIcons = new ObjectMap<>();
private static ObjectMap<String, TextureRegion> largeIcons = new ObjectMap<>();
private static TextureRegion[] iconTable;
private static int lastCid;
public static Font def, outline, icon, iconLarge, tech, logic;
public static TextureRegion logicIcon(int id){
return iconTable[id];
}
public static int getUnicode(String content){
return unicodeIcons.get(content, 0);
}
@@ -160,19 +153,6 @@ public class Fonts{
stringIcons.put("alphachan", stringIcons.get("alphaaaa"));
iconTable = new TextureRegion[512];
iconTable[0] = Core.atlas.find("error");
lastCid = 1;
Vars.content.each(c -> {
if(c instanceof UnlockableContent u){
TextureRegion region = Core.atlas.find(u.name + "-icon-logic");
if(region.found()){
iconTable[u.iconId = lastCid++] = region;
}
}
});
for(Team team : Team.baseTeams){
team.emoji = stringIcons.get(team.name, "");
}
@@ -10,6 +10,7 @@ import arc.util.*;
import arc.util.io.*;
import mindustry.*;
import mindustry.annotations.Annotations.*;
import mindustry.ctype.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.ui.*;
@@ -120,8 +121,10 @@ public class LogicDisplay extends Block{
case commandColor -> Draw.color(this.color = Color.toFloatBits(x, y, p1, p2));
case commandStroke -> Lines.stroke(this.stroke = x);
case commandImage -> {
var icon = Fonts.logicIcon(p1);
Draw.rect(Fonts.logicIcon(p1), x, y, p2, p2 / icon.ratio(), p3);
if(p4 >= 0 && p4 < ContentType.all.length && Vars.content.getByID(ContentType.all[p4], p1) instanceof UnlockableContent u){
var icon = u.fullIcon;
Draw.rect(icon, x, y, p2, p2 / icon.ratio(), p3);
}
}
case commandPrint -> {
var glyph = Fonts.logic.getData().getGlyph((char)p1);
+1 -1
View File
@@ -25,4 +25,4 @@ org.gradle.caching=true
#used for slow jitpack builds; TODO see if this actually works
org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000
archash=98900b203b
archash=7a6694c636
+1 -8
View File
@@ -19,7 +19,6 @@ import mindustry.world.*;
import mindustry.world.blocks.*;
import mindustry.world.blocks.environment.*;
import mindustry.world.blocks.legacy.*;
import mindustry.world.meta.*;
import java.util.concurrent.*;
@@ -27,7 +26,7 @@ import static mindustry.Vars.*;
import static mindustry.tools.ImagePacker.*;
public class Generators{
static final int logicIconSize = 64, maxUiIcon = 128;
static final int maxUiIcon = 128;
private static float fluid(boolean gas, double x, double y, float frame){
int keyframes = gas ? 4 : 3;
@@ -384,10 +383,6 @@ public class Generators{
}
save(image, "../editor/" + block.name + "-icon-editor");
if(block.buildVisibility != BuildVisibility.hidden){
saveScaled(image, block.name + "-icon-logic", Math.min(32 * 3, image.width));
}
saveScaled(image, "../ui/block-" + block.name + "-ui", Math.min(image.width, maxUiIcon));
boolean hasEmpty = false;
@@ -464,7 +459,6 @@ public class Generators{
base = container.outline(Pal.gray, 3);
}
saveScaled(base, item.name + "-icon-logic", Math.min(logicIconSize, Math.min(base.width, base.height)));
save(base, "../ui/" + item.getContentType().name() + "-" + item.name + "-ui");
}
});
@@ -722,7 +716,6 @@ public class Generators{
Pixmap fit = new Pixmap(maxd, maxd);
drawScaledFit(fit, image);
saveScaled(fit, type.name + "-icon-logic", Math.min(logicIconSize, Math.min(fit.width, fit.height)));
save(fit, "../ui/unit-" + type.name + "-ui");
}catch(IllegalArgumentException e){
Log.err("WARNING: Skipping unit @: @", type.name, e.getMessage());