Fixed #3133 (probably) / Logic icon draw command
|
Before Width: | Height: | Size: 826 B After Width: | Height: | Size: 792 B |
|
Before Width: | Height: | Size: 917 KiB After Width: | Height: | Size: 917 KiB |
|
Before Width: | Height: | Size: 556 KiB After Width: | Height: | Size: 614 KiB |
|
Before Width: | Height: | Size: 185 KiB After Width: | Height: | Size: 189 KiB |
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 2.9 MiB After Width: | Height: | Size: 2.9 MiB |
|
Before Width: | Height: | Size: 186 KiB After Width: | Height: | Size: 190 KiB |
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB |
@@ -1137,7 +1137,7 @@ public class UnitTypes implements ContentList{
|
|||||||
ammoType = AmmoTypes.powerLow;
|
ammoType = AmmoTypes.powerLow;
|
||||||
|
|
||||||
mineTier = 1;
|
mineTier = 1;
|
||||||
mineSpeed = 2.6f;
|
mineSpeed = 3f;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
poly = new UnitType("poly"){{
|
poly = new UnitType("poly"){{
|
||||||
@@ -1649,7 +1649,7 @@ public class UnitTypes implements ContentList{
|
|||||||
isCounted = false;
|
isCounted = false;
|
||||||
|
|
||||||
flying = true;
|
flying = true;
|
||||||
mineSpeed = 6f;
|
mineSpeed = 6.5f;
|
||||||
mineTier = 1;
|
mineTier = 1;
|
||||||
buildSpeed = 0.5f;
|
buildSpeed = 0.5f;
|
||||||
drag = 0.05f;
|
drag = 0.05f;
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ public abstract class UnlockableContent extends MappableContent{
|
|||||||
public @Nullable String description;
|
public @Nullable String description;
|
||||||
/** Whether this content is always unlocked in the tech tree. */
|
/** Whether this content is always unlocked in the tech tree. */
|
||||||
public boolean alwaysUnlocked = false;
|
public boolean alwaysUnlocked = false;
|
||||||
|
/** Special logic icon ID. */
|
||||||
|
public int iconId = 0;
|
||||||
/** Icons by Cicon ID.*/
|
/** Icons by Cicon ID.*/
|
||||||
protected TextureRegion[] cicons = new TextureRegion[Cicon.all.length];
|
protected TextureRegion[] cicons = new TextureRegion[Cicon.all.length];
|
||||||
/** Unlock state. Loaded from settings. Do not modify outside of the constructor. */
|
/** 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{
|
}else{
|
||||||
Vec2 intercept = Predict.intercept(unit, target, bulletSpeed);
|
Vec2 intercept = Predict.intercept(unit, target, bulletSpeed);
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import mindustry.game.Teams.*;
|
|||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
import mindustry.world.blocks.logic.*;
|
||||||
import mindustry.world.blocks.logic.LogicDisplay.*;
|
import mindustry.world.blocks.logic.LogicDisplay.*;
|
||||||
import mindustry.world.blocks.logic.MemoryBlock.*;
|
import mindustry.world.blocks.logic.MemoryBlock.*;
|
||||||
import mindustry.world.blocks.logic.MessageBlock.*;
|
import mindustry.world.blocks.logic.MessageBlock.*;
|
||||||
@@ -823,9 +824,15 @@ public class LExecutor{
|
|||||||
//graphics on headless servers are useless.
|
//graphics on headless servers are useless.
|
||||||
if(Vars.headless) return;
|
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
|
//add graphics calls, cap graphics buffer size
|
||||||
if(exec.graphicsBuffer.size < maxGraphicsBuffer){
|
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){
|
if(type == GraphicsType.color){
|
||||||
p2 = "255";
|
p2 = "255";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(type == GraphicsType.image){
|
||||||
|
p1 = "@copper";
|
||||||
|
p2 = "32";
|
||||||
|
p3 = "0";
|
||||||
|
}
|
||||||
rebuild(table);
|
rebuild(table);
|
||||||
}, 2, cell -> cell.size(100, 50)));
|
}, 2, cell -> cell.size(100, 50)));
|
||||||
}, Styles.logict, () -> {}).size(90, 40).color(table.color).left().padLeft(2);
|
}, 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, "x3", p3, v -> p3 = v);
|
||||||
fields(s, "y3", p4, v -> p4 = 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();
|
}).expand().left();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ import arc.scene.style.*;
|
|||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
|
import mindustry.*;
|
||||||
import mindustry.core.*;
|
import mindustry.core.*;
|
||||||
|
import mindustry.ctype.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -30,6 +32,8 @@ public class Fonts{
|
|||||||
private static final String mainFont = "fonts/font.woff";
|
private static final String mainFont = "fonts/font.woff";
|
||||||
private static ObjectIntMap<String> unicodeIcons = new ObjectIntMap<>();
|
private static ObjectIntMap<String> unicodeIcons = new ObjectIntMap<>();
|
||||||
private static ObjectMap<String, String> stringIcons = new ObjectMap<>();
|
private static ObjectMap<String, String> stringIcons = new ObjectMap<>();
|
||||||
|
private static TextureRegion[] iconTable;
|
||||||
|
private static int lastCid;
|
||||||
|
|
||||||
public static Font def;
|
public static Font def;
|
||||||
public static Font outline;
|
public static Font outline;
|
||||||
@@ -37,6 +41,10 @@ public class Fonts{
|
|||||||
public static Font icon;
|
public static Font icon;
|
||||||
public static Font tech;
|
public static Font tech;
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
@@ -111,6 +119,19 @@ public class Fonts{
|
|||||||
fonts.each(f -> f.getData().setGlyph(ch, glyph));
|
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.*/
|
/** Called from a static context for use in the loading screen.*/
|
||||||
|
|||||||
@@ -640,6 +640,8 @@ public class HudFragment extends Fragment{
|
|||||||
public void draw(){
|
public void draw(){
|
||||||
float next = amount.get();
|
float next = amount.get();
|
||||||
|
|
||||||
|
if(Float.isNaN(next) || Float.isInfinite(next)) next = 1f;
|
||||||
|
|
||||||
if(next < last && flash.get()){
|
if(next < last && flash.get()){
|
||||||
blink = 1f;
|
blink = 1f;
|
||||||
}
|
}
|
||||||
@@ -648,6 +650,8 @@ public class HudFragment extends Fragment{
|
|||||||
value = Mathf.lerpDelta(value, next, 0.15f);
|
value = Mathf.lerpDelta(value, next, 0.15f);
|
||||||
last = next;
|
last = next;
|
||||||
|
|
||||||
|
if(Float.isNaN(value) || Float.isInfinite(value)) value = 1f;
|
||||||
|
|
||||||
drawInner(Pal.darkishGray);
|
drawInner(Pal.darkishGray);
|
||||||
|
|
||||||
Draw.beginStencil();
|
Draw.beginStencil();
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import arc.util.*;
|
|||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
|
import mindustry.ui.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
@@ -22,7 +23,8 @@ public class LogicDisplay extends Block{
|
|||||||
commandLineRect = 5,
|
commandLineRect = 5,
|
||||||
commandPoly = 6,
|
commandPoly = 6,
|
||||||
commandLinePoly = 7,
|
commandLinePoly = 7,
|
||||||
commandTriangle = 8;
|
commandTriangle = 8,
|
||||||
|
commandImage = 9;
|
||||||
|
|
||||||
public int maxSides = 25;
|
public int maxSides = 25;
|
||||||
|
|
||||||
@@ -84,6 +86,7 @@ public class LogicDisplay extends Block{
|
|||||||
case commandTriangle -> Fill.tri(x, y, p1, p2, p3, p4);
|
case commandTriangle -> Fill.tri(x, y, p1, p2, p3, p4);
|
||||||
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 -> Draw.rect(Fonts.logicIcon(p1), x, y, p2, p2, p3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +113,8 @@ public class LogicDisplay extends Block{
|
|||||||
lineRect,
|
lineRect,
|
||||||
poly,
|
poly,
|
||||||
linePoly,
|
linePoly,
|
||||||
triangle;
|
triangle,
|
||||||
|
image;
|
||||||
|
|
||||||
public static final GraphicsType[] all = values();
|
public static final GraphicsType[] all = values();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public class Generators{
|
|||||||
0x454545ff, 0x00000000,//0x32394bff,
|
0x454545ff, 0x00000000,//0x32394bff,
|
||||||
0x00000099, 0x00000000//0x000000ff
|
0x00000099, 0x00000000//0x000000ff
|
||||||
);
|
);
|
||||||
|
static final Cicon logicIcon = Cicon.medium;
|
||||||
|
|
||||||
public static void generate(){
|
public static void generate(){
|
||||||
ObjectMap<Block, Image> gens = new ObjectMap<>();
|
ObjectMap<Block, Image> gens = new ObjectMap<>();
|
||||||
@@ -302,6 +303,10 @@ public class Generators{
|
|||||||
Image scaled = new Image(icon.size, icon.size);
|
Image scaled = new Image(icon.size, icon.size);
|
||||||
scaled.drawScaled(image);
|
scaled.drawScaled(image);
|
||||||
scaled.save("../ui/block-" + block.name + "-" + icon.name());
|
scaled.save("../ui/block-" + block.name + "-" + icon.name());
|
||||||
|
|
||||||
|
if(icon == logicIcon && block.synthetic() && !block.isHidden()){
|
||||||
|
image.save(block.name + "-icon-logic");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasEmpty = false;
|
boolean hasEmpty = false;
|
||||||
@@ -373,6 +378,10 @@ public class Generators{
|
|||||||
if(icon == Cicon.medium){
|
if(icon == Cicon.medium){
|
||||||
image.save("../ui/" + item.getContentType() + "-" + item.name + "-icon");
|
image.save("../ui/" + item.getContentType() + "-" + item.name + "-icon");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(icon == logicIcon){
|
||||||
|
image.save(item.name + "-icon-logic");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -489,6 +498,10 @@ public class Generators{
|
|||||||
|
|
||||||
scaled.drawScaled(image);
|
scaled.drawScaled(image);
|
||||||
scaled.save("../ui/unit-" + type.name + "-" + icon.name());
|
scaled.save("../ui/unit-" + type.name + "-" + icon.name());
|
||||||
|
|
||||||
|
if(icon == logicIcon){
|
||||||
|
scaled.save(type.name + "-icon-logic");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch(IllegalArgumentException e){
|
}catch(IllegalArgumentException e){
|
||||||
|
|||||||