diff --git a/CHANGELOG.md b/CHANGELOG.md index b7489a57..f55852b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2001.3.0] + +### Changed +* Significant GUI overhaul and cleanup in several places (backported improvements from 1.20.4) + * FTB Library 2001.2.0 is a requirement + ## [2001.2.7] ### Fixed diff --git a/common/src/main/java/dev/ftb/mods/ftbchunks/client/FTBChunksClient.java b/common/src/main/java/dev/ftb/mods/ftbchunks/client/FTBChunksClient.java index a94b1d22..90b612d2 100644 --- a/common/src/main/java/dev/ftb/mods/ftbchunks/client/FTBChunksClient.java +++ b/common/src/main/java/dev/ftb/mods/ftbchunks/client/FTBChunksClient.java @@ -18,12 +18,12 @@ import dev.ftb.mods.ftbchunks.FTBChunks; import dev.ftb.mods.ftbchunks.FTBChunksWorldConfig; import dev.ftb.mods.ftbchunks.api.FTBChunksAPI; -import dev.ftb.mods.ftbchunks.api.client.FTBChunksClientAPI; import dev.ftb.mods.ftbchunks.api.client.event.MapIconEvent; import dev.ftb.mods.ftbchunks.api.client.icon.MapIcon; import dev.ftb.mods.ftbchunks.api.client.icon.MapType; import dev.ftb.mods.ftbchunks.api.client.icon.WaypointIcon; import dev.ftb.mods.ftbchunks.api.client.waypoint.Waypoint; +import dev.ftb.mods.ftbchunks.client.gui.AddWaypointOverlay; import dev.ftb.mods.ftbchunks.client.gui.ChunkScreen; import dev.ftb.mods.ftbchunks.client.gui.LargeMapScreen; import dev.ftb.mods.ftbchunks.client.gui.WaypointEditorScreen; @@ -32,16 +32,20 @@ import dev.ftb.mods.ftbchunks.client.mapicon.*; import dev.ftb.mods.ftbchunks.net.PartialPackets; import dev.ftb.mods.ftbchunks.net.SendGeneralDataPacket.GeneralChunkData; +import dev.ftb.mods.ftblibrary.config.ColorConfig; import dev.ftb.mods.ftblibrary.config.StringConfig; import dev.ftb.mods.ftblibrary.config.ui.EditConfigFromStringScreen; +import dev.ftb.mods.ftblibrary.config.ui.EditStringConfigOverlay; import dev.ftb.mods.ftblibrary.icon.Color4I; import dev.ftb.mods.ftblibrary.icon.FaceIcon; import dev.ftb.mods.ftblibrary.icon.Icon; import dev.ftb.mods.ftblibrary.math.MathUtils; import dev.ftb.mods.ftblibrary.math.XZ; import dev.ftb.mods.ftblibrary.snbt.SNBTCompoundTag; +import dev.ftb.mods.ftblibrary.ui.BaseScreen; import dev.ftb.mods.ftblibrary.ui.CustomClickEvent; import dev.ftb.mods.ftblibrary.ui.GuiHelper; +import dev.ftb.mods.ftblibrary.ui.Theme; import dev.ftb.mods.ftblibrary.ui.input.Key; import dev.ftb.mods.ftblibrary.util.StringUtils; import dev.ftb.mods.ftblibrary.util.client.ClientUtils; @@ -363,7 +367,7 @@ public EventResult keyPressed(Minecraft client, int keyCode, int scanCode, int a public EventResult keyPressed(Minecraft client, Screen screen, int keyCode, int scanCode, int modifiers) { if (doesKeybindMatch(openMapKey, keyCode, scanCode, modifiers)) { LargeMapScreen gui = ClientUtils.getCurrentGuiAs(LargeMapScreen.class); - if (gui != null) { + if (gui != null && !gui.anyModalPanelOpen()) { gui.closeGui(false); return EventResult.interruptTrue(); } @@ -378,16 +382,9 @@ private EventResult addQuickWaypoint() { if (player == null) return EventResult.pass(); return MapManager.getInstance().map(manager -> { - new EditConfigFromStringScreen<>(name, set -> { - if (set && !name.getValue().isEmpty()) { - MapDimension mapDimension = manager.getDimension(player.level().dimension()); - WaypointImpl waypoint = new WaypointImpl(WaypointType.DEFAULT, mapDimension, player.blockPosition()) - .setName(name.getValue()) - .setColor(Color4I.hsb(MathUtils.RAND.nextFloat(), 1F, 1F).rgba()); - mapDimension.getWaypointManager().add(waypoint); - } - openGui(); - }).openGuiLater(); // later needed to prevent keypress being passed into gui + BaseScreen screen = new WaypointAddScreen(name, player); + screen.openGuiLater(); + // later needed to prevent keypress being passed into gui return EventResult.interruptTrue(); }).orElse(EventResult.pass()); } @@ -1163,10 +1160,49 @@ public int getMinimapTextureId() { return minimapTextureId; } - public static void addWaypoint(Player player, String name, BlockPos position, int color) { - FTBChunksAPI.clientApi().getWaypointManager(player.level().dimension()).ifPresent(mgr -> { + public static Waypoint addWaypoint(Player player, String name, BlockPos position, int color) { + return FTBChunksAPI.clientApi().getWaypointManager(player.level().dimension()).map(mgr -> { Waypoint wp = mgr.addWaypointAt(position, name); wp.setColor(color); - }); + return wp; + }).orElse(null); + } + + private static class WaypointAddScreen extends BaseScreen { + private final StringConfig name; + private final Player player; + + public WaypointAddScreen(StringConfig name, Player player) { + super(); + this.name = name; + this.player = player; + this.setHeight(35); + } + + @Override + public void drawBackground(GuiGraphics graphics, Theme theme, int x, int y, int w, int h) { + } + + @Override + public void addWidgets() { + ColorConfig col = new ColorConfig(); + col.setValue(Color4I.hsb(MathUtils.RAND.nextFloat(), 1F, 1F)); + AddWaypointOverlay overlay = new AddWaypointOverlay(this, name, col, set -> { + if (set && !name.getValue().isEmpty()) { + Waypoint wp = addWaypoint(player, name.getValue(), player.blockPosition(), col.getValue().rgba()); + Minecraft.getInstance().player.displayClientMessage( + Component.translatable("ftbchunks.waypoint_added", + Component.literal(wp.getName()).withStyle(ChatFormatting.YELLOW) + ), true); + } + }) { + @Override + public void onClosed() { + closeGui(); + } + }; + overlay.setWidth(this.width); + pushModalPanel(overlay); + } } } diff --git a/common/src/main/java/dev/ftb/mods/ftbchunks/client/gui/AddWaypointOverlay.java b/common/src/main/java/dev/ftb/mods/ftbchunks/client/gui/AddWaypointOverlay.java new file mode 100644 index 00000000..aa6fa050 --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbchunks/client/gui/AddWaypointOverlay.java @@ -0,0 +1,58 @@ +package dev.ftb.mods.ftbchunks.client.gui; + +import dev.ftb.mods.ftblibrary.config.ColorConfig; +import dev.ftb.mods.ftblibrary.config.ConfigCallback; +import dev.ftb.mods.ftblibrary.config.ConfigFromString; +import dev.ftb.mods.ftblibrary.config.ui.EditStringConfigOverlay; +import dev.ftb.mods.ftblibrary.icon.Color4I; +import dev.ftb.mods.ftblibrary.icon.Icon; +import dev.ftb.mods.ftblibrary.ui.*; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; + +public class AddWaypointOverlay extends EditStringConfigOverlay { + private final ColorButton colorButton; + + public AddWaypointOverlay(Panel panel, ConfigFromString config, ColorConfig colorConfig, ConfigCallback callback) { + super(panel, config, callback, Component.translatable("ftbchunks.gui.add_waypoint")); + + colorButton = new ColorButton(colorConfig.getValue(), (btn, mb) -> { + ColorSelectorPanel.popupAtMouse(getGui(), colorConfig, accepted -> { + if (accepted) { + btn.setIcon(colorConfig.getValue()); + } else { + colorConfig.setValue(((ColorButton) btn).getIcon()); + } + }); + }); + } + + @Override + public void addWidgets() { + super.addWidgets(); + add(colorButton); + } + + @Override + public void alignWidgets() { + super.alignWidgets(); + colorButton.setPosAndSize(width - 11, 1, 10, 10); + } + + private class ColorButton extends SimpleButton { + public ColorButton(Icon icon, Callback c) { + super(AddWaypointOverlay.this, Component.empty(), icon, c); + } + + Color4I getIcon() { + return icon instanceof Color4I c ? c : Color4I.empty(); + } + + @Override + public void draw(GuiGraphics graphics, Theme theme, int x, int y, int w, int h) { + icon.draw(graphics, x, y, w, h); + Color4I shade = getIcon().addBrightness(-0.15f); + GuiHelper.drawHollowRect(graphics, x, y, w, h, shade, false); + } + } +} diff --git a/common/src/main/java/dev/ftb/mods/ftbchunks/client/gui/ChunkScreen.java b/common/src/main/java/dev/ftb/mods/ftbchunks/client/gui/ChunkScreen.java index af48d0e7..f1710d69 100644 --- a/common/src/main/java/dev/ftb/mods/ftbchunks/client/gui/ChunkScreen.java +++ b/common/src/main/java/dev/ftb/mods/ftbchunks/client/gui/ChunkScreen.java @@ -22,6 +22,7 @@ import dev.ftb.mods.ftblibrary.ui.*; import dev.ftb.mods.ftblibrary.ui.input.Key; import dev.ftb.mods.ftblibrary.ui.input.MouseButton; +import dev.ftb.mods.ftblibrary.ui.misc.KeyReferenceScreen; import dev.ftb.mods.ftblibrary.util.TimeUtils; import dev.ftb.mods.ftblibrary.util.TooltipList; import dev.ftb.mods.ftbteams.api.property.TeamProperties; @@ -92,6 +93,7 @@ public void addWidgets() { int startX = chunkPos.x - FTBChunks.TILE_OFFSET; int startZ = chunkPos.z - FTBChunks.TILE_OFFSET; + chunkButtons.clear(); for (int z = 0; z < FTBChunks.TILES; z++) { for (int x = 0; x < FTBChunks.TILES; x++) { ChunkButton button = new ChunkButton(this, XZ.of(startX + x, startZ + z)); @@ -104,9 +106,14 @@ public void addWidgets() { new RequestMapDataPacket(chunkPos.x - FTBChunks.TILE_OFFSET, chunkPos.z - FTBChunks.TILE_OFFSET, chunkPos.x + FTBChunks.TILE_OFFSET, chunkPos.z + FTBChunks.TILE_OFFSET ).sendToServer(); + add(new SimpleButton(this, Component.translatable("ftbchunks.gui.large_map"), Icons.MAP, (simpleButton, mouseButton) -> LargeMapScreen.openMap() ).setPosAndSize(1, 1, 16, 16)); + + add(new SimpleButton(this, Component.translatable("ftbchunks.gui.chunk_info"), Icons.INFO, + (btn, mb) -> new ChunkMouseReferenceScreen().openGui() + ).setPosAndSize(1, 19, 16, 16)); } @Override @@ -170,6 +177,17 @@ public void drawBackground(GuiGraphics graphics, Theme theme, int x, int y, int } } + private static class ChunkMouseReferenceScreen extends KeyReferenceScreen { + public ChunkMouseReferenceScreen() { + super("ftbchunks.gui.chunk_info.text"); + } + + @Override + public Component getTitle() { + return Component.translatable("ftbchunks.gui.chunk_info"); + } + } + private class ChunkButton extends Button { private final XZ chunkPos; private final MapChunk chunk; @@ -258,24 +276,7 @@ public boolean mouseScrolled(double scroll) { int dir = (int) Math.signum(scroll); long now = System.currentTimeMillis(); Date expiry = chunk.getForceLoadExpiryDate().orElse(new Date(now)); - long offset = (expiry.getTime() - now) / 1000L; - if (dir == 1) { - if (offset < 86400L) { - offset = offset + 3600L; // hour - } else if (offset < 604800L) { - offset = offset + 86400L; // day - } else { - offset = offset + 604800L; // week - } - } else if (dir == -1) { - if (offset <= 86400L) { - offset = Math.max(0L, offset - 3600L); - } else if (offset <= 604800L) { - offset = Math.max(86400L, offset - 86400L); - } else { - offset = Math.max(604800L, offset - 604800L); - } - } + long offset = calcOffset(expiry, now, dir); chunk.updateForceLoadExpiryDate(now, offset * 1000L); lastAdjust = now; return true; @@ -284,6 +285,28 @@ public boolean mouseScrolled(double scroll) { }).orElse(super.mouseScrolled(scroll)); } + private static long calcOffset(Date expiry, long now, int dir) { + long offset = (expiry.getTime() - now) / 1000L; + if (dir == 1) { + if (offset < 86400L) { + offset = offset + 3600L; // hour + } else if (offset < 604800L) { + offset = offset + 86400L; // day + } else { + offset = offset + 604800L; // week + } + } else if (dir == -1) { + if (offset <= 86400L) { + offset = Math.max(0L, offset - 3600L); + } else if (offset <= 604800L) { + offset = Math.max(86400L, offset - 86400L); + } else { + offset = Math.max(604800L, offset - 604800L); + } + } + return offset; + } + @Override public void tick() { super.tick(); diff --git a/common/src/main/java/dev/ftb/mods/ftbchunks/client/gui/LargeMapScreen.java b/common/src/main/java/dev/ftb/mods/ftbchunks/client/gui/LargeMapScreen.java index 4554a032..8bd90a04 100644 --- a/common/src/main/java/dev/ftb/mods/ftbchunks/client/gui/LargeMapScreen.java +++ b/common/src/main/java/dev/ftb/mods/ftbchunks/client/gui/LargeMapScreen.java @@ -8,8 +8,8 @@ import dev.ftb.mods.ftbchunks.client.map.*; import dev.ftb.mods.ftbchunks.net.TeleportFromMapPacket; import dev.ftb.mods.ftbchunks.util.HeightUtils; +import dev.ftb.mods.ftblibrary.config.ColorConfig; import dev.ftb.mods.ftblibrary.config.StringConfig; -import dev.ftb.mods.ftblibrary.config.ui.EditConfigFromStringScreen; import dev.ftb.mods.ftblibrary.icon.Color4I; import dev.ftb.mods.ftblibrary.icon.Icon; import dev.ftb.mods.ftblibrary.icon.Icons; @@ -18,6 +18,7 @@ import dev.ftb.mods.ftblibrary.ui.*; import dev.ftb.mods.ftblibrary.ui.input.Key; import dev.ftb.mods.ftblibrary.ui.input.MouseButton; +import dev.ftb.mods.ftblibrary.ui.misc.KeyReferenceScreen; import dev.ftb.mods.ftblibrary.util.StringUtils; import dev.ftb.mods.ftblibrary.util.TooltipList; import net.minecraft.ChatFormatting; @@ -54,6 +55,7 @@ public class LargeMapScreen extends BaseScreen { private Button claimChunksButton; private Button dimensionButton; private Button waypointManagerButton; + private Button infoButton; private Button settingsButton; private Button serverSettingsButton; private Button clearDeathpointsButton; @@ -77,6 +79,11 @@ public static void openMap() { ); } + @Override + public Theme getTheme() { + return NordTheme.THEME; + } + @Override public void onClosed() { super.onClosed(); @@ -131,6 +138,8 @@ public void addWidgets() { .append(Component.literal("]")).withStyle(ChatFormatting.GRAY); add(waypointManagerButton = new SimpleTooltipButton(this, Component.translatable("ftbchunks.gui.waypoints"), Icons.COMPASS, (b, m) -> new WaypointEditorScreen().openGui(), tooltip)); + add(infoButton = new SimpleButton(this, Component.translatable("ftbchunks.gui.large_map_info"), Icons.INFO, + (b, m) -> new MapKeyReferenceScreen().openGui())); add(clearDeathpointsButton = new ClearDeathPointButton(this)); @@ -183,7 +192,8 @@ public void alignWidgets() { claimChunksButton.setPosAndSize(1, 1, 16, 16); waypointManagerButton.setPosAndSize(1, 19, 16, 16); - clearDeathpointsButton.setPosAndSize(1, 37, 16, 16); + infoButton.setPosAndSize(1, 37, 16, 16); + clearDeathpointsButton.setPosAndSize(1, 55, 16, 16); dimensionButton.setPosAndSize(1, height - 36, 16, 16); settingsButton.setPosAndSize(1, height - 18, 16, 16); @@ -210,19 +220,23 @@ public boolean mousePressed(MouseButton button) { } else if (button.isRight()) { final BlockPos pos = new BlockPos(regionPanel.blockX, regionPanel.blockY, regionPanel.blockZ); List list = new ArrayList<>(); - list.add(new ContextMenuItem(Component.translatable("ftbchunks.gui.add_waypoint"), Icons.ADD, () -> { + list.add(new ContextMenuItem(Component.translatable("ftbchunks.gui.add_waypoint"), Icons.ADD, btn -> { StringConfig name = new StringConfig(); - new EditConfigFromStringScreen<>(name, set -> { - if (set) { - WaypointImpl waypoint = new WaypointImpl(WaypointType.DEFAULT, dimension, pos) - .setName(name.getValue()) - .setColor(Color4I.hsb(MathUtils.RAND.nextFloat(), 1F, 1F).rgba()); - dimension.getWaypointManager().add(waypoint); - refreshWidgets(); - } - - openGui(); - }).openGui(); + name.setValue(""); + ColorConfig col = new ColorConfig(); + col.setValue(Color4I.hsb(MathUtils.RAND.nextFloat(), 1F, 1F)); + var overlay = new AddWaypointOverlay(getGui(), name, col, accepted -> { + if (accepted) { + WaypointImpl waypoint = new WaypointImpl(WaypointType.DEFAULT, dimension, pos) + .setName(name.getValue()) + .setColor(col.getValue().rgba()); + dimension.getWaypointManager().add(waypoint); + refreshWidgets(); + } + }).atMousePosition(); + overlay.setWidth(150); + overlay.setX(Math.min(overlay.getX(), getScreen().getGuiScaledWidth() - 155)); + getGui().pushModalPanel(overlay); })); openContextMenu(list); return true; @@ -233,18 +247,11 @@ public boolean mousePressed(MouseButton button) { @Override public boolean keyPressed(Key key) { - if (FTBChunksClient.doesKeybindMatch(FTBChunksClient.INSTANCE.openMapKey, key) || key.escOrInventory()) { - if (key.esc() && getContextMenu().isPresent()) { - closeContextMenu(); - } else { - closeGui(false); - } + if (super.keyPressed(key)) { return true; } else if (key.is(GLFW.GLFW_KEY_SPACE)) { movedToPlayer = false; return true; - } else if (super.keyPressed(key)) { - return true; } else if (key.is(GLFW.GLFW_KEY_T)) { new TeleportFromMapPacket(regionPanel.blockPos().above(), regionPanel.blockY == HeightUtils.UNKNOWN, dimension.dimension).sendToServer(); closeGui(false); @@ -446,6 +453,17 @@ public void addMouseOverText(TooltipList list) { } } + private static class MapKeyReferenceScreen extends KeyReferenceScreen { + public MapKeyReferenceScreen() { + super("ftbchunks.gui.large_map_info.text"); + } + + @Override + public Component getTitle() { + return Component.translatable("ftbchunks.gui.large_map_info"); + } + } + private class ClearDeathPointButton extends SimpleButton { public ClearDeathPointButton(Panel panel) { super(panel, Component.translatable("ftbchunks.gui.clear_deathpoints"), Icons.CLOSE, (b, m) -> { @@ -465,4 +483,5 @@ public boolean isEnabled() { return shouldDraw(); } } + } diff --git a/common/src/main/java/dev/ftb/mods/ftbchunks/client/gui/WaypointEditorScreen.java b/common/src/main/java/dev/ftb/mods/ftbchunks/client/gui/WaypointEditorScreen.java index 89f63bca..41c09735 100644 --- a/common/src/main/java/dev/ftb/mods/ftbchunks/client/gui/WaypointEditorScreen.java +++ b/common/src/main/java/dev/ftb/mods/ftbchunks/client/gui/WaypointEditorScreen.java @@ -4,6 +4,7 @@ import dev.ftb.mods.ftbchunks.client.map.MapManager; import dev.ftb.mods.ftbchunks.client.map.WaypointImpl; import dev.ftb.mods.ftbchunks.net.TeleportFromMapPacket; +import dev.ftb.mods.ftblibrary.config.ColorConfig; import dev.ftb.mods.ftblibrary.config.StringConfig; import dev.ftb.mods.ftblibrary.icon.Color4I; import dev.ftb.mods.ftblibrary.icon.Icon; @@ -136,7 +137,7 @@ public void alignWidgets() { @Override public Theme getTheme() { - return THEME; + return super.getTheme(); } @Override @@ -283,11 +284,11 @@ public boolean mousePressed(MouseButton button) { list.add(makeTitleMenuItem()); list.add(ContextMenuItem.SEPARATOR); - list.add(new ContextMenuItem(Component.translatable("gui.rename"), Icons.CHAT, () -> { + list.add(new ContextMenuItem(Component.translatable("gui.rename"), Icons.CHAT, btn -> { StringConfig config = new StringConfig(); config.setDefaultValue(""); config.setValue(wp.getName()); - config.onClicked(MouseButton.LEFT, accepted -> { + config.onClicked(btn, MouseButton.LEFT, accepted -> { if (accepted) { wp.setName(config.getValue()); } @@ -295,28 +296,28 @@ public boolean mousePressed(MouseButton button) { }); })); if (wp.getType().canChangeColor()) { - list.add(new ContextMenuItem(Component.translatable("ftbchunks.gui.change_color"), Icons.COLOR_RGB, () -> { - int r = (wp.getColor() >> 16) & 0xFF; - int g = (wp.getColor() >> 8) & 0xFF; - int b = wp.getColor() & 0xFF; - float[] hsb = Color.RGBtoHSB(r, g, b, new float[3]); - float add = isShiftKeyDown() ? -1F/12F : 1F/12F; - Color4I col = Color4I.hsb(hsb[0] + add, hsb[1], hsb[2]); - wp.setColor(col.rgba()); - wp.refreshIcon(); - if (widgets.get(1) instanceof TextField tf) { - tf.setColor(Color4I.rgb(wp.getColor())); - } - }).setCloseMenu(false)); + list.add(new ContextMenuItem(Component.translatable("ftbchunks.gui.change_color"), Icons.COLOR_RGB, btn -> { + ColorConfig col = new ColorConfig(); + col.setValue(Color4I.rgb(wp.getColor())); + ColorSelectorPanel.popupAtMouse(btn.getGui(), col, accepted -> { + if (accepted) { + wp.setColor(col.getValue().rgba()); + wp.refreshIcon(); + if (widgets.get(1) instanceof TextField tf) { + tf.setColor(Color4I.rgb(wp.getColor())); + } + } + }); + })); } if (Minecraft.getInstance().player.hasPermissions(2)) { // permissions are checked again on server! - list.add(new ContextMenuItem(Component.translatable("ftbchunks.gui.teleport"), PEARL_ICON, () -> { + list.add(new ContextMenuItem(Component.translatable("ftbchunks.gui.teleport"), PEARL_ICON, btn -> { BlockPos pos = wp.getPos().above(); new TeleportFromMapPacket(pos, false, wp.getDimension()).sendToServer(); closeGui(false); })); } - list.add(new ContextMenuItem(Component.translatable("gui.remove"), Icons.REMOVE, () -> { + list.add(new ContextMenuItem(Component.translatable("gui.remove"), Icons.REMOVE, btn -> { getGui().openYesNo(Component.translatable("ftbchunks.gui.delete_waypoint", Component.literal(wp.getName()) .withStyle(Style.EMPTY.withColor(wp.getColor()))), Component.empty(), () -> { wp.removeFromManager(); @@ -333,7 +334,7 @@ public boolean mousePressed(MouseButton button) { } private ContextMenuItem makeTitleMenuItem() { - return new ContextMenuItem(Component.literal(wp.getName()), Icon.empty(), () -> {}) { + return new ContextMenuItem(Component.literal(wp.getName()), Icon.empty(), null) { @Override public Icon getIcon() { return wp.getType().getIcon().withTint(Color4I.rgb(wp.getColor())); diff --git a/common/src/main/java/dev/ftb/mods/ftbchunks/client/mapicon/WaypointMapIcon.java b/common/src/main/java/dev/ftb/mods/ftbchunks/client/mapicon/WaypointMapIcon.java index 766a31cf..865f25c3 100644 --- a/common/src/main/java/dev/ftb/mods/ftbchunks/client/mapicon/WaypointMapIcon.java +++ b/common/src/main/java/dev/ftb/mods/ftbchunks/client/mapicon/WaypointMapIcon.java @@ -5,6 +5,7 @@ import dev.ftb.mods.ftbchunks.api.client.icon.WaypointIcon; import dev.ftb.mods.ftbchunks.client.gui.LargeMapScreen; import dev.ftb.mods.ftbchunks.client.map.WaypointImpl; +import dev.ftb.mods.ftblibrary.config.ColorConfig; import dev.ftb.mods.ftblibrary.config.StringConfig; import dev.ftb.mods.ftblibrary.icon.Color4I; import dev.ftb.mods.ftblibrary.icon.Icon; @@ -12,6 +13,7 @@ import dev.ftb.mods.ftblibrary.icon.ImageIcon; import dev.ftb.mods.ftblibrary.math.MathUtils; import dev.ftb.mods.ftblibrary.ui.BaseScreen; +import dev.ftb.mods.ftblibrary.ui.ColorSelectorPanel; import dev.ftb.mods.ftblibrary.ui.ContextMenuItem; import dev.ftb.mods.ftblibrary.ui.Widget; import dev.ftb.mods.ftblibrary.ui.input.Key; @@ -96,10 +98,10 @@ private void openWPContextMenu(LargeMapScreen screen) { contextMenu.add(makeTitleMenuItem()); contextMenu.add(ContextMenuItem.SEPARATOR); - contextMenu.add(new ContextMenuItem(Component.translatable("gui.rename"), Icons.CHAT, () -> { + contextMenu.add(new ContextMenuItem(Component.translatable("gui.rename"), Icons.CHAT, b -> { StringConfig config = new StringConfig(); config.setValue(waypoint.getName()); - config.onClicked(MouseButton.LEFT, accepted -> { + config.onClicked(b, MouseButton.LEFT, accepted -> { if (accepted) { waypoint.setName(config.getValue()); } @@ -108,26 +110,26 @@ private void openWPContextMenu(LargeMapScreen screen) { })); if (waypoint.getType().canChangeColor()) { - contextMenu.add(new ContextMenuItem(Component.translatable("ftbchunks.gui.change_color"), Icons.COLOR_RGB, () -> { - int r = (waypoint.getColor() >> 16) & 0xFF; - int g = (waypoint.getColor() >> 8) & 0xFF; - int b = waypoint.getColor() & 0xFF; - float[] hsb = Color.RGBtoHSB(r, g, b, new float[3]); - float add = Widget.isShiftKeyDown() ? -1F/12F : 1F/12F; - Color4I col = Color4I.hsb(hsb[0] + add, hsb[1], hsb[2]); - waypoint.setColor(col.rgba()); - icon = Color4I.empty(); - outsideIcon = Color4I.empty(); - checkIcon(); - }).setCloseMenu(false)); + contextMenu.add(new ContextMenuItem(Component.translatable("ftbchunks.gui.change_color"), Icons.COLOR_RGB, btn -> { + ColorConfig col = new ColorConfig(); + col.setValue(Color4I.rgb(waypoint.getColor())); + ColorSelectorPanel.popupAtMouse(btn.getGui(), col, accepted -> { + if (accepted) { + waypoint.setColor(col.getValue().rgba()); + icon = Color4I.empty(); + outsideIcon = Color4I.empty(); + checkIcon(); + } + }); + })); } - contextMenu.add(new ContextMenuItem(Component.translatable("ftbchunks.label." + (waypoint.isHidden() ? "show" : "hide")), Icons.BEACON, () -> { + contextMenu.add(new ContextMenuItem(Component.translatable("ftbchunks.label." + (waypoint.isHidden() ? "show" : "hide")), Icons.BEACON, b -> { waypoint.setHidden(!waypoint.isHidden()); screen.refreshWidgets(); })); - contextMenu.add(new ContextMenuItem(Component.translatable("gui.remove"), Icons.REMOVE, () -> { + contextMenu.add(new ContextMenuItem(Component.translatable("gui.remove"), Icons.REMOVE, b -> { waypoint.removeFromManager(); screen.refreshIcons(); })); @@ -136,7 +138,7 @@ private void openWPContextMenu(LargeMapScreen screen) { } private ContextMenuItem makeTitleMenuItem() { - return new ContextMenuItem(Component.literal(waypoint.getName()), icon, () -> {}) { + return new ContextMenuItem(Component.literal(waypoint.getName()), icon, null) { @Override public Icon getIcon() { return icon; diff --git a/common/src/main/resources/assets/ftbchunks/lang/en_us.json b/common/src/main/resources/assets/ftbchunks/lang/en_us.json index d4fb6e55..b31e0e65 100644 --- a/common/src/main/resources/assets/ftbchunks/lang/en_us.json +++ b/common/src/main/resources/assets/ftbchunks/lang/en_us.json @@ -90,6 +90,7 @@ "wilderness": "Wilderness", "ftbchunks.no_server_mod": "FTB Chunks requires mod on server!", "ftbchunks.already_claimed": "Chunk is already claimed by %s", + "ftbchunks.waypoint_added": "Waypoint '%s' added", "ftbchunks.deathpoint_removed": "Waypoint '%s' auto-removed", "ftbchunks.gui.claimed": "Claimed", "ftbchunks.gui.force_loaded": "Force loaded", @@ -110,6 +111,10 @@ "ftbchunks.gui.hold_alt_for_dates": "Hold Alt: show absolute times", "ftbchunks.gui.mouse_wheel_expiry": "Mouse Wheel: adjust force-load expiry", "ftbchunks.gui.teleport": "Teleport", + "ftbchunks.gui.large_map_info": "Key/Mouse Reference", + "ftbchunks.gui.large_map_info.text": "Mouse\nLeft Button;Click/Drag to move map view\nRight Button;Context Menu\nMouse Wheel;Rotate to zoom\n\nKeys\nSpace;Center view on player\nC;Open chunk claim screen\nT;Teleport to point (op required)\nS;Open settings screen\nCtrl + S;Open server settings screen (op required)\nF3+G;Toggle Chunk Grid", + "ftbchunks.gui.chunk_info": "Chunk Claiming Reference", + "ftbchunks.gui.chunk_info.text": "Claiming\nLeft Button;Drag to claim an area\nRight Button;Drag to unclaim an area\n\nForceloading\nShift + Left Button;Drag to forceload an area\nShift + Right Button;Drag to unforceload an area\nMouse Wheel;Rotate on forceloaded chunk to adjust auto-expiry\n\nMisc\nTab;Hold to hide chunk grid\nAlt;Hold to show absolute chunk claim/force times", "ftbteamsconfig.ftbchunks": "FTB Chunks Properties", "ftbteamsconfig.ftbchunks.allow_fake_players": "Allow All Fake Players", "ftbteamsconfig.ftbchunks.allow_fake_players.tooltip": "Treat ALL fake players as allies of the team.\nWARNING: Setting this to true could allow hostile players to access your claims via any fake player. Set this to false if you're unsure.", diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 2511b986..32b4f95c 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -31,8 +31,5 @@ "architectury": ">=${archversion}", "ftblibrary": ">=${ftblibraryversion}", "ftbteams": ">=${ftbteamsversion}" - }, - "breaks": { - "ftblibrary": ">=2001.2.0" } } diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index a705ec39..e3661f5d 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -38,7 +38,7 @@ side = "BOTH" [[dependencies.ftbchunks]] modId = "ftblibrary" mandatory = true -versionRange = "[${ftblibraryversion},2001.2.0)" +versionRange = "[${ftblibraryversion},)" ordering = "AFTER" side = "BOTH" diff --git a/gradle.properties b/gradle.properties index 283c57f1..d85f3d1e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,17 +5,17 @@ org.gradle.daemon=false mod_id=ftbchunks archives_base_name=ftb-chunks maven_group=dev.ftb.mods -mod_version=2001.2.7 +mod_version=2001.3.0 mod_author=FTB Team minecraft_version=1.20.1 -forge_version=47.1.3 +forge_version=47.1.47 architectury_version=9.1.12 fabric_loader_version=0.14.21 fabric_api_version=0.83.1+1.20.1 -ftb_library_version=2001.1.3 -ftb_teams_version=2001.1.4 +ftb_library_version=2001.2.0 +ftb_teams_version=2001.3.0 curseforge_id_forge=314906 curseforge_id_fabric=472657