* Added PrintChar operation

* Added 1ue999 to contributors

* Added PrintChar description, and improved the design of it.

* Ok intellij, removing the int cast

* Added capability to print content icons (@flare or @router)
https://github.com/Anuken/Mindustry/pull/10451#discussion_r1941282280

* Formatting changes (hopefully all of them)

* Update core/src/mindustry/logic/LStatements.java

* Update core/src/mindustry/logic/LStatements.java

---------

Co-authored-by: Anuken <arnukren@gmail.com>
This commit is contained in:
1ue999
2025-02-05 01:39:33 +01:00
committed by GitHub
parent fbd2944663
commit c4e25e312f
4 changed files with 65 additions and 0 deletions

View File

@@ -988,6 +988,29 @@ public class LExecutor{
}
}
public static class PrintCharI implements LInstruction{
public LVar value;
public PrintCharI(LVar value){
this.value = value;
}
PrintCharI(){}
@Override
public void run(LExecutor exec){
if(exec.textBuffer.length() >= maxTextBuffer) return;
if(value.isobj){
if(!(value.objval instanceof UnlockableContent cont)) return;
exec.textBuffer.append((char)cont.emojiChar());
return;
}
exec.textBuffer.append((char)Math.floor(value.numval));
}
}
public static class FormatI implements LInstruction{
public LVar value;

View File

@@ -312,6 +312,46 @@ public class LStatements{
}
}
@RegisterStatement("printchar")
public static class PrintCharStatement extends LStatement{
public String value = "65";
@Override
public void build(Table table){
table.add(" char ");
TextField field = field(table, value, str -> value = str).get();
table.button(b -> {
b.image(Icon.pencilSmall);
b.clicked(() -> showSelectTable(b, (t, hide) -> {
t.row();
t.table(i -> {
i.left();
int c = 0;
for(char j = 32; j < 127; j++){
final int chr = j;
i.button(String.valueOf(j), Styles.flatt, () -> {
value = Integer.toString(chr);
field.setText(value);
hide.run();
}).size(32f);
if(++c % 8 == 0) i.row();
}
});
}));
}, Styles.logict, () -> {}).size(40f).padLeft(-2).color(table.color);
}
@Override
public LInstruction build(LAssembler builder){
return new PrintCharI(builder.var(value));
}
@Override
public LCategory category(){
return LCategory.io;
}
}
@RegisterStatement("format")
public static class FormatStatement extends LStatement{
public String value = "\"frog\"";