Fixed #3133 (probably) / Logic icon draw command
This commit is contained in:
@@ -1137,7 +1137,7 @@ public class UnitTypes implements ContentList{
|
||||
ammoType = AmmoTypes.powerLow;
|
||||
|
||||
mineTier = 1;
|
||||
mineSpeed = 2.6f;
|
||||
mineSpeed = 3f;
|
||||
}};
|
||||
|
||||
poly = new UnitType("poly"){{
|
||||
@@ -1649,7 +1649,7 @@ public class UnitTypes implements ContentList{
|
||||
isCounted = false;
|
||||
|
||||
flying = true;
|
||||
mineSpeed = 6f;
|
||||
mineSpeed = 6.5f;
|
||||
mineTier = 1;
|
||||
buildSpeed = 0.5f;
|
||||
drag = 0.05f;
|
||||
|
||||
@@ -24,6 +24,8 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
public @Nullable String description;
|
||||
/** Whether this content is always unlocked in the tech tree. */
|
||||
public boolean alwaysUnlocked = false;
|
||||
/** Special logic icon ID. */
|
||||
public int iconId = 0;
|
||||
/** Icons by Cicon ID.*/
|
||||
protected TextureRegion[] cicons = new TextureRegion[Cicon.all.length];
|
||||
/** Unlock state. Loaded from settings. Do not modify outside of the constructor. */
|
||||
|
||||
@@ -948,7 +948,9 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
}
|
||||
}
|
||||
|
||||
unit.aim(Tmp.v1.trns(unit.rotation, 1000f).add(unit));
|
||||
//when not shooting, aim at mouse cursor
|
||||
//this may be a bad idea, aiming for a point far in front could work better, test it out
|
||||
unit.aim(Core.input.mouseWorldX(), Core.input.mouseWorldY());
|
||||
}else{
|
||||
Vec2 intercept = Predict.intercept(unit, target, bulletSpeed);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import mindustry.game.Teams.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.logic.*;
|
||||
import mindustry.world.blocks.logic.LogicDisplay.*;
|
||||
import mindustry.world.blocks.logic.MemoryBlock.*;
|
||||
import mindustry.world.blocks.logic.MessageBlock.*;
|
||||
@@ -823,9 +824,15 @@ public class LExecutor{
|
||||
//graphics on headless servers are useless.
|
||||
if(Vars.headless) return;
|
||||
|
||||
int num1 = exec.numi(p1);
|
||||
|
||||
if(type == LogicDisplay.commandImage){
|
||||
num1 = exec.obj(p1) instanceof UnlockableContent u ? u.iconId : 0;
|
||||
}
|
||||
|
||||
//add graphics calls, cap graphics buffer size
|
||||
if(exec.graphicsBuffer.size < maxGraphicsBuffer){
|
||||
exec.graphicsBuffer.add(DisplayCmd.get(type, exec.numi(x), exec.numi(y), exec.numi(p1), exec.numi(p2), exec.numi(p3), exec.numi(p4)));
|
||||
exec.graphicsBuffer.add(DisplayCmd.get(type, exec.numi(x), exec.numi(y), num1, exec.numi(p2), exec.numi(p3), exec.numi(p4)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +143,12 @@ public class LStatements{
|
||||
if(type == GraphicsType.color){
|
||||
p2 = "255";
|
||||
}
|
||||
|
||||
if(type == GraphicsType.image){
|
||||
p1 = "@copper";
|
||||
p2 = "32";
|
||||
p3 = "0";
|
||||
}
|
||||
rebuild(table);
|
||||
}, 2, cell -> cell.size(100, 50)));
|
||||
}, Styles.logict, () -> {}).size(90, 40).color(table.color).left().padLeft(2);
|
||||
@@ -205,6 +211,15 @@ public class LStatements{
|
||||
fields(s, "x3", p3, v -> p3 = v);
|
||||
fields(s, "y3", p4, v -> p4 = v);
|
||||
}
|
||||
case image -> {
|
||||
fields(s, "x", x, v -> x = v);
|
||||
fields(s, "y", y, v -> y = v);
|
||||
row(s);
|
||||
fields(s, "image", p1, v -> p1 = v);
|
||||
fields(s, "size", p2, v -> p2 = v);
|
||||
row(s);
|
||||
fields(s, "rotation", p3, v -> p3 = v);
|
||||
}
|
||||
}
|
||||
}).expand().left();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@ import arc.scene.style.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.ctype.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -30,6 +32,8 @@ public class Fonts{
|
||||
private static final String mainFont = "fonts/font.woff";
|
||||
private static ObjectIntMap<String> unicodeIcons = new ObjectIntMap<>();
|
||||
private static ObjectMap<String, String> stringIcons = new ObjectMap<>();
|
||||
private static TextureRegion[] iconTable;
|
||||
private static int lastCid;
|
||||
|
||||
public static Font def;
|
||||
public static Font outline;
|
||||
@@ -37,6 +41,10 @@ public class Fonts{
|
||||
public static Font icon;
|
||||
public static Font tech;
|
||||
|
||||
public static TextureRegion logicIcon(int id){
|
||||
return iconTable[id];
|
||||
}
|
||||
|
||||
public static int getUnicode(String content){
|
||||
return unicodeIcons.get(content, 0);
|
||||
}
|
||||
@@ -111,6 +119,19 @@ public class Fonts{
|
||||
fonts.each(f -> f.getData().setGlyph(ch, glyph));
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Called from a static context for use in the loading screen.*/
|
||||
|
||||
@@ -640,6 +640,8 @@ public class HudFragment extends Fragment{
|
||||
public void draw(){
|
||||
float next = amount.get();
|
||||
|
||||
if(Float.isNaN(next) || Float.isInfinite(next)) next = 1f;
|
||||
|
||||
if(next < last && flash.get()){
|
||||
blink = 1f;
|
||||
}
|
||||
@@ -648,6 +650,8 @@ public class HudFragment extends Fragment{
|
||||
value = Mathf.lerpDelta(value, next, 0.15f);
|
||||
last = next;
|
||||
|
||||
if(Float.isNaN(value) || Float.isInfinite(value)) value = 1f;
|
||||
|
||||
drawInner(Pal.darkishGray);
|
||||
|
||||
Draw.beginStencil();
|
||||
|
||||
@@ -9,6 +9,7 @@ import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
@@ -22,7 +23,8 @@ public class LogicDisplay extends Block{
|
||||
commandLineRect = 5,
|
||||
commandPoly = 6,
|
||||
commandLinePoly = 7,
|
||||
commandTriangle = 8;
|
||||
commandTriangle = 8,
|
||||
commandImage = 9;
|
||||
|
||||
public int maxSides = 25;
|
||||
|
||||
@@ -84,6 +86,7 @@ public class LogicDisplay extends Block{
|
||||
case commandTriangle -> Fill.tri(x, y, p1, p2, p3, p4);
|
||||
case commandColor -> Draw.color(this.color = Color.toFloatBits(x, y, p1, p2));
|
||||
case commandStroke -> Lines.stroke(this.stroke = x);
|
||||
case commandImage -> Draw.rect(Fonts.logicIcon(p1), x, y, p2, p2, p3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +113,8 @@ public class LogicDisplay extends Block{
|
||||
lineRect,
|
||||
poly,
|
||||
linePoly,
|
||||
triangle;
|
||||
triangle,
|
||||
image;
|
||||
|
||||
public static final GraphicsType[] all = values();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user