toolbar block icons centred in their 16px box (test for all icons), tutorials say where the objects tab is

This commit is contained in:
MineTec committed 2026-11-07 19:09:39 +01:00
1 parent 52c70e817d
commit 322e36c0f3
7 files changed
+60 -8

No files matched your search

+3
View File
@@ -4,6 +4,9 @@
- **Editor:** flying with the right mouse button + W A S D / Q E now works even when another part of
the window (a text field, a dock) still had the keyboard focus.
- **Editor:** the block, pillar and invisible-box icons sat too low in the toolbars (drawn outside
their box); a test now keeps every icon inside its 16 × 16 box.
- **Tutorials** say where the Objects panel is (the ⊙ tab next to *Outliner*).
## 0.2.2 – 2026-11-07
+3 -2
View File
@@ -40,8 +40,9 @@ Every change can be undone with **Ctrl+Z**.
## Step 4: A coin trail
1. Open the **Objects** panel (left) and click **Coin line** under the quick setups – or press
**O** for the **Coin line / arc** tool.
1. Open the **Objects** tab in the left dock – the ⊙ icon right next to *Outliner* (inactive tabs show only
their icon) and click **Coin line** under **Quick setups** – or press **O** for the
**Coin line / arc** tool.
2. Click once at the start of the trail and once at its end. Coins appear every *spacing* cells
on the ground (also up the ramp).
+2 -1
View File
@@ -32,7 +32,8 @@ Every drag is one undo step – **Ctrl+Z** takes it back.
## Step 3: Add a checkpoint
1. Open the **Objects** panel (left dock) and click the quick setup **Checkpoint**.
1. Open the **Objects** tab in the left dock – the ⊙ icon right next to *Outliner* (inactive tabs show only
their icon) and click the quick setup **Checkpoint**.
2. The Place tool (**P**) is now active. Click on the ground where the checkpoint should stand.
The editor places a checkpoint post together with its respawn point a little in front of it.
+2 -1
View File
@@ -69,7 +69,8 @@ plane shows as material 30. Look for:
The llama should not have to start over after every fall.
1. Open the **Objects** panel (left dock) and click **Checkpoint** in **Quick setups**.
1. Open the **Objects** tab in the left dock – the ⊙ icon right next to *Outliner* (inactive tabs show only
their icon) and click **Checkpoint** in **Quick setups**.
2. Click on a platform in the middle of the course.
You get a checkpoint post with its respawn point just in front of it. Falling after passing it
@@ -19,8 +19,8 @@ final class GeoIcons {
private static final Color RED = new Color(0xD93F3F);
static void register() {
Icons.register("prim-box", (g, fg) -> block(g, 2, 5, 12, 8, TOP, SIDE));
Icons.register("prim-platform", (g, fg) -> block(g, 1, 4, 14, 4, TOP, SIDE));
Icons.register("prim-box", (g, fg) -> block(g, 2, 1, 12, 8, TOP, SIDE));
Icons.register("prim-platform", (g, fg) -> block(g, 1, 2.5, 14, 4, TOP, SIDE));
Icons.register("prim-floor", (g, fg) -> {
Path2D p = poly(1, 10, 8, 6.5, 15, 10, 8, 13.5);
g.setColor(TOP);
@@ -47,7 +47,7 @@ final class GeoIcons {
g.setColor(fg);
g.draw(p);
});
Icons.register("prim-pillar", (g, fg) -> block(g, 5, 2, 6, 12, STONE, STONE.darker()));
Icons.register("prim-pillar", (g, fg) -> block(g, 5, 0.5, 6, 12, STONE, STONE.darker()));
Icons.register("prim-cylinder", (g, fg) -> {
g.setColor(STONE.darker());
g.fill(new java.awt.geom.Rectangle2D.Double(2, 6, 12, 5));
@@ -122,7 +122,7 @@ final class GeoIcons {
Icons.register("prim-invbox", (g, fg) -> {
g.setStroke(
new BasicStroke(1.2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1, new float[] {2, 1.5f}, 0));
outlineBlock(g, 2, 5, 12, 8, new Color(255, 60, 60, 60), RED);
outlineBlock(g, 2, 1, 12, 8, new Color(255, 60, 60, 60), RED);
});
Icons.register("geo-collision", (g, fg) -> {
Path2D p = poly(1, 10, 8, 6.5, 15, 10, 8, 13.5);
@@ -221,6 +221,7 @@ final class GeoIcons {
}
/** Isometric block: x, y of the top-left, width w, side height h. */
/** An isometric block filling y .. y + w / 2 + h; keep that within the 16 × 16 icon box. */
private static void block(Graphics2D g, double x, double y, double w, double h, Color top, Color side) {
Color fg = g.getColor();
double d = w / 4;
@@ -40,6 +40,11 @@ public final class Icons {
private Icons() {}
/** Names of all registered icons (sorted). */
public static java.util.List<String> names() {
return PAINTERS.keySet().stream().sorted().toList();
}
public static void register(String name, Painter p) {
PAINTERS.put(name, p);
CACHE.keySet().removeIf(k -> k.startsWith(name + "@"));
@@ -0,0 +1,40 @@
package com.eliasmueller.llamamod.editor.tools.geometry;
import static org.junit.jupiter.api.Assertions.assertTrue;
import com.eliasmueller.llamamod.editor.ui.Icons;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.Test;
/** Every vector icon stays inside its 16 × 16 box, so toolbar icons line up. */
class IconBoundsTest {
@Test
void iconsStayInsideTheirBox() {
GeoIcons.register();
List<String> outside = new ArrayList<>();
for (String name : Icons.names()) {
BufferedImage img = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = img.createGraphics();
Icons.get(name, 16).paintIcon(null, g, 8, 8);
g.dispose();
int minY = 32, maxY = -1, minX = 32, maxX = -1;
for (int y = 0; y < 32; y++) {
for (int x = 0; x < 32; x++) {
if ((img.getRGB(x, y) >>> 24) > 40) {
minY = Math.min(minY, y);
maxY = Math.max(maxY, y);
minX = Math.min(minX, x);
maxX = Math.max(maxX, x);
}
}
}
if (maxY >= 0 && (minY < 7 || maxY > 24 || minX < 7 || maxX > 24)) {
outside.add(name + " x " + (minX - 8) + ".." + (maxX - 8) + " y " + (minY - 8) + ".." + (maxY - 8));
}
}
assertTrue(outside.isEmpty(), "icons drawn outside their 16x16 box: " + outside);
}
}