Text align (#10804)

* Text/ShapeText marker text alignment

* Allow `draw print` to use a dynamic align

* Highlight currently selected value when possible

* Fix alignment with newlines

* Add `lineAlign`

---------

Co-authored-by: Anuken <arnukren@gmail.com>
This commit is contained in:
Redstonneur1256
2025-07-02 20:04:43 +02:00
committed by GitHub
parent b3050c299d
commit 835c8b4a6c
8 changed files with 130 additions and 31 deletions

View File

@@ -17,6 +17,7 @@ import mindustry.game.MapObjectives.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.io.*;
import mindustry.logic.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.ui.dialogs.*;
@@ -280,6 +281,15 @@ public class MapObjectivesDialog extends BaseDialog{
});
}));
setInterpreter(Alignment.class, int.class, (cont, name, type, field, remover, indexer, get, set) -> {
Alignment align = field.getAnnotation(Alignment.class);
name(cont, name, remover, indexer);
cont.button(b -> {
b.label(() -> LStatement.alignToName.get(get.get(), "center"));
b.clicked(() -> LStatement.showAlignSelect(b, get.get(), set::get, align.hor(), align.ver()));
}, () -> {});
});
// Types that use the default interpreter. It would be nice if all types could use it, but I don't know how to reliably prevent classes like [? extends Content] from using it.
for(var obj : MapObjectives.allObjectiveTypes) setInterpreter(obj.get().getClass(), defaultInterpreter());
for(var mark : MapObjectives.allMarkerTypes) setInterpreter(mark.get().getClass(), defaultInterpreter());