Logic icon support for all blocks
This commit is contained in:
@@ -889,17 +889,25 @@ public class LExecutor{
|
|||||||
exec.textBuffer.setLength(0);
|
exec.textBuffer.setLength(0);
|
||||||
}
|
}
|
||||||
}else{
|
}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){
|
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){
|
}else if(type == LogicDisplay.commandScale){
|
||||||
xval = packSign((int)(x.numf() / LogicDisplay.scaleStep));
|
xval = packSign((int)(x.numf() / LogicDisplay.scaleStep));
|
||||||
yval = packSign((int)(y.numf() / LogicDisplay.scaleStep));
|
yval = packSign((int)(y.numf() / LogicDisplay.scaleStep));
|
||||||
}
|
}
|
||||||
|
|
||||||
//add graphics calls, cap graphics buffer size
|
//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,7 +20,6 @@ import arc.struct.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.core.*;
|
import mindustry.core.*;
|
||||||
import mindustry.ctype.*;
|
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
|
|
||||||
@@ -33,15 +32,9 @@ public class Fonts{
|
|||||||
private static IntMap<String> unicodeToName = new IntMap<>();
|
private static IntMap<String> unicodeToName = new IntMap<>();
|
||||||
private static ObjectMap<String, String> stringIcons = new ObjectMap<>();
|
private static ObjectMap<String, String> stringIcons = new ObjectMap<>();
|
||||||
private static ObjectMap<String, TextureRegion> largeIcons = 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 Font def, outline, icon, iconLarge, tech, logic;
|
||||||
|
|
||||||
public static TextureRegion logicIcon(int id){
|
|
||||||
return iconTable[id];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getUnicode(String content){
|
public static int getUnicode(String content){
|
||||||
return unicodeIcons.get(content, 0);
|
return unicodeIcons.get(content, 0);
|
||||||
}
|
}
|
||||||
@@ -160,19 +153,6 @@ public class Fonts{
|
|||||||
|
|
||||||
stringIcons.put("alphachan", stringIcons.get("alphaaaa"));
|
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){
|
for(Team team : Team.baseTeams){
|
||||||
team.emoji = stringIcons.get(team.name, "");
|
team.emoji = stringIcons.get(team.name, "");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import arc.util.*;
|
|||||||
import arc.util.io.*;
|
import arc.util.io.*;
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
|
import mindustry.ctype.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.ui.*;
|
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 commandColor -> Draw.color(this.color = Color.toFloatBits(x, y, p1, p2));
|
||||||
case commandStroke -> Lines.stroke(this.stroke = x);
|
case commandStroke -> Lines.stroke(this.stroke = x);
|
||||||
case commandImage -> {
|
case commandImage -> {
|
||||||
var icon = Fonts.logicIcon(p1);
|
if(p4 >= 0 && p4 < ContentType.all.length && Vars.content.getByID(ContentType.all[p4], p1) instanceof UnlockableContent u){
|
||||||
Draw.rect(Fonts.logicIcon(p1), x, y, p2, p2 / icon.ratio(), p3);
|
var icon = u.fullIcon;
|
||||||
|
Draw.rect(icon, x, y, p2, p2 / icon.ratio(), p3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case commandPrint -> {
|
case commandPrint -> {
|
||||||
var glyph = Fonts.logic.getData().getGlyph((char)p1);
|
var glyph = Fonts.logic.getData().getGlyph((char)p1);
|
||||||
|
|||||||
@@ -25,4 +25,4 @@ org.gradle.caching=true
|
|||||||
#used for slow jitpack builds; TODO see if this actually works
|
#used for slow jitpack builds; TODO see if this actually works
|
||||||
org.gradle.internal.http.socketTimeout=100000
|
org.gradle.internal.http.socketTimeout=100000
|
||||||
org.gradle.internal.http.connectionTimeout=100000
|
org.gradle.internal.http.connectionTimeout=100000
|
||||||
archash=98900b203b
|
archash=7a6694c636
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import mindustry.world.*;
|
|||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.*;
|
||||||
import mindustry.world.blocks.environment.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
import mindustry.world.blocks.legacy.*;
|
import mindustry.world.blocks.legacy.*;
|
||||||
import mindustry.world.meta.*;
|
|
||||||
|
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
@@ -27,7 +26,7 @@ import static mindustry.Vars.*;
|
|||||||
import static mindustry.tools.ImagePacker.*;
|
import static mindustry.tools.ImagePacker.*;
|
||||||
|
|
||||||
public class Generators{
|
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){
|
private static float fluid(boolean gas, double x, double y, float frame){
|
||||||
int keyframes = gas ? 4 : 3;
|
int keyframes = gas ? 4 : 3;
|
||||||
@@ -384,10 +383,6 @@ public class Generators{
|
|||||||
}
|
}
|
||||||
|
|
||||||
save(image, "../editor/" + block.name + "-icon-editor");
|
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));
|
saveScaled(image, "../ui/block-" + block.name + "-ui", Math.min(image.width, maxUiIcon));
|
||||||
|
|
||||||
boolean hasEmpty = false;
|
boolean hasEmpty = false;
|
||||||
@@ -464,7 +459,6 @@ public class Generators{
|
|||||||
base = container.outline(Pal.gray, 3);
|
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");
|
save(base, "../ui/" + item.getContentType().name() + "-" + item.name + "-ui");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -722,7 +716,6 @@ public class Generators{
|
|||||||
Pixmap fit = new Pixmap(maxd, maxd);
|
Pixmap fit = new Pixmap(maxd, maxd);
|
||||||
drawScaledFit(fit, image);
|
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");
|
save(fit, "../ui/unit-" + type.name + "-ui");
|
||||||
}catch(IllegalArgumentException e){
|
}catch(IllegalArgumentException e){
|
||||||
Log.err("WARNING: Skipping unit @: @", type.name, e.getMessage());
|
Log.err("WARNING: Skipping unit @: @", type.name, e.getMessage());
|
||||||
|
|||||||
Reference in New Issue
Block a user