| 8 | import java.util.* |
| 9 | import java.util.function.Supplier |
| 10 | |
| 11 | class StandardText(val shader: Shader) { |
| 12 | val triangles: BaseMesh |
| 13 | val triangles_builder: MeshBuilder |
| 14 | |
| 15 | val lines: IdempotencyMap<Supplier<FLine>> = IdempotencyMap(Supplier::class.java) |
| 16 | val bulkLines: IdempotencyMap<Supplier<Collection<Supplier<FLine>>>> = IdempotencyMap(Collection::class.java) |
| 17 | |
| 18 | private var font: DrawBitmapFont |
| 19 | |
| 20 | @JvmField |
| 21 | var guard: Supplier<Boolean> = Supplier<Boolean> { true } |
| 22 | |
| 23 | init { |
| 24 | triangles = BaseMesh.triangleList(0, 0) |
| 25 | triangles_builder = MeshBuilder(triangles) |
| 26 | |
| 27 | font = DrawBitmapFont(Thread.currentThread().contextClassLoader.getResource("fonts/" + "source-sans-pro-regular-92.fnt")!! |
| 28 | .file, this.triangles_builder, 0, 5000) |
| 29 | |
| 30 | triangles.attach(font.getTexture()) |
| 31 | |
| 32 | with(shader) { |
| 33 | |
| 34 | attach(-3, { x -> |
| 35 | if (guard.get()) |
| 36 | render(x) |
| 37 | }) |
| 38 | |
| 39 | attach(triangles) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | private fun render(p: Int) { |
| 44 | |
| 45 | val q = lines |
| 46 | val q2 = bulkLines |
| 47 | |
| 48 | triangles_builder.open() |
| 49 | |
| 50 | try { |
| 51 | q.values |
| 52 | .stream() |
| 53 | .map({ x -> x.get() }) |
| 54 | .filter({ x -> x != null }) |
| 55 | .forEach { x -> dispatchText(x, triangles_builder) } |
| 56 | q2.values |
| 57 | .stream() |
| 58 | .map({ x -> x.get() }) |
| 59 | .filter({ x -> x != null }) |
| 60 | .flatMap({ x -> x.stream() }) |
| 61 | .filter({ x -> x != null }) |
| 62 | .map({ x -> x.get() }) |
| 63 | .filter({ x -> x != null }) |
| 64 | .forEach { x -> dispatchText(x, triangles_builder) } |
| 65 | } finally { |
| 66 | triangles_builder.close() |
| 67 | } |
nothing calls this directly
no test coverage detected