feat: added custom background for navigation arrow

This commit is contained in:
Andrey Terentev 2025-03-10 17:31:33 +07:00
parent b0c71740a3
commit 181811e039
3 changed files with 20 additions and 9 deletions

View File

@ -27,6 +27,7 @@ public class NavigatorContext extends PlayerContext implements Navigator {
private boolean prevTargetEmpty = true; private boolean prevTargetEmpty = true;
@Setter private String format = "[ %s ]"; @Setter private String format = "[ %s ]";
@Setter private TextColor textColor = TextColor.color(0xF8FF91); @Setter private TextColor textColor = TextColor.color(0xF8FF91);
@Setter private GlyphImage arrowBackground = Navigators.GLYPH_BACKGROUND;
public NavigatorContext(MsbPlayer player) { public NavigatorContext(MsbPlayer player) {
super(player); super(player);
@ -80,13 +81,15 @@ public class NavigatorContext extends PlayerContext implements Navigator {
var builder = new GlyphComponentBuilder(); var builder = new GlyphComponentBuilder();
builder.append((int) (arrowBackground.width() / -2.15) + 1, arrowBackground);
// Text // Text
if (text != null) { if (text != null) {
builder.setColorTo(textColor); builder.setColorTo(textColor);
if (cachedText == null) { if (cachedText == null) {
cachedText = MinecraftFont.translateByLineNumber(0, format.formatted(text)); cachedText = MinecraftFont.translateByLineNumber(0, format.formatted(text));
} }
builder.append((int) (cachedText.width() / -2.2), cachedText); builder.append((int) (cachedText.width() / -2.15), cachedText);
builder.resetColor(); builder.resetColor();
} }

View File

@ -10,53 +10,61 @@ import ru.dragonestia.msb3.resource.glyph.GlyphImage;
public class Navigators { public class Navigators {
private final static int ARROW_ASCENT = -5;
public final static GlyphImage GLYPH_UP = Resources.createGlyph( public final static GlyphImage GLYPH_UP = Resources.createGlyph(
Key.key("msb3", "navigator/up"), Key.key("msb3", "navigator/up"),
ResourceFromJar.of("glyphs/navigator/arrow/up.png"), ResourceFromJar.of("glyphs/navigator/arrow/up.png"),
16, 16,
0); ARROW_ASCENT);
public final static GlyphImage GLYPH_UP_RIGHT = Resources.createGlyph( public final static GlyphImage GLYPH_UP_RIGHT = Resources.createGlyph(
Key.key("msb3", "navigator/up_right"), Key.key("msb3", "navigator/up_right"),
ResourceFromJar.of("glyphs/navigator/arrow/up_right.png"), ResourceFromJar.of("glyphs/navigator/arrow/up_right.png"),
16, 16,
0); ARROW_ASCENT);
public final static GlyphImage GLYPH_RIGHT = Resources.createGlyph( public final static GlyphImage GLYPH_RIGHT = Resources.createGlyph(
Key.key("msb3", "navigator/right"), Key.key("msb3", "navigator/right"),
ResourceFromJar.of("glyphs/navigator/arrow/right.png"), ResourceFromJar.of("glyphs/navigator/arrow/right.png"),
16, 16,
0); ARROW_ASCENT);
public final static GlyphImage GLYPH_DOWN_RIGHT = Resources.createGlyph( public final static GlyphImage GLYPH_DOWN_RIGHT = Resources.createGlyph(
Key.key("msb3", "navigator/down_right"), Key.key("msb3", "navigator/down_right"),
ResourceFromJar.of("glyphs/navigator/arrow/down_right.png"), ResourceFromJar.of("glyphs/navigator/arrow/down_right.png"),
16, 16,
0); ARROW_ASCENT);
public final static GlyphImage GLYPH_DOWN = Resources.createGlyph( public final static GlyphImage GLYPH_DOWN = Resources.createGlyph(
Key.key("msb3", "navigator/down"), Key.key("msb3", "navigator/down"),
ResourceFromJar.of("glyphs/navigator/arrow/down.png"), ResourceFromJar.of("glyphs/navigator/arrow/down.png"),
16, 16,
0); ARROW_ASCENT);
public final static GlyphImage GLYPH_DOWN_LEFT = Resources.createGlyph( public final static GlyphImage GLYPH_DOWN_LEFT = Resources.createGlyph(
Key.key("msb3", "navigator/down_left"), Key.key("msb3", "navigator/down_left"),
ResourceFromJar.of("glyphs/navigator/arrow/down_left.png"), ResourceFromJar.of("glyphs/navigator/arrow/down_left.png"),
16, 16,
0); ARROW_ASCENT);
public final static GlyphImage GLYPH_LEFT = Resources.createGlyph( public final static GlyphImage GLYPH_LEFT = Resources.createGlyph(
Key.key("msb3", "navigator/left"), Key.key("msb3", "navigator/left"),
ResourceFromJar.of("glyphs/navigator/arrow/left.png"), ResourceFromJar.of("glyphs/navigator/arrow/left.png"),
16, 16,
0); ARROW_ASCENT);
public final static GlyphImage GLYPH_UP_LEFT = Resources.createGlyph( public final static GlyphImage GLYPH_UP_LEFT = Resources.createGlyph(
Key.key("msb3", "navigator/up_left"), Key.key("msb3", "navigator/up_left"),
ResourceFromJar.of("glyphs/navigator/arrow/up_left.png"), ResourceFromJar.of("glyphs/navigator/arrow/up_left.png"),
16, 16,
0); ARROW_ASCENT);
public final static GlyphImage GLYPH_BACKGROUND = Resources.createGlyph(
Key.key("msb3", "navigator/background"),
ResourceFromJar.of("glyphs/navigator/background.png"),
64,
12);
public static Navigator of(Player player) { public static Navigator of(Player player) {
return PlayerContext.of(player, NavigatorContext.class); return PlayerContext.of(player, NavigatorContext.class);

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B