From 181811e039c5dd20b84ca9b4755e4843058309c0 Mon Sep 17 00:00:00 2001 From: ScarletRedMan Date: Mon, 10 Mar 2025 17:31:33 +0700 Subject: [PATCH] feat: added custom background for navigation arrow --- .../api/player/defaults/NavigatorContext.java | 5 +++- .../msb3/api/ui/navigator/Navigators.java | 24 ++++++++++++------ .../resources/glyphs/navigator/background.png | Bin 0 -> 701 bytes 3 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 api/src/main/resources/glyphs/navigator/background.png diff --git a/api/src/main/java/ru/dragonestia/msb3/api/player/defaults/NavigatorContext.java b/api/src/main/java/ru/dragonestia/msb3/api/player/defaults/NavigatorContext.java index 6a8d5b3..7b0dcea 100644 --- a/api/src/main/java/ru/dragonestia/msb3/api/player/defaults/NavigatorContext.java +++ b/api/src/main/java/ru/dragonestia/msb3/api/player/defaults/NavigatorContext.java @@ -27,6 +27,7 @@ public class NavigatorContext extends PlayerContext implements Navigator { private boolean prevTargetEmpty = true; @Setter private String format = "[ %s ]"; @Setter private TextColor textColor = TextColor.color(0xF8FF91); + @Setter private GlyphImage arrowBackground = Navigators.GLYPH_BACKGROUND; public NavigatorContext(MsbPlayer player) { super(player); @@ -80,13 +81,15 @@ public class NavigatorContext extends PlayerContext implements Navigator { var builder = new GlyphComponentBuilder(); + builder.append((int) (arrowBackground.width() / -2.15) + 1, arrowBackground); + // Text if (text != null) { builder.setColorTo(textColor); if (cachedText == null) { 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(); } diff --git a/api/src/main/java/ru/dragonestia/msb3/api/ui/navigator/Navigators.java b/api/src/main/java/ru/dragonestia/msb3/api/ui/navigator/Navigators.java index cf6bec4..15a4e5f 100644 --- a/api/src/main/java/ru/dragonestia/msb3/api/ui/navigator/Navigators.java +++ b/api/src/main/java/ru/dragonestia/msb3/api/ui/navigator/Navigators.java @@ -10,53 +10,61 @@ import ru.dragonestia.msb3.resource.glyph.GlyphImage; public class Navigators { + private final static int ARROW_ASCENT = -5; + public final static GlyphImage GLYPH_UP = Resources.createGlyph( Key.key("msb3", "navigator/up"), ResourceFromJar.of("glyphs/navigator/arrow/up.png"), 16, - 0); + ARROW_ASCENT); public final static GlyphImage GLYPH_UP_RIGHT = Resources.createGlyph( Key.key("msb3", "navigator/up_right"), ResourceFromJar.of("glyphs/navigator/arrow/up_right.png"), 16, - 0); + ARROW_ASCENT); public final static GlyphImage GLYPH_RIGHT = Resources.createGlyph( Key.key("msb3", "navigator/right"), ResourceFromJar.of("glyphs/navigator/arrow/right.png"), 16, - 0); + ARROW_ASCENT); public final static GlyphImage GLYPH_DOWN_RIGHT = Resources.createGlyph( Key.key("msb3", "navigator/down_right"), ResourceFromJar.of("glyphs/navigator/arrow/down_right.png"), 16, - 0); + ARROW_ASCENT); public final static GlyphImage GLYPH_DOWN = Resources.createGlyph( Key.key("msb3", "navigator/down"), ResourceFromJar.of("glyphs/navigator/arrow/down.png"), 16, - 0); + ARROW_ASCENT); public final static GlyphImage GLYPH_DOWN_LEFT = Resources.createGlyph( Key.key("msb3", "navigator/down_left"), ResourceFromJar.of("glyphs/navigator/arrow/down_left.png"), 16, - 0); + ARROW_ASCENT); public final static GlyphImage GLYPH_LEFT = Resources.createGlyph( Key.key("msb3", "navigator/left"), ResourceFromJar.of("glyphs/navigator/arrow/left.png"), 16, - 0); + ARROW_ASCENT); public final static GlyphImage GLYPH_UP_LEFT = Resources.createGlyph( Key.key("msb3", "navigator/up_left"), ResourceFromJar.of("glyphs/navigator/arrow/up_left.png"), 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) { return PlayerContext.of(player, NavigatorContext.class); diff --git a/api/src/main/resources/glyphs/navigator/background.png b/api/src/main/resources/glyphs/navigator/background.png new file mode 100644 index 0000000000000000000000000000000000000000..08178b42f1a192ee4bd408060f61f64e17eebf3a GIT binary patch literal 701 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K595~p3Pw{&M3rEv6n1`&Vc-aHwuzuYB>|fBCuN z_OW{Z^R%1)o;oalF#x1|be zEazEpGiKrWvr!B?U!Bup@!IV2V6|AhgK+DGb?MIOAle_o6!e(NpH1>ScL>a7)dwX9+K_3eT6 z+!HwdS4Z{Z(5#IVB3)RP40`D>$@+y+ambZaa>t< zWy1DC2eyc0&nZ>D4iEoHu;;23Pd_TRj!Wmt<>ChOB#%a&ul0;95}=fa6=